JavaScript methods
samsung pay web checkout sdk exposes the following methods, which you can use to initiate and manage the checkout flow isreadytopay loadpaymentsheet notify isreadytopay the isreadytopay method performs a series of checks to determine whether the samsung pay button should be displayed it verifies device and platform compatibility, checks supported card brands, and, when used on a mobile website, detects whether the customer is using a samsung device syntax isreadytopay paymentmethods parameters field type required/optional description paymentmethods object required information used to verify device and browser compatibility with samsung pay for details, see paymentmethods return value resolves to the promise object that indicates whether samsung pay is supported the object contains the following fields field type required/optional description result boolean required whether the device supports samsung pay resultmessage string optional message that explains the compatibility verification result; for example, "invalid allowedbrands" or "not supported device" example const paymentmethods = { version "2", serviceid "dcc1cbb25d6a470bb42926", protocol "protocol_3ds", allowedbrands ["visa", "mastercard"] }; paymentclient isreadytopay paymentmethods then response => { if response result { console log "device is ready to pay with samsung pay " ; // proceed to load the payment sheet } else { console error "device is not ready ", response resultmessage ; // hide samsung pay button or show an alternative payment method } } catch error => { console error "error checking readiness ", error ; } ; loadpaymentsheet the loadpaymentsheet method initiates the samsung pay checkout flow it detects the customer’s context desktop browser, mobile browser, or android webview , displays the appropriate ui for payment authentication, and then returns the generated payment credentials syntax loadpaymentsheet paymentmethods, transactiondetail, modaloptions parameters field type required/optional description paymentmethods object required service-level configurations for the payment request for details, see paymentmethods transactiondetail object required transaction details for the purchase for details, see transactiondetail modaloptions object optional modal layout settings when the payment sheet is displayed on the desktop if omitted, default values are used for details, see modaloptions return value onsuccess resolves with the payment data returned from samsung pay the data includes encrypted payment credentials, and other relevant information required for payment processing onfailure rejects with an error object or message "user_cancel", "payment_error", "payment_timeout", "exceeded_retry_limit", "app_update_required" "fail" indicates a failure during the payment process with a message example const paymentmethods = { version "2 0", serviceid "your_service_id", protocol "protocol_3ds", allowedbrands ["visa", "mastercard"] }; const transactiondetail = { ordernumber "ord12345", merchant { name "my awesome store", url "https //myawesomestore com", countrycode "us" }, amount { option "format_total_price_only", currency "usd", total "10 99" } }; const modaloptions = { margin { top "10%", left "auto", bottom "10%", right "auto" } }; paymentclient loadpaymentsheet paymentmethod, transactiondetail, modaloptions then paymentdata => { console log "payment successful!", paymentdata ; // send paymentdata to your server to process with your payment gateway } catch error => { console error "payment failed or was cancelled ", error ; // handle the error e g , show a message to the customer } ; notify the notify method informs the samsung server of the payment status after the payment has processed through the payment gateway syntax notify paymentresult parameters field type required/optional description paymentresult object required status of the payment after the payment gateway has processed it for details, see paymentresult return value none example const paymentresult = { "status" "charged", "provider" "pg name" } samsungpayclient notify paymentresult ;