To confirm that the card the customer wants to enroll is not yet present in Samsung Wallet, use the getAllCards() method, provided by the CardManager (for the Samsung Pay SDK for Android) or SamsungPaySdkFlutter (for the Samsung Pay SDK for Flutter) class. As there is no need to call this method every time your app resumes, place the method within the onCreate() method rather than the onResume() method.
The getAllCards() method requests a list of all cards in the Samsung Wallet app on the same customer device where your app is running:
NoteIf your app is running on a Samsung Watch, create a WatchManager class instead of CardManager.
For the Samsung Pay SDK for Android only, create a CardManager instance with the same PartnerInfo object you used for checking the Samsung Pay status. The Samsung Pay SDK for Android uses the PartnerInfo object for caller verification.
If you are using an API level earlier than 1.4, set your issuer name or names (depending on your app or the requirements of your token service provider) in a cardFilter (for the Samsung Pay SDK for Android) or EXTRA_ISSUER_NAME (for the Samsung Pay SDK for Flutter) parameter. The parameter narrows the card list returned by Samsung Wallet to the specified issuers only. Only complete matches are returned.
Since the API level 1.4, the issuer names you have registered in the Samsung Pay Portal are automatically retrieved and the cardFilter parameter is ignored.
Call the getAllCards() method. The result is delivered to the GetCardListener interface, which provides the following events:
onSuccess(): Called when the operation is successful and returns cardId, cardStatus, and extra cardInfo data for all filtered cards.
onFail(): Called when the operation fails.
The following code snippet is an example of using the getAllCards() method:
Samsung Pay SDK for Android:
val cardFilter = Bundle()
// Since API level 1.4, cardFilter param is ignored.
// The data is retrieved from the Samsung Pay Portal
cardFilter.putString(CardManager.EXTRA_ISSUER_NAME, issuerName)
cardManager.getAllCards(null, object : GetCardListener{
override fun onSuccess(cards: MutableList<Card>?) {
// Getting card status succeeded
if (cards == null || cards.isEmpty()) {
Log.e(TAG, "No card is found")
return
} else {
// Perform operations with card data
for (s in cards) {
Log.d(TAG, "CardId: " + s.cardId + "CardStatus " + s.cardStatus)
// Get extra card data
if (s.cardInfo != null) {
val cardId = s.cardId // Since API level 2.13, ID comes from the card network
val last4FPan = s.cardInfo.getString(CardManager.EXTRA_LAST4_FPAN)
val last4DPan = s.cardInfo.getString(CardManager.EXTRA_LAST4_DPAN)
val cardType = s.cardInfo.getString(CardManager.EXTRA_CARD_TYPE)
val cardIssuerName =
s.cardInfo.getString(CardManager.EXTRA_ISSUER_NAME)
Log.d(
TAG,
"last4FPan:$last4FPan last4DPan:$last4DPan CardId: $cardId"
)
}
}
}
}
override fun onFail(errorCode: Int, errorData: Bundle?) {
// Getting card status failed
}
})
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.