#Vane-metadata

1 messages ยท Page 1 of 1 (latest)

hearty harness
#

๐Ÿ‘‹ happy to help

midnight grail
#

I stored order-id's in the metadata

hearty harness
#

in the metadata of what?

midnight grail
#

so I want to like retrieve a paymentintent from its order id

#

I think I got it

#

isn't there a limit on that though?

hearty harness
#

it's the search you're looking for

#

and there's an example there for how to retrieve PIs from metadata

midnight grail
#

ye thanks, what exactly are the \ \ \ \ ?

#
$stripe->paymentIntents->search([
  'query' => 'status:\'succeeded\' AND metadata[\'order_id\']:\'6735\'',
]);
#

spaces?

hearty harness
#

\' is to escape the quotes

midnight grail
#

<b>Fatal error</b>: Uncaught (Status 400) (Request req_NSI9YD39EEjpCf) Search is not supported on api version 2018-11-08. Update your API version, or set the API Version of this request to 2020-08-27 or greater.

hearty harness
#

Oh yeah, you are on a very old API version

midnight grail
#

how would I update

hearty harness
#

but if you don't want to migrate all your code, you could specify the API version for this particular call

#

look at the Per-request Stripe version example

midnight grail
#

thanks ๐Ÿ‘

midnight grail
# hearty harness https://stripe.com/docs/api/versioning?lang=php

can't seem to access 'id'

$stripe = new \Stripe\StripeClient(["api_key"=>'sk',"stripe_version" => "2020-08-27"]);
$paymentIntent = $stripe->paymentIntents->search([
    'query' => 'status:\'succeeded\' AND metadata[\'order_id\']:\''.$order_id.'\'',
]);
echo $paymentIntent->data['id'];
#

I tried json_decode but that returns NULL

robust kindle
#

That's because data is an array

#

you'd need data[0]['id'] i believe

#

I'd print out what $paymentIntent looks like though to make sure it's actually returning results

midnight grail
#

yup its printing, yeah data[0]['id'] works