Filter
-
Content Type
-
Category
Mobile/Wearable
Visual Display
Digital Appliance
Platform
Recommendations
Filter
Connect Samsung Developer Conference
websamsung wallet: mobile driver’s license / state id users will soon be able to add their driver’s license or state id to samsung wallet. initially, mobile driver’s licenses / state ids will work in a limited number of states at select tsa checkpoints to verify an id with just a tap.however, this is just the beginning. we look forward to expanding the feature to more states and adding more use cases beyond tsa checkpoints, some of which are currently not even possible with a physical id card. stay tuned. back to list
tutorials mobile
blogsamsung has invested tremendous effort in the digital economy from the very beginning and continuously facilitates millions of people who use samsung wallet. samsung wallet is one of the most used digital wallets right now in the cashless industry. it is a medium that fuels up digital currency transactions by its ease-of-use and security. to support various businesses, samsung has developed the 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.
Yasin Hosain
Connect Samsung Developer Conference
webadd to samsung wallet", a revamped partner portal with mdl sdk, and the new merchant notification system. smartthings find program tech session smartthings, iot/connectivity, open sources, mobile introducing the status and new services of smartthings find, what's new in our partnership program, and node management system(nms). smartthings innovation challenge awards open stage smartthings smartthings innovation challenge sound recognition applications tech session device ai, ai, smart appliances, mobile advancements and applications of sound recognition technology in various smart devices by samsung. the convergence of ai and iot: transforming our daily lives open stage smartthings, ai, iot/connectivity discover how ai and iot change our daily lives, making tech more intuitive and personalized, and reshaping our relationship with devices. unlocking the future of ai integration tech session device ai, ai, tizen, smart tv samsung will make screen highly interoperable with ai by empowering tizen sdk. now, we are unlocking ai cast, ai actions and recognition sdk. wallpaper translation using generative ai tech session advanced tech, ai time and weather translate your mobile device wallpaper using on-device generative ai for your daily photos. what's new in samsung health research stack? tech session advanced tech, health, open sources, platform introducing the newly rebranded samsung health research stack version 2.0, enhancing connectivity with samsung devices and services. what's new in tizen? tech session advanced tech, tizen, platform, open sources introducing the exciting features coming up in tizen 9.0 and deep diving into the latest updates. back to previous page
Develop Samsung Wallet
doc5 1 overview once your service is successfully onboarded, you gain the ability to design and deploy custom digital assets—such as boarding passes, coupons, tickets, and more—directly to samsung wallet create a base template before issuing any new wallet item or "wallet card" , you must first create a base template this serves as the foundation for your custom card types card management tools you can manage your wallet cards using two primary tools wallet partners portal ideal for creating and managing individual or smaller batches of cards provides a user-friendly interface for status management, updates, and review server api access designed for partners managing a high volume of cards allows for automation and scalable integration cards created via api are still visible and manageable through the wallet partners portal card lifecycle & status states wallet cards go through several status changes during their lifecycle each status affects what actions can be taken on a card state description draft initial state when a card is first created all fields and settings are fully editable verifying verification process by samsung administrators requires completion of general information and csr certificate signing request registration rejected card did not pass verification rejection reasons are emailed to the partner cards can be revised and resubmitted active card has been approved and is now visible to users activation is final and cannot be undone blocked card has been blocked by samsung administrator-only action important testing mode cards are automatically placed into testing mode when first created in this mode, the card is not live to end users you must manually switch testing mode off once testing is complete note testing mode cannot be re-enabled after it is turned off adding wallet cards to users wallet cards can be added to a user's samsung wallet in two ways standard add flow – user initiates the addition e g , via a qr code or deep link automatic add special case – select partners may be authorized to add cards automatically, without direct user interaction this functionality is strictly regulated and reserved for approved use cases only
Learn Code Lab
codelabintegrate samsung pay sdk flutter plugin into merchant apps for in-app payment objective learn how to integrate in-app payment with your flutter-based merchant apps using samsung pay sdk flutter plugin partnership request to use the samsung pay sdk flutter plugin, you must become an official samsung partner once done, you can fully utilize this code lab you can learn more about the partnership process by visiting samsung pay in samsung developers overview the samsung pay sdk flutter plugin allows developers to use samsung wallet features in flutter applications it is the wrapper of samsung pay sdk, which is an application framework for integrating samsung wallet features on galaxy devices the samsung pay sdk flutter plugin offers in-app payment feature that gives customers the opportunity to pay for products and services with samsung wallet set up your environment you will need the following samsung wallet app version 5 6 53, 5 8 0 samsung pay sdk flutter plugin android studio latest version recommended java se development kit jdk 11 or later flutter sdk a compatible galaxy device with android q 10 0 or android api level 29 or later android os versions noteflutter sdk must be installed and set up properly when developing flutter applications after downloading, follow the installation guide appropriate to your operating system after proper installation and setup, configure your android studio to include the flutter plugin for intellij check this editor guide for the detailed steps sample code here is a sample code for you to start coding in this code lab download it and start your learning experience! in-app payment flutter plugin sample code 20 4 mb start your project in android studio, click open to open an existing project locate the flutterinapppayment project from the directory, and click ok go to file > settings > languages & frameworks > flutter to change the flutter sdk path input the directory path where your flutter sdk is installed and click apply install the plugin and configure the api level add samsungpaysdkflutter_v1 01 00 folder in the project go to samsungpaysdkflutter_v1 01 00 > pubspec yaml file and click on pub get in right side of the action ribbon or run flutter pub get in the command line next, go to flutterinapppayment > pubspec yaml and add the samsungpaysdkflutter_v1 01 00 plugin under dependencies samsung_pay_sdk_flutter path /samsungpaysdkflutter_v1 01 00 warningbe careful of line alignment of pubspec yaml file, as the indentations indicate the structure and hierarchy of the data from the terminal, run flutter pub get command or click on pub get in the right side of the action ribbon configure the api level samsung pay sdk flutter plugin supports samsung pay sdk version 2 18 or later hence, we must set a valid api version latest version 2 19 of samsung pay sdk go to android > app > src > main > androidmanifest xml and add the api level in the meta-data of application tag <meta-data android name="spay_sdk_api_level" android value="2 19" /> // most recent sdk version is recommended to leverage the latest apis add the samsung pay button go to the main project, flutterinapppayment project > lib > main dart here, the ui is created using the build widget this widget shows the sample item information such as image, name, and price add a bottomnavigationbar before the end of the body of scaffold to display the samsung pay button bottomnavigationbar visibility visible isspaystatusready, child inkwell ontap { requestpaymentwithsamsungwallet ; }, child image asset 'assets/pay_rectangular_full_screen_black png' , , , check samsung pay status in main dart > myhomepage class, create an instance of samsungpaysdkflutter with valid partnerinfo service id and service type during onboarding, the samsung pay developers site assigns the service id and service type these data are used for partner verification static final samsungpaysdkflutterplugin = samsungpaysdkflutter partnerinfo serviceid service_id, data {spaysdk partner_service_type servicetype inapp_payment name} ; notethe service id is already provided in the sample code for this code lab however, this service id is for test purposes only and cannot be used for an actual application or service to change the service id in your actual application, the value of the variable service_id should be modified to check whether samsung pay is supported on your galaxy device, call the getsamsungpaystatus api and change the samsung pay button visibility accordingly in checksamsungpaystatus method, apply the following code void checksamsungpaystatus { //update ui according to samsung pay status myhomepage samsungpaysdkflutterplugin getsamsungpaystatus statuslistener onsuccess status, bundle async { if status == "2" { setstate { isspaystatusready = true; } ; } else { setstate { isspaystatusready = false; } ; _showtoast context,"spay status not ready" ; } }, onfail errorcode, bundle { setstate { isspaystatusready = false; } ; _showtoast context,"spay status api call failed" ; } ; } inside initstate method, call checksamsungpaystatus to ensure that getsamsungpaystatus api is called before any other api is called checksamsungpaystatus ; notethe getsamsungpaystatus api must be called before using any other feature in the samsung pay sdk flutter plugin create a custom payment sheet samsung pay sdk flutter plugin offers a custom type payment sheet called customsheet to customize the ui with additional payment related data here, create customsheet using the following controls amountboxcontrol it is a mandatory control to build a customsheet it provides the monetary details of the transaction addresscontrol it is used to display the billing and shipping address in makeamountcontrol method, add items and total price to build amountboxcontrol amountboxcontrol additem strings product_item_id, "item", 1199 00, "" ; amountboxcontrol additem strings product_tax_id, "tax", 5 0, "" ; amountboxcontrol additem strings product_shipping_id, "shipping", 1 0, "" ; amountboxcontrol setamounttotal 1205 00, spaysdk format_total_price_only ; in makebillingaddress method, add the following code to create billingaddresscontrol set sheetitemtype as zip_only_address while creating billingaddresscontrol to get the zip code as we are expecting to get the user's billing address from samsung wallet, set sheetupdatedlistener addresscontrol billingaddresscontrol = addresscontrol strings billing_address_id, sheetitemtype zip_only_address name ; billingaddresscontrol setaddresstitle strings billing_address ; billingaddresscontrol sheetupdatedlistener = billinglistener; return billingaddresscontrol; notefrom samsung pay sdk version 2 19 onwards, users can only add zip code as their billing address only the zip code is fetched from the user's samsung wallet instead of the full billing address implement this listener in makeupcustomsheet method to update the custom sheet when the user updates their billing address sheetupdatedlistener sheetupdatedlistener = sheetupdatedlistener onresult string controlid, customsheet sheet { if controlid == strings billing_address_id { var addresscontrol = sheet getsheetcontrol controlid as addresscontrol; setstate { postalcode = addresscontrol address! postalcode; } ; } myhomepage samsungpaysdkflutterplugin updatesheet sheet ; } ; create the shipping address in buildshippingaddressinfo method to add it in shipping addresscontrol this is the shipping address from the merchant app maddress = address addressee "jane smith", addressline1 "123 main st", addressline2 "suite 456", city "anytown", state "st", countrycode "usa", postalcode "12345", phonenumber "+1 555-123-4567", email "example@email com" ; add this address in makeshippingaddress method shippingaddresscontrol address = buildshippingaddressinfo ; finally, complete the makeupcustomsheet method by adding amountboxcontrol, billingaddresscontrol, and shippingaddresscontrol customsheet addcontrol makeamountcontrol ; customsheet addcontrol makebillingaddress sheetupdatedlistener ; customsheet addcontrol makeshippingaddress ; create a transaction request to start the payment process, the merchant app should create a transaction request with payment information in maketransactiondetailswithsheet method, add the merchant name and custom sheet in customsheetpaymentinfo customsheetpaymentinfo customsheetpaymentinfo = customsheetpaymentinfo merchantname "in app payment flutter app", customsheet makeupcustomsheet ; your merchant app must fill the following mandatory fields in customsheetpaymentinfo customsheetpaymentinfo merchantid = "123456"; customsheetpaymentinfo setordernumber "amz007mar" ; customsheetpaymentinfo setmerchantcountrycode "us" ; customsheetpaymentinfo addressinpaymentsheet = addressinpaymentsheet need_billing_send_shipping; request payment with a custom payment sheet the startinapppaywithcustomsheet api is called to request payment using a custom payment sheet in samsung pay this api requires customsheetpaymentinfo and customsheettransactioninfolistener first, implement this listener before starting the payment customsheettransactioninfolistener transactionlistener { customsheettransactioninfolistener customsheettransactioninfolistener = customsheettransactioninfolistener oncardinfoupdated paymentcardinfo paymentcardinfo, customsheet customsheet { myhomepage samsungpaysdkflutterplugin updatesheet customsheet ; }, onsuccess customsheetpaymentinfo customsheetpaymentinfo, string paymentcredential, map<string, dynamic>? extrapaymentdata { print "payment success" ; }, onfail string errorcode, map<string, dynamic> bundle { print "payment failed" ; } ; return customsheettransactioninfolistener; } lastly, call startinapppaywithcustomsheet api to start the payment in the requestpaymentwithsamsungwallet method void requestpaymentwithsamsungwallet { myhomepage samsungpaysdkflutterplugin startinapppaywithcustomsheet maketransactiondetailswithsheet , transactionlistener ; } run the app build the app by running flutter build apk --debug in the command line or going to build > flutter > build apk deploy the app on the device test it by clicking on samsung pay button to proceed with the payment transaction to thoroughly test the sample app, you must add at least one payment card to the samsung wallet app you're done! congratulations! you have successfully achieved the goal of this code lab now, you can integrate in-app payment with your flutter app by yourself! if you are having trouble, you may download this file in-app payment flutter plugin complete code 62 0 mb to learn more about developing apps for samsung pay devices, visit developer samsung com/pay
Develop Samsung Pay
doccommon flow once setup is complete, you’re ready to add the samsung pay sdk flutter plugin code within your partner app for calling the samsung pay sdk’s apis and receiving callbacks the following functionalities are ready to call through apis checking samsung wallet status activating the samsung wallet app updating the samsung wallet app checking samsung wallet status the first step in implementing the samsung pay sdk flutter plugin within your partner app is to create the samsungpaysdkflutter instance, this will check the samsung wallet status on the device it's determine the support for samsung wallet or lack thereof , and whether or not to display the samsung pay button to the user for selection as a payment option the samsung pay button also lets issuer apps add a card to samsung wallet in both instances, the partner app must have valid partnerinfo to pass to samsungpay for caller verification to set its partnerinfo, the partner app passes its serviceid sid and servicetype, both of which are assigned by the samsung pay developers portal when you create the service this will be used for checking blocked list and version control between the samsung pay sdk flutter plugin and the samsung wallet app on the device you must set the servicetype in partnerinfo to call other samsung wallet apis string serviceid; map<string,dynamic> data; static final samsungpaysdkflutterplugin = samsungpaysdkflutter partnerinfo serviceid 'partner_app_service_id', data {spaysdk partner_service_type servicetype app2app name tostring } ; after setting partnerinfo, your partner app can now call getsamsungpaystatus this method of the samsungpay class must be called before using any other feature in the samsung pay sdk flutter plugin future<void> getsamsungpaystatus statuslistener? statuslistener the result is delivered to statuslistener and provides onsucccess and onfail events check the android sdk common flow for more details the following sample code shows how to use the getsamsungpaystatus api method myhomepage samsungpaysdkflutterplugin getsamsungpaystatus statuslistener onsuccess status, bundle async { showstatus status, bundle ; }, onfail errorcode, bundle { showerror errorcode, bundle ; } ; activating the samsung walllet app the samsungpaysdkflutter class provides the following api method to activate the samsung wallet app on a device future<void> activatesamsungpay activatesamsungpay is called to activate the samsung wallet app on the same device on which the partner app is running first, the partner app must check the samsung wallet status with a getsamsungpaystatus call if the status is spay_not_ready and extra_error_reason is error_spay_setup_not_complete, the partner app needs to display an appropriate message to user, then call activatesamsungpay to launch the samsung wallet app so the user can sign in here’s an example of how to code this samsungpaysdkflutterplugin activatesamsungpay ; updating the samsung wallet app the samsungpaysdkflutter class provides the following api method to update the samsung wallet app on the device future<void> gotoupdatepage gotoupdatepage is called to update samsung wallet app on the same device on which the partner app is running as with all api calls, the partner app must first check the samsung wallet status with getsamsungpaystatus if this returns spay_not_ready and extra_error_reason is error_spay_app_need_to_update, then the partner app needs to display an appropriate message to the user and call gotoupdatepage , which launches the samsung wallet update page the following code sample reflects how to update samsung wallet samsungpaysdkflutterplugin gotoupdatepage ;
tutorials blockchain
bloghere at samsung, we want to stay on top of blockchain technology, which has the potential to revolutionize many aspects of our lives. cryptocurrency is a trillion dollar market and one of its biggest players is ethereum, a blockchain technology that allows its users to create decentralized applications (dapps) powered by its own currency, eth. the samsung blockchain platform (sbp) sdk provides android developers with a convenient platform and full set of features for developing dapps that interact with the ethereum network. transactions are the heart of any blockchain-based system. in ethereum, transactions can be initiated by either an account or a smart contract. the sbp sdk supports eth transactions, erc-20 token transactions, and erc-721 token transactions. this article describes a sample application that demonstrates how to use the sbp sdk to store and transfer erc-20 tokens, a primary transaction method on the ethereum network. you can follow along with the demonstration by downloading the sample application. the sample application connects to the hardware wallet on the device and retrieves your account details. you can then add a token to the account and create a transaction. each of these actions has been implemented with a corresponding button to help you understand the sequence of steps and visualize the result. figure 1: sample application prerequisites to implement sbp sdk features in an android application, you must integrate the sdk by downloading the aar file and adding its required dependencies. retrieving account details to retrieve your account details: configure and create an instance of the sblockchain class, which implements the sbp sdk. in the sample application, to call the onclickobjectcreate() method and create an instance of the sblockchain class, select create object. when the instance is successfully created, the message "object has been created" is displayed. figure 2: "sblockchain" class instance created connect to the hardware wallet. hardware wallets are special devices that provide secure storage for keys. the sbp sdk supports ledger nano s, ledger nano x, and samsung blockchain keystore wallets. the sample application implements support for the samsung blockchain keystore, which is a hardware wallet preloaded on selected galaxy devices. the sblockchain class allows you to access the hardwarewalletmanager class instance, which enables connecting to the hardware wallet. notefor information about integrating other hardware wallets, see getting started. in the sample application, when the hardware wallet is connected, its wallet id is shown. figure 3: hardware wallet connected restore the account information. sbp sdk manages each blockchain address as an account. the account contains the information required to sign a transaction, including the public and private key pair. you can both generate accounts for and restore your accounts from the ethereum network. once you have restored your accounts, they are saved and their details can be retrieved requiring a network operation. you only need to restore the accounts again when you change wallets. notefor more information about generating and restoring accounts, see account management. in the sample application, select create account to restore your account from the network. this is an asynchronous operation. the next time you select "create account," the account details are simply retrieved from memory. the sample application retrieves the first account in your hd path and displays its address below the "create account" button, as shown in figure 4. figure 4: account address successfully retrieved sending tokens to send an erc-20 token: add a token to the account. in the sample application, to add a token to the account, enter the contract address in the "contract address" field and select add token. noteto add the token, you must own it. for demonstration purposes, a token from the goerli faucet is added to the account and used in the following figure. figure 5: token added the following code snippet illustrates how the sample application implements adding a token. public void onclickaddtokenaccount(view view){ if (textutils.isempty(tokenaddressedittext.gettext().tostring())) { toast.maketext(mainactivity.this, "please add a token address", toast.length_short).show(); return; } addedtokenaddress = tokenaddressedittext.gettext().tostring(); boolean check = checkexistingtokenaccount(); if(check){ toast.maketext(mainactivity.this, "token already added", toast.length_short).show(); gettokenbalancebutton.setenabled(true); return; } ethereumservice.addtokenaddress((ethereumaccount) mfirstaccount, addedtokenaddress).setcallback(new listenablefuturetask.callback<ethereumaccount>() { @override public void onsuccess(final ethereumaccount account) { log.d(log_tag, "onsuccess: addtokenaccount " + account); runonuithread(()->{ gettokenbalancebutton.setenabled(true); }); getaccount(); } @override public void onfailure( @nonnull final executionexception exception) { log.e(log_tag, "onfailure: addtokenaccount " + exception); } @override public void oncancelled(@notnull interruptedexception exception) { log.e(log_tag, "onfailure: addtokenaccount " + exception); } }); } // check whether the token is already added to the account private boolean checkexistingtokenaccount(){ for (account currentaccount : accountlist) { if (currentaccount.getaddress().equals(mfirstaccount.getaddress())) { if (addedtokenaddress.equals(((ethereumaccount) currentaccount).gettokenaddress())) { return true; } } } return false; } retrieve the token balance. to ensure you have sufficient balance to make a transaction, you can check the token balance. in the sample application, select get token balance. this is a network operation and can take some time. the retrieved balance is displayed below the "get token balance" button. figure 6: token balance retrieved the following code snippet illustrates how to perform this task in two steps: first, retrieve the account associated with the token address with the gettokenaccount() method. next, pass the account into the gettokenbalance() method of the sdk to retrieve the token balance. private ethereumaccount gettokenaccount(){ ethereumaccount ethereumaccount = null; for (account currentaccount : accountlist) { if (currentaccount.getaddress().equals(mfirstaccount.getaddress())) { if (addedtokenaddress.equals(((ethereumaccount) currentaccount).gettokenaddress())) { ethereumaccount = (ethereumaccount) currentaccount; } } } return ethereumaccount; } public void onclickgettokenbalance(view view){ mtokenaccount = gettokenaccount(); if(mtokenaccount == null){ log.e(log_tag, "token account is null"); } ethereumservice.gettokenbalance(mtokenaccount).setcallback(new listenablefuturetask.callback<biginteger>() { @override public void onsuccess(biginteger tokenbalance) { runonuithread(()->{ tokenbalancetext.setenabled(true); gaspricebutton.setenabled(true); tokenbalancetext.settext(tokenbalance.tostring()); }); } @override public void onfailure(@nonnull executionexception e) { log.e(log_tag, "fetching balance is failed."); log.e(log_tag, "" + e.getmessage()); } @override public void oncancelled(@nonnull interruptedexception e) { log.e(log_tag, "fetching balance is canceled."); } }); } retrieve the gas fee. network operations on the ethereum network require gas, which is a unit that measures the effort required by the network to complete the operation. to perform a transaction, you must retrieve the gas fee and the gas limit of the transaction. the gas fee is determined by how quickly you want the transaction to be performed. in the sample application, enter the destination address and amount for the transaction, select the desired transaction speed, then select gas price. figure 7: gas fee retrieved the following code snippet illustrates how to retrieve the gas fee. public void onclickgasprice(view view) { ethereumservice.getfeeinfo(ethereumtransactiontype.eip1559).setcallback(new listenablefuturetask.callback<feeinfo>() { @override public void onsuccess(feeinfo feeinfo) { methereumfeeinfo = (eip1559feeinfo) feeinfo;; log.i(log_tag, "fee info is fetched successfully."); runonuithread(() -> { gaslimitbutton.setenabled(true); toast.maketext(getapplicationcontext(), "fee info is fetched successfully.", toast.length_short).show(); } ); } @override public void onfailure(@notnull executionexception e) { log.e(log_tag, "fetching fee info is failed."); log.e(log_tag, "" + e.getmessage()); } @override public void oncancelled(@notnull interruptedexception e) { log.e(log_tag, "fetching fee info is canceled."); } }); } retrieve the gas limit. the gas limit represents the maximum amount of work that may be required for the transaction. in the sample application, to retrieve the gas limit, select gas limit. the limit is calculated and displayed next to the "gas limit" button. noteto retrieve the gas limit, the "send account address" and "send amount" fields must not be empty. figure 8: gas limit retrieved the following code snippet illustrates how to retrieve the gas limit. public void onclickgaslimit(view view) { string toaddress = toaddressedittext.gettext().tostring(); string amount = sendamountedittext.gettext().tostring(); if (toaddress.isempty() || amount.isempty()) { toast.maketext(getapplicationcontext(), "fill send address and amount field", toast.length_short).show(); } else if(!ethereumservice.isvalidaddress(toaddress)){ toast.maketext(getapplicationcontext(), "invalid address.", toast.length_short).show(); } else { bigdecimal sendamount = new bigdecimal(amount); biginteger convertedsendamount = ethereumutils.convertethtowei(sendamount); list<type> inparams = arrays.aslist(new address(toaddress), new uint(convertedsendamount)); list outparams = arrays.aslist(new typereference<bool>() {}); string encodedfunction = functionencoder.encode(new function("transfer", inparams, outparams)); ethereumservice.estimategaslimit((ethereumaccount) mfirstaccount, toaddress, null, encodedfunction).setcallback(new listenablefuturetask.callback<biginteger>() { @override public void onsuccess(biginteger biginteger) { mgaslimit = biginteger; log.i(log_tag, "gas limit is fetched successfully."); log.i(log_tag, "gas limit is:" + biginteger.tostring()); runonuithread(() -> { sendbutton.setenabled(true); gaslimittext.settext(biginteger.tostring()); }); } @override public void onfailure(@notnull executionexception e) { log.e(log_tag, "fetching gas limit has failed."); log.e(log_tag, "" + e.getmessage()); } @override public void oncancelled(@notnull interruptedexception e) { log.e(log_tag, "fetching gas limit has been canceled."); } }); } } send the tokens. in the sample application, to send tokens using your available balance, select send. noteto confirm the transaction, samsung implements a trusted user interface (tui) with the samsung blockchain keystore to ensure that the transaction is safe and not tampered with. the tui runs completely separate from the device os, ensuring maximum security. for more information about the tui and other samsung blockchain keystore features, see what makes samsung blockchain keystore unique. when the transaction is complete, you can use the transaction hash to find the transaction details on the ethereum blockchain explorer. figure 9: transaction created the following code snippet illustrates how to create a transaction. public void onclicksendtoken(view view) { if (textutils.isempty(toaddressedittext.gettext().tostring())) { toast.maketext(mainactivity.this, "to address field must be filled!", toast.length_short).show(); return; } if (textutils.isempty(sendamountedittext.gettext().tostring())) { toast.maketext(mainactivity.this, "send amount field must be filled!", toast.length_short).show(); return; } string toaddress = toaddressedittext.gettext().tostring(); biginteger sendamount = new biginteger(sendamountedittext.gettext().tostring()); // retrieve the gas price int transactionspeedid = transactionspeedgroup.getcheckedradiobuttonid(); if (transactionspeedid == -1) { toast.maketext(getapplicationcontext(), "select a transaction speed.", toast.length_short).show(); } else { switch (transactionspeedid) { case r.id.transaction_speed_slow: mgasprice = methereumfeeinfo.getslowpriorityfee(); log.d(log_tag, "gasprice: " + mgasprice); break; case r.id.transaction_speed_normal: mgasprice = methereumfeeinfo.getnormalpriorityfee(); log.d(log_tag, "gasprice: " + mgasprice); break; case r.id.transaction_speed_fast: mgasprice = methereumfeeinfo.getfastpriorityfee(); log.d(log_tag, "gasprice: " + mgasprice); break; } } if(transactionspeedid != -1) { try { ethereumservice.sendtokentransaction( mhardwarewallet, (ethereumaccount) mtokenaccount, toaddress, addedtokenaddress, mgasprice, methereumfeeinfo.getestimatedbasefee().add(mgasprice), mgaslimit, sendamount, null ).setcallback(new listenablefuturetask.callback<transactionresult>() { @override public void onsuccess(transactionresult transactionresult) { log.d(log_tag, "transaction hash: " + transactionresult.gethash()); runonuithread(() -> toast.maketext(getapplicationcontext(), "transaction hash: " + transactionresult.gethash(), toast.length_short).show() ); } @override public void onfailure(@notnull executionexception e) { log.e(log_tag, "transaction failed."); log.e(log_tag, "" + e.getmessage()); } @override public void oncancelled(@notnull interruptedexception e) { log.e(log_tag, "transaction canceled."); } }); } catch (availabilityexception e) { log.e(log_tag, "error in sending: " + e); } } } conclusion token transactions are a vital part of the ethereum ecosystem, and the sbp sdk enables you to create wallet applications that manage erc-20 tokens and transactions. share your thoughts with us and the global blockchain developer community on the samsung blockchain developer forum. learn more about sbp sdk and its features in our recent blogs: integrate payment ui with your ethereum dapp step into the decentralized blockchain future with samsung blockchain ecosystem send trx with the samsung blockchain platform sdk additional resources on the samsung developers site the samsung developers site has many resources for developers looking to build for and integrate with samsung devices and services. stay in touch with the latest news by creating a free account and subscribing to our monthly newsletter. visit the galaxy store games page for information on bringing your game to galaxy store and visit the marketing resources page for information on promoting and distributing your android apps. finally, our developer forum is an excellent way to stay up-to-date on all things related to the galaxy ecosystem.
Samiul Hossain
Develop Samsung Pay
docunderstanding and using the sdk the samsung pay sdk is an application framework for integrating selected samsung wallet features with android-based partner apps on samsung devices the following major operations are supported in-app payment gives customers the option of paying for products and services with samsung wallet push provisioning allows customers add a bank card to samsung wallet from the issuer app by providing the required card details to integrate your partner application with the samsung pay sdk, the following components are included your sdk download samsungpay jar contains classes and interfaces of the samsung pay sdk which need to be integrated to partner apps javadoc provides descriptions of the apis included in the samsung pay sdk, along with sample code showing how to use them sample merchant app and sample issuer app showing how samsung pay apis can be coded in a finished android project all major operations of samsung pay sdk are implemented for demonstration purposes samsung pay sdk architecture the following diagram shows a high-level architecture revealing the general interactions between the samsung pay sdk and a partner app viewed at this level, the partner apps leverage the samsung pay sdk to perform the operations shown ― push provisioning and opening favorite cards for issuers; online payments for merchants ― with samsung pay the key components involved are partner app - merchant- or issuer-developed app for making online/offline payments and provisioning payment cards through samsung wallet samsung pay sdk - sdk integrated into the partner app for direct communication with samsung wallet samsung wallet app - wallet app that the samsung pay sdk communicates with financial network - comprises the payment gateways, acquirers, card associations, and issuers that participate in transaction processing under agreement with the merchant the main classes comprising the samsung pay sdk include samsungpay – used by the partner app to get the samsung pay sdk information and the status of samsung wallet app on the device paymentmanager – provides payment/transaction functionality cardmanager – manages card list get, add, update functionality watchmanager – manages all functions related to samsung pay watch cardinfolistener – interface for requestcardinfo result from samsung wallet customsheettransactioninfolistener – interface for transaction success/failure callbacks from samsung wallet use case in-app payment the most common in-app online payment use cases take the following form merchant app presents user with the option of making payment with samsung wallet upon the user selecting the samsung pay option, the merchant app calls the apis included in the samsung pay sdk to initiate a transaction with samsung wallet app samsung wallet app responds with the tokenized payment information necessary to complete the transaction merchant app forwards this payment information to the designated payment gateway pg , either directly through the merchant's web server, or indirectly via the samsung-pg interface server for normal transaction processing use case app-to-app push provisioning the push provisioning use case ― adding payment cards to samsung wallet from the card issuer’s app ― typically takes this form the user logs into the issuer app the issuer app checks if samsung wallet is activated on the device and ready to use if it is in the ready status, the issuer app displays an add button for cards not currently registered/enrolled with the samsung wallet app if the add card option is selected, the issuer app calls an api to push the proper payload data to samsung wallet while the card is being provisioned, samsung wallet stays in background setting up sdk development environment the importance of maintaining a good development environment cannot be overstated for integrating the samsung pay sdk with your partner app, the following prerequisites and recommendations help ensure a successful sdk implementation system requirements the samsung pay sdk is designed exclusively for samsung mobile devices supporting samsung pay and running android lollipop 5 1 android api level 22 or later versions of the android os the sdk’s in-app payments functionality requires android 6 0 m android api level 23 or later versions of the android os note as of sdk version 1 5, if the device runs android lollipop 5 1 android api level 22 or an earlier version, the getsamsungpaystatus api method returns a spay_not supported status code merchant apps still using samsung pay sdk 1 4 or earlier not recommended must check the android version running their app use the following snippet to determine the os version running on a device and whether or not to display the samsung pay button in your partner app import android os build; // in-app payment supported on android m or above // check android version of the device if build version sdk_int < build version_codes m { //hide samsung pay button } service registration to develop a samsung pay sdk service, merchants and issuers need to register for an account with samsung pay developers in order to create the appropriate service type for their applications here are some helpful links inside the portal become a member https //pay samsung com/developers/tour/memberguide create services https //pay samsung com/developers/tour/svcguide register apps https //pay samsung com/developers/tour/appsguide manage services and apps https //pay samsung com/developers/tour/svcnappsguide add samsung pay sdk to your project be sure to do the following before attempting to use the sdk if not already part of your environment, download and install an ide android studio is recommended download the samsung pay sdk the sdk package has the following directory structure folder contents docs javadoc – api reference documentation libs samsungpay jar sdk java archive file – contains the samsung pay apis to be used by your partner app samples sample apps configure your ide to integrate the samsung pay sdk with your partner app a add samsungpay jar to the libs folder of your android project b go to gradle scripts > build gradle and enter the following dependency dependencies { compile files 'libs/samsungpay jar' } c import the sdk package into your code import com samsung android sdk samsungpay v2; proguard rules if your app s have any issue with proguard, the following rules are recommended dontwarn com samsung android sdk samsungpay ** -keep class com samsung android sdk ** { *; } -keep interface com samsung android sdk ** { *; } when dexguard is employed, the following additional rules apply -keepresourcexmlelements manifest/application/meta-data@name=spay_sdk_api_level android r os targetsdkversion 30 informationfrom android r os if the target sdk version is 30 , you must include the following <queries> element in the androidmanifest <?xml version="1 0" encoding="utf-8"?> <manifest xmlns android="http //schemas android com/apk/res/android" xmlns tools="http //schemas android com/tools" package="xxx xxx xxx xxx"> <queries> <package android name="com samsung android spay" /> <package android name="com samsung android samsungpay gear" /> </queries> configuring api level api level attributes as of sdk version 1 4, enhanced version control management has been introduced to improve backward compatibility and handle api dependency from country and service type for example, if a partner integrates the latest sdk―for instance, api level 2 22―but continues to use apis based in level 1 4, the partner app remains compatible with samsung wallet apps supporting api level 1 4 without the necessity of upgrading the samsung pay app the chief characteristics and properties of the api level include every api starting from version 1 4 has an api level assigned based on the sdk version number in which it is introduced the sdk’s javadoc reference can be filtered by api level so you can determine the minimum api level you need to configure in the metadata section of your app’s androidmanifest file the earliest possible version is 1 4 this lets you use the api level defined in your androidmanifest without having to trigger an upgrade of the samsung wallet app on the user’s device implement the following usage in your androidmanifest <application <meta-data android name="spay_sdk_api_level" android value="2 22" /> // most recent sdk version is recommended to leverage the latest apis but it need to be set to 2 17 for russia </application> partner app verification in partner verification process samsung pay sdk verify your registered app, version in samsung pay portal and service it also determines device and app compatibility your app needs to verify the presence of the samsung wallet app on the device, its status, and whether or not its version is sufficient to support your implementation of the sdk appendix a common terminology terminology description aavs automatic add value service aidl android interface definition language for communication merchant a business entity engaged in retail e-commerce that provides an online checkout service for purchasing its products and/or services to registered end users issuer financial institution empowered to issue credit and/or debit payment cards to qualified consumers and businesses payment gateway pg e-commerce app service provider equipped to authorize credit card payments for e-businesses, online retailers, bricks and clicks, or traditional brick and mortar payment token secure method for payment ensuring that a cardholder’s information is not exploited by unauthorized parties samsung pay samsung’s proprietary mobile wallet app and payment system samsung pay service the server and service components of samsung pay samsung pay watch samsung pay app on samsung galaxy watches to support payment system eligibility check a query by third-party apps to check whether or not samsung pay is supported/activated/ready-to-use on a samsung device mst magnetic secure transmission tui trusted user interface
tutorials mobile
blogdigital identity verification has become a rising topic in the current technological landscape. samsung wallet allows samsung galaxy device users to securely register their state-issued us driver's license in their device, letting them use it as a mobile driver's license (mdl). through the "verify with wallet" (vww) functionality, samsung wallet provides android developers with the ability to authenticate a user's identity directly from their application by utilizing the user's registered mdl on the device. the implementation of the functionality is based on and is fully compliant with the iso 18013-5 standard. in this article, we explore the complete process of implementing verify with wallet in an android application. prerequisites in order to complete the tasks in this article and implement a complete sample application for verifying a user's identity, you need the following: valid us driver's license or state id us region samsung galaxy device with mdl support complete the samsung wallet partner onboarding process understanding the verify with wallet process samsung wallet offers a native relying party (rp) sdk for android applications. rp sdk is an app2app sdk designed for enabling samsung wallet's mdl service in online use cases. by integrating this sdk, you can leverage the vww functionality within their applications. in your application, you need to create a json object for defining the request and a json payload for the relying party card. then, you can utilize the rp sdk to create a valid mdoc request using the provided information. finally, the request needs to be sent to the samsung wallet application. in response, samsung wallet sends an encrypted response back to the application, which contains the requested information in a cbor encoded format. the application can then decode the provided data and use it as necessary. refer to the iso 18013-5 standard, aamva mdl guidelines and the samsung wallet documentation for a better understanding of the vww process. implementing the verify with wallet functionality in your android application the process of implementing vww in an android application includes creating a relying party card for samsung wallet, downloading and integrating the rp sdk into the android application and implementing the necessary functions in the android application for completing the verification process. creating a relying party wallet card template in the samsung wallet partners portal in order to implement and use the vww functionality, you need a wallet card of the relying party type for this purpose. to create a relying party wallet card template: go to the samsung wallet partners portal. select wallet card > create wallet cards. from wallet card templates, select relying party. select the applicable service location and authentication issuer from the advanced setting section. make sure to select the proper values for the card, otherwise the verification process may not work. figure 1: creating a relying party card for vww integrating the rp sdk in an android application once the relying party card template has been created, we can download and integrate the rp sdk to work with the android application. step 1: download the rp sdk for android to download the rp sdk: download the zip file containing the latest rp sdk release aar file from samsung wallet code resources on the samsung developer website. extract the aar file from the downloaded zip file. copy and paste the downloaded rp-sdk-x.xx-release.aar file inside a new directory in the android studio project (for example, \libs\). step 2: add android manifest permissions to implement the verify with wallet functionality, the application needs both the internet access permission and the ability to query the installed samsung wallet application. to provide the application with these permissions, open the androidmanifest.xml file in the android studio project and add the following lines: <uses-permission android:name="android.permission.internet" /> <queries> <package android:name="com.samsung.android.spay" /> </queries> step 3: add gradle dependencies in the application's build.gradle file, load the rp sdk aar file and the necessary additional dependencies for using the sdk, as follows: // load rp sdk aar file implementation(files("libs/rp-sdk-1.05-release.aar")) //cbor decoding dependencies implementation("com.upokecenter:cbor:4.0.1") implementation("com.augustcellars.cose:cose-java:1.1.0") // other dependencies implementation("com.google.code.gson:gson:2.11.0") implementation("org.bouncycastle:bcprov-jdk15to18:1.66") implementation("com.nimbusds:nimbus-jose-jwt:9.37.3") implementation("io.reactivex.rxjava2:rxjava:2.2.21") implementation("io.reactivex.rxjava2:rxkotlin:2.4.0") implementation("io.reactivex.rxjava2:rxandroid:2.1.1") implementation("com.squareup.okhttp3:okhttp:4.11.0") after these steps, the rp sdk is ready for use in your android application. configuring the android application for verify with wallet next, we need to complete the implementation of the verify with wallet functionality in your android application. step 1: build a card payload for the relying party card first, we need to create a request payload for the relying party card following the specification. private fun buildapp2apppayload(): string { return payload .replace("{refid}", uuid.randomuuid().tostring()) .replace("{createdat}", system.currenttimemillis().tostring()) .replace("{updatedat}", system.currenttimemillis().tostring()) } private val payload = """ { "card": { "type": "relyingparty", "data": [ { "createdat": {createdat}, "updatedat": {updatedat}, "language": "en", "refid": "{refid}", "attributes": { "clientpackagename": "com.ahsan.verifyappsample", "clienttype": "app", "fontcolor": "#ffffff", "logoimage": "https://kr-cdn-gpp.mcsvc.samsung.com/mcp25/resource/2024/9/4/b940b7a2-0f55-42ce-8da7-025d50dbb6b7.png", "logoimage.darkurl": "https://kr-cdn-gpp.mcsvc.samsung.com/mcp25/resource/2024/9/4/b940b7a2-0f55-42ce-8da7-025d50dbb6b7.png", "logoimage.lighturl": "https://kr-cdn-gpp.mcsvc.samsung.com/mcp25/resource/2024/9/4/b940b7a2-0f55-42ce-8da7-025d50dbb6b7.png", "providername": "samsung verification sample" } } ] } } """.trimindent() step 2: build the applink the applink is a tokenized url that is similar to the cdata tokens used for samsung wallet cards. the samsung wallet rp sdk includes a function to generate the applink using the payload and the partner credentials (private key, public key, partner id, card id, certificate id, etc.). to build the applink, you can simply call the rpclientapis.buildapplink() function with the required parameters: val rpclientapis = rpclientapis(this) val applink = rpclientapis.buildapplink( partnerid = partner_id, cardid = card_id, payload = buildapp2apppayload(), samsungpublickey = samsung_certificate, partnerpublickey = partner_certificate, partnerprivatekey = partner_private_key, partnercertificateid = certificate_id, isstagingserver = true ) step 3: build the request data finally, once the applink creation is complete, we can send the verification request using the rp sdk. before sending the request, we need to specify exactly which information we wish to retrieve. for this purpose, we need to create a json document following the iso 18013-5 specification and specify the fields we wish to retrieve in the response. it is possible to request for the following fields in the request data under the "org.iso.18013.5.1" namespace: portrait family_name given_name document_number age_in_years resident_address birth_date issue_date expiry_date sex height weight_range weight eye_colour hair_colour organ_donor driving_privileges veteran additionally, it is also possible to request for the following 3 fields, under the "org.iso.18013.5.1.aamva" namespace: domestic_driving_privileges dhs_compliance edl_credential in our example, we only try to retrieve the following 4 fields: family_name, age_in_years, issue_date, and expiry_date. in the following code example, we build the request string accordingly: val requestdata = """ { "doctype": "org.iso.18013.5.1.mdl", "namespaces": { "org.iso.18013.5.1": { "family_name": true, "age_in_years": true, "issue_date": true, "expiry_date": true } } } """.trimindent() step 4: create the onresponselistener class when using the vww rp sdk, it is necessary to create a listener class for both sending the request and for receiving and processing the response from the mdoc server. for our example, let's create an empty placeholder onresponselistener class which extends the rp sdk's onresponselistener class. class onresponselistener(private val requestdata: string) : rpclientapis.onresponselistener{ override fun ongetmdocrequestdata(deviceengagementbytes: bytearray): bytearray? { todo("not yet implemented") } override fun onmdocresponse(encryptedresponsebytes: bytearray) { todo("not yet implemented") } override fun onmdocresponsefailed(exception: exception) { log.e(tag, "response processing failed", exception) } } initiating the verification request to initiate the identity verification process, we need to establish a secure session and send a structured request to the samsung wallet application. we can use the previously created onresponselistener class for this purpose. step 1: define the ongetmdocrequestdata() function for sending the request data inside the ongetmdocrequestdata() function, we need to do 2 things for establishing a secure encrypted session: generate an elliptic curve key pair build session establishment bytes following the iso-18013-5 specification. once the key pair is generated, we can use this key pair, the device engagement bytes, and the previously created request data for building the encrypted session establishment bytes. the device engagement bytes are provided automatically inside the ongetmdocrequestdata() function by the rp client sdk. private val securerepository = securerepository() override fun ongetmdocrequestdata(deviceengagementbytes: bytearray): bytearray? { val keypair = securerepository.generateeckeypair() val encryptedsessionestablishmentbytes = securerepository.buildsessionestablishment(requestdata, deviceengagementbytes, keypair) return encryptedsessionestablishmentbytes!! } for further information regarding generating the key pair and building the session establishment bytes, check the provided sample code. step 2: initiate a verification request with the applink once the ongetmdocrequestdata() function is ready, we can use the request() function to initiate the verification request. val sessionid = uuid.randomuuid().tostring() val wallet_package = "com.samsung.android.spay" rpclientapis.request( wallet_package, sessionid, applink, onresponselistener(requestdata) ) processing the request response once the mdoc request has been sent and processed successfully, the application should receive a bytearray as response in the onmdocresponse() function inside the listener class. this bytearray is an encrypted json object. once decrypted, the response should look like the following: { "documents": [ { "issuersigned": { "namespaces": { "org.iso.18013.5.1": [ "pghkawdlc3rjrbku-mzyyw5kb21uagnkngduzdl5z2i1ctrjadv4znpxzwxlbwvudelkzw50awzpzxjrzxhwaxj5x2rhdgvszwxlbwvudfzhbhvlwhqymdmxltexltixvda3ojawojawwg", "pghkawdlc3rjrbknbwzyyw5kb21udjg1nmsydzizzzq3ohk5ctq0ahjxzwxlbwvudelkzw50awzpzxjsywdlx2lux3llyxjzbgvszw1lbnrwywx1zrgr", "pghkawdlc3rjrblvwwzyyw5kb21ubnrtdnj5oxlucxcyzjy2bmp2nxrxzwxlbwvudelkzw50awzpzxjqaxnzdwvfzgf0zwxlbgvtzw50vmfsdwxaddiwmjmtmtetmdhumdc6mda6mdba", "pghkawdlc3rjrbnxqwzyyw5kb21uoxjqd2nydjz6cxpqzm1xajnkcnhxzwxlbwvudelkzw50awzpzxjrzmftawx5x25hbwvszwxlbwvudfzhbhvlzufoc2fu" ] }, "issuerauth": [ "dcba", { "33": "..." }, "...", "..." ] }, "devicesigned": {…}, "doctype": "org.iso.18013.5.1.mdl" } ], "version": "1.0", "status": 0 } the values inside the org.iso.18013.5.1 json array are the information we requested, in the cbor (concise binary object representation) format. for example, if we decode the value: "pghkawdlc3rjrblvwwzyyw5kb21ubnrtdnj5oxlucxcyzjy2bmp2nxrxzwxlbwvudelkzw50awzpzxjqaxnzdwvfzgf0zwxlbgvtzw50vmfsdwxaddiwmjmtmtetmdhumdc6mda6mdba", we find that this cbor object contains the issue_date field and its value is 2023-11-08t07:00:00.000z. similarly, every value provided in the array is a cbor object that can be decoded using cbor decoders to find a key-value pair containing the requested information. we can now receive the mdoc response in the onmdocresponse() function and decode it to retrieve the final requested values: override fun onmdocresponse(encryptedresponsebytes: bytearray) { val plainresponse = securerepository.decryptmdocresponse(encryptedresponsebytes) log.i(tag, "plainresponse=${plainresponse?.toprettyjson()}") val mdoccontent = mdoc18013utils.parsemdocresponse(plainresponse!!) mdoccontent.foreach { (key, value) -> log.i(tag, "$key: $value") } } here, securerepository.decryptmdocresponse() performs the decryption operation and converts the encrypted bytes into a plain json response. afterwards, the mdoc18013utils.parsemdocresponse() function takes the plain response and decodes each cbor-encoded element contained in the org.iso.18013.5.1 array and returns these values in a simplified dictionary of key-value pairs. if you wish to learn more about these functions, you can check out the provided sample code. with this step, the sample application's implementation of verify with wallet is complete. you can now build and run the application. in the sample application, once the user clicks the "verify with samsung wallet" button, the vww procedure is initiated. once the user confirms that they wish to share their information, the application will receive the requested information about the user. figure 2: complete the verification process using vww conclusion in this article, we have explored how you can integrate the verify with wallet rp sdk directly into your application and use it to verify the user's identity. feel free to integrate the rp sdk in your own application and test the verify with samsung wallet process as well. if you have any further queries regarding this process, feel free to reach out to us through the samsung developers forum. related resources iso/iec 18013-5:2021 - personal identification — iso-compliant driving licence — part 5: mobile driving licence (mdl) application mobile driver license - american association of motor vehicle administrators - aamva rp sdk download link verify with wallet api guidelines relying party card specifications sample code download link
Mobassir Ahsan
Develop Samsung Pay
docenable app to app service the following diagram illustrates the flows of the app-to-app apis for payment card push provisioning bank appsamsung wallet apptoken service providerref[checking samsungpay status]section in common flowalt[if neccessary optional ]1cardmanager getallcards 2onsuccess card cardid, card cardstatus 3request card information with card cardid4success5samsungpay getwalletinfo 6onsuccess device_id, wallet_user_id 7create provisioningpayloadwith card information & wallet informationrefer to card networks spec8cardmanager addcard payload 9request token provision10success11onsuccess flows of push provisioning apis the main classes involved are samsung pay – for fetching samsung wallet app status and wallet information on the device paymentmanager – for card provisioning and invoking favorite cards payment functionalities cardmanager – for payment card management watchmanager – for all functions related to samsung pay watch let’s now take a look at how each one works in the context of your bank app requesting registered card list in the samsung pay thegetallcards method of the cardmanager class is used to request a list of all cards currently registered/enrolled in samsung wallet on the same device running the issuer’s app to succeed, the issuer app must pass valid partnerinfo to 'cardmanager' for caller verification 'cardfilter' narrows the card list returned by samsung wallet to the issuername specified please be noted that getsamsungpaystatus must be called before getallcards getallcards could not return a cards list when getsamsungpaystatus responds with a code other than spay_ready noteto get the cards list of samsung pay watch, you have to use the watchmanager class instead of the cardmanager class as of api level sdk version 1 4, cardfilter retrieves this information from the samsung pay developers portal certain issuers may need to register multiple issuer name s with the portal, depending on their app and/or the requirements of their token service provider tsp the getallcards parameter cardfilter matches the issuer name s specified with those registered in the portal only complete matches are returned this method is typically called when your partner app wants to check the card status it does not need to be called every time the partner app resumes therefore, you should create the card list with the 'oncreate ' method, rather than the 'onresume ' method the result of a getallcards call is delivered to getcardlistener, which provides the following events onsuccess - called when the operation succeeds; provides the list of all filtered cards and their status card information includes cardid, cardstatus, and extra cardinfo data onfail - called when the operation fails here’s an example of how to use the 'getallcards ' api method in your issuer app val cardfilter = bundle // since api level 1 4, cardfilter param is ignored partner does not need to use it here // it is retrieved from the samsung pay developers portal cardfilter putstring cardmanager extra_issuer_name, issuername cardmanager getallcards null, object getcardlistener{ override fun onsuccess cards mutablelist<card>? { // getting card status is success if cards == null || cards isempty { log e tag, "no card is found" return } else { // perform operation 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 from 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 is failed } } getting wallet information the samsungpay class provides the getwalletinfo api method, which is called to request wallet information from the samsung wallet app prior to calling the addcard api, when you want to avoid duplicate provisioning your issuer app uses this information to uniquely identify the user and the samsung wallet app on a particular device wallet device management id, device id, and wallet user id noteto get wallet information of samsung pay watch, you have to use the watchmanager class instead of the cardmanager class fun getwalletinfo list<string> keys, statuslistener callback the following example demonstrates how to use it // set the serviceid assigned by the samsung pay developers portal during service creation val serviceid = "sampleserviceid" val bundle = bundle bundle putstring samsungpay extra_issuer_name, "issuer name" bundle putstring samsungpay partner_service_type, servicetype app2app tostring val pinfo = partnerinfo serviceid, bundle val samsungpay = samsungpay context, pinfo // add bundle keys to get wallet information from samsung pay // this information can be delivered to the partner server for an eligibility check val keys = arraylist<string> keys add samsungpay wallet_user_id keys add samsungpay device_id samsungpay getwalletinfo keys, object statuslistener{ override fun onsuccess status int, walletdata bundle { // log d tag, "dowalletinfo onsuccess callback is called" ; // for visa, deviceid can be set to "clientdeviceid" as defined by visa val deviceid = walletdata getstring samsungpay device_id // for visa, walletuserid can be set to "clientwalletaccountid" as defined by visa val walletuserid = walletdata getstring samsungpay wallet_user_id } override fun onfail errorcode int, errordata bundle? { log e tag, "onfail callback is called, errorcode " + errorcode ; // check the extra error codes in the errordata bundle for all the reasons in // samsungpay extra_error_reason, when provided } } adding a card to samsung pay your issuer app calls the 'addcard ' api method of cardmanager to add a card to samsung wallet by providing the required card details, your app can make it convenient and easy for users to add their bank-issued debit/credit cards to samsung wallet directly from your app without additional steps, like switching between apps noteif you want to add a card to samsung pay watch, you have to use the 'watchmanager' class instead of the cardmanager class for most issuers, getwalletinfo suffices for requesting current wallet information the response from samsung wallet tells the issuer app whether or not the user’s card has already been added to samsung wallet or is ineligible for provisioning it is therefore recommended that you call getwalletinfo before displaying the add to samsung pay button if the card is eligible, display the “add” button and, if the user taps it, call addcard for some card networks, the bin bank identification number may be required while push provisioning the bin consists of the first 6 or 8 digits of a payment card number pan and is used to identify the card's issuing bank or financial institution if your card network requires the bin while push provisioning, you can use it as extra_issuer_id refer to the addcard code snippet for an example importantremember to obtain the governing issuer implementation guide s and specifications from the respective card network and implement each network’s required handling in your partner app and server the 'addcard ' result is delivered to addcardlistener, which provides the following events onsuccess - called when the operation succeeds; provides information and status regarding the added card onfail - called when the operation fails; returns the error code and extra bundle data such as extra_error_reason or extra_request_id if provided onprogress - called to indicate the current progress of the 'addcard ' operation; can be used to show a progress bar to the user in the issuer app this callback is supported for tsm solution issuers in china and spain here’s an example of how to use the addcard api method in your issuer app 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" //bin bank identification number can be set to issuerid it is mandatory for some card network val issuerid = "123456" val carddetail = bundle carddetail putstring extra_provision_payload, testpayload carddetail putstring extra_issuer_id, issuerid 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 some extra error codes in the errordata bundle // such as samsungpay extra_error_reason or samsungpay extra_request_id if provided } override fun onprogress currentcount int, totalcount int, bundledata bundle? { log d tag,"onprogress callback is called " + currentcount + " / " + totalcount ; } } adding a co-badge card to samsung pay co-badge payment cards combine two payment brands/networks to add a co-badge card through push provisioning, you must provide two different card network details one for the primary card network and another for the secondary card network issuer app calls the addcobadgecard api method of cardmanager to add a co-badge card to samsung pay in most cases, calling getwalletinfo will suffice to request current wallet information the response from samsung pay indicates whether the user's co-badge card has already been added to samsung pay or is ineligible for provisioning therefore, it is advisable to call getwalletinfo before displaying the add to samsung pay button if the co-badge card is eligible, display the "add" button and, upon user tapping, call addcobadgecard important please remember to refer to the relevant issuer implementation guide s and specifications provided by each card network and ensure that your partner app and server adhere to their specific requirements the addcobadgecard result is delivered to addcardlistener, which provides the following events onsuccess - called when the operation succeeds; provides information and status regarding the added card onfail - called when the operation fails; returns the error code and extra bundle data such as extra_error_reason or extra_request_id if provided onprogress - called to indicate the current progress of the 'addcard ' operation; can be used to show a progress bar to the user in the issuer app this callback is supported for tsm solution issuers in china and spain here’s an example of how to use the addcobadgecard api method in your issuer app note samsung pay does not provide detailed payload information; generate the provisioning payload in accordance with your card networks specifications string cardtype = card card_type_credit; string primarytokenizationprovider = addcardinfo provider_abcd; //provide your primary card network payload string testprimarypayload = "thisistestprimarypayloadcardinfo1234567890"; string secondarytokenizationprovider = addcardinfo provider_efgh; //provide your secondary card network payload string testsecondarypayload = "thisistestsecondarypayloadcardinfo1234567890"; bundle primarycarddetail = new bundle ; primarycarddetail putstring addcardinfo extra_provision_payload, testprimarypayload ; addcardinfo primaryaddcardinfo = new addcardinfo cardtype, primarytokenizationprovider, primarycarddetail ; bundle secondarycarddetail = new bundle ; secondarycarddetail putstring addcardinfo extra_provision_payload, testsecondarypayload ; addcardinfo secondaryaddcardinfo = new addcardinfo cardtype, secondarytokenizationprovider, secondarycarddetail ; cardmanager addcobadgecard primaryaddcardinfo, secondaryaddcardinfo, new addcardlistener { @override public void onsuccess int status, card card { log d tag, "onsuccess callback is called" ; } @override public void onfail int error, bundle errordata { log d tag, "onfail callback is called" ; check some extra error codes in the errordata bundle such as samsungpay extra_error_reason or samsungpay extra_request_id if provided } @override public void onprogress int currentcount, int totalcount, bundle bundledata { log d tag,"onprogress callback is called " + currentcount + " / " + totalcount ; } } ;
We use cookies to improve your experience on our website and to show you relevant advertising. Manage you settings for our cookies below.
These cookies are essential as they enable you to move around the website. This category cannot be disabled.
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.
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.
These cookies gather information about your browser habits. They remember that you've visited our website and share this information with other organizations such as advertisers.
You have successfully updated your cookie preferences.