v1.0.1
SDK Deno para integração com o sistema de pagamentos **Vinti4Net** (SISP Cabo Verde)
Attributes
Includes Deno configuration
Repository
Current version released
6 months ago
Versions
Vinti4Net Pay Deno - Payment SDK
SDK Deno para integração com o sistema de pagamentos Vinti4Net (SISP Cabo Verde).
Permite criar pagamentos de compra, serviços, recargas e reembolsos de forma simples, com suporte a processamento de respostas do gateway.
Instalação
Importe direto pelo Deno:
import { Vinti4Net, PaymentRequest, PaymentResult } from "https://deno.land/x/vinti4net_paydeno/mod.ts";Exemplo de Uso
import { Vinti4Net, BillingInfo } from "https://deno.land/x/vinti4net_paydeno/mod.ts";
const client = new Vinti4Net("POS123", "AUTH456");
// Preparar pagamento de compra
const request: PaymentRequest = {
amount: 1000,
billing: {
email: "cliente@exemplo.com",
billAddrCountry: "132",
billAddrCity: "Praia",
billAddrLine1: "Rua Exemplo, 123",
}
};
client.preparePurchasePayment(request.amount, request.billing);
// Gerar formulário HTML para redirecionamento
const html = await client.createPaymentForm("https://meusite.cv/response");
console.log(html);Processando Resposta do Gateway
Ao receber a resposta POST do gateway, use processResponse para interpretar o resultado:
import { Vinti4Net } from "https://deno.land/x/vinti4net_paydeno/mod.ts";
const client = new Vinti4Net("POS123", "AUTH456");
// postData é o corpo recebido do gateway via POST
const result = client.processResponse(postData);
if(result.success){
console.log("Pagamento aprovado:", result.status, result.message);
} else {
console.log("Pagamento falhou:", result.status, result.message);
}O retorno é um objeto PaymentResult:
interface PaymentResult {
status: "SUCCESS" | "CANCELLED" | "DECLINED" | "ERROR" | "UNKNOWN";
message: string;
success: boolean;
data: Record<string, unknown>;
dcc?: {
currency: string;
rate?: string;
markup?: string;
transactionCurrency?: string;
} | null;
debug?: Record<string, unknown>;
}API
preparePurchasePayment(amount: number, billing: BillingInfo, currency?: string)prepareServicePayment(amount: number, entity: number, number: string)prepareRechargePayment(amount: number, entity: number, number: string)prepareRefundPayment(amount: number, merchantRef: string, merchantSession: string, transactionID: string, clearingPeriod: string)createPaymentForm(responseUrl: string, merchantRef?: string): Promise<string>processResponse(postData: Record<string, unknown>): PaymentResult
Tipos
PaymentRequest- dados usados para preparar um pagamentoPaymentResult- retorno do gateway após a transaçãoBillingInfo- informações do cliente para faturamentoPaymentStatus-"SUCCESS" | "CANCELLED" | "DECLINED" | "ERROR" | "UNKNOWN"
Contribuição
- Faça um fork
- Crie uma branch com sua feature (
git checkout -b feature/foo) - Commit suas alterações (
git commit -am 'Add foo') - Push para a branch (
git push origin feature/foo) - Abra um Pull Request
Licença
MIT © Eril TS Carvalho