Class SamsungPay
java.lang.Object
SamsungPayBase
com.samsung.android.sdk.samsungpay.v2.SamsungPay
public final class SamsungPay
extends SamsungPayBase
This class provides APIs to get the Samsung Pay status on the device.
Also, this class provides APIs to activate Samsung Pay on the device.
Partner apps must check the Samsung Pay status on the device before performing any card management or payment operation.
Partner apps must check the Samsung Pay status on the device before performing any card management or payment operation.
- Since:
- API Level 1.1
-
Constructor Summary
ConstructorDescriptionSamsungPay
(android.content.Context context, PartnerInfo partnerInfo) Constructor to get the SamsungPay instance.
The caller should set the valid serviceId in PartnerInfo. -
Method Summary
Modifier and TypeMethodDescriptionvoid
API to bring the Samsung Pay app to a state in which cards can be added.
Samsung Pay might be either in stub only state or Samsung Account is not signed in state.
Partner app checks the Samsung Pay status withgetSamsungPayStatus(StatusListener)
API.
If the status is#SPAY_NOT_READY
and#EXTRA_ERROR_REASON
is#ERROR_SPAY_SETUP_NOT_COMPLETED
,
partner app can call this API to launch Samsung Pay and user can sign in to the app.void
getSamsungPayStatus
(StatusListener listener) API to get the Samsung Pay status on the device.
Partner (Issuers, Merchants, and so on) applications must call this API to check the current state of Samsung Pay before doing any operation.void
getWalletInfo
(List<String> keys, StatusListener listener) API to get the requested wallet information from Samsung Pay.
Partner app can use this information to uniquely identify the user and Samsung Pay app on a particular device.void
API to go to Samsung Pay update page.
Partner app checks the Samsung Pay status withgetSamsungPayStatus(StatusListener)
API.
If the status is#SPAY_NOT_READY
and#EXTRA_ERROR_REASON
is#ERROR_SPAY_APP_NEED_TO_UPDATE
,
partner app can call this API to go to update Samsung Pay app.
If Samsung Pay App version is same or bigger than 2.1.00, it goes to "About SamsungPay" menu.
If Samsung Pay App version is lower than 2.1.00 or KR device, it launches Samsung Pay App main screen.
-
Constructor Details
-
SamsungPay
Constructor to get the SamsungPay instance.
The caller should set the valid serviceId in PartnerInfo. PartnerInfo is passed to Samsung Pay for partner verification.Context ct = activity; // or Context ct = service; // 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.INAPP_PAYMENT.toString()); PartnerInfo pInfo = new PartnerInfo(serviceId, bundle); SamsungPay samsungPay = new SamsungPay(ct, pInfo);
- Parameters:
context
- Activity Context or Service Context.partnerInfo
- Partner information.- Throws:
NullPointerException
- Thrown if parameters are null.- Since:
- API Level 1.1
-
-
Method Details
-
getSamsungPayStatus
API to get the Samsung Pay status on the device.
Partner (Issuers, Merchants, and so on) applications must call this API to check the current state of Samsung Pay before doing any operation.
// 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.INAPP_PAYMENT.toString()); PartnerInfo pInfo = new PartnerInfo(serviceId, bundle); SamsungPay samsungPay = new SamsungPay(context, pInfo); samsungPay.getSamsungPayStatus(new StatusListener() { @Override public void onSuccess (int status, Bundle data){ // success case if (status == SPAY_READY){ Log.d(TAG, "Samsung Pay is ready on the device"); // Perform your operation. } else if(status == SPAY_NOT_READY){ // Samsung Pay is supported but not fully ready. // If EXTRA_ERROR_REASON is ERROR_SPAY_APP_NEED_TO_UPDATE, // Call goToUpdatePage(). // If EXTRA_ERROR_REASON is ERROR_SPAY_SETUP_NOT_COMPLETED, // Call activateSamsungPay(). } else if(status == SPAY_NOT_ALLOWED_TEMPORALLY) { Log.d(TAG, "Samsung Pay is not allowed temporally"); // If EXTRA_ERROR_REASON is ERROR_SPAY_CONNECTED_WITH_EXTERNAL_DISPLAY, // guide user to disconnect it. } else { // Samsung Pay is not supported on this device. Log.d(TAG, "Device does not support Samsung Pay"); } } @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). } });
- Parameters:
listener
- Callback through which the result is provided.
On success, Samsung Pay status code is provided viaStatusListener.onSuccess(int status, Bundle data)
.
If Samsung Pay is ready to be used,SamsungPay#SPAY_READY
will be returned.
Otherwise,SamsungPay#SPAY_NOT_READY
orSamsungPay#SPAY_NOT_SUPPORTED
orSamsungPay#SPAY_NOT_ALLOWED_TEMPORALLY
can be returned withSamsungPay#EXTRA_ERROR_REASON
from Bundle.
Also, partner can get extra information from Bundle data.
Bundle Keys(if provided) Bundle Values #EXTRA_COUNTRY_CODE
Device Country code(ISO 3166-1 alpha-2) #EXTRA_MEMBER_ID
String memberID (for Korean issuers only) StatusListener.onFail(int errorCode, Bundle errorData)
.
Note: Please referSpaySdk.COMMON_STATUS_TABLE
in detail.
- Throws:
NullPointerException
- Thrown if the callback passed is null.- Since:
- API Level 1.1
-
goToUpdatePage
public void goToUpdatePage()API to go to Samsung Pay update page.
Partner app checks the Samsung Pay status withgetSamsungPayStatus(StatusListener)
API.
If the status is#SPAY_NOT_READY
and#EXTRA_ERROR_REASON
is#ERROR_SPAY_APP_NEED_TO_UPDATE
,
partner app can call this API to go to update Samsung Pay app.
If Samsung Pay App version is same or bigger than 2.1.00, it goes to "About SamsungPay" menu.
If Samsung Pay App version is lower than 2.1.00 or KR device, it launches Samsung Pay App main screen.// 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.INAPP_PAYMENT.toString()); PartnerInfo pInfo = new PartnerInfo(serviceId, bundle); SamsungPay samsungPay = new SamsungPay(context, pInfo); samsungPay.goToUpdatePage();
- Since:
- API Level 1.2
-
activateSamsungPay
public void activateSamsungPay()API to bring the Samsung Pay app to a state in which cards can be added.
Samsung Pay might be either in stub only state or Samsung Account is not signed in state.
Partner app checks the Samsung Pay status withgetSamsungPayStatus(StatusListener)
API.
If the status is#SPAY_NOT_READY
and#EXTRA_ERROR_REASON
is#ERROR_SPAY_SETUP_NOT_COMPLETED
,
partner app can call this API to launch Samsung Pay and user can sign in to the app.
// 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.INAPP_PAYMENT.toString()); PartnerInfo pInfo = new PartnerInfo(serviceId, bundle); SamsungPay samsungPay = new SamsungPay(context, pInfo); samsungPay.activateSamsungPay();
- Since:
- API Level 1.1
-
getWalletInfo
API to get the requested wallet information from Samsung Pay.
Partner app can use this information to uniquely identify the user and Samsung Pay app on a particular device.// Set the serviceId which is assigned by the Samsung Pay Developer during on boarding. String serviceId = "sampleServiceId"; Bundle bundle = new Bundle(); bundle.putString(SamsungPay.EXTRA_ISSUER_NAME, "issuer name"); bundle.putString(SamsungPay.PARTNER_SERVICE_TYPE, SamsungPay.ServiceType.APP2APP.toString()); PartnerInfo pInfo = new PartnerInfo(serviceId, bundle); SamsungPay samsungPay = new SamsungPay(context, pInfo); // Bundle keys added to get wallet information from Samsung Pay. // This information can be delivered to the Partner Server for eligibility check. ArrayList<String> keys = new ArrayList<>(); keys.add(SamsungPay.WALLET_USER_ID); keys.add(SamsungPay.DEVICE_ID); samsungPay.getWalletInfo(keys, new StatusListener() { @Override public void onSuccess(int status, Bundle walletData) { // Log.d(TAG, "doWalletInfo onSuccess callback is called"); // For VISA, deviceID can be set to "clientDeviceID" as defined by VISA String deviceId = walletData.get(SamsungPay.DEVICE_ID); // For VISA, walletUserId can be set to "clientWalletAccountID" as defined by VISA String walletUserId = walletData.get(SamsungPay.WALLET_USER_ID); } @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). } }
- Parameters:
keys
- Key list to get wallet information.
If the list is empty, all possible key values are returned.
The possible keys are:
#WALLET_DM_ID
#DEVICE_ID
#WALLET_USER_ID
listener
- Callback through which the result is provided.
On success,StatusListener.onSuccess(int status, Bundle data)
is invoked with wallet information.
The success code can be one of the following codes with bundle data:
Status Bundle Keys Bundle Values USAGE VTS MDES #ERROR_NONE
SamsungPay#WALLET_DM_ID
String Device Management ID N/A paymentAppInstanceId = DEVICE_ID + Padding("00") + WALLET_DM_ID
(*If you need 'paymentAppInstanceId', you can generate it as above)SamsungPay#DEVICE_ID
String Device ID clientDeviceID SamsungPay#WALLET_USER_ID
String Wallet User ID clientWalletAccountID
On any failure, the error code is provided viaStatusListener.onFail(int errorCode, Bundle errorData)
.
Note: Please referSpaySdk.COMMON_STATUS_TABLE
in detail.
- Throws:
NullPointerException
- Thrown if parameters are null.- Since:
- API Level 1.2
-
Samsung Electronics.
Samsung Pay SDK 2.19.00 - Jun 12 2024