PUT
/
v2.01
/
{ClientId}
/
mandates
/
{MandateId}
/
cancel
<?php 

require_once 'vendor/autoload.php';

use MangoPay\MangoPayApi;
use MangoPay\Libraries\ResponseException as MGPResponseException;
use MangoPay\Libraries\Exception as MGPException;

$api = new MangoPayApi();

$api->Config->ClientId = 'your-client-id';
$api->Config->ClientPassword = 'your-api-key';
$api->Config->TemporaryFolder = 'tmp/';

try {
    $mandateId = '199255586';

    $response = $api->Mandates->Cancel($mandateId);

    print_r($response);
} catch(MGPResponseException $e) {
    print_r($e);
} catch(MGPException $e) {
    print_r($e);
}  
{
    "Scheme": "SEPA",
    "BankAccountId": "bankacc_m_01J999AWHFHW2PQ1ADNQ46AYE9",
    "BankReference": "QYDZMNP",
    "Culture": "EN",
    "DocumentURL": "https://api.sandbox.mangopay.com/webhook/eu/public/mandates/e8a73d/dfbdce2a12a442bfae973e56777b3ddb/document?version=2.01",
    "ReturnURL": "https://docs.mangopay.com/please-ignore?MandateId=mdt_m_01J999B9HSEDH9CZDEXXYZGHEZ",
    "RedirectURL": "https://api.sandbox.mangopay.com/mvc/eu/public/mandates/e8a73d/dfbdce2a12a442bfae973e56777b3ddb/confirmation?version=2.01",
    "Id": "mdt_m_01J999B9HSEDH9CZDEXXYZGHEZ",
    "CreationDate": 1727962392,
    "Status": "FAILED",
    "UserId": "user_m_01J8SY95DQ5CM7DH43NQCAS65T",
    "ExecutionType": "WEB",
    "MandateType": "DIRECT_DEBIT",
    "Tag": "Created using the Mangopay API Postman collection",
    "ResultCode": "001806",
    "ResultMessage": "The client has cancelled the mandate"
}
Warning – Call requires Content-Length adjustmentFor this call to succeed, you need to define the header Content-Length to 0.
Note – Mandate must be ACTIVE or SUBMITTEDA mandate can only be canceled if its Status is ACTIVE or SUBMITTED. Once canceled, its status changes to FAILED.

Path parameters

MandateId
string
required
The unique identifier of the mandate.

Responses

Scheme
string
The scheme of the mandate, which is available once the mandate is submitted. The value can be one of the following: 
  • BACS – Covers payments in the UK, in GBP only.
  • SEPA – Covers payments in the EU.
BankAccountId
string
The unique identifier of the bank account.Warning: The Bank Account Type must be IBAN for the SEPA scheme and GB for the Bacs scheme.
BankReference
string
The banking reference for the Mandate.
Culture
string
Returned values: One of the supported languages in the ISO 639-1 format: DE, EN, ES, FR, IT, NL, PLThe language in which the mandate confirmation page is to be displayed. This value only applies to mandates with the SEPA Scheme.
DocumentURL
string
The URL at which the mandate document can be downloaded.
ReturnURL
string
Max. length: 220 charactersThe URL to which the user is returned after the payment, whether the transaction is successful or not.
RedirectURL
string
The URL to which to redirect the user to complete the payment.Caution: This variable URL is specific to each payment. You must rely on the returned URL in full (host, path, and queries) and not hardcode any part of it.
Id
string
Max length: 128 characters (see data formats for details)The unique identifier of the object.
CreationDate
Unix timestamp
The date and time at which the object was created.
Status
string
Returned values: CREATED, SUBMITTED, ACTIVE, FAILED, EXPIREDThe status of the mandate:
  • CREATED – The mandate has been generated but not yet confirmed.
  • SUBMITTED – The mandate has been confirmed and sent to the user’s bank, and can be used to request a direct debit pay-in.
  • ACTIVE – The mandate has been accepted by the user’s bank or successfully used to process a direct debit direct pay-in. Further pay-ins can be requested.
  • FAILED – The mandate has been canceled or otherwise failed, and can no longer be used for payments.
  • EXPIRED – No payment has been made against the mandate in the last 24 months. It can no longer be used for payments.
UserId
string
The unique identifier of the User (natural or legal) who owns the bank account.
ExecutionType
string
Returned values: WEBThe execution type of the mandate.
MandateType
string
The type of the mandate.
Tag
string
Max. length: 255 charactersCustom data that you can add to this object.
ResultCode
string
The code indicating the result of the operation. This information is mostly used to handle errors or for filtering purposes.
ResultMessage
string
The explanation of the result code.
{
    "Message": "The Status of this mandate does not allow it to be cancelled",
    "Type": "mandate_cannot_be_cancelled",
    "Id": "f569e443-17a1-4c59-a8ca-143586c99bca#1756734881",
    "Date": 1756734882,
    "errors": null
}
{
    "Scheme": "SEPA",
    "BankAccountId": "bankacc_m_01J999AWHFHW2PQ1ADNQ46AYE9",
    "BankReference": "QYDZMNP",
    "Culture": "EN",
    "DocumentURL": "https://api.sandbox.mangopay.com/webhook/eu/public/mandates/e8a73d/dfbdce2a12a442bfae973e56777b3ddb/document?version=2.01",
    "ReturnURL": "https://docs.mangopay.com/please-ignore?MandateId=mdt_m_01J999B9HSEDH9CZDEXXYZGHEZ",
    "RedirectURL": "https://api.sandbox.mangopay.com/mvc/eu/public/mandates/e8a73d/dfbdce2a12a442bfae973e56777b3ddb/confirmation?version=2.01",
    "Id": "mdt_m_01J999B9HSEDH9CZDEXXYZGHEZ",
    "CreationDate": 1727962392,
    "Status": "FAILED",
    "UserId": "user_m_01J8SY95DQ5CM7DH43NQCAS65T",
    "ExecutionType": "WEB",
    "MandateType": "DIRECT_DEBIT",
    "Tag": "Created using the Mangopay API Postman collection",
    "ResultCode": "001806",
    "ResultMessage": "The client has cancelled the mandate"
}
<?php 

require_once 'vendor/autoload.php';

use MangoPay\MangoPayApi;
use MangoPay\Libraries\ResponseException as MGPResponseException;
use MangoPay\Libraries\Exception as MGPException;

$api = new MangoPayApi();

$api->Config->ClientId = 'your-client-id';
$api->Config->ClientPassword = 'your-api-key';
$api->Config->TemporaryFolder = 'tmp/';

try {
    $mandateId = '199255586';

    $response = $api->Mandates->Cancel($mandateId);

    print_r($response);
} catch(MGPResponseException $e) {
    print_r($e);
} catch(MGPException $e) {
    print_r($e);
}