Skip to main content

Overview

The JavaScript SDK lets you collect card payments inside your own web checkout. Customers stay on your site, and the card details are entered into secure Modulus-hosted fields that your page never touches. An integration has two pieces:

Payment Intents API

A server-side REST call that represents an amount the customer has agreed to pay. Your backend creates the intent with your secret key.

JavaScript SDK

A browser library that renders the card fields, runs 3D Secure, and confirms the payment with your publishable key.
Card data is entered into Modulus-hosted iframes. It never enters your frontend code or DOM.

End to end

How it works

1

Create a Payment Intent (server)

When the customer reaches checkout, your server calls Create a Payment Intent with the amount and currency, using your secret key. You receive an id and a client_secret.
2

Hand the intent to the browser

Pass the id and client_secret to your checkout page. Your server never sees card data from here on.
3

Mount the card fields

Load the SDK, initialize it with your publishable key, and mount the secure card fields into your checkout layout.
4

Confirm the payment

Call confirmPayment. The SDK collects the card securely, runs 3D Secure if the bank requires it, and resolves with the final result.

Prerequisites

You are provisioned two keys at onboarding, with separate sandbox and live sets:

Base URLs

This documentation targets the sandbox environment. Use keys provisioned for sandbox; no real money is moved. See Testing for the sandbox card numbers. Amounts are integers in the currency’s smallest unit (for PHP, centavos).