# Quickstart: Create Your First Card Present Payment

This guide helps you create your first successful hardware-integrated payment transaction in the **Sandbox** environment. You will authenticate with the API and submit a payment request using real-world **Card Present (CP)** data formats—simulating a physical chip or magnetic stripe interaction.

## Requirements

Before you begin, ensure you have:

* **Sandbox credentials**: `client_id` and `client_secret` (available in the developer portal).
* **Sandbox base URL**: `https://api-sbx.pre.globalgetnet.com`.
* **Terminal identifiers**: Valid `terminal_number`, `logical_code`, and `serial_number` registered to your account.

## Step 1: Get an Access Token

Authenticate with the API using your credentials. Combine your `client_id` and `client_secret` with a colon (`:`), Base64 encode the result, and use it in the Authorization header.

```bash
curl --request POST \
  --url https://api-sbx.pre.globalgetnet.com/authentication/oauth2/access_token \
  --header 'authorization: Basic <BASE64(client_id:client_secret)>' \
  --header 'content-type: application/x-www-form-urlencoded' \
  --data grant_type=client_credentials

```

The response includes an `access_token` that expires in approximately one hour:

```json
{
  "access_token": "eyJ0eXAiOiJKV1QiLCJraWQiOiI1amhLMy9xK0ZpK0tTRkIrRUwwN3VhMFYwdGM9IiwiYWxnIjoiUlMyNTYifQ...",
  "token_type": "Bearer",
  "expires_in": 3599
}

```

## Step 2: Create a Card Present Payment

Create a single-step payment that authorizes and captures the funds in one operation. For Card Present, you must use **Direct** payment methods and include the **`terminal`** and **`card`** (Entry Mode/EMV) objects.

### Implementation: Chip + Online PIN

This example simulates a transaction where a card is inserted into a chip reader and verified with a PIN.

```bash
curl --request POST \
  --url https://api-sbx.pre.globalgetnet.com/dpm/payments-gwproxy/v2/payments \
  --header 'authorization: Bearer <ACCESS_TOKEN>' \
  --header 'content-type: application/json' \
  --header 'x-seller-id: <YOUR_SELLER_ID>' \
  --header 'x-transaction-channel-entry: XX' \
  --data '{
  "idempotency_key": "qs-cp-test-001",
  "request_id": "f0612285-9493-4c2c-a05a-00268a51ea3a",
  "order_id": "RETAIL-TEST-101",
  "data": {
    "amount": 10000,
    "currency": "CLP",
    "payment": {
      "payment_id": "your-unique-payment-id",
      "payment_method": "DIRECT_CREDIT",
      "transaction_type": "FULL",
      "terminal": {
        "terminal_number": "21000334",
        "logical_code": "21000334",
        "serial_number": "CS21000334A"
      },
      "card": {
        "entry_mode": "chip",
        "cardholder_verification_method": "online_pin",
        "pin_block": "A0B6BA8D53C8D3C3",
        "ksn": "BC756011020000400001",
        "emv": "9f2701809f3303e0f8c8950580000080009f37045d21705a9f100706010a03a0b8089f2608819ba36f3f7934149f360205b782021c009c01009f1a0204849a032002279f02060000000309605F2A0200325f3401019f34031e03009f120c56495341204352454449544f5f201a2f435249535449414E2047414C494E444F2043484156455A2020",
        "aid": "A0000000031010"
      }
    }
  }
}'

```

A successful payment returns a response with `status: "APPROVED"`:

```json
{
  "payment_id": "6137278d-28a6-4293-9343-c73fbb2d9bda",
  "status": "APPROVED",
  "amount": 10000,
  "currency": "CLP",
  "authorization_code": "204050",
  "reason_message": "captured"
}

```

## Troubleshooting

**401 Unauthorized**: Your access token may have expired. Request a new token and try again.

**422 Validation Error**: Ensure all Card Present mandatory fields are present:

* `x-transaction-channel-entry: XX` (Header)
* `data.payment.terminal.terminal_number`, `data.payment.terminal.logical_code`, and `data.payment.terminal.serial_number`
* `data.payment.card.entry_mode` (`chip` or `magnetic_stripe`)
* `data.payment.card.emv` (Mandatory if `entry_mode` is `chip`)
* `pin_block` and `ksn` (Mandatory if `cardholder_verification_method` is `online_pin`)

**Payment Declined**: Check the `reason_message`. In Sandbox, ensure you are using a valid simulated `terminal_number`.

## Next Steps

Congratulations! You've successfully processed your first physical card transaction. To continue:

- **[Single-Step CP Payments]()**: Detailed guide on immediate sale-and-capture flows.
- **[Pre-authorized CP Payments]()**: Learn how to implement two-step flows for reservations.
- **[EMV Technology Guide]()**: Understand the structure of Tag-Length-Value (TLV) data.