← All projects

js

  • TypeScript 100%
  • Archived
git@gitlab.com:aice-lab/payment/js.git

Latest commit

b7333073 ·

README

⚠️ ARCHIVED — no active consumer (CORE-POLICY P5.5). Payment is a server-to-server API. Until a real consumer needs this language binding, it is not maintained. Integrate via the maintained clients — aice-lab/payment (node), payment/go, or aice-lab/payment (php) — or call the OpenAPI in payment/spec directly. This repo is unarchived the moment a consumer appears.

@aice-lab/payment-js

Browser TypeScript client SDK for the AiCE-Lab payment service.

Install

npm install @aice-lab/payment-js

Usage

import { HttpPaymentClient } from '@aice-lab/payment-js';

const client = new HttpPaymentClient({
  baseUrl: 'https://payment.aice-lab.org',
  apiKey: 'your-api-key',
});

// Create a checkout session
const checkout = await client.createCheckout({
  orderRef: 'ORD-001',
  gateway: 'bkash',
  amountMinor: 50000,   // 500.00 BDT in paisa
  currency: 'BDT',
  returnUrls: { success: 'https://app.example/ok', cancel: 'https://app.example/cancel' },
});
// Redirect the user to checkout.redirectUrl

// Retrieve a transaction
const tx = await client.getTransaction(checkout.transactionId);
if (tx.isSucceeded()) {
  // fulfil the order
}

// Refund
const refunded = await client.refund(tx.transactionId);

Testing

Import MockPaymentClient in your tests — no network required:

import { MockPaymentClient } from '@aice-lab/payment-js';

const mock = new MockPaymentClient();
// Optionally override behaviour:
mock.onCreateCheckout = () => ({ transactionId: 'test-tx', redirectUrl: 'https://mock' });

Errors

All errors extend PaymentError. Specific subclasses:

ClassTrigger
UnauthorizedError401
NotFoundError404
ConflictError409
AmountMismatchError400 + amount_mismatch
BadRequestError400
GatewayUnavailableError503 — check .retryAfterSeconds
TransportErrorNetwork failure before a response

License

FSL-1.1-Apache-2.0 — see LICENSE.

This is a snapshot generated from GitLab. For the live README, see the project page.