Skip to main content

Payment Intent Overview

Every payment in the H2H API starts with a payment intent. You create one by calling the same endpoint every time. What happens next depends on what you send.

One endpoint, two modes

ModeWhenWhat you get backWhat to do next
Direct chargeYou send network + account_numberA charge response with next_stepFollow the Direct Charge guide
StandardYou leave out network and account_numberA PaymentIntent objectComplete the payment via hosted checkout or your chosen payment method

The rule is simple: sending both network and account_number triggers a direct charge. If either is missing, you get a standard payment intent.

Most H2H partners use direct charge. Use standard mode when you do not know the customer's mobile money details yet, or when you want the customer to choose how to pay.

Creating a payment intent

curl -X POST "https://api.modempay.com/h2h/v1/payments" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"data": {
"amount": 10,
"currency": "GMD",
"network": "afrimoney",
"account_number": "7012345",
"external_reference": "order-1042",
"metadata": { "customer_id": "cus_889" },
"callback_url": "https://yourapp.com/payments/callback"
}
}'

Request fields

FieldRequiredMeaning
amountYesAmount to charge the customer
currencyYesCurrently "GMD"
networkFor direct chargeMobile money network: "wave", "afrimoney", "qmoney", or "aps"
account_numberFor direct chargeThe customer's mobile money number, in local format
external_referenceNoYour own reference (order ID, invoice number). Use it to match Modem Pay payments to records in your system
metadataNoKey-value pairs you want stored with the payment. Returned to you in responses and webhooks
callback_urlNoURL where Modem Pay sends the result of this payment
return_urlNoWhere the customer is sent after completing payment (standard mode / hosted flows)
cancel_urlNoWhere the customer is sent if they cancel (standard mode / hosted flows)

Tip: Always send external_reference. When you are reconciling payments later, it is much easier to search by your own order ID than by Modem Pay's IDs.

The response depends on the mode

Direct charge response

If you sent network and account_number, the response is a charge response with a transactionId and next_step telling you how to complete the payment. This is covered fully in the Direct Charge guide — read it before going live.

Standard response: the PaymentIntent object

If you did not trigger a direct charge, you get a PaymentIntent object.

The fields you will use:

FieldMeaning
idUnique ID of the payment intent. Save it
amount, currencyEcho of what you requested
type_of_payment"regular" or "direct" — which mode this intent used
is_sessiontrue means the customer completes payment through a hosted session
callback_urlThe URL you provided for result notifications
external_referenceYour reference, echoed back
metadataYour key-value pairs, echoed back

Fields for your records:

FieldMeaning
business_id, account_idThe partner business and account this payment belongs to
transaction_feeThe fee applied to this payment
usd_fx_rateExchange rate, present when currency conversion is involved
payment_metadataSystem-generated context about the payment
customer_nameCustomer name, when available for the flow used
payment_link_idPresent when the intent came from a payment link

You do not need most of the record fields to complete a payment. They exist for reporting and reconciliation.

Flow summary

  1. You create a payment intent (POST /h2h/v1/payments)
  2. Modem Pay validates the request and your authorization
  3. If network + account_number were sent → a direct mobile money charge starts. Follow Direct Charge
  4. If not → you get a PaymentIntent. Complete it through the hosted session or your chosen method
  5. The final result reaches you through your callback_url or webhooks

In both modes, the same rule from the Direct Charge guide applies: a payment is only successful when its status is completed.