@velvet mist pressed the 📡 API button in https://discord.com/channels/841573134531821608/842637025524842496 to ask a question:
Question
Hi,
I have created a subscription on php using $stripe->subscriptions->create
and obtained the client secret using $subscription->latest_invoice->payment_intent->client_secret;
I then mount the payment element using:
paymentElement.mount('#payment-element');
This displays the payment element which i fill in with the card details etc.
When I press the submit button, i use event.preventDefault() in the form handler
At this point, i'm confused how to I process the payment and come back to this script to handle additional none stripe actions without using a return_url.
Can this done?
Related Request ID(s)
prod_QXaoDpiXNxRdfb
What have you already attempted?
checkStatus();
async function checkStatus() {
const clientSecret = new URLSearchParams(window.location.search).get(
"payment_intent_client_secret"
);
if (!clientSecret) {
console.log("no client secret yet!");
return;
}
const { paymentIntent } = await stripe.retrievePaymentIntent(clientSecret);
switch (paymentIntent.status) {
case "succeeded":
console.log("succeeded!");
break;
case "processing":
console.log("processing.");
break;
case "requires_payment_method":
console.log("not successful");
break;
default:
console.log("Something went wrong.");
break;
}
What are you working on?
trying to impliment stripe to process a subscription payment and carry out automated setup tasks when comeplete.