#Ralph-webhook-laravel

1 messages · Page 1 of 1 (latest)

flat drum
distant seal
#

So essentially

#

I've created a POST route that leads to a controller that leads to a service class, and in that service class I have the test code

#
  public function handleCheckoutcomplete($event)
  {
    $payload = @file_get_contents('php:://input');
    return file_put_contents('php://stderr', print_r($payload, TRUE));
  }
#

The event does show up when I use the browser version of the CLI but I don't think this code is triggeredf

flat drum
#

Do you have any other detail than that? What troubleshooting have you tried so far to try and pinpoint what the issue could be?

distant seal
#

Sorry yeah I realize this is a bit vague

#

I'm using connected accounts and looking at the events log on the 'main' account (that others connect to) I don't see the checkout session event - those are firing off on the connected accounts event log

#
stripe listen --forward-to localhost:8080/v1/dealers/stripeCheckoutWebhook
#

this is what I have in the Stripe CLI

#

My route looks like this

Route::post('dealers/stripeCheckoutWebhook', 'DealerController@checkoutComplete');
#

I'

#

I've basically followed the 'enable connected accounts to accept payments directly' docs 1:1

flat drum
#

So you're using the Stripe-Account header to accept payments directly, and you're not seeing those webhook events come in on the webhook for your main account?

distant seal
#

Yes this is what my session creation looks like:

#
    $session = \Stripe\Checkout\Session::create([
      'payment_method_types' => ['card'],
      'line_items' => $products,
      'mode' => 'payment',
      'success_url' => $successURL,
      'cancel_url' => $returnURL,
    ], ['stripe_account' => $dealer->stripe_account_id]);
#

Creates the session and redirects back correctly - all is working there

#

Test funds are transferred properly to the stripe account

flat drum
#

Can you try again using this:
stripe listen --forward-connect-to localhost:8080/v1/dealers/stripeCheckoutWebhook

distant seal
#

Sure

#

I still don't see the event in my event log

#

Nor does it seem to hit the route and log on the server

flat drum
#

You're sure the account you're logged into with the CLI Is the platform account, right?

distant seal
#

Yeah positive, I just tried a different method where I trigger the event through the CLI and I did get this error

#
stripe trigger --stripe-account='connect account id' checkout.session.completed 
#

Trigger failed: You are not authorized to access this endpoint.

#

This request specifically:

#
{
  "url": "https://api.stripe.com/v1/payment_pages/cs_test_a1ouEgvsTb4beMMUZaHpDXOnmBgMicv5NOk2ICVafSovgsD2PVxXDHfjio",
  "method": "get",
  "parameters": {}
}
#
{
  "error": {
    "code": "invalid_request_http_origin",
    "message": "You are not authorized to access this endpoint.",
    "type": "invalid_request_error"
  }
}
#

I thought it was an issue of the call not hitting my server for some reason but this seems to indicate that I've either configured something wrong (likely I suppose) or that for some other reason the test command isn't working

#

the first request from that command does go through properly:

