#optic_webhooks

1 messages ยท Page 1 of 1 (latest)

untold carbonBOT
#

๐Ÿ‘‹ 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.

wary pier
#

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?

viscid hamlet
#

well these are my current logs when i pay with card

#

comapred to when i pay with revolut:

wary pier
#

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

viscid hamlet
#

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

wary pier
#

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?

viscid hamlet
#

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

wary pier
#

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.

viscid hamlet
#

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

wary pier
#

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

viscid hamlet
#

pi_3Q7LDNC1Ij5Di60q0C7trU7f

wary pier
#

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?

viscid hamlet
#

[STRIPE] Payment intent payment: <nil> is the log from when :
discord.SendMessage(discord.StripeLog, fmt.Sprintf("Payment intent payment: %v", paymentIntent.LatestCharge.PaymentMethodDetails))
runs

wary pier
untold carbonBOT
iron idol
#

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?

viscid hamlet
#

that is everything, i have got it working, thank you tho (u and hanzo)