#BidBird®

1 messages · Page 1 of 1 (latest)

weary oceanBOT
broken bough
#

Hi 👋

#

That is correct, Payment Intents are a stripped down implementation for collecting funds

#

If you aren't interested in using Checkout or Invoices to collect this information but need it in your webhooks you can store it in the metadata parameter when creating your Payment Intents.

atomic panther
#

ahh really, cool.

broken bough
#

Yup. You can then access the metadata in the Payment Intent sent in the webhook event

atomic panther
#

ok, how is the archetype of that in php? nevermind, just found this: "metadata" => ["order_id" => "6735"]

#

very cool. Thank you so much.

broken bough
#

Yes those little code snippets are handy 😁

atomic panther
#

I was literally ... man how am I going to do this. Awesome

broken bough
#

Happy to help 🙂

atomic panther
#

alrighty, gave that a go:

"metadata": {
"quantity": null,
"price": null
},
#

Here's the update method:

public function updatePaymentIntent(Request $request): \Illuminate\Http\JsonResponse{    

$amount = $request['params']['quantity'] * $request['params']['price'];    

$intent = \Stripe\PaymentIntent::update(        
$request['params']['paymentIntent'],        
['amount' => $amount,            
    'metadata' => [                
        'quantity' => $request['params']['quantity'],                
        'price'    => $request['params']['price'],            
    ]        
]    
);    

return response()->json(['status' => $intent]);
broken bough
#

Why are you passing in empty values?

atomic panther
#

What do you think could trip this up? I can see the values here: "id": "pi_3MlebAKT8fxib8XB0djHxHwV",

broken bough
#

This should work, as long as the PHP syntax is correct.

atomic panther
#

yea it's strange, because it posted to stripe just ok. but the webhook endpoint seems to lose the data.

broken bough
atomic panther
#

I believe it's this one: pi_3MlebAKT8fxib8XB0djHxHwV

#

sorry here: req_4kuLI5eN45ti9W

broken bough
#

The metadata was returned in the API response:

metadata: {
    quantity: "3",
    price: "500",
  },
atomic panther
#

weird. the payment_intent.created which is posted to the webhook uri shows null

broken bough
#

But you only provided the metadata when you updated the Payment Intent

atomic panther
#

I'm sorry, there's a number of posts to that uri. The null one happens on this: "type": "payment_intent.created" that makes sense.

#

OK I think it's because I set up a bunch of events to be sent?

broken bough
#

The intent returned from the payment_intent.created event will be exactly as it was when it was created. The code snippet you shared updates the PI, which must happen after it is created

atomic panther
#

yea, I get it now. I'm looking at several posts to that endpoint with different events. I'm just dialing in, with the dashboard and which events I really need to do work on my server.

Thank you for helping..

#

I do have a question on CI. Is it possible to test integration with webhooks?

#

Have a ton of tests, but I'll need to update to the new payment element.

broken bough
#

We do not recommend building CI tests directly against the Stripe API. For automated testing we recommend building a mocking service that returns Stripe API objects. You would manually test against the API and save copies of the data returned to use in your mocking service. Otherwise you could hit our rate limits and have all your requests blocked

atomic panther
#

ahh, that makes sense. Do you have any demos on this?

broken bough
#

Not yet but I'm working on an update to our docs. Basically you can trigger Stripe webhook events using the Stripe CLI and listen for the events using the CLI also. That is how I would suggest you get samples to use in your mocking service: https://stripe.com/docs/cli/listen

atomic panther
#

ok cool. I watched CJ's video earlier today, and got CLI up and running. Super cool. Will check your link out tomorrow....

#

Thank you much!

weary oceanBOT