# Refund a Charge Source: https://docs.paywithsoap.com/api-reference/api-v1/charges/refund POST /api/v1/charges/{id}/refund Refund a succeeded card deposit in full (NMI and Rapyd) Refund a succeeded card charge. The full amount is returned to the customer's card — partial refunds are not supported. The charge must belong to the merchant whose API key is used; otherwise the API responds with a 422 indistinguishable from "not found", by design. > [!NOTE] > > Refunds are supported for **card deposits processed through the NMI or Rapyd gateways**. Payout charges are rejected with `"Only credit charges can be refunded."`, and charges on other processors return `"We cannot refund this transaction through this processor at the moment."` — both as a 422. > [!WARNING] > > **Sandbox.** Sandbox accounts process cards through a test gateway that this endpoint does not support, so every refund of a sandbox card charge returns `422` with `"We cannot refund this transaction through this processor at the moment."`, whatever the charge's age. To exercise your `checkout.refunded` handler in sandbox, pay the test amount `$1.08` — see [Sandbox Test Data](/api-reference/api-v1/testing#testing-webhooks). Bank-rail deposits have no refund path in any environment; return money to a bank customer with a fixed-amount withdrawal instead. ## Behavior * The request takes **no body** — the full charge amount is always refunded. * On success the charge transitions to the terminal `refunded` status and the response is the **same charge object returned by [Retrieve a Charge](/api-reference/api-v1/charges/show)**, with `status: "refunded"`. * A charge can only be refunded once; a second attempt fails because the charge is no longer in the `succeeded` status. * If you subscribe to the opt-in [`checkout.refunded`](/api-reference/api-v1/webhooks/checkout-refunded) webhook, it fires when the charge transitions. ## Settlement timing Once a card charge is recorded as `succeeded` it can be refunded whether or not the daily settlement batch has run, so same-day refunds work. If the processor declines a refund for any reason, the API returns a 422 whose `responsetext` carries the processor's decline reason. ```bash Curl theme={null} curl -X POST "https://api-sandbox.paywithsoap.com/api/v1/charges/ch_pQsQ4kz3Af6Mb9rCupnWj6VFzxJsmkYK/refund" \ -H "Authorization: Bearer YOUR_API_KEY" ``` ```ruby Ruby theme={null} require 'net/http' require 'uri' charge_id = 'ch_pQsQ4kz3Af6Mb9rCupnWj6VFzxJsmkYK' uri = URI.parse("https://api-sandbox.paywithsoap.com/api/v1/charges/#{charge_id}/refund") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Post.new(uri.request_uri) request['Authorization'] = 'Bearer YOUR_API_KEY' response = http.request(request) puts response.body ``` ```javascript JavaScript theme={null} const axios = require('axios'); const refundCharge = async (chargeId) => { try { const response = await axios.post( `https://api-sandbox.paywithsoap.com/api/v1/charges/${chargeId}/refund`, {}, { headers: { 'Authorization': 'Bearer YOUR_API_KEY' } } ); console.log(response.data); } catch (error) { console.error(error); } }; refundCharge('ch_pQsQ4kz3Af6Mb9rCupnWj6VFzxJsmkYK'); ``` ```json Error (processor declined) theme={null} { "error": "Refund failed", "responsetext": "Refund amount may not exceed the transaction balance" } ``` ```json Error (unknown charge) theme={null} { "error": "Unable to refund charge.", "hint": "Please verify the charge_id is correct. \n charge_id: ch_pQsQ4kz3Af6Mb9rCupnWj6VFzxJsmkYK" } ``` # Retrieve a Charge Source: https://docs.paywithsoap.com/api-reference/api-v1/charges/show GET /api/v1/charges/{id} Fetch a single charge by ID, including the customer and payment method used Retrieve a single charge by its ID. The charge must belong to the merchant whose API key is used; otherwise the API responds with a 422 indistinguishable from "not found", by design. A charge is a single payment attempt, so one checkout can have several. For what each `status` value means, which transitions are possible, and which webhook each one emits, see [Checkouts, Charges and Reviews](/api-reference/lifecycles#charge-status-lifecycle). 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. > [!NOTE] > > The response object groups into three field clusters: > > * **Core**: `id`, `amount_cents`, `transaction_type`, `currency`, `status`, `failure_code`, `failure_message`, `created_at`, `updated_at`. `failure_code` and `failure_message` are always present and `null` unless the charge failed. > * **Related entities**: a flattened `customer` object and a `payment_method` object. `payment_method` always contains `id`, `payment_type`, `created_at`, `updated_at`, `saved`, and `fingerprint`, plus **exactly one** of `card`, `bank_account`, or `crypto_wallet` (matching `payment_type`). > * **Processor metadata** (card charges only): `avs_result`, `cvv_result`, `network_authorization_code`, `processor_charge_id`, and a `threeds` key that is an object when 3D Secure was performed and `null` otherwise (it is omitted entirely on bank and crypto charges). ```bash Curl theme={null} curl -X GET "https://api-sandbox.paywithsoap.com/api/v1/charges/ch_pQsQ4kz3Af6Mb9rCupnWj6VFzxJsmkYK" \ -H "Authorization: Bearer YOUR_API_KEY" ``` ```ruby Ruby theme={null} require 'net/http' require 'uri' require 'json' charge_id = 'ch_pQsQ4kz3Af6Mb9rCupnWj6VFzxJsmkYK' uri = URI.parse("https://api-sandbox.paywithsoap.com/api/v1/charges/#{charge_id}") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Get.new(uri.request_uri) request['Authorization'] = 'Bearer YOUR_API_KEY' response = http.request(request) puts response.body ``` ```javascript JavaScript theme={null} const axios = require('axios'); const getCharge = async (chargeId) => { try { const response = await axios.get(`https://api-sandbox.paywithsoap.com/api/v1/charges/${chargeId}`, { headers: { 'Authorization': 'Bearer YOUR_API_KEY' } }); console.log(response.data); } catch (error) { console.error(error); } }; getCharge('ch_pQsQ4kz3Af6Mb9rCupnWj6VFzxJsmkYK'); ``` ```python Python theme={null} import requests charge_id = "ch_pQsQ4kz3Af6Mb9rCupnWj6VFzxJsmkYK" url = f"https://api-sandbox.paywithsoap.com/api/v1/charges/{charge_id}" headers = { "Authorization": "Bearer YOUR_API_KEY" } response = requests.get(url, headers=headers) print(response.json()) ``` ```json Card — succeeded theme={null} { "id": "ch_pQsQ4kz3Af6Mb9rCupnWj6VFzxJsmkYK", "amount_cents": 2999, "transaction_type": "credit", "currency": "USD", "status": "succeeded", "failure_code": null, "failure_message": null, "created_at": "2026-05-31T10:30:00.000Z", "updated_at": "2026-05-31T10:30:05.000Z", "customer": { "id": "cus_pQsQ4kz3Af6Mb9rCupnWj6VFzxJsmkYK", "first_name": "Sarah", "last_name": "Johnson" }, "payment_method": { "id": "pm_pQsQ4kz3Af6Mb9rCupnWj6VFzxJsmkYK", "payment_type": "card", "created_at": "2026-05-31T10:30:00.000Z", "updated_at": "2026-05-31T10:30:05.000Z", "saved": true, "fingerprint": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08", "card": { "last_four": "4242", "card_brand": "visa", "card_expiration_month": 12, "card_expiration_year": 2027, "card_issuer_country": "US", "name_on_card": "Sarah Johnson", "card_type": "credit", "first_name": "Sarah", "last_name": "Johnson", "zip": "10001", "google_pay": false, "apple_pay": false, "bin": "424242" } }, "avs_result": "Y", "cvv_result": "M", "network_authorization_code": "OK1234", "processor_charge_id": "proc_5fNqQ8wRyzKp", "threeds": { "eci": "05", "version": "2.2.0", "liability_shifted": true, "failure_reason": null, "status": "success" } } ``` ```json Bank account — succeeded theme={null} { "id": "ch_8tRrL7zXqY3vMnB2wCkPjVgU6sHaDfEy", "amount_cents": 12000, "transaction_type": "credit", "currency": "USD", "status": "succeeded", "failure_code": null, "failure_message": null, "created_at": "2026-05-31T11:02:14.000Z", "updated_at": "2026-05-31T11:02:18.000Z", "customer": { "id": "cus_8tRrL7zXqY3vMnB2wCkPjVgU6sHaDfEy", "first_name": "Alice", "last_name": "Brown" }, "payment_method": { "id": "pm_8tRrL7zXqY3vMnB2wCkPjVgU6sHaDfEy", "payment_type": "bank_account", "created_at": "2026-05-31T11:02:14.000Z", "updated_at": "2026-05-31T11:02:18.000Z", "saved": true, "fingerprint": "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8", "bank_account": { "last_four": "1234", "bank_brand": "chase", "bank_account_type": "checking", "bank_account_name": "Alice Brown", "first_name": "Alice", "last_name": "Brown" } } } ``` ```json Crypto wallet — succeeded theme={null} { "id": "ch_3vMnB2wCkPjVgU6sHaDfEy8tRrL7zXqY", "amount_cents": 50000, "transaction_type": "credit", "currency": "USD", "status": "succeeded", "failure_code": null, "failure_message": null, "created_at": "2026-05-31T12:18:42.000Z", "updated_at": "2026-05-31T12:18:47.000Z", "customer": { "id": "cus_3vMnB2wCkPjVgU6sHaDfEy8tRrL7zXqY", "first_name": "Maya", "last_name": "Patel" }, "payment_method": { "id": "pm_3vMnB2wCkPjVgU6sHaDfEy8tRrL7zXqY", "payment_type": "crypto_wallet", "created_at": "2026-05-31T12:18:42.000Z", "updated_at": "2026-05-31T12:18:47.000Z", "saved": false, "fingerprint": "6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b", "crypto_wallet": { "crypto_wallet_address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb5" } } } ``` ```json Card — failed theme={null} { "id": "ch_FaIl5DxYzNqPkWmV2cBnTjLgU6sHaDfE", "amount_cents": 4999, "transaction_type": "credit", "currency": "USD", "status": "failed", "failure_code": "card_declined", "failure_message": "The card was declined by the issuing bank.", "created_at": "2026-05-31T13:44:01.000Z", "updated_at": "2026-05-31T13:44:03.000Z", "customer": { "id": "cus_FaIl5DxYzNqPkWmV2cBnTjLgU6sHaDfE", "first_name": "Jordan", "last_name": "Lee" }, "payment_method": { "id": "pm_FaIl5DxYzNqPkWmV2cBnTjLgU6sHaDfE", "payment_type": "card", "created_at": "2026-05-31T13:44:01.000Z", "updated_at": "2026-05-31T13:44:03.000Z", "saved": false, "fingerprint": "4e07408562bedb8b60ce05c1decfe3ad16b72230967de01f640b7e4729b49fce", "card": { "last_four": "0002", "card_brand": "visa", "card_expiration_month": 11, "card_expiration_year": 2028, "card_issuer_country": "US", "name_on_card": "Jordan Lee", "card_type": "credit", "first_name": "Jordan", "last_name": "Lee", "zip": "94110", "google_pay": false, "apple_pay": false, "bin": "400000" } }, "avs_result": "N", "cvv_result": "N", "network_authorization_code": null, "processor_charge_id": "proc_DeClInE9876", "threeds": null } ``` # Balance Withdrawal Source: https://docs.paywithsoap.com/api-reference/api-v1/checkouts/balance-withdrawal Customer withdraws a custom amount up to their available balance ## Overview A balance withdrawal presents the customer with an input form where they can choose how much to withdraw, up to their available balance. This is the standard withdrawal experience. > [!WARNING] > > **Soap does not store your customers' balances and has no endpoint to read one.** You own the ledger. Soap only ever sees the single `balance_amount_cents` figure you supply when you create the checkout, plus the charges it processes itself — it cannot reconstruct a balance you credit or debit for reasons it never sees (bonuses, promotions, corrections, gameplay). See [You Own the Ledger](#you-own-the-ledger) below before you wire up withdrawals. 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. You create a checkout session with `type: "withdrawal"` and include `balance_amount_cents` (the customer's available balance). 2. The customer is redirected to the Soap-hosted checkout page. 3. The customer enters the amount they'd like to withdraw (up to their balance) and selects a payout method. 4. Upon completion, a webhook is fired and the customer is redirected back to your app. ## API Request ```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": "withdrawal", "balance_amount_cents": 10000, "experience": "web", "return_url": "https://myapp.com/wallet" }' ``` ## Key Parameters | Parameter | Required | Description | | - | - | - | | `customer_id` | Yes | The customer's unique identifier | | `type` | Yes | Must be `"withdrawal"` | | `balance_amount_cents` | Yes | Your asserted snapshot of the customer's available balance, in cents. Soap enforces it as the ceiling for this one checkout — the customer can't withdraw more than this. Must be at least `1`. | | `experience` | No | `"web"`, `"webview"`, or `"iframe"`. Use `"iframe"` when embedding the checkout — see [Embedded Checkout](/get_started/embedded-checkout). | | `return_url` | No | Where to redirect the customer after completion | ## When to Use * Letting the customer choose their withdrawal amount * Standard cashout flows where the customer has a balance * Any scenario where the withdrawal amount is not predetermined ## You Own the Ledger Soap is a payments layer, not a ledger. There is no endpoint anywhere in the public API to look up a customer's balance — the full API surface is customers, checkouts, charges, products, KYC, device pings, and geo checks. Nothing else. Soap never tracks a running balance for your customers; the only balance-related figure it ever holds is the `balance_amount_cents` you send it, scoped to that single checkout. This means `balance_amount_cents` is not something Soap validates against a stored balance — it's a **snapshot you assert** at checkout-creation time. Soap stores it on the checkout and enforces it as a ceiling: the amount the customer ultimately withdraws must be less than or equal to what you sent. Soap does not re-check it against anything else, because it has nothing else to check it against. ### Computing `balance_amount_cents` Since you own the source of truth, compute this figure from your own ledger when you create the checkout: 1. Read the customer's current available balance from your ledger. 2. Subtract any amount you're already holding for withdrawals currently in flight (i.e. checkouts where you've received `checkout.hold` but not yet a terminal event) — otherwise the same funds could be authorized for withdrawal twice. 3. Pass the result as `balance_amount_cents`. > [!NOTE] > > `fixed_amount_cents` is the alternative to `balance_amount_cents` for withdrawals with a preset amount instead of a customer-chosen one. See [Preset Amount Withdrawal](/api-reference/api-v1/checkouts/preset-withdrawal). The rule is by checkout type, not by account: a withdrawal takes either `balance_amount_cents` or `fixed_amount_cents`, never both and never `line_items`; a deposit may take neither amount field (the customer chooses), `fixed_amount_cents`, or `line_items`, never `balance_amount_cents`. An invalid combination returns `422` and the `error` names the offending field. ## The Hold Lifecycle Withdrawals use a hold handshake so a customer can't spend money that's already being cashed out. Getting this wrong is the single easiest way to double-debit a real customer, so read this before you go live. ```mermaid theme={null} sequenceDiagram participant Customer participant YourApp participant Soap YourApp->>Soap: POST /api/v1/checkouts (type: withdrawal, balance_amount_cents) Soap-->>YourApp: checkout url YourApp->>Customer: Redirect to hosted checkout Customer->>Soap: Chooses amount + payout method Soap->>YourApp: webhook: checkout.hold YourApp->>YourApp: Debit customer ledger YourApp-->>Soap: 2xx (funds available) Soap->>YourApp: webhook: checkout.succeeded YourApp->>YourApp: No-op — already debited on hold alt Payout fails immediately Soap->>YourApp: webhook: checkout.release_hold YourApp->>YourApp: Credit customer back end alt Payout is accepted, then fails asynchronously Soap->>YourApp: webhook: checkout.failed (off by default) YourApp->>YourApp: Credit customer back end alt Payout is accepted, then cancelled by the rail (some processors) Soap->>YourApp: webhook: checkout.cancelled (off by default) YourApp->>YourApp: Credit customer back end ``` 1. You create the withdrawal checkout with `balance_amount_cents`. 2. The customer picks an amount and a payout method. 3. Soap sends `checkout.hold` — a question: does this customer have the funds? Respond **2xx** and the withdrawal proceeds; respond **non-2xx** and it doesn't. `checkout.hold` is delivered synchronously, is never retried, and times out after 10 seconds, so this check must be fast. 4. **Debit the customer immediately when you respond 2xx to `checkout.hold`.** This is what prevents the customer from spending the same funds elsewhere while the withdrawal is in flight. 5. Soap later sends `checkout.succeeded` for the same checkout — treat it as a no-op for withdrawals you already debited on hold. 6. If the withdrawal does not complete, credit the customer back. **Which event tells you depends on how it failed** — see [Every way a hold ends](#every-way-a-hold-ends) below. Getting this set wrong is how held funds go missing. 7. Every event carries a stable `event_id`. Use it as an idempotency key so retries never double-apply a debit or credit. > [!WARNING] > > **The double-debit trap:** debiting the customer on `checkout.hold` *and again* on `checkout.succeeded` for the same withdrawal. If you debit on hold (recommended), `checkout.succeeded` for that checkout must be a no-op. ### Every way a hold ends Once you have debited on `checkout.hold`, you have taken on an obligation to credit the money back if the withdrawal doesn't complete. A held charge can end in several ways, and they do not all send the same event: | How it ends | Event you receive | Delivered by default | Carries `charge.amount_cents` | | - | - | - | - | | The payout succeeds | `checkout.succeeded` | Always | Yes | | The payout fails immediately | `checkout.release_hold` | Always | Yes | | The payout is accepted, then fails | `checkout.failed` | **No** | Yes | | The payout is accepted, then cancelled by the rail (some processors) | `checkout.cancelled` | **No** | Yes | | The checkout is abandoned | `checkout.expired` | **No** | **No** | > [!WARNING] > > **`checkout.failed` is off by default and it is the one most likely to strand real money.** When a payout is accepted for processing and then fails, the charge moves from held to pending to failed. Because it was pending rather than held immediately before failing, Soap sends `checkout.failed` — *not* `checkout.release_hold`. This is the normal failure shape for asynchronous payout rails, so if you debit on hold and leave `checkout.failed` disabled, you will debit customers for withdrawals that never arrive and never hear about it. > > Enable `checkout.failed` in **Dashboard → Developers** before you take withdrawals live. `checkout.release_hold` and `checkout.succeeded` are always sent and cannot be disabled. `checkout.cancelled` is processor-specific (bank-transfer rails); ask Soap whether your payout rails emit it. `checkout.expired` is also off by default, and unlike the others its payload contains no `charge` object at all — only `id`, `expired_at`, `type`, `customer.id` and `subscription`. That is why the handler below records the amount it debited rather than reading it back off the event. > [!NOTE] > > A charge can also move from succeeded to failed or returned well after the fact, when a payout bounces. Those arrive as `checkout.failed` (with `charge.from_status` set to `"succeeded"`) and `checkout.returned`. Keep your record of what you debited until your reconciliation window closes so you can credit these back too, rather than deleting it the moment a withdrawal succeeds. ### Example: a single handler for the full lifecycle ```javascript theme={null} const express = require('express'); const app = express(); // Use a real database, not in-memory collections, to persist these across // restarts. const processedEventIds = new Set(); // chargeId -> { checkoutId, customerId, amountCents } // Withdrawals you have debited and not yet credited back, keyed on the // charge (one checkout can carry several attempts, each with its own // ch_ id — see Checkouts, Charges and Reviews). Store the amount yourself: // checkout.expired arrives with no charge object, so the event cannot tell // you how much to return. const debitedWithdrawals = new Map(); // Credits back at most once per charge, whichever event gets here first. function creditBackCharge(chargeId) { const debit = debitedWithdrawals.get(chargeId); if (!debit) return; // never debited for this charge — nothing to undo creditLedger(debit.customerId, debit.amountCents); debitedWithdrawals.delete(chargeId); } // checkout.expired has no charge, so it credits back every outstanding // debit on that checkout. function creditBackCheckout(checkoutId) { for (const [chargeId, debit] of debitedWithdrawals) { if (debit.checkoutId === checkoutId) creditBackCharge(chargeId); } } app.post('/webhooks/soap', express.raw({ type: 'application/json' }), (req, res) => { const event = JSON.parse(req.body.toString('utf8')); // event_id is your idempotency key — never apply the same event twice. if (processedEventIds.has(event.event_id)) { return res.sendStatus(200); } switch (event.type) { case 'checkout.hold': { const { id: checkoutId, charge, customer } = event.data; const hasSufficientFunds = getLedgerBalance(customer.id) >= charge.amount_cents; if (!hasSufficientFunds) { processedEventIds.add(event.event_id); return res.sendStatus(402); // non-2xx: withdrawal does not proceed } // Debit now, on the hold — this is what stops the customer from // spending these funds again before the withdrawal settles. debitLedger(customer.id, charge.amount_cents); debitedWithdrawals.set(charge.id, { checkoutId, customerId: customer.id, amountCents: charge.amount_cents, }); processedEventIds.add(event.event_id); return res.sendStatus(200); // 2xx: withdrawal proceeds } case 'checkout.succeeded': { const { charge, type } = event.data; if (type === 'withdrawal' && debitedWithdrawals.has(charge.id)) { // Already debited on checkout.hold. Debiting again here would be // the double-debit trap — this must be a no-op. The record stays so // a later reversal can still find the amount. processedEventIds.add(event.event_id); return res.sendStatus(200); } // Deposits (and any withdrawal you didn't debit on hold) settle here. applyLedgerUpdateForSucceededCheckout(event.data); processedEventIds.add(event.event_id); return res.sendStatus(200); } // Always delivered: the charge went straight from held to failed. case 'checkout.release_hold': // Off by default, and the one that actually strands money. An accepted // payout that fails later goes held -> pending -> failed, so Soap sends // this instead of release_hold. Also covers a settled payout bouncing, // where charge.from_status is "succeeded". case 'checkout.failed': // Always delivered. A completed payout was returned by the bank. case 'checkout.returned': // Off by default and processor-specific: the rail cancelled an accepted // payout (pending -> cancelled). Also fires for cancelled deposits on // those rails, which creditBackCharge ignores because nothing was debited. case 'checkout.cancelled': { creditBackCharge(event.data.charge.id); processedEventIds.add(event.event_id); return res.sendStatus(200); } // Off by default. Carries no charge object, which is why the amount // comes from your own record rather than the payload. case 'checkout.expired': { creditBackCheckout(event.data.id); processedEventIds.add(event.event_id); return res.sendStatus(200); } default: processedEventIds.add(event.event_id); return res.sendStatus(200); } }); ``` > [!NOTE] > > `creditBackCharge` is deliberately keyed on your own debit record rather than on > the event type, so the terminal charge events can share one branch and a > charge you never debited is ignored safely. Because it deletes the record as > it credits, two different terminal events for the same charge can never credit > the customer twice. The record is keyed on `charge.id`, not the checkout id: > a failed attempt can be followed by a new attempt with a new charge on the > same checkout, and a checkout-keyed record would let the second hold overwrite > the first. For signature verification and the general webhook endpoint setup, see [Receiving Webhooks](/api-reference/api-v1/webhooks/setup). For the full payload shape of each event, see [`checkout.hold`](/api-reference/api-v1/webhooks/checkout-hold) and [`checkout.release_hold`](/api-reference/api-v1/webhooks/checkout-release-hold). > [card] [← Back to Create Checkout](/api-reference/api-v1/checkouts/create) > > View the full API reference for creating checkouts. # Create Checkout Source: https://docs.paywithsoap.com/api-reference/api-v1/checkouts/create POST /api/v1/checkouts Create a checkout session with POST /api/v1/checkouts. The type is either deposit or withdrawal; purchases and subscriptions are deposits carrying line_items. Returns the checkout url the customer completes payment at. Use this endpoint to create a new checkout session for a customer. 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. The `type` field accepts exactly two values, `"deposit"` and `"withdrawal"`. The checkout flows below are built from those two values plus the other parameters — there is no `"purchase"` or `"subscription"` value for `type`. * A **deposit** checkout (`type: "deposit"`) deposits money into a customer's balance. * A **purchase** checkout is a deposit that carries `line_items`, used to buy a product or service such as credits, sweepstakes coins, or digital goods. * A **subscription** checkout is a deposit that carries `line_items` and `subscription_data`, for recurring billing. * A **withdrawal** checkout (`type: "withdrawal"`) withdraws money from a customer's balance. > [!TIP] > > Show Cash App and card / Apple Pay / Google Pay as separate buttons in your own UI: create one checkout per button, with that button's methods in `payment_options`. See [Limiting Payment Methods](#limiting-payment-methods). [View the Soap Experiences PDF →](https://drive.google.com/file/d/1QJHS4QqnpExpCuNpHBd-6eDpo4lTD9KQ/view) ### Receive Payments > [card] [Draft King's Style Deposit](/api-reference/api-v1/checkouts/draftkings-deposit) > > Input form where the customer enters a custom deposit amount. > [card] [Preset Amount Deposit](/api-reference/api-v1/checkouts/preset-deposit) > > Deposit a fixed amount (e.g. \$100) into the customer's balance. > [card] [Subscription Checkout](/api-reference/api-v1/checkouts/subscription-checkout) > > Create a recurring deposit checkout with subscription billing metadata. > [card] [Digital Goods Purchase](/api-reference/api-v1/checkouts/sweeps-purchase) > > Purchase virtual currency, in-game tokens, sweepstakes coins, and other digital goods. > [card] [Ecomm Purchase](/api-reference/api-v1/checkouts/ecomm-purchase) > > Purchase physical goods such as nutraceuticals, peptides, supplements, and more. ### Send Payments > [card] [Balance Withdrawal](/api-reference/api-v1/checkouts/balance-withdrawal) > > Input form where the customer withdraws up to their available balance. > [card] [Preset Amount Withdrawal](/api-reference/api-v1/checkouts/preset-withdrawal) > > Withdraw a fixed amount (e.g. \$100) from the customer's balance. ## Common Parameters | Parameter | Required | Description | | - | - | - | | `customer_id` | Yes | Soap customer ID for the customer starting the checkout. | | `type` | Yes | Checkout direction. Use `"deposit"` for deposits, purchases, and subscriptions. Use `"withdrawal"` for withdrawals. | | `line_items` | Required for purchase and subscription checkouts | Products included in the checkout. Supports existing product references and inline dynamic products. | | `subscription_data` | Required for subscription checkouts | Billing cadence for a recurring subscription checkout. Includes `interval` and `interval_count`. | | `fixed_amount_cents` | Required for preset amount flows | Fixed amount in cents for preset deposits or preset withdrawals. Must be at least `1`. | | `balance_amount_cents` | Required for balance withdrawal flows | Customer balance in cents. The customer can withdraw up to this amount. Must be at least `1`. | | `experience` | No | Checkout presentation. Use `"web"`, `"webview"`, or `"iframe"`. Set `"iframe"` when embedding the checkout in an iframe — required for in-frame Apple Pay. See [Embedded Checkout](/get_started/embedded-checkout). | | `payment_options` | No | Subset of your enabled payment methods to offer on this checkout, e.g. `["bank_account", "credit_card"]`. See [Limiting Payment Methods](#limiting-payment-methods). | | `return_url` | No | URL where Soap redirects the customer after checkout completion. When the checkout is embedded in an iframe, this redirect happens **inside the frame**. | ## Line Items and Dynamic Pricing Use `line_items` for purchase and subscription checkout flows where Soap should show purchased products and compute the checkout total from product quantities. Line items are not used for balance amount, fixed amount, or withdrawal-only flows. Each line item can be either: * An existing product reference with `product_id` and `quantity`. * An inline dynamic product with `name`, `price_cents`, and `quantity`, plus optional `sku`, `url`, and `dedup`. When `dedup` is `true`, include a stable `sku`. Soap reuses a matching product for the same business when both `sku` and `price_cents` match. If `dedup` is absent or `false`, Soap creates a new active product from the inline line item. ### Line Item Parameters | Parameter | Required | Description | | - | - | - | | `line_items[].product_id` | Yes for existing products | Soap product ID for an existing product. Use this shape with `quantity` when the product is already in Soap. | | `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 for the inline product. 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 looks for an existing product for the same business by `sku` and `price_cents` before creating a new product. Requires `sku`. | ### Dynamic Purchase Example ```json theme={null} { "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" } ``` ## Limiting Payment Methods By default a checkout offers every payment method enabled on your account for that checkout type. Pass `payment_options` to offer only a subset: ```json theme={null} { "customer_id": "cus_123", "type": "deposit", "fixed_amount_cents": 5000, "payment_options": ["bank_account", "credit_card"] } ``` Accepted values: `credit_card`, `bank_account`, `apple_pay`, `google_pay`, `link_money`, `aeropay`, `glide`, `cash_app`. For example, `"payment_options": ["cash_app"]` opens a deposit checkout with only Cash App, or a withdrawal checkout that pays out only to the player's \$cashtag (Cash App must be enabled on your account for that checkout type). * Saved payment methods of an excluded type are hidden for that checkout. * When Apple Pay is the only option and the device supports it, the checkout opens with Apple Pay selected. * The response echoes `payment_options`, or `null` when omitted, like every other unset optional field. * Every listed method must be enabled on your account for the checkout `type`. Otherwise Soap responds `422`: ```json theme={null} { "error": "Unsupported payment_options: google_pay.", "hint": "Payment methods enabled for deposit checkouts on this account: credit_card, bank_account." } ``` To show separate buttons in your own UI (for example Cash App, and card / Apple Pay / Google Pay), create the checkout when the player picks a button and pass that button's methods: `["cash_app"]` for one, `["credit_card", "apple_pay", "google_pay"]` for the other. ## Subscription Checkouts Create a subscription checkout by sending `subscription_data` on `POST /api/v1/checkouts`. Subscription checkouts are deposit-only and require `line_items`. Subscription checkouts use the same line item formats as purchase checkouts: either existing products by `product_id` or inline dynamic products with `name`, `price_cents`, and `quantity`. The `subscription_data.interval` value can be `day`, `week`, `month`, or `year`. For quarterly billing, use `interval: "month"` and `interval_count: 3`. ### Subscription Parameters | Parameter | Required | Description | | - | - | - | | `subscription_data.interval` | Yes | Billing interval. Must be `day`, `week`, `month`, or `year`. | | `subscription_data.interval_count` | Yes | Number of intervals between charges. Use `interval: "month"` and `interval_count: 3` for quarterly billing. | ```json theme={null} { "customer_id": "cus_aaN5GMMF8CFpsYMuEnN9DPFMtGQaVDQZ", "type": "deposit", "line_items": [ { "name": "Premium Monthly Plan", "price_cents": 2999, "quantity": 1, "sku": "PREMIUM-MONTHLY", "url": "https://images.unsplash.com/photo-1516321318423-f06f85e504b3?auto=format&fit=crop&w=800&q=80", "dedup": true } ], "subscription_data": { "interval": "month", "interval_count": 1 } } ``` ```bash Curl 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" }' ``` ```ruby Ruby theme={null} require 'net/http' require 'uri' require 'json' uri = URI.parse('https://api-sandbox.paywithsoap.com/api/v1/checkouts') request = Net::HTTP::Post.new(uri) request.content_type = 'application/json' request['Authorization'] = 'Bearer YOUR_API_KEY' request.body = { customer_id: 'cus_vi57KegYgcRqcGHqip8q6UZiqtrwMT870', type: 'deposit' }.to_json response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http| http.request(request) end puts response.body ``` ```javascript JavaScript theme={null} const fetch = require('node-fetch'); const options = { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer YOUR_API_KEY' }, body: JSON.stringify({ customer_id: 'cus_vi57KegYgcRqcGHqip8q6UZiqtrwMT870', type: 'deposit' }) }; fetch('https://api-sandbox.paywithsoap.com/api/v1/checkouts', options) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); ``` ```python Python theme={null} import requests import json url = "https://api-sandbox.paywithsoap.com/api/v1/checkouts" headers = { "Content-Type": "application/json", "Authorization": "Bearer YOUR_API_KEY" } data = { "customer_id": "cus_vi57KegYgcRqcGHqip8q6UZiqtrwMT870", "type": "deposit" } response = requests.post(url, headers=headers, json=data) print(response.json()) ``` ```json Response theme={null} { "url": "https://wallet-sandbox.paywithsoap.com?clientSecret=HMC3VTosbzJd7cLsoP3geC5QmSz8jqF6", "id": "chk_HBq6ExeoRDMPFCCabR8n1h7S1towds7K", "client_secret": "HMC3VTosbzJd7cLsoP3geC5QmSz8jqF6", "line_items": [], "line_items_total_amount_cents": null, "balance_amount_cents": null, "type": "deposit", "fixed_amount_cents": null, "experience": null, "payment_options": null } ``` > [!NOTE] > > Redirect the customer to `url`, or embed it in an ` ``` > [!WARNING] > > Without `allow="payment"` the checkout still renders and cards work, but Apple Pay / Google Pay buttons will not appear or will fail to open. Without `allow="geolocation"`, location checks that need the browser's location fail (see below). The other permissions (`camera`, `microphone`, `clipboard-write`) support identity verification and copy actions used by some flows. ### Location checks: `geolocation` on every iframe around the checkout The browser lets the checkout ask for a location only when **every** iframe between your top-level page and the checkout passes `geolocation` on. One iframe without it blocks location for everything inside it. So if the checkout's iframe sits inside another iframe (a game frame, a wrapper page), add `geolocation` (and `payment`) to that iframe's `allow` too, all the way up to your top-level page. If a page around the checkout sends a `Permissions-Policy` header that names `geolocation`, its allowlist must include Soap's checkout origin, for example `Permissions-Policy: geolocation=(self "https://wallet.paywithsoap.com")` (`https://wallet-sandbox.paywithsoap.com` in sandbox). When a frame blocks location, the browser refuses without showing a prompt. Customers then see a location card ("Allow location to continue", or "This page can't ask for your location") even though location is allowed in their browser. They can't get past the location check, unless your account has the IP-based fallback turned on and it places them. Sandbox ends a deposit whose frame blocks location just as production does, so an embed that blocks location fails while you test it instead of going on to the payment form. To check an embed, open your page in Chrome with the checkout loaded, open DevTools, pick the checkout's frame in the Console's context menu (it reads `top` until you change it), and run: ```js theme={null} document.featurePolicy.allowsFeature('geolocation') ``` It must print `true`. `false` means the checkout's iframe, or an iframe or header around it, doesn't pass `geolocation` on. ## 3. Know when checkout completes Use **two signals**, in order of authority: ### Webhooks (source of truth) Payment state is confirmed server-side. Always reconcile off [webhooks](/api-reference/api-v1/webhooks/webhooks) — never treat a client-side event as proof of payment. ### `return_url` + `postMessage` (UX hint) On completion the checkout redirects **within the iframe** to your `return_url`. Because that page loads inside the frame, it can notify your top-level page with `postMessage`: ```html theme={null} ``` Listen for it on the embedding page to update your UI (close the frame, show a receipt, etc.): ```javascript theme={null} window.addEventListener('message', (event) => { if (event.origin !== 'https://your-site.com') return; if (event.data?.type === 'soap:checkout-complete') { // update UI — then confirm the payment via your webhook / backend } }); ``` > [!NOTE] > > The completion message is sent by **your own `return_url` page** (it loads inside the iframe after the checkout redirects to it), so `event.origin` is *your* site's origin — not the Soap wallet domain. Validate it against your own origin as shown above, and treat the message as a UX hint only: confirm the payment via webhooks. ## Caveats > [accordion] Apple Pay requires registering your embedding domain > > Apple validates Apple Pay against the **top-level page domain** — the site hosting the iframe, not the checkout iframe itself. To offer Apple Pay in-frame you need both pieces from this guide: your embedding domain registered with Soap for Apple Pay web merchant validation (see [Before you start](#before-you-start-register-your-embedding-domain)), and the session created with `experience: "iframe"`. At payment time the checkout detects your top-level domain automatically — the only ongoing requirement is keeping the verification file from [Before you start](#before-you-start-register-your-embedding-domain) hosted. > [accordion] Bank login (Plaid / Link Money) may open a new window > > Banks refuse to be framed, so OAuth-style bank connection can open in a popout/new window and return control to the iframe afterward. Every other method — cards, Apple Pay, Google Pay — stays fully in-frame. > [accordion] Sandbox vs. production URLs > > Sandbox checkout URLs are on `wallet-sandbox.paywithsoap.com`; production on `wallet.paywithsoap.com`. The `url` in the API response already points at the right one for the key you used. # Introduction Source: https://docs.paywithsoap.com/get_started/introduction AI-native payments infrastructure for complex, compliance-heavy payment flows. ## Why Soap? We built Soap to unify payments, compliance, and fraud prevention into one AI-native infrastructure layer for merchants, platforms, and processors operating complex payment flows. * **Faster Go-Live**: Reduce the delays caused by fragmented underwriting, compliance reviews, and processor onboarding. * **Modern Infrastructure**: Replace brittle portals and disconnected vendor stacks with one implementation surface. * **Redundancy**: Add multiple processors and payment methods off the shelf so you can route around outages or coverage gaps. * **Connected Systems**: Keep payments, identity, geolocation, and fraud signals in one place so risk decisions improve over time. ## Our Solution Soap provides integrated payments, compliance, and fraud prevention capabilities for complex and regulated payment programs. * Process payments with different methods through different processors. * Run KYC checks when needed. * Run geolocation checks at critical moments in the user journey. Everything is customizable to your needs. Soap is built for teams handling operationally complex flows across digital commerce, marketplaces, digital health, gaming, and emerging agentic use cases. # Quickstart Source: https://docs.paywithsoap.com/get_started/quickstart Learn how to make your first API call with Soap ## Environments Soap provides two environments for development and production use: ### Sandbox Use the sandbox environment for testing and development: * Dashboard: [https://dashboard-sandbox.paywithsoap.com](https://dashboard-sandbox.paywithsoap.com) * API: [https://api-sandbox.paywithsoap.com](https://api-sandbox.paywithsoap.com) * Wallet: [https://wallet-sandbox.paywithsoap.com](https://wallet-sandbox.paywithsoap.com) ### Production For live transactions, use the production environment: * Dashboard: [https://dashboard.paywithsoap.com](https://dashboard.paywithsoap.com) * API: [https://api.paywithsoap.com](https://api.paywithsoap.com) * Wallet: [https://wallet.paywithsoap.com](https://wallet.paywithsoap.com) ## 1. Get Your API Key Sign in to your [Soap Dashboard](https://dashboard-sandbox.paywithsoap.com) and navigate to the Developer section to get your API key. While you're there, note that the Developer section also issues a separate **client secret**. You'll use your API key for almost everything in this guide; the client secret is only needed if you later call [Create Device Ping](/api-reference/api-v1/device_pings/create) from the browser. | Credential | Format | Used for | | - | - | - | | API key | `key_...` | Every endpoint in this guide | | Client secret | `secret_...` | Only `POST /api/v1/device_pings` | See [Authentication](/api-reference/introduction#authentication) for the full explanation of both credentials. ## 2. Create a Customer First, you need to create a customer in the Soap API. ```bash Curl theme={null} curl -X POST https://api-sandbox.paywithsoap.com/api/v1/customers \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"first_name": "John", "last_name": "Doe", "email": "john.doe@example.com" }' ``` ```javascript JavaScript theme={null} const response = await fetch('https://api-sandbox.paywithsoap.com/api/v1/customers', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ first_name: 'John', last_name: 'Doe', email: 'john.doe@example.com' }) }); const customer = await response.json(); console.log(customer); ``` ```python Python theme={null} import requests response = requests.post( 'https://api-sandbox.paywithsoap.com/api/v1/customers', headers={ 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, json={ 'first_name': 'John', 'last_name': 'Doe', 'email': 'john.doe@example.com' } ) print(response.json()) ``` ```ruby Ruby theme={null} require 'net/http' require 'uri' require 'json' uri = URI.parse('https://api-sandbox.paywithsoap.com/api/v1/customers') request = Net::HTTP::Post.new(uri) request.content_type = 'application/json' request['Authorization'] = 'Bearer YOUR_API_KEY' request.body = { first_name: 'John', last_name: 'Doe', email: 'john.doe@example.com' }.to_json response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http| http.request(request) end puts response.body ``` Response: ```json theme={null} { "id": "cus_LzgkjLVrNPnHqp6gUsK8TBtQPq4kf6R1", "first_name": "John", "last_name": "Doe", "email": "john.doe@example.com", "internal_id": null, "phone_number": null, "date_of_birth": null, "created_at": "2025-03-05T19:41:29.994Z" } ``` ## 3. Create a Checkout Session Now, you can create a checkout session for the customer. This call should happen on the backend of your application or platform. [View the Soap Experiences PDF →](https://drive.google.com/file/d/1QJHS4QqnpExpCuNpHBd-6eDpo4lTD9KQ/view) #### Receive Payments > [card] [Draft King's Style Deposit](/api-reference/api-v1/checkouts/draftkings-deposit) > > Input form where the customer enters a custom deposit amount. > [card] [Preset Amount Deposit](/api-reference/api-v1/checkouts/preset-deposit) > > Deposit a fixed amount (e.g. \$100) into the customer's balance. > [card] [Digital Goods Purchase](/api-reference/api-v1/checkouts/sweeps-purchase) > > Purchase virtual currency, in-game tokens, and other digital goods. > [card] [Ecomm Purchase](/api-reference/api-v1/checkouts/ecomm-purchase) > > Purchase physical goods such as nutraceuticals, peptides, supplements, and more. #### Send Payments > [card] [Balance Withdrawal](/api-reference/api-v1/checkouts/balance-withdrawal) > > Input form where the customer withdraws up to their available balance. > [card] [Preset Amount Withdrawal](/api-reference/api-v1/checkouts/preset-withdrawal) > > Withdraw a fixed amount (e.g. \$100) from the customer's balance. Here's an example deposit request. Now you can redirect the customer to the hosted checkout. ```bash Curl theme={null} curl -X POST https://api-sandbox.paywithsoap.com/api/v1/checkouts \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "customer_id": "cus_LzgkjLVrNPnHqp6gUsK8TBtQPq4kf6R1", "type": "deposit" }' ``` ```javascript JavaScript theme={null} const response = await fetch('https://api-sandbox.paywithsoap.com/api/v1/checkouts', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ customer_id: 'cus_LzgkjLVrNPnHqp6gUsK8TBtQPq4kf6R1', type: 'deposit' }) }); const checkout = await response.json(); console.log(checkout); ``` ```python Python theme={null} import requests response = requests.post( 'https://api-sandbox.paywithsoap.com/api/v1/checkouts', headers={ 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, json={ 'customer_id': 'cus_LzgkjLVrNPnHqp6gUsK8TBtQPq4kf6R1', 'type': 'deposit' } ) print(response.json()) ``` ```ruby Ruby theme={null} require 'net/http' require 'uri' require 'json' uri = URI.parse('https://api-sandbox.paywithsoap.com/api/v1/checkouts') request = Net::HTTP::Post.new(uri) request.content_type = 'application/json' request['Authorization'] = 'Bearer YOUR_API_KEY' request.body = { customer_id: 'cus_LzgkjLVrNPnHqp6gUsK8TBtQPq4kf6R1', type: 'deposit' }.to_json response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http| http.request(request) end puts response.body ``` Response: ```json theme={null} { "id": "chk_xgTp6tGT9u5cnnY5SD5zUMoeca4SUtLJ", "client_secret": "HMC3VTosbzJd7cLsoP3geC5QmSz8jqF6", "url": "https://wallet-sandbox.paywithsoap.com?clientSecret=HMC3VTosbzJd7cLsoP3geC5QmSz8jqF6", "line_items": [], "line_items_total_amount_cents": null, "balance_amount_cents": null, "type": "deposit", "fixed_amount_cents": null, "experience": null, "payment_options": null } ``` Now redirect the customer to the `url` returned in the response. We handle the rest of the checkout flow. > [!TIP] > > Prefer to keep customers on your page? Instead of redirecting, embed the `url` in an `