Class WatchManager

java.lang.Object
SamsungPayBase
com.samsung.android.sdk.samsungpay.v2.WatchManager
All Implemented Interfaces:
AppToAppConstants

public final class WatchManager extends SamsungPayBase implements AppToAppConstants
This class provides APIs for watch management. Partner apps must check the Samsung Pay watch status on the device before performing any card management.
Also, this class provides APIs getting cards information, adding new card to Samsung Pay on watch, and so on.
Since:
API Level 2.5
  • Field Details

    • DEVICE_SERIAL_NUM

      public static final String DEVICE_SERIAL_NUM
      Key to represent device serial number to generate the paymentAppInstanceId.
      Since:
      API Level 2.5
      See Also:
    • ERROR_SPAY_PIN_LOCK_SETUP_CANCELED

      public static final int ERROR_SPAY_PIN_LOCK_SETUP_CANCELED
      This error indicates that user canceled the PIN lock setup.
      Partner app should ask user to setup PIN for Samsung Pay Gear.
      Since:
      API Level 2.5
      See Also:
    • ERROR_INVALID_PARAMETER

      public static final int ERROR_INVALID_PARAMETER
      This error indicates that the given parameter is invalid.
      This is returned as SpaySdk.EXTRA_ERROR_REASON for SpaySdk.ERROR_REGISTRATION_FAIL error.
      Since:
      API Level 2.5
      See Also:
    • ERROR_SPAY_WATCH_PIN_LOCK_SETUP_CANCELED

      public static final int ERROR_SPAY_WATCH_PIN_LOCK_SETUP_CANCELED
      This error indicates that user canceled the PIN lock setup.
      Partner app should ask user to setup PIN for Samsung Pay(Watch).
      Since:
      API Level 2.5
      See Also:
    • SPAY_WATCH_UPDATE_IS_ONGOING

      public static final int SPAY_WATCH_UPDATE_IS_ONGOING
      This error indicates that Samsung Pay(Watch) being updated.
      Since:
      API Level 2.5
      See Also:
    • SPAY_WATCH_TAKING_LOG_FOR_REPORT

      public static final int SPAY_WATCH_TAKING_LOG_FOR_REPORT
      This error indicates that Samsung Pay(Watch) is taking log for error report.
      Since:
      API Level 2.5
      See Also:
    • ERROR_SPAY_WATCH_PAY_PROGRESS

      public static final int ERROR_SPAY_WATCH_PAY_PROGRESS
      This error indicates that Samsung Pay(Watch) is in a process of payment.
      Since:
      API Level 2.5
      See Also:
    • ERROR_SPAY_WATCH_CONNECTION

      public static final int ERROR_SPAY_WATCH_CONNECTION
      This error indicates that Samsung Pay(Watch Plug-in) can not connect with Samsung Pay(Watch).
      Partner app should ask user to check bluetooth connection or pairing.
      Since:
      API Level 2.5
      See Also:
  • Constructor Details

    • WatchManager

      public WatchManager(android.content.Context context, PartnerInfo partnerInfo)
      API to get the WatchManager instance.
      The caller should set valid ServiceId. PartnerInfo is passed to Samsung Pay on watch for caller verification.
       
          Context ct = activity;
          // or Context ct = service;
      
          String issuerName = "MyBank";
      
          // Set the serviceId which is assigned by the Samsung Pay Developer during on boarding.
          String serviceId = "sampleServiceId";
      
          Bundle bundle = new Bundle();
          bundle.putString(WatchManager.EXTRA_ISSUER_NAME, issuerName);
          bundle.putString(WatchManager.PARTNER_SERVICE_TYPE, WatchManager.ServiceType.APP2APP.toString());
      
          PartnerInfo pInfo = new PartnerInfo(serviceId, bundle);
          WatchManager watchManager = new WatchManager(ct, pInfo);
       
       
      Parameters:
      context - Activity Context or Service Context.
      partnerInfo - Partner information.
      Throws:
      NullPointerException - Thrown if parameters are null.
      Since:
      API Level 2.5
  • Method Details

    • getSamsungPayStatus

      public void getSamsungPayStatus(StatusListener listener)
      API to get the Samsung Pay on watch status on the device.
      Partner (Issuers) applications must call this API to check the current state of Samsung Pay on watch 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(WatchManager.PARTNER_SERVICE_TYPE, WatchManager.ServiceType.APP2APP.toString());
      
          PartnerInfo pInfo = new PartnerInfo(serviceId, bundle);
      
          WatchManager watchManager = new WatchManager(context, pInfo);
      
          watchManager.getSamsungPayStatus(new StatusListener() {
              @Override
              public void onSuccess (int status, Bundle data){
                  // success case
                  if (status == SPAY_READY){
                      Log.d(TAG, "Samsung Pay on watch is ready on the device");
      
                      // Perform your operation.
                  } else if( status == SPAY_NOT_READY){
                      // Samsung Pay on watch 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 {
                      // Samsung Pay on watch is not supported on this device.
                      Log.d(TAG, "Device does not support Samsung Pay on watch");
                  }
              }
      
              @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 WatchManager.EXTRA_ERROR_REASON (if provided).
              }
          });
       
       
      Parameters:
      listener - Callback through which the result is provided.

      On success, Samsung Pay on watch status code is provided via StatusListener.onSuccess(int status, Bundle data).
      If Samsung Pay on watch is ready to be used, #SPAY_READY will be returned.
      Otherwise, #SPAY_NOT_READY or #SPAY_NOT_SUPPORTED can be returned with #EXTRA_ERROR_REASON from Bundle.

      Also, partner can get extra information from Bundle data.
      Bundle Keys(if provided) Bundle Values
      SpaySdk.EXTRA_COUNTRY_CODE Device Country code(ISO 3166-1 alpha-2)
      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 2.5
    • goToUpdatePage

      public void goToUpdatePage()
      API to go to Samsung Pay on watch update page.
      Partner app checks the Samsung Pay on watch 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 on watch app.

       
          // Set the serviceId which is assigned by the Samsung Pay Developer during on boarding.
          String serviceId = "sampleServiceId";
          Bundle bundle = new Bundle();
          bundle.putString(WatchManager.PARTNER_SERVICE_TYPE, WatchManager.ServiceType.APP2APP.toString());
      
          PartnerInfo pInfo = new PartnerInfo(serviceId, bundle);
      
          WatchManager watchManager = new WatchManager(context, pInfo);
      
          watchManager.goToUpdatePage();
       
       
      Since:
      API Level 2.5
    • activateSamsungPay

      public void activateSamsungPay()
      API to bring the Samsung Pay on watch app to a state in which cards can be added.
      Samsung Pay on watch might be Samsung Account is not signed in state.
      Partner app checks the Samsung Pay on watch 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 on watch 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(WatchManager.PARTNER_SERVICE_TYPE, WatchManager.ServiceType.APP2APP.toString());
      
          PartnerInfo pInfo = new PartnerInfo(serviceId, bundle);
      
          WatchManager watchManager = new WatchManager(context, pInfo);
      
          watchManager.activateSamsungPay();
       
       
      Since:
      API Level 2.5
    • getWalletInfo

      public void getWalletInfo(List<String> keys, StatusListener listener)
      API to get the requested wallet information from Samsung Pay on watch.
      Partner app can use this information to uniquely identify the user and Samsung Pay on watch 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(WatchManager.EXTRA_ISSUER_NAME, "issuer name");
          bundle.putString(WatchManager.PARTNER_SERVICE_TYPE, WatchManager.ServiceType.APP2APP.toString());
      
          PartnerInfo pInfo = new PartnerInfo(serviceId, bundle);
      
          WatchManager watchManager = new WatchManager(context, pInfo);
      
          // Bundle keys added to get wallet information from Samsung Pay on watch.
          // This information can be delivered to the Partner Server for eligibility check.
          ArrayList&#60String&#62 keys = new ArrayList<>();
          keys.add(WatchManager.WALLET_USER_ID);
          keys.add(WatchManager.DEVICE_ID);
      
          watchManager.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(WatchManager.DEVICE_ID);
      
                  // For VISA, walletUserId can be set to "clientWalletAccountID" as defined by VISA
                  String walletUserId = walletData.get(WatchManager.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 WatchManager.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
      DEVICE_SERIAL_NUM
      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 #WALLET_DM_ID String Device Management ID N/A paymentAppInstanceId = DEVICE_SERIAL_NUM + WALLET_DM_ID
      (*If you need 'paymentAppInstanceId', you can generate it as above)
      #DEVICE_ID String Device ID clientDeviceID
      #WALLET_USER_ID String Wallet User ID clientWalletAccountID
      DEVICE_SERIAL_NUM String Device Serial Number N/A

      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 2.5
    • addCard

      public void addCard(AddCardInfo addCardInfo, AddCardListener listener)
      API to add a card from partner app (example: issuer/bank app) to Samsung Pay on watch.
      Partner app uses this API to add card to Samsung Pay on watch by providing the required card details. This helps user to add their cards to Samsung Pay on watch directly from partner app.
       
          WatchManager watchManager = new WatchManager(ct, pInfo);
      
          String cardType = Card.CARD_TYPE_CREDIT;
          String tokenizationProvider = AddCardInfo.PROVIDER_ABCD;
      
          // Get it from issuer app.
          // Samsung Pay on watch does not provide detailed payload information.
          // Generate provisioning payload in accordance with your card network specifications.
          String testPayload = "ThisIsTestPayloadCardInfo1234567890";
      
          Bundle cardDetail = new Bundle();
          cardDetail.putString(AddCardInfo.EXTRA_PROVISION_PAYLOAD, testPayload);
      
          AddCardInfo addCardInfo = new AddCardInfo(cardType, tokenizationProvider, cardDetail);
      
          watchManager.addCard(addCardInfo, new AddCardListener() {
              @Override
              public void onSuccess(int status, Card card) {
                  Log.d(TAG, "onSuccess callback is called");
              }
      
              @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 WatchManager.EXTRA_ERROR_REASON or WatchManager.EXTRA_REQUEST_ID (if provided).
              }
      
              @Override
              public void onProgress(int currentCount, int totalCount, Bundle bundleData) {
                  Log.d(TAG,"onProgress callback is called : " + currentCount + " / " + totalCount);
              }
          });
       
       
      Parameters:
      addCardInfo - Detail card information to add.
      listener - Callback through which the result is provided.
      On success, AddCardListener.onSuccess(int, Card) is invoked with #ERROR_NONE status code with added card information.

      On any failure, the error code is provided via AddCardListener.onFail(int errorCode, Bundle errorData).
      The failure code can be one of the following codes with bundle data:

      Status Bundle Keys Bundle Values
      #ERROR_REGISTRATION_FAIL (-104) #EXTRA_ERROR_REASON AppToAppConstants.ERROR_CARD_ALREADY_REGISTERED (-500)
      AppToAppConstants.ERROR_FRAMEWORK_INTERNAL (-501)
      AppToAppConstants.ERROR_INVALID_CARD (-502)
      AppToAppConstants.ERROR_INVALID_CARDINPUT (-503)
      ERROR_INVALID_PARAMETER (-504)
      AppToAppConstants.ERROR_SERVER_REJECT (-505)
      AppToAppConstants.ERROR_MAX_CARD_NUM_REACHED (-506)
      AppToAppConstants.ERROR_CARD_NOT_SUPPORTED (-514)
      AppToAppConstants.ERROR_MAX_PAN_PROVISION_NUM_REACHED (-515)
      AppToAppConstants.ERROR_WALLET_ID_MISMATCH (-516)
      ERROR_SPAY_WATCH_PIN_LOCK_SETUP_CANCELED (-701)
      SPAY_WATCH_UPDATE_IS_ONGOING (-702)
      SPAY_WATCH_TAKING_LOG_FOR_REPORT (-703)
      ERROR_SPAY_WATCH_PAY_PROGRESS (-704)
      ERROR_SPAY_WATCH_CONNECTION (-705)
      #EXTRA_REQUEST_ID String value returned from server
      Note: Please refer SpaySdk.COMMON_STATUS_TABLE for other error status.
      Throws:
      NullPointerException - Thrown if parameters are null.
      Since:
      API Level 2.17
    • getAllCards

      public void getAllCards(android.os.Bundle cardFilter, GetCardListener listener)
      API to get all the cards from Samsung Pay on watch for the given filter.
      Since API level 2.5, partner must define issuer names as a card filter on Samsung Pay Developers while on-boarding.
       
      
          Bundle cardFilter = new Bundle();
          watchManager.getAllCards(cardFilter, new GetCardListener() {
              @Override
              public void onSuccess(List&#60Card&#62 cards){
                  // Getting card status is success
                  if (cards == null || cards.isEmpty()){
                      Log.e(TAG,"No card is found");
                      return;
                  } else {
                      // Perform operation with card data.
                      for (Card s:cards){
                          Log.d(TAG, "CardId: " + s.getCardId() + "CardStatus" + s.getCardStatus());
                          // Get extra card data.
                          if (s.getCardInfo() != null) {
                              String last4FPan = s.getCardInfo().getString(WatchManager.EXTRA_LAST4_FPAN);
                              String last4DPan = s.getCardInfo().getString(WatchManager.EXTRA_LAST4_DPAN);
                              String cardType = s.getCardInfo().getString(WatchManager.EXTRA_CARD_TYPE);
                              String cardIssuerName = s.getCardInfo().getString(WatchManager.EXTRA_ISSUER_NAME);
      
                              Log.d(TAG, "last4FPan: " + last4FPan + "last4DPan" + last4DPan +
                                  "App2AppPayLoad: " + app2AppPayLoad);
                          }
                      }
                  }
              }
      
              @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 WatchManager.EXTRA_ERROR_REASON (if provided).
              }
          });
       
       
      Parameters:
      listener - Callback through which the result is provided.
      On success, GetCardListener.onSuccess(List) is invoked with list of Cards.

      On any failure, the error code is provided via GetCardListener.onFail(int, Bundle).

      Note: Please refer SpaySdk.COMMON_STATUS_TABLE in detail.
      Throws:
      NullPointerException - Thrown if listener is null.
      Since:
      API Level 2.13