Cancel payment¶
Payments API v2
DELETE
https://api.mollie.com/v2/payments/*id*
Authentication:API keysOrganization access tokensApp access tokens
Some payment methods can be canceled by the merchant for a certain amount of time, usually until the
next business day. Or as long as the payment status is open
. Payments may be canceled manually
from the Mollie Dashboard, or programmatically by using this endpoint.
The isCancelable
property on the Payment object will indicate if the
payment can be canceled.
Parameters¶
Replace id
in the endpoint URL by the payment’s ID, for example tr_7UhSN1zuXS
.
Access token parameters¶
If you are using organization access tokens or are creating an
OAuth app, you can enable test mode through the testmode
parameter.
Set this to
true
to cancel a test mode payment.Example¶
cURLPHPPythonRubyNode.js
1 2 | curl -X DELETE https://api.mollie.com/v2/payments/tr_WDqYK6vllg \ -H "Authorization: Bearer test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM" |
1 2 3 4 | <?php $mollie = new \Mollie\Api\MollieApiClient(); $mollie->setApiKey("test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"); $canceled_payment = $mollie->payments->delete("tr_WDqYK6vllg"); |
1 2 3 4 5 6 | from mollie.api.client import Client mollie_client = Client() mollie_client.set_api_key("test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM") canceled_payment = mollie_client.payments.delete("tr_WDqYK6vllg") |
1 2 3 4 5 6 7 | require 'mollie-api-ruby' Mollie::Client.configure do |config| config.api_key = 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM' end canceled_payment = Mollie::Payment.cancel('tr_WDqYK6vllg') |
1 2 3 4 | const { createMollieClient } = require('@mollie/api-client'); const mollieClient = createMollieClient({ apiKey: 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM' }); const canceledPayment = await mollieClient.payments.cancel('tr_Eq8xzWUPA4'); |
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 33 34 35 36 37 38 39 40 41 | HTTP/1.1 200 OK Content-Type: application/hal+json { "resource": "payment", "id": "tr_WDqYK6vllg", "mode": "live", "createdAt": "2018-03-19T10:18:33+00:00", "amount": { "value": "35.07", "currency": "EUR" }, "description": "Order 33", "method": "banktransfer", "metadata": null, "status": "canceled", "canceledAt": "2018-03-19T10:19:15+00:00", "details": { "bankName": "Stichting Mollie Payments", "bankAccount": "NL53ABNA0627535577", "bankBic": "ABNANL2A", "transferReference": "RF12-3456-7890-1234" }, "profileId": "pfl_QkEhN94Ba", "sequenceType": "oneoff", "redirectUrl": "https://webshop.example.org/order/33/", "_links": { "self": { "href": "https://api.mollie.com/v2/payments/tr_WDqYK6vllg", "type": "application/hal+json" }, "dashboard": { "href": "https://www.mollie.com/dashboard/org_12345678/payments/tr_WDqYK6vllg", "type": "text/html" }, "documentation": { "href": "https://docs.mollie.com/reference/v2/payments-api/cancel-payment", "type": "text/html" } } } |