Skip to main content

redx_courier 0.0.1 copy "redx_courier: ^0.0.1" to clipboard
redx_courier: ^0.0.1 copied to clipboard

A Dart/Flutter client for the RedX (redx.com.bd) courier OpenAPI: create parcels, resolve delivery areas from a free-text address, and list your pickup stores (including the shop-ID vs pickup-store-ID [...]

example/example.dart

import 'package:redx_courier/redx_courier.dart';

Future<void> main() async {
  final client = RedxClient(accessToken: 'YOUR_REDX_ACCESS_TOKEN');

  // Always fetch your real pickup store ID like this - don't hardcode your
  // shop ID (the number in your merchant dashboard URL) as the pickup
  // store ID. They're different things on RedX's side, and using the
  // wrong one makes createParcel() fail with "Cannot read property
  // 'PHONE' of undefined".
  final stores = await client.getPickupStores();
  for (final store in stores) {
    print('${store.name} -> id: ${store.id}, phone: ${store.phone}');
  }

  if (stores.isEmpty) {
    print('No pickup stores found on this account - add one in the RedX '
        'merchant dashboard first.');
    return;
  }

  final pickupStoreId = stores.first.id;

  final area = await client.resolveAreaForAddress(
    districtName: 'Dhaka',
    customerAddress: 'House 5, Road 12, Gulshan 2, Dhaka',
  );

  if (area == null) {
    print('Could not confidently resolve a delivery area - ask the '
        'customer to pick one from client.getAreasByDistrict(...) '
        'instead.');
    return;
  }

  final result = await client.createParcel(
    RedxParcelRequest(
      customerName: 'Test Customer',
      customerPhone: normalizeBdPhoneForRedx('+8801712345678') ?? '',
      customerAddress: 'House 5, Road 12, Gulshan 2, Dhaka',
      areaId: area.id,
      areaName: area.name,
      merchantInvoiceId: 'INV-0001',
      cashCollectionAmount: 500,
      parcelWeight: 1,
      value: 500,
      itemName: 'Sample Item',
      pickupStoreId: pickupStoreId,
    ),
  );

  print('success: ${result.success}, tracking: ${result.trackingId}, '
      'message: ${result.message}');

  client.close();
}
1
likes
150
points
218
downloads

Documentation

API reference

Publisher

verified publishercarboncodes.net

Weekly Downloads

A Dart/Flutter client for the RedX (redx.com.bd) courier OpenAPI: create parcels, resolve delivery areas from a free-text address, and list your pickup stores (including the shop-ID vs pickup-store-ID distinction that trips up most first integrations).

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

http

More

Packages that depend on redx_courier