Initiate Transaction

Method: POST

Create a Payment Initialization class object and call initiate transaction method by passing the parameters mentioned in the request parameters table.

PayU’s POS terminals support two types of transaction as follows:

  • Sale
    Customer can use debit or credit card in Sale mode and make transaction “N” number of times. For Sale Transaction, Amount should above Rs. 1000/- (check test cases) in UAT Environment. For production amount should be Minimum of Rs. 5/-.
  • EMI
    Customer can use credit card in EMI mode and make transaction “N” number of times. To support EMI
    transaction type please refer EMI Transaction APIs

❗️

Watch Out

Request parameters are consistent for all types of transaction . Only the transactionType parameter will be changed with the corresponding transaction type.

Request parameters

ParameterDescriptionExample
Handler

mandatory
handler Handlers are used for sending and receiving the data within the two classes.handler
Device type

mandatory
string The name of the bluetooth of the respective device.DeviceType.ME30S
Address

mandatory
string The bluetooth address incase of MAC devices.
Amount
mandatory
string The amount that is being transacted.11.00
Transaction type

mandatory
string The type of the transaction.PaymentTransactionConst ants.SALE/EMI
Payment Type

mandatory
string Type of payment is POS for Mobile POS devices.(PayU have multiple payment types like POS,Wallet,qr.)PaymentTransactionConst ants.POS
Mobile Number
Optional
string The mobile number of the customer.9000000000
Name
Optional
string The name of the customer.
Latitude
Optional
double Geolocation where the transaction took place.71.000001
Longitude
Optional
double Geolocation where the transaction took place.17.0000001
Merchant reference number

mandatory
string Merchant Invoice Reference Number or pass current date time stamp. [Max upto 40 characters].123456
Cash back amount

Optional
string Pass cash back amount only for SALE WITH CASH BACK transaction type otherwise pass null value.null
deviceCommMode

Optional
int Select device communication mode. It’s only applicable for QPOS device rest all devices can be ‘N’.DeviceCommunicationMode.BLUETOOTHCOMMUNICATION
orderReferenceNo

Optional
string Order reference no (only for PayUs internal apps)
appName

Optional
string The name of the app.
appVersion
Optional
string The version of the app.

Sample request

try {
  initialization = new PaymentInitialization(
    PaymentTransactionActivity.this);
  initialization.initiateTransaction(handler, deviceName, address, amount,
    paymentType, PaymentTransactionConstants.POS, null, null, 71.000001, 17.000001,
    merchantRefNo, null, deviceCommMode, merchantRefNo, null, null);
} catch (RuntimeException e) {
  e.printStackTrace();
}

Response parameters

ParameterDescriptionExample
ICCTransactionRes
ponse
objectICCTransactionRespons returns a list of transaction details such as transactionStatus, responseMessaege etc.Refer to ICCTRANSACTIONRESPONS payload objects.

Sample response

Use this code to fetch the response of this API.

