HomeGuidesReference↗ Forage Dashboard
Log In
Reference

Create a PaymentRefund

Refund Requests Must Be Server-Side

To keep your app secure, requests to create a PaymentRefund should only be generated on the server-side.

API Version Requirements

You must use Forage version 2024-01-08 or higher for this endpoint to return populated receipt data. Earlier versions return the receipt value as null, so to retrieve the data you need to send GET requests to /payments/{payment_ref}/refunds/{refund_ref}/ until the status of the refund is succeeded.

A POST request to /payments/{payment_ref}/refunds/ tells Forage’s servers to refund an existing Payment object. Funds are refunded to the originally charged PaymentMethod.

On success, Forage automatically begins processing the refund, so this request has immediate financial side effects.

The API responds with a Forage PaymentRefund object that represents the transaction and an HTTP 201 status code.

Deferred refunds

ForageTerminalSDK integrations use this endpoint to complete deferred refunds. Here are the steps:

  1. Collect the customer's PIN using Forage’s POS SDK.
  2. At the appropriate point in your refund workflow, call this endpoint to initiate the refund.
  3. If an error occurs (e.g., an Invalid PIN), relay the message back to the POS client immediately so the user is notified promptly.

HTTP 201

HTTP 201 is returned even if the refund attempt fails because Forage creates a PaymentRefund object to preserve a record of the refund regardless of the transaction outcome. To confirm that the outcome is a success, check that the status of the PaymentRefund is succeeded.

If the status is failed, then for Forage version 2024-01-08 or higher inspect the receipt.message field of the response for a description of the error. For earlier Forage versions, send a GET to /payments/{payment_ref}/refunds/ to retrieve updated receipt data.

Path Params
string
required
Defaults to cc3175bfea

A unique reference hash for the Forage Payment object, returned when the original Payment was created.

Body Params

Pass the following fields in the body of the request to /payments/{payment_ref}/refunds/ to initiate a PaymentRefund.

number
required
Defaults to 25.99

A positive decimal number that represents how much of the Payment to refund in USD. If a partial refund, then this value does not need to equal the amount field of the original Payment. Precision is supported to the penny.

The minimum amount that can be refunded is 0.01.

string
required
Defaults to Order could not be delivered

A string that describes why the Payment is to be refunded.

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.

Personally Identifiable Information

Do not include personally identifiable information (PII) such as names, emails, or payment details.

number

The fixed amount in USD that should be restored to the merchant from EBT Cash payments prior to splitting by the platform_fee. Precision is supported to the penny.

number

The fixed amount in USD that should be restored to the platform from EBT Cash payments prior to splitting by the platform_fee. Precision is supported to the penny.

string
length ≤ 64

A unique identifier for the order as created by the merchant or platform (not Forage).

When a merchant or platform passes this order ID to Forage, it persists in each Forage transaction related to the Order. This field enables merchants to map order IDs in their system to corresponding Forage Order IDs.

You must build with Forage Version 2023-05-15 or later to use external_order_id. Either pass 2023-05-15 as the API-Version header on a per request basis, or set the version for all requests in the Forage dashboard.

pos_terminal
object

⚠️  This param is required for POS Terminal refunds. It is not supported for online-only.

An object that details information about the POS Terminal that processed the payment.

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
URL
LoadingLoading…
Response
Choose an example:
application/json