Create payment refund¶
POST
https://api.mollie.com/v2/payments/*id*/refunds
Creates a refund for a specific payment. The refunded amount is credited to your customer usually either via a bank transfer or by refunding the amount to your customer’s credit card.
Parameters¶
Replace id
in the endpoint URL by the payment’s ID, for example v2/payments/tr_7UhSN1zuXS/refunds
.
amount
amount objectrequiredThe amount to refund. For some payments, it can be up to €25.00 more than the original transaction amount.
currency
stringrequiredvalue
stringrequireddescription
stringoptionalmetadata
mixedoptionalAccess token parameters¶
If you are using organization access tokens or are creating an
OAuth app, you can enable test mode through the testmode
parameter.
true
to refund a test mode payment.Mollie Connect parameters¶
With Mollie Connect you can split payments that are processed through your app across multiple connected accounts.
When creating full refunds for those split payments, you can use the reverseRouting
parameter to pull the split
payment back to the platform balance.
true
.
For example, if a €10,00 payment got split by sending €2,50 to the platform and €7,50 to the connected account, then
setting this parameter to true
will pull back the €7,50 from the connected account.When creating partial refunds for split payments, you should instead use the routingReversals
array to set the
amount that you want to pull back from the single routes.
If a routing reversals array is supplied, it must contain one or more routing objects with the following parameters:
amount
amount objectconditionalThe routing reversal object must indicate what portion of the originally routed amount is being reversed.
currency
stringrequiredEUR
payments can be
routed.value
stringrequiredsource
objectconditionalThe source of this portion of the route.
type
stringrequiredThe type of source. Currently only the source type organization
is supported.
Possible values: organization
organizationId
stringrequiredRequired for source type organization
. The ID of the connected organization the funds
should reversed from, for example org_12345
.
Note: me
or the ID of the current organization are not accepted as an organizationId
.
To learn more about creating refunds for split payments, refer to the Refunds and chargebacks for split payments guide.
Example¶
1 2 3 4 5 | curl -X POST https://api.mollie.com/v2/payments/tr_WDqYK6vllg/refunds \ -H "Authorization: Bearer test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM" \ -d "amount[currency]=EUR" \ -d "amount[value]=5.95" \ -d "metadata={\"bookkeeping_id\": 12345}" |
1 2 3 4 5 6 7 8 9 10 11 | <?php $mollie = new \Mollie\Api\MollieApiClient(); $mollie->setApiKey("test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"); $payment = $mollie->payments->get("tr_WDqYK6vllg"); $refund = $payment->refund([ "amount" => [ "currency" => "EUR", "value" => "5.95" // You must send the correct number of decimals, thus we enforce the use of strings ] ]); |
1 2 3 4 5 6 7 8 9 10 11 12 | from mollie.api.client import Client mollie_client = Client() mollie_client.set_api_key("test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM") payment = mollie_client.payments.get("tr_WDqYK6vllg") refund = payment.refunds.create({ "amount": { "value": "5.95", "currency": "EUR", } }) |
1 2 3 4 5 6 7 8 9 10 11 | require 'mollie-api-ruby' Mollie::Client.configure do |config| config.api_key = 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM' end refund = Mollie::Payment::Refund.create( payment_id: 'tr_WDqYK6vllg', amount: { value: '5.00', currency: 'EUR' }, description: 'Example refund description' ) |
1 2 3 4 5 6 7 8 9 10 | const { createMollieClient } = require('@mollie/api-client'); const mollieClient = createMollieClient({ apiKey: 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM' }); const refund = await mollieClient.paymentRefunds.create({ paymentId: 'tr_WDqYK6vllg', amount: { value: '5.95', currency: 'EUR' } }); |
Response¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | HTTP/1.1 201 Created Content-Type: application/hal+json { "resource": "refund", "id": "re_4qqhO89gsT", "amount": { "currency": "EUR", "value": "5.95" }, "status": "pending", "createdAt": "2018-03-14T17:09:02.0Z", "description": "Order #33", "metadata": { "bookkeeping_id": 12345 }, "paymentId": "tr_WDqYK6vllg", "_links": { "self": { "href": "https://api.mollie.com/v2/payments/tr_WDqYK6vllg/refunds/re_4qqhO89gsT", "type": "application/hal+json" }, "payment": { "href": "https://api.mollie.com/v2/payments/tr_WDqYK6vllg", "type": "application/hal+json" }, "documentation": { "href": "https://docs.mollie.com/reference/v2/refunds-api/create-payment-refund", "type": "text/html" } } } |
Response (duplicate refund detected)¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | HTTP/1.1 409 Conflict Content-Type: application/hal+json { "status": 409, "title": "Conflict", "detail": "A duplicate refund has been detected", "_links": { "documentation": { "href": "https://docs.mollie.com/overview/handling-errors", "type": "text/html" } } } |