Stripe payments 条带签出发货地址

Stripe payments 条带签出发货地址,stripe-payments,Stripe Payments,我正在使用Stripe Checkout API指导用户付款。我想得到发货地址,以便发货。 以下是我在WordPress小部件中使用的代码: <!-- Load Stripe.js on your website. --> <script src="https://js.stripe.com/v3"></script> <!-- Create a button that your customers click to complet

我正在使用Stripe Checkout API指导用户付款。我想得到发货地址,以便发货。 以下是我在WordPress小部件中使用的代码:

<!-- Load Stripe.js on your website. -->
<script src="https://js.stripe.com/v3"></script>

<!-- Create a button that your customers click to complete their purchase. Customize the styling to suit your branding. -->
<button
  style="background-color:#6772E5;color:#FFF;padding:8px 12px;border:0;border-radius:4px;font-size:1em"
  id="checkout-button-price_1HhPY2IT1E1kKJAOCUoQDPxI"
 role="link"
 type="button"
>
 Checkout
</button>

<div id="error-message"></div>

<script>
(function() {
  var stripe =Stripe('pk_live_51H7oCMIT1E1kKJAOeiJKZvF4R2uIJfFCIrOJ1hW8Krned1tfG0abtsQdMD6pRmRyqh5gNNnfxVCzltFc29K7C5Iq00YJyFHBZZ');

  var checkoutButton = document.getElementById('checkout-button-price_1HhPY2IT1E1kKJAOCUoQDPxI');
  checkoutButton.addEventListener('click', function () {
/*
 * When the customer clicks on the button, redirect
 * them to Checkout.
 */
stripe.redirectToCheckout({
  lineItems: [{price: 'price_1HhPY2IT1E1kKJAOCUoQDPxI', quantity: 1}],
  mode: 'payment',
 
  /*
   * Do not rely on the redirect to the successUrl for fulfilling
   * purchases, customers may not always reach the success_url after
   * a successful payment.
   * Instead use one of the strategies described in
   * https://stripe.com/docs/payments/checkout/fulfill-orders
   */
  successUrl: window.location.protocol + '//GLOBESITY.FOUNDATION/success',
  cancelUrl: window.location.protocol + '//GLOBESITY.FOUNDATION/canceled',
})
.then(function (result) {
  if (result.error) {
    /*
     * If `redirectToCheckout` fails due to a browser or network
     * error, display the localized error message to your customer.
     */
    var displayError = document.getElementById('error-message');
    displayError.textContent = result.error.message;
  }
  });
  });
 })();
  </script>

结账
(功能(){
风险条带=条带('pk_live_51h7ocmit1kjaoeijkzvf4r2uijffciroj1hw8krned1tfg0abtsqdmd6prmryqh5gnnnfxvczltfc29k7c5iq00yyyyfhbzz');
var checkburatton=document.getElementById('checkout-button-price_1hhpy2it1e1kkjaocuqdpxi');
CheckExutton.addEventListener('click',函数(){
/*
*当客户单击按钮时,重定向
*让他们结账。
*/
stripe.redirectToCheckout({
行项目:[{price:'price_1hhpy2it1kkjaocuqdpxi',数量:1}],
方式:‘付款’,
/*
*不要依靠重定向到successUrl来实现
*购买后,客户可能不会始终在
*成功的付款。
*相反,请使用中描述的其中一种策略
* https://stripe.com/docs/payments/checkout/fulfill-orders
*/
successUrl:window.location.protocol+'//GLOBESITY.FOUNDATION/success',
cancelUrl:window.location.protocol+'//GLOBESITY.FOUNDATION/canceled',
})
.然后(函数(结果){
if(result.error){
/*
*如果“redirectToCheckout”由于浏览器或网络而失败
*错误,向您的客户显示本地化的错误消息。
*/
var displayError=document.getElementById('error-message');
displayError.textContent=result.error.message;
}
});
});
})();

此代码在获得付款时运行良好,但未获得发货地址。另外,我希望发货地址默认为美国。谢谢大家!

您需要使用服务器+客户端版本的Checkout(仅客户端版本不支持此功能),并创建以下CheckoutSession。具体来说,您需要通过
允许的国家:[US']
传递
配送地址\u集合