#BidBird®
1 messages · Page 1 of 1 (latest)
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.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
ahh really, cool.
Yup. You can then access the metadata in the Payment Intent sent in the webhook event
ok, how is the archetype of that in php? nevermind, just found this: "metadata" => ["order_id" => "6735"]
very cool. Thank you so much.
Yes those little code snippets are handy 😁
I was literally ... man how am I going to do this. Awesome
Happy to help 🙂
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]);
Why are you passing in empty values?
What do you think could trip this up? I can see the values here: "id": "pi_3MlebAKT8fxib8XB0djHxHwV",
This should work, as long as the PHP syntax is correct.
yea it's strange, because it posted to stripe just ok. but the webhook endpoint seems to lose the data.
Can you share the request ID?
Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request
I believe it's this one: pi_3MlebAKT8fxib8XB0djHxHwV
sorry here: req_4kuLI5eN45ti9W
The metadata was returned in the API response:
metadata: {
quantity: "3",
price: "500",
},
weird. the payment_intent.created which is posted to the webhook uri shows null
But you only provided the metadata when you updated the Payment Intent
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?
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
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.
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
ahh, that makes sense. Do you have any demos on this?
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
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!