Class CardManager

java.lang.Object
com.samsung.android.sdk.samsungpay.v2.SpaySdk
com.samsung.android.sdk.samsungpay.v2.card.CardManager
All Implemented Interfaces:
AppToAppConstants

public final class CardManager extends SpaySdk implements AppToAppConstants
This class provides APIs for card management. The APIs include getting card status, adding new card to Samsung Pay, and so on.

Note:Whenever a new instance of CardManager is created, all pending requests (which were sent by another instances) will be discarded.
It would be helpful when partner application attempt to send a request again.
However, in a single session of partner application, you should maintain only one instance of this class and use it to send requests to Samsung Pay application.
Since:
API Level 1.1
  • Field Details

  • Constructor Details

    • CardManager

      public CardManager(android.content.Context context, PartnerInfo partnerInfo)
      API to get the CardManager instance.
      The caller should set valid ServiceId. PartnerInfo is passed to Samsung Pay 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(SamsungPay.EXTRA_ISSUER_NAME, issuerName);
          bundle.putString(SamsungPay.PARTNER_SERVICE_TYPE, SamsungPay.ServiceType.APP2APP.toString());
      
          PartnerInfo pInfo = new PartnerInfo(serviceId, bundle);
          CardManager cardManager = new CardManager(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

    • addCard

      public void addCard(AddCardInfo addCardInfo, AddCardListener listener)
      API to add a card from partner app (example: issuer/bank app) to Samsung Pay.
      Partner app uses this API to add card to Samsung Pay by providing the required card details. This helps user to add their cards to Samsung Pay directly from partner app.
       
          CardManager cardManager = new CardManager(ct, pInfo);
      
          String cardType = Card.CARD_TYPE_CREDIT;
          String tokenizationProvider = AddCardInfo.PROVIDER_ABCD;
      
          // Get it from issuer app.
          // Samsung Pay 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);
      
          cardManager.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 SamsungPay.EXTRA_ERROR_REASON or SamsungPay.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 SpaySdk.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
      SpaySdk.ERROR_REGISTRATION_FAIL (-104) SpaySdk.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)
      SpaySdk.EXTRA_REQUEST_ID String value returned from server
      AppToAppConstants.ERROR_TSM_FAIL (-507) SpaySdk.EXTRA_ERROR_REASON String Error Message(For TSM solution)
      Note: Please refer SpaySdk.COMMON_STATUS_TABLE for other error status.
      In case of TSM, please refer AddCardListener.onProgress(int, int, Bundle).
      Throws:
      NullPointerException - Thrown if parameters are null.
      Since:
      API Level 1.2
    • getAllCards

      public void getAllCards(android.os.Bundle cardFilter, GetCardListener listener)
      API to get all the cards from Samsung Pay for the given filter.
      Since API level 2.13, getAllCards(Bundle, GetCardListener) would return a card list in which a Card of SpaySdk.Brand.VISA brand would hold a Token Reference ID as its Card.getCardId() instead of a Provisioned Token ID in earlier API level.
      Since API level 1.4, partner must define issuer names as a card filter on Samsung Pay Developers while on-boarding.
       
      
          Bundle cardFilter = new Bundle();
          // since API Level 1.4, card filter is retrieved from Samsung Pay Developers.
          // No need to set from partner app.
          cardFilter.putString(CardManager.EXTRA_ISSUER_NAME, issuerName);
      
          cardManager.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(CardManager.EXTRA_LAST4_FPAN);
                              String last4DPan = s.getCardInfo().getString(CardManager.EXTRA_LAST4_DPAN);
                              String app2AppPayLoad = s.getCardInfo().getString(CardManager.EXTRA_APP2APP_PAYLOAD);
                              String cardType = s.getCardInfo().getString(CardManager.EXTRA_CARD_TYPE);
                              String cardIssuerName = s.getCardInfo().getString(CardManager.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 SamsungPay.EXTRA_ERROR_REASON (if provided).
              }
          });
       
       
      Parameters:
      cardFilter - Filter to limit the card list.
      Since API level 1.4, issuer name filter is retrieved from Samsung Pay Developers.
      CardFilter bundle key-value pairs are defined as follows:

      Keys Values
      SpaySdk.EXTRA_ISSUER_NAME String issuerName (issuerCode for Korean issuers)

      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.15