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:
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()
}
}
We use cookies to improve your experience on our website and to show you relevant
advertising. Manage you settings for our cookies below.
Essential Cookies
These cookies are essential as they enable you to move around the website. This
category cannot be disabled.
Company
Domain
Samsung Electronics
developer.samsung.com, .samsung.com
Analytical/Performance Cookies
These cookies collect information about how you use our website. for example which
pages you visit most often. All information these cookies collect is used to improve
how the website works.
Company
Domain
Samsung Electronics
.samsung.com
Functionality Cookies
These cookies allow our website to remember choices you make (such as your user name, language or the region your are in) and
tailor the website to provide enhanced features and content for you.
Company
Domain
Samsung Electronics
developer.samsung.com, google.account.samsung.com
Preferences Submitted
You have successfully updated your cookie preferences.