Filter
-
Content Type
-
Category
Mobile/Wearable
Visual Display
Digital Appliance
Platform
Recommendations
Filter
Develop Samsung Blockchain
dockey management in this section, we will cover general terms – public key, private key, and an address, and how samsung blockchain keystore generates and manages these keys. samsung blockchain keystore is a hierarchical deterministic (hd) wallet and follow the industry standards of bip-32, bip-39 and bip-44. (bip stands for bitcoin improvement proposal). by implementing these standards, samsung blockchain keystore aim to provide better user experience to back up the wallet, since the user only needs to keep the root seed of the private and public keys safe. it is just the 12 words generated from samsung blockchain keystore that user needs to remember or write down. we will look into how this is achieved by implementing hierarchical deterministic wallet in samsung blockchain keystore. public key, private key, and address the key pair is mandatory to participate in the blockchain network. this key pair is composed of a public key and a private key. public key is used to derive an address that is used like a user’s account in blockchain. it is safe to share the public key or the address with others. on the other hand, a private key is used to sign transactions and must be kept secret. anyone who has access to the private key can sign transactions and spend cryptocurrency or use crypto-assets without user’s permission. simply put, the private key is a random number. based on the private key, there are algorithms, like elliptic curve digital signature algorithm (ecdsa) that derives the public key. this algorithm may differ depending on the blockchain platform. but one interesting characteristic of a public key is that it is derived from a private key, but the other way around is not possible – public key cannot derive nor predict the private key. the same relationship applies to the public key and the address. address, which is used like a user’s account, cannot derive any public keys. since a private key is a random number, this implies that the randomness of a private key generation must be guaranteed. yet, software random number generators, also known as pseudo random number generators, are known to have security vulnerabilities. because the public key and address format differs by blockchain platforms, user needs to have one key pair for ethereum, another key pair for bitcoin, and etc. if a user wants several accounts for ethereum, then that many number of key pairs will be required. moreover, bitcoin uses countless number of accounts, because after a transaction has been made, any bitcoin changes after the transaction is returned to a different account of the user’s. in other words, it becomes very complex and inconvenient if a user would have to save a key pair for every blockchain account that the user holds. samsung blockchain keystore aims to reduce this by implementing hierarchical deterministic wallet. hierarchical deterministic wallet (hd wallet) hierarchical deterministic wallet allows these multiple key pairs to be derived from a single root seed called, “root seed.” root seed is the root of a large tree of public and private keys. this root seed is the only thing that user needs to store and back up. this is the key to access all of your crypto secrets, so how it is generated and stored should be kept in a secure environment. root seed is between 128 and 256 bits and because the physical look of root seed is not very user friendly, and is a combination of “0” and “1”, there is an industry standard, to replace them with mnemonic words, or a group of words. for example, if the root seed is 128 bits, then with the checksum of 4 bits, a total of 132 bits is split into a group of 11 bits. each group falls into a group number between 0 and 2047, which is an index to a wordlist of 2048 words. these index numbers are then converted into the corresponding words and the combination of 12 words make up “recovery phrase” in samsung blockchain keystore. generating root seed and mnemonic words in samsung blockchain keystore samsung blockchain keystore generates the root seed by trusted app in trusted execution environment, by the steps below: ① true random number generator (trng), also known as hardware random number generator, that is embedded into samsung device chipsets, generates an initial entropy length (ent) of 128 random bits. elaborating more on ent, industry standard allows 128 to 256 bits, in multiple of 32 bits. depending on the length of the initial entropy length, the number of words that this will be converted into will differ, from 12 to 24, in multiple of 3. ② samsung blockchain keystore takes the first 4 bits of the sha-256 hash of the 128 bits to generate something called, “checksum.” theoretically, it is ent/32 that is taken to generate the checksum. so for samsung blockchain keystore, ent is 128 bits, resulting in 4 bits of checksum. for other wallets that generate 24 words with the ent of 256 bits, 8 bits are used as a checksum. ③ samsung blockchain keystore appends the previously generated 4 bits of checksum to the initial entropy length, resulting in 132 bits. ④ 132 bits (combination of initial entropy length and checksum) are divided into 11 bits, resulting in 12 words, “mnemonic codes”. these 12 words are industry standard, and is one of the 2048 words on the bip-39 english wordlist. ⑤ because the 12 words follow bip-39 standard used in the industry, user can back up wallet on a different samsung device that supports samsung blockchain keystore, or other wallets that are bip-39-compatible. importing a wallet when a user imports a wallet in samsung blockchain keystore, the user will enter the 12, 18 or 24 words into the trusted user interface (tui) that will protect user’s input. this time, samsung blockchain keystore will convert the mnemonic words entered in order to the original root seed. the root seed is the one and only source that samsung blockchain keystore will save in a secure area. likewise, this will become the source to generate countless number of public keys and sign transactions with the private keys when a request is made. randomly entering mnemonic words to guess recovery phrase some may raise a question on the feasibility of guessing the words among 2048 words on the mnemonic words list and somehow, getting access to the private key that corresponds to the recovery phrase. but it’s not just the words of 12 to 24 in multiple of 3, that have to correctly chosen, but the order of these words have to be correct as well. this is because if you are using 12 words, then 128 bits must be correctly guessed, and 266 bits for 24 words. choice between 0 and 1 on 128 bits give us 2 x 2 x 2 x … 2 = 2128 of the possible root seeds, and 2^256 cases for 24 words. moreover, the checksum of 4 bits for 12 words, and 8 bits for 24 words, protects randomly making a combination of words. when importing a wallet in samsung blockchain keystore, there is a checksum check after user has entered 12, 18 or 24 words, and it will throw an error that the combination of words entered isn’t a valid recovery phrase. the user will receive absolutely no information on which words make the checksum invalid, making it even more difficult to randomly guess the recovery phrase. hd path the hd wallet is a tree of theoretically infinite number of private and public keys. one interesting fact is that it allows derivation of a child keys from the root seed via a function defined in bip-32 standard, “child key derivation (ckd) functions.” this means with the root seed and the location of the tree, key derivation is feasible. more details on the key derivations can be found in the appendix. the location in the tree is called a “path” and bip-44 standard defines the standard to unify rules for wallet’s compatibility of these hd key generation. hence developers just need to specify the path to derive the address from, and whoever keeps the root seed will be able to calculate and return the actual key value for that specified location. each depth is represented by “/” in the hd path and the apostrophe (‘) implies that the depth is hardened. the following is hd path level standard defined in bip-44. ![](/sd2_images/services/blockchain/hd_path _level_standard.png) purpose’ is “44” here, with the implication that it is the following bip-44 standard. coin_type’ tells if it is ethereum, bitcoin, or other coins. the algorithms to derive the public key from the private key can differ by the coin type, though both ethereum and bitcoin use ecdsa algorithm. the number is constant and set for each crypto, and it can be registered in slip-0044 (slip: satoshilabs improvement proposals), managed by satoshilabs. for example, it is “0” for bitcoin, and “60” for ethereum. account‘ represents multiple accounts number and is usually ‘0’. change is usually used in bitcoin, using “1” for the account to receive all the changes after sending bitcoins to other accounts. normally, “0” is used. address_index is the last depth, and usually starts with 0, and increases by one, when you “add” an account in a wallet. for example, hd path for the first account of ethereum is: m/44’/60’/0’/0/0 and for the second account of bitcoin is: m/44’/0’ /0’/0/1 use of hd path in samsung blockchain keystore samsung blockchain keystore can be used to (1) derive an address or extended public key and (2) sign a transaction. to consume these two features, developers of dapps or wallets will need to define, where in the hd tree, they would like to derive the public key from, and use the corresponding private key to sign the transaction. hd path is a required parameter for apis related to the two features below. get address from samsung blockchain keystore if you are a dapp or wallet developer, you can use samsung blockchain keystore to first get the user’s address or extended public key (public key and the chain code), and search on the blockchain ledger, transaction history and records of the user, so that user can know how much cryptocurrency or crypto-asset is remaining. here’s a brief flow of getting the address. ① wallet or dapps will make a request to samsung blockchain keystore to derive an address or extended public key for hd path “m/44’/60’/ 0’/0/0” (ethereum account). ② using samsung blockchain keystore sdk, wallet/dapp’s request will be passed to samsung blockchain keystore. ③ once samsung blockchain keystore will receives the request to get the address or extended public key, it will pass onto the controller to communicate with trusted app to derive the public key. ④ root seed is stored safely in a secure area, and the derivation of the extended public key (public key and the chain code) of the hd path, is executed by trusted application in trusted execution environment. ⑤ derived public key will be then passed to samsung blockchain keystore app to derive the address, where one more algorithm function will be executed. ⑥ after the calculation, the address that corresponds to the requested hd path will be returned to wallet or dapp via samsung blockchain keystore sdk. sign a transaction by samsung blockchain keystore the user will now want to make a transaction, such as sending cryptocurrencies, that will require the user to “write” on the ledger. this change needs to be signed by the private key that corresponds to the user’s address, derived from user’s public key. below is a diagram and explanation for each step. ① wallet or dapps will make a request to samsung blockchain keystore to sign a transaction. a correctly formatted transaction without the signature part, and hd path to derive the private key to sign the transaction will be needed. ② using samsung blockchain keystore sdk, wallet/dapp’s request will be passed to samsung blockchain keystore. ③ once samsung blockchain keystore will receives the request to get the public key, it will pass onto the controller to communicate with trusted app. ④ trusted app will first parse the transaction, and show critical information on tui, such as recipient address, amount and fees. after user checks the transaction details, user will confirm it via pin verification or fingerprint authentication. ⑤ after the user’s confirmation, the safely stored root seed will now be used to derive the private key that corresponds to the hd path that was passed with the transaction request. then the trusted application will sign the transaction with the derived private key. likewise, these are all executed in trusted execution environment. ⑥ the signed transaction will be returned to samsung blockchain keystore app. ⑦ samsung blockchain keystore app will return the signed transaction to wallet/dapp via samsung blockchain keystore sdk and wallet/dapps can now submit the signed transaction to the blockchain network. more details on the bip-32, bip-39 and bip-44 can be found in the following links. **bip-32:** hierarchical deterministic wallets [https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) bip-39: mnemonic code for generating deterministic keys https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki#wordlists bip-44: multi-account hierarchy for deterministic wallets https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki slip-44: registered coin types for bip-0044 https://github.com/satoshilabs/slips/blob/master/slip-0044.md
events iot, health, game, design, mobile, galaxy watch, foldable
blogthe samsung developer conference 2023 (sdc23) happened on october 5, 2023, at moscone north in san francisco and online. among the many exciting activities at the conference for developers and tech enthusiasts, code lab offered a unique opportunity to learn about the latest samsung sdks and tools. code lab is a hands-on learning experience, providing participants with a platform to explore the diverse world of samsung development. code lab activities are accessible for developers of all skill levels and interests, ensuring that everyone, from beginners to experts, can find something exciting to explore. covering a wide array of topics within the code lab, the conference catered to the diverse interests of the participants. here's a quick look at some of the sdc23 topics: 1. smartthings participants had the chance to build a matter iot app using the smartthings home api and create virtual devices that they could control using the smartthings app or their own iot apps. they also learned how to develop a smartthings find-compatible device. these topics are all about connecting and enhancing the smart home experience. 2. galaxy z participants, who are interested in foldable technology, were able to develop a widget for the flex window. this topic opens new possibilities in app design and user interaction. 3. samsung wallet participants learned to integrate the "add to samsung wallet" button into sample partner services. they also learned to implement in-app payment into a sample merchant app using the samsung pay sdk. these topics focus on enhancing the mobile wallet experience for samsung users. 4. gamedev game developers and enthusiasts had the opportunity to optimize game performance with adaptive performance in unity. they also learned to implement flex mode into unity games for foldable phones. these topics offer insights into the gaming industry's latest trends and technologies. 5. watch face studio code lab also provided an activity for participants to create a watch face design with customized styles using watch face studio. participants also learned how to convert the watch face design for galaxy z flip5's flex window display using the good lock plugin. 6. samsung health the health-focused code lab topics covered measuring skin temperature on galaxy watch and transferring heart rate data from galaxy watch to a mobile device with the samsung privileged health sdk. participants also learned how to create health research apps using the samsung health stack. these topics provide valuable insights into the health and fitness tech landscape. from creating virtual devices to building health-related apps, participants left the conference with new knowledge they could apply to their development projects. the samsung developer conference is a celebration of innovation and collaboration in the tech world. with a diverse range of topics in code lab, participants were equipped with the tools and knowledge to push the boundaries of what is possible in samsung's ecosystem. though sdc23 has ended, the innovation lives on! whether you missed the event or just want to try other activities, you can visit the code lab page anytime, anywhere. we can't wait to see you and the innovations that will emerge from this conference in the coming years. see you at sdc24!
Christopher Marquez
Develop Samsung Pay
docflutter plugin overview samsung pay sdk flutter plugin enables to use the samsung pay sdk the primary aim of the samsung pay sdk is to integrate selected samsung wallet features with flutter based android apps on samsung devices the following major operations are supported in the plugin in-app payment gives customers the option of paying for products and services with samsung wallet push provisioning allows customers add a bank card to samsung wallet from the issuer app by providing the required card details to integrate partner applications with the samsung pay sdk flutter plugin, the following components are included in the download samsung pay sdk flutter plugin contains classes, interfaces, and required libraries of samsung pay which is required to communicate with samsung pay services api reference provides descriptions of the apis included in the samsung pay sdk flutter plugin sample merchant app and sample issuer app showing how samsung pay apis can be coded in a finished flutter plugin project all major operations of the samsung pay sdk flutter plugin are implemented for demonstration purposes samsung pay sdk flutter plugin architecture the following diagram shows a high-level architecture revealing the general interactions between the samsung pay sdk flutter plugin and a partner app viewed at this level, the partner apps leverage the samsung pay sdk flutter plugin to perform the operations shown ― push provisioning and opening favorite cards for issuers; online payments for merchants ― with samsung pay the key components involved are partner app - merchant- or issuer-developed app for making online/offline payments and provisioning payment cards through samsung pay samsung pay sdk flutter plugin - sdk integrated into the partner app for direct communication with samsung pay samsung pay app - pay app that the samsung pay sdk communicates with financial network - comprises the payment gateways, acquirers, card associations, and issuers that participate in transaction processing under agreement with the merchant setting up flutter plugin environment the importance of maintaining a good development environment cannot be overstated for integrating the samsung pay sdk flutter plugin with your partner app, the following prerequisites and recommendations help ensure a successful plugin integration and implementation please check the requirements below for the samsung pay sdk flutter plugin for android and system requirements please check the samsung pay android sdk overview to develop a samsung pay sdk flutter plugin service, merchants and issuers need to create service please check this guide for service creation process service registration download the samsung pay sdk flutter plugin to use the plugin the plugin has the following directory structure folder contents docs api reference documentation libs samsungpaysdkflutter_v1 01 00 flutter plugin – contains the samsung pay apis to be used by your partner app samples sample apps integrate samsung pay sdk flutter plugin with your project be sure to do the following before attempting to use the plugin if not already part of your environment, download and install an ide android studio is recommended download the samsung pay sdk flutter plugin configure your ide to integrate the samsung pay sdk flutter plugin with your partner app go to pubspec yaml and enter the following dependency dependencies samsung_pay_sdk_flutter path plugin_directory_path\ [note] if your plugin path is c \users\username\downloads, the dependency will be like below dependencies samsung_pay_sdk_flutter path c \users\username\downloads\ for android proguard rules and dexguard, please check the android sdk overview
Develop Samsung Blockchain
apipackage class tree deprecated index help com.samsung.android.sdk.coldwallet class scwservice java.lang.object com.samsung.android.sdk.coldwallet.scwservice public class scwservice extends java.lang.object class for the proxy to use the samsung blockchain keystore service. the keystore's hd wallet seed is bip-39 compatible see also: https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki nested class summary nested classes modifier and type class and description static class scwservice.scwcheckformandatoryappupdatecallback callback for checkformandatoryappupdate api static class scwservice.scwgetaddresslistcallback callback for getaddresslist api static class scwservice.scwgetextendedpublickeylistcallback callback for getextendedpublickeylist api static class scwservice.scwsignbtctransactioncallback callback for signbtctransaction api static class scwservice.scwsignethpersonalmessagecallback callback for signethpersonalmessage api static class scwservice.scwsignethtransactioncallback callback for signethtransaction api static class scwservice.scwsignklaytransactioncallback callback for signklaytransaction api method summary all methods static methods instance methods concrete methods modifier and type method and description void checkformandatoryappupdate(scwservice.scwcheckformandatoryappupdatecallback callback) checks whether a mandatory update of samsung blockchain keystore is needed or not. void getaddresslist(scwservice.scwgetaddresslistcallback callback, java.util.arraylist<java.lang.string> hdpath) request to get a list of addresses that corresponds to a list of hd paths void getextendedpublickeylist(scwservice.scwgetextendedpublickeylistcallback callback, java.util.arraylist<java.lang.string> hdpath) request to get a list of extended public keys that corresponds to a list of hd paths static scwservice getinstance() return the instance of the keystore proxy object int getkeystoreapilevel() get api level which the keystore in the device supports java.lang.string getseedhash() get the pseudo seed hash which is randomly generated when the hd wallet created whenever the seed for the wallet is changed, this key shall be changed. int[] getsupportedcoins() get coin types supported by samsung blockchain keystore void signbtctransaction(scwservice.scwsignbtctransactioncallback callback, byte[] transaction, java.util.list<java.lang.string> hdpathlist, java.util.list<byte[]> utxotxlist, java.lang.string changehdpath) request to sign bitcoin transaction void signethpersonalmessage(scwservice.scwsignethpersonalmessagecallback callback, byte[] msg, java.lang.string hdpath) request to sign ethereum typed structured data void signethtransaction(scwservice.scwsignethtransactioncallback callback, byte[] transaction, java.lang.string hdpath) request to sign ethereum transaction void signklaytransaction(scwservice.scwsignklaytransactioncallback callback, byte[] transaction, java.lang.string hdpath, int networkid) request to sign klay transaction methods inherited from class java.lang.object equals, getclass, hashcode, notify, notifyall, tostring, wait, wait, wait method detail getinstance public static scwservice getinstance() return the instance of the keystore proxy object returns: the instance, or null if samsung blockchain keystore is not available on the device getkeystoreapilevel public int getkeystoreapilevel() get api level which the keystore in the device supports caution : you should check the api level before invoking any apis. otherwise, it will return scwapilevelexception. if keystore api level is lower than the required level, update the keystore app first via scwdeeplink.galaxy_store returns: api level since: api level 1 getseedhash public java.lang.string getseedhash() get the pseudo seed hash which is randomly generated when the hd wallet created whenever the seed for the wallet is changed, this key shall be changed. returns: null if keystore does not support wallet key, zero-length string if the wallet is not created. otherwise, wallet is created. since: api level 1 getsupportedcoins public int[] getsupportedcoins() get coin types supported by samsung blockchain keystore returns: array of coin types, scwcointype throws: scwapilevelexception - api level exception since: api level 1 see also: https://github.com/satoshilabs/slips/blob/master/slip-0044.md checkformandatoryappupdate public void checkformandatoryappupdate(@nonnull scwservice.scwcheckformandatoryappupdatecallback callback) checks whether a mandatory update of samsung blockchain keystore is needed or not. do not call this method in the background thread. if there is a mandatory update, you need to open the app update link, scwdeeplink.galaxy_store parameters: callback - result callback since: api level 1 getextendedpublickeylist public void getextendedpublickeylist(@nonnull scwservice.scwgetextendedpublickeylistcallback callback, @nonnull java.util.arraylist<java.lang.string> hdpath) request to get a list of extended public keys that corresponds to a list of hd paths parameters: callback - result callback hdpath - the hd path list to bring the public keys. the depth of a path should be between 3 and 6. for example, "m/44'/60'", "m/44'/60'/0'/0/0" since: api level 1 see also: https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki getaddresslist public void getaddresslist(@nonnull scwservice.scwgetaddresslistcallback callback, @nonnull java.util.arraylist<java.lang.string> hdpath) request to get a list of addresses that corresponds to a list of hd paths parameters: callback - result callback hdpath - the hd path list to bring the addresses. the depth of a path should be between 3 and 6. for example, "m/44'/60'", "m/44'/60'/0'/0/0" since: api level 1 see also: https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki signethtransaction public void signethtransaction(@nonnull scwservice.scwsignethtransactioncallback callback, @nonnull byte[] transaction, @nonnull java.lang.string hdpath) request to sign ethereum transaction parameters: callback - result callback transaction - a byte array of a rlp-encoded unsigned ethereum transaction hdpath - hd path that corresponds to public key needed for signing since: api level 1 signethpersonalmessage public void signethpersonalmessage(@nonnull scwservice.scwsignethpersonalmessagecallback callback, @nonnull byte[] msg, @nonnull java.lang.string hdpath) request to sign ethereum typed structured data parameters: callback - result callback msg - a byte array of raw message to be signed. the keystore will add "ethereum signed message:\n" prefix, so it should not be included in msg. hdpath - hd path that corresponds to public key needed for signing since: api level 1 see also: https://github.com/ethereum/eips/blob/master/eips/eip-712.md signklaytransaction public void signklaytransaction(@nonnull scwservice.scwsignklaytransactioncallback callback, @nonnull byte[] transaction, @nonnull java.lang.string hdpath, @nonnull int networkid) request to sign klay transaction parameters: callback - result callback transaction - a byte array of a raw transaction to be signed by samsung blockchain keystore. the transaction is same as the sigrlp value mentioned in klaytn's official document. hdpath - hd path that corresponds to public key needed for signing networkid - the klaytn network id, or the integer to identify the network. "8217" is klaytn cypress mainnet and "1001" is klaytn baobab testnet. since: api level 2 see also: https://docs.klaytn.com/node/en/installation/config signbtctransaction public void signbtctransaction(@nonnull scwservice.scwsignbtctransactioncallback callback, @nonnull byte[] transaction, @nonnull java.util.list<java.lang.string> hdpathlist, @nonnull java.util.list<byte[]> utxotxlist, @nonnull java.lang.string changehdpath) request to sign bitcoin transaction parameters: callback - result callback transaction - a byte array of a serialized unsigned bitcoin transaction to be signed by samsung blockchain keystore hdpathlist - a list of hd paths that corresponds to utxo's public key utxotxlist - a list of byte array of the serialized transaction which contain the utxo used in this transaction changehdpath - hd path that corresponds to the change address since: api level 2 see also: https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki, https://github.com/bitcoin/bips/blob/master/bip-0049.mediawiki, https://github.com/bitcoin/bips/blob/master/bip-0084.mediawiki
Develop Samsung Pay
apioverview package class tree index help package com samsung android sdk samsungpay v2 class samsungpay java lang object samsungpaybase com samsung android sdk samsungpay v2 samsungpay public final class samsungpay extends samsungpaybase this class provides apis to get the samsung pay status on the device also, this class provides apis to activate samsung pay on the device partner apps must check the samsung pay status on the device before performing any card management or payment operation since api level 1 1 constructor summary constructors constructor description samsungpay android content context context, partnerinfo partnerinfo constructor to get the samsungpay instance the caller should set the valid serviceid in partnerinfo method summary all methodsinstance methodsconcrete methods modifier and type method description void activatesamsungpay api to bring the samsung pay app to a state in which cards can be added samsung pay might be either in stub only state or samsung account is not signed in state partner app checks the samsung pay status with getsamsungpaystatus statuslistener api if the status is #spay_not_ready and #extra_error_reason is #error_spay_setup_not_completed, partner app can call this api to launch samsung pay and user can sign in to the app void getsamsungpaystatus statuslistener listener api to get the samsung pay status on the device partner issuers, merchants, and so on applications must call this api to check the current state of samsung pay before doing any operation void getwalletinfo list<string> keys, statuslistener listener api to get the requested wallet information from samsung pay partner app can use this information to uniquely identify the user and samsung pay app on a particular device void gotoupdatepage api to go to samsung pay update page partner app checks the samsung pay status with getsamsungpaystatus statuslistener api if the status is #spay_not_ready and #extra_error_reason is #error_spay_app_need_to_update, partner app can call this api to go to update samsung pay app if samsung pay app version is same or bigger than 2 1 00, it goes to "about samsungpay" menu if samsung pay app version is lower than 2 1 00 or kr device, it launches samsung pay app main screen methods inherited from class java lang object equals, getclass, hashcode, notify, notifyall, tostring, wait, wait, wait constructor details samsungpay public samsungpay android content context context, partnerinfo partnerinfo constructor to get the samsungpay instance the caller should set the valid serviceid in partnerinfo partnerinfo is passed to samsung pay for partner verification context ct = activity; // or context ct = service; // set the serviceid which is assigned by the samsung pay developer during on boarding string serviceid = "sampleserviceid"; bundle bundle = new bundle ; bundle putstring samsungpay partner_service_type, samsungpay servicetype inapp_payment tostring ; partnerinfo pinfo = new partnerinfo serviceid, bundle ; samsungpay samsungpay = new samsungpay ct, pinfo ; parameters context - activity context or service context partnerinfo - partner information throws nullpointerexception - thrown if parameters are null since api level 1 1 method details getsamsungpaystatus public void getsamsungpaystatus statuslistener listener api to get the samsung pay status on the device partner issuers, merchants, and so on applications must call this api to check the current state of samsung pay before doing any operation // set the serviceid which is assigned by the samsung pay developer during on boarding string serviceid = "sampleserviceid"; bundle bundle = new bundle ; bundle putstring samsungpay partner_service_type, samsungpay servicetype inapp_payment tostring ; partnerinfo pinfo = new partnerinfo serviceid, bundle ; samsungpay samsungpay = new samsungpay context, pinfo ; samsungpay getsamsungpaystatus new statuslistener { @override public void onsuccess int status, bundle data { // success case if status == spay_ready { log d tag, "samsung pay is ready on the device" ; // perform your operation } else if status == 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 } else if status == spay_not_allowed_temporally { log d tag, "samsung pay is not allowed temporally" ; // if extra_error_reason is error_spay_connected_with_external_display, // guide user to disconnect it } else { // samsung pay is not supported on this device log d tag, "device does not support samsung pay" ; } } @override public void onfail int errorcode, bundle errordata { log e tag, "onfail callback is called, errorcode " + errorcode ; // to get more reason of the failure, // check some extra error codes in the errordata bundle such as samsungpay extra_error_reason if provided } } ; parameters listener - callback through which the result is provided on success, samsung pay status code is provided via statuslistener onsuccess int status, bundle data if samsung pay is ready to be used, samsungpay#spay_ready will be returned otherwise, samsungpay#spay_not_ready or samsungpay#spay_not_supported or samsungpay#spay_not_allowed_temporally can be returned with samsungpay#extra_error_reason from bundle also, partner can get extra information from bundle data bundle keys if provided bundle values #extra_country_code device country code iso 3166-1 alpha-2 #extra_member_id string memberid for korean issuers only on any failure, the failure code is provided via statuslistener onfail int errorcode, bundle errordata note please refer spaysdk common_status_table in detail throws nullpointerexception - thrown if the callback passed is null since api level 1 1 gotoupdatepage public void gotoupdatepage api to go to samsung pay update page partner app checks the samsung pay status with getsamsungpaystatus statuslistener api if the status is #spay_not_ready and #extra_error_reason is #error_spay_app_need_to_update, partner app can call this api to go to update samsung pay app if samsung pay app version is same or bigger than 2 1 00, it goes to "about samsungpay" menu if samsung pay app version is lower than 2 1 00 or kr device, it launches samsung pay app main screen // set the serviceid which is assigned by the samsung pay developer during on boarding string serviceid = "sampleserviceid"; bundle bundle = new bundle ; bundle putstring samsungpay partner_service_type, samsungpay servicetype inapp_payment tostring ; partnerinfo pinfo = new partnerinfo serviceid, bundle ; samsungpay samsungpay = new samsungpay context, pinfo ; samsungpay gotoupdatepage ; since api level 1 2 activatesamsungpay public void activatesamsungpay api to bring the samsung pay app to a state in which cards can be added samsung pay might be either in stub only state or samsung account is not signed in state partner app checks the samsung pay status with getsamsungpaystatus statuslistener api if the status is #spay_not_ready and #extra_error_reason is #error_spay_setup_not_completed, partner app can call this api to launch samsung pay and user can sign in to the app // set the serviceid which is assigned by the samsung pay developer during on boarding string serviceid = "sampleserviceid"; bundle bundle = new bundle ; bundle putstring samsungpay partner_service_type, samsungpay servicetype inapp_payment tostring ; partnerinfo pinfo = new partnerinfo serviceid, bundle ; samsungpay samsungpay = new samsungpay context, pinfo ; samsungpay activatesamsungpay ; since api level 1 1 getwalletinfo public void getwalletinfo list<string> keys, statuslistener listener api to get the requested wallet information from samsung pay partner app can use this information to uniquely identify the user and samsung pay app on a particular device // set the serviceid which is assigned by the samsung pay developer during on boarding string serviceid = "sampleserviceid"; bundle bundle = new bundle ; bundle putstring samsungpay extra_issuer_name, "issuer name" ; bundle putstring samsungpay partner_service_type, samsungpay servicetype app2app tostring ; partnerinfo pinfo = new partnerinfo serviceid, bundle ; samsungpay samsungpay = new samsungpay context, pinfo ; // bundle keys added to get wallet information from samsung pay // this information can be delivered to the partner server for eligibility check arraylist<string> keys = new arraylist<> ; keys add samsungpay wallet_user_id ; keys add samsungpay device_id ; samsungpay getwalletinfo keys, new statuslistener { @override public void onsuccess int status, bundle walletdata { // log d tag, "dowalletinfo onsuccess callback is called" ; // for visa, deviceid can be set to "clientdeviceid" as defined by visa string deviceid = walletdata get samsungpay device_id ; // for visa, walletuserid can be set to "clientwalletaccountid" as defined by visa string walletuserid = walletdata get samsungpay wallet_user_id ; } @override public void onfail int errorcode, bundle errordata { log e tag, "onfail callback is called, errorcode " + errorcode ; // to get more reason of the failure, // check some extra error codes in the errordata bundle such as samsungpay extra_error_reason if provided } } parameters keys - key list to get wallet information if the list is empty, all possible key values are returned the possible keys are #wallet_dm_id #device_id #wallet_user_id listener - callback through which the result is provided on success, statuslistener onsuccess int status, bundle data is invoked with wallet information the success code can be one of the following codes with bundle data status bundle keys bundle values usage vts mdes #error_none samsungpay#wallet_dm_id string device management id n/a paymentappinstanceid = device_id + padding "00" + wallet_dm_id *if you need 'paymentappinstanceid', you can generate it as above samsungpay#device_id string device id clientdeviceid samsungpay#wallet_user_id string wallet user id clientwalletaccountid on any failure, the error code is provided via statuslistener onfail int errorcode, bundle errordata note please refer spaysdk common_status_table in detail throws nullpointerexception - thrown if parameters are null since api level 1 2 samsung electronics samsung pay sdk 2 22 00 - nov 19 2024
tutorials blockchain
blogdistributed ledger-based technologies are becoming more popular and easy to use. anyone can now build a new cryptocurrency or token in the blockchain world. this rise in popularity and value makes crypto assets a big target for hackers. if you want to keep your valuable crypto assets safe, using a hardware cold wallet such as trezor or ledger nano s has become a necessity. unfortunately, that adds up to one more item in your pocket that you always have to carry around. thankfully, gone are the days of carrying clunky, old wallets. recent galaxy phones, such as the s10e, s10, s10+, note10, and fold, can now securely store your cryptocurrency wallet using the samsung blockchain keystore (sbk). along with storing your cryptocurrency wallet, the sbk sdk allows you to get your blockchain address and sign cryptocurrency transactions. in this article, we explore one of the key features offered by the keystore sdk--how to get your blockchain address from the sbk sdk and three ways to share it: display as qr code copy to clipboard share through android’s share intent setting up the project and handling sbk data to set up your android project with the sbk sdk, follow these instructions. to use functionalities offered by the sdk, first fetch an instance of the service. private scwservice mscwservice = scwservice.getinstance(); after you have fetched the scwservice instance, you can check whether your device is keystore-supported. if (mscwservice == null) { log.e("keystoreapp", "keystore is not supported on this device."); } if the device is keystore-supported, you can fetch the address list with getaddresslist(): mscwservice.getaddresslist(addresslistcallback, hdpathlist); the first parameter to getaddresslist() is a scwgetaddresslistcallback, which is executed after getting a response from keystore. scwgetaddresslistcallback() has two functions: onsuccess(): this function is called when the address list has been fetched successfully from keystore. onfailure(): this function is called if any errors occur while fetching the address list from keystore. scwservice.scwgetaddresslistcallback addresslistcallback = new scwservice.scwgetaddresslistcallback() { @override public void onsuccess(list addresslist) { //you can share your address from the address list here } @override public void onfailure(int failurecode) { //based on the failure code you can show appropriate alerts here } }; the second parameter is an arraylist of hierarchical deterministic (hd) path(s) whose addresses you want to fetch. if you want to learn more about hd paths, please refer to bip-44. for example, if you want to find the public address of your first five accounts, pass the following list as a parameter: arraylist hdpathlist = new arraylist<>(); hdpathlist.add("m/44'/60'/0'/0/0"); hdpathlist.add("m/44'/60'/0'/0/1"); hdpathlist.add("m/44'/60'/0'/0/2"); hdpathlist.add("m/44'/60'/0'/0/3"); hdpathlist.add("m/44'/60'/0'/0/4"); a sample app with the sbk sdk now that we are familiar with getaddresslist(), let’s dive into our sample application. features of our public address with sbk app are: fetch your public address from the keystore switch between multiple public addresses display qr code of the selected account copy selected address into the clipboard send the selected address with supported applications with android’s share intent initially, only the address of the first account is loaded. when you press the add button, the hd path of a new account is added to hdpathlist, and public addresses are fetched. public void addaccount(view view) { //account index is incremented by 1 to get the new account accountindex++; //hdpath of new account is added to hdpathlist hdpathlist.add("m/44'/60'/0'/0/" + accountindex); showtoast("hdpath added to list"); //public address of new account is fetched getpublicaddress(); } public addresses are fetched using the getpublicaddress() function depicted below. if the address list is fetched successfully, onsuccess() is called, and: the spinner’s previous data is cleared. the newly fetched list is added to the spinner. the ui is updated. if an error occurs, it is logged and available from logcat. common errors such as error_invalid_scw_app_id can be fixed very easily by enabling developer mode from the keystore application. you can find instructions on how to enable developer mode here. private void getpublicaddress() { scwservice.scwgetaddresslistcallback addresslistcallback = new scwservice.scwgetaddresslistcallback() { @override public void onsuccess(final list publicaddresslist) { //after address list has been fetched spinner is updated with new list runonuithread(new runnable() { @override public void run() { //clear existing list spinneradapter.clear(); //new list is added spinneradapter.addall(publicaddresslist); spinneradapter.notifydatasetchanged(); if (publicaddresslist.size() == 1) { showtoast(publicaddresslist.size() + " address fetched."); } else { showtoast(publicaddresslist.size() + " addresses fetched."); } } }); } @override public void onfailure(int errorcode) { switch (errorcode) { case scwerrorcode.error_invalid_scw_app_id: log.e(log_tag,"developer option not enabled."); break; case scwerrorcode.error_check_app_version_failed: log.e(log_tag,"check internet connection."); break; case scwerrorcode.error_op_fail: log.e(log_tag,"operation failed"); break; default: log.e(log_tag,"error with error code: "+errorcode); break; } } }; if (mscwservice == null) { log.e(log_tag, "keystore is not supported in this device."); } else { //if keystore is supported on device address list is requested mscwservice.getaddresslist(addresslistcallback, hdpathlist); } } after loading all addresses into the spinner, we can now select any address from it. once an address is selected, its qr code is generated and displayed. publicaddressspinner.setonitemselectedlistener(new adapterview.onitemselectedlistener() { @override public void onitemselected(adapterview<?> adapterview, view view, int position, long l) { //get selected address from spinner selectedaddress = adapterview.getitematposition(position).tostring(); selectedaddresstextview.settext(selectedaddress); qrcodeimageview.setimagebitmap(generateqrcode(selectedaddress)); } } in this application, we used “zxing” to generate the qr bitmap of the selected public address. private bitmap generateqrcode(string text) { multiformatwriter multiformatwriter = new multiformatwriter(); bitmap bitmap = bitmap.createbitmap(10, 10, bitmap.config.rgb_565); try { //text encoded to qr bitmatrix bitmatrix bitmatrix = multiformatwriter.encode(text, barcodeformat.qr_code, 1000, 1000); barcodeencoder barcodeencoder = new barcodeencoder(); //qr bitmatrix encoded to bitmap bitmap = barcodeencoder.createbitmap(bitmatrix); } catch (writerexception e) { e.printstacktrace(); } finally { return bitmap; } } when you press the copy button, the address is copied to the clipboard. public void copyaddress(view view) { clipboardmanager clipboardmanager = (clipboardmanager) getsystemservice(context.clipboard_service); clipdata clipdata = clipdata.newplaintext("public address", selectedaddress); clipboardmanager.setprimaryclip(clipdata); toast.maketext(this, "address copied", toast.length_short).show(); } we can also share the selected public address using the android action_send intent. public void shareaddress(view view) { intent sendintent = new intent(); sendintent.setaction(intent.action_send); sendintent.putextra(intent.extra_text, selectedaddress); sendintent.settype("text/plain"); startactivity(sendintent); } conclusion now that you know more about the samsung blockchain keystore sdk, you can use it to enrich your blockchain application. additional resources: download the sbk example app more information on keystore sdk
Shuvo Saha
Develop Samsung Pay
docbecome a member to become a samsung pay partner, firstly you need to sign up to the samsung pay portal and then register your membership sign up/sign in to sign up as a samsung pay partner and request access to the samsung pay developers site, do the following in your browser, go to samsung pay developers if you already have a samsung account, click log in otherwise, click sign up and create an account a company business email address that won't change over time is recommended as the primary samsung account user id for managing your portal projects agree to the site's terms and conditions and acknowledge that you understand the samsung pay partners privacy policy, then click create a samsung account fill out the onscreen account creation form, making sure to correctly type the security code, then click continue click sign up, enter your samsung account id email address and password, then click sign in look in your email inbox for a welcome message with an account activation link and click the link this opens the developers site registration page complete the company and user profile described in the next step to become a registered samsung pay developer partner register your membership while becoming a member of the samsung pay developer community, you need to provide some information about your company - contact information, type of business, size, etc this information is entered into a company and user profile, which you can subsequently update as changes occur if you are the first one in your company to join samsung pay developers, you will be the principal contact as such, you will be given permissions to manage projects and invite others in your company to collaborate if you are an invited co-worker, you'll need your company's partner id to register follow these steps to register if you are the first samsung pay member of your company to register, select the first option "i am the first samsung pay member of my company" if you were given a samsung pay partner id by a co-worker, select the second option "my company is already registered" and enter your company's partner id in the field provided click next complete the company information form and agree to the terms and conditions of use, then click save and next if you cannot complete the profile at this time, click skip and verify later complete the user information form, then click done; or, if you cannot provide the information at this time, click skip and verify later upon review of the information provided, your samsung pay relationship manager rm may request additional details once your membership registration is approved, you'll be granted access to currently restricted areas of the samsung pay portal and you can invite members of your team to collaborate on your samsung pay projects until then, take advantage of valuable resources like the samsung pay sdk and sdk programming guide from the following link android sdk [in-app payment and push provisioning] https //developer samsung com/pay/native/sdk-overview html web checkout sdk https //developer samsung com/pay/web/overview html w3c mobile payment https //developer samsung com/internet/android/web-payments-integration-guide html when you receive the email notifying you of membership approval, you're ready to get started in your browser, return to the samsung pay portal and sign in set up your partner project when you integrate your project with samsung pay, it is important to have a clear understanding of what is involved for starters, consider the difference between apps and services app an app can be your issuer app or merchant app service a service is a combination of your app, its service type, a csr and a service id your app will pass these information to samsung wallet for partnership verification you can create different service for the same package for multiple purpose testing note that,only one application can be added under one service id for example app deployment scenario unique service-app combinations global issuer app using a different csr encryption key for services in different regions to interact with local servers service 1 = com issuer walletapp, csr1_us service 2 = com issuer walletapp, csr2_plcc_abcmart same issuer app for all customers but different csrs for managing different card services b2b vs plcc service 1 = com issuer walletapp, csr1_regular service 2 = com issuer walletapp, csr2_plcc_abcmart multiple merchant apps using the same pg service 1 = com merchant electronicsapp, csr_pg1 service 2 = com merchant groceryapp, csr_pg1 global merchant app using a different pg for each country service 1 = com merchant electronicsapp, csr_pg1 service 2 = com merchant electronicsapp, csr_pg2 multiple web sites using the same pg service 1 = electronicssite merchant com, csr_pg1 service 2 = grocerysite merchant com, crs_pg1 global merchant web site using a different pg for each country service 1 = electronicsapp merchant com, csr_pg1 service 2 = electronicsapp merchant com, csr_pg2 create new service to create a new service follow the below steps go to my projects > service management or click services management in the navigation panel on the left, then click create new service select for test or for release to define the service for integration with samsung pay, then click next note that, samsung pay will verify all services requested only for release purpose this is to ensure all samsung pay features are functioning correctly and follows samsung pay guideline select your desired service type web online payment service w3c mobile web payments in-app online payment service app to app card enrollment click save and next web online payment service enter the new service name select your service country select your payment gateway from the list of supported payment gateways if your payment gateway uses the network token mode, upload the certificate signing request csr you obtained from your pg supported formats are csr or pem contact your pg for details confirm your agreement with the portal's terms and conditions click the link to read and print , then click done thus, you have completed service configuration for web online payment w3c mobile web payments service enter the new service name select your service country select your payment gateway from the list of supported payment gateways if your payment gateway uses the network token mode, upload the certificate signing request csr you obtained from your pg supported formats are csr or pem 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 in the portal for each additional domain name, click add confirm your agreement with the portal's terms and conditions click the link to read and print , then click done thus, you have completed service configuration for w3c mobile web payments in-app online payment service enter the new service name select your service country select your payment gateway from the list of supported payment gateways drag and drop the csr you share with your payment gateway in the box provided or click the paperclip to browse confirm your agreement with the portal's terms and conditions click the link to read and print , then click save and next app to app card enrollment service enter the new service name select your service country add issuer names these correspond to your financial institution/bank's name s registered with the card networks be sure to click the add button after each entry note that, the issuer name on the samsung pay portal and the actual issuer name of the card must match if you cannot confirm the actual issuer name of the card, just add your card to samsung wallet app and see its details information open wallet app > tap on the card > three-dot menu > customer services option under the title you will find the issuer name confirm your agreement with the portal's terms and conditions click the link to read and print , then click save and next for android sdk in-app online payment service and push provisioning service , you have to go through two additional steps- providing app information and setting test environment providing app information if you have already registered an app following register a partner app for android sdk section, select i already registered app information then select the desired app name from the app list you can add a new app on the fly by selecting i will upload new app information click next setting test environment now enter up to 30 test accounts comma-separated these are samsung accounts associated with a registered samsung pay app on a supported device you can always edit the service later to add or delete test accounts click done to save the service configuration and see it listed in your service management dashboard register a partner app for android sdk go to my projects > app management in the navigation panel on the left, then click add new app enter the app name enter its package name to specifically identify this app enter an app description optional; helpful for version control upload the apk file by dragging and dropping it in the corresponding box click the paperclip icon to browse upload representative screenshots showing ui branding elements/buttons in a supported format png, jpeg, gif indicating samsung pay as a supported payment option in your app steps 5 and 6 are required for release versions of your app; not required for initial integration testing click create, then click next at the bottom of the plug-in configuration page your newly added app is now listed in your app management dashboard you can view its details by clicking its app name then, on the app details page, you can edit the app name and description by clicking the corresponding pencil icon
Develop Samsung Wallet
docapi specification app2app sdk integration specs description & use rp sdk is an app2app sdk for samsung wallet driver's license service online scenarios this sdk provides an implementation for direct communication between the samsung wallet and partner applications build the settings rpsdk requires additional dependencies with dependencies { implementation "rp-sdk-1 0-release aar" implementation "androidx core core-ktx 1 3 2" implementation "androidx lifecycle lifecycle-runtime-ktx 2 7 0" implementation "androidx lifecycle lifecycle-livedata-core-ktx 2 7 0" implementation "io reactivex rxjava2 rxjava 2 2 21" implementation "io reactivex rxjava2 rxkotlin 2 4 0" implementation "io reactivex rxjava2 rxandroid 2 1 1" implementation "com squareup okhttp3 okhttp 4 11 0" implementation "com google code gson gson 2 10 1" implementation "org bouncycastle bcprov-jdk15to18 1 66" implementation "com nimbusds nimbus-jose-jwt 9 37 3" } androidmanifest xml <manifest xmlns android="http //schemas android com/apk/res/android"> <uses-permission android name="android permission internet" /> <queries> <package android name="com samsung android spay" /> </queries> </manifest> r8 / proguard the specific rules are already bundled into the aar which can be interpreted by r8 automatically sdk method app2app sdk supports one method request signature & parameters of the request method fun request targetpackagename string, requestid string, applink string, onresponselistener onresponselistener? = null parameter name description targetpackagename the pakcage name to connect to requestid a random string to identify each request applink the applink built by samsung mcs server guide onresponselistener a listener to receive each events or requests sample code binding button setonclicklistener { rpclientapis request "com samsung android spay", uuid randomuuid tostring , applink, object rpclientapis onresponselistener { override fun ongetmdocrequestdata deviceengagementbytes bytearray bytearray? { log i tag, "ongetmdocrequestdata $deviceengagementbytes " /** * 1 prepare mdoc request data iso-18013-5 * 2 build sessionestablishmentbytes iso-18013-5 * 3 encrypt it with hkdf iso-18013-5, 9 1 1 5 cryptographic operations **/ return "encryptedsessionestablishmentbytes" } override fun onmdocresponse encryptedresponse bytearray { log i tag, "onmdocresponse $encryptedresponse " /** * 1 decrypt it with hkdf iso-18013-5, 9 1 1 5 cryptographic operations * 2 cbor decode it **/ } override fun onmdocresponsefailed exception exception { log i tag, "onmdocresponsefailed $exception " } } } error code explanation the below exceptions might occur through the onmdocresponsefailed callback exceptions name description rpcommunicationexception this error occurs when the data requested by the listener is incorrect rpconnectionfailedexception this occurs when the app 2 app communication between apps is not working this usually occurs when the target package name is written incorrectly web2app api integration specs the api specifications that need to be implemented by the rp partner are described below called by samsung to the rp partner send key send the wallet application key info and return the data field types requested to the client for authentication of the mdl [request] type value description method post url {partner server url}/rp/v1 0/{cardid}/{refid}/key headers authorization string 1024 required credential token the token can have the prefix "bearer" as an authorization type, e g , bearer <credentials> * refer to authorization token for more details path parameters cardid string 32 required wallet card identifier issued from partner portal when the partner manager signs up for partner services and registers the wallet card they want to service refid string 32 required unique content identifier defined by the content provider query parameter n/a payload data string 3000 required jwt data encrypted with the public key information and card type if decrypted this data is decoded, and it has the following format information { “data” “xxxxxxxxxxx”, “card” {"type" "relyingparty", "subtype" "others", "designtype" "us-01" }} example post {partner server url}/rp/v1 0/{cardid}/{refid}/key content-type application/json { “data” “eyjjdhkioijbvvriiiwidmvyijoimiisinbhcnruzxjjzci6inrlc3qilcj1dgmioje3mtyymdyznjaxmtasimfszyi6iljtmju2in0 zxlkbgjttwlpaupctvrjnfiwtk5jaxdpwvd4bklqb2lvbe5ctfu5qljwqxrnaluysw4wllz5afaxs0fnmvjhbzbdn2nix2pydgtfoddqbnhrrmpfwkppcnnsuus4mnn0owvxtjeyvzvmoejax1d5ngvzmze3vdnad0pncmpwzwdzoek3avlcwwrlogj5lxfimjblu3ruc3jsszlpslfnn1fam2xzauxscxltb0vlbervd0fpatrmry1jukzwdvlrbxrintg3utd1zwnuq1lwwgzwalvecg01yxbfbdv3szm1ugz3d0dkrem2tmowz1awbtz3nk1kdl9mddbvzwc2mwzjagdbyny0emxmzju2cvyzm0t6zjdjbwvpbkjrnnpmsgutymfwyxhvzk5ld2htzwvjuzftv3larm1nvlj6mefsmnbxa0dqlvjkt1iza3vzavo0vjfidy1aq2iyvwvwyvdzru9nuedrvw1mbtfuowjwt1zmz1nuv1f0se5pvtfjyvrhtg1dwlpvqs5pmzzrd1g4wmjnq21wd3o2ll9kzehfvxnnbm13b1drddrmcu4xmuncauntsnutbwpyv2zrckxos0zvenbss085ckdxbudpz0pqukf1ntfsotryc2vivwdfwu9ns2rgr1vomwjhmhb3y0tfngtjmet2dkfowhprodn0azbjqzrot2f6vzlmovntt0rhmu9imefoavfzqzddevfqnndnlwflvk8waejwsejkmeduruh1z3exc21vvmxrbjblsnjqwhm4x3fwcnplekwtadfpcfk1aes1zug5q3nisms0aehcngnmwulkrujfz09bcgzxcgfumgfsvgfmodhhdxlqsgzhdgrma0tlwdv0q0rtajixse5tt0fhwtjvwlzrr0hxu0wzngjabtu5aezmnvdha0ljce9bmhlwue9tqznwtflkv2jsmm85lkfoedbvytvgetzudkxkvxvketazshc e07yyl7ior3885vykss5_q1icpx750uu2ge5sujsedx3dr_u0x4tse9_0nxm46dywnfuxruagfjdnjhibc707li9vi3xtyihwnweifydgv1qb9oddkyyzuahxqmjhvuqncdt6df2caqzf5qgmvqfmgse_t7ipu8vqfxe34do-skzj8ftduss2ecdanbqokchih3m39noubpfhcx68plpcw50dixlupxwegniu2t3co24yliaklgac669accxdqr34utvuqhtjt_ftxkahalzoa34_hj_s82fivixh1itd74uojzse7ibwya_kvysozavnmztz2th9cbwycvx8wa” } [response] type value description http status code 200 ok payload data string 3000 required jwt data encrypted with the data field types requested to the client for authentication of the mdl [result] http status code description 200 ok success 400 bad request requests cannot or will not be processed due to something that is perceived to be a client error 401 unauthorized authorization token is invalid or expired 500 internal server error the server encountered an unexpected condition that prevented it from fulfilling the request 503 service unavailable the server is not ready to handle the request send authentication data the data is encrypted according to the requested data and then transmitted along with the data card information [request] type value description method post url {partner server url}/rp/v1 0/{cardid}/{refid}/auth headers authorization string 1024 required credential token the token can have the prefix "bearer" as an authorization type, e g , bearer <credentials> * refer to authorization token for more details pathparameters cardid string 32 required wallet card identifier issued from partner portal when the partner manager signs up for partner services and registers the wallet card they want to service refid string 32 required unique content identifier defined by the content provider queryparameter n/a payload data string 3000 required jwt data encrypted with the public key information and card type if decrypted this data is decoded, it has the following format information { “data” “xxxxxxxxxxx”, “card” {"type" "idcard","subtype" "drivers","designtype" "us-01" }} example post {partner server url}/rp/v1 0/{cardid}/{refid}/auth content-type application/json { “data” “eyjjdhkioijbvvriiiwidmvyijoimiisinbhcnruzxjjzci6inrlc3qilcj1dgmioje3mtyymdyznjaxmtasimfszyi6iljtmju2in0 zxlkbgjttwlpaupctvrjnfiwtk5jaxdpwvd4bklqb2lvbe5ctfu5qljwqxrnaluysw4wllz5afaxs0fnmvjhbzbdn2nix2pydgtfoddqbnhrrmpfwkppcnnsuus4mnn0owvxtjeyvzvmoejax1d5ngvzmze3vdnad0pncmpwzwdzoek3avlcwwrlogj5lxfimjblu3ruc3jsszlpslfnn1fam2xzauxscxltb0vlbervd0fpatrmry1jukzwdvlrbxrintg3utd1zwnuq1lwwgzwalvecg01yxbfbdv3szm1ugz3d0dkrem2tmowz1awbtz3nk1kdl9mddbvzwc2mwzjagdbyny0emxmzju2cvyzm0t6zjdjbwvpbkjrnnpmsgutymfwyxhvzk5ld2htzwvjuzftv3larm1nvlj6mefsmnbxa0dqlvjkt1iza3vzavo0vjfidy1aq2iyvwvwyvdzru9nuedrvw1mbtfuowjwt1zmz1nuv1f0se5pvtfjyvrhtg1dwlpvqs5pmzzrd1g4wmjnq21wd3o2ll9kzehfvxnnbm13b1drddrmcu4xmuncauntsnutbwpyv2zrckxos0zvenbss085ckdxbudpz0pqukf1ntfsotryc2vivwdfwu9ns2rgr1vomwjhmhb3y0tfngtjmet2dkfowhprodn0azbjqzrot2f6vzlmovntt0rhmu9imefoavfzqzddevfqnndnlwflvk8waejwsejkmeduruh1z3exc21vvmxrbjblsnjqwhm4x3fwcnplekwtadfpcfk1aes1zug5q3nisms0aehcngnmwulkrujfz09bcgzxcgfumgfsvgfmodhhdxlqsgzhdgrma0tlwdv0q0rtajixse5tt0fhwtjvwlzrr0hxu0wzngjabtu5aezmnvdha0ljce9bmhlwue9tqznwtflkv2jsmm85lkfoedbvytvgetzudkxkvxvketazshc e07yyl7ior3885vykss5_q1icpx750uu2ge5sujsedx3dr_u0x4tse9_0nxm46dywnfuxruagfjdnjhibc707li9vi3xtyihwnweifydgv1qb9oddkyyzuahxqmjhvuqncdt6df2caqzf5qgmvqfmgse_t7ipu8vqfxe34do-skzj8ftduss2ecdanbqokchih3m39noubpfhcx68plpcw50dixlupxwegniu2t3co24yliaklgac669accxdqr34utvuqhtjt_ftxkahalzoa34_hj_s82fivixh1itd74uojzse7ibwya_kvysozavnmztz2th9cbwycvx8wa” } [response] type value description http status code 200 ok400 bad request [result] http status code description 200 ok success 400 bad request requests cannot or will not be processed due to somethingthat is perceived to be a client error 401 unauthorized authorization token is invalid or expired 500 internal server error the server encountered an unexpected condition that prevented it from fulfilling the request 503 service unavailable the server is not ready to handle the request code explanation based on the sample code jwt jws + jwe decryption between the wallet backed server and partner server 1 verify by generateing a jws using the body data // generate jws by the body data private static signedjwt parsejwt final string data { try { return signedjwt parse data ; } catch parseexception e { log error "parserjwt error class {}, error message {}", e getclass , e getmessage ; throw new customexception httpstatus internal_server_error, "parserjwt error" ; } } // verify jws using samsung public key public requestbody getrequestbody final keyring keyring { final signedjwt signedjwt = jwtutils verify keyring gettargetpublickey , encrypteddata, 60 * 10000 ; // verify and generate jws try { final string strbody = jwtutils getdecryptedpayloadfrom keyring getsourceprivatekey , jweobject parse signedjwt getpayload tostring ; // decryption jwe by the jws return objectmapper readvalue strbody, requestbody class ; // convert to data format requested by client } catch parseexception | jsonprocessingexception e { log error "getrequestbody {}", e getmessage ; throw new customexception httpstatus internal_server_error, "data body parse error" ; } } 2 decrypt the jwe using the jws jweobject parse signedjwt getpayload tostring public static string getdecryptedpayloadfrom final key privatekey, final jweobject data { try { data decrypt new rsadecrypter privatekey privatekey ; // decryption jwe using partner private key return data getpayload tostring ; } catch joseexception e { log error "joseexception message {}", e getmessage ; throw new customexception httpstatus internal_server_error, "getdecryptedpayloadfrom error" ; } } 3 convert to the format send by the client public requestbody getrequestbody final keyring keyring { final signedjwt signedjwt = jwtutils verify keyring gettargetpublickey , encrypteddata, 60 * 10000 ; // verify and generate jws try { final string strbody = jwtutils getdecryptedpayloadfrom keyring getsourceprivatekey , jweobject parse signedjwt getpayload tostring ; // decryption jwe by the jws return objectmapper readvalue strbody, requestbody class ; // convert to data format requested by client } catch parseexception | jsonprocessingexception e { log error "getrequestbody {}", e getmessage ; throw new customexception httpstatus internal_server_error, "data body parse error" ; } } generate mdocestablishment 1 generate rsa key per refid public class transactioncontext { private final keypair keypair; // rsa key private final byte[] clientengagement; // body data received through key api, base64url decoded value @equalsandhashcode exclude private int encryptmessagecounter = 0; // count value when encrypted @equalsandhashcode exclude private int decryptmessagecounter = 0; // count value when decrypted } private cache<string, transactioncontext> contextcache; // rsa key management per refid with memory cache // generate and store rsa key per refid only once upon first request public transactioncontext settransactioncontext final string key, final string base64encodedclientengagement { log info "base64encodedclientpublickey {}", base64encodedclientengagement ; this contextcache put key, new transactioncontext keyutils generatekeypair , base64utils decode base64encodedclientengagement getbytes ; return this gettransactioncontextby key ; } // part of retrieving ras key based on refid public transactioncontext gettransactioncontextby final string key { return optional ofnullable this contextcache getifpresent key orelsethrow -> { log info "{} is empty", key ; return new customexception httpstatus bad_request, "no key matching the refid" ; } ; } 2 create request field values @override public mono<list<string>> createrequest final partnerinputdto inputdto { final string mockdata = "{ \"doctype\" \"org iso 18013 5 1 mdl\", \"namespaces\" { \"org iso 18013 5 1\" { \"sex\" false, \"portrait\" false, \"given_name\" false, \"issue_date\" false, \"expiry_date\" false, \"family_name\" false, \"document_number\" false, \"issuing_authority\" false }, \"org iso 18013 5 1 aamva\" { \"dhs_compliance\" false, \"edl_credential\" false } } }"; return mono just collections singletonlist mockdata ; } 3 generate establishment @allargsconstructor public class establishment { private final transactioncontext context; // info of client public key , partner private key, public key private final list<string> strreqs; // data field information required for authentication to the client private final keyring keyring; // rsa key information for jwt jws + jwe encryption and decryption between wallet backed server and partner server } protected cborobject generate { final cborobject sessionestablishment = cborobject newmap ; sessionestablishment set e_reader_key, cborobject fromobjectandtag keyutils getereaderkey context , tag_size ; // generate onekey by public key in transactioncontext sessionestablishment set data, cborobject fromobject cipherutils encrypt context, generaterequestformat getrequestcborobjectsfrom strreqs ; // add request data field information for authentication return sessionestablishment; } generate the response value jwt jws + jwe 1 generate establishment with jwe public static string encryptedstringjwe final key publickey, final string data { // please enter samsung public key and establishment data final jweobject jwe = new jweobject new jweheader builder jwealgorithm rsa_oaep_256, encryptionmethod a128gcm build , new payload data ; try { jwe encrypt new rsaencrypter rsapublickey publickey ; return jwe serialize ; } catch joseexception e { log error "encryptedstringjwe exception message {}", e getmessage ; throw new customexception httpstatus internal_server_error, "encryptedstringjwe error" ; } } 2 generate jws by jwe public static string generatesignedstringjws final key privatekey, final key publickey, final string payload { // enter your partner’s public key, private key, and jwe data try { final jwsobject jwsobj = new jwsobject getdefaultjwsheader , new payload payload ; jwssigner signer = new rsassasigner new rsakey builder rsapublickey publickey privatekey rsaprivatekey privatekey build ; jwsobj sign signer ; return jwsobj serialize ; } catch joseexception e { log error "encryptedstringjws exception message {}", e getmessage ; throw new customexception httpstatus internal_server_error, "generatesignedstringjws error" ; } } 3 generate jwt jws + jwe public partneroutputdto topartneroutputdto { final cborobject generate = this generate ; final string establishment = base64 geturlencoder encodetostring generate encodetobytes ; final string strjwe = jwtutils encryptedstringjwe keyring gettargetpublickey , establishment ; final jwsheader jwsheader = jwtutils getdefaultjwsheader keyring getversion , keyring getcertificateid , "partnerid" ; return new partneroutputdto jwtutils generatesignedstringjws jwsheader, keyring getsourceprivatekey , keyring getsourcepublickey ,strjwe ; } authentication processing for values in data fields requested for authentication 1 retrieve transactioncontext value stored in cache using refid value @override public mono<transactioncontext> getcontext final partnerinputdto inputdto { return mono just this transactioncontextmanager gettransactioncontextby inputdto getrefid ; } 2 processes the decryption process of the request body data like jwt jws + jwe decryption between wallet backed server and partner server 3 generate mdocresponse public class mdocresponse { private final transactioncontext context; // managed tranactioncontext by refid private final byte[] data; // base64url decoded data after decrypting jwt jws + jwe data public mdocresponse final transactioncontext context, final string inputdto { this context = context; this data = base64utils decode inputdto getbytes standardcharsets utf_8 ; } } 4 get the field values requested for authentication from the data in mdocresponse public string getdata { // sessiondata = { // ? "data" bstr ; encrypted mdoc response or mdoc request // ? "status" uint ; status code // } final cborobject response = cborobject decodefrombytes data ; checktype response, cbortype map ; final cborobject data = response get data ; checktype data, cbortype bytestring ; return cborobject decodefrombytes isencryptedmode ? cipherutils decrypt this context, data getbytestring data getbytestring tojsonstring ; } 5 create a session value using the transactioncontext value managed by refid and then decrypt it private static byte[] processcipher final ciphermode ciphermode, final transactioncontext context, final byte[] bytes { // ciphermode encrypt or decrypt, bytes data passed by the client try { cipher cipher = cipher getinstance "aes/gcm/nopadding" ; final int counter = ciphermode encrypt == ciphermode ? context getencryptmessagecounter context getdecryptmessagecounter ; gcmparameterspec parameterspec = new gcmparameterspec 128, getsessionkeyiv ciphermode identifier, counter ; cipher init ciphermode ciphermode , getsecretkeyspec context, ciphermode info , parameterspec ; return cipher dofinal bytes ; } catch invalidalgorithmparameterexception | nosuchpaddingexception | illegalblocksizeexception | nosuchalgorithmexception | badpaddingexception | invalidkeyexception e { log error "error type {}, message {}", e getclass , e getmessage ; throw new customexception httpstatus internal_server_error, "processcipher error" ; } } 6 examining data received from the client @override public mono<void> authentication final string response { log info "response info {}", response ; return mono empty ; } wallet cards refer to the wallet cards this chapter defines wallet card data fields for the attributes object of each wallet card type the structure for configuring wallet cards follows the defined specification configuring the card data in the specified formatted json structure is required see the details for each card type type value description card object card object required card information card type string 16 required wallet card type card subtype string 16 required allet card sub type card data[] array of object required wallet card data containerallows up to 6 objects at once data[] refid string 32 required a unique content identifier definedby the content provider data[] createdat long 13 required data creation timestamp epoch timestamp in milliseconds utc±00 00 data[] updatedat long 13 required data creation timestamp epoch timestamp in milliseconds utc±00 00 data[] language string 8 required default content language code e g , en, ko data[] attributes object required card data attributes * refer to the following chapters for each type data[] attributes {fields} attribute fields by card type data[] localization[] array of object optional information for multilingual support localization[] language string 8 required multilingual content language code e g , en, ko, etc localization[] attributes {fields} for displaying a given language,‘data[] attributes’ can be replaced bylocalized versions * refer to the following chapters for each type example example card object { "card" { "type" "ticket", "subtype" "movies", "data" [{ "refid" "ref-20230304-001", "createdat" 1612660039000, "language" "en", "attributes" { "title" "samsung wallet", "mainimg" "https // /main png" *refer to wallet cards for each type }, "localization" [{ "language" "ko", "attributes" { "title" "삼성 월렛" } }] }] } } to ensure secure card data transmission, it must be tokenized in jwt format for this purpose, partner will need the certificate obtained using the partner's email account when signing up for the partner portal for detailed information on secure data tokenization, partners can refer to the security chapter *image resources provided by urls can be cached therefore, for the image resource to be replaced immediately, the corresponding url path must be changed relying party ‘relyingparty’ cards are used for verifier authentication when partners create the verify with samsung wallet button, they will need to create cdata this is the data spec included when creating the cdata of relayingparty type wallet card type wallet card subtype relyingparty others type value description attributes{fields} 1 logoimage string 256 required url of the logo image the file size must not be greater than 256 kb 2 logoimage darkurl string 256 required url of the logo image the file size must not be greater than 256 kb 3 logoimage lighturl string 256 required url of the logo image the file size must not be greater than 256 kb 4 fontcolor string 8 optional display color of the font during user authentication 5 providername string 32 required display name during user authentication 6 clienttype string 32 required information on whether the client operates as an application or web 7 clientpackagename string 32 required if the client is operating as an app, enter the package name, if it works on the web, enter a service name example { "card" { "type" "relyingparty", "subtype" "others", "data" [ { "refid" "0613001", "createdat" 1686657600000, "updatedat " 1686657600000, "language" "en", "attributes" { "logoimage" "https //samsung com", "logoimage darkurl" "https //dark samsung com", "logoimage lighturl" "https //light samsung com", "fontcolor" "black", "providername" "company name", "clienttype" "app", "clientpackagename" "com companyname app" } } ] } }
Develop Samsung Pay
apioverview package class tree index help package com samsung android sdk samsungpay v2 class watchmanager java lang object samsungpaybase com samsung android sdk samsungpay v2 watchmanager all implemented interfaces apptoappconstants public final class watchmanager extends samsungpaybase implements apptoappconstants this class provides apis for watch management partner apps must check the samsung pay watch status on the device before performing any card management also, this class provides apis getting cards information, adding new card to samsung pay on watch, and so on since api level 2 5 field summary fields modifier and type field description static final string device_serial_num key to represent device serial number to generate the paymentappinstanceid static final int error_invalid_parameter this error indicates that the given parameter is invalid this is returned as spaysdk extra_error_reason for spaysdk error_registration_fail error static final int error_spay_pin_lock_setup_canceled this error indicates that user canceled the pin lock setup partner app should ask user to setup pin for samsung pay gear static final int error_spay_watch_connection this error indicates that samsung pay watch plug-in can not connect with samsung pay watch partner app should ask user to check bluetooth connection or pairing static final int error_spay_watch_pay_progress this error indicates that samsung pay watch is in a process of payment static final int error_spay_watch_pin_lock_setup_canceled this error indicates that user canceled the pin lock setup partner app should ask user to setup pin for samsung pay watch static final int spay_watch_taking_log_for_report this error indicates that samsung pay watch is taking log for error report static final int spay_watch_update_is_ongoing this error indicates that samsung pay watch being updated fields inherited from interface com samsung android sdk samsungpay v2 apptoappconstants error_auth_code_expired, error_auth_code_invalid, error_auth_code_max_try_reached, error_auth_code_type_invalid, error_authentication_closed, error_authentication_failed, error_authentication_not_ready, error_authentication_timed_out, error_card_already_registered, error_card_idv_not_supported, error_card_not_supported, error_framework_internal, error_invalid_card, error_invalid_cardinput, error_max_card_num_reached, error_max_pan_provision_num_reached, error_server_reject, error_tsm_fail, error_verify_card, error_wallet_id_mismatch, extra_app2app_intent, extra_app2app_payload, extra_card_balance, extra_card_status_reason, extra_issuer_app_card_linked constructor summary constructors constructor description watchmanager android content context context, partnerinfo partnerinfo api to get the watchmanager instance the caller should set valid serviceid method summary all methodsinstance methodsconcrete methods modifier and type method description void activatesamsungpay api to bring the samsung pay on watch app to a state in which cards can be added samsung pay on watch might be samsung account is not signed in state partner app checks the samsung pay on watch status with getsamsungpaystatus statuslistener api if the status is #spay_not_ready and #extra_error_reason is #error_spay_setup_not_completed, partner app can call this api to launch samsung pay on watch and user can sign in to the app void addcard addcardinfo addcardinfo, addcardlistener listener api to add a card from partner app example issuer/bank app to samsung pay on watch partner app uses this api to add card to samsung pay on watch by providing the required card details void getallcards android os bundle cardfilter, getcardlistener listener api to get all the cards from samsung pay on watch for the given filter void getsamsungpaystatus statuslistener listener api to get the samsung pay on watch status on the device partner issuers applications must call this api to check the current state of samsung pay on watch before doing any operation void getwalletinfo list<string> keys, statuslistener listener api to get the requested wallet information from samsung pay on watch partner app can use this information to uniquely identify the user and samsung pay on watch app on a particular device void gotoupdatepage api to go to samsung pay on watch update page partner app checks the samsung pay on watch status with getsamsungpaystatus statuslistener api if the status is #spay_not_ready and #extra_error_reason is #error_spay_app_need_to_update, partner app can call this api to go to update samsung pay on watch app methods inherited from class java lang object equals, getclass, hashcode, notify, notifyall, tostring, wait, wait, wait field details device_serial_num public static final string device_serial_num key to represent device serial number to generate the paymentappinstanceid since api level 2 5 see also constant field values error_spay_pin_lock_setup_canceled public static final int error_spay_pin_lock_setup_canceled this error indicates that user canceled the pin lock setup partner app should ask user to setup pin for samsung pay gear since api level 2 5 see also constant field values error_invalid_parameter public static final int error_invalid_parameter this error indicates that the given parameter is invalid this is returned as spaysdk extra_error_reason for spaysdk error_registration_fail error since api level 2 5 see also constant field values error_spay_watch_pin_lock_setup_canceled public static final int error_spay_watch_pin_lock_setup_canceled this error indicates that user canceled the pin lock setup partner app should ask user to setup pin for samsung pay watch since api level 2 5 see also constant field values spay_watch_update_is_ongoing public static final int spay_watch_update_is_ongoing this error indicates that samsung pay watch being updated since api level 2 5 see also constant field values spay_watch_taking_log_for_report public static final int spay_watch_taking_log_for_report this error indicates that samsung pay watch is taking log for error report since api level 2 5 see also constant field values error_spay_watch_pay_progress public static final int error_spay_watch_pay_progress this error indicates that samsung pay watch is in a process of payment since api level 2 5 see also constant field values error_spay_watch_connection public static final int error_spay_watch_connection this error indicates that samsung pay watch plug-in can not connect with samsung pay watch partner app should ask user to check bluetooth connection or pairing since api level 2 5 see also constant field values constructor details watchmanager public watchmanager android content context context, partnerinfo partnerinfo api to get the watchmanager instance the caller should set valid serviceid partnerinfo is passed to samsung pay on watch for caller verification context ct = activity; // or context ct = service; string issuername = "mybank"; // set the serviceid which is assigned by the samsung pay developer during on boarding string serviceid = "sampleserviceid"; bundle bundle = new bundle ; bundle putstring watchmanager extra_issuer_name, issuername ; bundle putstring watchmanager partner_service_type, watchmanager servicetype app2app tostring ; partnerinfo pinfo = new partnerinfo serviceid, bundle ; watchmanager watchmanager = new watchmanager ct, pinfo ; parameters context - activity context or service context partnerinfo - partner information throws nullpointerexception - thrown if parameters are null since api level 2 5 method details getsamsungpaystatus public void getsamsungpaystatus @nonnull statuslistener listener api to get the samsung pay on watch status on the device partner issuers applications must call this api to check the current state of samsung pay on watch before doing any operation // set the serviceid which is assigned by the samsung pay developer during on boarding string serviceid = "sampleserviceid"; bundle bundle = new bundle ; bundle putstring watchmanager partner_service_type, watchmanager servicetype app2app tostring ; partnerinfo pinfo = new partnerinfo serviceid, bundle ; watchmanager watchmanager = new watchmanager context, pinfo ; watchmanager getsamsungpaystatus new statuslistener { @override public void onsuccess int status, bundle data { // success case if status == spay_ready { log d tag, "samsung pay on watch is ready on the device" ; // perform your operation } else if status == spay_not_ready { // samsung pay on watch 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 } else { // samsung pay on watch is not supported on this device log d tag, "device does not support samsung pay on watch" ; } } @override public void onfail int errorcode, bundle errordata { log e tag, "onfail callback is called, errorcode " + errorcode ; // to get more reason of the failure, // check some extra error codes in the errordata bundle such as watchmanager extra_error_reason if provided } } ; parameters listener - callback through which the result is provided on success, samsung pay on watch status code is provided via statuslistener onsuccess int status, bundle data if samsung pay on watch is ready to be used, #spay_ready will be returned otherwise, #spay_not_ready or #spay_not_supported can be returned with #extra_error_reason from bundle also, partner can get extra information from bundle data bundle keys if provided bundle values spaysdk extra_country_code device country code iso 3166-1 alpha-2 on any failure, the failure code is provided via statuslistener onfail int errorcode, bundle errordata note please refer spaysdk common_status_table in detail throws nullpointerexception - thrown if the callback passed is null since api level 2 5 gotoupdatepage public void gotoupdatepage api to go to samsung pay on watch update page partner app checks the samsung pay on watch status with getsamsungpaystatus statuslistener api if the status is #spay_not_ready and #extra_error_reason is #error_spay_app_need_to_update, partner app can call this api to go to update samsung pay on watch app // set the serviceid which is assigned by the samsung pay developer during on boarding string serviceid = "sampleserviceid"; bundle bundle = new bundle ; bundle putstring watchmanager partner_service_type, watchmanager servicetype app2app tostring ; partnerinfo pinfo = new partnerinfo serviceid, bundle ; watchmanager watchmanager = new watchmanager context, pinfo ; watchmanager gotoupdatepage ; since api level 2 5 activatesamsungpay public void activatesamsungpay api to bring the samsung pay on watch app to a state in which cards can be added samsung pay on watch might be samsung account is not signed in state partner app checks the samsung pay on watch status with getsamsungpaystatus statuslistener api if the status is #spay_not_ready and #extra_error_reason is #error_spay_setup_not_completed, partner app can call this api to launch samsung pay on watch and user can sign in to the app // set the serviceid which is assigned by the samsung pay developer during on boarding string serviceid = "sampleserviceid"; bundle bundle = new bundle ; bundle putstring watchmanager partner_service_type, watchmanager servicetype app2app tostring ; partnerinfo pinfo = new partnerinfo serviceid, bundle ; watchmanager watchmanager = new watchmanager context, pinfo ; watchmanager activatesamsungpay ; since api level 2 5 getwalletinfo public void getwalletinfo list<string> keys, @nonnull statuslistener listener api to get the requested wallet information from samsung pay on watch partner app can use this information to uniquely identify the user and samsung pay on watch app on a particular device // set the serviceid which is assigned by the samsung pay developer during on boarding string serviceid = "sampleserviceid"; bundle bundle = new bundle ; bundle putstring watchmanager extra_issuer_name, "issuer name" ; bundle putstring watchmanager partner_service_type, watchmanager servicetype app2app tostring ; partnerinfo pinfo = new partnerinfo serviceid, bundle ; watchmanager watchmanager = new watchmanager context, pinfo ; // bundle keys added to get wallet information from samsung pay on watch // this information can be delivered to the partner server for eligibility check arraylist<string> keys = new arraylist<> ; keys add watchmanager wallet_user_id ; keys add watchmanager device_id ; watchmanager getwalletinfo keys, new statuslistener { @override public void onsuccess int status, bundle walletdata { // log d tag, "dowalletinfo onsuccess callback is called" ; // for visa, deviceid can be set to "clientdeviceid" as defined by visa string deviceid = walletdata get watchmanager device_id ; // for visa, walletuserid can be set to "clientwalletaccountid" as defined by visa string walletuserid = walletdata get watchmanager wallet_user_id ; } @override public void onfail int errorcode, bundle errordata { log e tag, "onfail callback is called, errorcode " + errorcode ; // to get more reason of the failure, // check some extra error codes in the errordata bundle such as watchmanager extra_error_reason if provided } } parameters keys - key list to get wallet information if the list is empty, all possible key values are returned the possible keys are #wallet_dm_id #device_id #wallet_user_id device_serial_num listener - callback through which the result is provided on success, statuslistener onsuccess int status, bundle data is invoked with wallet information the success code can be one of the following codes with bundle data status bundle keys bundle values usage vts mdes #error_none #wallet_dm_id string device management id n/a paymentappinstanceid = device_serial_num + wallet_dm_id *if you need 'paymentappinstanceid', you can generate it as above #device_id string device id clientdeviceid #wallet_user_id string wallet user id clientwalletaccountid device_serial_num string device serial number n/a on any failure, the error code is provided via statuslistener onfail int errorcode, bundle errordata note please refer spaysdk common_status_table in detail throws nullpointerexception - thrown if parameters are null since api level 2 5 addcard public void addcard @nonnull addcardinfo addcardinfo, @nonnull addcardlistener listener api to add a card from partner app example issuer/bank app to samsung pay on watch partner app uses this api to add card to samsung pay on watch by providing the required card details this helps user to add their cards to samsung pay on watch directly from partner app watchmanager watchmanager = new watchmanager ct, pinfo ; string cardtype = card card_type_credit; string tokenizationprovider = addcardinfo provider_abcd; // get it from issuer app // samsung pay on watch does not provide detailed payload information // generate provisioning payload in accordance with your card network specifications string testpayload = "thisistestpayloadcardinfo1234567890"; bundle carddetail = new bundle ; carddetail putstring addcardinfo extra_provision_payload, testpayload ; addcardinfo addcardinfo = new addcardinfo cardtype, tokenizationprovider, carddetail ; watchmanager addcard addcardinfo, new addcardlistener { @override public void onsuccess int status, card card { log d tag, "onsuccess callback is called" ; } @override public void onfail int errorcode, bundle errordata { log e tag, "onfail callback is called, errorcode " + errorcode ; // to get more reason of the failure, // check some extra error codes in the errordata bundle // such as watchmanager extra_error_reason or watchmanager extra_request_id if provided } @override public void onprogress int currentcount, int totalcount, bundle bundledata { log d tag,"onprogress callback is called " + currentcount + " / " + totalcount ; } } ; parameters addcardinfo - detail card information to add listener - callback through which the result is provided on success, addcardlistener onsuccess int, card is invoked with #error_none status code with added card information on any failure, the error code is provided via addcardlistener onfail int errorcode, bundle errordata the failure code can be one of the following codes with bundle data status bundle keys bundle values #error_registration_fail -104 #extra_error_reason apptoappconstants error_card_already_registered -500 apptoappconstants error_framework_internal -501 apptoappconstants error_invalid_card -502 apptoappconstants error_invalid_cardinput -503 error_invalid_parameter -504 apptoappconstants error_server_reject -505 apptoappconstants error_max_card_num_reached -506 apptoappconstants error_card_not_supported -514 apptoappconstants error_max_pan_provision_num_reached -515 apptoappconstants error_wallet_id_mismatch -516 error_spay_watch_pin_lock_setup_canceled -701 spay_watch_update_is_ongoing -702 spay_watch_taking_log_for_report -703 error_spay_watch_pay_progress -704 error_spay_watch_connection -705 #extra_request_id string value returned from server note please refer spaysdk common_status_table for other error status throws nullpointerexception - thrown if parameters are null since api level 2 17 getallcards public void getallcards @nullable android os bundle cardfilter, @nonnull getcardlistener listener api to get all the cards from samsung pay on watch for the given filter since api level 2 5, partner must define issuer names as a card filter on samsung pay developers while on-boarding bundle cardfilter = new bundle ; watchmanager getallcards cardfilter, new getcardlistener { @override public void onsuccess list<card> cards { // getting card status is success if cards == null || cards isempty { log e tag,"no card is found" ; return; } else { // perform operation with card data for card s cards { log d tag, "cardid " + s getcardid + "cardstatus" + s getcardstatus ; // get extra card data if s getcardinfo != null { string last4fpan = s getcardinfo getstring watchmanager extra_last4_fpan ; string last4dpan = s getcardinfo getstring watchmanager extra_last4_dpan ; string cardtype = s getcardinfo getstring watchmanager extra_card_type ; string cardissuername = s getcardinfo getstring watchmanager extra_issuer_name ; log d tag, "last4fpan " + last4fpan + "last4dpan" + last4dpan + "app2apppayload " + app2apppayload ; } } } } @override public void onfail int errorcode, bundle errordata { log e tag, "onfail callback is called, errorcode " + errorcode ; // to get more reason of the failure, // check some extra error codes in the errordata bundle such as watchmanager extra_error_reason if provided } } ; parameters listener - callback through which the result is provided on success, getcardlistener onsuccess list is invoked with list of cards on any failure, the error code is provided via getcardlistener onfail int, bundle note please refer spaysdk common_status_table in detail throws nullpointerexception - thrown if listener is null since api level 2 13 samsung electronics samsung pay sdk 2 22 00 - nov 19 2024
Develop Samsung Pay
docsample applications sample apps, use cases, and ux strategies are included here to aid you in understanding the sdk and implementing it in your application sample source code and apks can be downloaded from download section sample merchant app included with the samsung pay sdk to demonstrate its features, the sample merchant app shows you how to implement the payment sheet’s dynamic controls to leverage additional customer order and payment data and/or create a more custom ui look and feel the following payment sheet controls are available addresscontrol plaintextcontrol amountboxcontrol spinnercontrol controls are applied to suit a particular purpose or need for example, displaying a promotion notice in the payment sheet using the plaintextcontrol applying an addresscontrol this control is used to display the billing or shipping address on the payment sheet based on samsung pay’s my info user profile or addresses provided by your merchant app during the transaction request when creating the control, controlid and sheetitemtype are needed to distinguish the billing address from the shipping address otherwise, your merchant app sets the following properties address title – displays a merchant-defined title on the payment sheet if empty, the default title such as “billing address” is displayed address – provides various methods to retrieve address details the merchant app can retrieve the phone number using the 'getphonenumber' method of 'customsheetpaymentinfo' address starting from api level 1 5, the addressee’s email address has also been added retrieve the email address using 'getemail' you can also set a display option for the shipping address with 'setdisplayoption' for more information, see the samsung pay sdk-api reference javadoc and the sample code included with the samsung pay sdk sheetupdatedlistener – used to capture the response from the samsung wallet app; merchant app must deliver to the samsung wallet app an amountboxcontrol to display payment information on a custom payment sheet when the onresult callback is called, the updatesheet method must also be called to update the current payment sheet errorcode – used for containing error codes directly related to the address the workflows for billingaddresscontrol and shippingaddresscontrol are shown below the following sample code demonstrates use of addresscontrol on the payment sheet fun makebillingaddresscontrol addresscontrol { val billingaddresscontrol = if !iszipcodeonly { // for billing address addresscontrol billing_address_id, sheetitemtype billing_address billingaddresscontrol addresstitle = "billing address" } else { /* * for billing address with zip code only * since api level 2 19, sheetitemtype zip_only_address * for us country only */ addresscontrol billing_address_id, sheetitemtype zip_only_address billingaddresscontrol addresstitle = "zip code" } //this callback is received when controls are updated billingaddresscontrol sheetupdatedlistener = sheetupdatedlistener return billingaddresscontrol } //listener for billing or zip code only billing address fun sheetupdatedlistener sheetupdatedlistener { return sheetupdatedlistener { updatedcontrolid string, customsheet customsheet -> log d tag, "onresult billingaddresscontrol updatedcontrolid $updatedcontrolid" val addresscontrol = customsheet getsheetcontrol updatedcontrolid as addresscontrol val billaddress = addresscontrol address //validate only zipcode or billing address and set errorcode if needed if addresscontrol sheetitem sheetitemtype == sheetitemtype zip_only_address { val errorcode int = validatezipcodebillingaddress billaddress log d tag, "onresult updatesheetbilling errorcode $errorcode" addresscontrol errorcode = errorcode customsheet updatecontrol addresscontrol } else { val errorcode = validatebillingaddress billaddress log d tag, "onresult updatesheetbilling errorcode $errorcode" addresscontrol errorcode = errorcode customsheet updatecontrol addresscontrol } // update transaction values val amountboxcontrol = customsheet getsheetcontrol amount_control_id as amountboxcontrol amountboxcontrol updatevalue product_item_id, 1000 0 amountboxcontrol updatevalue product_tax_id, 50 0 amountboxcontrol updatevalue product_shipping_id, 10 0 amountboxcontrol updatevalue product_fuel_id, 0 0, "pending" amountboxcontrol setamounttotal 1060 0, amountconstants format_total_price_only customsheet updatecontrol amountboxcontrol try { // call updatesheet for the full amountboxcontrol; mandatory paymentmanager updatesheet customsheet } catch e illegalstateexception { e printstacktrace } catch e nullpointerexception { e printstacktrace } } } // for shipping address fun makeshippingaddresscontrol addresscontrol { val shippingaddresscontrol = addresscontrol shipping_address_id, sheetitemtype shipping_address shippingaddresscontrol addresstitle = "shipping address" val shippingaddress = customsheetpaymentinfo address builde setaddressee "name" setaddressline1 "addline1" setaddressline2 "addline2" setcity "city" setstate "state" setcountrycode "usa" setpostalcode "zip" setphonenumber "555-123-1234" setemail "user@samsung com" build shippingaddresscontrol address = shippingaddress /* * set address display option on custom payment sheet * if displayoption is not set, then default addresscontrol is displayed on custom payment sheet * the possible values are combination of below constants * {display_option_addressee} * {display_option_address} * {display_option_phone_number} * {display_option_email} */ var displayoption_val = addressconstants display_option_addressee // addressee is mandatory displayoption_val += addressconstants display_option_address displayoption_val += addressconstants display_option_phone_number displayoption_val += addressconstants display_option_email shippingaddresscontrol displayoption = displayoption_val return shippingaddresscontrol } here’s how these controls display on a custom payment sheet applying a plaintextcontrol this control is used for displaying a title with a two lines of text or a single line of text without a title on the payment sheet when allocating this control, a controlid is needed the merchant app sets both the title, as applicable, and the text diagrammed below is the flow between your merchant app and samsung pay the merchant app code invoking this class would look something like the following fun makeplaintextcontrol plaintextcontrol { val plaintextcontrol = plaintextcontrol "exampleplaintextcontrolid" plaintextcontrol settext "plain text [example]", "this is example of plaintextcontrol" return plaintextcontrol } and this is how it displays on the custom payment sheet applying an amountboxcontrol amountboxcontrol is used for displaying purchase amount information on the payment sheet it requires a controlid and a currencycode, and consists of item s and amounttotal, defined as follows and diagrammed on the next page item – consists of id, title, price, and extraprice if there is an extraprice in amountboxcontrol, its text is displayed on the payment sheet even though there is an actual numerical price value if there is no extraprice, then currencycode with the price value is displayed amounttotal – consists of price and displayoption the displayoption allows predefined strings only your merchant app can set the text to “estimated amount”, “amount pending”, “pending”, “free”, and so forth the ui format for the string is different for each option notethe setamounttotal api may accept strings that are not predefined as an argument, but itgenerates an invalid parameter condition or returns an error code in such cases for details, see the javadoc samsung pay sdk-api reference, available in the documentation folder of your downloaded sdk package here’s a coding example to demonstrate the use of amountboxcontrol in a payment sheet fun makeamountcontrol amountboxcontrol { val amountboxcontrol = amountboxcontrol amount_control_id, "usd" amountboxcontrol additem product_item_id, "item", 1000 0, "" amountboxcontrol additem product_tax_id, "tax", 50 0, "" amountboxcontrol additem product_shipping_id, "shipping", 10 0, "" amountboxcontrol setamounttotal 1060 0, amountconstants format_total_price_only amountboxcontrol additem 3, product_fuel_id, "fuel", 0 0, "pending" return amountboxcontrol } the merchant app can also add new items using the 'additem' method of 'amountcontrolbox' during callback importantyour merchant app needs to call the updatevalue item_id method of amountboxcontrol to update each amount item then call customsheet updatecontrol to make the changes take effect in customsheet eventually, paymentmanager updatesheet 'customsheet' must be called to let samsung pay know that no further action is pending in the merchant app when the custom sheet is updated, the merchant can add new items to amountboxcontrol for example, if the user selects a specific card in the payment sheet which the merchant offers, a discount item can be added via the updatesheet // example for adding new item while updating values val amount = sheet getsheetcontroll "id_amount" amount updatevalue "itemid", 900 0 amount updatevalue "taxid", 50 0 amount updatevalue "shippingid", 10 0 amount updatevalue "fuelid", 0 0 // add “discount” item amount additem 4, "discountid", "discount", -60 0, "" amount setamounttotal 1000 0, amountconstants format_total_price_only sheet updatecontrol amount // call updatesheet with amountboxcontrol; mandatory try { paymentmanager updatesheet sheet } catch e illegalstateexception { e printstacktrace } catch e nullpointerexception { e printstacktrace } applying the spinnercontrol this control is used for displaying spinner options on a payment sheet when creating the control, controlid, title, and sheetitemtype are needed to distinguish between the types of spinner to be displayed your merchant app sets the following properties with spinnercontrol title – the merchant-defined spinner title to appear the payment sheet sheetitemtype – provides various types of spinner a shipping_method_spinner and an installment_spinner are the two types of spinner available as of api level 1 6 noteshipping_method_spinner can be used when the shipping address comes from the samsung wallet app; i e , when the customsheetpaymentinfo addressinpaymentsheet option is set to need_billing_and_shipping or need_ shipping_spay when the shipping address is provided by the merchant app send_shipping or need_billing_ send_shipping , it is not changeable in the payment sheet the shipping fee if applied must be pre-calculated on the merchant app side here’s an example of constructing a spinnercontrol within your merchant app // construct spinnercontrol for shipping method val spinnercontrol = spinnercontrol shippingmethod_spinner_id, "shipping method ", sheetitemtype shipping_method_spinner // let the user can select one shipping method option on the payment sheet spinnercontrol additem "shipping_method_1", getstring android r string standard_shipping_free spinnercontrol additem "shipping_method_2", getstring android r string twoday_shipping spinnercontrol additem "shipping_method_3", getstring android r string oneday_shipping spinnercontrol selecteditemid = "shipping_method_1" // set default option // listen for sheetcontrol events spinnercontrol setsheetupdatedlistener sheetupdatedlistener { updatedcontrolid, customsheet -> val amountboxcontrol = customsheet getsheetcontrol amount_control_id as amountboxcontrol val spinnercontrol = customsheet getsheetcontrol updatedcontrolid as spinnercontrol when spinnercontrol selecteditemid { "shipping_method_1" -> amountboxcontrol updatevalue product_shipping_id, 10 0 "shipping_method_2" -> amountboxcontrol updatevalue product_shipping_id, 10 + 0 1 "shipping_method_3" -> amountboxcontrol updatevalue product_shipping_id, 10 + 0 2 else -> amountboxcontrol updatevalue product_shipping_id, 10 0 } amountboxcontrol setamounttotal 1000 + amountboxcontrol getvalue product_shipping_id , amountconstants format_total_price_only customsheet updatecontrol amountboxcontrol // call updatesheet with amountboxcontrol; mandatory try { paymentmanager updatesheet customsheet } catch e illegalstateexception { e printstacktrace } catch e nullpointerexception { e printstacktrace } } // construct spinnercontrol for installment plan val spinnercontrol = spinnercontrol installment_spinner_id, "installment", sheetitemtype installment_spinner spinnercontrol additem "installment_1", "1 month without interest" spinnercontrol additem "installment_2", "2 months with 2% monthly interest" spinnercontrol additem "installment_3", "3 months with 2 2% monthly interest" spinnercontrol selecteditemid = "installment_1" // set default option // listen for sheetcontrol events spinnercontrol setsheetupdatedlistener sheetupdatedlistener { updatedcontrolid, customsheet -> val amountboxcontrol amountboxcontrol = customsheet getsheetcontrol amount_control_id as amountboxcontrol val spinnercontrol = customsheet getsheetcontrol updatedcontrolid as spinnercontrol val totalinterest = 0 0 when spinnercontrol selecteditemid { "installment1" -> amountboxcontrol updatevalue product_total_interest_id, totalinterest "installment2" -> // calculate total interest again and updatevalue amountboxcontrol updatevalue product_total_interest_id, totalinterest "installment3" -> // calculate total interest again and updatevalue amountboxcontrol updatevalue product_total_interest_id, totalinterest else -> amountboxcontrol updatevalue product_total_interest_id, totalinterest } amountboxcontrol setamounttotal 1000 + amountboxcontrol getvalue product_total_interest_id , amountconstants format_total_price_only customsheet updatecontrol amountboxcontrol // call updatesheet with amountboxcontrol; mandatory try { paymentmanager updatesheet customsheet } catch e illegalstateexception { e printstacktrace } catch e nullpointerexception { e printstacktrace } } update sheet with custom error message to display a custom error message on the payment sheet, use updatesheet with customerrormessage fun updatesheet sheet customsheet, errorcode int, customerrormessage string this api method is an extended version of the existing updatesheet sheet method which gives the merchant the ability to display a custom error message in the payment sheet’s authentication area it can be used to inform the user of any foreseen error scenarios encountered // update sheet with custom_messsage error code paymentmanager updatesheet customsheet, paymentmanager custom_message,"phone number entered is not valid please change your phone number " sample issuer app the samsung pay sdk also provides a sample issuer app to showcase samsung pay sdk features issuer app can add card to samsung wallet by selecting specific token service provider tsp from the dropdown menu to add cobadge card you need to select primary and secondary token service providers tsp from the dropdown menus for more information, refer to the samsung pay sdk api reference and sample code
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.