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
}
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.
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.
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
}
We use cookies to improve your experience on our website and to show you relevant
advertising. Manage you settings for our cookies below.
Essential Cookies
These cookies are essential as they enable you to move around the website. This
category cannot be disabled.
Company
Domain
Samsung Electronics
developer.samsung.com, .samsung.com
Analytical/Performance Cookies
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.
Company
Domain
Samsung Electronics
.samsung.com
Functionality Cookies
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.
Company
Domain
Samsung Electronics
developer.samsung.com, google.account.samsung.com
Preferences Submitted
You have successfully updated your cookie preferences.