# Pay By Bank

Source: https://docs.gocardless.com/docs/gc-embed/setting-up-mandates-collecting-payments/actions-instant-payment

# Pay By Bank

In order to request a Pay By Bank, we'll need to initiate a `payment_request`. In this instance, we are going to set the currency to GBP and will need to link the `Billing Request with Actions` to the creditor we wish to pay out to, `CR123`.

The required actions of the Billing Request will be different from those of a `mandate_request`.

In order to generate the payment request url for the customer, we will also need to provide the `institution` as well as a `bank_authorisation_redirect_uri`. Setting the `create_bank_authorisation` to `true` allows us to retrieve the redirect `url` in the API response.

The list of available institution IDs can be obtained from the [Institutions API](/docs/api-reference/institution#list-institutions-for-billing-request).

> **Warning:**
> The customer's `email` is a mandatory field for Payment Providers using our Embed product.

```http
POST https://api.gocardless.com/billing_requests/create_with_actions HTTP/1.1
Content-Type: application/json
\
        \},
        "actions": \
            \},
            "select_institution": \,
            "bank_authorisation_redirect_uri": "https://pay.gocardless.com/billing/static/thankyou",
            "create_bank_authorisation": true
        \},
        "links": \

HTTP/1.1 200 OK
Content-Type: application/json
\,
...
"links": \,
...
"bank_authorisations": \
\}
\}
\}
```

```php
\$client->billingRequestsWithActions()->create([
"params" => [
"payment_request" => [
"description" => "Pay By Bank",
"amount" => 123,
"currency" => "GBP",
"metadata" => [
"internal_payment_id" => "ID123"
]
],
"actions" => [
"collect_customer_details" => [
"customer" => [
"given_name" => "Alice",
"family_name" => "Smith",
"email" => "alice.smith@example.com"
]
],
"select_institution" => [
"institution" => "INSTITUTION_ID123",
"country_code" => "GB"
],
"bank_authorisation_redirect_uri" => "https://pay.gocardless.com/billing/static/thankyou",
"create_bank_authorisation" => true
],
"links" => [
"creditor" => "CR123"
]
]
]);
```

```python
client.billing_requests_with_actions.create(params=\
\},
"actions": \
\},
"select_institution": \,
"bank_authorisation_redirect_uri": "https://pay.gocardless.com/billing/static/thankyou",
"create_bank_authorisation": True
\},
"links": \
\})
```

```ruby
@client.billing_requests_with_actions.create(
params: \
\},
actions: \
\},
select_institution: \,
bank_authorisation_redirect_uri: "https://pay.gocardless.com/billing/static/thankyou",
create_bank_authorisation: true
\},
links: \
\}
)
```

```java
BillingRequestWithActions response = client.billingRequestsWithActions().create()
.withPaymentRequestDescription("Pay By Bank")
.withPaymentRequestAmount(123)
.withPaymentRequestCurrency("GBP")
.withPaymentRequestMetadata("internal_payment_id", "ID123")
.withActionsCollectCustomerDetailsCustomerGivenName("Alice")
.withActionsCollectCustomerDetailsCustomerFamilyName("Smith")
.withActionsCollectCustomerDetailsCustomerEmail("alice.smith@example.com")
.withActionsSelectInstitutionInstitution("INSTITUTION_ID123")
.withActionsSelectInstitutionCountryCode("GB")
.withActionsBankAuthorisationRedirectUri("https://pay.gocardless.com/billing/static/thankyou")
.withActionsCreateBankAuthorisation(true)
.withLinksCreditor("CR123")
.execute();
```

```javascript
const response = await client.billingRequestsWithActions.create(\,
\},
actions: \,
\},
select_institution: \,
bank_authorisation_redirect_uri:
"https://pay.gocardless.com/billing/static/thankyou",
create_bank_authorisation: true,
\},
links: \,
\});
```

```net
var paymentRequest = new GoCardless.Services.BillingRequestWithActionsCreateRequest.BillingRequestWithActionsPaymentRequest
\
\}
\};

var collectCustomerDetails = new GoCardless.Services.BillingRequestWithActionsCreateRequest.BillingRequestWithActionsActionsCollectCustomerDetails
\
\};

var selectInstitution = new GoCardless.Services.BillingRequestWithActionsCreateRequest.BillingRequestWithActionsActionsSelectInstitution
\;

var resp = await gocardless.BillingRequestsWithActions.CreateAsync(
new GoCardless.Services.BillingRequestWithActionsCreateRequest
\,
Links = new GoCardless.Services.BillingRequestWithActionsCreateRequest.BillingRequestWithActionsLinks
\
\}
);
```

```go
billingRequestWithActionsCreateParams := gocardless.BillingRequestWithActionsCreateParams\\,
\},
Actions: &gocardless.BillingRequestWithActionsCreateParamsActions\,
\},
SelectInstitution: &gocardless.BillingRequestWithActionsCreateParamsActionsSelectInstitution\,
BankAuthorisationRedirectUri: "https://pay.gocardless.com/billing/static/thankyou",
CreateBankAuthorisation: true,
\},
Links: &gocardless.BillingRequestWithActionsCreateParamsLinks\,
\}

response, err := client.BillingRequestsWithActions.Create(context, billingRequestWithActionsCreateParams)
```

```bash
curl -X POST "https://api.gocardless.com/billing_requests/create_with_actions" \\
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \\
-H "GoCardless-Version: 2015-07-06" \\
-H "Content-Type: application/json" \\
-d '\
\},
"actions": \
\},
"select_institution": \,
"bank_authorisation_redirect_uri": "https://pay.gocardless.com/billing/static/thankyou",
"create_bank_authorisation": true
\},
"links": \
\}
\}'
```

We will now be able to grab the `url` parameter and send it to our customer.

- In a mobile-to-mobile flow we'd ideally use a call-to-action so that the customer is immediately redirected to this link after they clicked on a button.
- In a desktop-to-mobile flow, we could use the `qr_code_url` instead. This will allow the customer to scan the qr code on your website using their mobile device in order to then authorise the Pay By Bank request via their banking app.

Listening to the `bank_authorisation_authorised` [webhook](/docs/api-reference/events/billing-requests) allows us to make sure that the customer has approved the payment request.

Listening to the `payment_confirmed` [webhook](/docs/api-reference/events/payments) notifies us that the payment has been successfully collected.

Once the customer has approved the payment request and the funds were collected from their bank account, the status of the Billing Request will then move from `pending` to `fulfilled`.

## What's next?

  
#### [Dual Flow](/docs/gc-embed/setting-up-mandates-collecting-payments/actions-dual-flow)

Combine a Pay By Bank and a Direct Debit mandate setup in a single flow.

  
#### [Handling Webhooks](/docs/gc-embed/handling-webhooks)

Listen to webhooks to confirm payment authorisation and fulfilment.