Payment Card Push Provisioning Using Samsung Pay SDK
samsung pay sdk which allows you to use samsung wallet’s features effortlessly. the samsung pay android sdk consists of android-based apis to perform transactions using samsung wallet. it helps to implement simple payment solutions, which boost your businesses' growth to the next level. to understand the business and possibilities, visit the samsung pay sdk portal for more information. what is push provisioning? push provisioning is one of the major features of the samsung pay sdk. it allows an issuer bank to push the payment experience to a digital wallet. it simplifies the process of adding a payment card as it can be done with a single tap of a finger. the normal process is time consuming since it involves multiple steps, and the user needs to enter their card information. with push provisioning, the process is easier as it can be done with a single tap, and it's also secure because the process is performed from the issuer application. this tutorial demonstrates how to implement the push provisioning feature in an issuer application with the samsung pay sdk. figure 1: samsung pay push provisioning concept prerequisite to use the samsung pay sdk, you must be an official samsung partner. for information about the partnership process, see the samsung pay member guide. as a samsung pay sdk partner, you can utilize this tutorial while implementing push provisioning. sdk integration to download the samsung pay sdk, go to samsung developers portal > samsung pay > download . when the download is complete, a .jar file called “samsungpaysdk_x.xx.xx_release.jar” can be found under the libs folder. add the samsung pay sdk .jar file to the libs folder of your android project using android studio or file explorer. navigate to the build.gradle file of your application module and enter the following dependency to the dependencies block: implementation files('libs/samsungpaysdk_x.xx.xx_release.jar') if the target sdk version is 30 or higher (android 11 or r-os), include the following <queries> element in androidmanifest.xml. for more information, see declare package visibility needs. <queries> <package android:name="com.samsung.android.spay" /> </queries> since we are using the latest sdk, set the api level to 2.18. we recommend using the updated version of the samsung pay sdk for a better user experience. implement the following code in the <application> element of androidmanifest.xml: <meta-data android:name="spay_sdk_api_level" android:value="2.18" /><!-- most recent sdk version is recommended to leverage the latest apis--> configure the debug or release mode for your project as follows: for testing and qa, set the debug mode value to y. this mode requires the allowed samsung account(s) list to test. for market release to end users, set the debug mode value to n. <meta-data android:name="debug_mode" android:value="n" /><!--set to y if debug mode--> let’s get started since the main functionalities in this tutorial are based on push provisioning, we need to initialize the samsungpay and cardmanager classes first. these two classes take the same parameters to construct, which are context and an instance of the partnerinfo class. the partnerinfo object contains information about partners, which is to validate the request from the issuer application. private val partnerinfo = partnerinfoholder.getinstance(context).partnerinfo private val samsungpay= samsungpay(context,partnerinfo) private val cardmanager = cardmanager(context, partnerinfo) check if samsung wallet is ready since the samsung pay sdk depends on samsung wallet, you need to ensure that samsung wallet is prepared for transactions. check the samsung wallet status before the sdk api call using the getsamsungpaystatus() method. if you get the "spay_ready" status, you can proceed further to call any api. for more details, see the programming guide. samsungpay.getsamsungpaystatus(object : statuslistener { override fun onsuccess(status: int, bundle: bundle?) { if(status == spaysdk.spay_ready){ //enable samsung pay sdk functionalities } else{ //disable samsung pay sdk functionalities } } override fun onfail(status: int, bundle: bundle?) { //disable samsung pay sdk functionalities } }) check if the card is added during development, you may need to know whether the card is already added to samsung wallet or not. to get a list of cards that have already been added to the wallet, use the getallcards() method. for card-related operations, such as getting cards from samsung wallet, the cardmanager class is the responsible one to perform. this means that the getallcards() method is a property of the cardmanager class. this method takes a bundle and an interface as parameters, so it returns the result based on the operation. notethe getsamsungpaystatus() method must be called before the getallcards() method. the getallcards() method cannot return a card list if the getsamsungpaystatus() method responds with a code other than spay_ready. tipone of the most common issues during development is that the getallcards() method returns empty data even though a card has been added. the main reason for this issue is that the card issuer name and issuer name on the samsung pay portal are not the same. for more information, see the faq & troubleshooting page. val getcardlistener: getcardlistener = object : getcardlistener { override fun onsuccess(cards: list<card>) { //show cards } override fun onfail(errorcode: int, errordata: bundle) { //show error } } cardmanager.getallcards(null, getcardlistener) configure your payload the getwalletinfo() method is designed to request wallet information from the samsung wallet application prior to performing the add card operation. wallet information can be mandatory or optional for token providers for payload configuration. for visa, wallet information is mandatory, and you have to use it while building the payload. val keys = arraylist<string>() keys.add(samsungpay.wallet_dm_id) keys.add(samsungpay.device_id) keys.add(samsungpay.wallet_user_id) val statuslistener: statuslistener = object : statuslistener { override fun onsuccess(status: int, walletdata: bundle) { val deviceid: string? = walletdata.getstring(samsungpay.device_id) val walletaccountid: string? = walletdata.getstring(samsungpay.wallet_user_id) //build payload } override fun onfail(errorcode: int, errordata: bundle) { //show error } } samsungpay.getwalletinfo(keys, statuslistener) complete the push provisioning the last command to execute the push provisioning operation in our tutorial is the addcard() method, which is required to perform the push provisioning in samsung wallet. the payload we have created must be delivered with the addcard() method as a parameter. the payload is a tricky part where partners can sometimes get confused or misguided. to be clear, samsung does not provide the payload for push provisioning. the payload is defined between the issuer and the token provider, and it varies based on different issuers and token providers. samsung only delivers the payload to the token provider without consuming anything. the addcard() method also takes a callback as a parameter to return the result based on the operation. tipfor push provisioning of a payment card, samsung pay does not store any card information nor provide any payload for adding cards. so, the issuer needs to provide the payload in a format that is defined in the token provider specification. the issuer and the token provider have their own agreement of data sharing, payload, and encryption. samsung pay is only a medium for this process. val tokenizationprovider = addcardinfo.provider_abcd val carddetail = bundle() carddetail.putstring(extra_provision_payload, payload) var cardtype = card.card_type_credit_debit val addcardinfo = addcardinfo(cardtype, tokenizationprovider, carddetail) val addcardlistener: addcardlistener = object : addcardlistener { override fun onsuccess(status: int, card: card) { //show successful message } override fun onfail(errorcode: int, errordata: bundle) { //show error } override fun onprogress(currentcount: int, totalcount: int, bundledata: bundle) { //extra event for operation count } } cardmanager.addcard(addcardinfo, addcardlistener) summary push provisioning is the powerful experience of sharing information to a digital wallet, and digital wallets transform this experience to the next level by facilitating transactions within seconds. samsung wallet handles these operations and helps the digital payment system to its next step. for more information about the samsung pay sdk, visit the samsung pay developers portal. if you face any issues during sdk implementation, contact the developer support team.