#richie138 - Customer Emails

1 messages ยท Page 1 of 1 (latest)

languid thicket
#

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?

modern osprey
#

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

languid thicket
#

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?

modern osprey
#

request ID?

#

How about this subscription ID?

#

sub_K6ZOjrDnSb4zn9

languid thicket
#

Yeah, that works.

#

Looking...

modern osprey
#

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

languid thicket
modern osprey
#

Let me try to figure that out

#

req_kdTZykAN3ZiISv

#

I think

languid thicket
#

There's no email address specified in that request.

modern osprey
#

Hm

#

What about this one?

#

req_6LJkphwy2q7LRa

languid thicket
#

Same issue.

#

Ah, is it this one?

modern osprey
#

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

languid thicket
#

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.

modern osprey
#

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

languid thicket
#

Can you show me the code that generated this request?

modern osprey
#

sure

#

Am I not constructing this query propery?

languid thicket
#

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

modern osprey
#

Oh this chat is not private

#

D'oh

languid thicket
#

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.

modern osprey
#

That makes sense, thank you for the alert

languid thicket
#

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!

modern osprey
#

Ok

#

I rolled it

#

I'm ready to resume troubleshooting whenever you are ready to help

languid thicket
#

Sounds good! Can you share that code again, but with the key and any other sensitive info redacted? ๐Ÿ™‚

modern osprey
#
    $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;
  }


?>

languid thicket
#

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.

modern osprey
#

ohhh!

#

Thank you

#

I appreciate all your help

languid thicket
#

No problem! ๐Ÿ™‚

modern osprey
#

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?

languid thicket
#

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.

modern osprey
#

That is surprising

languid thicket
#

Yep, but that's unfortunately the way it works. ๐Ÿ˜…

modern osprey
#

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

languid thicket
#

The Dashboard has the ability to do a case-insensitive search, yeah.