admin管理员组文章数量:1399251
Here is my code based on the documentation
const appearance = {
theme: 'stripe',
variables: {
borderRadius: '36px',
},
};
const expressCheckoutOptions = {
buttonHeight: 50,
buttonType: {
applePay: 'buy',
googlePay: 'buy',
paypal: 'checkout',
klarna: 'pay',
},
};
const elements = stripe.elements({
mode: 'payment',
// mode: 'subscription', DOES NOT WORK despite documentation saying it does?
amount: amount * 100, // Convert to smallest currency unit
currency: currency,
appearance,
});
const expressCheckoutElement = elements.create('expressCheckout', expressCheckoutOptions);
expressCheckoutElement.mount(mountElementId);
It does not work if I change mode to subscription. Im not sure why. The element will not be created and it will return an empty element. However with payment, I can see my express checkout, like so:
Here is my code based on the documentation https://docs.stripe/elements/express-checkout-element/accept-a-payment#additional-options
const appearance = {
theme: 'stripe',
variables: {
borderRadius: '36px',
},
};
const expressCheckoutOptions = {
buttonHeight: 50,
buttonType: {
applePay: 'buy',
googlePay: 'buy',
paypal: 'checkout',
klarna: 'pay',
},
};
const elements = stripe.elements({
mode: 'payment',
// mode: 'subscription', DOES NOT WORK despite documentation saying it does?
amount: amount * 100, // Convert to smallest currency unit
currency: currency,
appearance,
});
const expressCheckoutElement = elements.create('expressCheckout', expressCheckoutOptions);
expressCheckoutElement.mount(mountElementId);
It does not work if I change mode to subscription. Im not sure why. The element will not be created and it will return an empty element. However with payment, I can see my express checkout, like so:
Share Improve this question asked Mar 26 at 6:03 Matthew FrancisMatthew Francis 7403 gold badges11 silver badges27 bronze badges 1- What is the issue you are facing when passing subscription as a mode ? Can you share the error message you got ? – os4m37 Commented Mar 26 at 8:18
1 Answer
Reset to default 0you can do it like this
first Set Up the Elements Instance for Subscriptions
mode: 'setup',
amount: amount * 100,
currency: currency,
appearance,
});
Create and Mount the Express Checkout Element
const expressCheckoutElement = elements.create('expressCheckout', expressCheckoutOptions);
expressCheckoutElement.mount(mountElementId);
then Handle the Confirmation Event
const { error: submitError } = await elements.submit();
if (submitError) {
handleError(submitError);
return;
}
const { error, paymentMethod } = await stripe.createPaymentMethod({
elements,
params: {
billing_details: event.billingDetails,
},
});
if (error) {
handleError(error);
return;
}
// Use the paymentMethod.id to create a subscription on your server
});
本文标签: javascriptStripe Express Checkout Element for Subscriptions is not appearingStack Overflow
版权声明:本文标题:javascript - Stripe Express Checkout Element for Subscriptions is not appearing? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744162497a2593400.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论