Filter
-
Content Type
-
Category
Mobile/Wearable
Visual Display
Digital Appliance
Platform
Recommendations
Filter
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 Wallet
docwallet portal on-boarding information please review the attached partner on-boarding guide for the samsung wallet portal the rp partner needs registration information on the wallet portal wallet portal currently offers 'add to wallet' & ‘verify with wallet’ functionality to rp partners please proceed with the registration by referring to the url of the developer site below connect to partner portal the wallet partners portal access is via url below connect to the wallet partners portal partner onboarding partner on-boarding details are accessed via url below partner onboarding manage wallet cards to use the online rp function, you need to create a card as a relying party type refer to the manage wallet cards overall managing process the following image illustrates the process of managing samsung wallet cards create wallet cards draft status partners can create and manage their wallet cards with this step-by-step guide manage wallet cards partners can manage all registered wallet cards partners can edit wallet cards and check their status general information the general information page allows the partner to enter administrative details to manage their cards, as well as to define common parameters for the samsung wallet item description testing mode all data generated during testing mode is periodically deleted be sure to turn off the 'testing mode' setting after the test is over wallet card name representative title of the wallet card wallet card id unique wallet card domain name automatically generated partner app package name partner app package name wallet card template pre-defined partner’s wallet card template type > sub type > design type wallet card custom setting type authentication issuer set the authentication issuer for the relying party service to be provided as this wallet card please select authentication issuers from the identity provider groups only authentication issuers with the same “service location” as the relying party service are displayed ※ the identity provider of the “authentication issuer”is supported depending on the "service location" set partner rp get request data url through which a partner receives a card data inquiry api callin case of web2app method, the partner should provide this api /rp/v1 0/{cardid}/{refid}/key ※ the attribute could be activated with the approval of a manager partner rp send authentication data url through which a partner receives a card data inquiry api callin case of web2app method, the partner should provide this api /rp/v1 0/{cardid}/{refid}/auth ※ the attribute could be activated with the approval of a manager samsung server ips samsung wallet server ips which need to be allowed at the partner’s firewall separately described for inbound and outbound calls service location select a regional limit for the wallet card if there was no selected location, the wallet card is shown in all locations if the specified location was selected, the wallet card is shown only in the selected location users can 'verify with samsung wallet' only in service locations where the wallet service is provided ※ the identity provider of the “authentication issuer” is supported depending on the "service location" set main headquarters location check to set it as a 'main location' as the company's main service country head office for creating and proceeding with wallet cards, notification e-mails such as wallet card approval requests are sent only to the selected main location wallet card data save in server set whether to store wallet card data in the server to protect personal information if the card has sensitive information, you can contact the developer support team not to save it description description of the wallet card select template partners can choose from various types of wallet card templates optimized for partners such as boarding pass, ticket, coupon, and digital id ※ for rp partners select "relying party type > other sub type" to set the relying party wallet card partners can select the type of wallet card needed to register from the 'select wallet card template' pop-up first, select the wallet card type and then select the wallet card sub type to select one of the templates belonging to it wallet card custom setting you must set the attributes of the "wallet card custom setting" according to the wallet card ttype you selected ※ for rp partners the "authentication issuer" attribute is a unique property of the relying party card the identity provider of the authentication issuer is supported depending on the "service location" set e g if service location is in the us, the authentication issuer field only supports an identity provider belonging to the us when the parent hierarchy value is checked, its children values created later are automatically checked in the united states, the authentication issuer is the state government, and the driver's license can be understood as an mdl mobile driver's license view wallet card partners can view all the registered information, edit and delete the wallet card launch wallet cards verifying status partners can launch and activate cards you can activate a card by clicking the launch button once a card is launched, the button text changes to 'launched' the activation cannot be canceled when a card is launched, its status changes to 'verifying', and then to ‘active’ after administrator approval launch wallet cards rejected status if the wallet card is rejected after launching, partners can modify and re-launch the administrator registers the reason for rejection when rejecting a launched wallet card partners will receive an email from the system, including the reason for rejection partners can apply for launching again by checking the reason for rejection and modifying the wallet card information testing mode partners can test a card internally to make sure everything works before officially release to the users by default, the ‘testing mode’ option is enabled all data generated in testing mode is periodically deleted card exposure is not affected even when the testing mode is enabled be sure to turn off the testing mode after the test is over testing mode on → testing mode off admin approval active status all launched cards are activated after the administrator's approval when a card is launched, its status changes to 'verifying' and then to ‘active’ after administrator approval when the card is activated, it becomes visible to the user verify with samsung wallet integration to integrate the wallet, you need to run the ‘verify with samsung wallet’ script into your system the verify with samsung wallet script is available for both web and android platforms each system has a different composition to implement the verify with samsung wallet button, follow the steps below in order create tokenized card data cdata card data is the actual content data of wallet card and it has several format based on card type please refer to generate_cdata sample code for detail copy the sample verify with samsung wallet script from partner portal’s wallet card page and replace cdata with the data token created above apply the script to your system please see web_integration sample code and app_integration sample code for detail below are ‘verify with samsung wallet’ script guide in partner portal to integrate the ‘verify with samsung wallet’ you may need some base data you can find this base data and other necessary information on the partner portal and the wallet api spec you can also add image beacon in the script for tracking effect analysis
Develop Samsung Wallet
webdesign guideline for samsung wallet & pay samsung wallet is a mobile wallet service that allows people to access their virtual wallet from anywhere with a simple swipe up, providing them with a convenient and innovative lifestyle. samsung wallet samsung pay samsung pay stickers assets for samsung wallet we encourage you to learn and follow the rules and guidelines suggested in this toolkit to ensure message consistency and drive brand awareness. logo asset logo toolkit logo buttons partnership logo use the service logo lock-up for advertisements, marketing materials and webpages that are promoting samsung pay. you must not lock up an icon with the lettermark. type basic - horizontal basic - vertical alternate - horizontal alternate - vertical ratio & alignment a horizontal logo lock-up should be used in cases where there is plenty of horizontal space or where vertical space is limited. a vertical logo lock-up may be used in cases where horizontal space is limited or where there is a corner or other element to clearly align with. do nots do not violate the spacing rules do not lock up in any other way. do not change the typeface. do not change the lock-up color. do not distort or change the shape. do not lock up basic logo with the icon. do not add drop shadows. do not outline. do not place the logo on busy backgrounds with insufficient contrast. buttons the samsung wallet buttons are for adding or registering tickets and travel passes to the app. type in-app & online - horizontal in-app & online - vertical cta - horizontal cta - vertical ratio & alignment a horizontal logo lock-up should be used in cases where there is plenty of horizontal space or where vertical space is limited. a vertical logo lock-up may be used in cases where horizontal space is limited or where there is a corner or other element to clearly align with. do nots do not use a white button on white backgrounds or with a black stroke. do not use a black button on black backgrounds or with a white stroke. do not change the color of the button. do not alter the height ratio of the button. do not add drop shadows or other effects. do not abbreviate. do not change the typeface of the button. do not use the samsung wallet app icon as a button. do not use lower case for text-only buttons. usage example partnership for partnerships, the horizontal logo lock-up is the preferred choice. type horizontal vertical lock-up format a horizontal partnership lock-up fromat a horizontal partnership lock-up fromat a vertical partnership lock-up fromat do nots do not create a lock-up with the icon. do not use any alignment other than centered. do not use a lock-up format that is not visually balanced. do not scale the partner logo larger than our logo. do not alter the length of the divider bar. do not use other graphic elements as a divider. do not remove the lettermark. do not alter the line weight of the divider bar. do not change the color of the logo. usage example ooh horizontal lock-up ooh horizontal lock-up common usage vertical lock-up common usage horizontal lock-up assets for samsung pay we encourage you to learn and follow the rules and guidelines suggested in this toolkit to ensure message consistency and drive brand awareness. logo asset logo toolkit logo buttons logo use the service logo lock-up for advertisements, marketing materials and webpages that are promoting samsung pay. you must not lock up an icon with the lettermark. type horizontal vertical ratio & alignment a horizontal logo lock-up should be used in cases where there is plenty of horizontal space or where vertical space is limited. a vertical logo lock-up may be used in cases where horizontal space is limited or where there is a corner or other element to clearly align with. do nots do not violate the spacing rules do not lock up in any other way. do not change the typeface. do not change the lock-up color. do not distort or change the shape. do not lock up basic logo with the icon. do not add drop shadows. do not outline. do not place the logo on busy backgrounds with insufficient contrast. buttons the samsung wallet buttons are for adding or registering tickets and travel passes to the app. type in-app & online cta partner ratio a horizontal logo lock-up should be used in cases where there is plenty of horizontal space or where vertical space is limited. do nots do not use a white button on white backgrounds or with a black stroke. do not use a black button on black backgrounds or with a white stroke. do not change the color of the button. do not alter the height ratio of the button. do not add drop shadows or other effects. do not abbreviate. do not change the typeface of the button. do not use the samsung wallet app icon as a button. do not use lower case for text-only buttons. samsung pay stickers we encourage you to learn and follow the rules and guidelines suggested in this toolkit to ensure message consistency and drive brand awareness. download logo signage we accept decal assets staying true to samsung brand guidelines, we’ll utilize samsung blue in rounded rectangle format for a distinctive look from other brands. for general retail stores horizontal vertical usage example entry decals a horizontal type decal on the entrance entry decals a vertical type decal on the entrance register decals a vertical type decal on the register checkout kiosk for ses / partnership stores horizontal vertical usage example open/closed an open signage on the entrance open/closed an closed signage on the entrance push/pull a vertical push signage on the entrance push/pull a vertical pull signage on the entrance push/pull a horizontal push signage on the entrance push/pull a horizontal pull signage on the entrance we accept decals horizontal vertical usage example
Develop Samsung Pay
docin mobile payment card provisioning, id&v identity verification is the process of verifying the user’s identity before they can add their payment card to their mobile device samsung wallet supports various ways to ensure that only authorized individuals have access to their own payment cards and to prevent fraud these id&v methods are shown in the following screenshot they include receiving an sms, email, phone call, or access code, or verifying their identity through their bank’s website, banking application, or phone support this guide focuses on app-to-app id&v, which allows the user to verify their identity through another application, typically the application for their own bank you can implement app-to-app id&v through the samsung wallet application in 2 ways using the samsung wallet sdk, which must be integrated into the banking application itself using android intents, which enables you to implement the feature without the samsung wallet sdk specifically, this documentation describes using android intents to implement app-to-app id&v in your banking application card network specification details related to app-to-app id&v are not within the scope of this document note american express amex does not support app-to-app id&v if you want to support adding amex cards to samsung wallet, you must use other id&v methods
tutorials mobile
blogas businesses strive to enhance their mobile payment capabilities and provide seamless transaction experiences to users, integrating third-party payment solutions like samsung pay has become increasingly common. however, amid the excitement of implementing these solutions, developers often encounter challenges and pitfalls that can hinder the integration process and impact the overall user experience. in this blog, we show some of the most common mistakes developers make when integrating the samsung pay sdk, and offer practical insights and best practices to overcome these hurdles and ensure successful implementation and testing. pitfall 1: using an unofficial email id to implement the samsung pay sdk, the first step is to establish a partnership between your company and samsung. when submitting a partnership request, do so using your company's official email domain. this precaution is crucial, as partnership requests originating from non-official email addresses are prone to rejection by the samsung relationship manager. pitfall 2: providing the wrong issuer name while creating your service while creating a service for the push provisioning feature, you have to add the issuer names, meaning the names of your financial institution or bank. you must make sure to provide the correct names that have been registered with the card networks such as visa, mastercard and so on. if incorrect names are provided, the getallcard() api returns an empty list even though the card has already been added to the samsung wallet. to confirm your issuer name, first add your card to the samsung wallet application. tap on the card in the wallet application, open the more menu, and select customer services. the correct issuer name is listed on the “customer services” pane. to correct your issuer name for services that you have created: select my projects > service management. select the service name to open the service details page. select edit info. you can delete the incorrect issuer name and enter a new one. pitfall 3: using service id with an invalid effective date a common error that occurs during sdk integration is the error_expired_or_invalid_debug_key (-310) error. this error occurs in two cases: using a newly created service id without generating an expiration date of the service: after creating a service, if you check the edit info of the service details page, you will find that the debug effective data is blank. hence, you have to generate a date right after creating the service. using a service id with an expired debugging date: the service id provided by samsung pay portal remains valid for 90 days. after that time, the service expires. therefore, you must generate a date for debugging every 90 days. to generate or extend the validity date of the service: select my projects > service management. select the service name to open the service details page. select edit info. click generate new date. provide a samsung account for testing the application. this account is placed on the allow list for testing. click generate. the new expiration date of your service appears on the page. remember to extend the date after 90 days if you continue testing your application past that point. pitfall 4: configuring the release service with insufficient information it is essential to include the apk file when setting up the release service. failure to include the apk file will result in samsung pay’s relationship manager rejecting the service, leading to delays in the release process. additionally, ensure that you have correctly integrated the appropriate service id into your release application. pitfall 5: testing your application with a mismatched configuration samsung wallet uses the service id, package name, and apk signature for partner verification. if you test your application with an apk signature different from the one already registered in the samsung pay portal, samsung pay recognizes that the apk signature is inconsistent with the service id and produces the error code -6 (not_allowed). in conclusion, navigating the integration of the samsung pay sdk can present you with many challenges. but, armed with the knowledge shared here, you can steer clear of some potential pitfalls and ensure a smoother implementation process. by prioritizing thorough testing, adhering to best practices, and maintaining clear communication with samsung's support channels, you can mitigate risks and deliver a seamless payment experience to users.
Ummey Habiba Bristy
Learn Code Lab
codelabintegrate samsung pay web checkout with merchant sites objective learn how to integrate the samsung pay payment system into your merchant sites using the samsung pay web checkout sdk partnership request to use the samsung pay web checkout sdk, you must become an official samsung pay partner once done, you can fully utilize this code lab you can learn more about the partnership process by visiting the samsung pay page here in samsung developers notein accordance with the applicable samsung pay partners agreements, this code lab covers the setup and use of the samsung pay web checkout sdk for purposes of integrating samsung pay with merchant sites the use cases and corresponding code samples included are representative examples only and should not be considered as either recommended or required overview the samsung pay web checkout service enables users to pay for purchases on your website with payment cards saved in the samsung wallet app on their mobile device it supports browser-based payments on both computers and mobile devices a mobile device with samsung wallet installed is required to make purchases through samsung pay web checkout when the user chooses to pay with samsung pay, they must provide their samsung account id email id or scan the qr code on the screen with their mobile device the user then authorizes the purchase within the samsung wallet application, which generates the payment credential on the device and transmits it to your website through the web checkout for more information, see samsung pay web checkout set up your environment you will need the following access to samsung pay developers site samsung wallet test app from samsung pay developers site samsung galaxy device that supports samsung wallet app internet browser, such as google chrome codesandbox account notein this code lab, you can use the samsung wallet test app to try the functionality of the samsung pay web checkout service in a staging environment you can use the official samsung wallet app from the galaxy store once your service is in the production environment start your project and register your service in your browser, open the link below to access the project file of the sample merchant site codesandbox io/s/virtual-store-sample-fnydk5 click the fork button to create an editable copy of the project next, follow the steps below to register your sample merchant site in the samsung pay developers site go to my projects > service management click create new service select web online payment as your service type enter your service name and select your service country select your payment gateway from the list of supported payment gateways pg if your pg uses the network token mode, upload the certificate signing request csr or privacy enhanced mail pem file you obtained from your pg contact your pg for details enter the payment domain name s for your website in the service domain field and click add for example, if your domain is mywebstore com, but the checkout page is hosted on the subdomain payments mywebstore com, you will need to enter payments mywebstore com as the service domain for each additional domain url, click add in this code lab, the generated preview url of the forked project is your service domain click the name of the newly created service to see its details, such as the generated service id that you can use for all the registered service domains include the samsung pay web checkout javascript sdk the samsung pay web checkout sdk uses javascript to integrate the samsung pay payment system to your website this sdk allows users to purchase items via web browser in the <head> section of the index html file of the project, include the samsung pay web checkout javascript sdk file <script src="https //img mpay samsung com/gsmpi/sdk/samsungpay_web_sdk js"></script> initialize the samsung pay client to initiate payments using the samsung pay api, create a new instance of the paymentclient class and pass an argument specifying that the environment as stage write the code below in the <script> tag of the <body> section const samsungpayclient = new samsungpay paymentclient { environment "stage" } ; when the service is still in debug or test mode, you can only use the staging environment to test payment functionality without processing live transactions noteby default, the service is initially set to debug or test mode during creation to switch the service status to release mode, a request must be made through the samsung pay developers site after successfully transitioning to release mode, change the environment to production next, define the service id, security protocol, and card brands that the merchant can support as payment methods the service id is the unique id assigned to your service upon creation in the samsung pay developers site let paymentmethods = { version "2", serviceid "", //input your service id here protocol "protocol_3ds", allowedbrands ["visa", "mastercard"] }; check whether the samsung pay client is ready to pay using the given payment method call the createandaddbutton function if the response indicates that the client is ready samsungpayclient isreadytopay paymentmethods then function response { if response result { createandaddbutton ; } } catch function err { console error err ; } ; create and implement the samsung pay button go to the <body> section and, inside the page-container div, create a container for the samsung pay button <div align="center" id="samsungpay-container"></div> next, go back to the <script> tag and write the createandaddbutton function inside this function, generate the samsung pay button by calling the createbutton method ensure that the button appears on the page by appending it to the container you created function createandaddbutton { const samsungpaybutton = samsungpayclient createbutton { onclick onsamsungpaybuttonclicked, buttonstyle "black"} ; document getelementbyid "samsungpay-container" appendchild samsungpaybutton ; } function onsamsungpaybuttonclicked { // create the transaction information //launch the payment sheet } from the createandaddbutton function, call the onsamsungpaybuttonclicked function when the user clicks the generated button create the transaction information in the onsamsungpaybuttonclicked function, create the transactiondetail object for the user’s purchase input your service domain in the url key let transactiondetail = { ordernumber "sample0n1y123", merchant { name "virtual shop", url "", //input your service domain countrycode "us" }, amount { option "format_total_estimated_amount", currency "usd", total 2019 99 } }; below are the descriptions of the keys included in the transactiondetail object key type description ordernumber string order number of the transaction allowed characters [a-z][a-z][0-9,-] merchant object data structure containing the merchant information merchant name string merchant name merchant url string merchant domain url e g , samsung com the maximum length is 100 characters merchant countrycode string merchant country code e g , us for united states iso-3166-1 alpha-2 amount object data structure containing the payment amount amount option string display format for the total amount on the payment sheet format_total_estimated_amount = displays "total estimated amount " with the total amountformat_total_price_only = displays the total amount only amount currency string currency code e g , usd for us dollar the maximum length is 3 character amount total string total payment amount in the currency specified by amount currencythe amount must be an integer e g , 300 or in a format valid for the currency, such as 2 decimal places after a separator e g , 300 50 notefor the complete list of specifications for the transactiondetail object, see samsung pay web checkout api reference launch the payment sheet after creating the transaction information, call the loadpaymentsheet method to display the web checkout ui the user can either input their email address or scan the generated qr code a timer screen in the web checkout ui is displayed after the user input, while a payment sheet is launched in the user's samsung wallet app the payment sheet contains the payment card option s and the transaction details when the user confirms their payment on their mobile device, you will receive the paymentcredential object generated by the device then, inform the samsung server of the payment result using the notify method the paymentresult object contains the payment result information during transaction processing and after the payment is processed with the pg network notefor real transactions, you need to extract the payment credential information from the 3ds data key within the paymentcredential object and process it through your payment provider however, in this code lab, you only need to print the paymentcredential to the console samsungpayclient loadpaymentsheet paymentmethods, transactiondetail then function paymentcredential { console log "paymentcredential ", paymentcredential ; const paymentresult = { status "charged", provider "test pg" }; samsungpayclient notify paymentresult ; } catch function error { console log "error ", error ; } ; other possible values of the status key are charged - payment was charged successfully canceled - payment was canceled by either the user, merchant, or the acquiring bank rejected - payment was rejected by the acquiring bank erred - an error occurred during the payment process test the samsung pay button after integrating the samsung pay web checkout service into your sample merchant site, follow the steps below to test the functionality of the integrated service open your sample merchant site in a new tab then, click the pay with samsung pay button in the web checkout ui, enter the email address of your samsung account to send a payment request to samsung pay tap the push notification sent to the samsung wallet app installed on your mobile device then, click accept when the payment sheet is loaded, tap on pin and enter your pin to proceed a verified message will display in both the samsung wallet app and web checkout ui to indicate that the payment was processed successfully you're done! congratulations! you have successfully achieved the goal of this code lab topic now, you can integrate the samsung pay web checkout service into your website by yourself if you're having trouble, you may check the complete code below codesandbox io/s/virtual-store-complete-dkhzfx to learn more about developing apps for samsung pay devices, visit developer samsung com/pay
Develop Samsung Pay
webdesign guideline for samsung wallet & pay samsung wallet is a mobile wallet service that allows people to access their virtual wallet from anywhere with a simple swipe up, providing them with a convenient and innovative lifestyle. samsung wallet samsung pay samsung pay stickers assets for samsung wallet we encourage you to learn and follow the rules and guidelines suggested in this toolkit to ensure message consistency and drive brand awareness. logo asset logo toolkit logo buttons partnership logo use the service logo lock-up for advertisements, marketing materials and webpages that are promoting samsung pay. you must not lock up an icon with the lettermark. type basic - horizontal basic - vertical alternate - horizontal alternate - vertical ratio & alignment a horizontal logo lock-up should be used in cases where there is plenty of horizontal space or where vertical space is limited. a vertical logo lock-up may be used in cases where horizontal space is limited or where there is a corner or other element to clearly align with. do nots do not violate the spacing rules do not lock up in any other way. do not change the typeface. do not change the lock-up color. do not distort or change the shape. do not lock up basic logo with the icon. do not add drop shadows. do not outline. do not place the logo on busy backgrounds with insufficient contrast. buttons the samsung wallet buttons are for adding or registering tickets and travel passes to the app. type in-app & online - horizontal in-app & online - vertical cta - horizontal cta - vertical ratio & alignment a horizontal logo lock-up should be used in cases where there is plenty of horizontal space or where vertical space is limited. a vertical logo lock-up may be used in cases where horizontal space is limited or where there is a corner or other element to clearly align with. do nots do not use a white button on white backgrounds or with a black stroke. do not use a black button on black backgrounds or with a white stroke. do not change the color of the button. do not alter the height ratio of the button. do not add drop shadows or other effects. do not abbreviate. do not change the typeface of the button. do not use the samsung wallet app icon as a button. do not use lower case for text-only buttons. usage example partnership for partnerships, the horizontal logo lock-up is the preferred choice. type horizontal vertical lock-up format a horizontal partnership lock-up fromat a horizontal partnership lock-up fromat a vertical partnership lock-up fromat do nots do not create a lock-up with the icon. do not use any alignment other than centered. do not use a lock-up format that is not visually balanced. do not scale the partner logo larger than our logo. do not alter the length of the divider bar. do not use other graphic elements as a divider. do not remove the lettermark. do not alter the line weight of the divider bar. do not change the color of the logo. usage example ooh horizontal lock-up ooh horizontal lock-up common usage vertical lock-up common usage horizontal lock-up assets for samsung pay we encourage you to learn and follow the rules and guidelines suggested in this toolkit to ensure message consistency and drive brand awareness. logo asset logo toolkit logo buttons logo use the service logo lock-up for advertisements, marketing materials and webpages that are promoting samsung pay. you must not lock up an icon with the lettermark. type horizontal vertical ratio & alignment a horizontal logo lock-up should be used in cases where there is plenty of horizontal space or where vertical space is limited. a vertical logo lock-up may be used in cases where horizontal space is limited or where there is a corner or other element to clearly align with. do nots do not violate the spacing rules do not lock up in any other way. do not change the typeface. do not change the lock-up color. do not distort or change the shape. do not lock up basic logo with the icon. do not add drop shadows. do not outline. do not place the logo on busy backgrounds with insufficient contrast. buttons the samsung wallet buttons are for adding or registering tickets and travel passes to the app. type in-app & online cta partner ratio a horizontal logo lock-up should be used in cases where there is plenty of horizontal space or where vertical space is limited. do nots do not use a white button on white backgrounds or with a black stroke. do not use a black button on black backgrounds or with a white stroke. do not change the color of the button. do not alter the height ratio of the button. do not add drop shadows or other effects. do not abbreviate. do not change the typeface of the button. do not use the samsung wallet app icon as a button. do not use lower case for text-only buttons. samsung pay stickers we encourage you to learn and follow the rules and guidelines suggested in this toolkit to ensure message consistency and drive brand awareness. download logo signage we accept decal assets staying true to samsung brand guidelines, we’ll utilize samsung blue in rounded rectangle format for a distinctive look from other brands. for general retail stores horizontal vertical usage example entry decals a horizontal type decal on the entrance entry decals a vertical type decal on the entrance register decals a vertical type decal on the register checkout kiosk for ses / partnership stores horizontal vertical usage example open/closed an open signage on the entrance open/closed an closed signage on the entrance push/pull a vertical push signage on the entrance push/pull a vertical pull signage on the entrance push/pull a horizontal push signage on the entrance push/pull a horizontal pull signage on the entrance we accept decals horizontal vertical usage example
Develop Samsung Pay
docinitiate samsung pay service once setup is complete, you’re ready to add the sdk code within your partner app for calling the sdk’s apis and receiving callbacks api common flow when a partner app calls one of the sdk’s apis, the following interaction flow is processed to check whether the caller is authenticated and authorized before responding to the request the steps of the interaction are enumerated below the partner app calls an sdk api the sdk checks the call’s validity - is samsung wallet installed on the device? - is there any problem with the integrity of samsung pay on the device? sdk calls the samsung wallet app using aidl check the current status of the samsung wallet app - is samsung pay provisioning complete? - does samsung pay need a mandatory update? - is the samsung pay sdk api level higher than the sdk api level in the partner app? request verification of partner app eligibility status from the samsung pay server verify that the partner app matches the information registered in samsung pay developers samsung wallet app responds to the sdk request using aidl the sdk calls the callback function of the partner app checking samsung pay status the first step in implementing the samsung pay sdk within your partner app is to create the samsungpay instance and check the samsung pay status on the device to determine its support for samsung pay 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 pay 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 used for checking blocked list and version control between the samsung pay sdk and the samsung wallet app on the device, you must set the servicetype in partnerinfo to call other samsung pay apis val serviceid = "partner_app_service_id" val bundle = bundle bundle putstring samsungpay partner_service_type, samsungpay servicetype inapp_payment tostring val partnerinfo = partnerinfo serviceid, bundle 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 noteif you want to get the status of samsung pay watch, you have to use the watchmanager class instead of the samsungpay class fun getsamsungpaystatus callback statuslistener the result is delivered to statuslistener and provides the following events onsuccess ‒ called when the requested operation is successful it provides the status of the request, as well as extra bundle data related to the request onfail ‒ called when the request operation fails it returns the error code and extra bundle data related to the request the samsung pay status code returned is one of the following spay_not_supported - indicates samsung wallet is not supported on this device; typically returned if the device is incompatible with samsung pay or if the samsung wallet app is not installed spay_not_ready - indicates samsung wallet is not completely activated; usually returned if the user did not complete a mandatory update or if the user has not signed in with a valid samsung account in which case, the partner app can activate or update the samsung wallet app on the device according to the 'extra_error_reason' bundle keys below error_spay_setup_not_complete - tells the partner app to display a popup message asking if the user wishes to activate samsung pay if the user agrees, the partner app calls activatesamsungpay to activate the samsung wallet app error_spay_app_need_to_update - tells the partner app to display a popup message asking if the user wishes to update samsung pay if user agrees, the partner app calls gotoupdatepage to open the app update page error_partner_info_invalid - indicates that partner app information is invalid; typically the partner app is using a sdk version that is not allowed, an invalid service type, or the wrong api level error_partner_sdk_api_level - tells the partner app it is using the wrong api level to resolve the error condition, the partner app must set a valid api level error_partner_service_type - tells the partner app that it did not set a service type, or that the service type it did set is invalid service type is set in partnerinfo spay_ready - indicates that samsung pay is activated and ready to use; typically returned after the user completes all mandatory updates and signs in extra bundle data can have the following values extra_country_code - for both onsuccess and onfailure , this is the current device’s country code iso 3166-1 alpha-2 set by samsung pay if the partner app is not supported in this particular country, the partner app can decide not to display samsung pay button extra_error_reason - for onfailure , this is the reason for failure set by samsung pay when the returned status code is spay_ready, the partner app can safely display the samsung pay button for user selection as a payment option, card provisioning, and so on the following sample code shows how to use the getsamsungpaystatus api method val serviceid = "partner_app_service_id" val bundle = bundle bundle putstring samsungpay partner_service_type, samsungpay servicetype inapp_payment tostring val partnerinfo = partnerinfo serviceid, bundle val samsungpay = samsungpay context, partnerinfo /* * method to get the samsung pay status on the device * partner issuers, merchants applications must call this method to * check the current status of samsung pay before doing any operation */ samsungpay getsamsungpaystatus object statuslistener { override fun onsuccess status int, bundle bundle { when status { samsungpay spay_not_supported -> // samsung pay is not supported samsungpaybutton setvisibility view invisible samsungpay spay_not_ready -> { // activate samsung pay or update samsung pay, if needed samsungpaybutton setvisibility view invisible val errorreason = bundle getint samsungpay extra_error_reason if errorreason == samsungpay error_setup_not_completed { // display an appropriate popup message to the user samsungpay activatesamsungpay } else if errorreason == samsungpay error_spay_app_need_to_update { // display an appropriate popup message to the user samsungpay gotoupdatepage } else { toast maketext context, "error reason $errorreason", toast length_long show } } samsungpay spay_ready -> // samsung pay is ready samsungpaybutton setvisibility view visible else -> // not expected result samsungpaybutton setvisibility view invisible } } override fun onfail errorcode int, bundle bundle { samsungpaybutton setvisibility view invisible log d tag, "checksamsungpaystatus onfail $errorcode" } } activating the samsung wallet app the samsungpay class provides the following api method to activate the samsung wallet app on a device fun activatesamsungpay activatesamsungpay is called to activate the samsung wallet app on the same device on which the partner app is running first, however, the partner app must check the samsung pay status with a getsamsungpaystatus call see section 4 2 above 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 val serviceid = "partner_app_service_id" val bundle = bundle bundle putstring samsungpay partner_service_type, spaysdk servicetype inapp_payment tostring val partnerinfo = partnerinfo serviceid, bundle val samsungpay = samsungpay context, partnerinfo samsungpay activatesamsungpay updating the samsung wallet app the samsungpay class provides the following api method to update the samsung wallet app on the device fun 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 pay 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 pay update page the following code sample reflects how to update samsung pay val serviceid = "partner_app_service_id" val bundle = bundle bundle putstring samsungpay partner_service_type, spaysdk servicetype inapp_payment tostring val partnerinfo = partnerinfo serviceid, bundle val samsungpay = samsungpay context, partnerinfo samsungpay gotoupdatepage
Develop Samsung Pay
docinitiate in-app payment the main classes and interfaces involved here are samsungpay– class for a merchant app to get samsung pay sdk information and the status of samsung pay on the device paymentmanager – class to provide payment/transaction functionality cardinfolistener – interface for requestcardinfo result callbacks from samsung wallet customsheettransactioninfolistener – interface for transaction success/failure callbacks from samsung wallet; payment information is provided with a success callback and must be used by the merchant app for processing the payment the flow pictured next captures the essential online payment api process between merchant apps integrated with the samsung pay sdk and samsung wallet and the merchant’s payment gateway pg reflected in the diagram above are the following operations check the ready status of samsung pay start the payment manager to establish the service binding and verify the merchant app get payment card information and the payment amount, including updates get/update the user’s billing and shipping addresses, including an updated payment amount if shipping charges will be incurred authenticate the user submit payment information to pg verify transaction success or failure token modes network vs gateway to complete the payment, the merchant’s designated payment gateway pg handles one of two types of tokens gateway tokens indirect or network tokens direct the samsung pay sdk supports both types the essential difference between the two types is who decrypts the token information network tokens require that the merchant app handles decryption of the token bundle or work with the pg to handle decryption, whereas gateway token decryption is handled by the pg via the samsung-pg interface server check with your pg to determine its specific requirements for payment processing regardless of the pg model employed, direct or indirect, the goal is to offer samsung pay as a secure payment method within your merchant app the most common use case involves the following general steps to make a purchase, the user selects to “buy” or got to checkout after adding items to a shopping cart now in checkout, the user selects a payment option; for example, either the merchant’s “standard” method or samsung pay upon selecting samsung pay, the user is presented with a payment sheet that allows for card selection and shipping address confirmation with the option to add/modify information for this order, whereupon the user * makes payment card selection from the list of enrolled cards * chooses to change or add the delivery address * enters required address information in the form presented and saves it * authenticates the payment method, amount, and delivery with a biometric verification fingerprint, iris… or pin checking registered/enrolled card information before displaying the samsung pay button, a partner app can query card brand information for the user’s currently enrolled payment cards in samsung wallet to determine if payment is supported with the enrolled card for example, if a merchant app accepts one card brand exclusively but the user has not registered any cards matching this brand in samsung wallet, the merchant app needs to determine whether or not to display the samsung pay button for this purchase checkout to query the card brand, use the requestcardinfo api method of the paymentmanager class the requestfilter is optional bundle data reserved for future use the merchant app does not need to set a value for it now however, before calling this method, cardinfolistener must be registered so its listener can provide the following events onresult - called when the samsung pay sdk returns card information from samsung wallet; returns information about enrolled cards or is empty if no card is registered onfailure - called when the query fails; for example, if sdk service in the samsung wallet app ends abnormally the following snippet shows how to retrieve the list of supported card brands from samsung pay val serviceid = "partner_app_service_id" val bundle = bundle bundle putstring samsungpay partner_service_type, spaysdk servicetype inapp_payment tostring val partnerinfo = partnerinfo serviceid, bundle val paymentmanager = paymentmanager context, partnerinfo paymentmanager requestcardinfo bundle , cardinfolistener // get card brand list //cardinfolistener is for listening requestcardinfo callback events val cardinfolistener cardinfolistener = object cardinfolistener { // this callback is received when the card information is received successfully override fun onresult cardresponse list<cardinfo> { var visacount = 0 var mccount = 0 var amexcount = 0 var dscount = 0 var brandstrings = "card info " var brand spaysdk brand? for i in cardresponse indices { brand = cardresponse[i] brand when brand { spaysdk brand americanexpress -> amexcount++ spaysdk brand mastercard -> mccount++ spaysdk brand visa -> visacount++ spaysdk brand discover -> dscount++ else -> { /* other card brands */ } } } brandstrings += " vi = $visacount, mc = $mccount, ax = $amexcount, ds = $dscount" log d tag, "cardinfolistener onresult $brandstrings" toast maketext context, "cardinfolistener onresult" + brandstrings, toast length_long show } /* * this callback is received when the card information cannot be retrieved * for example, when sdk service in the samsung wallet app dies abnormally */ override fun onfailure errorcode int, errordata bundle { //called when an error occurs during in-app cryptogram generation toast maketext context, "cardinfolistener onfailure " + errorcode, toast length_long show } } creating a transaction request upon successful initialization of the samsungpay class, the merchant app needs to create a transaction request with payment information noteas of sdk v2 0 00, the normal payment sheet is deprecated all merchant apps must now use the custom payment sheet, which offers more dynamic controls for tailoring the ui look and feel with additional customer order and payment data merchant app developers choosing to temporarily continue offering the normal sheet will need to configure their android manifest to reflect the pre-2 0 00 version of the sdk used to implement their app’s existing normal sheet, although this is not recommended in all cases, merchant app developers should update their apps with the latest version of the sdk as soon as possible to avoid timing out using an earlier version of the sdk when responding to samsung pay callbacks using the custom payment sheet to initiate a payment transaction with samsung pay’s custom payment sheet, your merchant app must populate the following mandatory fields in customsheetpaymentinfo merchant name - as it will appear in samsung pay’s payment sheet, as well as the user's card account statement amount - the constituent transaction properties currency, item price, shipping price, tax, total price which together determine the total amount the user is agreeing to pay the merchant cautionnot populating the mandatory fields throws an illegalargumentexception optionally, the following fields can be added to the payment information merchant id- can be used for the merchant’s own designated purpose at its discretion unless the merchant uses an indirect pg like stripe or braintree if an indirect pg is used, this field must be set to the merchant’s payment gateway id fetched from the samsung pay developers portal merchant id is mandatory if a merchant request mada token, this filed should be included in the payload order number - usually created by the merchant app via interaction with a pg this number is required for refunds and chargebacks in the case of visa cards, the value is mandatory the allowed characters are [a-z][a-z][0-9,-] and the length of the value can be up to 36 characters address - the user’s billing and/or shipping address see applying an addresscontrol for details allowed card brands - specifies card brands accepted by the merchant if no brand is specified, all brands are accepted by default if at least one brand is specified, all other card brands not specified are set to "card not supported’ on the payment sheet here’s the 'customsheetpaymentinfo' structure class customsheetpaymentinfo parcelable { private val version string? = null private val merchantid string? = null private val merchantname string? = null private val ordernumber string? = null private val addressinpaymentsheet addressinpaymentsheet = addressinpaymentsheet do_not_show private val allowedcardbrand list<spaysdk brand>? = null private val cardinfo cardinfo? = null private val iscardholdernamerequired = false private val isrecurring = false private val merchantcountrycode string? = null private val customsheet customsheet? = null private val extrapaymentinfo bundle? = null } your merchant app sends this customsheetpaymentinfo to samsung wallet via the applicable samsung pay sdk api methods upon successful user authentication in direct mode, samsung wallet returns the above "payment info" structure and a result string the result string is forwarded to the pg by your merchant app to complete the transaction it will vary based on the pg you’re using noteif you want to add any other information for any card brand, you can add them in the extrapaymentinfo bundle the following example demonstrates how to populate customsheet in the customsheetpaymentinfo class see sample merchant app using custom payment sheet below for example usage of each customsheet control /* * make user's transaction details * the merchant app should send customsheetpaymentinfo to samsung wallet via * the applicable samsung pay sdk api method for the operation being invoked */ private fun makecustomsheetpaymentinfo customsheetpaymentinfo { val brandlist = arraylist<spaysdk brand> // if the supported brand is not specified, all card brands in samsung wallet are // listed in the payment sheet brandlist add paymentmanager brand visa brandlist add paymentmanager brand mastercard brandlist add paymentmanager brand americanexpress /* * make the sheetcontrols you want and add them to custom sheet * place each control in sequence with amountboxcontrol listed last */ val customsheet = customsheet customsheet addcontrol makebillingaddresscontrol customsheet addcontrol makeshippingaddresscontrol customsheet addcontrol makeplaintextcontrol customsheet addcontrol makeshippingmethodspinnercontrol customsheet addcontrol makeamountcontrol val extrapaymentinfo = bundle /* * you can add transaction type for mada card brand * the supported values are purchase and preauthorization * if you don't set any value, the default value is purchase */ extrapaymentinfo putstring spaysdk extra_online_transaction_type, spaysdk transactiontype preauthorization tostring val customsheetpaymentinfo = customsheetpaymentinfo builder setmerchantid "123456" setmerchantname "sample merchant" // merchant requires billing address from samsung wallet and // sends the shipping address to samsung wallet // show both billing and shipping address on the payment sheet setaddressinpaymentsheet customsheetpaymentinfo addressinpaymentsheet need_billing_send_shipping setallowedcardbrands brandlist setcardholdernameenabled true setrecurringenabled false setcustomsheet customsheet setextrapaymentinfo extrapaymentinfo build return customsheetpaymentinfo } requesting payment with a custom payment sheet the startinapppaywithcustomsheet method of the paymentmanager class is applied to request payment using a custom payment sheet in samsung wallet the two methods are defined as follows startinapppaywithcustomsheet - initiates the payment request with a custom payment sheet the payment sheet persist for 5 minutes after the api is called if the time limit expires, the transaction fails updatesheet - must be called to update current payment sheet as of api level 1 5, a merchant app can update the custom sheet with a custom error message refer to updating sheet with custom error message when you call the startinapppaywithcustomsheet method, a custom payment sheet is displayed on the merchant app screen from it, the user can select a registered card for payment and change the billing and shipping addresses, as necessary the result is delivered to customsheettransactioninfolistener, which provides the following events onsuccess - called when samsung pay confirms payment it provides the customsheetpaymentinfo object and the paymentcredential json string customsheetpaymentinfo is used for the current transaction it contains amount, shippingaddress, merchantid, merchantname, ordernumber api methods exclusively available in the onsuccess callback comprise getpaymentcardlast4dpan – returns the last 4 digits of the user's digitized personal/primary identification number dpan getpaymentcardlast4fpan – returns the last 4 digits of the user's funding personal/primary identification number fpan getpaymentcardbrand – returns the brand of the card used for the transaction getpaymentcurrencycode – returns the iso currency code in which the transaction is valued getpaymentshippingaddress – returns the shipping/delivery address for the transaction getpaymentshippingmethod – returns the shipping method for the transaction for pgs using the direct model network tokens , the paymentcredential is a json object containing encrypted cryptogram which can be passed to the pg pgs using the indirect model gateway tokens like stripe, it is a json object containing reference card reference – a token id generated by the pg and status i e , authorized, pending, charged, or refunded refer to payment credential sample for details oncardinfoupdated - called when the user changes the payment card in this callback, updatesheet method must be called to update current payment sheet onfailure - called when the transaction fails; returns the error code and errordata bundle for the failure here’s how to call the startinapppaywithcustomsheet method of the paymentmanager class /* * customsheettransactioninfolistener is for listening callback events of in-app custom sheet payment * this is invoked when card is changed by the user on the custom payment sheet, * and also with the success or failure of online in-app payment */ private val transactionlistener = object customsheettransactioninfolistener { // this callback is received when the user changes card on the custom payment sheet in samsung pay override fun oncardinfoupdated selectedcardinfo cardinfo, customsheet customsheet { /* * called when the user changes card in samsung wallet * newly selected cardinfo is passed so merchant app can update transaction amount * based on different card if needed , */ val amountboxcontrol = customsheet getsheetcontrol amount_control_id as amountboxcontrol amountboxcontrol updatevalue product_item_id, 1000 0 //item price amountboxcontrol updatevalue product_tax_id, 50 0 // sales tax amountboxcontrol updatevalue product_shipping_id, 10 0 // shipping fee amountboxcontrol updatevalue product_fuel_id, 0 0, "pending" // additional item status amountboxcontrol setamounttotal 1060 0, amountconstants format_total_price_only // grand total customsheet updatecontrol amountboxcontrol // call updatesheet with amountboxcontrol; mandatory try { paymentmanager updatesheet customsheet } catch e java lang illegalstateexception { e printstacktrace } catch e java lang nullpointerexception { e printstacktrace } } /* * this callback is received when the payment is approved by the user and the transaction payload * is generated payload can be an encrypted cryptogram network token mode or the pg's token * reference id gateway token mode */ override fun onsuccess response customsheetpaymentinfo, paymentcredential string, extrapaymentdata bundle { /* * called when samsung pay creates the transaction cryptogram, which merchant app then sends * to merchant server or pg to complete in-app payment */ try { val dpan = response cardinfo cardmetadata getstring spaysdk extra_last4_dpan, "" val fpan = response cardinfo cardmetadata getstring spaysdk extra_last4_fpan, "" toast maketext context, "dpan " + dpan + "fpan " + fpan, toast length_long show } catch e java lang nullpointerexception { e printstacktrace } toast maketext context, "transaction onsuccess", toast length_long show } override fun onfailure errorcode int, errordata bundle { // called when an error occurs during cryptogram generation toast maketext context, "transaction onfailure $errorcode", toast length_long show } } private fun startinapppaywithcustomsheet { // show custom payment sheet try { val bundle = bundle bundle putstring samsungpay partner_service_type, spaysdk servicetype inapp_payment tostring val partnerinfo = partnerinfo serviceid, bundle paymentmanager = paymentmanager context, partnerinfo // request payment using samsung wallet paymentmanager startinapppaywithcustomsheet makecustomsheetpaymentinfo , transactionlistener } catch e illegalstateexception { e printstacktrace } catch e numberformatexception { e printstacktrace } catch e nullpointerexception { e printstacktrace } catch e illegalargumentexception { e printstacktrace } } when an address is provided by samsung wallet, onaddressupdated is called whenever address information is updated in the custom payment sheet you can use the updatesheet method to update the shipping fee or any other relevant information in the payment sheet set the errorcode to determine if the address provided by samsung wallet app is invalid, out of delivery, or does not exist for example, when the merchant does not support the product delivery to the designated location billing address from samsung wallet is not valid for tax recalculation for all such cases, the merchant app should call updatesheet with one of the following error codes error_shipping_address_invalid error_shipping_address_unable_to_ship error_shipping_address_not_exist error_billing_address_invalid error_billing_address_not_exist the sample code included below under applying the address control demonstrates how to use the updatesheet method for 'addresscontrol' in the payment sheet payment credential sample the paymentcredential is the resulting output of the startinapppaywithcustomsheet method the structure varies depending on the pg you’re using and the integration model—direct or indirect the following paymentcredential is for a visa card for pg using direct network token mode – e g first data, adyen, cybs sample paymentcredential json output using jwe-only { "billing_address" {"city" "billingcity","country" "usa","state_province" "ca","street" "billingaddr1","zip_postal_code" "123456"}, "card_last4digits" "1122", "3ds" {"data" "eyjhbgcioijsu0exxzuilcjrawqioijcak91a1h2afv4wu5wofiwvgs2y25oactzwwfqzxhiehrvz0vfdhlhyy9npsisinr5cci6ikppu0uilcjjagfubmvsu2vjdxjpdhldb250zxh0ijoiulnbx1blssisimvuyyi6ikexmjhhq00ifq fg2oouvhdgkkivyba2s5kturpwueujkzeyxz7n6kalhqahszv3p5jabaoj-rokcznfjdg3qierzjktu7zxst9gwv4oclahpfdw64w0x6ttaxeyjiivkjug-edxxtwajeyeikgc68wehf1cltsqg4zlwi6upvcaywdppbn0hl0c5wcf5az4wabytv_fda5ahguypne70keqrtwdlacw9mzejx2xth7msd9ohoulr8luq-7gha17jhoobwgmoq9q0haocnm0ljwiuhkoryyu-njulnbkk8fzus_aiumgdv2yn9ygfqilmculb0vwuf0yekx6isgaxi0zqhliusjkcz_w auzzxog46lnrtk3q qe2llws30vzh-zduue8b045cnfrm2p-rjzgbnzchels3v26n64cfg1av5mtp5f-fswbj3ntp5x4v1nk8fmdy0uspxzemfvl5badgac7w9frxt6x5xv1fqu6-q-zkbxcb9bygownt983bckoe1bd5djxfbodlrc4j68ikdjc5m3lebdx6hv0aqzkmilch-jevl3awqykbny4vj7m3fizw7u1prli2zfwukxdfs4vwv3bpm4qudemvnhxj qtymdmn4ne93juljnmwkjg","type" "s","version" "100"}, "merchant_ref" "merchantid", "method" "3ds", "recurring_payment" false } decrypt using the merchant’s private key below is sample private key -----begin rsa private key----- miieowibaakcaqea4lzyjqr+dqd/xleoxct9jwtjxhd2ptjke9djtmijki0h2oc2ghow4ujhhy/1jvft2+zcnjtoxuvlp+76/dwa3bcwfrj+fpp6x5kkylpb+djdyo1ttumltnqcwymjb3u7jbc+xr4vkfrzqjxke7xhn/sbb82ue8c3smzvkynuji<…> -----end rsa private key----- the decrypted output will be similar to this { "amount" "1000", "currency_code" "usd", "utc" "1490266732173", "eci_indicator" "5", "tokenpan" "1234567890123456", "tokenpanexpiration" "0420", "cryptogram" "ak+zkbpmcorcabcd3agraoacfa==" } processing the payload depending on the structure of the payment processing api provided by your pg, your merchant app can send either of these directly to the pg entire paymentcredential output extracted “3ds” part only consult your pg documentation for specific guidance when using indirect model e g stripe in indirect gateway token mode, paymentcredential is the pg’s token reference id and its status here’s a sample of the json output { "reference" "tok_18rje5e6szui23f2mefakep7", "status" "authorized" } for stripe, your merchant app should be able to pass this token object directly to charge or another appropriate payment processing api provided by the pg
Develop Samsung Pay
docto verify their payment card in the samsung wallet application, the user must accept the terms and conditions, after which samsung wallet initiates token provision through the samsung token requestor tr from the trust service provider tsp the tsp provides samsung wallet with the available id&v methods and the data needed to perform user verification through your application when the user selects “open banking app” in samsung wallet, an android activity launches your application through an intent the intent contains information from the tsp server you can implement app-to-app id&v support in your banking application in 2 ways token activation through bank server after user verification, the token is activated through your bank’s backend and tsp apis token activation through samsung wallet application after user verification, your bank server returns an authorization code to samsung wallet, which is used to activate the token the samsung tr and tsp the following figure shows the app-to-app id&v process flow launch the application to launch your application, the samsung wallet application calls the startactivityforresult method, providing the following intent data from the tsp server package name of your application intent action, whose specific name depends on the tsp additional data in the intent extra_text key, depending on the card type mastercard a base64-encoded json object with the following elements paymentappproviderid, paymentappinstanceid, tokenuniquereference, accountpansuffix, and accountexpiry visa an encrypted json payload including pan id, tr id, token reference id, last 4 digits of pan, device id, and wallet account id intent data is generated with the getapp2appintent method in the samsung wallet application public intent getapp2appintent { intent app2appintent = new intent ; app2appintent setpackage packagename ; app2appintent setaction action ; if !textutils isempty extratext { app2appintent putextra intent extra_text, extratext ; } return intent; } note for information about the data in the intent extra_text key, refer to the card network’s own specifications the samsung wallet application only transfers the data to your application for handling process the id&v request to enable your application to handle the intent data transmitted from the samsung wallet application, in your “androidmanifest xml” file, define an activity with the intent action used by the tsp <activity android name="app2appidnvactivity"> <intent-filter> <action android name="com bank mobileapp action launch_a2a_idv"/> <category android name="android intent category default"/> </intent-filter> </activity> when your application is called by samsung wallet, start the activity to process the id&v request the data passed by the intent can be processed through your backend server along with other data that the application already has, such as user and account information if user verification is successful, you can activate the token by calling the tsp api return to samsung wallet after the user has completed verification, your application must direct the user back to samsung wallet using the activity setresult resultcode, resultintent method if the value of resultcode is result_ok, the resultintent object must contain extra bundle data the step_up_response key must have one of the following values depending on the scenario intent result = new intent ; // authentication successful result putextra "step_up_response", "accepted" ; // authentication failed; do not add the user’s card result putextra "step_up_response", "declined" ; // authentication failed; allow user to retry or select another id&v method result putextra "step_up_response", "failure" ; // authentication failed because the application was not ready result putextra "step_up_response", "appnotready" ; activity setresult result_ok, result ; to use an authentication code to activate the token in samsung wallet, you must also include the activation_code key-value intent result = new intent ; result putextra "step_up_response", "accepted" ; result putextra "activation_code", authcode ; activity setresult result_ok, result ; otherwise, the value of resultcode is result_cancel, when the user has canceled the operation intent result = new intent ; activity setresult result_cancel ;
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.