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(@NonNull AddCardInfo addCardInfo, @NonNull 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 codes from the PUSH_PROVISION_ERROR with bundle data.

      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
    • addCobadgeCard

      public void addCobadgeCard(@NonNull AddCardInfo primaryAddCardInfo, @NonNull AddCardInfo secondaryAddCardInfo, @NonNull AddCardListener listener)
      API to add a co-badge card from partner app (example: issuer/bank app) to Samsung Pay.
      Partner app uses this API to add co-badge card to Samsung Pay by providing the required card details. This helps user to add their cards to Samsung Pay directly from partner app.
      Parameters:
      primaryAddCardInfo - Detail primary card information to add.
      secondaryAddCardInfo - Detail secondary 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 codes from the PUSH_PROVISION_ERROR with bundle data.

      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 2.22
    • getAllCards

      public void getAllCards(@Nullable android.os.Bundle cardFilter, @NonNull 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
    • verifyCardIdv

      public void verifyCardIdv(@NonNull IdvVerifyInfo idvVerifyInfo, @NonNull StatusListener listener)
      API to verify and activate a card in Samsung Pay.
      Issuer app uses this API to send verification code back to token network to activate a card on Samsung Pay.
      When adding a card to Samsung Pay, the issuer/card network may request secondary authentication(IDV).
      The user can verify IDV via issuer app and after user verification (by logging to issuer app), issuer app sends some information back to issuer/card network via Samsung Pay to activate the card.
       
          CardManager cardManager = new CardManager(ct, pInfo);
      
          // Issuer can get cardID from getAllCards() API result.
          String cardId = "card_id_example_dummy" ;
      
          // Issuer app gets card status from Samsung Pay and talks to issuer server
          // and gets authentication code.
          String authCode = "auth_code_example_dummy";
      
          // If any extra information issuer wants to pass to card network/issuer server.
          Bundle cardInfoData  = new Bundle();
          IdvVerifyInfo idvVerifyInfo = new IdvVerifyInfo(cardId, authCode, cardInfoData);
      
          // In case auth code is generated for SMS or Email,
          // set authCodeType as IdvVerifyInfo.IDV_TYPE_SMS or IdvVerifyInfo.IDV_TYPE_EMAIL
          // If you don't specify any value for authCodeType, IDV_TYPE_APP2APP will be used by default.
          idvVerifyInfo.setIDnVType(IdvVerifyInfo.IDV_TYPE_APP2APP);
      
          cardManager.verifyCardIdv(idvVerifyInfo, new StatusListener() {
              @Override
              public void onSuccess (int status, Bundle data){
                  // Log.d (TAG, "verification code successfully send to server");
              }
      
              @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:
      idvVerifyInfo - Card verification information from issuer.
      listener - Verification status callback through which the result is provided.
      On success, StatusListener.onSuccess(int status, Bundle data) is invoked when request operation is success.

      On any failure, the failure code is provided via StatusListener.onFail(int errorCode, Bundle errorData).

      The failure code can be one of the following codes with bundle data:

      Status Bundle Keys Bundle Values
      AppToAppConstants.ERROR_VERIFY_CARD (-8) SpaySdk.EXTRA_ERROR_REASON AppToAppConstants.ERROR_AUTH_CODE_INVALID (-517)
      AppToAppConstants.ERROR_AUTH_CODE_EXPIRED (-518)
      AppToAppConstants.ERROR_AUTH_CODE_MAX_TRY_REACHED (-519)
      AppToAppConstants.ERROR_AUTH_CODE_TYPE_INVALID (-520)
      AppToAppConstants.ERROR_CARD_IDV_NOT_SUPPORTED (-521)
      Note: Please refer SpaySdk.COMMON_STATUS_TABLE in detail.
      Throws:
      NullPointerException - Thrown if parameters are null.
      Since:
      API Level 1.1