I have stripe subscription payment button and the following is the code for that:
var stripe = Stripe("<?php echo $stripe["public_key"]; ?>");
$(".btnStripeSubscribe").click(function () {
stripe.redirectToCheckout({
items: [{
plan: "<?php echo $planId; ?>",
quantity: 1
}],
customerEmail: "<?php echo $user["email"]; ?>",
successUrl: "http://example.com/success.php",
cancelUrl: "http://example.com/dashboard.php"
});
});
And i added Alipay option and the following is the code I use:
stripe.createSource({
type: 'alipay',
amount: '500',
currency: 'cny',
redirect: {
return_url: 'http://example.com/success.php'
},
}).then(function (response) {
if (response.error) {
alert(response.error.message);
} else {
window.location.href = source.redirect.url;
}
});
Question 1: I am not sure i am doing it correctly. The code for Alipay looks like a one-time charge and it does not look like subscription. Because in my Stripe Dashboard, it does not show up in Subscription page.
Question 2: Is there anyway to use the plan Id to charge using Alipay?
Thank you!
You have to request approval for Alipay subscriptions, or else Stripe only allows one-time Alipay payments. I was approved for recurring Alipay payments. You request approval for a specific yearly recurring max amount from Stripe Support, then they request approval from Alipay and let you know the decision.
You should be able to use a plan id with Alipay by creating a Subscription. However, after Stripe Support activated recurring payments I haven't been able to get Alipay subscriptions working in production. It works fine in test mode, following the official docs:
https://stripe.com/docs/billing/subscriptions/alipay
However, in production the customers click confirm on Alipay's website but when I create a Subscription it returns a PaymentIntent that still needs user confirmation. It's an infinite loop.
Has anyone else gotten recurring payments working with Alipay and Stripe?