LogoLogo
  • Transaction API
    • Overview
    • Authentication
    • Payment Methods
    • Integrations
      • POS (In-Store)
      • E-commerce
    • Payment Flows
      • Create a transaction
        • Examples for POS (In-Store)
          • Basic Payment Request
          • Payment request with products
          • Payment request with callback
          • Payment request with POS Data
          • SMS Payment Request
          • Email Payment Request
          • Payment request with invoice
          • Payment request with receipt generated by SensePass
          • Payment request with receipt generated by the POS
        • Examples for e-commerce
          • Basic Payment Request
          • iFrame Example
          • Payment request with products
          • Payment request with callback
          • Payment request with website custom data
          • SMS Payment Request
          • Email Payment Request
          • Payment request with invoice
          • Payment request with receipt generated by SensePass
          • Payment request with receipt generated by the e-commerce platform
      • Transaction status
      • Authorization
      • Tokenization
      • Subscription
        • Fetch a subscription
        • Update a subscription
        • Subscription callbacks
      • Cancel a pending transaction
      • Refund a transaction
      • Pay by Credit Card
      • Credit by Credit Card
      • Payment Commit
      • Update a Transaction
    • Other Flows
      • Tags Pairing
      • Receipts
      • Customer Input
      • Token Migration
      • Create Dynamic QR
    • Terminal Agent
      • Installation
      • Pairing
      • Usage
        • Synchronous Payment
        • Real-time product information update
        • Get Last Transaction Status
        • Get Device ID
    • Settlement
    • API Notifications
      • Socket.IO Websockets
      • Callback/Webhook
      • Post Message
    • Flow Charts
      • Payment Flow
      • Transaction Status Flow
    • SDK & iFrames
      • JavaScript UI SDK
        • API
        • Commit Transaction
        • Custom SDK Style
        • Simulator
        • Manual Capture (deprecated)
      • E-commerce iFrame
      • POS iFrame
      • Credit Card iFrame
    • Models
      • Receipts Model
      • Metadata Model
      • SDK Theme Config Model
      • SDK Credit Card Field Model
      • Invoice Model
      • Product Model
      • Payment Details Model
      • Receipt Notifications Model
      • Payment Commit Model
      • Confirmation Model
      • Settlement Model
      • Subscription Model
      • Transaction Page Model
      • Transaction Model
      • Customer Input Model
      • Settlement Report Model
      • Customer Shipping/Billing Details Model
      • Additional Data Model
    • SOAP and XML
      • SOAP
      • XML
    • Testing
    • Postman
  • Partner API
    • Models
      • Onboarding Model
      • Onboarding Configuration Pages
      • Onboarding Status Model
    • SDK & iFrames
      • Onboarding iFrame
    • Flows
      • Create onboarding
      • Get Onboarding Configuration Page
      • Onboarding status
Powered by GitBook
On this page
  • Sample App
  • Script
  • Security
  • Using the JS API

Was this helpful?

Export as PDF
  1. Transaction API
  2. SDK & iFrames
  3. JavaScript UI SDK

API

Embed your website/checkout-page with our payments widget using our web-component or iframe SDK.

Last updated 29 days ago

Was this helpful?

Sample App

You can play around with the SDK in

The SDK exposes a few methods to let you operate the iFrame in various ways.

Script

iFrame SDK

Legacy industry standard, using an iframe embedded widget to handle payments SDK.


Add the following SDK and add it to your front-end website's scripts: https://js.sensepass.com/scripts/sensepass-front-end@1.0.9.sdk.js

<html>
<head>
    <script src="" type="application/javascript"></script>
</head>
</html>

SensePass Elements

Latest industry standard of , making our widget native to your web-page. No unnecessary pop-ups, easy-to-handle UI (CSS) & faster load-times thanks to native script caching.


Add the following SDK and add it to your front-end website's scripts: https://js.sensepass.com/scripts/sensepass-front-end@1.1.0.sdk.js

<html>
<head>
    <script src="" type="application/javascript"></script>
</head>
</html>

Security

  1. The frontend uses client ID that does not have permissions to payment except for initalizing the SDK

  2. The backend uses device ID / Merchant API Key / Branch API key for calling the

Using the JS API

Step 1 - Configuration

Create a global variable in your front-end website called SensePassFrontEndSDK.

Set the following configuration for the sandbox or production environment:

const spClient = SensePassFrontEndSDK.config({
   mode: "sandbox", // "sandbox" | "production"
   debug: true, // optional for logs
   visualizer: true, // optional visual logs, requires HTML with id="sensepass-front-end-visualizer"
   clientId: "aee8d2cdc1cb...", // Client ID
   methodType: "manual_capture", // type for the transaction, defaults to "manual_capture", enum: "manual_capture" | "tokenize" | "authorize"
   payButtonId: "my-payment-button" // id for the payment-button (element) the customer will click to start the payment process
});

Create an HTML element with the id sensepass-front-end.

Step 2 - Initiate the iFrame element

Initiate the iframe with the init method:

const sensepass = spClient.init();

You can also handle the SDK client from the global variable, e.g. SensePassFrontEndSDK.init()

  • There is an optional argument for the spClient.init(iframeContainerEl) to let you set the iframe's container-element directly. This is a replacement option for the element by id search for the sensepass-front-end value.

Step 3 - Style the frame dimensions (optional)

You can skip this implementation when using version 1.1.0 (beta)

Use the method frameDimensions to get the iframe's width & height value (in pixels). Assuming you have an element <div id="sensepass-front-end"></div> you may get its iFrame (as its first child element) and apply the following callback's dimensions:

const spFrontEndContainerEl = document.getElementById("sensepass-front-end");
const spFrontEndIframeEl = spFrontEndContainerEl.firstElementChild;
sensepass.frameDimensions((payload: any) => {
   if (payload) {
      const height = payload.height;
      const width = payload.width;
      spFrontEndIframeEl.style.height = `${height}px`;
      spFrontEndIframeEl.style.width = `${width}px`;
   }
});

Step 4 - Listen to callback events

Using the above example, you may hook on to the following callbacks aswell:

const callback = payload => console.log(payload);
sensepass.paymentSelected(callback); // get event for the payment method's selection
sensepass.paying(callback); // get event for the payment method in its paying-process
sensepass.paymentMethodValidationStatus(callback); // if a payment method has a validatable state, always updates you on it.
sensepass.error(callback); // get various error messages for the payment attempts, transaction status and more...

Step 5 - Pay button event

Use the pay method to let the payment method trigger its payment request:

sensepass.pay(callback); // get a JSON of the transaction's final state

billingAddress object is optional

sensepass.pay(callback, 
{ 
    amount: 1099,   //Transaction amount in Cents (10.99 USD)
    currency: "USD",
    billingAddress: { //Optional
	city: "New York",
	email: "john@doe.com",
	firstName: "John",
	lastName: "Doe",
	street: "Baker St",
	state: "NY",
	zipcode: "12345",
	mobilePhone: "123456789",
	country: "US"
    }
});

Step 6 - Commit payment from your backend (Backend verification)

Pay button event - For manual capture transaction type -

SensePass's Front-end Playground website
web-components
commit API
see our docs here
See full details here