#lucas-soares_webhooks
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1287772295485718681
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
this is my code in webhook:
case 'checkout.session.completed': // quando o pagamento no checkout รฉ feito
const checkoutSession = event.data.object;
let schedule = await stripe.subscriptionSchedules.create({
from_subscription: checkoutSession.subscription,
})
console.log(`Schedule created: ${schedule.id}`);
const phases = schedule.phases.map(phase => ({
start_date: phase.start_date,
end_date: phase.end_date,
items: phase.items
}))
schedule = await stripe.subscriptionSchedules.update(
schedule.id,
{
end_behavior: "cancel",
phases: [
...phases,
{
items: [{
price: 'price_1Q2BLYRx522Tv10myvWnstsX',
quantity: 1,
}],
iterations: 3
}
]
}
)
break;
Hi there ๐ do you have the ID of the request throwing that error?
https://support.stripe.com/questions/finding-the-id-for-an-api-request
Offhand it sounds like you're trying to attach a Subscription Schedule to a Subscription that is already being controlled by an existing Subscription Schedule. If so you'd either want to update the existing Subscription Schedule, or remove the existing schedule before attaching a new one.
Find help and support for Stripe. Our support site provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
Sorry, I have the request ID here, I didn't know where to find it.
req_FCwGSbuknUKJzI
I tried to update the Scheduled that already exists or delete it, but I couldn't check id
Yeah, that request is failing for the reason indicated in the returned error message, the Subscription is already being controlled by another Subscription Schedule. You previously created a Subscription Schedule from that Subscription in this request:
https://dashboard.stripe.com/test/logs/req_wiBqowCMlsewpK
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
ok, I see, but I didn't find where it was being added before
I just created the link at checkout and then I try to attach it to the webhook
at some point it is calling subscription Schedules
Yeah, I'm not sure what in your code is calling that endpoint, I just see that you are. Do you have logic in your code to make sure you aren't processing an Event that has already been processed? It looks like you're sending that Event to you endpoint multiple times. My suspicion is that the Subscription Schedule creation request ran the first time the Event was received, so it errors when you try to reprocess the same Event.
yeah, I had made a request but it gave an error at the end and it still created the Schedules
he had created it even though it gave me an error and I didn't notice
I made a new payment at checkout and now it works!
๐ฅณ glad to hear!
thank you very much for the help! ๐