Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

KalimeroMK's avatar

Search try stripe transaction

Hi I need to search try my stripe transaction cording to email and amount according to the documentation on stripe https://stripe.com/docs/api/charges/search?lang=php my code is

 $transactions = Transaction::with('user')->whereStatus('pending')->get();
            foreach ($transactions as $transaction) {
                $stripe = new StripeClient(
                    'sk_test_51ILwQcDTtGd18F0vf'
                );
                $stripe->charges->search([
                    'query' => 'amount>'.$transaction->amount.' AND metadata[\'email\']:\''.$transaction->user->email.'\'',
                ]);
                dd($stripe);
            }

getting this error

We were unable to parse your search query. Try using the format `metadata["key"]:"value"` to query for metadata or key:"value" to query for other fields. 
0 likes
10 replies
MohamedTammam's avatar

what's the value of dd('query' => 'amount>'.$transaction->amount.' AND metadata[\'email\']:\''.$transaction->user->email.'\'') ?

kokoshneta's avatar

@KalimeroMK The documentation consistently uses double quotes, so it may be considering the single quotes invalid – have you tried this instead?

"query" => "amount > {$transaction->amount} AND metadata[\"email\"]:\"{$transaction->user->email}\"

That would be an easy first thing to try, at least.

Edit: Oh, actually it doesn’t. The documentation for the search query language and supported query fields both use double quotes, but the example on the page you linked to uses single quotes, so it’s probably not that after all.

kokoshneta's avatar

@KalimeroMK Are you sure the API accepts floats? The documentation only calls it “numeric”, which is wonderfully vague, but I seem to recall from past dealings with the Stripe API that amounts must be integers, at least back when I was integrating it some years ago.

Have you tried using $transaction->amount * 100?

KalimeroMK's avatar

The doc is wrong or I understand it wrong the end point it is for mount only for email need separate endpoint

Please or to participate in this conversation.