Create a custom payment sheet
create a custom payment sheet for a transaction request to manage the customer's payment through samsung pay, you must create a custom payment sheet that displays the payment details and allows the customer to select their card, define their shipping and billing address, and authorize the payment custom payment sheet structure the following code snippet shows the structure of the customsheetpaymentinfo class samsung pay sdk for android class customsheetpaymentinfo parcelable { private val version string? = null private val merchantid string? = null private val merchantname string? = null private val ordernumber string? = null private val addressinpaymentsheet addressinpaymentsheet = addressinpaymentsheet do_not_show private val allowedcardbrand list<spaysdk brand>? = null private val cardinfo cardinfo? = null private val iscardholdernamerequired = false private val isrecurring = false private val merchantcountrycode string? = null private val customsheet customsheet? = null private val extrapaymentinfo bundle? = null } samsung pay sdk for flutter string? merchantid; string merchantname; string? ordernumber; addressinpaymentsheet? addressinpaymentsheet; list<brand>? allowedcardbrand; paymentcardinfo? cardinfo; bool? iscardholdernamerequired; bool? isrecurring; string? merchantcountrycode; customsheet customsheet; map<string,dynamic>? extrapaymentinfo; the purpose of the customsheetpaymentinfo instance is both to display the payment details to the customer for their approval and to receive the final payment data from samsung pay after the customer has authorized the payment to initiate a payment transaction and display the payment details to the customer, populate the custom payment sheet fields, as defined in the following table field/data required/optional description merchantname required your name, as it will appear in samsung pay’s payment sheet as well as the customer's card account statement merchantid optional your payment gateway pg id as defined in the samsung pay portal if your pg uses direct network tokens, this field can be used for your designated purposes and you can define the value at your discretion the merchant id is mandatory for purchases with a mada card ordernumber optional order number, required for refunds and chargebacks for visa cards, the value is mandatory the value is usually created in interaction with a pg the value has the allowed characters [a-z][a-z][0-9,-] with the maximum length of 36 characters address optional customer's billing and/or shipping address, defined with dynamic payment sheet controls allowedcardbrand optional list of card brands you support if none are specified, all brands are accepted by default if at least one brand is specified, all non-specified card brands are set to "card not supported" on the payment sheet noteif you want to add any other information for any card brand, you can add it in the extrapaymentinfo bundle custom payment sheet controls in addition to the static fields, the custom payment sheet contains dynamic controls that you can use to modify the sheet details during the payment process the details can be modified by your app, the customer, or samsung pay the following details, for example, are provided as dynamic controls amount, containing the currency, item price, shipping price, tax, and total price that together make up the amount the customer is agreeing to pay you the amount control is required address, containing the customer's billing and/or shipping address the address control is optional the following code snippet is an example of using the amount control for more information on using dynamic controls, see samsung pay sdk for android sample app samsung pay sdk for android 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 } samsung pay sdk for flutter amountboxcontrol populate custom payment sheet the following code snippet is an example of populating the customsheetpaymentinfo object samsung pay sdk for android /* * create the customer's transaction details * your app should send customsheetpaymentinfo to the samsung wallet app using * the applicable samsung pay sdk for android method for the operation being invoked */ private fun makecustomsheetpaymentinfo customsheetpaymentinfo { val brandlist = arraylist<spaysdk brand> // if the supported brand is not specified, all card brands in the samsung wallet app are // listed in the payment sheet brandlist add paymentmanager brand visa brandlist add paymentmanager brand mastercard brandlist add paymentmanager brand americanexpress /* * create the sheetcontrols you want and add them to custom sheet * place each control in sequence, with amountboxcontrol listed last */ val customsheet = customsheet customsheet addcontrol makebillingaddresscontrol customsheet addcontrol makeshippingaddresscontrol customsheet addcontrol makeplaintextcontrol customsheet addcontrol makeshippingmethodspinnercontrol customsheet addcontrol makeamountcontrol val extrapaymentinfo = bundle /* * you can add transactiontype for the mada card brand * the supported values are purchase and preauthorization * if you do not set any value, the default value is purchase */ extrapaymentinfo putstring spaysdk extra_online_transaction_type, spaysdk transactiontype preauthorization tostring val customsheetpaymentinfo = customsheetpaymentinfo builder setmerchantid "123456" setmerchantname "sample merchant" // merchant requires billing address from the samsung wallet app and // sends the shipping address to the samsung wallet app // show both billing and shipping address on the payment sheet setaddressinpaymentsheet customsheetpaymentinfo addressinpaymentsheet need_billing_send_shipping setallowedcardbrands brandlist setcardholdernameenabled true setrecurringenabled false setcustomsheet customsheet setextrapaymentinfo extrapaymentinfo build return customsheetpaymentinfo } samsung pay sdk for flutter list<brand> brandlist = []; brandlist add brand visa ; brandlist add brand mastercard ; brandlist add brand americanexpress ; customsheetpaymentinfo customsheetpaymentinfo= customsheetpaymentinfo merchantname "merchantname", customsheet customsheet ; customsheetpaymentinfo setmerchantid "123456" ; customsheetpaymentinfo setmerchantname "sample merchant" ; customsheetpaymentinfo setaddressinpaymentsheet addressinpaymentsheet need_billing_send_shipping ; customsheetpaymentinfo setcardholdernameenabled true ; customsheetpaymentinfo setrecrringenabled false ; customsheetpaymentinfo setcustomsheet customsheet ; customsheetpaymentinfo allowedcardbrand = brandlist; return customsheetpaymentinfo;