JavaScript Drop-in Flow#
Embed a pre-built payment flow directly in your website. The customer completes mandate setup and payment authorisation without leaving your domain.
Supports: Direct Debit only. Does not support Pay By Bank or Commercial VRP. For these payments, use Hosted Pages or Custom Payment Pages.
Best for#
- Keeping customers on your site throughout the payment flow
- Moderate customisation with less development than a full custom build
- Modern web applications (React, Vue, etc.)
- Balance between speed of implementation and control
How it works#
- Create a Billing Request and Billing Request Flow via the API (same as Hosted Pages)
- Include the GoCardless Drop-in JavaScript library on your page
- Initialise the component with the flow ID
- The component renders the payment flow inline on your page
- Listen for completion events and webhooks
Customisation#
- Style the component to match your brand colours and fonts
- Control the container element and placement
- Handle events (success, exit, error) in your application code
Step-by-step guide#
Create a billing request#
The Billing Request defines what you're collecting.
Response:
Create a billing request flow#
This generates the hosted URL where the customer completes authorisation.
Response:
Initialise the Drop-in Component#
Include the GoCardless Drop-in script on your page and initialise it with the billing_request_flow_id from the previous step.
Handle Webhooks#
| Event | Meaning | What to do |
|---|---|---|
| billing_requests.fulfilled | Customer completed the flow | Record the mandate_id from links.mandate_request_mandate |
| mandates.active | Mandate is ready to collect against | Enable payment collection in your system |
| payments.confirmed | A payment against the mandate was collected | Mark the associated period/invoice as paid |
| payments.failed | A payment failed | Notify the customer, retry if appropriate |
| mandates.cancelled | Mandate was cancelled | Stop future payment creation |
Pre-collecting customer details#
If you already have the customer's name, email, and address, submit them before creating the flow. The hosted page skips those fields or locks them if you prefer.
Collect customer details (optional)#
Response: Updated Billing Request with collect_customer_details marked completed.
Collect bank account (optional)#
Response: Updated Billing Request with collect_bank_account marked completed.
What's next?#
Create mandates and collect bank account details via the API.
Skip form steps by supplying customer details before the drop-in loads.
Redirect to a GoCardless-hosted checkout — no frontend JavaScript required.
Full API control for teams that want complete UX ownership.