{
"BankAccountId": "bankacc_m_01J999AWHFHW2PQ1ADNQ46AYE9",
"Culture": "EN",
"ReturnURL": "http://example.com",
"Tag": "Created using the Mangopay API Postman collection"
}
<?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 {
$bankAccountId = '198982529';
$mandate = new \MangoPay\Mandate();
$mandate->BankAccountId = $bankAccountId;
$mandate->Culture = 'EN';
$mandate->ReturnURL = 'http://example.com';
$mandate->Tag = 'Created using Mangopay PHP SDK';
$response = $api->Mandates->Create($mandate);
print_r($response);
} catch(MGPResponseException $e) {
print_r($e);
} catch(MGPException $e) {
print_r($e);
}
const mangopayInstance = require('mangopay4-nodejs-sdk')
const mangopay = new mangopayInstance({
clientId: 'your-client-id',
clientApiKey: 'your-api-key',
})
let myMandate = {
BankAccountId: '151467634',
Culture: 'EN',
ReturnUrl: 'http://example.com',
}
const createMandate = async (mandate) => {
return await mangopay.Mandates.create(mandate)
.then((response) => {
console.info(response)
return response
})
.catch((err) => {
console.log(err)
return false
})
}
createMandate(myMandate)
require 'mangopay'
MangoPay.configure do |client|
client.preproduction = true
client.client_id = 'your-client-id'
client.client_apiKey = 'your-api-key'
client.log_file = File.join(Dir.pwd, 'mangopay.log')
end
def createMandate(mandateObject)
begin
response = MangoPay::Mandate.create(mandateObject)
puts response
return response
rescue MangoPay::ResponseError => error
puts "Failed to create mandate: #{error.message}"
puts "Error details: #{error.details}"
return false
end
end
myMandate = {
BankAccountId:'151453487',
Culture:'EN',
ReturnURL:'http://example.com',
Tag:'Created using Mangopay Ruby SDK'
}
createMandate(myMandate)
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.mangopay.MangoPayApi;
import com.mangopay.core.enumerations.CultureCode;
import com.mangopay.entities.Mandate;
public class CreateMandate {
public static void main(String[] args) throws Exception {
MangoPayApi mangopay = new MangoPayApi();
mangopay.getConfig().setClientId("your-client-id");
mangopay.getConfig().setClientPassword("your-api-key");
Mandate mandate = new Mandate();
mandate.setBankAccountId("bankacc_m_01HW2YJFFGYMY4HHHQSZ9YBCQJ");
mandate.setReturnUrl("https://www.mangopay.com/docs/please-ignore");
mandate.setCulture(CultureCode.EN);
mandate.setTag("Created using the Mangopay Java SDK");
Mandate createMandate = mangopay.getMandateApi().create(mandate);
Gson prettyPrint = new GsonBuilder().setPrettyPrinting().create();
String prettyJson = prettyPrint.toJson(createMandate);
System.out.println(prettyJson);
}
}
from pprint import pprint
import mangopay
mangopay.client_id='your-client-id'
mangopay.apikey='your-api-key'
from mangopay.api import APIRequest
handler = APIRequest(sandbox=True)
from mangopay.resources import Mandate
bank_account_id = '214050174'
mandate = Mandate(
bank_account_id = bank_account_id,
culture = 'EN',
return_url = 'http://example.com',
tag = 'Created using the Mangopay Python SDK'
)
create_mandate = mandate.save()
pprint(create_mandate)
using MangoPay.SDK;
using MangoPay.SDK.Entities.PUT;
using Newtonsoft.Json;
class Program
{
static async Task Main(string[] args)
{
MangoPayApi api = new MangoPayApi();
api.Config.ClientId = "your-client-id";
api.Config.ClientPassword = "your-api-key";
var bankAccountId = "bankacc_m_01J3D0VAFPEAFA42S9A641M91Z";
var returnUrl = "https://www.mangopay.com/docs/please-ignore/";
var mandate = new MandatePostDTO(bankAccountId, CultureCode.EN, returnUrl);
var createMandate = await api.Mandates.CreateAsync(mandate);
string prettyPrint = JsonConvert.SerializeObject(createMandate, Formatting.Indented);
Console.WriteLine(prettyPrint);
}
}
{
"Scheme": null,
"BankAccountId": "bankacc_m_01J999AWHFHW2PQ1ADNQ46AYE9",
"BankReference": null,
"Culture": "EN",
"DocumentURL": "https://api.sandbox.mangopay.com/webhook/eu/public/mandates/e8a73d/dfbdce2a12a442bfae973e56777b3ddb/document?version=2.01",
"ReturnURL": "http://example.com?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": "CREATED",
"UserId": "user_m_01J8SY95DQ5CM7DH43NQCAS65T",
"ExecutionType": "WEB",
"MandateType": "DIRECT_DEBIT",
"Tag": "Created using the Mangopay API Postman collection",
"ResultCode": null,
"ResultMessage": null
}
Direct debits
Create a Mandate
POST
/
v2.01
/
{ClientId}
/
mandates
/
directdebit
/
web
{
"BankAccountId": "bankacc_m_01J999AWHFHW2PQ1ADNQ46AYE9",
"Culture": "EN",
"ReturnURL": "http://example.com",
"Tag": "Created using the Mangopay API Postman collection"
}
<?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 {
$bankAccountId = '198982529';
$mandate = new \MangoPay\Mandate();
$mandate->BankAccountId = $bankAccountId;
$mandate->Culture = 'EN';
$mandate->ReturnURL = 'http://example.com';
$mandate->Tag = 'Created using Mangopay PHP SDK';
$response = $api->Mandates->Create($mandate);
print_r($response);
} catch(MGPResponseException $e) {
print_r($e);
} catch(MGPException $e) {
print_r($e);
}
const mangopayInstance = require('mangopay4-nodejs-sdk')
const mangopay = new mangopayInstance({
clientId: 'your-client-id',
clientApiKey: 'your-api-key',
})
let myMandate = {
BankAccountId: '151467634',
Culture: 'EN',
ReturnUrl: 'http://example.com',
}
const createMandate = async (mandate) => {
return await mangopay.Mandates.create(mandate)
.then((response) => {
console.info(response)
return response
})
.catch((err) => {
console.log(err)
return false
})
}
createMandate(myMandate)
require 'mangopay'
MangoPay.configure do |client|
client.preproduction = true
client.client_id = 'your-client-id'
client.client_apiKey = 'your-api-key'
client.log_file = File.join(Dir.pwd, 'mangopay.log')
end
def createMandate(mandateObject)
begin
response = MangoPay::Mandate.create(mandateObject)
puts response
return response
rescue MangoPay::ResponseError => error
puts "Failed to create mandate: #{error.message}"
puts "Error details: #{error.details}"
return false
end
end
myMandate = {
BankAccountId:'151453487',
Culture:'EN',
ReturnURL:'http://example.com',
Tag:'Created using Mangopay Ruby SDK'
}
createMandate(myMandate)
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.mangopay.MangoPayApi;
import com.mangopay.core.enumerations.CultureCode;
import com.mangopay.entities.Mandate;
public class CreateMandate {
public static void main(String[] args) throws Exception {
MangoPayApi mangopay = new MangoPayApi();
mangopay.getConfig().setClientId("your-client-id");
mangopay.getConfig().setClientPassword("your-api-key");
Mandate mandate = new Mandate();
mandate.setBankAccountId("bankacc_m_01HW2YJFFGYMY4HHHQSZ9YBCQJ");
mandate.setReturnUrl("https://www.mangopay.com/docs/please-ignore");
mandate.setCulture(CultureCode.EN);
mandate.setTag("Created using the Mangopay Java SDK");
Mandate createMandate = mangopay.getMandateApi().create(mandate);
Gson prettyPrint = new GsonBuilder().setPrettyPrinting().create();
String prettyJson = prettyPrint.toJson(createMandate);
System.out.println(prettyJson);
}
}
from pprint import pprint
import mangopay
mangopay.client_id='your-client-id'
mangopay.apikey='your-api-key'
from mangopay.api import APIRequest
handler = APIRequest(sandbox=True)
from mangopay.resources import Mandate
bank_account_id = '214050174'
mandate = Mandate(
bank_account_id = bank_account_id,
culture = 'EN',
return_url = 'http://example.com',
tag = 'Created using the Mangopay Python SDK'
)
create_mandate = mandate.save()
pprint(create_mandate)
using MangoPay.SDK;
using MangoPay.SDK.Entities.PUT;
using Newtonsoft.Json;
class Program
{
static async Task Main(string[] args)
{
MangoPayApi api = new MangoPayApi();
api.Config.ClientId = "your-client-id";
api.Config.ClientPassword = "your-api-key";
var bankAccountId = "bankacc_m_01J3D0VAFPEAFA42S9A641M91Z";
var returnUrl = "https://www.mangopay.com/docs/please-ignore/";
var mandate = new MandatePostDTO(bankAccountId, CultureCode.EN, returnUrl);
var createMandate = await api.Mandates.CreateAsync(mandate);
string prettyPrint = JsonConvert.SerializeObject(createMandate, Formatting.Indented);
Console.WriteLine(prettyPrint);
}
}
{
"Scheme": null,
"BankAccountId": "bankacc_m_01J999AWHFHW2PQ1ADNQ46AYE9",
"BankReference": null,
"Culture": "EN",
"DocumentURL": "https://api.sandbox.mangopay.com/webhook/eu/public/mandates/e8a73d/dfbdce2a12a442bfae973e56777b3ddb/document?version=2.01",
"ReturnURL": "http://example.com?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": "CREATED",
"UserId": "user_m_01J8SY95DQ5CM7DH43NQCAS65T",
"ExecutionType": "WEB",
"MandateType": "DIRECT_DEBIT",
"Tag": "Created using the Mangopay API Postman collection",
"ResultCode": null,
"ResultMessage": null
}
Note – Mandate expires after 1 hourIf not confirmed within 1 hour of the
CreationDate, the Mandate expires with the error 001807 and a new one must be created.BankAccountId is a Danish or Swedish IBAN (starting DK or SE), this endpoint returns a 400 error because they are not currently supported (see IBAN compatibility).
Body parameters
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.Allowed 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.Max. length: 220 charactersThe URL to which the user is returned after the payment, whether the transaction is successful or not.
Responses
200
200
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.
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.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.Max. length: 220 charactersThe URL to which the user is returned after the payment, whether the transaction is successful or not.
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.
Max length: 128 characters (see data formats for details)The unique identifier of the object.
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.
The code indicating the result of the operation. This information is mostly used to handle errors or for filtering purposes.
400 - For SDD, IBAN country not supported
400 - For SDD, IBAN country not supported
{
"Message": "One or several required parameters are missing or incorrect. An incorrect resource ID also raises this kind of error.",
"Type": "param_error",
"Id": "c0f5f61a-d752-4dd8-816d-fd3c34595c5d#1771499159",
"Date": 1771499160,
"errors": {
"BankAccountId": "The IBAN bank account is not accepted for this country and currency"
}
}
400 - EN only for BACS
400 - EN only for BACS
{
"Message": "One or several required parameters are missing or incorrect. An incorrect resource ID also raises this kind of error.",
"Type": "param_error",
"Id": "277c7c4e-baf1-43f8-ba1d-d9f02d7939e2",
"Date": 1727958031.0,
"errors": {
"Culture": "The requested language is not supported for this bank account"
}
}
400 - Language not supported
400 - Language not supported
{
"Message": "One or several required parameters are missing or incorrect. An incorrect resource ID also raises this kind of error.",
"Type": "param_error",
"Id": "9d45b954-4eda-4247-b4e3-91027628ab22",
"Date": 1690294898.0,
"errors": {
"Culture": "The requested language is not supported"
}
}
{
"Scheme": null,
"BankAccountId": "bankacc_m_01J999AWHFHW2PQ1ADNQ46AYE9",
"BankReference": null,
"Culture": "EN",
"DocumentURL": "https://api.sandbox.mangopay.com/webhook/eu/public/mandates/e8a73d/dfbdce2a12a442bfae973e56777b3ddb/document?version=2.01",
"ReturnURL": "http://example.com?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": "CREATED",
"UserId": "user_m_01J8SY95DQ5CM7DH43NQCAS65T",
"ExecutionType": "WEB",
"MandateType": "DIRECT_DEBIT",
"Tag": "Created using the Mangopay API Postman collection",
"ResultCode": null,
"ResultMessage": null
}
{
"BankAccountId": "bankacc_m_01J999AWHFHW2PQ1ADNQ46AYE9",
"Culture": "EN",
"ReturnURL": "http://example.com",
"Tag": "Created using the Mangopay API Postman collection"
}
<?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 {
$bankAccountId = '198982529';
$mandate = new \MangoPay\Mandate();
$mandate->BankAccountId = $bankAccountId;
$mandate->Culture = 'EN';
$mandate->ReturnURL = 'http://example.com';
$mandate->Tag = 'Created using Mangopay PHP SDK';
$response = $api->Mandates->Create($mandate);
print_r($response);
} catch(MGPResponseException $e) {
print_r($e);
} catch(MGPException $e) {
print_r($e);
}
const mangopayInstance = require('mangopay4-nodejs-sdk')
const mangopay = new mangopayInstance({
clientId: 'your-client-id',
clientApiKey: 'your-api-key',
})
let myMandate = {
BankAccountId: '151467634',
Culture: 'EN',
ReturnUrl: 'http://example.com',
}
const createMandate = async (mandate) => {
return await mangopay.Mandates.create(mandate)
.then((response) => {
console.info(response)
return response
})
.catch((err) => {
console.log(err)
return false
})
}
createMandate(myMandate)
require 'mangopay'
MangoPay.configure do |client|
client.preproduction = true
client.client_id = 'your-client-id'
client.client_apiKey = 'your-api-key'
client.log_file = File.join(Dir.pwd, 'mangopay.log')
end
def createMandate(mandateObject)
begin
response = MangoPay::Mandate.create(mandateObject)
puts response
return response
rescue MangoPay::ResponseError => error
puts "Failed to create mandate: #{error.message}"
puts "Error details: #{error.details}"
return false
end
end
myMandate = {
BankAccountId:'151453487',
Culture:'EN',
ReturnURL:'http://example.com',
Tag:'Created using Mangopay Ruby SDK'
}
createMandate(myMandate)
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.mangopay.MangoPayApi;
import com.mangopay.core.enumerations.CultureCode;
import com.mangopay.entities.Mandate;
public class CreateMandate {
public static void main(String[] args) throws Exception {
MangoPayApi mangopay = new MangoPayApi();
mangopay.getConfig().setClientId("your-client-id");
mangopay.getConfig().setClientPassword("your-api-key");
Mandate mandate = new Mandate();
mandate.setBankAccountId("bankacc_m_01HW2YJFFGYMY4HHHQSZ9YBCQJ");
mandate.setReturnUrl("https://www.mangopay.com/docs/please-ignore");
mandate.setCulture(CultureCode.EN);
mandate.setTag("Created using the Mangopay Java SDK");
Mandate createMandate = mangopay.getMandateApi().create(mandate);
Gson prettyPrint = new GsonBuilder().setPrettyPrinting().create();
String prettyJson = prettyPrint.toJson(createMandate);
System.out.println(prettyJson);
}
}
from pprint import pprint
import mangopay
mangopay.client_id='your-client-id'
mangopay.apikey='your-api-key'
from mangopay.api import APIRequest
handler = APIRequest(sandbox=True)
from mangopay.resources import Mandate
bank_account_id = '214050174'
mandate = Mandate(
bank_account_id = bank_account_id,
culture = 'EN',
return_url = 'http://example.com',
tag = 'Created using the Mangopay Python SDK'
)
create_mandate = mandate.save()
pprint(create_mandate)
using MangoPay.SDK;
using MangoPay.SDK.Entities.PUT;
using Newtonsoft.Json;
class Program
{
static async Task Main(string[] args)
{
MangoPayApi api = new MangoPayApi();
api.Config.ClientId = "your-client-id";
api.Config.ClientPassword = "your-api-key";
var bankAccountId = "bankacc_m_01J3D0VAFPEAFA42S9A641M91Z";
var returnUrl = "https://www.mangopay.com/docs/please-ignore/";
var mandate = new MandatePostDTO(bankAccountId, CultureCode.EN, returnUrl);
var createMandate = await api.Mandates.CreateAsync(mandate);
string prettyPrint = JsonConvert.SerializeObject(createMandate, Formatting.Indented);
Console.WriteLine(prettyPrint);
}
}
Was this page helpful?