配送料を使用すると、通常配送、エクスプレス配送、翌日配送など、さまざまな配送オプションを表示して、配達日の目安をより正確に提示できます。さまざまな Stripe プロダクトを使用して配送料を顧客に請求します。配送料を作成する前に、請求先住所と配送先住所を収集 する方法を確認してください。
注 配送料は、注文全体に対する一定額のみ設定できます。注文の品目数に応じて配送料を調整することはできません。
注 配送料は、注文全体に対する一定額のみ設定できます。注文の品目数に応じて配送料を調整することはできません。
ダッシュボードを使用して配送料 を追加するには、次の操作を実行します。
配送料を作成 をクリックします。金額、説明と、必要に応じて配達予定日を入力します。 保存 をクリックし、配送料 ID (shr_ 123456
) をコピーします。配送料の詳細を入力する
配送料金を更新する You can’t update a shipping rate in the Dashboard. To update a shipping rate in the Dashboard, you must archive the shipping rate and then create a new one.
Archive a shipping rate To archive a shipping rate:
On the Shipping rates tab, select the applicable shipping rate. Click the overflow menu , and select Archive . To unarchive the shipping rate, click the overflow menu , and select Unarchive shipping rate .
配送料を含む Checkout セッションを作成するには、生成された配送料 ID を shipping_options パラメーターに渡します。Checkout セッションと同時に配送料を作成する場合は、shipping_ rate_ data
パラメーターと shipping_ options
を使用します。配送オプションに対応しているのは、支払いモード の Checkout セッションのみです。
次のコードサンプルでは、Checkout セッションに 2 つの配送オプションを追加します。
送料無料、配達予定日は 5 〜 7 営業日。 翌日配送の航空便、費用は 15.00 USD、配達予定日はちょうど 1 営業日。 この例では、顧客が便利になるように、決済ページで shipping_ options
配列の最初のオプションが事前に選択されています。ただし、顧客はどちらのオプションも選択できます。
curl https://api.stripe.com/v1/checkout/sessions \
-u "sk_test_BQokikJOvBiI2HlWgH4olfQ2
:" \
-d "shipping_address_collection[allowed_countries][0]" = US \
-d "shipping_address_collection[allowed_countries][1]" = CA \
-d "shipping_options[0][shipping_rate_data][type]" = fixed_amount \
-d "shipping_options[0][shipping_rate_data][fixed_amount][amount]" = 0 \
-d "shipping_options[0][shipping_rate_data][fixed_amount][currency]" = usd \
-d "shipping_options[0][shipping_rate_data][display_name]" = "Free shipping" \
-d "shipping_options[0][shipping_rate_data][delivery_estimate][minimum][unit]" = business_day \
-d "shipping_options[0][shipping_rate_data][delivery_estimate][minimum][value]" = 5 \
-d "shipping_options[0][shipping_rate_data][delivery_estimate][maximum][unit]" = business_day \
-d "shipping_options[0][shipping_rate_data][delivery_estimate][maximum][value]" = 7 \
-d "shipping_options[1][shipping_rate_data][type]" = fixed_amount \
-d "shipping_options[1][shipping_rate_data][fixed_amount][amount]" = 1500 \
-d "shipping_options[1][shipping_rate_data][fixed_amount][currency]" = usd \
-d "shipping_options[1][shipping_rate_data][display_name]" = "Next day air" \
-d "shipping_options[1][shipping_rate_data][delivery_estimate][minimum][unit]" = business_day \
-d "shipping_options[1][shipping_rate_data][delivery_estimate][minimum][value]" = 1 \
-d "shipping_options[1][shipping_rate_data][delivery_estimate][maximum][unit]" = business_day \
-d "shipping_options[1][shipping_rate_data][delivery_estimate][maximum][value]" = 1 \
-d "line_items[0][price_data][currency]" = usd \
-d "line_items[0][price_data][product_data][name]" = T-shirt \
-d "line_items[0][price_data][unit_amount]" = 2000 \
-d "line_items[0][quantity]" = 1 \
-d mode = payment \
- -data -urlencode success_url = "https://example.com/success "
成功すると、決済ページに配送セレクターが表示されます。
決済ページに配送セレクターが表示される