Direct Debit Payin Workflow

Overview

This integration guide will run you through how to do payins via direct debit (ACH / DE / BECS). You will need to capture a user's bank account details into a bank account and then create an item between buyer/payer and seller/payee. Afterwards you perform a make payment action on that item specifying the bank account of the buyer/payer.

Getting Started

Before you can run your direct debit workflow there are a few setup steps that need to be completed so that all of the pieces are available.

Prerequisites
You will need to capture specific details from your users for you to be able to perform direct debits.
The setup discussed in this guide makes use of a float to fund your payout.

Terminology used
The following terminology is used throughout this guide:

  • Platform​ refers to your platform (you, your website, app, marketplace etc.).
  • User​ refers to your customer who will have a User record in Assembly.
  • Item​ is the mechanism for moving funds between users in the API.
  • Payin​ is money being paid into the Assembly ecosystem.
  • Payout​ is money being paid out of the Assembly ecosystem to a bank account.
  • ASM​ is shorthand for Assembly
  • Callback​ is Assembly speak for a Webhook.

API steps

Setup steps
We recommend that you create callbacks (webhooks) on the following objects to receive notifications from us of state and status changes.

  • Transactions
  • Items
  • Users
  • Batch Transactions
  • Accounts

To create a callback, you would call ​POST /callbacks​, more information on callbacks can be ​found here​.

Inbound payments (topping up your float - PreLive only)
The following steps allow you to add funds to a user’s digital wallet in our prelive environment. In the real world, you would sent us a payment and we would match it to the wallet. For the purposes of testing, you can add funds to wallets as needed.

API steps

  1. Create a user for your customer (who you want to pay) if they don’t exist already.
    POST /users
  2. Update the user for your customer if they already exist (if needed).
    PATCH /users/:id
  3. Add a ​bank account​ for your customer (you’ll need the bank account ID in further steps).
    POST /bank_accounts
  4. Create a seller ​user​ in Assembly.
    POST /users
  5. Create an item Create Item between the buyer and the seller without the amount
    POST /items
  6. (Once off) Set up ​Callback​ (webhook) on the ​items​ object to be notified of when the item status changes
    POST /callbacks
"object_type": "items",
  1. (Once off) Set up ​Callback​ (webhook) on the ​transactions​ object to be notified of when the transaction state changes
    POST /callbacks
"object_type": "transactions",
  1. (Once off) Set up ​Callback​ (webhook) on the Batch Transactions object to be notified of when the transaction state changes
    POST /callbacks
"object_type": "batch_transactions",
  1. Call Make Payment on the item and specify the bank account id (obtained from step 3)
    PATCH /items/:id/make_payment

Once the the make_payment API has been called, Assembly will attempt to send the direct debit out via its bank. This will result in the following to occur:

  1. (Pre-Live only) You can call the following API which moves all pending batch_transactions into batched state. As a result this API will return all the batch_transactions that have moved from pending to exported. This will simulate the step of the flow where we batch payments and will result in you receiving a batch_transactions webhook which has the direct debit payment transaction. Please store the id in order to progress it in Pre-Live
    GET /batch_transactions/export_transactions
{
    "transactions": [
        {
            "id": "439970a2-e0a1-418e-aecf-6b519c115c55",
            "batch_id": null,
            "status": "batched",
            "type": "payment",
            "type_method": "direct_debit"
        }
    ]
}
  1. (Pre-Live only) You can call the following API which moves one or more batch_transactions into bank_processing state 12700. This will simulate the step of the flow where we send payments to our bank and will result in you receiving a batch_transactions webhook
    PATCH /batches/:id/transaction_states
{
    "exported_ids" : ["439970a2-e0a1-418e-aecf-6b519c115c55"],
    "state": 12700
}
{
    "aggregated_jobs_uuid": "c1cbc502-9754-42fd-9731-2330ddd7a41f",
    "msg": "1 jobs have been sent to the queue.",
    "errors": []
}
  1. (Pre-Live only) You can call the same API from the step above to move one or more batch_transactions to the final states of processing being either successful state 12000 or invalid_account_details state 12360 or failed_direct_debit state 12370. This will simulate the step of the flow where we complete the processing of the payment and will result in you receiving a batch_transactions webhook and an items webhook for completion in case of successful.
    PATCH /batches/:id/transaction_states
{
    "exported_ids" : ["439970a2-e0a1-418e-aecf-6b519c115c55"],
    "state": 12000
}
{
    "aggregated_jobs_uuid": "c1cbc502-9754-42fd-9731-2330ddd7a41f",
    "msg": "1 jobs have been sent to the queue.",
    "errors": []
}

Alternatively to waiting for webhooks you can check the Callback payload to see that the payout was completed.
GET /callbacks/id:/responses

Design considerations

User data design
When designing how this workflow will interface with your platform, we suggest storing a map of specific object IDs on your side in order to reduce the number of API calls required throughout the API workflow.

your_customer_id

asm_user_id

asm_bank_account_id

asm_digital_wallet_id

Asm_user_npp_crn (for payins)

10001001

5b8f59b6-32c1-44a3-8f5b-b9e2c77bc265

fb35b028-76fb-44df-86ac-822dccf1cd7d

dcdfdb78-27e7-485d-90c0-11ffbf950d72

1000023456

10001002

efe6f8c1-0a30-484a-b085-9d9d0539dbfc

4355de7b-18c2-4892-b800-b7bbb6f0a9b3

054cd04e-19f1-4938-908b-8e9e5c212f4d

1000098653

Payment descriptors
For direct debit payins descriptors please refer to https://docs.assemblypayments.com/en/articles/2037264-payment-descriptors

Workflow summary
Once you’ve run through the API steps, and implemented something like the above in your platform, the sequence of calls to run the payin workflow in production will be reduced. It will exclude any Pre-Live steps listed above

Failed Direct Debit Payins
In the case of a failure relating to the direct credit payouts the batch_transactions object will be transitioned to invalid_account_details or failed_direct_debit. In this case you should verify the account details with the user and aim to create a new account with the correct details before reattempting the payment

Additional Details

For a list of error codes please refer to: Common error messages
For a list of statuses please refer to: Statuses
For FAQs payouts please refer to:


Did this page help you?