Add a standard card

To add a standard debit or credit card to Samsung Wallet, use the addCard() method, provided by the CardManager (for the Samsung Pay SDK for Android) or SamsungPaySdkFlutter (for the Samsung Pay SDK for Flutter) class. As you can provide the necessary card details without customer input, this method allows direct provisioning without switching between apps:

  1. Gather the necessary card and wallet details in a provisioning payload, following the card network's requirements.

  2. Call the addCard() method. The result is delivered to the AddCardListener interface, which provides the following events:

    • onSuccess(): Called when the operation is successful and returns information and status for the card.
    • onFail(): Called when the operation fails.

The following code snippet is an example of using the addCard() method:

Samsung Pay SDK for Android:

val cardType = Card.CARD_TYPE_CREDIT
val tokenizationProvider: String = AddCardInfo.PROVIDER_ABCD
// Samsung Pay does not provide detailed payload information; generate the provisioning payload in
// accordance with your card network specifications
val testPayload = "ThisIsTestPayloadCardInfo1234567890"

val cardDetail = Bundle()
cardDetail.putString(EXTRA_PROVISION_PAYLOAD, testPayload)
val addCardInfo = AddCardInfo(cardType, tokenizationProvider, cardDetail)

cardManager.addCard(addCardInfo, object : AddCardListener {
    override fun onSuccess(status: Int, card: Card?) {
        Log.d(TAG, "onSuccess callback is called");
    }

    override fun onFail(errorCode: Int, errorData: Bundle?) {
        Log.d(TAG, "onFail callback is called");
// Check extra error codes in the errorData bundle,
// such as SamsungPay.EXTRA_ERROR_REASON or SamsungPay.EXTRA_REQUEST_ID (if provided)
    }
})

Samsung Pay SDK for Flutter:

String cardType; 
String tokenizationProvider;
String testPayload = "TestPayloadCardInfoforFlutterPlugin"
Map<String, dynamic> cardDetail;

cardDetail: {AddCardInfo.EXTRA_PROVISION_PAYLOAD: testPayload});

var addCardInfo = AddCardInfo(cardType: WalletCard.CARD_TYPE_CREDIT_DEBIT, tokenizationProvider: getTokenProvider(tokenProvider.toString()), cardDetail: {AddCardInfo.EXTRA_PROVISION_PAYLOAD:payload});
    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");

    }));