# Setting up Mandates

Source: https://docs.gocardless.com/docs/collect-payments/setting-up-mandates

# Setting Up Mandates

A Direct Debit mandate is an authorisation from your customer that allows you to collect payments directly from their bank account. Once authorised, you can collect recurring or future payments without the customer taking any further action.

## Step-by-step guide

### Create a Billing Request

Use Billing Requests to create a mandate alongside a new customer. If you want to create a mandate against an existing customer, specify the customer ID in `links.customer.`

Pass currency rather than scheme — GoCardless automatically selects the optimal scheme for that currency.

> **Info: Verified Mandates**
> If you submit the verify setting, payers may be asked to verify themselves if GoCardless deems
>   them risky or if scheme compliance requires it. [Read more about verified
>   mandates.](/docs/collect-payments/setting-up-mandates/verified-mandates)

```php
$client = new \GoCardlessPro\Client(array(
  'access_token' => 'your_access_token_here',
  'environment'  => \GoCardlessPro\Environment::SANDBOX
));

$client->billingRequests()->create([
  "params" => [
    "mandate_request" => [
      "scheme" => "bacs"
    ]
  ]
]);
```

```python

client = gocardless_pro.Client(access_token="your_access_token_here", environment='sandbox')

client.billing_requests.create(params=
})
```

```ruby
@client = GoCardlessPro::Client.new(
  access_token: "your_access_token",
  environment: :sandbox
)

@client.billing_requests.create(
  params: 
  }
)
```

```java

String accessToken = "your_access_token_here";
GoCardlessClient client = GoCardlessClient
    .newBuilder(accessToken)
    .withEnvironment(SANDBOX)
    .build();

BillingRequest billingRequest = client.billingRequests().create()
  .withMandateRequestScheme("bacs")
  .execute();
```

```javascript
const constants = require("gocardless-nodejs/constants");
const gocardless = require("gocardless-nodejs");
const client = gocardless("your_access_token_here", constants.Environments.Sandbox);

const billingRequest = await client.billingRequests.create(,
});
```

```cs
String accessToken = "your_access_token";
GoCardlessClient gocardless = GoCardlessClient.Create(accessToken, Environment.SANDBOX);

var mandateRequest = new GoCardless.Services.BillingRequestCreateRequest.BillingRequestMandateRequest
;

var resp = await gocardless.BillingRequests.CreateAsync(
  new GoCardless.Services.BillingRequestCreateRequest()
  
);

GoCardless.Resources.BillingRequest billingRequest = resp.BillingRequest;
```

```http
POST https://api.gocardless.com/billing_requests HTTP/1.1

  }
}
```

```go
package main

	gocardless "github.com/gocardless/gocardless-pro-go/v6"
)

accessToken := "your_access_token_here"
opts := gocardless.WithEndpoint(gocardless.SandboxEndpoint)
config, err := gocardless.NewConfig(accessToken, opts)
if err != nil 
client, err := gocardless.New(config)
if err != nil 

billingRequestCreateParams := gocardless.BillingRequestCreateParams,
}

billingRequest, err := client.BillingRequests.Create(context, billingRequestCreateParams)
```

```CLI
gc create billing_request \
  -d 'mandate_request[scheme]=bacs'
```

Response:

```json
,
    "links": ,
    "actions": [
      ,
      
    ]
  }
}
```

### Authorise the mandate

Direct the customer to authorise the mandate. How you do this depends on your integration type:

- **Hosted Pages:** Create a Billing Request Flow and redirect the customer to the authorisation_url. See the [Hosted Pages guide](/docs/collect-payments/integration-types/gocardless-hosted-pages)
- **Drop-in:** Create a Billing Request Flow and pass the flow ID to the GoCardless Drop-in. See the [Drop-in guide](/docs/collect-payments/integration-types/javascript-drop-in-flow)
- **Custom Payment Pages:** Collect customer details and bank account via Billing Request actions, then confirm payer details. See the [Custom Payment Pages guide](/docs/collect-payments/integration-types/custom-payment-pages)

For Hosted Pages and Drop-in, create the flow:

```php
$client = new \GoCardlessPro\Client(array(
  'access_token' => 'your_access_token_here',
  'environment'  => \GoCardlessPro\Environment::SANDBOX
));

$client->billingRequestFlows()->create([
  "params" => [
    "redirect_uri" => "https://my-company.com/landing",
    "exit_uri" => "https://my-company.com/exit",
    "links" => [
      "billing_request" => "BRQ000010NMDMH2"
    ]
  ]
]);
```

```python

client = gocardless_pro.Client(access_token="your_access_token_here", environment='sandbox')

client.billing_request_flows.create(params=
})
```

```ruby
@client = GoCardlessPro::Client.new(
  access_token: "your_access_token",
  environment: :sandbox
)

@client.billing_request_flows.create(
  params: 
  }
)
```

```java

String accessToken = "your_access_token_here";
GoCardlessClient client = GoCardlessClient
    .newBuilder(accessToken)
    .withEnvironment(SANDBOX)
    .build();

BillingRequestFlow billingRequestFlow = client.billingRequestFlows().create()
  .withRedirectUri("https://my-company.com/landing")
  .withExitUri("https://my-company.com/exit")
  .withLinksBillingRequest("BRQ000010NMDMH2")
  .execute();
```

