Direct debit allows you to take payments directly from your customer's bank account. It operates on a slower schedule, but is far cheaper than credit card payments. This is ideal for recurring bills or background payments. Since payments are not immediate, there are a few more steps you need to take to find the status of your payment.
This guide shows you our most popular workflow for integrating direct debit into your products.
Here's the list of steps to take to ensure a complete integration.
- Get an Access Token. See Authentication
- Save a Payer. Capture your customer's bank account information for later use. See Save a payer
- Schedule a Payment. You can schedule a payment for today, or any time in the future. All payments process overnight. See Save scheduled payment
- Poll for new Events. Events tell you when things happen in the background, such as a payment failing or succeeding. See List all events
- Lookup Bank Results events for failed payments. See Get Event
- Lookup Transfer event for successful payments. See Get Event and List transfer line items
Once you have your token, include it as a header with each API call like so:
Authorization: Bearer <token>
All payments within Pinch need to be associated with a Payer. This is the customer that you will be taking funds from.
See Save a payer for the details to submit.
Submit as much information about the payer as you can and be sure to save the Payer ID (pyr_123456789) from the response.
Direct debit payments are processed each day, once in the morning and once in the evening. They are sent to the bank overnight and can take up to 5 business days to be completed.
You can submit a payment for a payer using the Save scheduled payment endpoint.
It's a good idea to keep track of the Payment ID (pmt_123456789) that is returned in the response.
Since direct debit payments can take a few days to process, you'll need a way to be notified when they are either successful or failed (dishonoured). To do this we have an events system for all background processes.
Use the List all events endpoint to retrieve a list of all events. You can look at the
type property to determine which kind of event it is. The events you'll want to look at are:
bank-results- Returns a list of failed payments
transfer- Lets you know when a Transfer has been created
You'll use these two events in the next steps.
When a payment is dishonoured (meaning it failed), it will be part of a Bank-Results event containing all the failed payments for that day.
You can use the Get Event endpoint to retrieve the event data, which will contain a list of failed payments and their IDs. These will match the payment IDs you saved earlier.
It's up to you to schedule a new payment when one fails.
A transfer is created whenever there are payments ready to be settled to your merchant bank account. Each transfer contains the details of any successful payments, failed payments, application charges and the fees related to any of these.
Firstly, use the Get Event endpoint to lookup the details of your new transfer event. Specifically, you'll want the Transfer ID (tra_123456789).
Next, fetch the transfer details from the List transfer line items endpoint. This will return a list of Payment IDs and their status (type: 'Settlement' for successful, type: 'Dishonour' for failed.).
You've now successfully integrated Direct Debit payments into your system.
Updated less than a minute ago