API to request payment with Simple Pay.
Using this API, partner app can start the Samsung Pay payment screen for a specific card.
For example, user can login to partner app (example: bank app), view the list of cards, and
select a card (which is already registered in Samsung Pay) to make in-store payment.
Samsung Pay is launched with the selected card for payment. The user can authenticate and
start the payment.
Partner app needs to obtain an usage permission of startSimplePay() API in server-side.
Without the permission, calling of startSimplePay() API would be failed.
// Set the serviceId which is assigned by the Samsung Pay Developer during on boarding.
String serviceId = "sampleServiceId";
Bundle bundle = new Bundle();
bundle.putString(SamsungPay.PARTNER_SERVICE_TYPE, SamsungPay.ServiceType.APP2APP.toString());
PartnerInfo pInfo = new PartnerInfo(serviceId, bundle);
PaymentManager paymentManager = new PaymentManager(context, pInfo);
String cardId = "cardId_test";
Bundle metaData = new Bundle();
//
// Set values in metaData bundle.
//
CardInfo cardInfo = new CardInfo.Builder().setCardId(cardId).setCardMetaData(metaData).build();
paymentManager.startSimplePay(cardInfo, new StatusListener() {
@Override
public void onSuccess(int status, Bundle data) {
// Called when start Samsung Pay Simple Pay is showed to user with specified card.
Log.d (TAG, "Simple Pay is shown");
}
@Override
public void onFail(int errorCode, Bundle errorData) {
Log.e(TAG, "onFail callback is called, errorCode: " + errorCode);
// To get more reason of the failure,
// check some extra error codes in the errorData bundle such as SamsungPay.EXTRA_ERROR_REASON (if provided).
}
});
How to set metaData in CardInfo:
- Case 1. Requesting in-store payment
metaData.putString(PaymentManager.EXTRA_PAY_OPERATION_TYPE,
PaymentManager.PAY_OPERATION_TYPE_PAYMENT);
metaData.putString(PaymentManager.EXTRA_ISSUER_NAME, "issuerName_test");
metaData.putInt(PaymentManager.EXTRA_TRANSACTION_TYPE,
PaymentManager.TRANSACTION_TYPE_MST | PaymentManager.TRANSACTION_TYPE_NFC);
// Set Logo image and background color for Simple Pay screen
metaData.putString(PaymentManager.EXTRA_LOGO_IMAGE_URL, "http://testbank.com/logo.png");
- Case 2. Requesting refund for in-store payment (for Korean issuers only)
metaData.putString(PaymentManager.EXTRA_PAY_OPERATION_TYPE,
PaymentManager.PAY_OPERATION_TYPE_REFUND);
metaData.putString(PaymentManager.EXTRA_ISSUER_NAME, "issuerName");
metaData.putString(PaymentManager.EXTRA_TRANSACTION_DATE, "yyyyMMddHHmm");
metaData.putString(PaymentManager.EXTRA_TRANSACTION_NUMBER, "1234567890");
metaData.putInt(PaymentManager.EXTRA_TRANSACTION_TYPE,
PaymentManager.TRANSACTION_TYPE_MST | PaymentManager.TRANSACTION_TYPE_NFC);