import { Callout } from "zudoku/ui/Callout";

# Collect Stripe Payments

This article describes how to collect customer payments with Stripe in 365 business Banking.

## Prerequisites

- A payment method code with **Bal. Account Type** set to `Bank Account`, linked to the connected Stripe bank account.
- A customer bank account with **Payment Service** set to `Stripe`.
- A successful payment authorization for that customer bank account.
- For automatic collection during posting: **Preferred Bank Account Code** is set on the customer.

## Setup

### 1. Create or configure payment method

1. Open **Payment Methods**.
2. Create a payment method (for example `STRIPE`).
3. Set **Bal. Account Type** to `Bank Account` and choose the connected Stripe bank account.

![Set up payment method](/assets/images/365-business-banking/psp-capture/payment-method.de-DE.png)

### 2. Configure customer bank account and request authorization

1. Open **Customers** and select the customer.
2. Open **Bank Accounts**.
3. Create a customer bank account and set **Payment Service** to `Stripe`.
4. Run **Request Payment Authorization...**.
5. Wait until the authorization status is **Successful**.

**Example email for Stripe:**

![Payment authorization email Stripe](/assets/images/365-business-banking/psp-capture/stripe-request-pmt-approval-email.de-DE.png)

![Stripe customer bank account](/assets/images/365-business-banking/psp-capture/stripe-customer-bank-account.de-DE.png)

### 3. Optional: enable automatic collection on posting

1. Open the customer card.
2. Set **Preferred Bank Account Code** to the authorized customer bank account.

## Collect Payments

### Automatically during posting

1. Create a sales invoice with **Payment Method Code** set to your Stripe payment method.
2. Post the invoice.
3. If successful, the invoice is applied automatically.

![Payment transaction log](/assets/images/365-business-banking/psp-capture/pmt-log-entry-stripe.de-DE.png)

![Posted sales invoice](/assets/images/365-business-banking/psp-capture/posted-sales-invoice-stripe.de-DE.png)

### Manually for a posted invoice

1. Open **Posted Sales Invoices**.
2. Select the invoice.
3. Run **Collect Payment**.

### Batch collection

1. Open **Collect Payments**.
2. Set filters (for example due date, customer, payment method code).
3. Run the process with **OK**.

![Collect payments](/assets/images/365-business-banking/psp-capture/collect-payments.de-DE.png)

## Stripe Restricted Key Permissions

When restricted keys are used for payment collection, the following write permissions are required:

| Resource Type | Permission | Description |
| --- | --- | --- |
| `Customer Session` | Write | Allows creating customer sessions for payment processing. |
| `Customers` | Write | Allows creating and managing customers. |
| `Payment Intents` | Write | Allows creating payment transactions. |
| `Payment Methods` | Write | Allows managing payment methods. |
| `Setup Intents` | Write | Allows setting up payment authorizations for future payments. |
| `Checkout Sessions` | Write | Allows creating checkout sessions for collection flows. |

## Error Handling

- If collection fails, the invoice is not applied automatically.
- Check **Payment Transactions** on the posted invoice for root-cause details.
- After resolving the issue, retry collection.

<Callout type="danger" title="Important when collection fails">

If collection fails, verify payment authorization status and the selected payment method code first. Retry only after the underlying issue has been fixed.

</Callout>

## See also

- [Stripe Overview](../stripe.mdx)
- [Stripe Setup](setup.mdx)
- [Retrieve Stripe Transactions](retrieve-transactions.mdx)
- [Bank Account Reconciliation](../../bank-reconciliation.mdx)
- [Feature: Collect Payment](../../features/details/collect-payment.md)
