# 스테이블코인 결제 API 문서

공개 테스트넷 베타에서 Ethereum Sepolia와 Base Sepolia의 테스트 USDC, TRON Nile의 테스트 USDT를 사용합니다. 실제 비용은 0원입니다.

## 테스트 키로 지원 자산 조회

대시보드에서 프로젝트의 테스트 키를 발급하세요. ZERO_TO_ONE_PAY_API_KEY는 서버 환경에 보관합니다. API 주소는 https://api.0to1pay.com이고 HTTP 경로는 /v1에서 시작합니다.

```
curl --fail-with-body https://api.0to1pay.com/v1/chain/assets \
  -H "Authorization: Bearer ${ZERO_TO_ONE_PAY_API_KEY}"
```

## 주문에서 이용권 지급까지

연결에 일회용 수취 주소를 등록하고, 주문과 견적을 생성하세요. 구매자는 송금 전과 거래 해시 제출 시 지갑으로 서명합니다. 웹훅 원문을 서명 검증하고 지급 명령을 영속화한 뒤 워커에서 이용권을 지급하세요. Next.js 예제는 이 흐름을 Base Sepolia에서 실행합니다.

## 네트워크와 연결

- `GET /v1/chain/assets` · `listChainAssets` · 활성 네트워크 및 자산 조회 (`payments:read`)
- `POST /v1/chain/connections` · `createChainConnection` · 감시 전용 체인 연결 생성 (`connections:manage`)
- `POST /v1/connections/{connection_id}/chain-recipients` · `registerChainRecipients` · 일회용 수취 주소 등록 (`connections:manage`)
- `GET /v1/connections` · `listConnections` · 프로젝트 연결 목록 조회 (`connections:read`)
- `GET /v1/connections/{connection_id}` · `getConnection` · 연결 정보 조회 (`connections:read`)
- `POST /v1/connections/{connection_id}/disable` · `disableConnection` · 연결의 신규 수납 중지 (`connections:manage`)

## 주문과 견적

- `POST /v1/payments` · `createPayment` · 주문 결제 생성 (`payments:write`)
- `GET /v1/payments` · `listPayments` · 프로젝트 결제 목록 조회 (`payments:read`)
- `GET /v1/payments/{payment_id}` · `getPayment` · 결제·판정·이행 상세 조회 (`payments:read`)
- `GET /v1/payments/{payment_id}/receipt` · `getPaymentReceipt` · 자산과 네트워크별 확정 수령액 조회 (`payments:read`)
- `POST /v1/payments/{payment_id}/quotes` · `createQuote` · 수취 주소 예약 및 결제 조건 확정 (`payments:write`)
- `GET /v1/quotes/{quote_id}` · `getQuote` · 확정 견적 조회 (`payments:read`)
- `POST /v1/payments/{payment_id}/attempts` · `createAttempt` · 견적의 송금 시도 생성 (`attempts:initiate`)
- `GET /v1/payments/{payment_id}/attempts` · `listAttempts` · 결제 시도 목록 조회 (`payments:read`)
- `GET /v1/attempts/{attempt_id}` · `getAttempt` · 결제 시도 상세 조회 (`payments:read`)
- `POST /v1/payments/{payment_id}/cancel` · `cancelPayment` · 신규 결제 시도 중지 (`payments:write`)

## 지갑 승인과 검증

- `POST /v1/quotes/{quote_id}/chain-intents` · `createChainIntent` · 구매자 지갑 서명 요청 생성 (`payments:write`)
- `POST /v1/quotes/{quote_id}/chain-intents/{intent_id}/authorize` · `authorizeChainIntent` · 선택한 지갑으로 견적 승인 (`payments:write`)
- `POST /v1/quotes/{quote_id}/chain-intents/{intent_id}/submit` · `submitChainIntent` · 서명한 거래 증빙 제출 (`payments:write`)
- `POST /v1/payments/{payment_id}/verify` · `requestVerification` · 결제 증빙 검증 요청 (`payments:verify`)
- `POST /v1/payments/{payment_id}/reviews` · `reviewPayment` · 감사 기록을 남기는 결제 검토 (`payments:review`)
- `GET /v1/operations/{operation_id}` · `getOperation` · 작업 결과 조회 (`operations:read`)

