Skip to main content

Overview

PurchaseInfo encapsulates all the necessary information about a purchase transaction, including the amount, customer details, and transaction references.

Constructor

PurchaseInfo({
  required double amount,
  required String customerPhoneNumber,
  required String purchaseDescription,
  required String clientReference,
})

Parameters

amount
double
required
The total amount to be charged for this purchase. Should be a positive number.
customerPhoneNumber
String
required
The customer’s phone number in Ghanaian format (e.g., ‘0241234567’ or ‘233241234567’). This is used for mobile money payments and customer identification.
purchaseDescription
String
required
A description of what the customer is purchasing. This appears in transaction records and receipts.
clientReference
String
required
Your unique reference ID for this transaction. Use this to track and reconcile payments in your system.

Properties

amount
double
The purchase amount to be charged.
customerPhoneNumber
String
The customer’s phone number as provided.
purchaseDescription
String
Description of the purchase.
clientReference
String
Your unique transaction reference ID.
customerMsisdn
String
A getter that returns the formatted customer phone number in MSISDN format. This is automatically generated from customerPhoneNumber.

Usage Example

import 'package:hubtel_merchant_checkout_sdk/hubtel_merchant_checkout_sdk.dart';

// Create purchase information
final purchaseInfo = PurchaseInfo(
  amount: 250.00,
  customerPhoneNumber: '0241234567',
  purchaseDescription: 'Premium subscription - Monthly',
  clientReference: 'ORDER-2024-001',
);

// Use in checkout
CheckoutScreen(
  purchaseInfo: purchaseInfo,
  configuration: configuration,
);

Phone Number Format

The customerPhoneNumber accepts various Ghanaian phone number formats:
  • 0241234567 - Local format
  • 233241234567 - International format without plus
  • +233241234567 - International format with plus
The SDK automatically formats these into the correct MSISDN format via the customerMsisdn getter.

Client Reference Best Practices

Use a unique, traceable reference for each transaction to simplify reconciliation and customer support.
  • Make references unique across all transactions
  • Include identifiable information (order ID, customer ID, timestamp)
  • Keep references alphanumeric for compatibility
  • Store the reference in your database for transaction tracking
  • Examples: ORDER-123456, INV-2024-001, SUB-USER-789-20240315

Build docs developers (and LLMs) love