Refund payments

To enable refunds, you need to provide a refund URL when you are confirming the payment through the payment endpoint.

If you do not provide this URL, it won't be possible to refund the order through the merchant dashboard. However, it is possible to update the order to include the refund URL after it has been confirmed. To do so, send it again through the payment endpoint.

When a refund is triggered, a webhook is sent to the provided URL. From there, you can process a refund with the payment gateway you chose, and return the refund ID. Doing so will allow us to update the order status and information inside the dashboard.

Serverless function example (Netlify functions/JavaScript)

exports.handler = async function (event, context, callback) {
  // Retrieve refund information
  const requestBody = JSON.parse(event.body);

  // Refund the order with the payment gateway here

  // Return successful status code
  return {
    statusCode: 200,
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ refundId: '<YOUR_REFUND_ID>' })
  };
}

Next up

→ Technical Reference

Was this article helpful?