```javascript
const constants = require("gocardless-nodejs/constants");
const gocardless = require("gocardless-nodejs");
const client = gocardless("your_access_token_here", constants.Environments.Sandbox);

const billingRequestFlow = await client.billingRequestFlows.create(,
});
```

```cs
String accessToken = "your_access_token";
GoCardlessClient gocardless = GoCardlessClient.Create(accessToken, Environment.SANDBOX);

var resp = await gocardless.BillingRequestFlows.CreateAsync(
  new GoCardless.Services.BillingRequestFlowCreateRequest()
  ,
  }
);

GoCardless.Resources.BillingRequestFlow billingRequestFlow = resp.BillingRequestFlow;
```

```http
POST https://api.gocardless.com/billing_request_flows HTTP/1.1

  }
}
```

```go
package main

	gocardless "github.com/gocardless/gocardless-pro-go/v6"
)

accessToken := "your_access_token_here";
opts := gocardless.WithEndpoint(gocardless.SandboxEndpoint)
client, err := gocardless.New(accessToken, opts)

billingRequestFlowCreateParams := gocardless.BillingRequestFlowCreateParams
billingRequestFlowCreateParams.RedirectUri = "https://my-company.com/landing"
billingRequestFlowCreateParams.ExitUri = "https://my-company.com/exit"
billingRequestFlowCreateParams.Links.BillingRequest = "BRQ000010NMDMH2"
billingRequestFlow, err := client.BillingRequestFlows.Create(context, billingRequestFlowCreateParams)
```

```CLI
gc create billing_request_flow \
  -d "links[billing_request]= BRQ000010NMDMH2" \
  -d 'redirect_uri=https://my-company.com/landing' \
  -d 'exit_uri=https://my-company.com/exit'
```

Response:

```json

  }
}
```

`redirect_uri:` where GoCardless sends the customer after they complete the flow.

`exit_uri:` where GoCardless sends customers who can't complete the flow (e.g. bank not found, no online banking). We recommend returning them to your checkout so they can choose a different payment method.

Send the `authorisation_url` to your customer via redirect, email, or SMS.

> **Warning: Confirming Billing Request Flow outcome**
> Don't rely on the redirect back to your site to confirm the outcome. Always use webhooks. Learn
>   more about [Mandate events](/docs/collect-payments/events-and-webhooks/mandate-events).

### Collect payments

With the mandate active, you're now ready to collect payments. See:

- [One-off payments](/docs/collect-payments/one-off-payments/one-off-direct-debit)
- [Recurring payments](/docs/collect-payments/recurring-payments/subscriptions)

### Lock customer details or bank account

Set these on the Billing Request Flow to restrict what the customer can change during the flow:

| **Parameter**                 | **Effect**                                                             |
| ----------------------------- | ---------------------------------------------------------------------- |
| `lock_customer_details: true` | Customer details page hidden; customer cannot edit                     |
| `lock_bank_account: true`     | The bank selection page is hidden; the customer cannot switch accounts |
| `lock_currency: true`         | The customer cannot change the currency or payment scheme              |

If both `lock_customer_details` and lock_bank_account are set, the customer goes directly to the confirmation page.

> **Info: New to GoCardless?**
> See the [Collect Payments overview](/docs/collect-payments) to choose your payment type and
>   integration approach before starting this guide.

## What the customer will see

### Customer fills in their personal details

Collect customer details in order to complete the billing request.

**Note:** this screen is skipped if the details already exist, or the customer details have been locked.

![bacs-collect-customer-details](/images/docs/collect-payments/setting-up-mandates/screenshot_2024-05-12_at_14.45.51.png)

### Customer provides their bank details

Provide the Bank account details in order for GC to setup mandate.

**Note:** this screen is skipped if the details already exist or the bank account is locked.

![bacs-collect-bank-details](/images/docs/collect-payments/setting-up-mandates/screenshot_2024-05-12_at_14.49.32.png)

### Customer confirms their details

Confirm your personal and bank details, before authorising the mandate.

![bacs-confirm-payer-details](/images/docs/collect-payments/setting-up-mandates/screenshot_2024-05-12_at_15.16.36.png)

### Confirmed!

View confirmation that the payment has been successful once the bank authorisation is complete.

![bacs-05-success](/images/docs/collect-payments/setting-up-mandates/4.jpg)

## What's next?

  
#### [Verified Mandates](/docs/collect-payments/setting-up-mandates/verified-mandates)

Require identity verification for high-risk or scheme-mandated payers.

  
#### [Offline Mandates](/docs/collect-payments/setting-up-mandates/offline-mandates)

Import mandates collected outside of GoCardless.

  
#### [One-off Direct Debit](/docs/collect-payments/one-off-payments/one-off-direct-debit)

Collect a one-off payment against an existing mandate.

  
#### [Recurring Payments](/docs/collect-payments/recurring-payments/subscriptions)

Set up subscription schedules against active mandates.