Custom UI- Android – PayU Documentation

Custom UI Android

Pre-requisites

1. A mobile app to accept payments.

Steps Involved

 

  1. Import the .aar file as module
  2. Collect all the common parameters that needs to be send to the SDK.
  3. Make an API call
  4. Collect additional parameters depending on the mode chosen by user
  5. Create payments activity and submit it to web view
  6. Accept payment response as provided by SDK

Importing .aar file as a module

 

You need to follow the below mentioned steps to import the .aar file.

Collecting all common parameters

 

Following are the common parameters, common to all the payment modes, to get a transaction  initiated

Parameters Description Data type Character Limit Example
key Unique key provided by Payu varchar 20 characters C0Ds8q
txnid Transaction id/ reference id generated at your end varchar 25 characters fd3e847h2
amount Amount payable by customer number, float, double 2 digits after decimel 10.00
productinfo Small description of product, a string defining your product varchar 100 characters tshirt100
firstname First name of customer varchar 60 characters Ankit
email                          Email id of customer varchar 50 test@gmail.com
phone Phone number of customer varchar 50 (numeric) 9999999999
surl Redirect URL (your site) in case of a successful transaction  HTTP url  mediumtext success@yoursite.com
furl Redirect URL (your site) in case of a failed transaction  HTTP url  mediumtext failure@yoursite.com
hash Security parameter to avoid tampering  SHA512  varchar(256)

How to generate hash?

 

Hash is a security parameter to avoid tampering. You have to  calculate it from  your server and post it to PayU server  for each transaction and for each API call.

Sample code to generate hash at app side:

Sample code to generate hash at server side:

Making an API call

 

You will have to make an API call to fetch all the available payment options for you. But in order to do that, first you would have to implement the following listener (PaymentRelatedDetailsListener ) at your end so as to accept the response which payu will send back to you.

Posting the parameters to PayU

POST

 

In order to retrieve all the payment options, you need to make a server to server call on the following URL with certain parameters:

 

Environment URL
Test https://test.payu.in/merchant/postservice.php?form=2
Live https://info.payu.in/merchant/postservice.php?form=2

Parameters:

Parameter Description Sample value
key Your key provided by payu gtKFFx
command Name of web service call payment_related_details_for_mobile_sdk
hash Security parameter e54de882e2b14c13424c91a4855fea2dc9b2a3a9525531408beec97564dd336460e22d72770ba37a5fcb6bad76d042582e87cc26b34741b6b6747e6b5b71b2cc
user_credentials Identification parameter of customer gtKFFx:payutest@payu.in

You would need to send all the parameters in the following mentioned format:

Response

 

After this API call has been made, you will receive a response which will show all the available payment options for you.

IF CC/DC is chosen as the mode of Payment

 

Along with the other chosen parameters, following additional parameters are required to be sent to PayU

 

Parameter Description Data type Character limit Example
Ccnum Credit/ debit card number as entered by customer for transaction  string  20  CC
Ccname Name on card- as entered by customer  string  20  5123456789012346
Ccvv Cvv number of the card- as entered by the customer  string  4 digits  123
Ccexpmon Card’s expiry month- as entered by customer  string 2 digits 06
Ccexpyr Card’s expiry year- as entered by customer  string 4 digits 2018

 

Lines of code that should be appended in the main code:

Sample form (complete) for CC/DC flow will be look like this:

IF Net Banking is chosen as the mode of payment

 

Along with the other chosen parameters, following additional parameters are required to be sent to payu

 

Parameter Description Data type Character limit Example
bankCode Bank code of selected Bank (details recieved form API response)  string  8 ICIB

Lines of code that should be appended in the main code:

 

Sample form (complete) for NB flow will be look like this:

If cash card is chosen as mode of payment

 

Along with the other chosen parameters, following additional parameters are required to be sent to payu

 

Parameter Description Data type Character limit Example
Bank Code Bank code of selected Bank (details recieved form API response)  string  8 ICIB

 

Lines of code that should be appended in the main code:

 

Sample form (complete) for Cash Card flow will be look like this:

If EMI is chosen as mode of payment

 

Along with the other chosen parameters,following additional parameters are required to be sent to payu

 

Parameter Description Data type Character limit Example
Bank Code Bank code of selected Bank (details recieved form API response)  string  8 ICIB
ccnum Credit/ debit card number as entered by customer for transaction  string  20  5123456789012346
ccname Name on card- as entered by customer  string  20  ABC XYZ
ccvv Cvv number of the card- as entered by the customer  string 4 digits  123
ccexpmon Card’s expiry month- as entered by customer  string 2 digits 06
ccexpyr Card’s expiry year- as entered by customer  string 4 digits 2018

 

Lines of code that should be appended in the main code:

Sample form (complete) for EMI flow will be look like this:

If PayUmoney is chosen as mode of payment

 

For this payment option you don’t need to send us any more parameters, but you will need to append some lines of code in the main code.

Lines of code that needs to be appended

Sample form (complete) for PayUmoney flow will be look like this:

Create a web view activity

 

In each of these transactions no matter what has been chosen as the mode of payment, after the “Pay Now” button has been clicked, customer has to be directed to the bank’s page. In order to do that you would need to create a activity and add a webview with the following properties:

Sample code for creating webview activity (compulsory code, no changes to be made)

Response

 

After the transaction is done, depending on the status of transaction, the customer would be redirected to surl/furl, and as soon as the surl/furl finishes loading, payment activities onMerchantUrlFinished() would be called and the variable payuReponse will provide the actual response in the app in JSON format.

Still have questions?

Our team will be more than happy to help you out. You can reach out to them at mobile-integration@payu.in