@axionenterprise/pay-sdk
v1.0.1
Published
Official Node.js SDK for AxionPAY API
Maintainers
Readme
@axionenterprise/pay-sdk
SDK oficial Node.js para a API https://pay.axionenterprise.cloud/.
Instalação
npm install @axionenterprise/pay-sdkInÃcio rápido (ESM)
import { AxionPay } from "@axionenterprise/pay-sdk";
const client = new AxionPay({
apiKey: process.env.AXION_PAY_API_KEY
});
const health = await client.health();
console.log(health);InÃcio rápido (CommonJS)
const { AxionPay } = require("@axionenterprise/pay-sdk");Configuração
baseUrl: URL base da API. Padrãohttps://pay.axionenterprise.cloud/apiapiKey: token de autenticaçãotimeoutMs: timeout por requisição em milissegundos. Padrão30000userAgent: User-Agent customizado da integração
Métodos principais
health()createCharge(payload)getChargeStatus(chargeId)cancelCharge(chargeId)createRefund(payload)listTransactions(query?)createWebhook(payload)listWebhooks()
const charge = await client.createCharge({
amount: 1000,
currency: "BRL",
customer: {
name: "Cliente Exemplo",
email: "[email protected]"
}
});
const chargeStatus = await client.getChargeStatus(charge.id);
const refund = await client.createRefund({ chargeId: charge.id, amount: 500 });
const txs = await client.listTransactions({ page: 1, status: "paid" });Métodos HTTP genéricos
request(path, options)get(path, options?)post(path, body, options?)put(path, body, options?)patch(path, body, options?)delete(path, options?)
Tratamento de erros
import { AxionPayError } from "@axionenterprise/pay-sdk";
try {
await client.listWebhooks();
} catch (error) {
if (error instanceof AxionPayError) {
console.log(error.status, error.code, error.message, error.details);
}
}