Filter
-
Content Type
-
Category
Mobile/Wearable
Visual Display
Digital Appliance
Platform
Recommendations
Filter
Learn Code Lab
codelabintegrate samsung pay sdk flutter plugin into merchant apps for in-app payment objective learn how to integrate in-app payment with your flutter-based merchant apps using samsung pay sdk flutter plugin partnership request to use the samsung pay sdk flutter plugin, you must become an official samsung partner once done, you can fully utilize this code lab you can learn more about the partnership process by visiting samsung pay in samsung developers overview the samsung pay sdk flutter plugin allows developers to use samsung wallet features in flutter applications it is the wrapper of samsung pay sdk, which is an application framework for integrating samsung wallet features on galaxy devices the samsung pay sdk flutter plugin offers in-app payment feature that gives customers the opportunity to pay for products and services with samsung wallet set up your environment you will need the following samsung wallet app version 5 6 53, 5 8 0 samsung pay sdk flutter plugin android studio latest version recommended java se development kit jdk 11 or later flutter sdk a compatible galaxy device with android q 10 0 or android api level 29 or later android os versions noteflutter sdk must be installed and set up properly when developing flutter applications after downloading, follow the installation guide appropriate to your operating system after proper installation and setup, configure your android studio to include the flutter plugin for intellij check this editor guide for the detailed steps sample code here is a sample code for you to start coding in this code lab download it and start your learning experience! in-app payment flutter plugin sample code 20 4 mb start your project in android studio, click open to open an existing project locate the flutterinapppayment project from the directory, and click ok go to file > settings > languages & frameworks > flutter to change the flutter sdk path input the directory path where your flutter sdk is installed and click apply install the plugin and configure the api level add samsungpaysdkflutter_v1 01 00 folder in the project go to samsungpaysdkflutter_v1 01 00 > pubspec yaml file and click on pub get in right side of the action ribbon or run flutter pub get in the command line next, go to flutterinapppayment > pubspec yaml and add the samsungpaysdkflutter_v1 01 00 plugin under dependencies samsung_pay_sdk_flutter path /samsungpaysdkflutter_v1 01 00 warningbe careful of line alignment of pubspec yaml file, as the indentations indicate the structure and hierarchy of the data from the terminal, run flutter pub get command or click on pub get in the right side of the action ribbon configure the api level samsung pay sdk flutter plugin supports samsung pay sdk version 2 18 or later hence, we must set a valid api version latest version 2 19 of samsung pay sdk go to android > app > src > main > androidmanifest xml and add the api level in the meta-data of application tag <meta-data android name="spay_sdk_api_level" android value="2 19" /> // most recent sdk version is recommended to leverage the latest apis add the samsung pay button go to the main project, flutterinapppayment project > lib > main dart here, the ui is created using the build widget this widget shows the sample item information such as image, name, and price add a bottomnavigationbar before the end of the body of scaffold to display the samsung pay button bottomnavigationbar visibility visible isspaystatusready, child inkwell ontap { requestpaymentwithsamsungwallet ; }, child image asset 'assets/pay_rectangular_full_screen_black png' , , , check samsung pay status in main dart > myhomepage class, create an instance of samsungpaysdkflutter with valid partnerinfo service id and service type during onboarding, the samsung pay developers site assigns the service id and service type these data are used for partner verification static final samsungpaysdkflutterplugin = samsungpaysdkflutter partnerinfo serviceid service_id, data {spaysdk partner_service_type servicetype inapp_payment name} ; notethe service id is already provided in the sample code for this code lab however, this service id is for test purposes only and cannot be used for an actual application or service to change the service id in your actual application, the value of the variable service_id should be modified to check whether samsung pay is supported on your galaxy device, call the getsamsungpaystatus api and change the samsung pay button visibility accordingly in checksamsungpaystatus method, apply the following code void checksamsungpaystatus { //update ui according to samsung pay status myhomepage samsungpaysdkflutterplugin getsamsungpaystatus statuslistener onsuccess status, bundle async { if status == "2" { setstate { isspaystatusready = true; } ; } else { setstate { isspaystatusready = false; } ; _showtoast context,"spay status not ready" ; } }, onfail errorcode, bundle { setstate { isspaystatusready = false; } ; _showtoast context,"spay status api call failed" ; } ; } inside initstate method, call checksamsungpaystatus to ensure that getsamsungpaystatus api is called before any other api is called checksamsungpaystatus ; notethe getsamsungpaystatus api must be called before using any other feature in the samsung pay sdk flutter plugin create a custom payment sheet samsung pay sdk flutter plugin offers a custom type payment sheet called customsheet to customize the ui with additional payment related data here, create customsheet using the following controls amountboxcontrol it is a mandatory control to build a customsheet it provides the monetary details of the transaction addresscontrol it is used to display the billing and shipping address in makeamountcontrol method, add items and total price to build amountboxcontrol amountboxcontrol additem strings product_item_id, "item", 1199 00, "" ; amountboxcontrol additem strings product_tax_id, "tax", 5 0, "" ; amountboxcontrol additem strings product_shipping_id, "shipping", 1 0, "" ; amountboxcontrol setamounttotal 1205 00, spaysdk format_total_price_only ; in makebillingaddress method, add the following code to create billingaddresscontrol set sheetitemtype as zip_only_address while creating billingaddresscontrol to get the zip code as we are expecting to get the user's billing address from samsung wallet, set sheetupdatedlistener addresscontrol billingaddresscontrol = addresscontrol strings billing_address_id, sheetitemtype zip_only_address name ; billingaddresscontrol setaddresstitle strings billing_address ; billingaddresscontrol sheetupdatedlistener = billinglistener; return billingaddresscontrol; notefrom samsung pay sdk version 2 19 onwards, users can only add zip code as their billing address only the zip code is fetched from the user's samsung wallet instead of the full billing address implement this listener in makeupcustomsheet method to update the custom sheet when the user updates their billing address sheetupdatedlistener sheetupdatedlistener = sheetupdatedlistener onresult string controlid, customsheet sheet { if controlid == strings billing_address_id { var addresscontrol = sheet getsheetcontrol controlid as addresscontrol; setstate { postalcode = addresscontrol address! postalcode; } ; } myhomepage samsungpaysdkflutterplugin updatesheet sheet ; } ; create the shipping address in buildshippingaddressinfo method to add it in shipping addresscontrol this is the shipping address from the merchant app maddress = address addressee "jane smith", addressline1 "123 main st", addressline2 "suite 456", city "anytown", state "st", countrycode "usa", postalcode "12345", phonenumber "+1 555-123-4567", email "example@email com" ; add this address in makeshippingaddress method shippingaddresscontrol address = buildshippingaddressinfo ; finally, complete the makeupcustomsheet method by adding amountboxcontrol, billingaddresscontrol, and shippingaddresscontrol customsheet addcontrol makeamountcontrol ; customsheet addcontrol makebillingaddress sheetupdatedlistener ; customsheet addcontrol makeshippingaddress ; create a transaction request to start the payment process, the merchant app should create a transaction request with payment information in maketransactiondetailswithsheet method, add the merchant name and custom sheet in customsheetpaymentinfo customsheetpaymentinfo customsheetpaymentinfo = customsheetpaymentinfo merchantname "in app payment flutter app", customsheet makeupcustomsheet ; your merchant app must fill the following mandatory fields in customsheetpaymentinfo customsheetpaymentinfo merchantid = "123456"; customsheetpaymentinfo setordernumber "amz007mar" ; customsheetpaymentinfo setmerchantcountrycode "us" ; customsheetpaymentinfo addressinpaymentsheet = addressinpaymentsheet need_billing_send_shipping; request payment with a custom payment sheet the startinapppaywithcustomsheet api is called to request payment using a custom payment sheet in samsung pay this api requires customsheetpaymentinfo and customsheettransactioninfolistener first, implement this listener before starting the payment customsheettransactioninfolistener transactionlistener { customsheettransactioninfolistener customsheettransactioninfolistener = customsheettransactioninfolistener oncardinfoupdated paymentcardinfo paymentcardinfo, customsheet customsheet { myhomepage samsungpaysdkflutterplugin updatesheet customsheet ; }, onsuccess customsheetpaymentinfo customsheetpaymentinfo, string paymentcredential, map<string, dynamic>? extrapaymentdata { print "payment success" ; }, onfail string errorcode, map<string, dynamic> bundle { print "payment failed" ; } ; return customsheettransactioninfolistener; } lastly, call startinapppaywithcustomsheet api to start the payment in the requestpaymentwithsamsungwallet method void requestpaymentwithsamsungwallet { myhomepage samsungpaysdkflutterplugin startinapppaywithcustomsheet maketransactiondetailswithsheet , transactionlistener ; } run the app build the app by running flutter build apk --debug in the command line or going to build > flutter > build apk deploy the app on the device test it by clicking on samsung pay button to proceed with the payment transaction to thoroughly test the sample app, you must add at least one payment card to the samsung wallet app you're done! congratulations! you have successfully achieved the goal of this code lab now, you can integrate in-app payment with your flutter app by yourself! if you are having trouble, you may download this file in-app payment flutter plugin complete code 62 0 mb to learn more about developing apps for samsung pay devices, visit developer samsung com/pay
Develop Samsung Pay
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
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 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.
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 ;
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? {}
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
docthe following figure illustrates the ui flow for app-to-app id&v when the user wants to add a payment card to samsung wallet and selects the “open banking app” option
Develop Samsung Pay
docintroduction detailed flow step 1 → 2 partner server is ready to show the user the "add to spay ui" partner server registers to save2pay and gets a regid and welcomeurl back regid uniquely identifies this session and should be cached by partner server and used throughout the entire flow welcomeurl provides the ui to lead the user to add the card to spay step 3 the partner server shows the welcome ui on the browser, presumably in an iframe the welcome ui would show qr code as well as necessary instructions step 4 user launches spay wa and scans the qr code displayed on the welcome ui if spay wa was not installed, the instructions on welcome ui would lead the user to download the app if necessary , register samsung account and login into the spay client step 5 → 6 the spay wa qr scanner would attempt to invoke the url embedded in the qrcode, more specifically the "initiate" request to save2pay server the server verifies the payload and notifies partner server that the spay wa is ready device specific information such as the device id, wallet id & user id will also be sent this step essentially links the samsung account with the regid the welcome ui would also show a message indicating the linking is successful step 7 → 8 partner server talks to the issuer to pre-provision the card and get encrypted issuerblob step 9 partner server returns the issuerblob in the notify response the issuerblob will be encrypted and can only be decrypted by the issuer server the blob will also have device and wallet specific information so it can only be provisioned to the device that made the 'initiate' request the exact format of the issuerblob depends on the issuer step 10 the issuerblob and additional information are returned to the device in the 'initiate' response steps 11 → 16 spay wa would go through the normal tokenization flow to add the token into spay using the issuerblob step 17 spay wa report to s2p server that the provision is completed for this regid step 18 s2p notifies partner server that provisioning is completed for this regid data types type json type format description string string size 2048 boolean boolean object object enum string pattern [a-za-z0-9_]{1,256 values from a limited set are only allowed each field of type enum will define the values allowed phonenumber string pattern [0-9+ -]+ uuid string pattern [a-za-z0-9-_]{26,128} unique identifie url string size 2048 must be an absolute url defined by rfc 2396 uniform resource identifiers uri generic syntax supported schemes - http, https timestamp number int64 - signed 64 bits unix epoch time in milliseconds countrycode string size 2 unique identifie
Learn Code Lab
codelabtransfer erc20 token with blockchain app objective develop a decentralized application dapp to transfer erc20 tokens between ethereum accounts using samsung blockchain platform sdk overview blockchain technology has been creating a significant impact in multiple sectors, such as banking, cybersecurity, and supply chain management it is widely used as a means of secure payment between different parties samsung blockchain platform sdk brings developers and consumers to the blockchain world by providing a complete set of functions that the decentralized app dapp or blockchain app needs ethereum is a decentralized blockchain network where you can perform transactions using its native currency, ether, and token you can interact with the network through simple api calls provided by the sdk for detailed information, see samsung blockchain platform sdk set up your environment you will need the following java se development kit 8 or later android studio latest version recommended samsung galaxy device that supports samsung blockchain sample code here is a sample code for you to start coding in this code lab download it and start your learning experience! token transaction sample code 2 73 mb enable developer mode to activate developer mode on your mobile device, follow the steps below navigate through settings > biometrics and security > samsung blockchain keystore and click about blockchain keystore tap the samsung blockchain keystore app name quickly, ten times or more if succeeded, developer mode will show start your project after downloading the sample code containing the project files, in android studio, click open to open the existing project locate the downloaded android project codelab-send-token-transaction-blank-code from the directory and click ok noteuser interface ui resources are already included in the provided project simply apply the code in the next steps in this code lab moreover, going through the sdk document is recommended initialize the instance since sblockchain is the initial base class of the samsung blockchain platform sdk, the first thing you need to do is create an sblockchain instance along with that, create the following in sendtokenfragment java hardwarewalletmanager for wallet operations accountmanager for account operations ethereumservice for transactions msblockchain = new sblockchain ; try { msblockchain initialize mcontext ; } catch ssdkunsupportedexception e { e printstacktrace ; } maccountmanager = msblockchain getaccountmanager ; mhardwarewalletmanager = msblockchain gethardwarewalletmanager ; mcoinnetworkinfo = new coinnetworkinfo cointype eth, ethereumnetworktype goerli, rpcurl ; mcoinservice = coinservicefactory getcoinservice getcontext , mcoinnetworkinfo ; ethereumservice = ethereumservice mcoinservice; connecttohardwarewallet ; connect to samsung blockchain keystore connect the app to the hardware wallet, which, in this case, is the samsung blockchain keystore you can get a hardware wallet instance from hardwarewalletmanager if you want to reset the wallet, set the second parameter of connect api to true otherwise, set it to false mhardwarewalletmanager connect hardwarewallettype samsung, false setcallback new listenablefuturetask callback<hardwarewallet> { @override public void onsuccess hardwarewallet hardwarewallet { handler post new runnable { @override public void run { log i tag, "hardwarewallet is connected " ; mprogressbar setvisibility view invisible ; getaccount ; } } ; } @override public void onfailure @nonnull executionexception e { mprogressbar setvisibility view invisible ; log e tag, "hardwarewallet connection failed " + e ; } @override public void oncancelled @nonnull interruptedexception e { mprogressbar setvisibility view invisible ; log e tag, "hardwarewallet connection cancelled " + e ; } } ; generate new account samsung blockchain platform sdk manages the address on blockchain as an account it contains the information required for signing and the blockchain address accountmanager provides apis dedicated for fetching, creating, and restoring accounts use generatenewaccount api for the creation of a new ethereum account upon clicking the create account button in the app hardwarewallet connectedhardwarewallet = mhardwarewalletmanager getconnectedhardwarewallet ; maccountmanager generatenewaccount connectedhardwarewallet, mcoinnetworkinfo setcallback new listenablefuturetask callback<account> { @override public void onsuccess account account { mprogressbar setvisibility view invisible ; log i tag, "generate new account successful " + account ; handler post new runnable { @override public void run { getaccount ; } } ; } @override public void onfailure @nonnull executionexception e { mprogressbar setvisibility view invisible ; log e tag, "generate new account failed " + e ; } @override public void oncancelled @nonnull interruptedexception e { mprogressbar setvisibility view invisible ; log e tag, "generate new account cancelled " + e ; } } ; after creating a new account, call the getaccounts api to get the account list if you already have an account, the textview will show the account's address and the create account button will be disabled in the app accounts = maccountmanager getaccounts null, cointype eth, ethereumnetworktype goerli ; if !accounts isempty { methereumaccount = ethereumaccount accounts get accounts size - 1 ; showaccounttextview settext methereumaccount getaddress ; generateaccountbutton setenabled false ; } create a token account to perform a token transaction, add the token address with the corresponding ethereum account and create a token account by calling the addtokenaddress api use the generated token account to perform token-related actions an ethereum account can add one or more tokens ethereumservice addtokenaddress methereumaccount, tokenaddress setcallback new listenablefuturetask callback<ethereumaccount> { @override public void onsuccess ethereumaccount ethereumaccount { mprogressbar setvisibility view invisible ; log i tag, "add token successful " + ethereumaccount ; handler post new runnable { @override public void run { toast maketext getcontext , "add token successful", toast length_short show ; } } ; } @override public void onfailure @nonnull executionexception e { mprogressbar setvisibility view invisible ; log e tag, "add token failed " + e ; } @override public void oncancelled @nonnull interruptedexception e { mprogressbar setvisibility view invisible ; log e tag, "add token cancelled " + e ; } } ; get token balance fetch the balance of the added token using gettokenbalance api ethereumservice gettokenbalance mtokenaccount, ethereumblockparameter latest setcallback new listenablefuturetask callback<biginteger> { @override public void onsuccess biginteger biginteger { mprogressbar setvisibility view invisible ; bigdecimal tokendecimal = bigdecimal ten pow 18 ; bigdecimal balance = new bigdecimal biginteger divide tokendecimal ; log d tag, "gettokenbalance success " + balance ; handler post new runnable { @override public void run { tokenbalance settext balance tostring ; } } ; } @override public void onfailure @nonnull executionexception e { mprogressbar setvisibility view invisible ; log e tag, "gettokenbalance failed " + e ; } @override public void oncancelled @nonnull interruptedexception e { mprogressbar setvisibility view invisible ; log e tag, "gettokenbalance cancelled " + e ; } } ; transfer token to transfer tokens between accounts, set the receiver address and the amount of tokens to send the trusted ui of the samsung blockchain keystore hardware wallet appears upon pressing the send button in the app, showing all the information regarding the transaction for confirmation generate a transaction hash upon confirmation of the transaction ethereumservice sendtokentransaction mhardwarewalletmanager getconnectedhardwarewallet , mtokenaccount, mtoaddress, tokenaddress, maxpriorityfee, methereumfeeinfo getestimatedbasefee add maxpriorityfee , mgaslimit, msendtokenamount, null setcallback new listenablefuturetask callback<transactionresult> { @override public void onsuccess transactionresult transactionresult { mprogressbar setvisibility view invisible ; log i tag, "send token successful " + transactionresult gethash ; handler post new runnable { @override public void run { toast maketext getcontext , "transaction hash " + transactionresult gethash , toast length_short show ; } } ; } @override public void onfailure @nonnull executionexception e { mprogressbar setvisibility view invisible ; log e tag, "send token failed " + e ; } @override public void oncancelled @nonnull interruptedexception e { mprogressbar setvisibility view invisible ; log i tag, "send token cancelled " + e ; } } ; run the app after building the apk, follow the steps below to test the application on a samsung blockchain-compatible device in send token tab, click create account copy the generated account address go to eth faucet tab to open the free faucet site already added to the application paste the account address and press the send me eth button click the hash string under your transactions to open etherscan and wait until the transaction succeeded go to token faucet tab and press get token to add some tokens in the account confirm the transaction go back to send token tab, click add token and press token balance to see added tokens press gas limit and max priority fee lastly, press send to transfer tokens confirm the transaction check the transaction status and details by finding the account address or the generated transaction hash txn hash in goerli testnet explorer you're done! congratulations! you have successfully achieved the goal of this code lab now, you can develop a decentralized application that can transfer erc20 tokens using samsung blockchain platform sdk if you face any trouble, you may download this file token transaction complete code 2 73 mb to learn more about developing apps with samsung blockchain, visit developer samsung com/blockchain
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.