← All projects

flutter

  • Dart 100%
git@gitlab.com:aice-lab/payment/flutter.git

Latest commit

a81ace89 ·

README

aice_payment

Dart client SDK for the AiCE-Lab payment service. Pure-Dart (no Flutter SDK dependency) — usable in Flutter apps and plain Dart projects.

Installation

dependencies:
  aice_payment:
    git:
      url: git@gitlab.com:aice-lab/payment/flutter.git
      ref: main

Quickstart

import 'package:aice_payment/aice_payment.dart';

final client = HttpPaymentClient(
  baseUrl: 'https://pay.aice-lab.com',
  apiKey: 'your-api-key',
);

// Create a checkout
final checkout = await client.createCheckout(
  CheckoutRequest(
    orderRef: 'order-123',
    gateway: 'bkash',
    amountMinor: 100000, // 1000.00 BDT in paisa
    currency: 'BDT',
    customer: {'name': 'Alice', 'phone': '+8801...'},
    returnUrls: {'success': 'https://yourapp.com/success'},
  ),
);
// Redirect the user to checkout.redirectUrl

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

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

Error handling

All methods throw [PaymentException] or a subclass:

ExceptionTrigger
UnauthorizedException401 — invalid API key
NotFoundException404 — resource not found
ConflictException409 — e.g. already refunded
AmountMismatchException400 with amount_mismatch error code
BadRequestException400 (other)
GatewayUnavailableException503 — check .retryAfterSeconds
TransportExceptionDNS/TLS/connection failure

Testing

Use MockPaymentClient so tests need no network:

import 'package:aice_payment/aice_payment.dart';

final mock = MockPaymentClient();
// Records last call; returns sensible defaults.
// Override behavior:
mock.onCreateCheckout = (_) => throw ConflictException('already exists');

Inject http.MockClient from package:http/testing.dart to test HttpPaymentClient itself (see test/payment_client_test.dart).

License

FSL-1.1-Apache-2.0 — see LICENSE.

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