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

# Digital Goods Purchase

> Purchase virtual currency, in-game tokens, and other digital goods using line items

## Overview

A digital goods purchase allows customers to buy virtual currency, in-game tokens, sweepstakes coins, and other digital products. This uses the line items checkout flow where you specify the products, prices, and quantities being purchased.

Every Soap API request is authenticated with a bearer token in the `Authorization` header:

```bash theme={null}
Authorization: Bearer YOUR_API_KEY
```

Your API key is in the Soap Dashboard under the Developers section. It looks like `key_...`.

Requests with a missing or invalid API key return `422` — never `401` — with a JSON `error` field, usually `{"error": "API key not found."}`. Branch on the status code rather than the message: `GET /api/v1/device_pings/latest_geo_check` does not yet return the same wording.

Never expose your API key in client-side code — it is server-side only.

## How It Works

1. Create products in Soap, or pass inline dynamic product details directly in `line_items`.
2. Create a checkout session with `type: "deposit"` and include `line_items`.
3. The customer is redirected to the Soap-hosted checkout page showing the items and total.
4. The customer selects a payment method and completes the purchase.
5. Upon completion, a webhook is fired and the customer is redirected back to your app.

> [!NOTE]
>
> To charge a processing fee, add it as its own line item with `sku: "processing_fee"`. The checkout shows it as a separate "Processing Fee" line in the order summary rather than as a product, and includes it in the total.

## API Request

> [!NOTE]
>
> You can also manage products from the Soap dashboard and reference them by ID. Simply pass `line_items: [{ "product_id": "pr_XXX", "quantity": 1 }]` instead of inline product details.

```bash theme={null}
curl -X POST 'https://api-sandbox.paywithsoap.com/api/v1/checkouts' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--data '{
    "customer_id": "cus_vi57KegYgcRqcGHqip8q6UZiqtrwMT870",
    "type": "deposit",
    "line_items": [
        {
            "name": "Gold Coins Pack",
            "price_cents": 999,
            "quantity": 1,
            "sku": "gold-coins-1000",
            "url": "https://example.com/products/gold-coins.png",
            "dedup": true
        }
    ],
    "experience": "web",
    "return_url": "https://myapp.com/store"
}'
```

## Key Parameters

| Parameter | Required | Description |
| - | - | - |
| `customer_id` | Yes | The customer's unique identifier |
| `type` | Yes | Must be `"deposit"` |
| `line_items` | Yes | Array of existing product references or inline dynamic products |
| `experience` | No | `"web"`, `"webview"`, or `"iframe"`. Use `"iframe"` when embedding the checkout — see [Embedded Checkout](https://docs.paywithsoap.com/get_started/embedded-checkout.md). |
| `return_url` | No | Where to redirect the customer after completion |

## Line Item Parameters

Each line item can reference an existing product or define a product inline.

| Parameter | Required | Description |
| - | - | - |
| `line_items[].product_id` | Yes for existing products | Soap product ID for an existing product. Use with `quantity`. |
| `line_items[].name` | Yes for inline products | Product name to create and display in checkout. |
| `line_items[].price_cents` | Yes for inline products | Unit price in cents. Must be at least `1`. |
| `line_items[].quantity` | Yes | Number of units to purchase. Must be at least `1`. |
| `line_items[].sku` | Required when `dedup` is `true` | Stable merchant SKU used with `price_cents` to find an existing product for this business. |
| `line_items[].url` | No | Product image URL shown in checkout where supported. |
| `line_items[].dedup` | No | When `true`, Soap reuses an existing product for the same business when `sku` and `price_cents` match. Requires `sku`. |

## When to Use

* Virtual currency purchases (gold coins, tokens, credits, etc.)
* Sweepstakes coin packages
* Any digital goods tied to a product catalog or priced dynamically at checkout time

> [card] [← Back to Create Checkout](https://docs.paywithsoap.com/api-reference/api-v1/checkouts/create.md)
>
> View the full API reference for creating checkouts.


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