SamsungPay

This page describes how to integrate with SamsungPay SDK.

Getting Started

Add below url in root project's build.gradle.

implementation 'com.payu.samsungpay:samsungpay:1.0'

Callbacks

List of the callback function provided by PayU SamsungPay:

  1. onSamsungPayFailure (String payuResponse) - Calls when payment fails

  2. onSamsungPaySuccess (String payuResponse) - Calls when payment succeeds

  3. onSamsungPayInitialisationFailure (int errorCode,String description) - Called for Samsung Pay initialisation failure where,

    • errorCode : Error Code

    • description : Error Description

Following are error messages w.r.t. Samsung Pay initialisation failure

- ErrorCode : Description
- 1 : VENDOR_NOT_SUPPORTED
- 2 : DEVICE_NOT_SUPPORTED // Device is not supported
- 3 : APP_VERSION_MISMATCH // Samsung Pay version doesn't meet requirements
- 4 : COUNTRY_NOT_SUPPORTED // Country of device origin is not supported by Samsung Pay
- 5 : MERCHANT_KEY_NOT_REGISTER_FOR_SAMSUNG_PAY // Merchant is not registered for
Samsung Pay with PayU
- 6 : CONTEXT_NULL // Context is null
- 7 : PAYMENT_ID_NOT_PRESENT // Check your postdata

4. onSamsungPayInitialisationSuccess (String vpa) - Callback when Samsung Pay is successfully initialised.

  • vpa : Customer vpa in masked form

Check Payment Availability

Call method checkForPaymentAvailability available in SamsungPay to check if the payment is available or not on the device. This method is called before showing SamsungPay as a checkout option.

Sample:

PayUSamsungPay.getInstance().checkForSamsungPayAvailiability( PayUSamsungPayCallback payUSamsungPayCallback, Context context, String paymentOptionHash, String merchantKey, String user_credentials)
PayUSamsungPayCallback : the class to provide callbacks
Context : Context instance
paymentOptionHash : Payment Related Details hash
merchantKey : PayU Merchant Key
user_credentials : Provide user credentials or use "default"

To generate PaymentOption Hash visit here.

Make Payment by SamsungPay

After successful initialisation of SamsungPay by calling checkForPaymentAvailability method call makePayment method to make payment.

Sample:

PayUSamsungPay.getInstance().init( Activity mActivity, PayUSUPIPostData payUSUPIPostData);
Activity : activity instance
PayUSUPIPostData : PayUSUPIPostData instance

PayUSUPIPostData:

Initialize PayUSUPIPostData using builder class PayUSUPIPostData.Builder. Use bankcode = SAMPAY and pg = SAMPAY for Samsung Pay payments in your post data.

Sample:

PayUSUPIPostData.Builder builder = new PayUSUPIPostData.Builder();

builder.setPostData(postData);
PayUSUPIPostData payUSUPIPostData = null;

try {

payUSUPIPostData = builder.build();

} catch (Exception e) {
e.printStackTrace();

}

Sample Postdata:

txnid=1524122818080&productinfo=product_info&user_credentials=default&key=*****&surl=**SUCCESS_URL**&furl=**FAILURE_URL&firstname=firstname&[email protected]&amount=10&udf1=udf1&udf2=udf2&udf3=udf3&udf4=udf4&udf5=udf5&pg=SAMPAY&bankcode=SAMPAY&hash=***PAYMENT_HASH***