@nicotordev/flowcl-pagos
Version:
SDK en TypeScript para integrar pagos con la API de Flow.cl de manera sencilla y segura.
70 lines • 3.12 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
require("dotenv/config");
const flow_payments_1 = __importDefault(require("../clients/flow.payments"));
const flowIntegration_1 = require("../test-utils/flowIntegration");
let flowPayments;
(0, flowIntegration_1.describeFlowIntegration)('FlowPayments API Integration Tests', () => {
let token = '';
beforeAll(() => {
flowPayments = new flow_payments_1.default(flowIntegration_1.flowIntegrationConfig.apiKey, flowIntegration_1.flowIntegrationConfig.secretKey, flowIntegration_1.flowIntegrationConfig.baseUrl);
});
test('Crear pago en Flow', async () => {
const paymentData = {
commerceOrder: Date.now().toString(),
subject: 'Test de pago',
amount: 1000,
email: 'nicotordev@gmail.com',
urlReturn: 'https://nicotordev.com',
urlConfirmation: 'https://nicotordev.com/confirmation',
};
const response = await flowPayments.create(paymentData);
console.log('Crear Pago:', response);
expect(response).toHaveProperty('token');
expect(response).toHaveProperty('url');
token = response.token;
});
test('Consultar estado de pago por token', async () => {
const response = await flowPayments.status.byToken(token);
console.log('Estado del pago:', response);
expect(response).toHaveProperty('status');
});
test('Consultar pagos recibidos por fecha', async () => {
const aDayBefore = new Date();
aDayBefore.setDate(aDayBefore.getDate() - 1);
const requestData = {
date: aDayBefore.toISOString().split('T')[0],
};
const response = await flowPayments.listPaymentsByDate(requestData);
console.log('Pagos recibidos:', response);
expect(response).toHaveProperty('total');
});
test('Consultar transacciones recibidas por fecha', async () => {
const aDayBefore = new Date();
aDayBefore.setDate(aDayBefore.getDate() - 1);
const requestData = {
date: aDayBefore.toISOString().split('T')[0],
};
const response = await flowPayments.listTransactionsByDate(requestData);
console.log('Transacciones recibidas:', response);
expect(response).toHaveProperty('total');
});
test('Crear pago por email', async () => {
const emailPaymentData = {
commerceOrder: 'order-002',
subject: 'Cobro por email',
amount: 2000,
email: 'nicotordev@gmail.com',
urlReturn: 'https://www.google.com',
urlConfirmation: 'https://www.google.com',
};
const response = await flowPayments.createByEmail(emailPaymentData);
console.log('Pago por email:', response);
expect(response).toHaveProperty('token');
expect(response).toHaveProperty('url');
});
});
//# sourceMappingURL=flowPayments.test.js.map