Code: Select all
Customer with ID "foobar" not found!
In the Square extension file /catalog/controller/payment/squareup.php, the function checkout() retrieves the customer's Square ID from the squareup_customer DB here:
Code: Select all
$square_customer = $this->imodule_model_credit_card->getCustomer($this->customer->getId());
Code: Select all
$square_card = $this->squareup_api->addCard($square_customer['square_customer_id'], $card_data);
The api.php file contains a function API(), which is used to actually handle all the CURL executions. However, it is setup so that if the Square API returns an error, it will throw an exception and break:
Code: Select all
if (!empty($return['errors'])) {
throw new Exception\Api($this->registry, $return['errors']);
} else {
return $return;
}
The workaround right now is to delete the row in squareup_customer (via the browser or CLI) containing the incorrect customer ID and let the API recreate the customer on its own. However, to do this as part of the extension would probably require rewriting the way the api() function handles errors returned from the API.
Alternatively, an API call to the Square RetrieveCustomer endpoint could be implemented so that before calling addCard(), the controller will check to see if the customer exists on Square's end, and if not, delete the customer in the squareup_customer DB before proceeding to call addCard().
Any further insight on implementing a fix is appreciated, thanks!