> ## 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.

# 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.

## 2. Create a Customer

First, you need to create a customer in the Soap API.

<CodeGroup>
  ```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
  ```
</CodeGroup>

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.

<a href="https://drive.google.com/file/d/1QJHS4QqnpExpCuNpHBd-6eDpo4lTD9KQ/view" target="_blank">View the Soap Experiences PDF →</a>

#### Receive Payments

<CardGroup cols={2}>
  <Card title="Draft King's Style Deposit" icon="keyboard" href="/api-reference/api-v1/checkouts/draftkings-deposit">
    Input form where the customer enters a custom deposit amount.
  </Card>

  <Card title="Preset Amount Deposit" icon="money-bill" href="/api-reference/api-v1/checkouts/preset-deposit">
    Deposit a fixed amount (e.g. \$100) into the customer's balance.
  </Card>

  <Card title="Digital Goods Purchase" icon="coins" href="/api-reference/api-v1/checkouts/sweeps-purchase">
    Purchase virtual currency, in-game tokens, and other digital goods.
  </Card>

  <Card title="Ecomm Purchase" icon="cart-shopping" href="/api-reference/api-v1/checkouts/ecomm-purchase">
    Purchase physical goods such as nutraceuticals, peptides, supplements, and more.
  </Card>
</CardGroup>

#### Send Payments

<CardGroup cols={2}>
  <Card title="Balance Withdrawal" icon="wallet" href="/api-reference/api-v1/checkouts/balance-withdrawal">
    Input form where the customer withdraws up to their available balance.
  </Card>

  <Card title="Preset Amount Withdrawal" icon="money-check-dollar" href="/api-reference/api-v1/checkouts/preset-withdrawal">
    Withdraw a fixed amount (e.g. \$100) from the customer's balance.
  </Card>
</CardGroup>

Here's an example deposit request. Now you can redirect the customer to the hosted checkout.

<CodeGroup>
  ```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
  ```
</CodeGroup>

Response:

```json theme={null}
{
  "id": "chk_xgTp6tGT9u5cnnY5SD5zUMoeca4SUtLJ",
  "url": "https://wallet-sandbox.paywithsoap.com?clientSecret=HMC3VTosbzJd7cLsoP3geC5QmSz8jqF6",
  "line_items": [],
  "line_items_total_amount_cents": null,
  "balance_amount_cents": null,
  "type": "deposit",
  "experience": 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 `<iframe allow="payment">`. See [Embedded Checkout](/get_started/embedded-checkout).
</Tip>

## 4. Handle the Webhook

You will receive webhooks as the customer completes the checkout.

More on webhooks can be found in the [Webhooks](/api-reference/api-v1/webhooks) section.

## Full Example

A complete backend + frontend integration showing how to create a checkout session and redirect the customer.

### Backend (Node.js)

```javascript theme={null}
app.post('/deposit', async (req, res) => {
  try {
    const user = { soap_customer_id: 'cus_LzgkjLVrNPnHqp6gUsK8TBtQPq4kf6R1' }
    
    const response = await fetch('https://api-sandbox.paywithsoap.com/api/v1/checkouts', {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${process.env.SOAP_API_KEY}`,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        customer_id: user.soap_customer_id,
        type: 'deposit'
      })
    });
    
    const checkoutSession = await response.json();
    
    res.json({ url: checkoutSession.url });
  } catch (error) {
    res.status(500).json({ error: error.message });
  }
});
```

### Frontend (JavaScript)

```javascript theme={null}
document.getElementById('checkout-button').addEventListener('click', async () => {
  try {
    const response = await fetch('/deposit', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' }
    });
    
    const { url } = await response.json();
    window.location.href = url;

    // Or, to keep the customer on your page, embed instead of redirecting:
    // document.querySelector('iframe').src = url;  // <iframe allow="payment">
  } catch (error) {
    console.error('Error redirecting to checkout:', error);
  }
});
```

To render checkout in-context instead of redirecting, see [Embedded Checkout](/get_started/embedded-checkout).

## Additional Examples + Webhook Handling

Check out our sample code repository for a complete integration including webhook handling.

<Card title="Sample Code Repository" icon="github" href="https://github.com/Soap-Payments/sample-code">
  Full working examples with webhook handling, error management, and more.
</Card>