{
  "url": "https://api.stripe.com/v1/checkout/sessions",
  "method": "post",
  "parameters": {
    "success_url": "https://httpbin.org/post",
    "cancel_url": "https://httpbin.org/post",
    "payment_method_types": [
      "card"
    ],
    "line_items": [
      {
        "name": "t-shirt",
        "description": "comfortable cotton t-shirt",
        "amount": 1500,
        "currency": "usd",
        "quantity": 2
      }
    ],
    "payment_intent_data": {
      "shipping": {
        "name": "Jenny Rosen",
        "address": {
          "line1": "510 Townsend St",
          "postal_code": "94103",
          "city": "San Francisco",
          "state": "CA",
          "country": "US"
        }
      }
    }
  }
}
``` I can paste the response if its required but i dont think its helpful
flat drum
#

I need to head out soon, but do you have an example event ID that you're not seeing come through from the stripe listen command?

distant seal
#

When I run the command through the CLI I get nothing through stripe listen when following this portion of the docs.

Finally, to allow your local host to receive a simulated event on your connected account run stripe listen --forward-connect-to localhost:{PORT}/webhook in one terminal window, and run stripe trigger --stripe-account={{CONNECTED_STRIPE_ACCOUNT_ID}} checkout.session.completed (or trigger any other supported event) in another.
#

The stripe listen command doesn't error out though, it's the second command that gives me the Trigger failed error

#

I know the account is connected correctly because I've been testing it through my website and payments go through fine

flat drum
#

Backing up for a minute - are you only testing with stripe trigger and that's not working? Or are you generating the Checkout Sessions another way, and the checkout sessions are still not coming through on stripe listen? If it's the latter, do you have a Checkout Session ID I can take a look at?

distant seal
#

I've tried both, I can try to find a checkout session ID one moment

#

The session ID would be present on the client account, correct?

flat drum
#

Yup

distant seal
#

So when checking out using my website (not the CLI), here is the most recent session ID from a completed checkout.session.completed event

#

cs_test_a1ZTK8DjdBiYW0O7l0KS9sYhJ1CJHQNX0lsCdAu0Benko1J2l30fppkJP8

#

Is there a way to see if the webhook is failing/not reaching my server because of some kind of error on my end?

flat drum
#

It depends on your server - I imagine if the request reached your server you'd have logs on your end to see the incoming reqeust.

distant seal
#

Yeah so I think it's not reaching it at all or not firing off correcetly

flat drum
#

Ignoring the issues you're seeing with stripe trigger for a bit, I'd suggest starting a fresh test with stripe listen --forward-connect-to localhost:8080/v1/dealers/stripeCheckoutWebhook and send over the full output your get to us.

#

I need to head out, but @outer delta can help take over from here

distant seal
#

OK thank you for all your help I appreciate it

#
2022-04-04 15:40:11
→
connect
payment_intent.created
[evt_3Kkvl0QhG88walQ21nGnCyQB]
2022-04-04 15:40:32
→
connect
customer.created
[evt_1KkvlMQhG88walQ2OuJbB1AB]
2022-04-04 15:40:32
→
connect
payment_intent.succeeded
[evt_3Kkvl0QhG88walQ21637ESHv]
2022-04-04 15:40:32
→
connect
charge.succeeded
[evt_3Kkvl0QhG88walQ21v35l85r]
2022-04-04 15:40:33
→
connect
checkout.session.completed
[evt_1KkvlNQhG88walQ2wcDbj12n]
#

This is what I get in the browser CLI after walking through the checkout on my website

#

omg one second

#
2022-04-04 15:42:37
→
connect
payment_intent.created
[evt_3KkvnNQhG88walQ21ZKiVmjv]
2022-04-04 15:42:57
→
connect
customer.created
[evt_1KkvnhQhG88walQ2WGH3ZObN]
2022-04-04 15:42:57
→
connect
payment_intent.succeeded
[evt_3KkvnNQhG88walQ21ulFpeYf]
2022-04-04 15:42:57
→
connect
charge.succeeded
[evt_3KkvnNQhG88walQ21WEhJXD1]
2022-04-04 15:42:58
→
connect
checkout.session.completed
[evt_1KkvnhQhG88walQ21z6csmRR]
(ShopAccessories365) $  
#

This one would be better to look at

outer delta
#

Hi there 👋 getting caught up

distant seal
#

I'm wondering if it's because I'm using this:

    \Stripe\Stripe::setApiKey(env('STRIPE_ACCOUNT_KEY'));

    $payload = @file_get_contents('php:://input');
    //return file_put_contents('php://stderr', print_r($payload, TRUE));
    Storage::put('dealer_errors.txt', json_encode($payload));
#

but using laravel

outer delta
#

You mentioned that you're using Laravel. Are you just using the Larevel framework, or are you leveraging Laravel Cashier?

distant seal
#

Not using Laravel cashier

outer delta
#

Gotcha. To clarify, are you using the Stripe CLI Shell beta, or are you running the CLI locally?

distant seal
#

I'm using the browser one

#

Right on the stripe webstie

outer delta
#

Hm, I'm not sure localhost is going to work there.

distant seal
#

OK one minute

#

OK I think this is now sending correctly lol, give me a moment to test

#

I'm getting server errors now at least so that's a step in the right direction

outer delta
#

Awesome! I think trying to use localhost on the browser CLI resolves to something that isn't local to you, but local to the system running the shell.

distant seal
#

Yeah it's obvious now that you said it

#

Just not a consideration I made I suppose

outer delta
#

Don't worry, I did the exact same thing when I was first made aware of the browser-based CLI.

distant seal
#

OK I think I have this working now

#

If I have another question I'll open another thread but this issue seems solved

#

Thanks so much! Can't believe I used up so much time on something so obvious in hindsight

#

Actually one second

#

I want to test the actual checkout process now as well

#

looks good! thank you

outer delta
#

Happy to help!