v1
latestOpenAPI 3.0.02026-07-244352379.2 KBCreate a Payment
⚠️ Payment Creation Must Be Server-Side
To keep your app secure, requests to create a Payment should only be generated on the server-side.
A POST request to /payments/ tells Forage’s servers how much to charge an existing PaymentMethod.
On success, the API responds with a Forage Payment object that represents the one-time charge. You need to pass the ref response value to an SDK function to authorize and capture the payment, one of:
- Forage JS: capturePayment()
- Android: capturePayment()
- iOS: capturePayment()
📘 Use customer_id When Creating Payments
Pass customer_id in the request to Create a Payment. customer_id helps Forage's servers more quickly identify and associate the correct customer with the Payment. While customer_id is not technically a required parameter, if you omit it then the request to create the Payment could take longer to process. It is strongly recommended to pass customer_id.
Each customer should only have one unique customer_id. For example, if you create both a Payment and a PaymentMethod for the same customer, then the customer_id should be the same in both requests to ensure continuity of stored payment methods.
⚠️ Payments Expire After 30 Minutes
Payment objects expire after 30 minutes. If a Payment is not captured or canceled within 30 minutes of when it's created, then it expires. To attempt the transaction again, create a new Payment.
Headers
An OAuth 2.0 authentication token that validates the request. Send a POST to the /o/token/ endpoint to generate an authentication token. Pass the token in this header after the word Bearer and a whitespace, for example Bearer <api_key>.
A unique merchant ID that Forage provides during onboarding, as in 123ab45c67. The Merchant ID can be found in the Forage sandbox or production dashboard.
An alphanumeric key that clients can use to identify repeated requests that are dropped in transit. Generate a distinct key for every unique request and only re-use keys for retries.
The Forage version, represented as a string with the format of a YYYY-MM-DD date.
If not specified in the request header, then the version defaults to the value set in the Forage dashboard.
Request body
Example request
{
"tpp_lookup_id": "pi_1DpdZq2eZvKYlo2CAYyzTr8j_secret_lxr4crBJP4txbrg7sqit0XQQO",
"external_location_id": "6e3b2ff7-51c8-4c64-befa-2eac90f7c3e9"
}Response
OK - Success
Example response
{
"amount": 25.99,
"funding_type": "ebt_snap",
"payment_method": "ac47392bb1",
"delivery_address": {
"city": "San Francisco",
"country": "US",
"line1": "1856 Market St.",
"zipcode": "94106",
"state": "CA"
},
"is_delivery": true,
"description": "An EBT Payment",
"metadata": {},
"platform_fee": 0.05,
"platform_fixed_settlement": 5.11,
"merchant_fixed_settlement": 5.95,
"customer_id": "cus_1234567890",
"external_order_id": "1f2ee410-5b47-4130-aec2-40f5eb2108f5",
"merchant_destination_account": "1bdefaa456",
"pos_terminal": {
"provider_terminal_id": "tbd123"
},
"external_location_id": "6e3b2ff7-51c8-4c64-befa-2eac90f7c3e9",
"ref": "cc3175bfea",
"merchant": "9000055",
"status": "requires_confirmation",
"created": "2021-06-16T00:11:50.000000Z-07:00",
"updated": "2021-06-16T00:11:50.000000Z-07:00",
"expires_at": "2021-06-16T00:41:50.000000Z-07:00",
"success_date": "2021-06-16T00:11:50.000000Z-07:00",
"refunds": [
"ac47392bb1"
],
"receipt": {
"ref_number": "cc3175bfea",
"is_voided": true,
"snap_amount": "25.99",
"ebt_cash_amount": "10.99",
"other_amount": "5.99",
"sales_tax_applied": "5.16",
"balance": {
"snap": "72.94",
"non_snap": "32.16",
"updated": "2021-06-16T00:11:50.000000Z-07:00"
},
"last_4": "3456",
"message": "Approved",
"transaction_type": "Payment",
"created": "2021-06-16T00:11:50.000000Z-07:00"
},
"last_processing_error": null,
"previous_errors": []
}