EC Checkout Integration GuideEC 決済 連携ガイド

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 の画面を貴社で作る必要はありません。

Your server 貴社サーバー API key + webhook secret API キー・シークレットを保管 Buyer 顧客 browser + own wallet ブラウザ・自身のウォレット TRADOM トレーダム ペイメント checkout · receives coin · pays ¥ 決済ページ・着金・円での入金 1 Create order: order_id, amount, currency 注文作成:order_id・金額・通貨 checkout_url · checkout_token · expires_at 2 Redirect to checkout_url checkout_url へ遷移 3 Sends USDC / USDT (exact amount) USDC / USDT を送金(表示額ちょうど) 4 Webhook: order.deposit_confirmed 5 Read status → confirmed: true → ship ステータス取得 → confirmed: true → 出荷 Converts coin → JPY コイン → 円に換算 6 Yen to your bank account · order.completed 貴社口座へ円で入金・order.completed Yen orders: the locked yen amount less the fee 円建て注文:ロックした円金額から手数料を差し引いた額

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ベース URLStaging: https://payment-stg.tradom.jp
Production: 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-AgentRequired 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リクエスト IDEvery response has an X-Request-Id header. Log it for support.すべてのレスポンスに X-Request-Id ヘッダーが付きます。お問い合わせ用にログへ残してください。
info

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クイックスタート

  1. Install the SDK and create a client with your API key.SDK をインストールし、API キーでクライアントを作成します。
  2. Create an order and save checkout_token.注文を作成し、checkout_token を保存します。
  3. Redirect the buyer to checkout_url.顧客を checkout_url へ遷移させます。
  4. On a webhook event, read the order and ship only when confirmed is true.Webhook イベントを受けたら注文を取得し、confirmed が true のときだけ出荷します。
Terminal
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);

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 になります。

check_circleShip on出荷してよい

confirmed: true from GET …/status

GET …/status で取得した confirmed: true

cancelNever ship on出荷の根拠にしない

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 で判断してください。

stateMeaning意味Your action貴社の対応
awaitingCreated or opened, or paid but not yet cleared.作成済み・表示済み、または支払い済みで着金確認中。Wait.待機。
deposit_confirmedFull amount received. Conversion and payout are in progress.全額を受領。換算・入金の処理中。Ship.出荷。
on_holdTRADOM 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.出荷しない。トレーダム ペイメントが保留解除または失敗とします。
completedYou have been paid in yen. Final.貴社へ円で入金済み。確定。None.なし。
failedThe 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.出荷しない。顧客は新しい注文で支払います。
expiredThe payment window closed with no deposit.入金のないまま支払い期限が終了。None.なし。
declinedThe buyer did not pass screening. Final.顧客が審査を通過しなかった。確定。None.なし。
late_depositA 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イベントの種類

typeSent when送信タイミングdata.object
order.on_holdThe order becomes on_hold.注文が on_hold になった。Order
order.deposit_confirmedThe order becomes deposit_confirmed.注文が deposit_confirmed になった。Order
order.failedThe order becomes failed.注文が failed になった。Order
order.expiredThe order becomes expired.注文が expired になった。Order
order.completedThe 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秒以上前の署名は拒否されます。

Node.js
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");
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パラメータ

FieldTypeRequired必須Description説明
order_idstringYes必須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。
amountnumberYes必須Major unit (yen or dollars), above 0. JPY is rounded to whole yen, USD to cents.主単位(円またはドル)で 0 より大きい値。JPY は円単位、USD はセント単位に丸められます。
currencyenumNo任意JPY (default) or(既定)または USD
buyer_namestringNo任意Used for screening.審査に使用します。
buyer_emailstringNo任意Used for screening.審査に使用します。
countrystringNo任意ISO 3166-1 alpha-2 (JP). Used for screening.ISO 3166-1 alpha-2(JP)。審査に使用します。
itemsarrayNo任意Objects with name (string) and category (string). Used for screening.name(string)と category(string)を持つオブジェクトの配列。審査に使用します。
return_urlstringNo任意Absolute https:// URL, at most 200 characters.200文字以内の絶対 https:// URL。
cancel_urlstringNo任意Absolute https:// URL, at most 200 characters.200文字以内の絶対 https:// URL。
modeenumNo任意live (default),(既定)、testnet, simulate. See Testingテストを参照

Responseレスポンス

Both outcomes return 200. Check status.

どちらの結果も 200 で返ります。status で判別してください。

FieldTypeDescription説明
statusenumok orまたは kyc_declined
checkout_urlstringok: the checkout page. kyc_declined: the declined page.ok:決済ページ。kyc_declined:お断りページ。
checkout_tokenstringok only. Needed to read the order.ok のみ。注文の取得に必要です。
payment_idintegerok only. TRADOM's ID for the order.ok のみ。トレーダム ペイメント側の注文 ID。
order_idstringok only. Your order ID.ok のみ。貴社の注文 ID。
amountstringok only. The stored amount after rounding.ok のみ。丸め後の確定金額。
currencyenumJPY · USD
expires_atstringok only. End of the payment window (ISO 8601).ok のみ。支払い期限(ISO 8601)。
modeenumok only. The mode actually used.ok のみ。実際に適用されたモード。
reasonstringkyc_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。

