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
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.
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”).
A description of what the customer is purchasing. This appears in the checkout interface and helps customers identify the transaction.
A unique reference identifier for this transaction from your system. This helps you track and reconcile payments with your internal records.
Getters
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: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
CombiningPurchaseInfo with configuration to launch checkout:
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.