# Bacs Direct Debit for web Accept Bacs Direct Debit payments on your website with [Flow](https://www.checkout.com/docs/payments/accept-payments/accept-a-payment-on-your-website.md), our pre-built, customizable payment user interface. Flow enables you to accept payments using Checkout.com's global network of payment methods with a single integration. Set up your client-side and server-side configuration to integrate with Checkout.com's payment gateway and enable payments on your website. Bacs Direct Debit works differently from most payment methods in Flow. It does not take an immediate payment. Instead, it sets up a Direct Debit mandate, and you confirm the payment setup server-side after the mandate's five-day activation period passes. --- ## How it works 1. The customer lands on the checkout page. 2. You perform a server-side request to create a payment session. 3. You use the payment session data on the client-side to mount Flow. 4. Flow displays the Bacs Direct Debit payment method to the customer. 5. The customer chooses an individual or corporate account, enters their name or company name, email, sort code, and account number, and accepts the Direct Debit agreement. 6. When the customer confirms, Flow creates a payment setup against the payment session and calls your `onMandateCreated` callback with the setup ID. 7. You store the setup ID against your order. 8. After the five-day mandate activation period, you call the [Confirm a payment setup](https://api-reference.checkout.com/tag/Payment-Setups/#operation/confirmAPaymentSetup) endpoint. --- ## Before you start Make sure you have a [test account](https://www.checkout.com/get-test-account) with Checkout.com. Create a [public key and a secret key](https://www.checkout.com/docs/developer-resources/api/manage-api-keys/api-keys.md) from the [Dashboard](https://dashboard.checkout.com), with the following key scopes: - Public key – `payment-sessions:pay` and `vault-tokenization` - Secret key – `payment-sessions` To receive webhooks for the [payment events](https://www.checkout.com/docs/developer-resources/event-notifications/event-types.md#Gateway), [configure your webhook server](https://www.checkout.com/docs/developer-resources/event-notifications/receive-webhooks/configure-your-webhook-server.md). To enable Bacs Direct Debit on your account, contact your account manager or [request support](https://dashboard.checkout.com/support/new?topic=case_account_management_and_access&issue=issue_account_changes). ### Content Security Policy If you have a Content Security Policy (CSP) on your website, Checkout.com requires the following directives: ``` connect-src, https://*.checkout.com frame-src, https://*.checkout.com script-src, https://*.checkout.com img-src, https://*.checkout.com ``` --- ## Step 1: Create a new Payment Session `Server side` When the customer is ready to pay, you must send a server-side request to securely create a `PaymentSession` object. The `PaymentSession` contains the information required to handle all steps of the payment flow. In your request: - Set `billing.address.country` to `GB` - Set `currency` to `GBP` - Set `payment_type` to `Regular` or `Recurring` - Provide `amount` - Provide the `customer.email` or `customer.id` - Provide `items[]` - For each `item` in `items[]`, provide the: - `name` - `quantity` - `reference` - `unit_price` > **Information** > > For the full API specification, see the [API reference](https://api-reference.checkout.com/tag/Flow/#operation/CreatePaymentSession). > **Information** > > Your base URL's `{prefix}` value is unique to your account and environment. To learn how to retrieve your base URLs for the sandbox and production environments, see [API endpoints](https://www.checkout.com/docs/developer-resources/api/api-endpoints.md). **Production** `POST` `https://{prefix}.api.checkout.com/payment-sessions` **Sandbox** `POST` `https://{prefix}.api.sandbox.checkout.com/payment-sessions` ### Request example ```json { "amount": 1000, "currency": "GBP", "reference": "ORDER_01234", "display_name": "Online shop", "payment_type": "Regular", "billing": { "address": { "country": "GB" } }, "customer": { "name": "Hannah Bret", "email": "hannah.bret@example.com" }, "items": [ { "reference": "0001", "name": "Monthly subscription", "quantity": 1, "unit_price": 1000 } ], "success_url": "https://example.com/payments/success", "failure_url": "https://example.com/payments/failure" } ``` ### Response example ```json { "id": "ps_2Un6I6lRpIAiIEwQIyxWVnV9CqQ", "payment_session_secret": "pss_9823241e-2cec-4c98-b23d-7b29ow4e2e34", "payment_session_token": "YmFzZTY0:eyJpZCI6InBzXzJVbjZJNmxScElBaUlFd1FJeXhXVm5WOUNxUSIsIm...", "_links": { "self": { "href": "https://{prefix}.api.sandbox.checkout.com/payment-sessions/ps_2Un6I6lRpIAiIEwQIyxWVnV9CqQ" } } } ``` --- ## Step 2: Initialize and mount Flow `Client side` You can install the `@checkout.com/checkout-web-components` package via npm: ```bash npm install @checkout.com/checkout-web-components --save ``` Alternatively, you can load the package directly via a script: ```html