HomeGuidesReference↗ Forage Dashboard
Log In
Reference

Create refunds for specific products in an Order

Product Refunds Must Be Server-Side

To keep your app secure, requests to refund specific products should only be generated on the server-side.

A POST request to /orders/{order_ref}/refund_by_product/ creates refunds for specific products in an Order. It tells Forage's servers to create OrderRefund objects for the specified products and refund the appropriate amounts to their original payment methods. This request has immediate financial side effects.

On success, the API responds with an array of refund objects that represent the transactions and a 201 HTTP status code.

HTTP STATUS 201

This endpoint always returns a 201, even if some refund attempts fail, because Forage always creates refund objects to preserve a record of the attempted transactions. To make sure that the refunds were successful, check that the status of each refund is succeeded. Send periodic GET requests to /orders/{order_ref}/refunds/{refund_ref}/ to retrieve the updated objects. If the status is failed, then inspect the last_processing_error field of the response object for information about the error.

Webhooks For Refund Status Updates

Forage sends a REFUND_STATUS_UPDATED webhook when the status of a refund changes. Check out the guide to Forage webhooks for instructions on how to listen for the event.

Path Params
string
required

A unique reference hash for the Forage Order object, returned when the order's parent Session was created.

Body Params

Pass the below parameters to create refunds for specific products in an Order.

products
array of objects
required

A list of the products that need to be returned.

products*
string
required

A string that describes why the refund is happening.

metadata
object
required

A required object containing merchant-defined key-value pairs to provide additional context for the payment.

Merchants should use this field to store reference information relevant to the transaction (for example, order details, system identifiers, or tracking data). This helps link the payment to records within their system.

Pass an empty object ({}) if no additional information is available.

Headers
string
required

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>.

string
required

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.

string
required

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.

string

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.

Responses

Language
Credentials
OAuth2
URL
LoadingLoading…
Response
Choose an example:
application/json