# How to Collect Payments with Atlas

Step-by-step guide to collecting payments by initiating a checkout session via the Atlas API, redirecting customers to the hosted checkout page, and confirming payments via webhooks.

Tip

Skip the integration process and [collect payments using the Atlas UI](https://docs.tryduplo.com/atlas/guides/ui).

## [Prerequisites](https://docs.tryduplo.com/en/atlas/guides/collect-pay#prerequisites)

To follow this guide, you need the following:

- A verified Atlas account. If you don't have one, you can [sign up for free](https://atlas-app.tryduplo.com/auth/signup) and follow this guide to [verify your Atlas account](https://docs.tryduplo.com/atlas/guides/compliance).
- An Atlas API Key. You can fetch your API Key from your Atlas dashboard.
- Configured and setup webhooks on Atlas. See our guide on [Configuring and Verifying Atlas webhooks](https://docs.tryduplo.com/atlas/guides/webhooks).

## [Collecting a payment](https://docs.tryduplo.com/en/atlas/guides/collect-pay#collecting-a-payment)

To collect a payment using the Atlas API, you have to make a POST request to the [Initialize Checkout endpoint](https://docs.tryduplo.com/atlas/checkout/checkoutInitiate) with details of the customer, the amount, and currency you want to collect the payment in.

For example:

### JavaScript

```javascript
const axios = require("axios");

const initiateCheckout = async () => {
  const url = "https://atlas.tryduplo.com/api/v1/checkout/initiate";

const data = {
    currency: "NGN",
    first_name: "John",
    last_name: "Doe",
    email: "john.doe@example.com",
    amount: 1000,
    source_reference: "CHK_SRC_001",
  };

const config = {
    headers: {
      Authorization: "Bearer YOUR_API_KEY",
      "Content-Type": "application/json",
    },
  };

try {
    const response = await axios.post(url, data, config);
    console.log(response.data);
    return response.data;
  } catch (error) {
    console.error("Error:", error.response?.data || error.message);
    throw error;
  }
};

// Call the function
initiateCheckout();
```

Note

The only currency supported in your region is `NGN`.

For added security, you can [encrypt the request payload](https://docs.tryduplo.com/atlas/guides/encryption) before sending it to the Atlas API.

When you send the request, you will receive a response similar to the code block below:

### Initiate Checkout Response

```json
{
  "requestId": "abcd1234-5678-90ef-ghij-1234567890kl",
  "requestTimestamp": "2025-07-16 09:15:00",
  "message": "Checkout Transaction Initiated successfully.",
  "statusCode": 200,
  "data": {
    "checkoutUrl": "https://checkout.tryduplo.com?ref=CHK_6WZSIYEK43",
    "checkoutReference": "CHK_6WZSIYEK43",
    "amount": {
      "value": 1000,
      "currency": "NGN",
      "formatted": "NGN 1000.00"
    }
  }
}
```

The response will contain a link to a checkout page where you can redirect your customer to. Once your customer completes a payment, Atlas will verify the payment and send you a webhook to confirm the final status of the transaction.

Follow this guide to learn how you can [configure and verify webhooks from Atlas](https://docs.tryduplo.com/atlas/guides/webhooks).

Once your application verifies that the webhook was sent by Atlas and has not been used before, you can fulfil the service.

## [Related guides](https://docs.tryduplo.com/en/atlas/guides/collect-pay#related-guides)

- [Atlas Checkout](https://docs.tryduplo.com/atlas/guides/checkout)  
- [Customers & Virtual Accounts](https://docs.tryduplo.com/atlas/guides/customers)
