#Edp425

1 messages · Page 1 of 1 (latest)

south urchinBOT
wispy imp
#

Hi

viscid field
#

hello! gimme a couple of minutes to get back to you

wispy imp
#

Thanks

viscid field
wispy imp
#

'query' => 'status: "active" AND metadata['somedata']:'{$variablehere}'',

#

?

viscid field
#

Your string is formatted wrongly. You can see a example here : https://stripe.com/docs/api/subscriptions/search - select php from the sample code

Example

$stripe->subscriptions->search([
  'query' => 'status:\'active\' AND metadata[\'order_id\']:\'6735\'',
]);```
wispy imp
#

yes but my order id is a variable

#

so $stripe->subscriptions->search([
'query' => 'status:'active' AND metadata['order_id']:'$howdoiputvariablehere'',
]);

viscid field
#

To clarify, this
'status:'active' AND metadata['order_id']:'$howdoiputvariablehere'' isn't a proper string

#

to include single quotes in the string, you need to prefix with a slash

wispy imp
#

$log= $stripe->subscriptions->search([
'query' => 'status: "active" AND metadata['customerid']: '$test' ',

]);

#

it wont let me add the slash on dc

#

but i need to search by variable

viscid field
#

to include code in discord, start and end with 3 backticks

#

since you're aware of how to format the string, go ahead and try it out

wispy imp
#

but i don't know how to add a variable

#

how do i concentrate the variable into the string

#
    'query' => 'status:\'active\' AND metadata[\'customerid\']:\'{$myvariablehere}\'',
  ]);


#

the {} is not workign 😦

viscid field
#

to give you an example

$varhere = 'hello';
$longstring = "status:\'active\' AND metadata[\'order_id\']:\'{$varhere}\'";
echo $longstring;
wispy imp
#

ty bro "" worked

#

it was the speechmarks

#

still getting an error though 1 sec

#

but i am trying to add it in that stripe query

viscid field
#

what's the error?

wispy imp
#

the variable doesn't work

#
    'query' => "status:\'active\' AND metadata[\'customerid\']:\'{$testvariable}\'",
  ]);
  echo $log;
viscid field
#

why aren't you using double quotes to enclose the string?

like the documentation mentions : https://www.php.net/manual/en/language.operators.string.php

Remember to use double quotes (" ") as their content is parsed by php, because in single quotes (' ') you'll get literal name of variable provided:
wispy imp
#

Ensure you have properly quoted values while searching. Try updating your query to status:"\'active\'" at line 1 and column 8. thrown in C:\xampp\htdocs\myfans3\vendor\stripe\stripe-php\lib\Exception\ApiErrorException.php on line 38

#

but at least the variable is blue in double quotes

viscid field
#

onesec, looking into this

wispy imp
#

all these different speech marks are doing my nut in man

#

any luck?

viscid field
#

yeah, it was driving me up the wall too 🤣

#

this should work

#
$longstring = "status:'active' AND metadata['order_id']:'" . $varhere ."'";
echo $longstring;

$result = $stripe->subscriptions->search([
  'query' => $longstring,
]);
#

if you enclose it with double quotes, you don't need the slash for the single quotes

#

so this works too

$result = $stripe->subscriptions->search([
  'query' => "status:'active' AND metadata['order_id']:'{$varhere}'",
]);
wispy imp
#

i tried that first method you sent me but it didnt work i'll try again

#

thanks a lot bro you are the best