Step3:お支払い方法設定での購入者認証の取得
お支払い方法設定を有効にするためには、Amazonお支払い方法設定同意ウィジェットを表示しなければなりません。このウィジェットを利用することで、購入者はAmazon Payアカウントで定期購買や請求支払のように将来の購入と支払について請求することを承認することができます。この同意は販売事業者に提供されます。この同意はAmazon Payの定期支払ポリシーを条件として期限なしである定期購買、一定量の請求、その他の定期支払シナリオをサポートする目的で、変動する総額を柔軟に請求することを提供します。
お支払い方法設定同意ウィジェットをWebサイトに埋め込むためには、Webページに次のサンプルコードを追加します。
<!--- please put the style below inside your CSS file -->
<style type="text/css">
#consentWidgetDiv {width: 400px; height: 140px;}
</style>
<div id="consentWidgetDiv">
</div>
<script>
new OffAmazonPayments.Widgets.Consent({
sellerId: 'YOUR_SELLER_ID_HERE',
// amazonBillingAgreementId obtained from the Amazon Address Book widget.
amazonBillingAgreementId: amazonBillingAgreementId,
design: {
designMode: 'responsive'
},
onReady: function(billingAgreementConsentStatus){
// Called after widget renders
buyerBillingAgreementConsentStatus =
billingAgreementConsentStatus.getConsentStatus();
// getConsentStatus returns true or false
// true - checkbox is selected
// false - checkbox is unselected - default
},
onConsent: function(billingAgreementConsentStatus) {
buyerBillingAgreementConsentStatus =
billingAgreementConsentStatus.getConsentStatus();
// getConsentStatus returns true or false
// true - checkbox is selected - buyer has consented
// false - checkbox is unselected - buyer has not consented
// Replace this code with the action that you want to perform
// after the consent checkbox is selected/unselected.
},
onError: function(error) {
// your error handling code
}
}).bind("consentWidgetDiv ");
</script>
お支払い方法設定同意ウィジェットを表示する場合は、amazonBillingAgreementIdを指定しなければなりません。amazonBillingAgreementIdが指定されていない場合は、ウィジェットはエラーメッセージを表示します。
お支払い方法設定同意ウィジェットを生成する場合はwidthとheightパラメータを指定しなければなりません、そうしなければウィジェットは表示されません。推奨または有効なwidthとheightパラメータは次の表の通りに指定できます。
パラメータ | 推奨 | 有効 |
---|---|---|
width | 400px | 300px - 600px |
height | 140px | 140px - 400px |
Amazonは購入者が同意するためのウィジェットのチェックボックスがチェックされるまで購入ワークフローができなくすることを推奨します。Amazonは同意ステータスをbillingAgreementConsentStatusコールバック関数経由で通知します。チェックボックスがチェックされている場合は、buyerbillingAgreementConsentStatusはtrueをセットし、その他の場合ではfalseがセットされます。また、GetBillingAgreementDetails処理を呼び出すことでBillingAgreementConsentStatusを得ることができます。詳しい情報はAmazon Pay APIリファレンスガイドのGetBillingAgreementDetailsを参照してください。
同意ステータスに基いて、購入フローの次のステップを可能にできます。例えば、注文確認画面を持っている場合はWebページの続けるボタンを有効にできます、また、購入者が購入を完了するために同意するボタンを有効にすることができます。BillingAgreementはbuyerbillingAgreementConsentStatusがtrueにセットされるまで承認されないことに注意してください。