NikolaGavric94 / laravel-square

Square integration with Laravel/Lumen >=5.5
MIT License
31 stars 23 forks source link

Customer with ID not found. #47

Closed jakus1 closed 3 years ago

jakus1 commented 3 years ago

Here is my code:

$user = User::firstOrCreate(
    ['email'=>$data['email']],
    ['first'=>$data['first'],'last'=>$data['last']]
);
$customer = [
    'first_name' => $data['first'],
    'last_name' => $data['last'],
    'email' => $data['email'],
];

Square::setMerchant($user)->setCustomer($customer)->save();

When I run the code against the sandbox api, everything works great. The customer is created and the transaction is attached to the customer. When I switch to live credentials I get: [HTTP/1.1 404 Not Found] {"errors": [{"code": "NOT_FOUND","detail": "Customer with ID `6XG3GYC5D8VCKE9JEHVVZAKECC` not found.","category": "INVALID_REQUEST_ERROR"}]}

I can't figure out why it works fine in sandbox, but not in live

jakus1 commented 3 years ago

I figured out what the issue is here. If anyone else encounters it, this is what is going on.

If you are using the same database for testing and live, when you test you create customers in your database that reference the Square sandbox but don't exist in the live database.

When you switch to live credentials, Square can't find the customer anymore (since it only exists in the sandbox) and throws this error.