Enable App to App service

Adding payment cards to Samsung Wallet from the card issuer’s app.

  • Requesting registered card list in the Samsung Wallet
  • Getting wallet information
  • Adding a card to Samsung Wallet
  • Adding a Co-badge card to Samsung Wallet

Requesting Registered Card List in the Samsung Wallet

The getAllCards() method of the CardManager() class is used to request a list of all cards currently registered/enrolled in Samsung Wallet on the same device running the issuer’s app. To succeed, the issuer app must pass valid PartnerInfo to 'CardManager' for caller verification. 'cardFilter' narrows the card list returned by Samsung Wallet to the issuerName specified. Please be noted that getSamsungPayStatus() must be called before getAllCards() . getAllCards() could not return a cards list when getSamsungPayStatus() responds with a code other than SPAY_READY().

As of API level (SDK version) 1.4, cardFilter retrieves this information from the Samsung Pay Developers portal. Certain issuers may need to register multiple ISSUER NAME(s) with the portal, depending on their app and/or the requirements of their token service provider (TSP). The getAllCards() parameter cardFilter matches the ISSUER NAME(s) specified with those registered in the portal. Only complete matches are returned.

This method is typically called when your partner app wants to check the card status. It does not need to be called every time the partner app resumes. Therefore, you should create the card list with the 'onCreate()' method, rather than the 'onResume()' method.

The result of a getAllCards() call is delivered to GetCardListener, which provides the following events:

onSuccess() - called when the operation succeeds; provides the list of all filtered cards and their status. Card information includes cardId, cardStatus, and extra cardInfo data.

onFail() - called when the operation fails.

Here’s an example of how to use the 'getAllCards()' API method in your issuer app.

 samsungPaySdkFlutterPlugin.getAllCards(GetCardListener(onSuccess:(list){
      showCardList(list);
    }, onFail:(errorCode, bundle){
      showError(errorCode, bundle);
    }));

Getting Wallet Information

The SamsungPay class provides the getWalletInfo() API method, which is called to request wallet information from the Samsung Wallet app prior to calling the addCard() API, when you want to avoid duplicate provisioning. Your issuer app uses this information to uniquely identify the user and the Samsung Wallet app on a particular device (wallet device management ID, device ID, and wallet user ID).

 void getWalletInfo(StatusListener? statusListener)

The following example demonstrates how to use it.

    String serviceId;
    SpaySdk.PARTNER_SERVICE_TYPE: ServiceType.APP2APP.name.toString()

    SamsungPaySdkFlutter(PartnerInfo(serviceId: "", data: {}));
    samsungPay=SamsungPay(context,partnerInfo)

    val keys = ArrayList<String>()
    keys.add(SamsungPay.WALLET_DM_ID)
    keys.add(SamsungPay.DEVICE_ID)
    keys.add(SamsungPay.WALLET_USER_ID)
samsungPaySdkFlutterPlugin.getWalletInfo(StatusListener(onSuccess: (status, bundle) async {
      val deviceId: String? = walletData.getString(SamsungPay.DEVICE_ID)
      val walletUserId: String? = walletData.getString(SamsungPay.WALLET_USER_ID)
    }, onFail: (errorCode, bundle) {

      Util.showError(context, errorCode, bundle);
    }));

Adding a Card to Samsung Wallet

Your issuer app calls the addCard() API method of CardManager to add a card to Samsung Wallet. By providing the required card details, your app can make it convenient and easy for users to add their bank-issued debit/credit cards to Samsung Wallet directly from your app without additional steps, like switching between apps.

For most issuers, getWalletInfo() suffices for requesting current wallet information. The response from Samsung Wallet tells the issuer app whether or not the user’s card has already been added to Samsung Wallet or is ineligible for provisioning. It is therefore recommended that you call getWalletInfo() before displaying the Add to Samsung Pay button. If the card is eligible, display the “add” button and, if the user taps it, call addCard().

The addCard() result is delivered to AddCardListener, which provides the following events:

onSuccess() - called when the operation succeeds; provides information and status regarding the added card.

onFail() - called when the operation fails; returns the error code and extra bundle data such as EXTRA_ERROR_REASON or EXTRA_REQUEST_ID (if provided).

