add boarding passes, tickets, and coupons objective learn how to integrate the add to wallet functionality with partner services, enabling users to add boarding passes, tickets, and coupons to samsung wallet. partnership request to create, manage, and monitor performance of wallet cards with the samsung wallet partners portal, 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 partner agreements, this code lab covers setup and use of the samsung wallet partners portal for purposes of integrating the add to wallet functionality with partner sites. the use cases and corresponding code samples included are representative examples only and should not be construed as either recommended or required. overview samsung wallet is the secure, go-everywhere app for your essentials — credit cards, boarding passes, tickets, coupons, and more. all in one spot, all accessible with one swipe. users can conveniently access the samsung wallet by swiping it up from the bottom of the screen. various wallet cards of partners can be added to the samsung wallet, allowing users to quickly and easily access partners' contents, such as: boarding passes: registered boarding passes can remind the user of boarding time and help during check-in. depending on the integration level, it can provide status information updates related to flights, such as boarding gate changes or cancellations. tickets: registered tickets can provide additional information about the event and an alarm before expiration. ticket cards support event commodities for performances, sports, movies, and entrance. coupons: registered coupons for various channels can provide alarms before expiration and update usage status. 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 detailed description, see manage wallet cards. set up your environment you will need the following: samsung wallet from galaxy store samsung galaxy device that supports samsung wallet samsung wallet partners portal account internet browser, such as chrome intellij idea community edition samsung public key, partner public key, and private key (see encryption setting) start your project open your internet browser and go to the following sample partner sites: boarding pass - https://codesandbox.io/s/sdc-boarding-pass-template-3c4o0c ticket - https://codesandbox.io/s/sdc-ticket-template-8lgph7 coupon - https://codesandbox.io/s/sdc-coupon-template-rrw0bt click fork on each project to copy and modify the code. once done, three projects are automatically copied to your codesandbox account. modify the index.html later for the add to wallet integration. notethe next steps require a samsung wallet partners portal account. if you wish to check and test the complete code of these sample partner sites, you can jump to you're done! section of this code lab. otherwise, you can proceed to learn the process of integrating add to wallet functionality. create wallet cards now, go to samsung wallet partners portal and sign in using your samsung partner account. on the left sidebar menu, click wallet cards > create wallet card and enter wallet card details for the boarding pass as below: in wallet card template, choose [wallet] boardingpass as card type and boarding pass > airline as a subcategory. select samsung wallet boarding pass > airline as the card template. then, click done. you can choose from various types of wallet card templates optimized for partners such as boarding pass, ticket, and coupon. once all the details are entered and the correct template is selected, click save to set the wallet card status to draft. 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. apply the add to wallet script the samsung wallet partners portal includes generated add to wallet scripts for every wallet card created. these scripts can be copied and inserted into partner apps (web and android) or via email/mms. go to [add to wallet script guide] of the card(s) you created. click show to see the scripts for web integration and copy the script under web button (js) code sample. notea statistical image beacon is added to the script for tracking effect analysis. below are generated add to wallet scripts of wallet cards created for this code lab: boarding pass:<script src="https://us-cdn-gpp.stg.mcsvc.samsung.com/lib/wallet-card.js" type="text/javascript"></script> <div id="target_id"></div> <script> samsungwallet.addbutton({ partnercode: "4030093436155138240", cardid: "3fre4kmmboq00", cdata: "${card data as jwt}", rdclickurl: "https://us-rd.mcsvc.samsung.com/statistics/click/addtowlt?ep=c50c3754feb24833b30c10b275bb6ab8;cc=gc;ii=1287098641030840334;co=4030093436155138240;cp=1288017491089625089;si=24;pg=101212967375212546;pi=aqz68ebxsx6mv9jsazxzaa;tp=4030093501522138240;li=0", rdimpressionurl: "https://us-rd.mcsvc.samsung.com/statistics/impression/addtowlt?ep=c50c3754feb24833b30c10b275bb6ab8;cc=gc;ii=1287098641030840334;co=4030093436155138240;cp=1288017491089625089;si=24;pg=101212967375212546;pi=aqz68ebxsx6mv9jsazxzaa;tp=4030093501522138240;li=0", targetid: "target_id", buttonid: "button_id", }); </script> ticket:<script src="https://us-cdn-gpp.stg.mcsvc.samsung.com/lib/wallet-card.js" type="text/javascript"></script> <div id="target_id"></div> <script> samsungwallet.addbutton({ partnercode: "4030093436155138240", cardid: "3fre4mp5mui00", cdata: "${card data as jwt}", rdclickurl: "https://us-rd.mcsvc.samsung.com/statistics/click/addtowlt?ep=c50c3754feb24833b30c10b275bb6ab8;cc=gc;ii=1287098641034510350;co=4030093436155138240;cp=1288017491089625089;si=24;pg=101212967375212546;pi=aqz68ebxsx6mv9jsazxzaa;tp=4030093588496138240;li=0", rdimpressionurl: "https://us-rd.mcsvc.samsung.com/statistics/impression/addtowlt?ep=c50c3754feb24833b30c10b275bb6ab8;cc=gc;ii=1287098641034510350;co=4030093436155138240;cp=1288017491089625089;si=24;pg=101212967375212546;pi=aqz68ebxsx6mv9jsazxzaa;tp=4030093588496138240;li=0", targetid: "target_id", buttonid: "button_id", }); </script> coupon:<script src="https://us-cdn-gpp.stg.mcsvc.samsung.com/lib/wallet-card.js" type="text/javascript"></script> <div id="target_id"></div> <script> samsungwallet.addbutton({ partnercode: "4030093436155138240", cardid: "3fre4p0otdv00", cdata: "${card data as jwt}", rdclickurl: "https://us-rd.mcsvc.samsung.com/statistics/click/addtowlt?ep=c50c3754feb24833b30c10b275bb6ab8;cc=gc;ii=1287098641019830286;co=4030093436155138240;cp=1288017491089625089;si=24;pg=101212967375212546;pi=aqz68ebxsx6mv9jsazxzaa;tp=4030093644822138240;li=0", rdimpressionurl: "https://us-rd.mcsvc.samsung.com/statistics/impression/addtowlt?ep=c50c3754feb24833b30c10b275bb6ab8;cc=gc;ii=1287098641019830286;co=4030093436155138240;cp=1288017491089625089;si=24;pg=101212967375212546;pi=aqz68ebxsx6mv9jsazxzaa;tp=4030093644822138240;li=0", targetid: "target_id", buttonid: "button_id", }); </script> paste the copied add to wallet script into the index.html file of the sample partner site. then, add the attributes below, to the samsungwallet.addbutton function. target: "wallet", showforced: true target sets the button’s name to samsung wallet ("wallet") or samsung pay ("pay"). by default, the value is "wallet". showforced is a flag to show or hide the button. by default, the button is hidden. otherwise, set the flag value to true. noteincluding the javascript library in the head tag and adding the rest of the script to the body tag is recommended. yet, it works if you paste it as is. generate and input the cdata the add to wallet script does not automatically include the cdata (encrypted card data) as it requires encryption for security purposes. cdata is the actual content data of wallet card and it has several formats based on card type. you can use the sample cdata generator created to serve the purpose of this code lab only. download the cdata generation sample code. locate and open the downloaded file in intellij idea. in the project folder, go to src > main > java > jwtgenerator.java. input your partner id as partner_code string value. public class jwtgenerator { private static final string partner_code = "insert_your_partner_id"; //same with partnercode of add to wallet script next, go to resources > sample > certificate and replace the pem files with samsung public key, your public key, and private key (see encryption setting). build the project. right-click on jwtgenerator class and click run 'jwtgenerator.main()' to create the cdata. different cdata must be created for each of the sample partner sites of this code lab. notethe generated cdata won't expire and can only be used for code lab testing. cdata must expire 30 seconds after creation for security purposes in actual application. lastly, go back to the index.html of the partner site and paste the generated cdata to the cdata attribute value of the addbutton sub-item. test the add to wallet button you can test the add to wallet button functionality integrated to the sample partner sites, directly on a mobile device with the samsung wallet app. access the url provided by codesandbox on samsung internet or any browser. click the samsung wallet button in each app to add the boarding pass, ticket, and coupon cards to the samsung wallet. tipthe add to wallet button only works for mobile devices with samsung wallet or samsung pay app, so it is recommended to handle exceptions like this. also, you can add a qr code feature for your site. users can scan the qr code using a compatible mobile device when the site is accessed via desktop or laptop. noteyou can see and monitor wallet card statistics by going to the portal's dashboard > wallet card statistics. you're done! congratulations! you have successfully achieved the goal of this code lab topic. now, you can integrate the add to wallet with your website by yourself! if you're having trouble, you may check the complete code below: boarding pass - https://codesandbox.io/s/sdc-boarding-pass-complete-67kvwh ticket - https://codesandbox.io/s/sdc-ticket-complete-pb720c coupon - https://codesandbox.io/s/sdc-coupon-complete-3n0ugf to learn more about samsung wallet, visit: developer.samsung.com/wallet