# 

## What you will learn

1. Retrieve an API key using Basic Auth
2. Send a test card sale to the sandbox
3. Read the transaction response


## Prerequisites

* A Paradise Gateway username and password (provided during registration)
* `curl` or any HTTP client


## Step 1: Retrieve your API key

Send a `POST` to `/v1/auth/keys` with Basic Auth (your email and password).

curl
```shell
curl -X POST \
  https://api.dev.paradisegateway.net/v1/auth/keys \
  -u "john.doe@example.com:your-password"
```

Python
```python
import requests

resp = requests.post(
    "https://api.dev.paradisegateway.net/v1/auth/keys",
    auth=("john.doe@example.com", "your-password"),
)
data = resp.json()
api_key = data["api_key"]
print("API Key:", api_key)
```

JavaScript
```javascript
const credentials = btoa("john.doe@example.com:your-password");
const resp = await fetch(
  "https://api.dev.paradisegateway.net/v1/auth/keys",
  {
    method: "POST",
    headers: { Authorization: `Basic ${credentials}` },
  }
);
const data = await resp.json();
console.log("API Key:", data.api_key);
```

### Response

```json
{
  "api_key": "KEY-abc123def456...",
  "encryption_keys": {
    "public_key": "...",
    "private_key": "..."
  },
  "correlation_id": "e9c1b2a3-f4d5-e6f7-g8h9-i0j1k2l3m4n5"
}
```

Store your keys securely
The `api_key` and `encryption_keys` are returned only once. Store them in a secrets manager or environment variable — never commit them to source control.

Save the `api_key` — you will use it in the next step.

## Step 2: Send a test sale

Use the API key from Step 1 to process a $10.00 card sale in the sandbox.

curl
```shell
curl -X POST \
  https://api.dev.paradisegateway.net/v1/transactions \
  -H "Content-Type: application/json" \
  -H "APIKEY: KEY-abc123def456..." \
  -d '{
    "type": "sale",
    "amount": 1000,
    "payment_method": {
      "type": "card",
      "card": {
        "pan": "4111111111111111",
        "expiry_month": "12",
        "expiry_year": "2027",
        "cvv": "123",
        "cardholder_name": "John Doe"
      }
    }
  }'
```

Python
```python
resp = requests.post(
    "https://api.dev.paradisegateway.net/v1/transactions",
    headers={"Content-Type": "application/json", "APIKEY": api_key},
    json={
        "type": "sale",
        "amount": 1000,
        "payment_method": {
            "type": "card",
            "card": {
                "pan": "4111111111111111",
                "expiry_month": "12",
                "expiry_year": "2027",
                "cvv": "123",
                "cardholder_name": "John Doe",
            },
        },
    },
)
txn = resp.json()
print(f"Status: {txn['response_status']}, ID: {txn['id']}")
```

JavaScript
```javascript
const txnResp = await fetch(
  "https://api.dev.paradisegateway.net/v1/transactions",
  {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "APIKEY": data.api_key,
    },
    body: JSON.stringify({
      type: "sale",
      amount: 1000,
      payment_method: {
        type: "card",
        card: {
          pan: "4111111111111111",
          expiry_month: "12",
          expiry_year: "2027",
          cvv: "123",
          cardholder_name: "John Doe",
        },
      },
    }),
  }
);
const txn = await txnResp.json();
console.log(`Status: ${txn.response_status}, ID: ${txn.id}`);
```

### Response example

```json
{
  "id": "TRANSACTION-01KEW32V6YNV11T33XGDR7TGWC",
  "object": "transaction",
  "type": "sale",
  "amount": 1000,
  "transaction_state": "completed",
  "response_status": "approved",
  "response_code": "00",
  "response_message": "The API request is approved.",
  "authorization_code": "123456",
  "payment_method": {
    "type": "card",
    "card": {
      "brand": "visa",
      "last_four": "1111",
      "funding": "credit"
    }
  },
  "correlation_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}
```

## Step 3: Understand the response

| Field | What it tells you |
|  --- | --- |
| `response_status` | `approved` — the payment succeeded |
| `response_code` | `00` — the approval code |
| `transaction_state` | `completed` — funds are captured (because it's a sale, not an auth) |
| `id` | Use this to retrieve, capture, cancel, or refund the transaction later |
| `correlation_id` | Include in support requests for faster troubleshooting |


## What you built

![image](https://files.modern-mermaid.live/images/1776276612814-mermaid-diagram-1776276612989.png)

## Next steps

* [Build a checkout page](/docs/tutorials/build-checkout-page) — end-to-end tutorial
* [Authorize and capture separately](/docs/how-tos/process-payments/authorize-capture-separately) — two-step flow
* [Sandbox vs production](/docs/get-started/sandbox-vs-production) — test card numbers and environment differences