> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anglpay.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How an integration works

> See how your server, your checkout, and webhooks work together to take a payment.

Every integration has three parts. Your server holds the API key and calls the API. Your checkout collects payment details from the buyer. Webhooks tell your server when a transaction changes.

```mermaid theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
sequenceDiagram
    participant Buyer
    participant Checkout as Your checkout
    participant Server as Your server
    participant Platform

    Server->>Platform: Create a checkout session
    Server->>Checkout: Checkout session ID, and a token for Embed
    Buyer->>Checkout: Enter payment details
    alt Embed
        Checkout->>Platform: Create the transaction
        Checkout->>Server: Transaction ID
    else Secure Fields or a native SDK
        Checkout->>Platform: Store the card in the checkout session
        Checkout->>Server: Submit the order
        Server->>Platform: Create a transaction with the checkout session
    end
    Server->>Platform: Get the transaction
    Platform->>Server: Webhook event when the transaction changes
```

## Your server

Your server is the only part of the integration that holds the private API key. Never send the key to the browser or to a mobile app.

1. [Create an API key](https://docs.anglpay.com/guides/api/authentication.md#create-an-api-key) in the **Integrations** panel of the dashboard. Store the private key securely, because the dashboard doesn't keep a copy.
2. Sign a [JSON Web Token (JWT)](https://docs.anglpay.com/guides/api/jwts.md) with the key for every API call. The server-side SDKs sign the token for you.
3. Create a [checkout session](https://docs.anglpay.com/reference/checkout-sessions/new-checkout-session.md) for each checkout. A checkout session links every attempt to pay for the same order, and it can hold cart items and metadata.
4. For Embed, [sign a token](https://docs.anglpay.com/guides/payments/embed/quick-start/sdks.md) for the checkout and send it to your checkout page or app with the checkout session ID.
5. Create, capture, and refund transactions with the [API](https://docs.anglpay.com/reference/overview.md) or a server-side SDK.

## Your checkout

Your checkout collects the payment details. The approach you choose decides whether the checkout or your server creates the transaction.

| Approach | Platforms | Creates the transaction | PCI scope |
| :- | :- | :- | :- |
| [Embed](https://docs.anglpay.com/guides/payments/embed/quick-start/overview.md) | Web | Embed | SAQ A |
| [Secure Fields](https://docs.anglpay.com/guides/payments/secure-fields/quick-start/overview.md) | Web | Your server, with the checkout session | SAQ A |
| [Embed SDKs](https://docs.anglpay.com/guides/payments/mobile.md#embed-sdks) | iOS, Android, and React Native | Embed | SAQ A |
| [Native SDKs](https://docs.anglpay.com/guides/payments/native/overview.md) | iOS and Android | Your server, with the checkout session | [SAQ D](https://docs.anglpay.com/guides/payments/native/overview.md#self-certification-and-scope) |

Embed returns the transaction ID to your checkout when it creates the transaction. Send the ID to your server, and get the transaction from the API to confirm its status before you fulfill the order.

To compare the approaches in more detail, see [Accept payments on the web](https://docs.anglpay.com/guides/payments/web.md) and [Accept payments on mobile](https://docs.anglpay.com/guides/payments/mobile.md).

## Webhooks

Webhooks send an event to your server when a transaction, a buyer, or another resource changes. Use them to keep your system up to date without polling the API.

1. Add a webhook subscription in the dashboard, under **Settings** > **Manage Integrations** > **Webhook subscriptions**. See [Webhooks](https://docs.anglpay.com/guides/features/webhooks/overview.md).
2. Respond with a `2XX` status within 5000 milliseconds. The platform retries any other response for up to 7 days. See [Technical considerations](https://docs.anglpay.com/guides/features/webhooks/technical-considerations.md).
3. Check the [signature](https://docs.anglpay.com/guides/features/webhooks/signatures.md) of each request to confirm it comes from the platform.

Each event holds a snapshot of the resource at the time of the change. Get the resource from the API before you take an action that you can't undo, such as shipping an order. See [Payloads](https://docs.anglpay.com/guides/features/webhooks/payload.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.