overview package class tree index help package com samsung android sdk samsungpay v2 payment class paymentmanager java lang object com samsung android sdk samsungpay v2 spaysdk com samsung android sdk samsungpay v2 payment paymentmanager public final class paymentmanager extends spaysdk this class provides apis for payment related operations example in-app payment partner merchants and other third party applications can use these apis to perform variety of payment operations for instance, partner apps can - request in-app payment - start simple pay on samsung pay - fetch available cards on samsung pay for payment since api level 1 1 nested class summary nested classes modifier and type class description static interface paymentmanager cardinfolistener this interface is for listening requestcardinfo callback events static interface paymentmanager customsheettransactioninfolistener this interface is for listening callback events of online in-app custom sheet payment this is invoked when card is changed by the user on the custom payment sheet, and also with the success or failure of online in-app payment this listener is registered when startinapppaywithcustomsheet customsheetpaymentinfo, customsheettransactioninfolistener api is called caution amountboxcontrol must be returned in oncardinfoupdated on sheetupdatedlistener to remove progress bar on custom payment sheet class paymentmanager inapppaymentcallback class paymentmanager inappuserinfocallback nested classes/interfaces inherited from class com samsung android sdk samsungpay v2 spaysdk spaysdk brand, spaysdk servicetype field summary fields modifier and type field description static final int custom_message the merchant can call the updatesheet customsheet, int, string api with this error when it wants to display a custom error message on customsheet static final int error_address_updated_time_out indicates that online payment address updating is timed out static final int error_billing_address_invalid the merchant can call the updateamountfailed int or updatesheet customsheet, int, string api with this error when the billing address shared by samsung pay to the merchant is invalid static final int error_billing_address_not_exist the merchant can call the updateamountfailed int or updatesheet customsheet, int, string api with this error when the billing address shared by samsung pay does not exist static final int error_card_not_supported_online_pay indicates that this card does not support online pay static final int error_internal_address_updated indicates address update internal error static final int error_making_sheet_failed indicates that making sheet has failed static final int error_not_ready_payment indicates that online payment is not ready to complete because of various types of errors for example, internal error, unexpected error from samsung pay app, and so on static final int error_shipping_address_invalid the merchant can call the updateamountfailed int or updatesheet customsheet, int, string api with this error when the shipping address shared by samsung pay to the merchant is invalid static final int error_shipping_address_not_exist the merchant can call the updateamountfailed int or updatesheet customsheet, int, string api with this error when the shipping address shared by samsung pay does not exist static final int error_shipping_address_unable_to_ship the merchant can call the updateamountfailed int or updatesheet customsheet, int, string api with this error when the shipping address shared by samsung pay is not available for delivery by the merchant static final int error_spay_reset indicates that spay will be reset static final int error_transaction_closed indicates that transaction ui has closed static final int error_transaction_timed_out indicates that online payment processing has timed out static final string extra_key_additional_data key to represent additional data partner can use this key to put tagged data to a bundle before sending to samsung pay static final string extra_key_card_brand_filter key to represent request card filter list partner can use this key to put filter into bundle for requestcardinfo bundle, cardinfolistener static final string extra_key_test_mode key to represent pg test mode to prevent payment transaction being processed if the value is true, samsung-pg interface server redirects payment info to test pg server this is only for pg-indirect model static final string extra_logo_image_url key to represent the url of partner logo image on simple pay image width max static final string extra_pay_operation_type key to represent start simple pay operation type the possible values are pay_operation_type_payment pay_operation_type_refund static final string extra_transaction_date key to represent transaction date value when start simple pay to refund this is for korean issuers only example value mapped with this key 201906211428 yyyymmddhhmm static final string extra_transaction_number key to represent transaction number value when start simple pay to refund this is for korean issuers only maximum length is 14 static final string extra_transaction_type key to represent transaction type the possible values are transaction_type_mst transaction_type_nfc static final string pay_operation_type_payment indicates start simple pay option to make payment static final string pay_operation_type_refund indicates start simple pay option to make refund this is for korean issuers only static final int transaction_type_mst indicates that transaction type is mst static final int transaction_type_nfc indicates that transaction type is nfc fields inherited from class com samsung android sdk samsungpay v2 spaysdk common_status_table, cryptogram_type_icc, cryptogram_type_ucaf, device_id, device_type_gear, device_type_phone, error_android_platform_check_fail, error_device_integrity_check_fail, error_device_not_samsung, error_duplicated_sdk_api_called, error_expired_or_invalid_debug_key, error_initiation_fail, error_invalid_parameter, error_missing_information, error_no_network, error_none, error_not_allowed, error_not_found, error_not_supported, error_partner_app_blocked, error_partner_app_signature_mismatch, error_partner_app_version_not_supported, error_partner_info_invalid, error_partner_not_approved, error_partner_sdk_api_level, error_partner_sdk_version_not_allowed, error_partner_service_type, error_registration_fail, error_sdk_not_supported_for_this_region, error_server_internal, error_server_no_response, error_service_id_invalid, error_service_not_approved_for_release, error_service_unavailable_for_this_region, error_spay_app_integrity_check_fail, error_spay_app_need_to_update, error_spay_connected_with_external_display, error_spay_fmm_lock, error_spay_internal, error_spay_pkg_not_found, error_spay_sdk_service_not_available, error_spay_setup_not_completed, error_unable_to_verify_caller, error_unauthorized_request_type, error_user_canceled, error_user_not_registered_for_debug, extra_accept_combo_card, extra_card_type, extra_country_code, extra_cpf_holder_name, extra_cpf_number, extra_cryptogram_type, extra_device_card_limit_reached, extra_device_type, extra_error_reason, extra_error_reason_message, extra_issuer_name, extra_issuer_pkgname, extra_last4_dpan, extra_last4_fpan, extra_member_id, extra_merchant_ref_id, extra_partner_name, extra_request_id, extra_require_cpf, extra_resolved_1, extra_resolved_2, extra_resolved_3, extra_resolved_4, extra_resolved_5, extra_resolved_6, extra_resolved_7, partner_service_type, spay_has_no_transit_card, spay_has_transit_card, spay_not_allowed_temporally, spay_not_ready, spay_not_supported, spay_ready, wallet_dm_id, wallet_user_id constructor summary constructors constructor description paymentmanager android content context context, partnerinfo partnerinfo constructor of paymentmanager class the caller should set a valid serviceid in partnerinfo method summary all methodsinstance methodsconcrete methods modifier and type method description void requestcardinfo android os bundle requestfilter, paymentmanager cardinfolistener listener api to request card information of the available cards for payment using samsung pay the partner app can use this api to query available cards user already has registered in samsung pay and decide whether to display samsung pay button or not on their application for example, if merchant app supports only one specific card brand, but the user has not registered any card with the brand, then merchant app decides not to display the samsung pay button with this query void startinapppaywithcustomsheet customsheetpaymentinfo customsheetpaymentinfo, paymentmanager customsheettransactioninfolistener listener api to request online in-app payment with samsung pay void startsimplepay cardinfo cardinfo, statuslistener listener api to request payment with simple pay using this api, partner app can start the samsung pay payment screen for a specific card for example, user can login to partner app example bank app , view the list of cards, and select a card which is already registered in samsung pay to make in-store payment void updatesheet customsheet sheet api to update sheet on the custom payment sheet void updatesheet customsheet sheet, int errorcode, string customerrormessage api to update sheet on the custom payment sheet and display a custom error message methods inherited from class com samsung android sdk samsungpay v2 spaysdk getversioncode, getversionname methods inherited from class java lang object equals, getclass, hashcode, notify, notifyall, tostring, wait, wait, wait field details extra_pay_operation_type public static final string extra_pay_operation_type key to represent start simple pay operation type the possible values are pay_operation_type_payment pay_operation_type_refund see also constant field values pay_operation_type_payment public static final string pay_operation_type_payment indicates start simple pay option to make payment see also constant field values pay_operation_type_refund public static final string pay_operation_type_refund indicates start simple pay option to make refund this is for korean issuers only see also constant field values extra_transaction_date public static final string extra_transaction_date key to represent transaction date value when start simple pay to refund this is for korean issuers only example value mapped with this key 201906211428 yyyymmddhhmm see also constant field values extra_transaction_number public static final string extra_transaction_number key to represent transaction number value when start simple pay to refund this is for korean issuers only maximum length is 14 see also constant field values extra_transaction_type public static final string extra_transaction_type key to represent transaction type the possible values are transaction_type_mst transaction_type_nfc see also constant field values transaction_type_mst public static final int transaction_type_mst indicates that transaction type is mst see also constant field values transaction_type_nfc public static final int transaction_type_nfc indicates that transaction type is nfc see also constant field values error_not_ready_payment public static final int error_not_ready_payment indicates that online payment is not ready to complete because of various types of errors for example, internal error, unexpected error from samsung pay app, and so on see also constant field values extra_logo_image_url public static final string extra_logo_image_url key to represent the url of partner logo image on simple pay image width max 330 pixels image height 72 pixels see also constant field values extra_key_test_mode public static final string extra_key_test_mode key to represent pg test mode to prevent payment transaction being processed if the value is true, samsung-pg interface server redirects payment info to test pg server this is only for pg-indirect model since api level 2 3 see also constant field values extra_key_additional_data public static final string extra_key_additional_data key to represent additional data partner can use this key to put tagged data to a bundle before sending to samsung pay since api level 2 4 see also constant field values extra_key_card_brand_filter public static final string extra_key_card_brand_filter key to represent request card filter list partner can use this key to put filter into bundle for requestcardinfo bundle, cardinfolistener since api level 2 7 see also constant field values error_transaction_timed_out public static final int error_transaction_timed_out indicates that online payment processing has timed out see also constant field values error_transaction_closed public static final int error_transaction_closed indicates that transaction ui has closed see also constant field values error_address_updated_time_out public static final int error_address_updated_time_out indicates that online payment address updating is timed out see also constant field values error_internal_address_updated public static final int error_internal_address_updated indicates address update internal error see also constant field values error_making_sheet_failed public static final int error_making_sheet_failed indicates that making sheet has failed see also constant field values error_spay_reset public static final int error_spay_reset indicates that spay will be reset see also constant field values error_shipping_address_invalid public static final int error_shipping_address_invalid the merchant can call the updateamountfailed int or updatesheet customsheet, int, string api with this error when the shipping address shared by samsung pay to the merchant is invalid see also constant field values error_shipping_address_unable_to_ship public static final int error_shipping_address_unable_to_ship the merchant can call the updateamountfailed int or updatesheet customsheet, int, string api with this error when the shipping address shared by samsung pay is not available for delivery by the merchant see also constant field values error_shipping_address_not_exist public static final int error_shipping_address_not_exist the merchant can call the updateamountfailed int or updatesheet customsheet, int, string api with this error when the shipping address shared by samsung pay does not exist see also constant field values error_billing_address_invalid public static final int error_billing_address_invalid the merchant can call the updateamountfailed int or updatesheet customsheet, int, string api with this error when the billing address shared by samsung pay to the merchant is invalid see also constant field values error_billing_address_not_exist public static final int error_billing_address_not_exist the merchant can call the updateamountfailed int or updatesheet customsheet, int, string api with this error when the billing address shared by samsung pay does not exist see also constant field values custom_message public static final int custom_message the merchant can call the updatesheet customsheet, int, string api with this error when it wants to display a custom error message on customsheet see also constant field values error_card_not_supported_online_pay public static final int error_card_not_supported_online_pay indicates that this card does not support online pay since api level 2 5 see also constant field values constructor details paymentmanager public paymentmanager android content context context, partnerinfo partnerinfo constructor of paymentmanager class the caller should set a valid serviceid in partnerinfo partnerinfo is passed to samsung pay for caller 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 ; paymentmanager paymentmanager = new paymentmanager ct, pinfo ; parameters context - activity context or service context partnerinfo - partner information throws nullpointerexception - if the context or partnerinfo is null since api level 1 1 method details requestcardinfo public void requestcardinfo android os bundle requestfilter, paymentmanager cardinfolistener listener api to request card information of the available cards for payment using samsung pay the partner app can use this api to query available cards user already has registered in samsung pay and decide whether to display samsung pay button or not on their application for example, if merchant app supports only one specific card brand, but the user has not registered any card with the brand, then merchant app decides not to display the samsung pay button with this query // 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 ; paymentmanager paymentmanager = new paymentmanager context, pinfo ; boolean enablepaybutton = false; paymentmanager cardinfolistener cardinfolistener = new paymentmanager cardinfolistener { @override public void onresult list<cardinfo> cardlist { // cardinfo list for available cards if cardlist != null && cardlist size > 0 { // this means registered card s found in samsung pay for cardinfo cardinfo cardlist { if cardinfo getbrand == spaysdk brand abcd { enablepaybutton = true; break; } } } } @override public void onfailure 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 } }; bundle filter = new bundle ; arraylist<paymentmanager brand> list = new arraylist<> ; list add paymentmanager brand visa ; list add paymentmanager brand mastercard ; filter putparcelablearraylist paymentmanager extra_key_card_brand_filter, list ; paymentmanager requestcardinfo filter, cardinfolistener ; parameters requestfilter - filter to limit return cardinfo list this is optional parameter if the caller does not set any value, all the cards which are available for online in-app payment on samsung pay are returned listener - callback through which the result is provided on success, paymentmanager cardinfolistener onresult list is invoked with cardinfo list on any failure, the failure code is provided via paymentmanager cardinfolistener onfailure int, bundle note please refer spaysdk common_status_table in detail throws nullpointerexception - if the cardinfolistener is null since api level 1 1 updatesheet public void updatesheet customsheet sheet api to update sheet on the custom payment sheet @override public void oncardinfoupdated cardinfo selectedcardinfo, customsheet customsheet { amountboxcontrol amountboxcontrol = amountboxcontrol customsheet getsheetcontrol amount_control_id ; if amountboxcontrol == null { log d tag, "transaction failed / amountboxcontrol is null " ; return; } // you can set updated amount amountboxcontrol updatevalue product_item_id, 1000 ; amountboxcontrol updatevalue product_tax_id, 50 ; amountboxcontrol updatevalue product_shipping_id, 10 ; amountboxcontrol updatevalue product_fuel_id, 0, "pending" ; amountboxcontrol setamounttotal 1060, amountconstants format_total_price_only ; customsheet updatecontrol amountboxcontrol ; // call updatesheet api method with amountboxcontrol this is mandatory paymentmanager updatesheet customsheet ; } parameters sheet - customsheet is to be updated throws illegalstateexception - thrown if service is disconnected nullpointerexception - thrown if the sheetcontrol is null since api level 1 3 updatesheet public void updatesheet customsheet sheet, int errorcode, string customerrormessage api to update sheet on the custom payment sheet and display a custom error message @override public void oncardinfoupdated cardinfo selectedcardinfo, customsheet customsheet { amountboxcontrol amountboxcontrol = amountboxcontrol customsheet getsheetcontrol amount_control_id ; if amountboxcontrol == null { log d tag, "transaction failed / amountboxcontrol is null " ; return; } // you can set updated amount amountboxcontrol updatevalue product_item_id, 1000 ; amountboxcontrol updatevalue product_tax_id, 50 ; amountboxcontrol updatevalue product_shipping_id, 10 ; amountboxcontrol updatevalue product_fuel_id, 0, "pending" ; amountboxcontrol setamounttotal 1060, amountconstants format_total_price_only ; customsheet updatecontrol amountboxcontrol ; // if merchant want to display error message, call updatesheet api method with custom_message error code and text message paymentmanager updatesheet customsheet, paymentmanager custom_message, "phone number is not valid please change your phone number!" ; } parameters sheet - customsheet is to be updated errorcode - this code should be custom_message if merchant wants to use its own message customerrormessage - if errorcode is set to custom_message then this parameter will be used to display the message on the payment sheet, else it will be ignored throws illegalstateexception - thrown if service is disconnected nullpointerexception - thrown if the sheetcontrol is null since api level 1 5 startsimplepay public void startsimplepay cardinfo cardinfo, statuslistener listener api to request payment with simple pay using this api, partner app can start the samsung pay payment screen for a specific card for example, user can login to partner app example bank app , view the list of cards, and select a card which is already registered in samsung pay to make in-store payment samsung pay is launched with the selected card for payment the user can authenticate and start the payment partner app needs to obtain an usage permission of startsimplepay api in server-side without the permission, calling of startsimplepay api would be failed // 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 app2app tostring ; partnerinfo pinfo = new partnerinfo serviceid, bundle ; paymentmanager paymentmanager = new paymentmanager context, pinfo ; string cardid = "cardid_test"; bundle metadata = new bundle ; // // set values in metadata bundle // cardinfo cardinfo = new cardinfo builder setcardid cardid setcardmetadata metadata build ; paymentmanager startsimplepay cardinfo, new statuslistener { @override public void onsuccess int status, bundle data { // called when start samsung pay simple pay is showed to user with specified card log d tag, "simple pay is shown" ; } @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 } } ; how to set metadata in cardinfo - case 1 requesting in-store payment metadata putstring paymentmanager extra_pay_operation_type, paymentmanager pay_operation_type_payment ; metadata putstring paymentmanager extra_issuer_name, "issuername_test" ; metadata putint paymentmanager extra_transaction_type, paymentmanager transaction_type_mst | paymentmanager transaction_type_nfc ; // set logo image and background color for simple pay screen metadata putstring paymentmanager extra_logo_image_url, "http //testbank com/logo png" ; - case 2 requesting refund for in-store payment for korean issuers only metadata putstring paymentmanager extra_pay_operation_type, paymentmanager pay_operation_type_refund ; metadata putstring paymentmanager extra_issuer_name, "issuername" ; metadata putstring paymentmanager extra_transaction_date, "yyyymmddhhmm" ; metadata putstring paymentmanager extra_transaction_number, "1234567890" ; metadata putint paymentmanager extra_transaction_type, paymentmanager transaction_type_mst | paymentmanager transaction_type_nfc ; parameters cardinfo - card information to pay cardmetadata bundle key-value pairs can be defined as follows keys values samsungpay#extra_issuer_name string issuername issuercode for korean issuers extra_pay_operation_type pay_operation_type_payment pay_operation_type_refund for korean issuers only extra_transaction_type - for korean issuers effective as requested - for other country issuers effective depends on device configuration i e in uk, only nfc supported or card meta-data token profile from card network transaction_type_mst transaction_type_nfc transaction_type_mst | transaction_type_nfc extra_transaction_date string transaction date for refund for korean issuers only extra_transaction_number string transaction number for refund for korean issuers only extra_logo_image_url string issuer logo image url listener - statuslistener instance callback through which the result is provided on success, statuslistener onsuccess int status, bundle data is invoked with spaysdk error_none status code 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 cardinfo or statuslistener is null illegalargumentexception - thrown if cardinfo getcardmetadata does not have extra_pay_operation_type and extra_transaction_type since api level 1 1 startinapppaywithcustomsheet public void startinapppaywithcustomsheet customsheetpaymentinfo customsheetpaymentinfo, paymentmanager customsheettransactioninfolistener listener api to request online in-app payment with samsung pay partner app can use this api to make in-app purchase using samsung pay from their application with custom payment sheet you can refer to startinapppay paymentinfo, transactioninfolistener in case of normal payment sheet // create {@link customsheet} to contain sheetcontrols customsheet sheet = new customsheet ; // make sheetcontrols you want and add to custom sheet // each sheetcontrol is located in sequence // there must be a amountboxcontrol and it must be located on last // add {@link addresscontrol} on custom payment sheet sheet addcontrol new addresscontrol ; // add {@link plaintextcontrol} on custom payment sheet sheet addcontrol new plaintextcontrol ; // add {@link spinnercontrol} on custom payment sheet sheet addcontrol new spinnercontrol ; // add {@link amountboxcontrol} on custom payment sheet sheet addcontrol new amountboxcontrol ; // create {@link customsheetpaymentinfo} with in-app details customsheetpaymentinfo custompaymentreq = new customsheetpaymentinfo builder setmerchantid merchantid setmerchantname merchantname setordernumber ordernumber // the allowed characters are [a-z][a-z][0-9,-] & up to 36 characters setpaymentprotocol protocol setaddressinpaymentsheet addressinpaymentsheet setallowedcardbrands brandlist setcardholdernameenabled iscardholdernameenabled setcustomsheet sheet // 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 ; // create {@link paymentmanager#paymentmanager context, partnerinfo } paymentmanager paymentmanger = new paymentmanager this, pinfo ; // set {@link customsheettransactioninfolistener} paymentmanager customsheettransactioninfolistener transactionlistener = new paymentmanager customsheettransactioninfolistener { @override public void oncardinfoupdated cardinfo selectedcardinfo, customsheet customsheet { log d tag, "oncardinfoupdated" ; // called when the user changes the card in samsung pay // newly selected cardinfo is passed and partner app // can update transaction amount based on new card if needed } @override public void onsuccess customsheetpaymentinfo customsheetpaymentinfo, string paymentcredential, bundle extrapaymentdata { log d tag, "transaction successfully received paymentcredential from samsung pay" ; // called when samsung pay able to create in-app cryptogram successfully // partner app will send this cryptogram to partner server/payment gateway and complete // in-app payment } @override public void onfailure 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 } } // execute startinapppaywithcustomsheet to show custom payment sheet try { paymentmanger startinapppaywithcustomsheet custompaymentreq, transactionlistener ; } catch nullpointerexception e | illegalstateexception e | illegalargumentexception e { e printstacktrace ; } parameters customsheetpaymentinfo - custom sheet and payment information from partner app merchant app listener - callback through which the result is provided on success, paymentmanager customsheettransactioninfolistener onsuccess customsheetpaymentinfo, string, bundle is invoked with payment credential paymentmanager customsheettransactioninfolistener oncardinfoupdated cardinfo, customsheet is invoked when user changes the card on the payment sheet in samsung pay on any failure, the failure error code and error data are provided via paymentmanager customsheettransactioninfolistener onfailure int, bundle the failure code can be one of the following codes with bundle data status spaysdk error_user_canceled -7 spaysdk error_duplicated_sdk_api_called -105 error_not_ready_payment -108 error_transaction_timed_out -111 error_transaction_closed -112 error_card_not_supported_online_pay -402 error_address_updated_time_out -113 error_making_sheet_failed -115 note please refer spaysdk common_status_table for other status throws nullpointerexception - thrown if parameters are null illegalstateexception - thrown if samsung pay sdk service is not available illegalargumentexception - thrown if mandatory custom sheet information and payment information values are not set since api level 1 3 samsung electronics samsung pay sdk 2 19 00 - jun 12 2024