Install and initialize
Install Pay.com.js via npm or CDN and initialize it with your merchant ID.
Install Pay.com.js and initialize it with your merchant ID before rendering Universal checkout, Headless checkout, or secure card fields.
Before you begin, retrieve these credentials from the Developers tab of the Pay.com dashboard:
- API key: Used on your server to create sessions. Never expose it in browser code.
- Merchant ID: Passed to
Pay.com({ identifier })in the browser.
Set up Pay.com.js
Install the package or load the script, then initialize it with your merchant ID.
- 1
Install Pay.com.js
Install
@pay-com/jswith npm or yarn, or load it from the CDN. Both provide the full SDK.Install the package with npm or yarn:
npm install --save @pay-com/js # or yarn add @pay-com/jsImport Pay.com.js in your module:
import Pay from '@pay-com/js'The package includes TypeScript definitions, so you can import types directly from
@pay-com/jswithout a separate@typespackage:import type { UniversalOpts } from '@pay-com/js' const style: UniversalOpts['style'] = { base: { fontFamily: "'Inter', sans-serif" } }UniversalOptsis the type of the options object you pass tocheckout.universal(). Typing yourstyleoverrides asUniversalOpts['style']gives you editor autocomplete before you pass them tocheckout.universal(). See Customize the checkout for usage. - 2
Initialize Pay.com.js
Initialize Pay.com.js with your merchant ID (
identifier) to obtain apayinstance. The payment session is attached later viaclientSecretinpay.checkout().With
@pay-com/js,Pay.com()returns a promise and defaults to the sandbox. Passlive: truein live.import Pay from '@pay-com/js' const pay = await Pay.com({ identifier: 'YOUR_MERCHANT_ID', // live: true, // Uncomment for live payments })
SDK architecture
Pay.com.js is organized around three objects (the top-level Pay module, a
pay instance returned by Pay.com(), and a
checkout instance returned by pay.checkout()).
Choose your integration mode
Continue with the guide for your checkout architecture:
Universal checkout
Pre-built hosted checkout form with card fields, wallets, and a submit button.
Headless checkout
Custom checkout UI backed by Pay.com.js submission methods.
Tokenize a card
Collect a card token without charging immediately.
Hybrid checkout
Combine hosted wallet buttons with a custom card form on one page.