Accept stablecoin payments, get paid in yenステーブルコインで受け取り、円で入金
Your server creates an order and sends the buyer to a checkout page hosted by TRADOM. The buyer pays in USDC or USDT. TRADOM confirms the deposit, sends a webhook event to your server, and pays you in yen. You build no crypto, wallet or QR screens.
貴社サーバーで注文を作成し、顧客をトレーダム ペイメントの決済ページへ遷移させます。顧客は USDC または USDT で支払い、トレーダム ペイメントが着金を確認して Webhook イベントを送信し、貴社へ円で入金します。暗号資産・ウォレット・QR の画面を貴社で作る必要はありません。
Purple: coin from the buyer to TRADOM. Green: yen from TRADOM to you. The buyer only sees the TRADOM checkout page.
紫:顧客からトレーダム ペイメントへのコイン。緑:トレーダム ペイメントから貴社への円。顧客に表示されるのはトレーダム ペイメントの決済ページのみです。
Before you start事前準備
| Item項目 | Details内容 |
|---|---|
| Base URLベース URL | Staging: https://payment-stg.tradom.jpProduction: https://payment.tradom.jp (SDK default; release date to be announced)ステージング:https://payment-stg.tradom.jp本番: https://payment.tradom.jp(SDK の既定値。提供開始日は別途ご案内) |
| API keyAPI キー | gw_live_…, issued in the merchant dashboard. Server-side only. Send it as X-Api-Key or Authorization: Bearer.加盟店管理画面で発行する gw_live_…。サーバー側でのみ使用します。X-Api-Key または Authorization: Bearer で送信します。 |
| User-Agent | Required on every request. Requests without it are rejected.すべてのリクエストに必須です。ないリクエストは拒否されます。 |
| Rate limitレート制限 | 60 requests per minute per IP address. Above that: 429 too_many_requests.IP アドレスごとに毎分 60 リクエスト。超えると 429 too_many_requests。 |
| Field namesフィールド名 | This guide uses the API's snake_case names. The SDK uses the same fields in camelCase (checkout_token → checkoutToken).本ガイドは API の snake_case の名前で記載しています。SDK では同じフィールドを camelCase で扱います(checkout_token → checkoutToken)。 |
| Amounts and times金額と日時 | Amounts in responses are decimal strings ("12800"). Times are ISO 8601 in UTC.レスポンスの金額は10進数の文字列("12800")、日時は UTC の ISO 8601 です。 |
| Request IDリクエスト ID | Every response has an X-Request-Id header. Log it for support.すべてのレスポンスに X-Request-Id ヘッダーが付きます。お問い合わせ用にログへ残してください。 |
This guide covers SDK @tradom/payment 0.6.0 (beta). Fields and behaviour may change before 1.0.0.
本ガイドは SDK @tradom/payment 0.6.0(ベータ版)を対象としています。1.0.0 までにフィールドや挙動が変わる可能性があります。
Quickstartクイックスタート
- Install the SDK and create a client with your API key.SDK をインストールし、API キーでクライアントを作成します。
- Create an order and save
checkout_token.注文を作成し、checkout_tokenを保存します。 - Redirect the buyer to
checkout_url.顧客をcheckout_urlへ遷移させます。 - On a webhook event, read the order and ship only when
confirmedis true.Webhook イベントを受けたら注文を取得し、confirmedが true のときだけ出荷します。
npm install @tradom/payment
import { PaymentClient } from "@tradom/payment"; const client = new PaymentClient({ apiKey: process.env.TPAY_GATEWAY_KEY, baseUrl: "https://payment-stg.tradom.jp", // omit for production }); const order = await client.gateway.orders.create({ orderId: "order_12345", amount: 12800, currency: "JPY", returnUrl: "https://shop.example.com/thanks", cancelUrl: "https://shop.example.com/cart", }); if (order.status === "kyc_declined") { // No order was created. Send the buyer to order.checkoutUrl (declined page). } await db.save(order.orderId, order.checkoutToken); redirect(order.checkoutUrl);
curl https://payment-stg.tradom.jp/api/v1/gateway/orders \ -H "X-Api-Key: $TPAY_GATEWAY_KEY" \ -H "Content-Type: application/json" \ -H "User-Agent: my-shop/1.0" \ -d '{ "order_id": "order_12345", "amount": 12800, "currency": "JPY", "return_url": "https://shop.example.com/thanks", "cancel_url": "https://shop.example.com/cart" }'
When to ship出荷してよいタイミング
Ship only when the order's confirmed is true. It is true when the full amount has cleared, the order is not on hold or failed, and the deposit did not arrive after the checkout closed.
注文の confirmed が true のときだけ出荷してください。全額の着金が完了し、保留・失敗ではなく、決済ページの期限後の着金でもない場合に true になります。
confirmed: true from GET …/status
GET …/status で取得した confirmed: true
The buyer returning to return_url, or a webhook event alone
顧客が return_url に戻ったこと、Webhook イベントだけ
GET /api/v1/gateway/checkout/{checkout_token}/status · returns theレスポンス: order object注文オブジェクト
Order states注文の state
The order's state is one of eight values. Decide shipping on confirmed, not on state.
注文の state は次の8つのいずれかです。出荷は state ではなく confirmed で判断してください。
| state | Meaning意味 | Your action貴社の対応 |
|---|---|---|
| awaiting | Created or opened, or paid but not yet cleared.作成済み・表示済み、または支払い済みで着金確認中。 | Wait.待機。 |
| deposit_confirmed | Full amount received. Conversion and payout are in progress.全額を受領。換算・入金の処理中。 | Ship.出荷。 |
| on_hold | TRADOM is reviewing the order (for example a compliance or rate check, a late payment, or an underpayment). The reason is not shown.トレーダム ペイメントが確認中(コンプライアンス・レートの確認、期限後の支払い、入金不足など)。理由は表示されません。 | Do not ship. TRADOM releases or fails it.出荷しない。トレーダム ペイメントが保留解除または失敗とします。 |
| completed | You have been paid in yen. Final.貴社へ円で入金済み。確定。 | None.なし。 |
| failed | The order did not complete (processing failed, an underpayment was cancelled, or the order was cancelled). Final.注文が完了しなかった(処理の失敗、入金不足による取消、注文の取消)。確定。 | Do not ship. The buyer places a new order.出荷しない。顧客は新しい注文で支払います。 |
| expired | The payment window closed with no deposit.入金のないまま支払い期限が終了。 | None.なし。 |
| declined | The buyer did not pass screening. Final.顧客が審査を通過しなかった。確定。 | None.なし。 |
| late_deposit | A deposit arrived after the checkout closed. No webhook event is sent.決済ページの期限後に着金。Webhook イベントは送信されません。 | Do not ship. TRADOM handles it with the buyer.出荷しない。トレーダム ペイメントが顧客と対応します。 |
Amounts and timing金額と時間のルール
Amount金額
| Buyer sends顧客の送金額 | Result結果 |
|---|---|
| Exact amount表示額ちょうど | deposit_confirmed. For USD-pegged coins, a difference under $0.01 counts as exact.deposit_confirmed。USD 連動のコインは 0.01 ドル未満の差を一致とみなします。 |
| Less (underpaid)不足(入金不足) | on_hold until the network finishes the deposit, then failed. The coin is returned to the buyer automatically. There is no top-up.ネットワーク上で入金が確定するまで on_hold、その後 failed。コインは自動で顧客に返金されます。追加入金はできません。 |
| More (overpaid)超過(過払い) | deposit_confirmed. You see and receive the order amount. TRADOM contacts the buyer about the excess.deposit_confirmed。貴社には注文金額が表示・入金されます。超過分はトレーダム ペイメントが顧客に連絡して対応します。 |
Timing時間
| Ruleルール | Value値 |
|---|---|
| Payment window支払い期限 | 72 hours from order creation (expires_at).注文作成から72時間(expires_at)。 |
| Checkout session決済ページの有効時間 | 45 minutes after the buyer opens it, plus one 5-minute extension for the wallet check. Never beyond the payment window.顧客が開いてから45分(ウォレット確認のため5分の延長が1回)。支払い期限を超えることはありません。 |
| Yen rate lock円建てのレートロック | 10 minutes from the confirm step, never extended. After it ends, the buyer can take a new rate within the session.確認ステップから10分(延長なし)。終了後は、決済ページの有効時間内であれば新しいレートを取得できます。 |
| Late payment期限後の支払い | A payment sent after the rate lock ended, or first seen more than 20 minutes after it ended, becomes on_hold.レートロック終了後に送られた支払い、または終了から20分を過ぎて初めて検知された支払いは on_hold になります。 |
| Expiry期限切れ | order.expired is sent within about 5 minutes; for a rate-locked order, after the 20-minute grace.order.expired は約5分以内に送信されます(レートロック中の注文は20分の猶予の後)。 |
Webhooks
Add your endpoint URL in the merchant dashboard (Developers page). Each endpoint has its own secret whsec_…, separate from the API key. The URL must be a public https:// address.
加盟店管理画面(Developers ページ)でエンドポイント URL を登録します。エンドポイントごとに専用のシークレット whsec_…(API キーとは別)があります。URL は公開された https:// アドレスである必要があります。
Event typesイベントの種類
| type | Sent when送信タイミング | data.object |
|---|---|---|
order.on_hold | The order becomes on_hold.注文が on_hold になった。 | Order |
order.deposit_confirmed | The order becomes deposit_confirmed.注文が deposit_confirmed になった。 | Order |
order.failed | The order becomes failed.注文が failed になった。 | Order |
order.expired | The order becomes expired.注文が expired になった。 | Order |
order.completed | The order becomes completed.注文が completed になった。 | Order |
refund.{status} | A refund moves to a new refund status (six events).返金が新しい返金の status になった(6種類)。 | Refund |
No event is sent for declined or late_deposit.
declined と late_deposit ではイベントは送信されません。
Verify and handle検証と処理
Pass the raw request body, the Tradom-Signature header and the endpoint secret to constructEvent. Signatures more than 300 seconds old are rejected.
constructEvent に、加工前のリクエスト本文、Tradom-Signature ヘッダー、エンドポイントのシークレットを渡します。300秒以上前の署名は拒否されます。
import { constructEvent } from "@tradom/payment"; const event = await constructEvent( rawBody, request.headers.get("tradom-signature") ?? "", process.env.TPAY_WEBHOOK_SECRET, ); if (await db.seenEvent(event.id)) return ok(); // ignore repeats switch (event.type) { case "order.deposit_confirmed": { const order = await client.gateway.orders.retrieveStatus(event.data.object.token); if (order.confirmed) await ship(order.orderId); break; } case "refund.completed": await markRefunded(event.data.object.orderId, event.data.object.txHash); break; default: break; // new event types can be added } return ok(); // answer 2xx quickly
Delivery配信
| Ruleルール | Value値 |
|---|---|
| Guarantee保証 | At least once. Events can repeat or arrive out of order: skip an id you have seen, and read the current state before acting.少なくとも1回。重複・順不同で届くことがあるため、受信済みの id は無視し、処理前に最新の state を取得してください。 |
| Success成功の条件 | 2xx within 5 seconds. Redirects are not followed.5秒以内の 2xx。リダイレクトは追いません。 |
| Retries再送 | Up to 5 attempts per endpoint, with increasing intervals. Timing may change before 1.0.0.エンドポイントごとに最大5回、間隔を広げながら再送します。間隔は 1.0.0 までに変わる可能性があります。 |
| Testingテスト | generateTestHeaderString({ payload, secret }) builds a valid signature header.generateTestHeaderString({ payload, secret }) で有効な署名ヘッダーを作れます。 |
Refunds返金
Start a refund on a paid order by amount or percentage, then follow its status or the refund.{status} events. TRADOM reviews each refund, confirms the wallet with the buyer by email, and sends it to the wallet the buyer paid from.
支払い済みの注文に対し、金額または割合で返金を開始し、status または refund.{status} イベントで進捗を確認します。トレーダム ペイメントが内容を確認し、顧客にメールでウォレットを確認したうえで、支払いに使われたウォレットへ送金します。
const { refund } = await client.gateway.refunds.create("order_12345", { amountMode: "percent", value: "20", sellerReason: "fee_deduction", idempotencyKey: "refund-order_12345-1", }); const latest = await client.gateway.refunds.retrieve("order_12345");
curl https://payment-stg.tradom.jp/api/v1/gateway/orders/order_12345/refunds \ -H "X-Api-Key: $TPAY_GATEWAY_KEY" \ -H "Idempotency-Key: refund-order_12345-1" \ -H "Content-Type: application/json" \ -H "User-Agent: my-shop/1.0" \ -d '{ "amount_mode": "percent", "value": "20", "seller_reason": "fee_deduction" }'
| Ruleルール | Details内容 |
|---|---|
| Availability利用条件 | Switched on per merchant. Otherwise 404 not_available.加盟店ごとに有効化されます。無効の場合は 404 not_available。 |
| Partial refunds一部返金 | One at a time. While one is in review: refund_pending_review. Above what is left: exceeds_refundable.1件ずつ順に処理されます。確認中の返金があると refund_pending_review、残額を超えると exceeds_refundable。 |
| Eligible payments対象 | Real USDC and USDT payments of checkout orders. Underpaid orders are returned automatically, not through this API.決済ページ経由の注文の、実際の USDC・USDT の支払い。入金不足の注文はこの API ではなく自動で返金されます。 |
Parameters and response:パラメータとレスポンス: Refund object返金オブジェクト
Create an order注文の作成
POST /api/v1/gateway/orders · SDK client.gateway.orders.create()
Parametersパラメータ
| Field | Type | Required必須 | Description説明 |
|---|---|---|---|
order_id | string | Yes必須 | Your order ID. The same ID, amount, currency and mode returns the same order. A different amount, currency or mode returns 409 order_conflict.貴社の注文 ID。ID・金額・通貨・モードが同じなら同じ注文が返ります。金額・通貨・モードが異なると 409 order_conflict。 |
amount | number | Yes必須 | Major unit (yen or dollars), above 0. JPY is rounded to whole yen, USD to cents.主単位(円またはドル)で 0 より大きい値。JPY は円単位、USD はセント単位に丸められます。 |
currency | enum | No任意 | JPY (default) or(既定)または USD |
buyer_name | string | No任意 | Used for screening.審査に使用します。 |
buyer_email | string | No任意 | Used for screening.審査に使用します。 |
country | string | No任意 | ISO 3166-1 alpha-2 (JP). Used for screening.ISO 3166-1 alpha-2(JP)。審査に使用します。 |
items | array | No任意 | Objects with name (string) and category (string). Used for screening.name(string)と category(string)を持つオブジェクトの配列。審査に使用します。 |
return_url | string | No任意 | Absolute https:// URL, at most 200 characters.200文字以内の絶対 https:// URL。 |
cancel_url | string | No任意 | Absolute https:// URL, at most 200 characters.200文字以内の絶対 https:// URL。 |
mode | enum | No任意 | live (default),(既定)、testnet, simulate. See Testingテストを参照 |
Responseレスポンス
Both outcomes return 200. Check status.
どちらの結果も 200 で返ります。status で判別してください。
| Field | Type | Description説明 |
|---|---|---|
status | enum | ok orまたは kyc_declined |
checkout_url | string | ok: the checkout page. kyc_declined: the declined page.ok:決済ページ。kyc_declined:お断りページ。 |
checkout_token | string | ok only. Needed to read the order.ok のみ。注文の取得に必要です。 |
payment_id | integer | ok only. TRADOM's ID for the order.ok のみ。トレーダム ペイメント側の注文 ID。 |
order_id | string | ok only. Your order ID.ok のみ。貴社の注文 ID。 |
amount | string | ok only. The stored amount after rounding.ok のみ。丸め後の確定金額。 |
currency | enum | JPY · USD |
expires_at | string | ok only. End of the payment window (ISO 8601).ok のみ。支払い期限(ISO 8601)。 |
mode | enum | ok only. The mode actually used.ok のみ。実際に適用されたモード。 |
reason | string | kyc_declined only. No order is created and no event is sent.kyc_declined のみ。注文は作成されず、イベントも送信されません。 |
Order object注文オブジェクト
Returned by GET /api/v1/gateway/checkout/{checkout_token}/status, and sent as data.object in order.* events.
GET /api/v1/gateway/checkout/{checkout_token}/status のレスポンス、および order.* イベントの data.object。
| Field | Type | Description説明 |
|---|---|---|
order_id | string | Your order ID.貴社の注文 ID。 |
payment_id | integer | TRADOM's ID for the order.トレーダム ペイメント側の注文 ID。 |
token | string | Same value as checkout_token.checkout_token と同じ値。 |
state | enum | Order state注文の state |
confirmed | boolean | true = safe to ship.true なら出荷可能。 |
amount | string | Order amount.注文金額。 |
currency | enum | JPY · USD |
paid_amount | string | Coin amount paid. Empty string until paid.支払われたコインの額。支払いまでは空文字。 |
paid_currency | string | Coin paid. Empty string until paid.支払われたコイン。支払いまでは空文字。 |
paid_network | string | Network used. Empty string until paid.使われたネットワーク。支払いまでは空文字。 |
tx_hash | string | On-chain transaction. Empty string until paid.オンチェーンのトランザクション。支払いまでは空文字。 |
checkout_url | string | Checkout page.決済ページ。 |
checkout_expires_at | string | null | End of the checkout session (ISO 8601). null until the buyer opens the page.決済ページの有効期限(ISO 8601)。顧客が開くまでは null。 |
mode | enum | live · testnet · simulate |
livemode | boolean | true for real money.実際の資金なら true。 |
Refund object返金オブジェクト
POST /api/v1/gateway/orders/{order_id}/refunds · GET /api/v1/gateway/orders/{order_id}/refund · both returnレスポンス: {"refund": { … }}
Parametersパラメータ
| Field | Type | Required必須 | Description説明 |
|---|---|---|---|
amount_mode | enum | Yes必須 | amount · percent |
value | string | Yes必須 | amount: whole yen (JPY) or up to 2 decimals (USD). percent: above 0, at most 100, up to 2 decimals.amount:円単位(JPY)、小数2桁まで(USD)。percent:0 より大きく100以下、小数2桁まで。 |
seller_reason | enum | Yes必須 | fee_deduction · partial_items · other |
reason_detail | string | If otherother の場合 | At most 2,000 characters.2,000文字以内。 |
Idempotency-Key | header | No任意 | Same key and request returns the original refund. Same key, different request: idempotency_conflict.同じキー・同じ内容なら元の返金が返ります。同じキーで内容が違うと idempotency_conflict。 |
Fieldsフィールド
| Field | Type | Description説明 |
|---|---|---|
id | string | Refund ID (RF-…).返金 ID(RF-…)。 |
order_id | string | Your order ID.貴社の注文 ID。 |
status | enum | Refund status返金の status |
amount_mode | enum | amount · percent |
requested_amount | string | null | null when percent.percent の場合は null。 |
requested_percent | string | null | null when amount.amount の場合は null。 |
order_currency | enum | JPY · USD |
tokens | string | Coin amount refunded.返金されるコインの額。 |
token | string | Coin the buyer paid with.顧客が支払いに使ったコイン。 |
requested_at | string | ISO 8601 |
seller_reason | enum | fee_deduction · partial_items · other |
reason_detail | string | Empty string if none.ない場合は空文字。 |
tx_hash | string | null | null until completed.completed までは null。 |
Event objectイベントオブジェクト
Headers:ヘッダー: Tradom-Signature · Tradom-Event-Id
| Field | Type | Description説明 |
|---|---|---|
id | string | Event ID (evt_…). Use it to skip repeats.イベント ID(evt_…)。重複の判定に使います。 |
object | string | event |
type | string | Event typeイベントの種類 |
created | integer | Unix time in seconds.Unix 時間(秒)。 |
livemode | boolean | true for real money.実際の資金なら true。 |
data.object | object | Order object for order.*. Refund object plus previous_status for refund.*.order.* は注文オブジェクト。refund.* は返金オブジェクトと previous_status。 |
Enums列挙値
| Field | Values値 |
|---|---|
Order注文 state | awaiting · deposit_confirmed · on_hold · completed · failed · expired · declined · late_deposit (meanings)(意味) |
Refund返金 status | requested · approved · processing · completed · rejected · cancelled |
mode | live · testnet · simulate |
currency | JPY · USD |
amount_mode | amount · percent |
seller_reason | fee_deduction · partial_items · other |
Refund status返金の status
| status | Meaning意味 |
|---|---|
| requested | Received, waiting for review.受付済み、確認待ち。 |
| approved | Accepted by TRADOM.トレーダム ペイメントが承認。 |
| processing | Waiting on the buyer's wallet confirmation or the send. No action needed.顧客のウォレット確認または送金の待ち。対応は不要です。 |
| completed | Sent and verified. tx_hash is set.送金・確認済み。tx_hash が入ります。 |
| rejected | Not accepted by TRADOM.トレーダム ペイメントが承認しなかった。 |
| cancelled | Cancelled.取消。 |
Errorsエラー
| Field | Type | Description説明 |
|---|---|---|
status | string | error |
error | string | Error code (below).エラーコード(下表)。 |
message | string | Human-readable message.説明文。 |
param | string | The field at fault, when it applies.該当する場合、原因のフィールド。 |
details | object | Extra detail, when it applies.該当する場合、補足情報。 |
The SDK throws PaymentError with these fields plus httpStatus. It does not retry and times out after 15 seconds. Keep a default branch: codes can be added.
SDK はこれらのフィールドと httpStatus を持つ PaymentError を投げます。自動で再試行せず、15秒でタイムアウトします。コードは追加される可能性があるため、既定の分岐を残してください。
| Endpoint対象 | Codesコード |
|---|---|
| All共通 | missing_api_key 401 · invalid_api_key 403 · invalid_json 400 · too_many_requests 429 · service_unavailable 503 · maintenance_mode 503 · internal_error 500 |
| Create an order注文の作成 | parameter_missing · parameter_invalid · invalid_return_url · invalid_cancel_url · amount_limit_exceeded · merchant_wallet_missing · rate_unavailable 503 · order_conflict 409 |
| Read an order注文の取得 | order_not_found 404 |
| Refunds返金 | not_available 404 · refund_not_found 404 · exceeds_refundable · too_small · refund_pending_review · nothing_refundable · not_received · not_settled_with_tradom · status_not_refundable · not_a_real_deposit · underpaid · compliance_hold · idempotency_conflict |
| SDK onlySDK のみ | authentication_required · invalid_request · insecure_base_url · network_error · timeout · signature_verification_failed · invalid_webhook_payload |
Testingテスト
| mode | What you can testテストできること |
|---|---|
simulate | The full flow without coins ("Simulate payment" on the checkout page). Stops at deposit_confirmed. No payout or refund.コインを使わない全体の流れ(決済ページの「Simulate payment」)。deposit_confirmed で止まり、入金・返金は行われません。 |
testnet | Real deposit detection with test tokens. No payout or refund.テスト用トークンで実際の着金検知を確認できます。入金・返金は行われません。 |
live | Real money. From the production release.実際の資金。本番提供の開始後に利用できます。 |
Checks before go-live本番前の確認項目
- Retry the same
order_idand get the same order back. - Complete a
simulatepayment and ship only after readingconfirmed: true. - Receive
order.deposit_confirmed, verify the signature, and skip a repeatedid. - Let an order expire and receive
order.expired. - Handle
kyc_declined,429and5xxwithout breaking checkout. - Refunds can't be tried in
simulateortestnet. Contact us to test them.
- 同じ
order_idで再送し、同じ注文が返ること。 simulateで支払いを完了し、confirmed: trueを取得してから出荷処理に進むこと。order.deposit_confirmedを受信して署名を検証し、重複したidを無視すること。- 注文を期限切れにして
order.expiredを受信すること。 kyc_declined・429・5xxで購入画面が壊れないこと。- 返金は
simulate・testnetでは試せません。テスト方法はお問い合わせください。
Supportサポート
| For内容 | Contact連絡先 |
|---|---|
| API, SDK, webhooks, integrationAPI・SDK・Webhook・連携 | developers@tradom.jp |
| Orders, payouts, buyer questions, other注文・入金・顧客からのお問い合わせ・その他 | support-payment@tradom.jp |
Include the X-Request-Id, order_id, checkout_token, the time and the mode.
お問い合わせの際は X-Request-Id・order_id・checkout_token・日時・mode をお知らせください。