Skip to main content

Get a payment

Reads back a payment by your reference: the reference you sent when you initiated the payment. Use it as a fallback when a notification did not reach you, to follow a PENDING payment, and to recover a payment when you did not receive the answer to the initiation.

For the concepts and the whole flow, see the Payment API guide.


Endpoint​

GET https://app.papi.mg/engine/api/v1/payments/{reference}

The endpoint returns the Payment object.

ItemValue
Base URLhttps://app.papi.mg/engine/api
Path/v1/payments/{reference}
MethodGET
Request bodyNone
Response bodyJSON

The same path is available in the sandbox environment.


Authentication​

Every request must carry your shop API key in the Token header. You find the API key in the dashboard: Avatar icon → Boutiques → select shop → Developer tab. It is the same key as for the payment link API.

The payment is searched inside the shop that the API key belongs to only. A payment of another shop gives 404.


Request headers​

HeaderRequiredValueDescription
Token✓<YOUR_API_KEY>API key of your shop.

The LinkToken header used by the payment page is not accepted as an authentication method.


Path parameters​

ParameterLocationTypeRequiredConstraintsDescription
referencePathstring✓URL-encode reserved characters.Your reference: the reference you sent when you initiated the payment. It is the merchantPaymentReference of the notification.

Papi's paymentReference is not a lookup key. It identifies one payment attempt in the responses and in the notification, but you read a payment with the reference you chose, which you know even when the initiation answer never reached you.

Which payment is returned​

Several payment attempts can share one reference (for example, a new attempt after a FAILED one, see Idempotency). The endpoint returns the payment that counts for this reference: the SUCCESS attempt if there is one, otherwise the latest attempt.


Request example​

curl -X GET "https://app.papi.mg/engine/api/v1/payments/ORDER-1042" \
-H "Token: <YOUR_API_KEY>"

Success response​

Status: 200 OK

{
"data": {
"papiPaymentReference": "b6d1…-uuid",
"reference": "ORDER-1042",
"paymentMethod": "MVOLA",
"paymentStatus": "PENDING",
"amount": 5000.0,
"payerFee": 0.0,
"totalAmount": 5000.0,
"currency": "MGA",
"description": "Commande 1042",
"clientName": "Ranaivo",
"payerEmail": "ranaivo@example.mg",
"phoneNumber": "+261 34 12 345 67",
"notificationUrl": "https://shop.example/papi/notify",
"notificationToken": "uuid",
"error": null,
"createdAt": 1790238788404,
"updatedAt": 1790238788404
}
}

Response fields​

The response contains the Payment object, with the same fields as the initiation response. When paymentStatus is FAILED, the error object gives the reason: see Failed payment.


Errors​

Error body format:

{
"error": {
"code": "<ERROR_CODE>",
"message": "<Human-readable message, in French>"
}
}
HTTP statusError codeMeaning
401CORE_PERM_0001The Token header is missing, or the API key is invalid (message: API key invalide).
404PAYMENT_NOT_FOUNDNo payment with this reference exists in your shop. A payment of another shop also gives 404.

Practical notes​

Recovering a missed notification​

Rely on the notification sent to your notificationUrl. If it did not reach you:

  1. Call GET /v1/payments/{reference} with your reference.
  2. If paymentStatus is SUCCESS, confirm the order.
  3. If paymentStatus is PENDING, call the endpoint again later.
  4. If paymentStatus is FAILED, keep the order unpaid. The payer can try again: see Idempotency.

Recovering a lost initiation answer​

If you did not receive the answer to POST /v1/payments (timeout, dropped connection), call GET /v1/payments/{reference} with your reference. A 404 means that no payment was created: you can initiate the payment. You can also send the same initiation request again, with the same body.

Polling​

This endpoint is a fallback, not a replacement for notifications. If you poll, space the calls out (for example, every few seconds while paymentStatus is PENDING) and stop when paymentStatus is SUCCESS or FAILED.