Filter
-
Content Type
-
Category
Mobile/Wearable
Visual Display
Digital Appliance
Platform
Recommendations
Filter
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 pay 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
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
tutorials blockchain
blogwhether you are making a cryptocurrency exchange or a game on the ethereum blockchain, if you want to get more users for your web dapp, this article is for you. more web traffic now comes from smartphones than pcs. so, if you want to get more users for your dapp, you need to take your application to the “galaxies” (that is, samsung galaxy devices)! thankfully, the samsung blockchain platform (sbp) sdk has got you covered for all of your blockchain needs. this article explores how to connect to a hardware wallet using sbp sdk and how to leverage that connection to sign your cryptocurrency transaction. you will learn how to use cucumber webview provided by sbp sdk to display your web dapp and leverage sbp sdk features. you will also explore how to send the signed transaction to a blockchain network and receive payment. let’s get started! initialize the samsung blockchain platform sdk before using sbp sdk, make sure to include the required supporting libraries. to learn more about the required libraries and how to add them to the project, you can review the sbp sdk getting started guide. to begin, initialize the sbp sdk for our application. running the following code segment initializes the sblockchain object. you need to use this object for all further communication with the sbp sdk. try { msblockchain = new sblockchain(); msblockchain.initialize(this); } catch (ssdkunsupportedexception e) { handleplatformsdkunsupportederror(e); } connect to a hardware wallet many samsung galaxy devices, such as the galaxy note20 and s20, already have a hardware wallet available: the samsung blockchain keystore. you will connect to it in this demonstration. however, you can adapt the following code to connect to other supported hardware wallets, such as the ledger nano x, by simply changing the hardware wallet type. private hardwarewallet connectedhardwarewallet; listenablefuturetask<hardwarewallet> connectiontask = msblockchain.gethardwarewalletmanager().connect(hardwarewallettype.samsung, true); connectiontask.setcallback(new listenablefuturetask.callback<hardwarewallet>() { @override public void onsuccess(hardwarewallet hardwarewallet) { connectedhardwarewallet = hardwarewallet; setupaccounts(connectedhardwarewallet); } @override public void onfailure(executionexception e) { log.e(log_tag, "connecting to hardware wallet failed."); log.e(log_tag, e.getmessage()); } @override public void oncancelled(interruptedexception e) { log.e(log_tag, "connecting to hardware wallet cancelled."); log.e(log_tag, e.getmessage()); } }); once successfully connected to the hardware wallet, you can retrieve the accounts associated with it. retrieve ethereum accounts using the sbp’s account manager, you can retrieve the list of accounts associated with a hardware wallet. accountmanager accountmanager = msblockchain.getaccountmanager(); list<account> accountlist = accountmanager.getaccounts(connectedwallet.getwalletid(), coin_network_info.getcointype(), coin_network_info.getnetworktype()); in order to get a list of accounts using sbp sdk, you need to specify the wallet id of the hardware wallet connected, the coin type (cryptocurrency) you want to use (as of writing this article, only ethereum is supported), and the desired network type (such as mainnet or ropsten). if the account list is empty, the account manager can generate a new account based on the connected hardware wallet, the specified cryptocurrency, and the network. accountmanager.generatenewaccount(connectedhardwarewallet, coin_network_info).setcallback( new listenablefuturetask.callback<account>() { @override public void onsuccess(account newaccount) { defaultaccount = newaccount; showaccountaddressonui(defaultaccount.getaddress()); initializewebview(); log.d(log_tag, "account fetched."); } @override public void onfailure(executionexception e) { log.e(log_tag, "account fetching failed."); log.e(log_tag, e.getmessage()); } @override public void oncancelled(interruptedexception e) { log.e(log_tag, "account fetching cancelled."); log.e(log_tag, e.getmessage()); } }); after the account is retrieved, you can proceed to loading our web dapp using cucumber webview. initialize cucumber webview the next step is to prepare the cucumber webview and enable it to make transactions through the dapp. dappwebview = findviewbyid(r.id.dapp_web_view); dappwebview.addcoinserviceconnector(coin_network_info.getcointype(), ethereumcoinservice, defaultaccount, transactionlistener); to communicate with the blockchain network, use the coinservice interface of the sbp. the coin service enables us to retrieve the information needed for the transaction, such as nonce and gas prices. after all the information for the transaction has been retrieved, the coin service can help us upload the signed transaction to the blockchain network. browser-based web dapps built using web3js nowadays use metamask as their web3 provider. when our dapp is loaded on the dappwebview, the sbp sdk works as the web3 provider and forwards the web3js-prepared transaction to a baseonsendtransactionlistener event handler, which handles the transaction created by our web dapp. after preparing the transaction, a payment intent powered by the sbp sdk can be launched, which provides an interactive ui with the transaction details and a mechanism to select the preferred transaction speed. coinservice ethereumcoinservice = coinservicefactory.getcoinservice(mainactivity.this, coin_network_info); baseonsendtransactionlistener transactionlistener = new onsendethereumtransactionlistener() { @override public void onsendtransaction(string requestid, ethereumaccount ethereumaccount, string toaddress, biginteger value, string data, biginteger nonce) { intent paymentintent = dappwebview.createethereumpaymentsheetactivityintent(mainactivity.this, requestid, connectedhardwarewallet, toaddress, value, data, nonce); mainactivity.this.startactivityforresult(paymentintent, 0); } }; dappwebview.addcoinserviceconnector(coin_network_info.getcointype(),ethereumcoinservice, defaultaccount, transactionlistener); dappwebview.loadurl(marketplace_url); our cucumber webview (dappwebview) is now ready to load our web dapp using its url. dappwebview.loadurl("https://www.example.com"); when the marketplace has loaded, the sbp prompts the user to allow the dapp to connect to our hardware wallet. the sbp’s payment intent ui enables the user to easily purchase items from the marketplace. using the payment intent ui, the user can choose the transaction speed and send the transaction to their hardware wallet for signing. once signing is done, the sbp sdk sends the transaction to the blockchain network for processing. bonus: display the transaction id in addition to enabling users to sign in and send a transaction with your dapp, the sbp sdk can also retrieve the transaction id. the payment intent returns the transaction information, which can be parsed using the onactivityresult method, if desired. @override protected void onactivityresult(int requestcode, int resultcode, @nullable intent data) { super.onactivityresult(requestcode, resultcode, data); if (requestcode == 0 && data != null) { dappwebview.onactivityresult(requestcode, resultcode, data); switch (resultcode) { case activity.result_ok: string transactionid = data.getstringextra("txid"); log.d(log_tag, "transactionid : " + transactionid); showalertdialog("transaction successful with id : " + transactionid); break; case activity.result_canceled: log.d(log_tag, "transaction canceled by user."); break; default: log.d(log_tag, "unknown activity result code. result code: " + resultcode); } } } conclusion with the sbp sdk, your dapp is no longer confined to pcs. both new and existing users can have your dapp at their fingertips on samsung galaxy devices. it’s also easy to add support for new cryptocurrencies and hardware wallets to your dapp; the sbp has you covered. submit your application to the samsung galaxy store and reach millions of new users today! additional resources download the samsung blockchain platform sdk example app more information on samsung blockchain platform sdk
Shuvo Saha
Develop Samsung Blockchain
docintroducing aerowallet the samsung blockchain platform sdk is a one stop solution to all your blockchain needs. aerowallet is a sample application showcasing the features of sbp sdk. the sbp sdk provides six primary features: hardware wallet management account management transactions token transactions simple payment ui cucumber web-view (dapp browser) to ensure maximum security a hardware wallet is always recommended to interact with blockchain networks. the sbp sdk provides support for three types of hardware wallets: samsung blockchain keystore (sbk) ledger nano x ledger nano s aerowallet helps showcase most of the available services and apis of the sbp sdk. understanding aerowallet welcome to aerowallet to use aerowallet, you need a stable connection to the internet. the get started button redirects users to the hardware wallet selection page. however, if you have no connection to the internet, the application will prompt you to try again when you have internet. before diving into how aerowallet showcases all the features of the sbp sdk, we must understand the structure & design of aerowallet. aerowallet follows the well-known mvvm pattern to design its core architecture. the mvvm architecture helps maintain better separation of concerns, improved testing capacity, and transparent communication between the classes. the codebase is divided into three separate layers: view viewmodel model (service) the view layer consists of the layout, activity and fragment classes. they provide the interface that displays the application data to interact. it contains many ui elements that enable user interaction and helps reflect changes in the network/data from the server. the activity/fragment classes in the view layer consist of observers that observe for changes in the data and update the ui, respectively. the service layer or model layer in mvvm terminology consists of many service classes interacting with the sbp sdk. it enables direct communication with the sbp sdk and is the last layer of the architecture. service classes receive requests from the viewmodel and interact with the sbp sdk. the viewmodel layer consists of the viewmodels that help encapsulate all the application's business logic. it contains mutable livedata objects that change depending on user and server feedback. the view layer observes these changes and updates the ui where necessary. the viewmodel also gets/sets data by communicating with the service layer. hardware wallet management sbp sdk provides an instance of hardwarewalletmanager that can be retrieved from the sblockchain. currently, the sbp sdk supports three types of hardware wallets: samsung blockchain keystore (sbk) and ledger nano devices (usb & ble). hardware wallet selection page in the aerowallet codebase, you can find the walletselectionactivity class inside the view folder. the logic behind setting the hardware wallet has been decoupled as such: walletselectionactivity -> setupviewmodel -> setupservice -> sbpmanager in the walletselectionactivity, listeners are implemented on the buttons of the page. when you press on your desired hardware wallet, the listener calls the connecthardwarewallet function from the setupviewmodel. this function calls the connecthardwarewallet function of setupservice which in turn calls the connecthardwarewallet function of sbpmanager. finally, sbpmanager calls the connect api of the sbp sdk's hardwarewalletmanager module to connect with the respective hardware wallet. when you are done connecting to the hardware wallet, you can move to select your desired cointype. note sbpmanager is a core service class that provides direct interaction with the sbp sdk. it contains instances of sblockchain, hardwarewalletmanager, and accountmanager. the sblockchain class provides methods to get the accountmanager (singleton instance), hardwarewalletmanager (singleton instance) and supportedhardwarewallet. account management the samsung blockchain platform sdk manages the address on a blockchain network as an account. these accounts contain all the necessary information required to sign a transaction on the blockchain network. before fetching or generating an account, you must provide your walletid, cointype and networktype to the api. coin selection page network selection page of ethereum after selecting the wallettype, cointype, and networktype, you can now communicate with the sbp sdk to fetch your account. the sbpmanager class stores the data for all these variables. now we have all the necessary pieces of the puzzle to use the accountmanager instance to manage our account. the accountmanager has the following apis at our disposal: getaccounts: required parameters are walletid, cointype, and networktype. returns the accounts that are stored locally by the sbp sdk. generatenewaccount: required parameters are connectedhardwarewallet and coinnetworkinfo. generates a new account with the root seed of connected hardware wallet. restoreaccounts: required parameters are connectedhardwarewallet, reset and coinnetworkinfo. restores all accounts based on the current root seed. stored accounts in the sdk's repository are deleted and restored. coinnetworkinfo is a special class in the sbp sdk that allows the packing of coin/platform, network, and rpc node information. to create a coinnetworkinfo, you need to pass the cointype, networktype, and rpc url to its constructor. reset is a boolean parameter that is usually set to false. if set to true it removes all accounts in the shared preferences and writes restored accounts. there is also a navigation bar that helps to navigate between the fragments. all the account information is displayed within the dashboard fragment of aerowallet. the send button redirects to transfer fragment and the receive button redirects to the receive fragment. receive fragment showcases the public address of your account to copy/share dashboard displaying the public address and balance of the account account tree to switch between accounts and add new button to generate a new account transactions one of the primary goals achieved by the sbp sdk is to provide simple transactions through abstracted apis for each type of ledger system. to learn how to use the apis from sbp sdk to sign transactions, please look into the respective service classes in the programming guide section of sbp sdk. to perform a transaction on the blockchain network, you need the receiver's public address and sufficient balance. in aerowallet, you can use a qr scanner to scan the receive's public address qr code enter the desired amount of funds to transfer. please note that a transaction fee (gas) is required to perform transactions on the blockchain network. ethereum transaction fragment sbp sdk supports both legacy and eip-1559 transactions for ethereum. you can also choose your desired transaction speed. token transactions besides fund transfers, the sbp sdk provides apis to perform token, nft and safenft transactions. aerowallet has a separate fragment to showcase token transfer from one account to another. however before sending a token, you must add the token into your account. in the token fragment press on the '+' button to add a new token to your account. you can type in the address of the token or use the qr code scanner and aerowallet will automatically fill in the rest of the fields from the blockchain network. add token fragment after the token has been added, you will find it displayed in the token fragment along with all its details. you can now send tokens to any account of your choice by simply filling in the receiver's address and token amount. send token fragment payment sheet one of the key selling features of the sbp sdk is our simple payment ui or payment sheet. this feature is embedded inside the sbp sdk and comes with a complete ui for your application's payment solutions. error handling, null checking and balance checking are also added to the payment sheet. there are a lot of possible use cases for the sbp sdk's payment sheet. developers can easily use our payment solution to process in-app transactions. aerowallet presents such a use case by showcasing an online marketplace where the transactions are processed by the sbp sdk's payment sheet. mobi dapp marketplace ethereum payment sheet (eth, erc20, and erc721 showcased in aerowallet) all the required information has been passed into the payment sheet. the gas fee will depend on the transaction speed of your choice. payment sheet allows you to easily complete a transaction without the need of handling all your intricacies yourself. cucumber web-view (dapp browser) cucumber webview is a customized webview dedicated to web dapp. this allows users to integrate their web dapp into their mobile with zero changes to their web code. currently, cucumberwebview is capable of javascript sdks for ethereum and tron, more specifically: web3.js tronweb demo ethereum crypto store you can easily integrate your own crypto store or any other web dapp using cucumberwebview. after the successful integration, the web dapp of your choice will be able to implement our built-in payment sheet activity of the sbp sdk that will cater to all your transaction needs. use the addcoinserviceconnector method with your desired cointype to inject the cucumberwebview provider. this injection will allow you to delegate the sendtransaction of javascript api to our onsendtransaction method. you can use this to initiate the desired payment sheet or the sdk's available transaction apis. payment sheet triggered through cucumber webview the complete codebase of aerowallet and api reference of the sbp sdk can be found here.
Learn Code Lab
webcode lab code lab is an education platform that engages anyone to understand, through a series of topics, the entirety of the sdks and tools powered by samsung. all tags all tags in-app purchase add samsung in-app purchase service to your app 30 mins start watch face studio get creative with weather data in watch face studio 30 mins start sdc24 health build a health app with steps from samsung health and its connected wearables 30 mins start sdc24 health access rich sleep data from samsung health measured by galaxy wearables 30 mins start sdc24 smartthings create a smartthings edge driver for an iot bulb 30 mins start sdc24 smartthings develop a smartthings find-compatible device 30 mins start sdc24 smartthings test edge drivers using smartthings test suite 30 mins start sdc24 health research stack establish a health research system using samsung health research stack 30 mins start sdc24 samsung pay samsung wallet integrate samsung pay web checkout with merchant sites 30 mins start sdc24 samsung pay samsung wallet integrate samsung pay sdk flutter plugin into merchant apps for in-app payment 30 mins start sdc24 samsung wallet utilize add to samsung wallet service for digital cards 30 mins start sdc24 samsung wallet verify your id with samsung wallet 30 mins start sdc24 automotive create an android automotive operating system (aaos) app with payments via samsung checkout 30 mins start watch face studio apply gyro effects to a watch face using watch face studio 20 mins start sdc23 smartthings matter: create a virtual device and make an open source contribution 25 mins start sdc23 smartthings matter: build a matter iot app with smartthings home api 25 mins start sdc23 galaxy z develop a widget for flex window 25 mins start sdc23 samsung pay samsung wallet integrate in-app payment into merchant apps using samsung pay sdk 30 mins start sdc23 gamedev optimize game performance with adaptive performance in unity 30 mins start sdc23 gamedev galaxy z implement flex mode into a unity game 30 mins start sdc23 watch face studio customize styles of a watch face with watch face studio 30 mins start sdc23 watch face studio galaxy z customize flex window using good lock plugin on watch face studio 20 mins start sdc23 health measure skin temperature on galaxy watch 20 mins start sdc23 health transfer heart rate data from galaxy watch to a mobile device 30 mins start watch face studio design a watch face using mask and moon phase tags 30 mins start sdc22 bixby smartthings control a smart bulb 30 mins start sdc22 watch face studio apply conditional lines on watch faces 20 mins start sdc22 health measure blood oxygen level on galaxy watch 30 mins start sdc22 health measure blood oxygen level and heart rate on galaxy watch 40 mins start sdc22 galaxy z implement multi-window picture-in-picture on a video player 20 mins start sdc22 samsung blockchain transfer erc20 token with blockchain app 45 mins start sdc22 galaxy ar emoji gamedev use ar emoji on games and 3d apps 60 mins start sdc22 gamedev galaxy z implement flex mode on an unreal engine game 120 mins start sdc22 smartthings integrate iot devices into the smartthings ecosystem 45 mins start health create a daily step counter on galaxy watch 40 mins start health track deadlift exercise on galaxy watch 40 mins start watch face studio create a watch face using tag expressions 60 mins start galaxy z implement flex mode on a video player 30 mins start galaxy z implement app continuity and optimize large screen ui of a gallery app 40 mins start galaxy z configure an app to enable copy and paste in multi-window 30 mins start galaxy z configure an app to enable drag and drop in multi-window 30 mins start galaxy s pen remote implement keyevent.callback by mapping air actions 30 mins start galaxy s pen remote handle s pen's raw data 30 mins start samsung blockchain develop a secure blockchain app 40 mins start samsung blockchain develop a blockchain shopping app 40 mins start
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 ;
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 Blockchain
docfaq q01. what is the difference between samsung blockchain sdk and samsung blockchain keystore sdk? a. samsung blockchain platform sdk is a superset of sdks. it focuses to offer a friendly blockchain solution especially for mobile developers. you can use keystore sdk if you already have dapp development experience when you need a hardware wallet. but still, you may need a deeper knownledge to use it so that platform sdk may be a better option for beginners. the main difference is the existence of network module. samsung blockchain platform sdk is available to communicate with an external blockchain node providing a payment solution. also samsung blockchain platform sdk has cucumber(web-based dapp browser which is built using android webview) so it is helpful to reduce costs to build your dapp for mobile environment. q02. what would be a good choice among sdks? a. samsung blockchain sdk: the blockchain dapp developer needs a simple payment solution, dapp without handset limitation, integrated with various cold wallets, and a legacy player who already has an experience with e-commerce (ex. online shopping app). especially it can be a better option for web based dapp partners who has a plan to integrate the service into mobile environment. samsung blockchain keystore sdk: for dapp partners who needs a key storage to directly handle it. q03. which coin is supported? a. it supports ethereum and tron. you can see erc20, erc721 and trc10, trc20 item information when it follows the specification. q04. does it have any device limitations / restrictions? a. no. samsung blockchain platforms sdk doesn’t have any device or region dependency. but, please note that it needs a cold wallet so that it follows the cold wallet’s restriction. for example, you can use your dapp integrated with sdk on any device released by samsung when you connect to external cold wallet. but if you use the samsung keystore, it has to be same with the keystore’s restriction. q05. what should i do using keystore via platform sdk? a. you need an api key for getting a permission to access keystore. please refer request for api key. note that, in case of integrating ledger devices, you don't need this process. q06. what should i do when i get the following build error: "failed to transform artifact 'bcprov-jdk15on.jar"? a. add the following to your project's gradle.properties: android.jetifier.blacklist=bcprov
Develop Samsung Pay
docinitiate in-app payment merchant applications can use apis to fetch payment information details with custom payment sheet the following functionalities are ready to perform a variety of payment operations checking registered/enrolled card information creating a transaction request requesting payment with a custom payment sheet 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 to query the card brand, use the requestcardinfo api method of the samsungpaysdkflutter class 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 onresult and onfailure events the following snippet shows how to retrieve the list of supported card brands from samsung wallet samsungpaysdkflutterplugin requestcardinfo cardinfolistener {onresult paymentcardinfo showcardlist paymentcardinfo ; }, onfailure errorcode, bundle { showerror errorcode, bundle ; } ; creating a transaction request upon successful initialization of the samsungpaysdkflutter class, the merchant app needs to create a transaction request with payment information using the custom payment sheet to initiate a payment transaction with samsung wallet’s custom payment sheet, your merchant app must populate the following mandatory fields in customsheetpaymentinfo merchant name - as it will appear in samsung wallet’s payment sheet, as well as the user's card account statement customsheet - is called when the user changes card on the custom payment sheet in samsung wallet 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 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 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 string? merchantid; string merchantname; string? ordernumber; addressinpaymentsheet? addressinpaymentsheet; list<brand>? allowedcardbrand; paymentcardinfo? cardinfo; bool? iscardholdernamerequired; bool? isrecurring; string? merchantcountrycode; customsheet customsheet; map<string,dynamic>? extrapaymentinfo; your merchant app sends this customsheetpaymentinfo to samsung wallet via the applicable samsung pay sdk flutter plugin 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 the following example demonstrates how to populate customsheet in the customsheetpaymentinfo class list<brand> brandlist = []; brandlist add brand visa ; brandlist add brand mastercard ; brandlist add brand americanexpress ; customsheetpaymentinfo customsheetpaymentinfo= customsheetpaymentinfo merchantname "merchantname", customsheet customsheet ; customsheetpaymentinfo setmerchantid "123456" ; customsheetpaymentinfo setmerchantname "sample merchant" ; customsheetpaymentinfo setaddressinpaymentsheet addressinpaymentsheet need_billing_send_shipping ; customsheetpaymentinfo setcardholdernameenabled true ; customsheetpaymentinfo setrecrringenabled false ; customsheetpaymentinfo setcustomsheet customsheet ; customsheetpaymentinfo allowedcardbrand = brandlist; return customsheetpaymentinfo; requesting payment with a custom payment sheet the startinapppaywithcustomsheet method of the samsungpaysdkflutter 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 - updates the custom payment sheet if any values on the sheet are changed 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 wallet 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 samsungpaysdkflutter class class customsheettransactioninfolistener{ function paymentcardinfo paymentcardinfo, customsheet customsheet oncardinfoupdated; function customsheetpaymentinfo customsheetpaymentinfo, string paymentcredential, map<string, dynamic>? extrapaymentdata onsuccess; function string errorcode, map<string, dynamic> bundle onfail; customsheettransactioninfolistener {required this oncardinfoupdated, required this onsuccess, required this onfail} ; } void oncardinfoupdated cardinfo selectedcardinfo, customsheet customsheet { amountboxcontrol amountboxcontrol = customsheet getsheetcontrol amount_control_id as amountboxcontrol; amountboxcontrol updatevalue product_item_id, 1000 ; amountboxcontrol updatevalue product_tax_id, 50 ; amountboxcontrol updatevalue product_shipping_id, 10 ; amountboxcontrol updatevalue product_fuel_id, 0, "pending" ; amountboxcontrol setamounttotal 1060, amountconstants format_total_price_only ; customsheet updatecontrol amountboxcontrol ; } } void startinapppaywithcustomsheet customsheetpaymentinfo customsheetpaymentinfo,customsheettransactioninfolistener? customsheettransactioninfolistener { try{ methodchannelsamsungpaysdkflutter? startinapppaywithcustomsheet customsheetpaymentinfo, customsheettransactioninfolistener ; }on platformexception catch e { print e ; } } override fun onsuccess response customsheetpaymentinfo, paymentcredential string, extrapaymentdata bundle {} override fun onfailure errorcode int, errordata bundle? {}
web
learn to developwith samsung explore our sdks and tools through code lab, blogs, articles, videos and more. popular learning topics discover what our developers are watching and reading. code lab code lab integrate 'add to samsung wallet' button into partner services learn how to integrate the add to samsung wallet functionality into partner services, enabling users to add boarding passes, tickets, coupons, gift cards, loyalty cards, and id cards to samsung wallet. code lab code lab customize styles of a watch face with watch face studio learn how to easily customize the style of a watch face using the customization editor in watch face studio. know how to make your watch face respond to your step count using conditional lines. code lab code lab matter: build a matter iot app with smartthings home api learn how to create an iot app to onboard, control, remove, and share matter devices using smartthings home apis. tutorial tutorial start your learning journey with code lab code lab is a learning platform where you can get started with the latest technologies and services in samsung. tutorial tutorial integrate samsung iap in your unreal engine 5 game monetize your unreal engine game in galaxy store using samsung iap unreal plugin video tutorials go to youtube video apr 3, 2024 developing apps for galaxy watch? start setting up! learn how to enable developer mode on your galaxy watch, operating on wear os powered by samsung. apr 3, 2024 video mar 21, 2023 quick and easy: using a galaxy emulator skin watch this youtube shorts to quickly learn how to make your android virtual device look like a galaxy device using the galaxy emulator skin. mar 21, 2023 video oct 12, 2022 watch face studio with dark mode create a beautiful watch face that is refined and provides a more comfortable viewing experience in low-light situations. oct 12, 2022 video feb 9, 2022 how to test your mobile apps through a web browser remote test lab is a service that enables developers to control devices remotely. with this, you can test your applications on a real device by interacting with it over the network in real-time. feb 9, 2022 newsletter monthly newsletter for samsung developers if you don't currently receive the newsletter, you can subscribe here. 뉴스레터 전송을 위한 개인정보 수집∙이용에 동의합니다(필수). detail 광고성 정보 수신에 동의합니다(필수). detail i agree to data processing for sending newsletters. (required) detail i consent to receiving newsletters via email. (required) i consent to receiving newsletters via email. detail subscribe code lab learn about how to use samsung sdks and tools to implement various use cases with sample apps. learn more foldables and large screens boost your app's value with foldables and large screen optimization learn more
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.