#candy_cane
1 messages · Page 1 of 1 (latest)
Hello, here: "pi_3O1wAtFd9r7pbKmK1vOsTLqk"
Thanks, taking a look
Looks like you are trying to confirm a PaymentIntent that has already been confirmed successfully
Okay, thank you too.
Can you tell me what you are trying to do here?
Sure, I am trying to create a subscription for an existing customer. Code:
const attachPaymentToCustomer = await stripe.paymentMethods.attach(
paymentMethodId,
{ customer: stripeId }
);
stripe.customers.update(
stripeId,
{
invoice_settings: { default_payment_method: attachPaymentToCustomer.id },
},
);
console.log(attachPaymentToCustomer);
const product = "prod_Oofvfy39kzYyuC";
const subscription = await stripe.subscriptions.create({
customer: stripeId,
items: [
{
price_data: {
currency: "EUR",
product: product!,
unit_amount: 1000,
recurring: {
interval: "month",
},
},
},
],
payment_settings: {
payment_method_types: ["card"],
save_default_payment_method: "on_subscription",
},
expand: ["latest_invoice.payment_intent"],
default_payment_method: paymentMethodId,
});
```, then send the "subscription?.latest_invoice?.payment_intent?.client_secret" back to client side and confirm the client secret like:``` const result = await stripe.confirmCardPayment(client_secret, {
payment_method: paymentMethod.paymentMethod?.id
});```
You already have a PaymentMethod attached in this scenario though, yes?
So you don't need to confirm client-side unless 3DS is required
Yes.
That said, if you want to do what you are suggesting, then you set payment_behavior: 'default_incomplete': https://stripe.com/docs/api/subscriptions/create#create_subscription-payment_behavior
Okay, thanks. I will give it a try.
Sure
Okay, thanks! I have a webhook that doesnt seem to execute.
After the payment is completed.
What does "doesn't seem to execute" mean?
Do you see an error?
Does your endpoint get hit at all?
Have you added logs?
I dont see them getting hit in the logs
Well that green check mark means they were delivered successfully...
Can you give me an Event ID that I can look at?
Thats from 2 days ago,
Okay can you give me a recent Event that fired but wasn't delivered to your endpoint?
You can find them in https://dashboard.stripe.com/test/events
Couple of them:
xxx's subscription has changed
evt_1O1wPWFd9r7pbKmK9d6iiC5c
10/16/23, 9:25:06 PM
xxx's payment for an invoice for €10.00 succeeded
evt_1O1wPWFd9r7pbKmKUTfrpcVM
10/16/23, 9:25:06 PM
xxx's invoice for €10.00 was paid
evt_1O1wPWFd9r7pbKmKhjlXPU9p
10/16/23, 9:25:06 PM
xxx's invoice has changed
evt_1O1wPWFd9r7pbKmKGPKD0zxO
10/16/23, 9:25:06 PM
The payment pi_3O1wPUFd9r7pbKmK1o1RbduU for €10.00 has succeeded
evt_3O1wPUFd9r7pbKmK1geZG61Q
10/16/23, 9:25:05 PM
xxx was charged €10.00
evt_3O1wPUFd9r7pbKmK1E4RX6jv
10/16/23, 9:25:05 PM
xxx attempted to subscribe to price_1O1wPTFd9r7pbKmKqAXNjGxS
evt_1O1wPUFd9r7pbKmKPrAr2zck
10/16/23, 9:25:04 PM
A draft invoice for €10.00 to xxx was finalized
evt_1O1wPUFd9r7pbKmKaZd6nymH
10/16/23, 9:25:04 PM
A draft invoice was created
evt_1O1wPUFd9r7pbKmK0N0sy351
10/16/23, 9:25:04 PMCouple of them:
xxx's subscription has changed
evt_1O1wPWFd9r7pbKmK9d6iiC5c
10/16/23, 9:25:06 PM
xxx's payment for an invoice for €10.00 succeeded
evt_1O1wPWFd9r7pbKmKUTfrpcVM
10/16/23, 9:25:06 PM
xxx's invoice for €10.00 was paid
evt_1O1wPWFd9r7pbKmKhjlXPU9p
10/16/23, 9:25:06 PM
xxx's invoice has changed
evt_1O1wPWFd9r7pbKmKGPKD0zxO
10/16/23, 9:25:06 PM
The payment pi_3O1wPUFd9r7pbKmK1o1RbduU for €10.00 has succeeded
evt_3O1wPUFd9r7pbKmK1geZG61Q
10/16/23, 9:25:05 PM
xxx was charged €10.00
evt_3O1wPUFd9r7pbKmK1E4RX6jv
10/16/23, 9:25:05 PM
xxx attempted to subscribe to price_1O1wPTFd9r7pbKmKqAXNjGxS
evt_1O1wPUFd9r7pbKmKPrAr2zck
10/16/23, 9:25:04 PM
A draft invoice for €10.00 to xxx was finalized
evt_1O1wPUFd9r7pbKmKaZd6nymH
10/16/23, 9:25:04 PM
A draft invoice was created
evt_1O1wPUFd9r7pbKmK0N0sy351
10/16/23, 9:25:04 PM
Would recommend redacting your email here
As this is a public server
Okay if you look at your Webhook endpoint it isn't listening for those types of Events: https://dashboard.stripe.com/test/webhooks/we_1O15pCFd9r7pbKmK1JX6f2SQ
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
It is only listening for 4 event types
So you need to edit it to listen for these other types if you want to receive them
Oh, yes. Thanks. I forgot. I will add "
invoice.payment_succeeded".