> For the complete documentation index, see [llms.txt](https://docs.sensepass.com/sensepay/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sensepass.com/sensepay/transaction-api/sdk-and-iframes/javascript-ui-sdk/api/elements-sdk.md).

# Elements SDK

### Quick demo

Check out our demo page to see the flow in action.

{% embed url="<https://js.sandbox.sensepass.com/sp-ecom-elements-sdk.html>" %}

{% hint style="info" %}
This is a checkout page example with the Elements SDK.
{% endhint %}

***

<figure><img src="/files/25bJ4kotfOZAGfheBTqd" alt="" width="375"><figcaption></figcaption></figure>

### Configuration

{% hint style="info" %}
You can copy-paste the (relevant) following HTML code to your checkout page to get going.

* Note that the current widget configuration is set up to use the mock client-id - and replace it with yours.
  {% endhint %}

{% code lineNumbers="true" expandable="true" %}

```html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>SensePass Elements SDK</title>
    <!-- Set the SensePass SDK script -->
    <script src="https://js.sensepass.com/scripts/sensepass-front-end@1.1.1.sdk.js"></script>
</head>
<body style="width: 25rem; margin: 0 auto">
    <!-- Top Payment Button -->
    <button id="primary-payment-button" onclick="handlePaymentButtonClick()">Complete Payment (primary)</button>
    <!-- SensePass Elements Container -->
    <div id="sensepass-front-end"></div>
    <!-- Bottom Payment Button -->
    <button id="secondary-payment-button" onclick="handlePaymentButtonClick()">Complete Payment (secondary)</button>
    <script>
        // Configure the SDK
        const spClient = SensePassFrontEndSDK.config({
            mode: "sandbox", // "sandbox" | "production"
            debug: true,
            clientId: "SensePassSDKGeneralClientId",
            methodType: "manual_capture", // "manual_capture" | "authorize" | "tokenize"
            theme: {
                paymentMethodGrid: "vertical" // "horizontal" | "vertical" | "vertical-b"
            },
            payButtonId: ['primary-payment-button', 'secondary-payment-button'], // Array of button IDs
        });
        // Initialize the SDK
        const sensepass = spClient.init();
        // Event: Payment method selected
        sensepass.paymentSelected(payload => console.log('Payment method selected:', payload));
        // Event: Payment in progress
        sensepass.paying(payload => console.log('Payment in progress:', payload));
        // Event: Payment method validation status
        sensepass.paymentMethodValidationStatus(payload => console.log('Payment validation status:', payload));
        // Event: Error occurred
        sensepass.error(payload => console.error('SDK Error:', payload));

        function handlePaymentButtonClick() {
            // Call the pay method when button is clicked
            sensepass.pay(payload => console.log('Payment result:', payload),
                {
                    amount: 1299, // Amount in cents (12.99 USD)
                    currency: "USD",
                    billingAddress: {
                        city: "New York",
                        email: "demo@example.com",
                        firstName: "John",
                        lastName: "Doe",
                        street: "123 Demo St",
                        state: "NY",
                        zipcode: "10001",
                        mobilePhone: "5551234567",
                        country: "US"
                    }
                }
            );
        }
    </script>
</body>
</html>
```

{% endcode %}

***

### Payment Data

{% hint style="info" %}
Example of the SDK's "pay" callback payload (sets the payment for commit)
{% endhint %}

{% code lineNumbers="true" expandable="true" %}

```json
{
  "TransactionNumber": "7f943e53476a3efcc263d0f975a01c45a6118fc55852efde8dad7227",
  "status": 20
}
```

{% endcode %}

### Customization

{% hint style="info" %}
This code sample demonstrates how to customize the appearance of the Elements Widget's payment buttons/elements. \
Set this object in our SDK configuration to apply your custom theme.

Download and edit the following themes you wish to style on your own:

1. Material theme: <https://pay.sandbox.sensepass.com/publicAssets/themes/material.theme.css>
2. SensePass theme: [https://pay.sandbox.sensepass.com/publicAssets/themes/ecommerce.theme.css](https://pay.sandbox.sensepass.com/publicAssets/themes/material.theme.css)
3. Save your themes in a hosting site of your choosing and set their URL in the config JSON.
4. Use the [SDK Theme Config Model](https://docs.sensepass.com/sensepay/transaction-api/models/sdk-theme-config-model) to set you custom text and other UI configurations.
   {% endhint %}

{% code lineNumbers="true" %}

```javascript
SensePassFrontEndSDK.config({
   // ...,
   theme: { // optional theme for various packages
	/** angular material provides extensive documentation on customizing their theme
	* you can find it at: https://material.angular.io/guide/theming */
	material: "https://pay.sandbox.sensepass.com/publicAssets/themes/custom-sample-material.theme.css", // sample for a customized material theme
	sensepassEcommerce: "https://pay.sandbox.sensepass.com/publicAssets/themes/custom-sample-ecommerce.theme.css", // sample for a customized sensepass theme
	paymentMethodGrid: "horizontal", // horizontal | vertical style of the payment options
	config: {} // a configuration object for specific payment methods text/animations
   }
})
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.sensepass.com/sensepay/transaction-api/sdk-and-iframes/javascript-ui-sdk/api/elements-sdk.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
