@gatepayfe/pay-js
v0.0.4
Published
Gate Pay embedded cashier SDK for merchants — framework-agnostic, browser-only
Readme
@gatepayfe/pay-js
Gate Pay embedded cashier SDK for merchants. Framework-agnostic, browser-only.
Embed the Gate Pay checkout iframe in any web app (vanilla JS, Vue, Angular, React, etc.) via postMessage bridge.
Install
npm install @gatepayfe/pay-jsQuick start
<div id="checkout"></div>import { GatePay } from '@gatepayfe/pay-js'
const gp = GatePay({
clientId: 'your-client-id',
locale: 'en',
})
const element = gp.createPaymentElement({
clientSessionSecret: 'cs_xxx', // from your backend
onReady: () => console.log('checkout ready'),
onSuccess: result => console.log('paid', result),
onError: error => console.error(error),
})
element.mount('#checkout')API
GatePay(options)
| Option | Type | Required | Description |
|--------|------|----------|-------------|
| clientId | string | yes | Merchant client ID |
| locale | 'ar' \| 'br' \| 'cn' \| 'en' \| 'es' \| 'fr' \| 'id' \| 'ja' \| 'pt' \| 'ru' \| 'tw' \| 'uk' \| 'vn' | no | Global locale, default browser language |
Supported locale values:
| Code | Language |
|------|----------|
| ar | Arabic |
| br | Português (Brasil) |
| cn | 简体中文 |
| en | English |
| es | Español |
| fr | Français (Afrique) |
| id | Bahasa Indonesia |
| ja | 日本語 |
| pt | Português (Portugal) |
| ru | Русский |
| tw | 繁體中文 |
| uk | Українська |
| vn | Tiếng Việt |
createPaymentElement(options)
| Option | Type | Required | Description |
|--------|------|----------|-------------|
| clientSessionSecret | string | yes | Session secret from backend |
| paymentMethods | ('GatePay' \| 'Web3Pay')[] | no | Filter payment methods, default all |
| onReady | () => void | no | Iframe rendered |
| onSuccess | (result) => void | no | Payment / authorization succeeded |
| onCancel | () => void | no | User cancelled |
| onError | (error) => void | no | Payment failed |
| onExpired | () => void | no | Order expired |
| onSessionExpired | () => void | no | Session secret expired |
PaymentElementInstance
mount(target)— mount to CSS selector orHTMLElementunmount()— remove from DOMdestroy()— release all resourcesupdateLocale(locale)— switch language at runtime
React
For React apps, use @gatepayfe/pay-js-react.
License
UNLICENSED — contact Gate Pay for usage terms.
