> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zafapay.com/llms.txt
> Use this file to discover all available pages before exploring further.

# クイックスタート

> 最初の決済を実装するまでのステップガイド

## 環境

| 環境         | 管理画面                                                       | API                       |
| ---------- | ---------------------------------------------------------- | ------------------------- |
| Sandbox    | [app.sandbox.zafapay.com](https://app.sandbox.zafapay.com) | `api.sandbox.zafapay.com` |
| Production | [app.zafapay.com](https://app.zafapay.com)                 | `api.zafapay.com`         |

<Note>
  開発・テスト時はSandbox環境をご利用ください。本番環境への切り替えはAPIエンドポイントのURLを変更するだけです。
</Note>

## 1. アクセストークンを取得

加盟店管理画面の「加盟店設定」から、アクセストークンを確認します。

```bash theme={null}
# 全てのAPIリクエストにAuthorizationヘッダーが必要です
Authorization: Bearer YOUR_ACCESS_TOKEN
```

<Note>
  詳しい取得方法は[認証](/ja/api-reference/authentication)を参照してください。
</Note>

## 2. 決済を作成

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.sandbox.zafapay.com/v1/payments \
    -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "amount": 100,
      "currency": "usd",
      "external_id": "order_12345"
    }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api.sandbox.zafapay.com/v1/payments', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      amount: 100,
      currency: 'usd',
      external_id: 'order_12345'
    })
  });

  const payment = await response.json();
  console.log(payment.payment_url);
  ```
</CodeGroup>

**レスポンス:**

```json theme={null}
{
  "success": true,
  "status": "pending",
  "transaction_id": "tx_abc123",
  "gateway_transaction_id": "depot_xxxxx",
  "payment_url": "https://pay.sandbox.zafapay.com/checkout/tx_abc123?sig=xxxxxxxxxxxxxxxx"
}
```

## 3. 顧客をリダイレクト

レスポンスの `payment_url` に顧客をリダイレクトします。
決済完了後、顧客は加盟店管理画面で設定した `success_redirect_url` または `failure_redirect_url` にリダイレクトされます。

## 4. 決済結果を確認

```bash theme={null}
curl https://api.sandbox.zafapay.com/v1/payments/tx_abc123 \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
```

**レスポンス:**

```json theme={null}
{
  "id": "tx_abc123",
  "status": "completed",
  "amount": 100,
  "currency": "usd"
}
```

## 次のステップ

<Columns cols={2}>
  <Card title="APIリファレンス" icon="book" href="/ja/api-reference/introduction">
    全てのAPIエンドポイントの詳細
  </Card>

  <Card title="返金を実装" icon="rotate-left" href="/ja/api-reference/payments/refund">
    決済の返金方法
  </Card>
</Columns>
