Skip to main content
This walkthrough takes a card payment from start to finish: create an intent on your server, mount the card fields in the browser, and confirm.
1

Create a Payment Intent on your server

Call POST /payment-intents with your secret key when the customer reaches checkout. Amounts are integers in the currency’s smallest unit (for PHP, centavos).
The response returns the id and client_secret you hand to the browser:
See Create a Payment Intent for the full request and response.
2

Include the SDK

Load the library from the Modulus CDN with a single script tag. Load it from the CDN, do not self-host or bundle a copy, so you are always on the latest patched build.
You point at /v1, not a pinned version like /v1.4.2. Patches and backward-compatible fixes ship behind that same URL, so the browser always fetches the latest v1 build. The script exposes a global Modulus.
3

Initialize and mount the card fields

Construct Modulus with your publishable key, create an Elements group scoped to the intent, then mount the fields into placeholders on your page.
See Card fields for field types, styling, and events.
4

Confirm the payment

On submit, call confirmPayment with the mounted elements and the cardholder billing details. It collects the card securely, runs 3D Secure if required, and resolves once with the final result.
3D Secure runs inside confirmPayment for both flows: frictionless cards resolve without a challenge, and challenge cards render the bank’s step in your threeds-container. See 3D Secure for the container, window sizing, and lifecycle, and Confirm the payment for billingDetails and every result status.
Test the whole flow with the sandbox test cards. Use a 3DS challenge card to see the in-page authentication step, and a frictionless card to see a payment that authenticates with no customer interaction.