# 発行導入をテストする お客様の組み込みをテストし、購入のシミュレーションを行う方法をご紹介します。 Stripe システムの[テスト](https://docs.stripe.com/testing.md)の詳細をご覧ください。 *サンドボックス* (A sandbox is an isolated test environment that allows you to test Stripe functionality in your account without affecting your live integration. Use sandboxes to safely experiment with new features and changes)環境で独自の Stripe 実装を使用して、カードを発行し、購入をシミュレートできます。これにより、実際の購入を行うことなく、本番環境に移行する前に実装をテストできます。これらのカードは、Stripe アカウント内でのテストにのみ使用でき、外部での購入には使用できません。 > [authorization endpoint](https://docs.stripe.com/issuing/purchases/authorizations.md) をテストする際は、[Issuing settings](https://dashboard.stripe.com/account/issuing) でテストエンドポイントを設定していることを確認してください。*サンドボックス* (A sandbox is an isolated test environment that allows you to test Stripe functionality in your account without affecting your live integration. Use sandboxes to safely experiment with new features and changes) 環境に切り替えることで、テストデータを表示できます。 ## テスト用の Issuing 残高に資金を追加する テスト取引を作成する前に、アカウントの Issuing 残高にテスト資金を追加する必要があります。これらは実際の資金ではなく、テスト購入のシミュレーションにのみ使用できます。 ### アメリカの Issuing ユーザー アメリカの Issuing ユーザーの場合、資金の「引き出し」と *top-ups* (資金の追加) を使用して、Issuing 残高に資金を追加します。テスト環境のトップアップは、ダッシュボードまたは [Top-ups API](https://docs.stripe.com/api/topups/create.md) を使用して作成できます。[アメリカのユーザー](https://docs.stripe.com/issuing/funding/balance.md?push-pull-preference=pull)向けの Issuing 残高への資金追加については、こちらから詳細をご確認ください。 ### イギリスおよびユーロ圏の Issuing ユーザー イギリスとヨーロッパの Issuing ユーザーは、残高にトップアップするために *資金追加指示* を使用して資金を「追加」します。これは、ダッシュボードからアクセスする *サンドボックス* (A sandbox is an isolated test environment that allows you to test Stripe functionality in your account without affecting your live integration. Use sandboxes to safely experiment with new features and changes) 環境、または [Funding Instructions API](https://docs.stripe.com/api/funding_instructions.md) を使用して実行できます。[イギリスとユーロ圏のユーザー](https://docs.stripe.com/issuing/funding/balance.md?push-pull-preference=push)向けの Issuing 残高に資金を追加する方法の詳細をご確認ください。 # コード不使用 > This is a コード不使用 for when testing-method is without-code. View the full page at https://docs.stripe.com/issuing/testing?testing-method=without-code. カード購入のシミュレーションを行うには、ダッシュボードでオーソリの詳細情報を指定します。 ## カードを作成する [ダッシュボード] [API](https://docs.stripe.com/api/issuing/cards.md) または[ダッシュボード](https://dashboard.stripe.com/issuing/cards)を使用して、テスト用のカード保有者とカードを作成します。ダッシュボード固有の手順については、[仮想カードを作成](https://docs.stripe.com/issuing/cards/virtual/issue-cards.md)または[物理カードを作成](https://docs.stripe.com/issuing/cards/physical/issue-cards.md)をご覧ください。 ## テスト購入を作成する [ダッシュボード] *サンドボックス* (A sandbox is an isolated test environment that allows you to test Stripe functionality in your account without affecting your live integration. Use sandboxes to safely experiment with new features and changes)環境で [カード発行ページ](https://dashboard.stripe.com/issuing/cards) に移動し、新しく作成したクレジットカードを見つけて、**テスト購入を作成**をクリックします。 !['Create test purchase' オプションを含む Issuing カード詳細メニュー](https://b.stripecdn.com/docs-statics-srv/assets/card-details-menu.34670985a02c84d359ed55331aafc730.png) 強制的にキャプチャーすることで、[Authorizations (オーソリ)](https://docs.stripe.com/api/issuing/authorizations/object.md) または [Transactions (取引)](https://docs.stripe.com/api/issuing/transactions/object.md) の作成を選択できます。 ![「テスト購入サイドバーを作成」フォーム](https://b.stripecdn.com/docs-statics-srv/assets/create-test-purchase.49735340603617a6226fbe471c8ddaf7.png) 選択内容に応じて、金額やビジネスデータなど、さまざまなプロパティを指定できます。 購入を作成するには、**送信**をクリックします。オーソリを選択して、[同期 Webhook](https://docs.stripe.com/issuing/controls/real-time-authorizations.md) を設定している場合は、それを使用してオーソリを承認または拒否することができます。ブラウザーは、新しく作成されたオーソリのページにリダイレクトします。 ## キャプチャーを作成する [ダッシュボード] ダッシュボードでオーソリを使用してテストキャプチャーを作成するには、*サンドボックス* (A sandbox is an isolated test environment that allows you to test Stripe functionality in your account without affecting your live integration. Use sandboxes to safely experiment with new features and changes)環境に切り替えて、次の手順を実行します。 1. [オーソリ](https://dashboard.stripe.com/issuing/authorizations)ページの**発行済みのカード**の下に移動します。 1. キャプチャーするオーソリをクリックして、 **キャプチャー** をクリックします。![Issuing オーソリの詳細](https://b.stripecdn.com/docs-statics-srv/assets/issuing-authorization-details.24989e6ddba734d4e63df884bf171371.png) オーソリされた合計金額よりも多い、少ない、または同等の金額のオーソリをキャプチャーすることができます。オーソリの現在の状態に関係なく、[複数回キャプチャー](https://docs.stripe.com/issuing/purchases/transactions.md?issuing-capture-type=multi_capture)することもできます。 ![「Issuing オーソリをキャプチャー」フォーム](https://b.stripecdn.com/docs-statics-srv/assets/capture-authorization.166a462b58fae6d07aa62135577ce06e.png) キャプチャーする金額を入力して **送信** をクリックし、キャプチャーを作成します。ブラウザーによって、取引ページにリダイレクトされ、新たに作成された取引を選択します。 # コード使用 > This is a コード使用 for when testing-method is with-code. View the full page at https://docs.stripe.com/issuing/testing?testing-method=with-code. ## カードを作成する [サーバー側] 名前、請求先住所、法人タイプを指定して、[カード保有者を作成](https://docs.stripe.com/api.md#create_issuing_cardholder)します。また、必要に応じて追加情報を入力することもできます。 ```curl curl https://api.stripe.com/v1/issuing/cardholders \ -u "<>:" \ -d name="Jenny Rosen" \ --data-urlencode email="jenny.rosen@example.com" \ --data-urlencode phone_number="+18008675309" \ -d status=active \ -d type=individual \ -d "individual[first_name]"=Jenny \ -d "individual[last_name]"=Rosen \ -d "individual[dob][day]"=1 \ -d "individual[dob][month]"=11 \ -d "individual[dob][year]"=1981 \ -d "billing[address][line1]"="123 Main Street" \ -d "billing[address][city]"="San Francisco" \ -d "billing[address][state]"=CA \ -d "billing[address][postal_code]"=94111 \ -d "billing[address][country]"=US ``` 次に、カード保有者用の[カードを作成します](https://docs.stripe.com/api/.md#create_issuing_card)。 ```curl curl https://api.stripe.com/v1/issuing/cards \ -u "<>:" \ -d cardholder="{{ISSUINGCARDHOLDER_ID}}" \ -d type=virtual \ -d currency=usd \ -d status=active ``` ## オーソリを作成する [サーバー側] [Authorization (オーソリ)](https://docs.stripe.com/api.md#issuing_authorization_object) は、カード保有者のカードによる購入を表します。[Authorization のテストヘルパー API](https://docs.stripe.com/api/issuing/authorizations/test_mode_create.md) を使用して、テスト環境でオーソリの作成をシミュレーションできます。 ```curl curl https://api.stripe.com/v1/test_helpers/issuing/authorizations \ -u "<>:" \ -d card="{{ISSUINGCARD_ID}}" \ -d amount=1000 \ -d authorization_method=chip \ -d "merchant_data[category]"=taxicabs_limousines \ -d "merchant_data[city]"="San Francisco" \ -d "merchant_data[country]"=US \ -d "merchant_data[name]"="Rocket Rides" \ -d "merchant_data[network_id]"=1234567890 \ -d "merchant_data[postal_code]"=94107 \ -d "merchant_data[state]"=CA ``` [リアルタイムのオーソリ](https://docs.stripe.com/issuing/controls/real-time-authorizations.md)を設定すると、Stripe から `issuing_authorization.request` Webhook イベントが送信されます。このイベントに直接応答して、承認するか拒否できます。[リアルタイムのオーソリエンドポイントビルダー](https://docs.stripe.com/issuing/controls/real-time-authorizations/quickstart.md)の詳細をご覧ください。 ## オーソリをキャプチャーする [サーバー側] 承認後、[キャプチャー](https://docs.stripe.com/issuing/purchases/transactions.md)を待っている間、Authorization は `pending` 状態になります。API でオーソリのキャプチャーをシミュレーションできます。 ```curl curl -X POST https://api.stripe.com/v1/test_helpers/issuing/authorizations/{{ISSUINGAUTHORIZATION_ID}}/capture \ -u "<>:" ``` これにより、新しい[取引](https://docs.stripe.com/api.md#issuing_transaction_object)リソースが生成され、オーソリステータスは `closed` に更新されます。