Skip to main content
The PurchaseInfo class contains all the necessary information about a transaction that needs to be processed through the Hubtel Checkout SDK.

Overview

This object encapsulates the purchase details including the amount to charge, customer information, and transaction references.

Properties

amount
double
required
The price of the item or service the customer is purchasing. This should be a positive decimal value representing the amount in the currency configured for your merchant account.
The amount should include any applicable taxes or fees you want to charge the customer.
customerPhoneNumber
String
required
The mobile number of the customer making the purchase. This number is used for mobile money payments and transaction notifications.
The phone number should be in a valid Ghanaian mobile number format (e.g., “0541234567”).
purchaseDescription
String
required
A description of what the customer is purchasing. This appears in the checkout interface and helps customers identify the transaction.
Use clear, descriptive text like “Premium Subscription” or “Camera Equipment” to help customers recognize the purchase.
clientReference
String
required
A unique reference identifier for this transaction from your system. This helps you track and reconcile payments with your internal records.
Ensure each transaction has a unique client reference to avoid duplicate payment processing.

Getters

customerMsisdn
String
A computed property that returns the formatted version of the customerPhoneNumber. This is used internally by the SDK for payment processing.

Usage Example

Here’s how to create a purchase info object:
import 'package:hubtel_merchant_checkout_sdk/hubtel_merchant_checkout_sdk.dart';
import 'package:uuid/uuid.dart';

final purchaseInfo = PurchaseInfo(
  amount: 0.1,
  customerPhoneNumber: '0541234567',
  clientReference: const Uuid().v4(),
  purchaseDescription: 'Camera',
);
The example uses the uuid package to generate a unique client reference. You can install it from pub.dev or use your own unique identifier generation method.

Complete Checkout Example

Combining PurchaseInfo with configuration to launch checkout:
import 'package:flutter/material.dart';
import 'package:hubtel_merchant_checkout_sdk/hubtel_merchant_checkout_sdk.dart';
import 'package:uuid/uuid.dart';

// Create configuration
final hubtelConfig = HubtelCheckoutConfiguration(
  merchantApiKey: "QTN1akQ1SzpiM2IxMjA1NTEwZmI0NjYzYTdiY2ZmZmUyNmQ1YmIzZA==",
  merchantID: "1122334",
  callbackUrl: "https://your-domain.com/payment/callback",
);

// Create purchase info
final purchaseInfo = PurchaseInfo(
  amount: 25.50,
  customerPhoneNumber: '0541234567',
  clientReference: const Uuid().v4(),
  purchaseDescription: 'Monthly Subscription',
);

// Launch checkout
final result = await Navigator.push(
  context,
  MaterialPageRoute(
    builder: (context) => CheckoutScreen(
      purchaseInfo: purchaseInfo,
      configuration: hubtelConfig,
    ),
  ),
);

Validation Tips

Amount Validation

Always validate that the amount is greater than zero before creating the purchase info.

Phone Number Format

Ensure the customer phone number is in the correct format and belongs to a supported network.

Unique References

Use UUID v4 or timestamp-based IDs to ensure each transaction has a unique client reference.

Description Length

Keep purchase descriptions concise but descriptive enough for customers to recognize the transaction.

Next Steps

After the checkout is complete, you’ll receive a Payment Status result that indicates whether the transaction was successful.

Build docs developers (and LLMs) love