テスト方法
simulateとtestnetで決済integrationを安全に確認する
Hosted Checkoutは、資金不要の simulate と実testnet tokenを使う testnet を提供します。最初は simulate でredirectから完了画面まで確認してください。
Hosted Checkout
EC Gatewayの注文は live(既定)、testnet、simulate の3モードを受け付けます。
| モード | 用途 | 完了方法 |
|---|---|---|
live | 本番 | メインネットのUSDC / USDTを送金 |
testnet | オンチェーン試験 | Sepolia / Amoyのテストtokenを送金(testnetのtoken契約はUSDCのみ。usdt を選んでもUSDCのtestnet契約が返る) |
simulate | 資金不要のsmoke test | ホスト画面またはsimulate endpoint |
staging(Fireblocks sandbox)に対して mode を省略、または live を指定した注文は testnet として作成されます。responseの mode を確認してください。
SDK 0.5.0では注文作成から擬似着金まで実行できます。
const order = await gatewayClient.gateway.createOrder({
orderId: "test-1",
amount: 1000,
country: "JP",
mode: "simulate",
returnUrl: "https://shop.example/thanks",
});
if (order.status !== "ok") {
throw new Error(order.reason);
}
const checkoutToken = new URL(order.checkoutUrl)
.pathname.split("/").filter(Boolean).at(-1)!;
await gatewayClient.gateway.selectAsset(checkoutToken, {
token: "usdc",
network: "ethereum",
});
await gatewayClient.gateway.acceptTos(checkoutToken);
const completed =
await gatewayClient.gateway.simulateDeposit(checkoutToken);通常のredirect型integrationでは、asset選択とToS同意はHosted Checkoutが処理します。上の直接呼び出しは自動smoke test向けです。画面の「Simulate payment」でも完了できます。
このendpointは simulate 注文だけを受け付けます。live / testnet では拒否されます。
PaymentIntent
PaymentIntentは simulate が既定です。test secret key(sk_test_…) を使って、作成・確定・擬似着金を通します。sk_live_… で作成したintentは livemode: true になり、simulateDeposit は payment_intent_unexpected_state(400)で拒否されます。
const paymentIntent = await paymentIntentClient.paymentIntents.create({
paymentLinkToken: "<share_token>",
mode: "simulate",
idempotencyKey: "simulate-order-42",
});
await paymentIntentClient.paymentIntents.confirm(paymentIntent.id, {
stablecoin: "usdc",
network: "ethereum",
});
const succeeded =
await paymentIntentClient.paymentIntents.simulateDeposit(paymentIntent.id);simulateDeposit(id, { amount }) の amount は正の数を受け付けますが、現行実装は不足/超過を分岐せず succeeded に進めます。金額照合のテストにはEC Gatewayを使ってください。EC Gatewayの simulateDeposit(token, { amount }) で不足額を渡すと、checkoutStatus に confirmed: false / underpaid: true が返ります。
PaymentIntentのtestnet / live制約
- testnetはUSDCのみ。Ethereum Sepolia / Polygon Amoyを使用
confirmはfaucet情報と入金指示を返す- 現行本番ではオンチェーン着金をPaymentIntentへ自動反映する配線が未完了
submit_txendpointは存在しない
したがって、オンチェーンまで含むE2EテストはEC Gatewayの testnet を使用してください。