Store Card- Android – PayU Documentation

Store card- Android

Pre-requisites

1. PayU PG SDK v4.3+

Steps Involved

 

  1. To store a new card, you need to provide a checkbox in your payment page UI and post us the corresponding parameters.
  2. To use an already stored card, you need to fetch all the previously stored cards via an API and post us the parameters.
  3. Deleting a stored card.

To store a new card

 

UI change

In CC/DC screen of your payment page, create a checkbox, which should ask user to save the card. (Refer {PayUCreditDebitCardActivity} in sample app for more details)

 

Make Payment

 

To facilitate a customer to enroll a credit/ debit card to store card  you are required to  make some changes in your code. Also, you are required to post two extra parameters to PayU compared to the otherwise existing flow of CC/DC.

Extra parameters to be posted:

Parameter Description Value
user_credentials Used to identify each unique user, to show the option of saving a card, on payment page. <merchant_key:unique_customer_identifier>

merchant_key: Unique merchant key provided by payu.

unique_customer_identifier: unique value to identify a customer, be it email id, phone or any unique string

Please note both variable are separated by a ‘:’

store_card Check whether the feature is on or not 1
card_name (non-mandatory) For setting a nickname/ custom label to the card string

Examples of user_credentials:

If the merchant_key is JBiPgT, then examples of user_credentials are as below:

  1. a) JBiPgT:test@example.com – [Email ID used here]
  2. b) JBiPgT:9999999999 – [Phone number used]
  3. c) JBiPgT:123456 – [Numeric Value]
  4. d) JBiPgT:ertyui12fgh5jasas – [String used]

Lines of code that needs to be added

The complete sample code form with all the parameters required to convert a CC/ DC card to store Card will look like the following

All the parameters that are being send to PayU server should follow the following format

 

Response

 

Once all these parameters are passed and a successful transaction is carried out, the card would be saved in PayU’s database and you would receive a card token in the response.

The sample code for response would be a follows

Using an already stored card for payment

 

Fetching stored cards from PayU

 

You are required to fetch all the store cards from PayU for a customer to choose one of the store cards to make payment. You have to do this by calling our API payment_related_details_for_mobile_sdk.

To use payment_related_details_for_mobile_sdk:

POST

In order to retrieve all the store cards, 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=1
Live https://info.payu.in/merchant/postservice.php?form=1

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– SHA512(key|command|var1|salt) e54de882e2b14c13424c91a4855fea2dc9b2a3a9525531408beec97564dd336460e22d72770ba37a5fcb6bad76d042582e87cc26b34741b6b6747e6b5b71b2cc
var1=user_credentials Identification parameter of customer gtKFFx:payutest@payu.in

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

 

Response

This response gives a list of all the stored cards, in the form of stored card objects (StoredCard). The stored card object will have the following parameters, card_token, card name, card_type, etc.

Making a POST request

When all stored cards pertaining to a user are returned and user chooses one of those to make a payment, you are required to  POST set of following parameters instead of sending the usual parameters for a CC/DC transaction.

Parameter to be replaced Replacing parameters Description Example
ccnum card_token  Encoded String to identify unique stored card
ccname user_credentials  Merchant’s user credentials  username;password
ccexpmon
ccexpyr

Now the form has to be submitted to PayU’s SDK, the sample code is as follows

To make payment using an already stored card, thePOST params that needs to be send to PayU server are as follows

Deleting a card

 

You need to provide a “delete store card” option in your app. For futher reference please refer to {PayUStoredCardsActivity} in SDKUI module in Sample App.

In order to delete a card, you would need to implement the following interface:

Delete store cards

 

If your customer chooses to delete a card, it can be done by making an API call to PayU. All you need to do is:

Post:

 

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

Parameters:

Parameter Description Sample value
key Your key provided by payu  JBiPgT
command Name of web service call  delete_user_card
hash Security parameter— SHA512(key|command|var1|salt)
var1=user_credentials Identification parameter of customer  JBiPgT:9999999999
var2=card_token

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

 

Response

 

Still have questions?

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