@SuppressLint("HandlerLeak")
private final Handler handler = new Handler() {
    public void handleMessage(android.os.Message msg) {
        checkFlag = true;
        if (msg.what == SOCKET_NOT_CONNECTED) {
          alertMessage((String) msg.obj);
        }
        i
        f(msg.what == QPOS_ID) {
          Toast.makeText(PaymentTransactionActivity.this, (String) msg.obj,
            Toast.LENGTH_LONG).show();
        } else if (msg.what == CHIP_TRANSACTION_APPROVED ||
          msg.what == SWIP_TRANSACTION_APPROVED) {
          ICCTransactionResponse iCCTransactionResponse = (ICCTransactionResponse)
          msg.obj;
          if (iCCTransactionResponse.isSignatureRequired()) {
            Intent i = new Intent(PaymentTransactionActivity.this,
              SignatureCaptureActivity.class);
            i.putExtra("vo", iCCTransactionResponse);
            //mpaysdk 2.0
            i.putExtra("paymentType", paymentType);
            finish();
            PaymentTransactionActivity.this.startActivity(i);
          } else {
            Intent i = new Intent(PaymentTransactionActivity.this,
              TransactionDetails.class);
            i.putExtra("vo", iCCTransactionResponse);
            //mpaysdk 2.0
            i.putExtra("paymentType", paymentType);;
            f
            inish();
            PaymentTransactionActivity.this.startActivity(i);
          }
        } else if (msg.what == CHIP_TRANSACTION_DECLINED ||
          msg.what == SWIP_TRANSACTION_DECLINED) {
          ICCTransactionResponse vo = (ICCTransactionResponse) msg.obj;
          Intent i = new Intent(PaymentTransactionActivity.this, TransactionDetails.class);
          i.putExtra("vo", vo);
          i.putExtra("paymentType", paymentType);
          PaymentTransactionActivity.this.startActivity(i);
          Toast.makeText(PaymentTransactionActivity.this, "Transaction Status : " +
            vo.getResponseCode() + ":" + vo.getResponseMessage(), Toast.LENGTH_LONG).show();
          finish();
        } else if (msg.what == QPOS_DEVICE) {
          alertMessage((String) msg.obj);
        } else if (msg.what == TRANSACTION_FAILED) {
          ICCTransactionResponse vo = (ICCTransactionResponse) msg.obj;
          if (paymentType.equalsIgnoreCase(EMI)) {
            Intent i = new Intent(PaymentTransactionActivity.this,
              TransactionDetails.class);
            i.putExtra("vo", vo);
            i.putExtra("paymentType", paymentType);
            PaymentTransactionActivity.this.startActivity(i);
            Toast.makeText(PaymentTransactionActivity.this, "Transaction Status :
              " + vo.getResponseCode() + ": " + vo.getResponseMessage(), Toast.LENGTH_LONG).show();
              finish();
            }
            else {
              Toast.makeText(PaymentTransactionActivity.this, "Transaction Status :
                " + vo.getResponseCode() + ": " + vo.getResponseMessage(), Toast.LENGTH_LONG).show();
                finish();
              }
            } else if (msg.what == TRANSACTION_INITIATED) {
              Toast.makeText(PaymentTransactionActivity.this, msg.obj.toString(), Toast.LE NGTH_LONG).show();
            } else if (msg.what == ERROR_MESSAGE) {
              alertMessage((String) msg.obj);
            } else if (msg.what == TRANSACTION_PENDING) {
              Toast.makeText(PaymentTransactionActivity.this,
                (String) msg.obj + "Pending status",
                Toast.LENGTH_SHORT).show();
              finish();
            } else if (msg.what == DISPLAY_STATUS) {
              Toast.makeText(PaymentTransactionActivity.this,
                (String) msg.obj, Toast.LENGTH_SHORT).show();
            } else if (msg.what == QPOS_EMV_MULITPLE_APPLICATION) {
              ArrayList < String > applicationList = (ArrayList < String > ) msg.obj;
              emvList = (ListView) findViewById(R.id.application_list);
              emvList.setVisibility(View.VISIBLE);
              ArrayAdapter < String > adapter = new
              ArrayAdapter < String > (PaymentTransactionActivity.this,
                android.R.layout.simple_list_item_1, applicationList);
              emvList.setAdapter(adapter);
              emvList.setOnItemClickListener(new OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView < ? > parent, View view,
                  int position, long id) {
                  if (initialization != null) {
                    initialization.getQposListener().executeSelectedEMVApplication(position);
                    emvList.setVisibility(View.GONE);
                  }
                }
              });
            } else if (msg.what == SUCCESS) {
              Toast.makeText(PaymentTransactionActivity.this,
                (String) msg.obj, Toast.LENGTH_SHORT).show();
              Intent i = new Intent(PaymentTransactionActivity.this,
                MainActivity.class);
              finish();
              PaymentTransactionActivity.this.startActivity(i);
            }
          }
        };