1.5.14The JS Payments SDK provides an easy and flexible way to integrate various payment methods into your JavaScript applications. It supports ACH, Credit Card, Debit Card, PayPal, and Apple Pay payment flows.
Sandbox environment JS SDK: https://sdk.embedded-payments.a.intuit.com/staging/embedded-payment-ui-sdk.en.js
Production environment JS SDK: https://sdk.embedded-payments.a.intuit.com/embedded-payment-ui-sdk.en.js
Before calling the render method, you need to include the SDK script in your HTML file: <script src="https://sdk.embedded-payments.a.intuit.com/staging/embedded-payment-ui-sdk.en.js"></script>.
const container = document.getElementById("iframe-container");
const submitButton = document.getElementById("submit-button");
let payPalIntuitTransactionId;
window.EmbeddedPayment.render({
sdkToken: "token", // Token provided to you by the integration administrator
env: "sandbox",
amount: 100,
companyName: "Foo Company Name",
companyWebsite: "foo.com",
payorName: "John Smith", // Optional, prepopulate CC/DC/ACH form
payorZip: "11111", // Optional, prepopulate CC/DC/ACH form
payorEmail: "foo@bar.com", // Payor email
companyId: "9341452559410447",
containerRef: container, // Element to render iframe
submitButtonRef: submitButton, // Element to listen for click events and replace for PayPal/Apple Pay
enabledPaymentMethods: ["card", "bank", "payPal", "venmo", "applePay"], // Order-specific, with the first one as the default.
mode: "payment", // Optional, default is "payment". Other options: "wallet-create", "wallet-edit"
style: "default", // Optional, default is "default". Other option: "nb44"
// savedWallet: { // Required when mode is "wallet-edit"
// id: "djQuMTo5MzQxNDUyNTU5NDEwNDQ3OmJlMzY5M2Q5NjU",
// maskedNumber: "xxxxxxxxxxxx1111",
// expYear: "2029",
// expMonth: "11",
// cardType: "VISA"
// }
onApprove: ({ transactionId }) => {
// Fires when any payment is completed, use it to show success screen
},
onError: (error) => {
// Handle error
// Fires when any error occurs, use it to show error message
},
onSubmitStart: ({ paymentMethod }) => {
// Handle submit start
// Fires when any payment submission starts, use it to disable the payment button
},
onSubmitEnd: ({ paymentMethod }) => {
// Handle submit end
// Fires when any payment submission finishes, use it to enable a payment button
},
handleSubmitPayment: async ({
tokenizedPaymentMethod, // defined only if `paymentMethod` is `card` or `bank`
paymentMethodType,
riskProfileToken,
applePayRequest // defined only if `paymentMethod` is `applePay`
}) => {
// Used for CC/DC/ACH/AP payments
// Should return { id } (or { transactionId } for backwards compatibility)
const response = await fetch("/order", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
tokenizedPaymentMethod,
paymentMethodType,
riskProfileToken,
applePayRequest
}),
});
const data = await response.json();
return { id: data.id };
},
handleCreateWallet: async ({
tokenizedPaymentMethod, // defined only if `paymentMethod` is `card` or `bank`
paymentMethodType,
riskProfileToken
}) => {
// Used for wallet creation
// Make API call to create new wallet
return { id: "wallet-id-123" };
},
handleEditWallet: async ({
tokenizedPaymentMethod, // defined only if `paymentMethod` is `card` or `bank`
paymentMethodType,
riskProfileToken,
savedWallet // contains the existing wallet information
}) => {
// Used for wallet editing
// Make API call to update existing wallet
return { id: savedWallet.id };
},
handlePayPalCreateOrder: async () => {
// Implementation of the /paypal-create-order API request to the Merchant Server
// Should save payPalIntuitTransactionId as a variable to be used later on the handlePayPalApproveOrder call
// Should return paypalOrderId as string
const response = await fetch("/initiate-paypal-payment", {
method: "POST",
headers: { "Content-Type": "application/json" },
});
const data = await response.json();
payPalIntuitTransactionId = data.payment_response.payment_instrument_details.order_id;
return payPalIntuitTransactionId;
},
handlePayPalApproveOrder: async () => {
// Implementation of the /order API request to the Merchant Server
// Should use previously saved payPalIntuitTransactionId
// Should return { id } (or { transactionId } for backwards compatibility)
const response = await fetch("/order", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
transactionId: payPalIntuitTransactionId,
}),
});
const data = await response.json();
return { id: data.id };
},
});
Renders the embedded payment iframe into the provided container element.
The JS Payments SDK provides an easy and flexible way to integrate various payment methods into your JavaScript applications. It supports ACH, Credit Card, Debit Card, PayPal, and Apple Pay payment flows.
(Object)
Configuration options for the payment SDK
| Name | Description |
|---|---|
options.sdkToken string
|
A token from the BE to be used for authentication of network calls |
options.env (
|
Use staging environment during development |
options.enabledPaymentMethods Array<PaymentMethod>
|
Order-specific, with the first one as the default |
options.containerRef HTMLElement
|
Element to render iframe |
options.submitButtonRef HTMLElement
|
Element to listen for click events and replace for PayPal/Apple Pay |
options.companyId string
|
Realm ID of the company in QBO |
options.payorEmail string
|
Payor email address |
options.amount number?
|
Amount of the payment in USD (required for Apple Pay) |
options.companyName string?
|
Name of the merchant (to be displayed inside the Apple Pay window) |
options.companyWebsite string?
|
Business name. May be used to differentiate between multiple domains to assign correct business name as dynamic_descriptor header on the BE to assign correct business name to the transaction. |
options.payorName string?
|
Payor's first name + last name to prepopulate CC/DC/ACH form |
options.payorZip string?
|
Payor's ZIP to prepopulate CC/DC/ACH form |
options.onApprove function ({transactionId: string}): void
|
Called after successful payment |
options.onError function (Error): void
|
Called in case of an error |
options.onSubmitStart function ({paymentMethod: PaymentMethod}): void?
|
Executed before payment started to process |
options.onSubmitEnd function ({paymentMethod: PaymentMethod}): void?
|
Executed after payment is submitted or in case of error, same as listening to onApprove and onError simultaneously |
options.handlePayPalCreateOrder function (): Promise<{orderId: string}>?
|
PayPal specific: Implementation of the /initiate-paypal-payment API request to the Merchant Server. Should save payPalIntuitTransactionId as a variable to be used later on the handlePayPalApproveOrder call. Should return paypalOrderId as string |
options.handlePayPalApproveOrder function (): Promise<{id: string}>?
|
PayPal specific: Implementation of the /payment API request to the Merchant Server. Should use previously saved payPalIntuitTransactionId. Should return { id } (or { transactionId } for backwards compatibility) |
options.onTaxCalculation function ({totalTaxRate: number}): void?
|
Callback for tax calculation results |
options.enableSalesTaxCalculation boolean
(default false)
|
Whether to enable sales tax calculation, if enabled onTaxCalculation callback is required. The tax is calculated based on the zip code provided in the options.payorZip parameter. |
options.enableCaptchaAndZeroDollarAuthForCard boolean
(default false)
|
Flag to enable both reCaptcha and validating credit card details by performing the $0 transaction invisible for the payor. |
options.onKeydownEscape function (): void?
|
Callback executed when the ESC key is pressed in the iframe. Useful for closing modals or handling escape key interactions. |
options.mode (
(default 'payment')
|
The mode of operation for the SDK. 'payment' for standard payment flows, 'wallet-create' for creating new wallets, 'wallet-edit' for editing existing wallets. |
options.savedWallet Object?
|
Required when mode is 'wallet-edit'. Contains the saved wallet information to edit. |
options.savedWallet.id string
|
The unique identifier of the saved wallet |
options.savedWallet.maskedNumber string
|
The masked card number (e.g., "xxxxxxxxxxxx1111") |
options.savedWallet.expYear string
|
The expiration year (e.g., "2029") |
options.savedWallet.expMonth string
|
The expiration month (e.g., "11") |
options.savedWallet.cardType string
|
The card type (e.g., "VISA") |
options.style (
(default 'default')
|
The style variant to apply to the payment UI. 'default' for standard styling, 'nb44' for custom NB44 styling. |
options.isZipCodeRequiredForCard boolean
(default true)
|
Defaults: true. If you have clients outside US please disable this flag to make the ZIP code field to be non required |
Updates the payment amount for the SDK instance.
This method allows you to dynamically update the payment amount after the SDK has been initialized. The amount is used specifically for Apple Pay transactions and should be in USD.
(number)
The new payment amount in USD
// Update the payment amount
EmbeddedPayment.updateAmount(150.00);
Updates the payor zip code for the SDK instance.
This method allows you to dynamically update the payor's zip code after the SDK has been initialized. The zip code will be updated in the payment form if the card payment method is active.
(string)
The new payor zip code
// Update the payor zip code
EmbeddedPayment.updatePayorZip("94043");