#richie138 - Customer Emails
1 messages ยท Page 1 of 1 (latest)
Hello! There's no way to find Customers via the API using a case-insensitive email match. The email address you provide must be an exact match.
Can you give me the Customer ID of the Customer you're not seeing when you use the API? Is it because the case of the email address does not match?
It's not because it doesn't match
It's not working whether it matches or not
Here's the customer ID
d9d3d8c4-20e2-d198-424c-3f105919d272
Oh, unfortunately I can't look up that ID as it's not a Stripe-generated ID. Do you have a request ID or other Stripe ID associated with that Customer?
Note: I updated the email address in the last 10 minutes or so to be all lowercase, prior to the update the R was capital
However it wasn't finding it before whether I passed it in capitalized or not
Can you give me the request ID showing the list Customers call that didn't show this Customer? It would be similar to this one: https://dashboard.stripe.com/logs/req_3oSieg9fEZWVYe
There's no email address specified in that request.
Same issue.
Here's one with an email specified, for example: https://dashboard.stripe.com/logs/req_amJnFuj37O25hg
Ah, is it this one?
Well, it could be
It's similar, that's from a different program than the one I'm debugging, but it is the same email
Gotcha. If you can find the exact request we should be able to make progress solving the issue. If you can reproduce the issue again you should be able to find the new request easier, as it should be at or near the top of the request logs in your Dashboard.
I'll try to find it - I'm not sure why I can't
Maybe req_3iP0sPyJAsJgif
Not sure why it's not showing any email on the request
Can you show me the code that generated this request?
You shared your live key in that code. You should never share your secret API keys, as they can be used to do just about anything on your account. Since you shared your key here I strongly recommend you immediately roll your API key (which will create a new key and block the old one) as explained here: https://stripe.com/docs/keys#rolling-keys
No, this is a public Discord server.
Even if it wasn't I would still say the same thing.
You should never share your secret key with anyone, ever, under any circumstances, even someone at Stripe.
That makes sense, thank you for the alert
No problem. Make sure you roll your key immediately, which I realize might take some time. We'll still be here to resume helping you with this issue when you're done!
Ok
I rolled it
I'm ready to resume troubleshooting whenever you are ready to help
Sounds good! Can you share that code again, but with the key and any other sensitive info redacted? ๐
$stripe = new \Stripe\StripeClient('
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET');
header('Content-type: application/json');
// If you're using Composer, use Composer's autoload:
require_once('../vendor/autoload.php');
// Be sure to replace this with your actual test API key
// (switch to the live key later)
$stripe = new \Stripe\StripeClient("REDACTED");
$emailQuery = $_GET['email'];
echo $emailQuery;
//$emailQuery = strtolower($_GET['email']);
try {
$customers = $stripe->customers->all('email'->$emailQuery);
echo json_encode($customers,JSON_PRETTY_PRINT);
// foreach($customers['data'] as $customer) {
// if (strtolower($customer->email) == strtolower($emailQuery)) {
// echo json_encode($customer);
// }
// }
}
catch (Exception $ex) {
// echo 'err';
echo $ex;
}
?>
Ah, so $customers = $stripe->customers->all('email'->$emailQuery); needs to be $customers = $stripe->customers->all(['email' => $emailQuery]);
Interesting that existing code didn't throw an error about that.
No problem! ๐
So since there's no way to query case insensitive
Is there any way to mass update all the emails in dashboard to be lowercase?
And is there a way to enforce lowercase in checkout?
No, nor should you. Stripe doesn't treat emails as case-insensitive because some email systems (and the email spec) doesn't. For example, person@example.com and Person@example.com can go to different inboxes.
That is surprising
Yep, but that's unfortunately the way it works. ๐
On the other hand, the dashboard returns results for a capitalized email address when I search for a lowercase one
So the query is somehow possible
The Dashboard has the ability to do a case-insensitive search, yeah.