FieldTypeDescription説明
order_idstringYour order ID.貴社の注文 ID。
payment_idintegerTRADOM's ID for the order.トレーダム ペイメント側の注文 ID。
tokenstringSame value as checkout_token.checkout_token と同じ値。
stateenumOrder state注文の state
confirmedbooleantrue = safe to ship.true なら出荷可能。
amountstringOrder amount.注文金額。
currencyenumJPY · USD
paid_amountstringCoin amount paid. Empty string until paid.支払われたコインの額。支払いまでは空文字。
paid_currencystringCoin paid. Empty string until paid.支払われたコイン。支払いまでは空文字。
paid_networkstringNetwork used. Empty string until paid.使われたネットワーク。支払いまでは空文字。
tx_hashstringOn-chain transaction. Empty string until paid.オンチェーンのトランザクション。支払いまでは空文字。
checkout_urlstringCheckout page.決済ページ。
checkout_expires_atstring | nullEnd of the checkout session (ISO 8601). null until the buyer opens the page.決済ページの有効期限(ISO 8601)。顧客が開くまでは null。
modeenumlive · testnet · simulate
livemodebooleantrue 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パラメータ

FieldTypeRequired必須Description説明
amount_modeenumYes必須amount · percent
valuestringYes必須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_reasonenumYes必須fee_deduction · partial_items · other
reason_detailstringIf otherother の場合At most 2,000 characters.2,000文字以内。
Idempotency-KeyheaderNo任意Same key and request returns the original refund. Same key, different request: idempotency_conflict.同じキー・同じ内容なら元の返金が返ります。同じキーで内容が違うと idempotency_conflict。

Fieldsフィールド

FieldTypeDescription説明
idstringRefund ID (RF-…).返金 ID(RF-…)。
order_idstringYour order ID.貴社の注文 ID。
statusenumRefund status返金の status
amount_modeenumamount · percent
requested_amountstring | nullnull when percent.percent の場合は null。
requested_percentstring | nullnull when amount.amount の場合は null。
order_currencyenumJPY · USD
tokensstringCoin amount refunded.返金されるコインの額。
tokenstringCoin the buyer paid with.顧客が支払いに使ったコイン。
requested_atstringISO 8601
seller_reasonenumfee_deduction · partial_items · other
reason_detailstringEmpty string if none.ない場合は空文字。
tx_hashstring | nullnull until completed.completed までは null。

Event objectイベントオブジェクト

Headers:ヘッダー: Tradom-Signature · Tradom-Event-Id

FieldTypeDescription説明
idstringEvent ID (evt_…). Use it to skip repeats.イベント ID(evt_…)。重複の判定に使います。
objectstringevent
typestringEvent typeイベントの種類
createdintegerUnix time in seconds.Unix 時間(秒)。
livemodebooleantrue for real money.実際の資金なら true。
data.objectobjectOrder object for order.*. Refund object plus previous_status for refund.*.order.* は注文オブジェクト。refund.* は返金オブジェクトと previous_status。

Enums列挙値

FieldValues値
Order注文 stateawaiting · deposit_confirmed · on_hold · completed · failed · expired · declined · late_deposit (meanings)(意味)
Refund返金 statusrequested · approved · processing · completed · rejected · cancelled
modelive · testnet · simulate
currencyJPY · USD
amount_modeamount · percent
seller_reasonfee_deduction · partial_items · other

Refund status返金の status

statusMeaning意味
requestedReceived, waiting for review.受付済み、確認待ち。
approvedAccepted by TRADOM.トレーダム ペイメントが承認。
processingWaiting on the buyer's wallet confirmation or the send. No action needed.顧客のウォレット確認または送金の待ち。対応は不要です。
completedSent and verified. tx_hash is set.送金・確認済み。tx_hash が入ります。
rejectedNot accepted by TRADOM.トレーダム ペイメントが承認しなかった。
cancelledCancelled.取消。

Errorsエラー

FieldTypeDescription説明
statusstringerror
errorstringError code (below).エラーコード(下表)。
messagestringHuman-readable message.説明文。
paramstringThe field at fault, when it applies.該当する場合、原因のフィールド。
detailsobjectExtra 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テスト

modeWhat you can testテストできること
simulateThe full flow without coins ("Simulate payment" on the checkout page). Stops at deposit_confirmed. No payout or refund.コインを使わない全体の流れ(決済ページの「Simulate payment」)。deposit_confirmed で止まり、入金・返金は行われません。
testnetReal deposit detection with test tokens. No payout or refund.テスト用トークンで実際の着金検知を確認できます。入金・返金は行われません。
liveReal money. From the production release.実際の資金。本番提供の開始後に利用できます。

Checks before go-live本番前の確認項目

  • Retry the same order_id and get the same order back.
  • Complete a simulate payment and ship only after reading confirmed: true.
  • Receive order.deposit_confirmed, verify the signature, and skip a repeated id.
  • Let an order expire and receive order.expired.
  • Handle kyc_declined, 429 and 5xx without breaking checkout.
  • Refunds can't be tried in simulate or testnet. 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 をお知らせください。