@multimegas/sdk-js
v0.0.28
Published
Multimegas client SDK for JS/TS apps
Readme
@multimegas/sdk-js
Multimegas client SDK for JS/TS apps.
OpenPay integration
Use the OpenPay integration from:
sdk.integrations.openPay.createOpenpayToken(...)
You can configure OpenPay in two ways:
- Environment variables
- SDK constructor config
You can also mix both. Resolution priority is:
- Method override
- Constructor config (
openpay) - Environment variables
Required env vars
For OpenPay token creation you need:
OPENPAY_PUBLIC_KEY(required)OPENPAY_MERCHANT_ID(required ifOPENPAY_BASE_URLis not provided)OPENPAY_BASE_URL(optional; if missing, SDK buildshttps://sandbox-api.openpay.mx/v1/${OPENPAY_MERCHANT_ID})
Example .env:
OPENPAY_MERCHANT_ID=your_merchant_id
OPENPAY_PUBLIC_KEY=pk_your_public_key
# Optional
# OPENPAY_BASE_URL=https://sandbox-api.openpay.mx/v1/your_merchant_idConstructor config option
import { MultimegasClient } from '@multimegas/sdk-js';
const sdk = new MultimegasClient({
openpay: {
merchantId: 'your_merchant_id',
publicKey: 'pk_your_public_key',
// optional
// baseURL: 'https://sandbox-api.openpay.mx/v1/your_merchant_id',
},
});Create token example
const token = await sdk.integrations.openPay.createOpenpayToken({
card_number: '4111111111111111',
holder_name: 'Mauricio Adrian Pinon Islas',
expiration_year: '27',
expiration_month: '12',
cvv2: '110',
});
console.log(token.id);