#jvheaney

1 messages · Page 1 of 1 (latest)

terse stagBOT
#

Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

worn cypress
#

That event doesn't get called right away. It can take multiple days for it to fir, because it's used for payment methods like ACH, which take 3 to 5 business days.

If you want immediate confirmation for cards, then use checkout.session.completed

gaunt tangle
#

I see, and would that change why I can't see anything in the dashboard logs?

worn cypress
#

No. If that's not firing, it's either because you're taking an asynchronous payment method (which means you'd have to wait a couple of days to receive it), or something is going wrong in your payment flow

gaunt tangle
#

It has nothing to do with using Connect?

#

I am following the documentation to the best of my abilities, but I must be missing something

worn cypress
#

Do you have an example Payment Intent ID I can look at to verify?

gaunt tangle
#

Interesting, I haven't seen anything like that. Here's my js code for creating a session:

const session = await stripeClient.checkout.sessions.create(
      {
        mode: 'payment',
        line_items: [
          {
            price: stripeDetailsQuery.rows[0]['stripe_price_id'],
            quantity: 1,
          },
        ],
        payment_intent_data: {
          application_fee_amount: stripeDetailsQuery.rows[0]['fee_amount'],
        },
        customer: customerId,
        success_url: 'http://localhost:3000/success',
        cancel_url: 'http://localhost:3000/viewGpt/' + gptId,
      },
      {
        stripeAccount: stripeDetailsQuery.rows[0]['stripe_account_id'],
      }
    );

This successfully creates a payment intent and returns the URL to the frontend.

#

If you give me a minute I can get you a payment intent ID

#

How can I get the payment intent ID from a session creation? I am having a hard time figuring that out, is it possible?

worn cypress
#

You have to go through the Checkout Session and attempt to pay with a test card

gaunt tangle
#

We've done that

#

is it a call back?

worn cypress
#

It will show up in the Dashboard from there, or you can retrieve it from the Checkout Session object

gaunt tangle
#

Where can I find it in the checkout session object? Payment intent is null when I console log it on the frontend.

#

Also I am still not seeing it in the dashboard

worn cypress
#

Do you have the Checkout Session ID I can look at instead?

gaunt tangle
#

cs_test_a1PD9CEMXnsJA1DtacotliVXItVE5iCQpXReoFjOf6ZYmqBHkarsh8iJcS

#

Does that work?

worn cypress
#

Yup. Looking now

gaunt tangle
#

Thank you!

worn cypress
#

That checkout session hasn't had a payment attempt yet. You have to navigate to its URL and attempt to pay using a test card

gaunt tangle
#

So we've done that, this was just a test

#

do you want to see one with a completed flow?

#

Try this one:

cs_test_a16iixBrUt3lmtny94Ae1O4HaXLKwyIxDCDR6TKnsirB2DgCcgFWz8hE6U

worn cypress
#

Taking a look now

#

I see a Payment Intent on that object

#

I'm not sure where the disconnect is happening here, but that definitely has a PI attached to it

gaunt tangle
#

Okay, I don't see one when the link originally gets created, maybe it appears afterwards

#

however I still can't see it in the dashboard and it's not calling the webhook

worn cypress
#

Like I said before, a Payment Intent isn't created until you actually visit the Checkout URL and go through the Checkout payment flow

gaunt tangle
#

I understand, but after you complete the checkout it should call the webhook, right?

worn cypress
gaunt tangle
#

Is there a place I am supposed to see it calling the webhook? I am checking the logs and cannot see anything from today

worn cypress
#

I understand, but after you complete the checkout it should call the webhook, right?
If you have a webhook setup to listen for that event on your connect accounts, yes.

#

I don't see any webhook endpoints setup in the platform's dashboard that are listening for Connect events. Just one for Account level events. You need to create a new webhook endpoint that listens for Connect events

gaunt tangle
#

I've done both in the last few days and received nothing

#

I will setup a new one and try again, does it take time to propagate or something?

worn cypress
#

Don't set up a new one. Set up an additional one. You have to have at least 2 webhook endpoints: 1 for events on your platform account, and 1 for events on all your connect accounts.

When you go in to create a new webhook endpoint in the dashboard, you'll see the option to toggle it on for Connect account events, so just click that and try again

gaunt tangle
#

That has worked, I don't know what is different now vs before but maybe I just needed a sanity check

#

I appreciate that help

#

I am not seeing line items appear in the webhook completion now though, am I supposed to use the payment intent to get the purchased item id?

terse stagBOT
worn cypress
#

Can you elaborate on what you mean? What specifically are you looking for? Where are you looking for it?

gaunt tangle
#

I have the webhook body, I am looking for the price id (or product id) of the item purchased. I read in the documentation (I think) that I could access this via the data object returned in the call to the webhook for event checkout.session.completed. The property line_items (which I believe has the ID) is not present on it

worn cypress
#

Do you have an Event ID for the checkout.session.completed webhook? It looks like evt_abc123

gaunt tangle
#

Is it in event.data.object? I have payment intent id, session id, but not event id

worn cypress
#

Checkout Session ID is fine

gaunt tangle
#

cs_test_a1tJ7U1guXcGAhZuaavatct4U1GgzlLbblzF3MO1CMB5c25d734eNKh7F8

ionic rose
#

The individual line_items are not included in the checkout.session.completed because they're only included via expansion when requested

#

You need to retrieve the Checkout Session via the API and use expansion to include line_items using expand[]=line_items
https://stripe.com/docs/expand

Learn how to reduce the number of requests you make to the Stripe API by expanding objects in responses.

gaunt tangle
#

Am I able to do that all within the webhook function? or does that delay the 200 response too much?

ionic rose
#

You should respond to the webhook delivery first, then do any processing necessary

#

The success response is only intended to communicate delivery

gaunt tangle
#

Got it, i'll give that a try now

gaunt tangle
#

Okay, so now I get an error:

StripeInvalidRequestError: No such checkout.session: cs_test_a1hlqSORuQUjERwYSY7YZYucBy8CBXzrhIera5zpNryxFCW23tP84Z0Y4B

I assume it's because the checkout session is valid for a specific connect account? I have to call it with that connect account id in the header of the expand req?

ionic rose
#

If you're doing direct charge patterns and the session was created with a stripe-account header, yes, you need to retrieve it the same way

gaunt tangle
#

Which I wouldn't be able to get without knowledge of what the user purchased to match it up with the merchant account id, I think? Is there something I am missing?

ionic rose
gaunt tangle
#

Alright, that's worked now! I appreciate your help, thank you for helping us out