Filter
-
Content Type
-
Category
Mobile/Wearable
Visual Display
Digital Appliance
Platform
Recommendations
Filter
Learn Code Lab
codelabwallet cards with the samsung wallet partners site, you must become an official samsung partner once done, you can fully utilize this code lab you can learn more by visiting samsung wallet partner onboarding process, here in samsung developers overview samsung wallet is an application that securely stores essential items such as boarding passes, tickets, and coupons, making them easily accessible from anywhere with this app, users can access various partner wallet cards in one place, simply by swiping up from the bottom of the screen the add to samsung wallet service provides interfaces for users to conveniently add digital content to samsung wallet here are examples of the supported wallet cards boarding pass journey information such as flights, trains, and buses can be provided as notifications, allowing easy retrieval when checking in by configuring server synchronization, updates to journey information such as gate changes, schedule changes, or cancellations can be received by the users ticket notifications about events and additional information, including benefits, can be provided based on real-time utilization of performances, sports games, movies, and admission tickets, status updates related to expiration and availability can be provided gift card gift card, also referred to as a prepaid card, provides real-time balance and transaction history loyalty loyalty cards function as membership credentials, managing membership information through these cards, loyalty points can be administered and redeemed id id cards can fulfill identification verification purposes, such as identity cards, employee cards, and licenses physical documents can be represented through wallet cards, and near field communication nfc -based authentication can be provided reservation reservation cards can contain diverse online booking details, including rental cars, restaurants, and accommodations ongoing reservation information can be managed as a journey pay as you go pay as you go cards allow users to register services that can be charged and utilized according to their preference for convenient use generic card generic cards enable users to create customized cards by selecting preferred card template layouts and designing elements notedepending on your country or region, some card types are not supported if you need assistance, please contact us at developer samsung com/dashboard/support the image below shows the process of managing wallet cards for more information, refer to manage wallet cards set up your environment you will need the following latest version of samsung wallet app from galaxy store samsung galaxy device that supports samsung wallet access to samsung wallet partners site internet browser, such as chrome openssl intellij idea or any java ide optional start the onboarding process partners can manage wallet cards and monitor performance with the samsung wallet partners site to join as partner generate a private key and certificate signing request csr using the openssl command you can follow the instructions in security factors notea private key enables encryption and is the most important component of certificates while csr, which is a necessary factor to obtain a signed certificate, includes the public key and additional information like organization and country proceed to register in the samsung wallet partners site using your samsung account follow the samsung wallet partner onboarding process upload the generated csr for data encryption in encryption setting management section after registration, you will receive a welcome email noteupon receiving the certificates via email, be sure to keep the information safe from exposure and only use them for the following purposes signed certificate used along with the private key to sign data samsung certificate used to encrypt card data and validate authentication tokens in server api headers create a wallet card follow the steps below to create a wallet card in samsung wallet partners site click the wallet cards menu and choose create wallet card fill out the general information form with the details of the wallet card in wallet card template, choose a card type and sub type select the design type and click done you can choose from various types of wallet card templates optimized for partners after inputting all necessary details, click save to set the wallet card status to draft launch the wallet card you can launch and request activation of the card by clicking the launch button upon agreeing to proceed, the launch button text changes to launched and the card status becomes verifying add the card to samsung wallet using the test tool open a web browser on your computer or galaxy mobile device, and go to the following link partner walletsvc samsung com/addtowallettest go to add to wallet tab and click choose key file to upload your private key in the select card dropdown menu, select the created card to display the card details and populate sample data navigate to the form tab and modify the card data as desired notethe structure for configuring wallet cards follows the defined specification you can refer to the full list of card-specific attributes specification scroll down to the bottom of the page and click the add to samsung wallet button click done when a preview of the card shows on your mobile screen with a message indicating that the card has been added to your wallet once the card is added to your samsung wallet app, you can check its details by clicking on it noteyou can also go to the playground tab and add cards to the samsung wallet app even without creating a card on the wallet partners site update the status of the added card if a server api info partner get card data and partner send card state is registered in the wallet card, real-time updates of the user's registered cards can be provided notefor more information, see server interaction modify and update the card's status by utilizing the push notification feature of the test tool navigate to the push notification tab ensure that the correct private key is uploaded and the same card as in the add to wallet tab is selected copy the ref id value from the add to wallet tab and paste it into ref id field in the push notification tab in the status field, enter one of the following card states expired, redeemed, held, suspended, or deleted the current state is set to active then, click the request push notification button check the card in the samsung wallet app to confirm the change tokenize card data and implement the add to samsung wallet button to your service optional notethis step is optional, but if you want to learn how to integrate the add to samsung wallet button into your services like an android app, web app, or email, you can follow these steps the samsung wallet partners site provides generated add to samsung wallet scripts for each wallet card you create you can simply copy and paste these scripts into your partner apps web and android or include them in emails/mms messages to implement the add to wallet button, follow these steps go to the [add to wallet script guide] section of the card you created click show to view the available scripts and then copy the appropriate script for your service develop a program that can generate tokenized card data cdata the cdata represents the actual content of the wallet card and comes in different formats depending on the card type you can check the cdata generation sample code for reference the cdata is derived from the card data, which is in json format for testing purposes, you can utilize the generated json from the test tool follow the implementing atw button guide to determine where to incorporate the generated cdata and gain further insights into this process you're done! congratulations! you have successfully achieved the goal of this code lab topic now, you can utilize the add to samsung wallet service by yourself! to learn more about samsung wallet, visit developer samsung com/wallet
Learn Code Lab
codelabwallet cards with the samsung wallet partners site, you must become an official samsung partner once done, you can fully utilize this code lab you can learn more by visiting samsung wallet partner onboarding process, here in samsung developers notein accordance with the applicable samsung wallet partners agreements, this code lab covers the setup and use of the verify with samsung wallet service for purposes of integrating samsung wallet with partner sites and apps the use cases and corresponding code samples included are representative examples only and should not be considered as either recommended or required overview verify with samsung wallet enables users to utilize the digital id added to their wallets to simplify online transactions that require an identity verification a mobile device with samsung wallet installed is required to verify the user’s identity through this feature this feature uses the relying party card type to verify a user's identity using the id information stored in samsung wallet this feature supports app-to-app app2app and web-to-app web2app integration models the web2app integration supports the partner's mobile web application to request a verification to the samsung wallet app the app2app integration supports the partner’s mobile application to request a verification to the samsung wallet app when the partner site requests the user to verify their identity, the verify with samsung wallet button is displayed the user is redirected to the samsung wallet app where they verify their identity via pin or biometrics once verified, the user's identity information is sent to the partner and the transaction will proceed noteas of 2024, this feature is only available in the united states and can be used by the state government with mobile driver's license mdl support for more information, visit https //developer samsung com/dashboard/support for detailed description, see verify with samsung wallet set up your environment you will need the following access to samsung wallet partners site samsung galaxy device that supports samsung wallet app samsung wallet app latest version android studio latest version recommended java se development kit jdk 11 or later supported mobile driver's license be added to samsung wallet app internet browser, such as google chrome openssl intellij idea or any java ide optional sample code here is a sample code for you to start coding in this code lab download it and start your learning experience! verify with wallet sample code for app2app integration 802 3 kb start the onboarding process partners can manage wallet cards and monitor performance with the samsung wallet partners site to join as partner generate a private key and certificate signing request csr using the openssl command you can follow the instructions in security factors notea private key enables encryption and is the most important component of certificates while csr, which is a necessary factor to obtain a signed certificate, includes the public key and additional information like organization and country proceed to register in the samsung wallet partners site using your samsung account follow the samsung wallet partner onboarding process upload the generated csr for data encryption in encryption setting management section after registration, you will receive a welcome email noteupon receiving the certificates via email, be sure to keep the information safe from exposure and only use them for the following purposes signed certificate used along with the private key to sign data samsung certificate used to encrypt card data and validate authentication tokens in server api headers create a relying party wallet card follow the steps below to create a wallet card in samsung wallet partners site go to wallet cards > manage wallet card and click add wallet card in wallet card template field, choose [wallet] relying party as wallet card type and relyingparty > others as sub type select the design type and click done in wallet card custom setting, click change, and choose drivers as authentication issuer you can also select specific mdls such as below notethe authentication issuer is a unique property of the relying party card type the identity provider of the authentication issuer is supported depending on the service location set for example, if the service location is in the united states, the authentication issuer field only supports any identity provider in the united states region in main headquarters location, select united states once finished, select save to view all registered information launch wallet cards you can launch and request activation of the cards by clicking the launch button upon agreeing to proceed, the launch button text changes to launched and the card status becomes verifying create a verify with samsung wallet button app2app for the app2app integration, you need to setup the button inside the mobile application in android studio, click open locate the downloaded android project rpclient_codelab from the directory and click ok go to app > kotlin+java > com samsung android sample rpclient > presentation > partners and, in the partnersrequestfragment kt file, add the verify with samsung wallet button inside the oncreateview function glide with this load partner getverifybuttonimage into binding verifybutton set up a click listener for the verifybutton binding verifybutton setonclicklistener { /// add the requestdata variable to prepare the request fields /// add the applink variables to request the card information /// call the applink method to request verification } inside the listener, add the requestdata variable to prepare the request fields for verification val requestdata = demodata requestdata add the applink variables to request the card information val applink = rpclientapis buildapplink partnerid = partner getpartnerid , cardid = partner getcardid , payload = partner buildapp2apppayload , samsungpublickey = partner getsamsungpublickey , partnerpublickey = partner getpartnerpublickey , partnerprivatekey = partner getpartnerprivatekey , isstagingserver = true the data being requested are as follows partnerid = gets the partner id from the identification card used cardid = gets the card id from the identification card used payload = builds the app2app payload samsungpublickey = gets the samsung public key partnerpublickey = gets the partner's public key partnerprivatekey = gets the partner's private key isstagingserver = checks if the application runs on a staging environment noterequested data such as partnerid, public keys, and private keys are generated during the onboarding process, while cardid is generated when you create a wallet card however, in this code lab, these data is already predefined and included in the sample mobile app call the applink method to request verification this method creates a channel between the test app and samsung wallet app to create the request and response data for the verification process applink? let { log i tag, applink rpclientapis request "com samsung android spay", uuid randomuuid tostring , applink, object rpclientapis onresponselistener { override fun ongetmdocrequestdata deviceengagementbytes bytearray bytearray? { log i tag, "deviceengagementbytes=${deviceengagementbytes tohex }" val keypair = securerepository generateeckeypair log i tag, "requestdata=$requestdata" val encryptedsessionestablishmentbytes = securerepository buildsessionestablishment requestdata, deviceengagementbytes, keypair log i tag, "encryptedsessionestablishmentbytes=${encryptedsessionestablishmentbytes? tohex }" return encryptedsessionestablishmentbytes } override fun onmdocresponse encryptedresponsebytes bytearray { log i tag, "encryptedresponsebytes=${encryptedresponsebytes tohex }" try { val plainresponse = securerepository decryptmdocresponse encryptedresponsebytes log i tag, "plainresponse=${plainresponse? toprettyjson }" val responsedata = plainresponse? toprettyjson onresponse postvalue responsedata } catch e exception { e printstacktrace } } override fun onmdocresponsefailed exception exception { log i tag, "onmdocresponsefailed ${exception} " onerror postvalue exception } } } run and test the application app2app go to build > build app bundle s / apk s > build apk s to build the application install the apk file to your mobile device and test the sample app as follows open the sample app and choose sdc code lab press the verify with samsung wallet button once you are redirected to the samsung wallet app, press the verify button the samsung wallet app shows a checkmark to indicate that the identity has already been verified while the sample app displays a verification success screen test the verify with samsung wallet button web2app for the web2app integration, you can use the test tool to test the verify with samsung wallet button open a web browser on your computer or galaxy mobile device and go to the following link partner walletsvc samsung com/addtowallettest go to verify with wallet tab and click choose key file to upload your private key in the select card dropdown menu, select the card you created to display its details navigate to the form tab and modify the data as desired you can change the logo image or provider name press the verify with samsung wallet button once you are redirected to samsung wallet, press the verify button the samsung wallet app shows a checkmark to indicate that the identity has already been verified go back to the test tool, open the mdoc tab, and click the check result button it displays a result success popup when the verification process is successful tokenize card data and implement the verify with wallet button to your service optional notethis step is optional, but if you want to learn how to integrate the verify with wallet button into your services like an android app, web app, or email, you can follow these steps the samsung wallet partners site provides generated verify with samsung wallet scripts for each wallet card you create you can simply copy and paste these scripts into your partner apps web and android or include them in emails/mms messages to implement the verify with wallet button, follow these steps go to the [verify with wallet script guide] section of the card you created click show to view the available scripts and then copy the appropriate script for your service develop a program that can generate tokenized card data cdata the cdata represents the actual content of the wallet card and comes in different formats depending on the card type you can check the cdata generation sample code for reference the cdata is derived from the card data, which is in json format for testing purposes, you can utilize the generated json from the test tool follow the implementing button guide to determine where to incorporate the generated cdata and gain further insights into this process you are redirected back to your app and your identity is verified you're done! congratulations! you have successfully accomplished the topic of this code lab now, you are ready to verify your id with the verify with samsung wallet button into your application on your own! if you're having trouble, you may download this file verify with wallet complete code for app2app integration 802 5 kb to learn more about samsung wallet, visit developer samsung com/wallet
Learn Code Lab
codelabintegrate samsung pay web checkout with merchant sites objective learn how to integrate the samsung pay payment system into your merchant sites using the samsung pay web checkout sdk partnership request to use the samsung pay web checkout sdk, you must become an official samsung pay partner once done, you can fully utilize this code lab you can learn more about the partnership process by visiting the samsung pay page here in samsung developers notein accordance with the applicable samsung pay partners agreements, this code lab covers the setup and use of the samsung pay web checkout sdk for purposes of integrating samsung pay with merchant sites the use cases and corresponding code samples included are representative examples only and should not be considered as either recommended or required overview the samsung pay web checkout service enables users to pay for purchases on your website with payment cards saved in the samsung wallet app on their mobile device it supports browser-based payments on both computers and mobile devices a mobile device with samsung wallet installed is required to make purchases through samsung pay web checkout when the user chooses to pay with samsung pay, they must provide their samsung account id email id or scan the qr code on the screen with their mobile device the user then authorizes the purchase within the samsung wallet application, which generates the payment credential on the device and transmits it to your website through the web checkout for more information, see samsung pay web checkout set up your environment you will need the following access to samsung pay developers site samsung wallet test app from samsung pay developers site samsung galaxy device that supports samsung wallet app internet browser, such as google chrome codesandbox account notein this code lab, you can use the samsung wallet test app to try the functionality of the samsung pay web checkout service in a staging environment you can use the official samsung wallet app from the galaxy store once your service is in the production environment start your project and register your service in your browser, open the link below to access the project file of the sample merchant site codesandbox io/s/virtual-store-sample-fnydk5 click the fork button to create an editable copy of the project next, follow the steps below to register your sample merchant site in the samsung pay developers site go to my projects > service management click create new service select web online payment as your service type enter your service name and select your service country select your payment gateway from the list of supported payment gateways pg if your pg uses the network token mode, upload the certificate signing request csr or privacy enhanced mail pem file you obtained from your pg contact your pg for details enter the payment domain name s for your website in the service domain field and click add for example, if your domain is mywebstore com, but the checkout page is hosted on the subdomain payments mywebstore com, you will need to enter payments mywebstore com as the service domain for each additional domain url, click add in this code lab, the generated preview url of the forked project is your service domain click the name of the newly created service to see its details, such as the generated service id that you can use for all the registered service domains include the samsung pay web checkout javascript sdk the samsung pay web checkout sdk uses javascript to integrate the samsung pay payment system to your website this sdk allows users to purchase items via web browser in the <head> section of the index html file of the project, include the samsung pay web checkout javascript sdk file <script src="https //img mpay samsung com/gsmpi/sdk/samsungpay_web_sdk js"></script> initialize the samsung pay client to initiate payments using the samsung pay api, create a new instance of the paymentclient class and pass an argument specifying that the environment as stage write the code below in the <script> tag of the <body> section const samsungpayclient = new samsungpay paymentclient { environment "stage" } ; when the service is still in debug or test mode, you can only use the staging environment to test payment functionality without processing live transactions noteby default, the service is initially set to debug or test mode during creation to switch the service status to release mode, a request must be made through the samsung pay developers site after successfully transitioning to release mode, change the environment to production next, define the service id, security protocol, and card brands that the merchant can support as payment methods the service id is the unique id assigned to your service upon creation in the samsung pay developers site let paymentmethods = { version "2", serviceid "", //input your service id here protocol "protocol_3ds", allowedbrands ["visa", "mastercard"] }; check whether the samsung pay client is ready to pay using the given payment method call the createandaddbutton function if the response indicates that the client is ready samsungpayclient isreadytopay paymentmethods then function response { if response result { createandaddbutton ; } } catch function err { console error err ; } ; create and implement the samsung pay button go to the <body> section and, inside the page-container div, create a container for the samsung pay button <div align="center" id="samsungpay-container"></div> next, go back to the <script> tag and write the createandaddbutton function inside this function, generate the samsung pay button by calling the createbutton method ensure that the button appears on the page by appending it to the container you created function createandaddbutton { const samsungpaybutton = samsungpayclient createbutton { onclick onsamsungpaybuttonclicked, buttonstyle "black"} ; document getelementbyid "samsungpay-container" appendchild samsungpaybutton ; } function onsamsungpaybuttonclicked { // create the transaction information //launch the payment sheet } from the createandaddbutton function, call the onsamsungpaybuttonclicked function when the user clicks the generated button create the transaction information in the onsamsungpaybuttonclicked function, create the transactiondetail object for the user’s purchase input your service domain in the url key let transactiondetail = { ordernumber "sample0n1y123", merchant { name "virtual shop", url "", //input your service domain countrycode "us" }, amount { option "format_total_estimated_amount", currency "usd", total 2019 99 } }; below are the descriptions of the keys included in the transactiondetail object key type description ordernumber string order number of the transaction allowed characters [a-z][a-z][0-9,-] merchant object data structure containing the merchant information merchant name string merchant name merchant url string merchant domain url e g , samsung com the maximum length is 100 characters merchant countrycode string merchant country code e g , us for united states iso-3166-1 alpha-2 amount object data structure containing the payment amount amount option string display format for the total amount on the payment sheet format_total_estimated_amount = displays "total estimated amount " with the total amountformat_total_price_only = displays the total amount only amount currency string currency code e g , usd for us dollar the maximum length is 3 character amount total string total payment amount in the currency specified by amount currencythe amount must be an integer e g , 300 or in a format valid for the currency, such as 2 decimal places after a separator e g , 300 50 notefor the complete list of specifications for the transactiondetail object, see samsung pay web checkout api reference launch the payment sheet after creating the transaction information, call the loadpaymentsheet method to display the web checkout ui the user can either input their email address or scan the generated qr code a timer screen in the web checkout ui is displayed after the user input, while a payment sheet is launched in the user's samsung wallet app the payment sheet contains the payment card option s and the transaction details when the user confirms their payment on their mobile device, you will receive the paymentcredential object generated by the device then, inform the samsung server of the payment result using the notify method the paymentresult object contains the payment result information during transaction processing and after the payment is processed with the pg network notefor real transactions, you need to extract the payment credential information from the 3ds data key within the paymentcredential object and process it through your payment provider however, in this code lab, you only need to print the paymentcredential to the console samsungpayclient loadpaymentsheet paymentmethods, transactiondetail then function paymentcredential { console log "paymentcredential ", paymentcredential ; const paymentresult = { status "charged", provider "test pg" }; samsungpayclient notify paymentresult ; } catch function error { console log "error ", error ; } ; other possible values of the status key are charged - payment was charged successfully canceled - payment was canceled by either the user, merchant, or the acquiring bank rejected - payment was rejected by the acquiring bank erred - an error occurred during the payment process test the samsung pay button after integrating the samsung pay web checkout service into your sample merchant site, follow the steps below to test the functionality of the integrated service open your sample merchant site in a new tab then, click the pay with samsung pay button in the web checkout ui, enter the email address of your samsung account to send a payment request to samsung pay tap the push notification sent to the samsung wallet app installed on your mobile device then, click accept when the payment sheet is loaded, tap on pin and enter your pin to proceed a verified message will display in both the samsung wallet app and web checkout ui to indicate that the payment was processed successfully you're done! congratulations! you have successfully achieved the goal of this code lab topic now, you can integrate the samsung pay web checkout service into your website by yourself if you're having trouble, you may check the complete code below codesandbox io/s/virtual-store-complete-dkhzfx to learn more about developing apps for samsung pay devices, visit developer samsung com/pay
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
Learn Code Lab
codelabintegrate in-app payment into merchant apps using samsung pay sdk objective learn how to integrate in-app payment with your merchant apps using samsung pay sdk partnership request to use the samsung pay sdk, 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 page, here in samsung developers notein accordance with the applicable samsung partner agreements, this code lab covers setup and use of the samsung pay sdk for purposes of integrating the samsung pay app with partner apps the use cases and corresponding code samples included are representative examples only and should not be construed as either recommended or required overview the samsung pay sdk is an application framework for integrating selected samsung pay features with android-based partner apps on samsung devices in-app payment, which allows customers to pay for products and services with samsung pay, is one of the operations supported alongside push provisioning and open favorite cards partner apps can leverage the samsung pay sdk to perform different operations ― push provisioning and open favorite cards for issuers; in-app payment for merchants key components include partner app app developed by merchant or issuer for making online or offline payments and provisioning payment cards through samsung pay samsung pay sdk sdk integrated into the partner app for direct communication with samsung pay samsung pay app pay app with which the samsung pay sdk communicates financial network comprises the payment gateways, acquirers, card associations, and issuers that participate in transaction processing under agreement with the merchant most common use case for in-app payment the merchant app allows the user to make payments with samsung pay upon user selection of the samsung pay option, the merchant app calls the apis included in the samsung pay sdk to initiate a transaction with the samsung pay app the samsung pay app responds with the tokenized payment information necessary to complete the transaction the merchant app forwards this payment information to the designated payment gateway pg , either directly through the merchant's web server or indirectly via the samsung-pg interface server for standard transaction processing for more detailed information, see the official samsung pay sdk programming guide set up your environment you will need the following samsung wallet or samsung pay app depending on the country a compatible mobile device with android marshmallow 6 0 or android api level 23 or later android os versions samsung pay sdk android studio latest version recommended java se development kit jdk 11 or later 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 sample code 1 90 mb integrate the samsung pay sdk with your app the following steps comprise the general process for integrating the samsung pay sdk with your app sign up for the samsung pay developers site by clicking sign up and register your samsung account or create it if you don't already have one , then sign in follow the on-screen instructions for adding your app and creating a new service to generate the service id you'll need to use in your project download the samsung pay sdk by going to resources > sdk download add the samsung pay sdk jar file samsungpay jar to your android project using android studio or file explorer develop your partner app with the required api calls and callbacks for samsung pay integration upload a release version of your app to the samsung pay developers site for approval upon samsung approval, publish your partner app to the google play store and samsung galaxy apps 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 using the provided test service id enforces your app to use the fixed properties below service id 0915499788d6493aa3a038 package name com test beta pay app version 1 0/ 1 or higher start your project after downloading the sample code containing the project files, in android studio click open to open existing project locate the downloaded android project sampleonlinepay from the directory and click ok add the samsungpaysdk_2 18 00_release jar file from the sdk's libs folder to your android project's libs folder go to gradle scripts > build gradle module sampleonlinepay app and enter the following to the dependencies block implementation files 'libs/samsungpaysdk_2 18 00_release jar' if the target sdk version is 30 android 11 or the r-os , you must include the following <queries> element in androidmanifest xml <queries> <package android name="com samsung android spay" /> </queries> configure the api level as of sdk version 1 4, enhanced version control management has been introduced to improve backward compatibility and handle api dependency from country and service type for example, if a partner integrates the latest sdk—for instance, api level 2 18—but continues to use apis based on level 1 4, the partner app remains compatible with samsung pay apps supporting api level 1 4 without upgrading the samsung pay app implement the following in application tag of androidmanifest xml <meta-data android name="spay_sdk_api_level" android value="2 17" /> // most recent sdk version is recommended to leverage the latest apis add an xml layout and modify the activity next, replace the xml layout in res > layout > activity_main xml this layout shows the sample item information such as image, name, and price <?xml version="1 0" encoding="utf-8"?> <layout xmlns tools="http //schemas android com/tools" xmlns app="http //schemas android com/apk/res-auto" xmlns android="http //schemas android com/apk/res/android"> <androidx constraintlayout widget constraintlayout android layout_width="match_parent" android layout_height="match_parent" tools context=" mainactivity"> <imageview android id="@+id/imageview" android layout_width="350dp" android layout_height="184dp" android layout_margintop="100dp" app layout_constraintend_toendof="parent" app layout_constraintstart_tostartof="parent" app layout_constrainttop_totopof="parent" android src="@drawable/galaxy_s23_ultra_image"/> <imageview android id="@+id/samsung_pay_button" android layout_width="wrap_content" android layout_height="75dp" app layout_constraintbottom_tobottomof="parent" app layout_constraintend_toendof="parent" app layout_constraintstart_tostartof="parent" android src="@drawable/pay_rectangular_full_screen_black" android visibility="invisible"/> <textview android id="@+id/textview" android layout_width="wrap_content" android layout_height="wrap_content" android layout_margintop="10dp" android text="galaxy s23 ultra" android textsize="16sp" android textstyle="bold" app layout_constraintend_toendof="parent" app layout_constraintstart_tostartof="parent" app layout_constrainttop_tobottomof="@+id/imageview" /> <textview android id="@+id/textview2" android layout_width="wrap_content" android layout_height="wrap_content" android layout_margintop="5dp" android text="$1,199 00" android textsize="14sp" app layout_constraintend_toendof="parent" app layout_constrainthorizontal_bias="0 517" app layout_constraintstart_tostartof="parent" app layout_constrainttop_tobottomof="@+id/textview" /> </androidx constraintlayout widget constraintlayout> </layout> since you added a data binding layout, you need to inflate the xml file differently go to java > com > test > beta > pay > mainactivity kt, and declare the databinding variable in the mainactivity class private lateinit var databinding activitymainbinding replace the standard setcontentview declaration with the data binding version inside the oncreate method databinding = databindingutil setcontentview this, r layout activity_main check samsung pay status in the mainactivity, create the samsungpay instance to determine if the device supports samsung pay and if the samsung pay button can be displayed as the user's payment option, check the samsung pay status samsungpay requires a valid partnerinfo from the merchant app, which consists of service id and service type during onboarding, the samsung pay developers site assigns the service id and service type in the mainactivity, declare the partnerinfo variable private lateinit var partnerinfo partnerinfo then, set the partnerinfo in the oncreate method val bundle = bundle bundle putstring spaysdk partner_service_type, spaysdk servicetype inapp_payment tostring partnerinfo = partnerinfo service_id, bundle after setting partnerinfo, call the getsamsungpaystatus method via updatesamsungpaybutton function inside the oncreate method updatesamsungpaybutton the getsamsungpaystatus method of the samsungpay class must be called before using any other feature in the samsung pay sdk write the updatesamsungpaybutton function as follows private fun updatesamsungpaybutton { val samsungpay = samsungpay this, partnerinfo samsungpay getsamsungpaystatus object statuslistener { override fun onsuccess status int, bundle bundle { when status { spaysdk spay_ready -> { databinding samsungpaybutton visibility = view visible // perform your operation } spaysdk spay_not_ready -> { // samsung pay is supported but not fully ready // if extra_error_reason is error_spay_app_need_to_update, // call gotoupdatepage // if extra_error_reason is error_spay_setup_not_completed, // call activatesamsungpay databinding samsungpaybutton visibility = view invisible } spaysdk spay_not_allowed_temporally -> { // if extra_error_reason is error_spay_connected_with_external_display, // guide user to disconnect it databinding samsungpaybutton visibility = view invisible } spaysdk spay_not_supported -> { databinding samsungpaybutton visibility = view invisible } else -> databinding samsungpaybutton visibility = view invisible } } override fun onfail errorcode int, bundle bundle { databinding samsungpaybutton visibility = view invisible toast maketext applicationcontext, "getsamsungpaystatus fail", toast length_short show } } } tipfor the list and detailed definition of status codes such as spay_ready, refer to checking samsung pay status noteas of sdk version 1 5, if the device has android lollipop 5 1 android api level 22 or earlier versions, the getsamsungpaystatus api method returns a spay_not supported status code merchant apps using sdk 1 4 or earlier must check their app's android version activate the samsung pay app the samsungpay class provides an api method called activatesamsungpay to activate the samsung pay app on the same device where the partner app is running if the getsamsungpaystatus returns spay_not_ready and the extra_error_reason is error_spay_setup_not_complete, the partner app needs to display an appropriate message to the user then, call activatesamsungpay to launch samsung pay app and request the user to sign in in updatesamsungpaybutton function, add the code to call activatesamsungpay method via doactivatesamsungpay function when the status is spay_not_ready // if extra_error_reason is error_spay_setup_not_completed, // call activatesamsungpay val extraerror = bundle getint samsungpay extra_error_reason if extraerror == samsungpay error_spay_setup_not_completed { doactivatesamsungpay spaysdk servicetype inapp_payment tostring } create the doactivatesamsungpay function as below private fun doactivatesamsungpay servicetype string { val bundle = bundle bundle putstring samsungpay partner_service_type, servicetype val partnerinfo = partnerinfo service_id, bundle val samsungpay = samsungpay this, partnerinfo samsungpay activatesamsungpay } create a transaction request upon successfully initializing the samsungpay class, the merchant app should create a transaction request with payment information samsung pay offers two types of online payment sheet―normal and custom the normal payment sheet has fixed display items ― items, tax, and shipping the custom payment sheet offers more dynamic controls for customizing the ui, together with additional customer order and payment data for this code lab, use the custom payment sheet and populate the fields in customsheetpaymentinfo to initiate a payment transaction /* * make user's transaction details * the merchant app should send paymentinfo to samsung pay via the applicable samsung pay sdk api method for the operation * being invoked * upon successful user authentication, samsung pay returns the "payment info" structure and the result string * the result string is forwarded to the pg for transaction completion and will vary based on the requirements of the pg used * the code example below illustrates how to populate payment information in each field of the paymentinfo class */ private fun maketransactiondetailswithsheet customsheetpaymentinfo? { val brandlist = brandlist val extrapaymentinfo = bundle val customsheet = customsheet customsheet addcontrol makeamountcontrol return customsheetpaymentinfo builder setmerchantid "123456" setmerchantname "sample merchant" setordernumber "amz007mar" // if you want to enter address, please refer to the javadoc // reference/com/samsung/android/sdk/samsungpay/v2/payment/sheet/addresscontrol html setaddressinpaymentsheet customsheetpaymentinfo addressinpaymentsheet do_not_show setallowedcardbrands brandlist setcardholdernameenabled true setrecurringenabled false setcustomsheet customsheet setextrapaymentinfo extrapaymentinfo build } private fun makeamountcontrol amountboxcontrol { val amountboxcontrol = amountboxcontrol amount_control_id, "usd" amountboxcontrol additem product_item_id, "item", 1199 00, "" amountboxcontrol additem product_tax_id, "tax", 5 0, "" amountboxcontrol additem product_shipping_id, "shipping", 1 0, "" amountboxcontrol setamounttotal 1205 00, amountconstants format_total_price_only return amountboxcontrol } private val brandlist arraylist<spaysdk brand> get { val brandlist = arraylist<spaysdk brand> brandlist add spaysdk brand visa brandlist add spaysdk brand mastercard brandlist add spaysdk brand americanexpress brandlist add spaysdk brand discover return brandlist } request 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 pay when you call the startinapppaywithcustomsheet method, a custom payment sheet is displayed on the merchant app screen from there, the user can select a registered card for payment and change the billing and shipping addresses as necessary the payment sheet lasts for 5 minutes after calling the api if the time limit expires, the transaction fails in the mainactivity class, declare the paymentmanager variable private lateinit var paymentmanager paymentmanager then, in oncreate , set an onclicklistener method before calling the updatesamsungpaybutton function to trigger the startinapppaywithcustomsheet function when the samsungpaybutton is clicked databinding samsungpaybutton setonclicklistener { startinapppaywithcustomsheet } lastly, create a function to call startinapppaywithcustomsheet method of the paymentmanager class /* * paymentmanager startinapppaywithcustomsheet is a method to request online in-app payment with samsung pay * partner app can use this method to make in-app purchase using samsung pay from their * application with custom payment sheet */ private fun startinapppaywithcustomsheet { paymentmanager = paymentmanager applicationcontext, partnerinfo paymentmanager startinapppaywithcustomsheet maketransactiondetailswithsheet , transactioninfolistener } /* * customsheettransactioninfolistener is for listening callback events of online 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 transactioninfolistener paymentmanager customsheettransactioninfolistener = object paymentmanager 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 pay * newly selected cardinfo is passed and partner app can update transaction amount based on new card if needed * call updatesheet method this is mandatory */ paymentmanager updatesheet customsheet } override fun onsuccess response customsheetpaymentinfo, paymentcredential string, extrapaymentdata bundle { /* * you will receive the payloads shown below in paymentcredential parameter * the output paymentcredential structure varies depending on the pg you're using and the integration model direct, indirect with samsung */ toast maketext applicationcontext, "onsuccess ", toast length_short show } // this callback is received when the online payment transaction has failed override fun onfailure errorcode int, errordata bundle? { toast maketext applicationcontext, "onfailure ", toast length_short show } } run the app after building the apk, you can run the sample merchant app and see how it connects to samsung pay upon clicking the button at the bottom of the screen to thoroughly test the sample app, you must add at least one card to the samsung pay app you're done! congratulations! you have successfully achieved the goal of this code lab now, you can integrate in-app payment with your app by yourself! if you face any trouble, you may download this file in-app payment complete code 2 26 mb to learn more about developing apps for samsung pay devices, visit developer samsung com/pay
Learn Code Lab
codelabcreate an android automotive operating system aaos app with payments via samsung checkout objective create a shopping app for android automotive os aaos , which uses templates from aaos and ignite store, and processes payments via the ignite payment sdk powered by samsung checkout partnership request to use the ignite payment sdk and have access to development tools and resources, such as ignite aaos emulators, you must become an official partner once done, you can fully utilize this code lab you can learn more about the partnership process by visiting the ignite store developer portal overview android automotive os android automotive os aaos is a base android platform that runs directly on the car and is deeply integrated with the underlying vehicle hardware unlike the android auto platform, users can download compatible apps with aaos directly into their cars, without needing a phone, and utilize an interface specifically designed for the car screen aaos can run both system and third-party android applications as aaos is not a fork and shares the same codebase as android for mobile devices, developers can easily adapt existing smartphone apps to function on aaos the diagram below illustrates the architecture of aaos at the hardware abstraction layer hal level, aaos incorporates additional components such as the vehicle hal vhal , exterior view system evs , and broadcast radio br to handle vehicle properties and connectivity at the framework level, car service and webview modules are included at the application level, the main system applications include car system ui, car launcher, and car input method editor ime additionally, car media and automotive host are incorporated as system apps third-party apps are classified into three categories audio media, car templated, and parked car templates the car templated apps use templates specified by the car app library, which are rendered by the automotive host, customized by original equipment manufacturers oem the library consists of approximately 10 templates list, grid, message, pane, navigation and is utilized in both android auto aa and android automotive os aaos apps to target aaos, you must incorporate an additional app-automotive library that injects the carappactivity into the app the carappactivity needs to be included in the manifest and can be set as distractionoptimized upon launching the application, the carappactivity provides a surface that is employed by the automotive host to render the template models additionally, on the harman ignite store, you can optionally integrate the ignite-car-app-lib, which adds supplementary templates such as explore, listdetails, routeoverview, and poistreaming harman ignite store the harman ignite store is a white-labeled and modular aaos-based automotive app store by connecting app developers with car manufacturers, harman creates unique in-vehicle experiences the ignite store has a rich app ecosystem with unique content, growth opportunities, and long-term partnerships it facilitates future-proof monetization with a payments api powered by samsung checkout after registering at the ignite store developer portal, developers can submit their apps for certification and testing by harman upon approval from the oem, the developer can proceed with publishing their app comprehensive developer documentation and tools are available to support app developers throughout the development process payments api the ignite store comes enabled with payment features empowering developers to monetize their apps developers are now able to offer their apps as paid apps the payment sdk exposes apis for goods and services, in-app purchases, and subscriptions developers can also integrate their own payment service providers psps , to sell goods or services, and receive the money directly in their bank account for a frictionless in-car payment experience, ignite provides a dedicated digital wallet app for end-users to securely store their credit card information the payment processor is powered by the industry proven samsung checkout the developer portal provides additional documentation to allow developers to access ignite aaos emulators, vim3, tablet or cuttlefish ignite images, and additional guidelines set up your environment you will need the following ignite aaos system image running on android emulator or on reference devices android studio latest version recommended java se development kit jdk 11 or later sample code here is a sample code for you to start coding in this code lab download it and start your learning experience! aaos ignite shopping app sample code 11 7 mb prepare your ignite aaos emulator add the ignite aaos emulator to your android studio by following the guide provided in the ignite store developer console open the device manager and start the emulator configure the emulator to use fake data for payments, as instructed in the ignite store developer console under the offline mode tab in the payment sdk section the sample app requires navigation from point a starting location to point b destination location the destination addresses are predefined and near san jose mcenery convention center to shorten the distance between two locations, follow the steps below to set the starting location a open the extended controls in the emulator panel b go to location, search for a location near the destination location, and click set location next, in the emulator, go to the ignite navigation app's settings and enable the following enable navigation simulation enable mock location provider go to settings > system > developer options > location and set ignite navigation as mock location app start your project after downloading the sample code containing the project files, open your android studio and click open to open an existing project locate the downloaded android project igniteautomotivepaymentssdc202488 from the directory and click ok check the ignite payment sdk dependency verify that the ignite payment sdk library is included in the dependencies section of the module's build gradle file dependencies { implementation files 'libs/ignite-payment-sdk-3 13 0 24030417-0-snapshot aar' } add payment permission next, go to the manifests folder and, in the androidmanifest xml file, include the payment_request permission to perform in-app purchases <uses-permission android name="com harman ignite permission payment_request" /> this ensures that the app has the necessary permissions to perform transactions and handle sensitive financial data show the payment screen when an item is added to the cart, the shopping cart screen displays the select store button, selected pickup store address, total amount to pay, and details of each item added the screen also includes the pay button go to kotlin + java > com harman ignite pickupstore > screens > shoppingcartscreen kt in the docheckout function, use the car app's screenmanager to navigate to the payment screen from the shopping cart screen after clicking the pay button getscreenmanager push paymentscreen carcontext, session notethe screenmanager class provides a screen stack you can use to push screens that can be popped automatically when the user selects a back button in the car screen or uses the hardware back button available in some cars instantiate the ignite payment client the ignite payment api provides a singleton class called ignitepaymentclientsingleton, which enables performing and tracking transactions navigate to the paymentscreen kt file and instantiate the ignite payment client private val mipc = ignitepaymentclientsingleton getinstance carcontext define the ignite payment transaction callback the ignite payment transaction provides three callback methods onsuccess, oncanceled, and onfailure after each callback, make sure to set the ispaymentfailed variable to track whether a payment is successful or not update the session which owns the shopping cart screen to reflect the status of the payment transaction call the updatetemplate function to invalidate the current template and create a new one with updated information private val mipctcb = object iignitepaymentclienttransactioncallback { override fun onsuccess requestuuid string?, sessionid string?, successmessage string?, paymentadditionalproperties hashmap<string, string>? { log d tag, log_prefix + "onsuccess rid $requestuuid, sid $sessionid, sm $successmessage" cartoast maketext carcontext, "payment successful", cartoast length_short show ispaymentfailed = false session paymentdone requestuuid, sessionid, successmessage updatetemplate } override fun oncanceled requestuuid string?, sessionid string? { log d tag, log_prefix + "oncanceled rid $requestuuid, sid $sessionid" cartoast maketext carcontext, "payment canceled", cartoast length_long show ispaymentfailed = true session paymenterror requestuuid, sessionid, null updatetemplate } override fun onfailure requestuuid string?, sessionid string?, wallererrorcode int, errormessage string { log d tag, log_prefix + "onfailure rid $requestuuid, sid $sessionid, wec $wallererrorcode, em $errormessage" cartoast maketext carcontext, "payment failed", cartoast length_long show ispaymentfailed = true session paymenterror requestuuid, sessionid, errormessage updatetemplate } } define the ignite payment client connection callback the ignite payment client needs to be connected in order to perform a payment request once the client connects successfully, retrieve the names of the shopping cart items and use them to create an order summary afterwards, construct an ignite payment request containing the total amount, currency code, merchant id, and details of the order summary then, initiate the payment process by invoking the readytopay function of the ignite payment client api private val mipccb = iignitepaymentclientconnectioncallback { connected -> log d tag, log_prefix + "onpaymentclientconnected $connected" if connected { val textsummary = session shoppingcart cartitems jointostring ", " { item -> item name } val ipr = ignitepaymentrequest builder setamount session shoppingcart gettotal * 100 setcurrencycode currencycode usd setpaymentoperation paymentoperation purchase setmerchantid constants merchant_id setordersummary ordersummary builder setordersummarybitmapimage bitmapfactory decoderesource carcontext resources, session shoppingcart store largeicon setordersummarylabel1 "${carcontext getstring r string pickupstore_app_title } ${session shoppingcart store title}" setordersummarysublabel1 session shoppingcart store address setordersummarylabel2 textsummary setordersummarysublabel2 carcontext getstring r string pickupstore_payment_sublabel2 build build try { mipc readytopay ipr, mipctcb } catch e exception { log d tag, log_prefix + "payment exception $e" e printstacktrace } catch e error { log d tag, log_prefix + "payment error $e" e printstacktrace } } } start the payment process and go back to previous screen after the transaction next, in the startpayment function, connect the ignite payment client and the connection callback to start the payment process mipc connect mipccb after the transaction is completed, the updatetemplate function refreshes the template used in the payment screen before calling the schedulegoback function modify the schedulegoback function to navigate back to the previous template screen shopping cart you can use the pop method of the screenmanager screenmanager pop start the navigation to the store to collect the paid pickup the shopping cart screen shows the pickup store location, details of the order, and go to store button after a successful payment go to kotlin + java > com harman ignite pickupstore > pickupstoresession kt modify the navigatetostore geofence geofence function to trigger the navigation to the pickup store when the go to store button is clicked you can use the intent carcontext action_navigate with geo schema rfc 5879 data, containing latitude and longitude e g , geo 12 345, 14 8767 to send the intent, use the carcontext startcarapp api call val geouristring = "geo ${geofence latitude},${geofence longitude}" val uri = uri parse geouristring val navintent = intent carcontext action_navigate, uri try { carcontext startcarapp navintent } catch e exception { log e tag, log_prefix + "navigatetostore exception starting navigation" e printstacktrace cartoast maketext carcontext, "failure starting navigation", cartoast length_short show } run the app on ignite aaos emulator run the pickup-store-app on ignite aaos emulator when the app starts for the first time, it requests for user permissions click grant permissions choose allow all the time for location permission and click the return button 4 browse the pickup store catalog and add items to shopping cart open the shopping cart and click pay you can also change the pickup store by clicking select store check the order summary and billing information then, click confirm and pay to process payment after a successful payment, the app returns to shopping cart screen with the updated transaction information click go to store to start the navigation to the store the app displays a notification when the car is near the store click the notification to show a reference qr code to present to the store upon pick up you're done! congratulations! you have successfully achieved the goal of this code lab topic now, you can create an aaos templated app, which supports payments by yourself! if you're having trouble, you may download this file aaos ignite shopping app complete code 11 7 mb learn more by going to the developer console section of the ignite store developer portal
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.