## 웹훅과 이벤트

- `POST /v1/webhook-endpoints` · `createWebhookEndpoint` · 웹훅 엔드포인트 등록 (`webhooks:manage`)
- `GET /v1/webhook-endpoints/{endpoint_id}` · `getWebhookEndpoint` · 웹훅 엔드포인트 정보 조회 (`webhooks:read`)
- `POST /v1/webhook-endpoints/{endpoint_id}/rotate-secret` · `rotateWebhookSecret` · 웹훅 서명 비밀 교체 (`webhooks:manage`)
- `GET /v1/events` · `listEvents` · 커서로 프로젝트 이벤트 조회 (`events:read`)

## 상품 이행

- `GET /v1/fulfillments/{command_id}` · `getFulfillment` · 이행 명령 및 실행 상태 조회 (`fulfillment:read`)
- `POST /v1/fulfillments/{command_id}/claim` · `claimFulfillment` · 이행 명령 실행 권한 요청 (`fulfillment:execute`)
- `POST /v1/fulfillments/{command_id}/results` · `reportFulfillmentResult` · 이행 결과 보고 (`fulfillment:results`)
- `POST /v1/fulfillments/{command_id}/retry-delivery` · `retryFulfillmentDelivery` · 동일한 이행 명령 재전송 (`fulfillment:retry`)

## 구독과 사용량

- `GET /v1/billing/plans` · `listBillingPlans` · 요금제와 결제 가능한 네트워크·토큰 조회 (`billing:read`)
- `GET /v1/billing/subscription` · `getBillingSubscription` · 구독 및 API 요청 사용량 조회 (`billing:read`)
- `GET /v1/billing/invoices` · `listBillingInvoices` · 최근 구독 청구서 조회 (`billing:read`)
- `POST /v1/billing/invoices` · `createBillingInvoice` · 구독료 청구서와 지갑 서명 요청 생성 (`billing:write`)
- `GET /v1/billing/invoices/{invoice_id}` · `getBillingInvoice` · 구독 청구서 상세 조회 (`billing:read`)
- `POST /v1/billing/invoices/{invoice_id}/authorize` · `authorizeBillingInvoice` · 송금 지갑으로 구독 청구서 승인 (`billing:write`)
- `POST /v1/billing/invoices/{invoice_id}/submit` · `submitBillingInvoice` · 서명한 구독 송금 증빙 제출 (`billing:write`)
- `POST /v1/billing/test-keys` · `issueTestBillingKey` · 샌드박스 테스트 키 발급 (`billing:write`)
- `POST /v1/billing/keys` · `issueBillingKey` · 프로젝트 범위의 서버 키 발급 (`billing:write`)

## 연동 자료

- [Next.js에서 Base USDC 결제받고 웹훅으로 이용권 지급하기](https://0to1pay.com/guides/nextjs-base-usdc)
- [연동 가이드 (Markdown)](https://0to1pay.com/guides/nextjs-base-usdc.md)
- [0.01 테스트 USDC로 실행하는 데모](https://0to1pay.com/demo/base-usdc)
- [Next.js 예제 소스 (ZIP)](https://0to1pay.com/examples/nextjs-base-usdc.zip)
- [@0to1pay/server-sdk](https://www.npmjs.com/package/@0to1pay/server-sdk)
- [@0to1pay/fulfillment-sdk](https://www.npmjs.com/package/@0to1pay/fulfillment-sdk)
- [OpenAPI JSON](https://api.0to1pay.com/openapi.json)
- [프로젝트 설정에서 가맹점·프로젝트 ID 확인](https://pay.0to1pay.com/merchant#settings)
- [테스트 프로젝트와 API 키](https://pay.0to1pay.com/merchant)
