If your site applies a Content Security Policy (CSP), add a nonce. The nonce is a unique, randomly generated value that you assign to script tags and the Samsung Pay configuration. It allows inline or injected content to execute when CSP rules are applied.
Generate a new nonce for each page load to maintain security.
const samsungPayClient = new SamsungPay.PaymentClient({environment: "STAGE", nonce: "your-randomly-generated-nonce"});
Step 4: Check Samsung Pay availability
Check whether Samsung Pay is supported for the current device, browser, and card brands. Call the isReadyToPay() method with the paymentMethods object. Only show the Samsung Pay button if response.result is true.
samsungPayClient.isReadyToPay(paymentMethods).then(function(response) {
if (response.result) {
// Show the payment button
}
}).catch(function(err) {
console.error(err);
});
Step 5: Show the Samsung Pay button
Show the Samsung Pay button on your page using the official branded asset.
NoteDownload the official button images and branding guidelines from the Downloads and resources page. Ensure that your implementation follows the branding requirements.
Call the loadPaymentSheet() method to launch the Web Checkout UI. After the customer confirms the payment from their device, the method returns the payment token (generated on the device) inside the paymentCredential object.
Extract the token from 3DS.data within the paymentCredential object, decrypt it, and process it with your payment gateway. The token decryption and processing must take place on the server side. For more details, see Decrypt payment credentials and the payment gateway documentation.
After the payment gateway confirms the payment result, call the notify() method with the paymentResult object to update the payment status in the Samsung server.
function onSamsungPayButtonClicked() {
samsungPayClient.loadPaymentSheet(paymentMethods, transactionDetail).then(function(paymentCredential) {
// Process payment with payment gateway
...
...
const paymentResult = {
"status": "CHARGED",
"provider": "PG Name"
}
samsungPayClient.notify(paymentResult);
}).catch(error => {
// Show error in developer console for debugging
console.error(err);
});
}
The following code snippet is an example of the returned paymentCredential object:
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.