#optic_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/1292904441632129024
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
payment_intent.succeeded should be triggered for all sort of payments that are processed using PaymentIntents API. Do you have an example Payment where you didn't see the event?
well these are my current logs when i pay with card
comapred to when i pay with revolut:
Please share actual IDs in text so that I can take a look on my end..
Also, in the screenshot you've shared for card payment - your logs do have payment_intent.succeeded event listed
they do but in the card logs it says that the email or plan id is empty compared to in the revolut one where the subscription is marked as paid etc
here is the text version of the logs:
stripe logs
โ Today at 18:42
[STRIPE] Received webhook
[STRIPE] event type: customer.subscription.created
[STRIPE] Received webhook
[STRIPE] event type: payment_intent.succeeded
[STRIPE] Subscription created
[STRIPE] Payment intent succeeded
[STRIPE] Plan name: Entrepreneur Plan
[STRIPE] Subscription marked as paid for PaymentIntent ID: in_1Q7KxLC1Ij5Di60qzWBbIyvC
[STRIPE] Email or plan ID is empty
stripe logs
APP
โ Today at 18:43
[STRIPE] Received webhook
[STRIPE] event type: customer.subscription.created
[STRIPE] Subscription created
[STRIPE] Plan ID: price_1Q1p2pC1Ij5Di60qzJa2bhM0
[STRIPE] Plan name: Entrepreneur Plan
[STRIPE] Invoice ID: in_1Q7KyBC1Ij5Di60qBTGEavGi
[STRIPE] Received webhook
[STRIPE] event type: payment_intent.succeeded
[STRIPE] Payment intent succeeded
[STRIPE] Payment intent ID: pi_3Q7KyBC1Ij5Di60q0W202bX8
[STRIPE] Subscription marked as paid for PaymentIntent ID: in_1Q7KyBC1Ij5Di60qBTGEavGi
[STRIPE] djsilver998@gmail.com price_1Q1p2pC1Ij5Di60qzJa2bhM0
Sorry let's take a step back as there seems to be some confusion..
What does your code do when it recieves the event?
Have you tried looking at the event you've received in both cases and compare the body?
It first verifies the webhook signature to ensure it's a valid Stripe event.
Then, based on the event type, it performs different actions:
for customer.subscriptions.created: It adds a new subscription to the database with the customer's email, plan ID, plan name, and invoice ID.
For payment_intent.succeeded:
It marks the subscription as paid and saves the last 4 digits of the customer's card.
For nvoice.payment_succeeded - (i added this thinking it was the alternative for when the payment_intent.succeeded for card doesnt fire correctly)
Similar to "payment_intent.succeeded", it marks the subscription as paid and saves the last 4 digits of the card.
For payment_intent.payment_failed:
It deletes the subscription from the database if the payment fails.
Have you tried looking at the event you've received in both cases and compare the body?
i have not yet i will do that now
okay so
Yeah.. Like I mentioned earlier payment_intent.succeeded should be generated by any payment processed using the PaymentIntents API..
This includes subscriptions API too as the Subscriptions are built on top of invoicing which use PaymentIntents API.
Depending on what API you integrate, you may have to check if payment_intent.succeeded belongs to a subscription payment or one-time payment & treat them both differently.
ive played about with it a little and now they are both setting the paid field in the database to true which is perfect, however when i try to pull the last 4 digits off of the payment intent -> latest charge -> payment method details -> card, it doesnt work as it throws this error:
card details not found in payment intent - that error is thrown when it is null
what do i need to use to get the last 4 digits for a billing page - moreover has stripe got its own billing page that customers can view?
i seen it on a website before i cant rememebr what ill try find it but it was like all the customers details and how they can cancel they're subscription and stuff
Are you referring to customer portal? https://docs.stripe.com/customer-management
it doesnt work as it throws this error:
card details not found in payment intent - that error is thrown when it is null
That doesn't sound like a Stripe error. Your code is likely throwing this error.
Can you share an example PaymentIntent you're looking at?
pi_xxx
pi_3Q7LDNC1Ij5Di60q0C7trU7f
i beieve this is it yes
The charge does contain the last4 from what I see. Can you try printing what you see under payment_intent.latest_charge.payment_method_details?
[STRIPE] Payment intent payment: <nil> is the log from when :
discord.SendMessage(discord.StripeLog, fmt.Sprintf("Payment intent payment: %v", paymentIntent.LatestCharge.PaymentMethodDetails))
runs
Are you trying to access latest_charge directly on the payload delivered by the webhook event?
If so, that won't work. latest_charge is an expandable property. You'd need to retrieve the PaymentIntent object and expand latest_charge
https://docs.stripe.com/api/payment_intents/object#payment_intent_object-latest_charge
https://docs.stripe.com/api/expanding_objects
Hi there ๐ I've taken over as my teammate needed to step away. I see the thread is getting a bit stale and wanted to see if you were all set and the thread could be closed, or if there are additional questions that I can help clear up?
that is everything, i have got it working, thank you tho (u and hanzo)