Check card eligibility

To check the card brand information for the payment cards in the customer's Samsung Wallet, use the requestCardInfo() method, provided by the PaymentManager (for the Samsung Pay SDK for Android) or SamsungPaySdkFlutter (for the Samsung Pay SDK for Flutter) class. The method allows you to determine whether you support any of the customer's cards. For example, if your app accepts one card brand exclusively but the customer has no cards in Samsung Wallet matching this brand, your app can hide the Samsung Pay button during checkout.

To retrieve the card brand for each of the customer's cards:

  1. Make sure you have checked the Samsung Pay status on the customer's device and the returned status is SPAY_READY.

  2. Call the requestCardInfo() method. You can ignore the optional requestFilter parameter, it is reserved for future use.

    The result is delivered to the CardInfoListener interface, which provides the following events:

    • onResult(): Called when the operation is successful and returns the brand details of the cards. If no cards are present, the result is empty.
    • onFailure(): Called when the operation fails.

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

Samsung Pay SDK for Android:

val serviceId = "partner_app_service_id"
val bundle = Bundle()
bundle.putString(SamsungPay.PARTNER_SERVICE_TYPE, SpaySdk.ServiceType.INAPP_PAYMENT.toString())
val partnerInfo = PartnerInfo(serviceId, bundle)
val paymentManager = PaymentManager(context, partnerInfo)
paymentManager.requestCardInfo(Bundle(), cardInfoListener) // Get card brand list
// CardInfoListener is for listening requestCardInfo() callback events

val cardInfoListener: CardInfoListener = object : CardInfoListener {
    // This callback is received when the card information is retrieved successfully
    override fun onResult(cardResponse: List<CardInfo>) {
        var visaCount = 0
        var mcCount = 0
        var amexCount = 0
        var dsCount = 0
        var brandStrings = "Card Info : "
        var brand: SpaySdk.Brand?
        for (i in cardResponse.indices) {
            brand = cardResponse[i].brand
            when (brand) {
                SpaySdk.Brand.AMERICANEXPRESS -> amexCount++
                SpaySdk.Brand.MASTERCARD -> mcCount++
                SpaySdk.Brand.VISA -> visaCount++
                SpaySdk.Brand.DISCOVER -> dsCount++
                else -> { /* Other card brands */
                }
            }
        }
        brandStrings += "  VI = $visaCount,  MC = $mcCount,  AX = $amexCount,  DS = $dsCount"
        Log.d(TAG, "cardInfoListener onResult  : $brandStrings")
        Toast.makeText(context, "cardInfoListener onResult" + brandStrings, Toast.LENGTH_LONG).show()
    }
    /*
     * This callback is received when the card information cannot be retrieved.
     * For example, when the SDK service in the Samsung Wallet app dies abnormally.
     */
    override fun onFailure(errorCode: Int, errorData: Bundle) {
        Toast.makeText(context, "cardInfoListener onFailure : " + errorCode,
            Toast.LENGTH_LONG).show()
    }
}

Samsung Pay SDK for Flutter:

samsungPaySdkFlutterPlugin.requestCardInfo(cardInfoListener){onResult:(paymentCardInfo)

      showCardList(paymentCardInfo);
  
    }, onFailure:(errorCode, bundle){
  
      showError(errorCode, bundle);
  
    };