On This Page
Requesting a Payment
- Use thestartSamsungPay()API method in thePaymentManagerclass. ThePaymentManagerclass includes the following API methods:
ADDITIONAL INFORMATION
- startSamsungPay()—requests to initiate payment with Samsung Pay.
- updateAmount()—updates the transaction amount if shipping address or card information is updated by Samsung Pay.
- updateAmountFailed()—returns an error code when the new amount cannot be updated because of a wrong address.
- Request thestartSamsungPay()API method and include the following data:
ADDITIONAL INFORMATION
- PaymentInfo—contains payment information.
- PID—the product ID created in the Samsung Pay Partner Portal.
- StatusListener—the result of the payment request is delivered toStatusListener. This listener should be registered before you call thestartSamsungPay()API method.
When you request thestartSamsungPay()API method, the Samsung Pay online payment sheet is displayed on your application. The customer selects a registered card for payment and can also update the billing and shipping address.The payment reply is delivered as one of the following events toStatusListener:- onSuccess()—this event is requested when Samsung Pay confirms the payment. It includesencryptedPaymentCredentialin JSON format:
- method:Payment protocol: 3-D Secure.
- merchant_ref:Merchant reference code.
- billing_address.street: Number, street name.
- billing_address.state_province:Two-letter state code.
- billing_address.zip_postal_code:Five-character zip code.
- billing_address.city:City name.
- billing_address.county:Two-letter country code.
- 3ds.type:Sfor Samsung Pay. Encrypted.
- 3ds.version:Current version100. Encrypted.
- 3ds.data:Base64-encoded payment data. Encrypted.
- onFailure()—this event is requested when the transaction fails. It returns an error code and error message.
Example: Request startSamsungPay() API Method
public void onPayButtonClicked(View v) { // Call startSamsungPay() method of PaymentManager class. // To create a transaction request for makeTransactionDetails() in the following code, see Example: Transaction Request Structure. try { mPaymentManager.startSamsungPay(makeTransactionDetails(), "enter product ID", mStatusListener); } catch (NullPointerException e) { e.printStackTrace(); } } private PaymentManager.StatusListener mStatusListener = new PaymentManager.StatusListener() { @Override public void onFailure(int errCode, String msg) { Log.d(TAG, " onFailed ); } @Override public void onSuccess(PaymentInfo arg0, String result) { Log.d(TAG, "onSuccess "); };