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.
Since:
API Level 1.1
  • Constructor Summary

    Constructors
    Constructor
    Description
    SamsungPay(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 Type
    Method
    Description
    void
    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 with getSamsungPayStatus(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
    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
    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 with getSamsungPayStatus(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.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SamsungPay

      public SamsungPay(android.content.Context context, PartnerInfo partnerInfo)
      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

      public 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.
       
          // 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 via StatusListener.onSuccess(int status, Bundle data).
      If Samsung Pay is ready to be used, SamsungPay#SPAY_READY will be returned.
      Otherwise, SamsungPay#SPAY_NOT_READY or SamsungPay#SPAY_NOT_SUPPORTED or SamsungPay#SPAY_NOT_ALLOWED_TEMPORALLY can be returned with SamsungPay#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)
      On any failure, the failure code is provided via StatusListener.onFail(int errorCode, Bundle errorData).

      Note: Please refer SpaySdk.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 with getSamsungPayStatus(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 with getSamsungPayStatus(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

      public 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.
       
          // 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&#60String&#62 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 via StatusListener.onFail(int errorCode, Bundle errorData).

      Note: Please refer SpaySdk.COMMON_STATUS_TABLE in detail.
      Throws:
      NullPointerException - Thrown if parameters are null.
      Since:
      API Level 1.2