← All projects

rn

  • TypeScript 95.59%
  • JavaScript 4.41%
git@gitlab.com:aice-lab/payment/rn.git

Latest commit

e4e5b0ce ·

README

@aice-lab/payment-rn

React Native (TypeScript) client SDK for the AiCE-Lab payment service.

Installation

npm install @aice-lab/payment-rn

Usage

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

const client = new HttpPaymentClient({
  baseUrl: 'https://pay.example.com',
  apiKey: 'your-api-key',
});

// Create a checkout
const { transactionId, redirectUrl } = await client.createCheckout({
  orderRef: 'ORD-001',
  gateway: 'bkash',
  amountMinor: 50000, // 500 BDT in poisha
  currency: 'BDT',
  returnUrls: { success: 'myapp://payment/success', cancel: 'myapp://payment/cancel' },
});

// Poll a transaction
const tx = await client.getTransaction(transactionId);
if (tx.isSucceeded()) { /* ... */ }

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

Testing

Use MockPaymentClient to stub the client in consumer tests without network calls:

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

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

Errors

All methods throw a PaymentError subclass on failure:

ClassStatus
UnauthorizedError401
NotFoundError404
ConflictError409
AmountMismatchError400 + amount_mismatch
BadRequestError400
GatewayUnavailableError503 (has retryAfterSeconds)
TransportErrornetwork failure

License

FSL-1.1-Apache-2.0 — see LICENSE.

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