onProgress() - called to indicate the current progress of the 'addCard()' operation; can be used to show a progress bar to the user in the issuer app. This callback is supported for TSM solution issuers in China and Spain.

Here’s an example of how to use the addCard() API method in your issuer app:

String cardType = WalletCard.CARD_TYPE_CREDIT_DEBIT;
String tokenProvider = AddCardInfo.PROVIDER_ABCD;
String testPayload = "TestPayloadCardInfoforFlutterPlugin";
Map<String, dynamic> cardDetail = {};

cardDetail[AddCardInfo.EXTRA_PROVISION_PAYLOAD] =  testPayload;

var addCardInfo = AddCardInfo(cardType, tokenProvider,cardDetail);

MyApp.samsungPaySdkFlutterPlugin.addCard(addCardInfo, AddCardListener(onSuccess: (status, card){

    print("Success : $status / Data : $card");

},onFail: (errorCode, bundle){

        Util.showError(context, errorCode, bundle);

print("Error : $errorCode / Data : $bundle");

    },ON-PROGRESS: (currentCount, totalCount, bundle){

print("currentCount : $currentCount / totalCount : $totalCount / Data : $bundle");

  }));

Adding a Co-badge card to Samsung Pay

Co-badge payment cards include two payment brands or networks.
When adding a Co-badge card using push provisioning, you need to supply the card details for both networks: one as the primary and the other as the secondary.

Issuer app calls the addCobadgeCard() API method of CardManager to add a Co-badge card to Samsung Pay. In most cases, calling getWalletInfo() will suffice to request current wallet information. The response from Samsung Pay indicates whether the user's Co-badge card has already been added to Samsung Pay or is ineligible for provisioning. Therefore, it is advisable to call getWalletInfo() before displaying the Add to Samsung Pay button. If the Co-badge card is eligible, display the "add" button and, upon user tapping, call addCobadgeCard().

Important
Please remember to refer to the relevant issuer implementation guide(s) and specifications provided by each card network and ensure that your partner app and server adhere to their specific requirements.

The addCobadgeCard() result is delivered to AddCardListener, which provides the following events:

  • onSuccess() - called when the operation succeeds; provides information and status regarding the added card.
  • onFail() - called when the operation fails; returns the error code and extra bundle data such as EXTRA_ERROR_REASON or EXTRA_REQUEST_ID (if provided).
  • onProgress() - called to indicate the current progress of the 'addCard()' operation; can be used to show a progress bar to the user in the issuer app. This callback is supported for TSM solution issuers in China and Spain.

Here’s an example of how to use the addCobadgeCard() API method in your issuer app.

Note
Samsung Pay does not provide detailed payload information; generate the provisioning payload in accordance with your card networks specifications.

String cardType = WalletCard.CARD_TYPE_CREDIT_DEBIT;

String primarytokenProvider = AddCardInfo.PROVIDER_ABCD;
//Provide your primary card network payload
String testPrimaryPayload = "ThisIsTestPrimaryPayloadCardInfo1234567890";

String secondarytokenProvider = AddCardInfo.PROVIDER_EFGH;
//Provide your secondary card network payload
String testSecondaryPayload = "ThisIsTestSecondaryPayloadCardInfo1234567890";

Map<String, dynamic> primaryCardDetails={};
primaryCardDetails[AddCardInfo.EXTRA_PROVISION_PAYLOAD] = testPrimaryPayload;

Map<String, dynamic> secondaryCardDetails={};
secondaryCardDetails[AddCardInfo.EXTRA_PROVISION_PAYLOAD] = testSecondaryPayload;

var primaryAddCardInfo = AddCardInfo(cardType, primarytokenProvider, primaryCardDetails);
var secondaryAddCardInfo = AddCardInfo(cardType, secondarytokenProvider, secondaryCardDetails);

MyApp.samsungPaySdkFlutterPlugin.addCobadgeCard(primaryAddCardInfo, secondaryAddCardInfo, AddCardListener(onSuccess: (status, card){

    print("Success : $status / Data : $card");

},onFail: (errorCode, bundle){

print("Error : $errorCode / Data : $bundle");

},ON-PROGRESS: (currentCount, totalCount, bundle){

print("currentCount : $currentCount / totalCount : $totalCount / Data : $bundle");

}));