Introduction

This how-to guide will show you how to successfully process a direct debit payment with the SEPA scheme.

Prerequisites

  • A ClientId and an API key – if you don’t have these, contact Sales to get access to the Mangopay Dashboard
  • A user with a wallet to which to make the payment
  • Activation of the feature by Mangopay teams (contact Support via the Dashboard)

Direct debits allow platforms to collect payments from a user’s bank account based on a preauthorized mandate agreement.

Learn more about direct debit

1. Register the user’s bank account

Using the user’s UserId as the path parameter, create an IBAN-type Bank Account from which the funds will be collected.

See testing data

POST /v2.01/{ClientId}/users/{UserId}/bankaccounts/iban

You’ll need the returned Bank Account Id value for the next step.

2. Create the mandate

Create the mandate against the IBAN Bank Account by using it’s Id as the BankAccountId.

POST /v2.01/{ClientId}/mandates/directdebit/web

You’ll need the returned Mandate Id to request the payment, and the RedirectURL for the next step.

3. Redirect the user to confirm the mandate

Redirect the user to the RedirectURL so they can confirm the mandate. When they click the confirmation button, they are returned to your platform on the ReturnURL.

Mandates expire 1 hour after their CreationDate unless confirmed by the user.

The Mandate Status becomes SUBMITTED when the user has confirmed it.

Best practice - Set up webhooks for mandates

Set up webhooks for mandate event types to be notified of progress.

4. Request the pay-in

Once your Mandate has a Status of SUBMITTED, request the direct debit pay-in.

POST /v2.01/{ClientId}/payins/directdebit/direct

If the pay-in is successful, the Status of the SEPA mandate becomes ACTIVE.

Note - Direct debit processing times

Due to the nature of direct debits, payments take several days to be processed. See pay-in processing times for details.

Best practice – Set up hooks for pay-ins

Set up webhooks for the pay-in event types to be notified of processing:

  • PAYIN_NORMAL_SUCCEEDED
  • PAYIN_NORMAL_FAILED

When you receive a notification, call the GET View a PayIn endpoint on the webhook ResourceId to confirm the payment outcome and other details.