Im trying to retrieve as much data from Square and saving to our database. So fetching data from PaymentsAPI, OrdersAPI and of course getting their corresponding Customer and Employee data as well. On accessing OrdersAPI, I fetch the CustomerID from Tenders then check if my database table has that Id or not. The problem Im facing is that OrdersAPI gives me a Customer Id: RNRW1RT1R15TDEAYKBAB8X78G8 but when I retrieve Customer from the CustomersAPI, it fetches an Id which is already in my database. How come both Ids refer to same Customer?
I’m not entirely clear what you mean by it already being in your database. The customer ids can definitely be reused, of course, because a customer can make multiple purchases. Did perhaps this customer already purchase something else, and that’s why it’s already in your database?
If I get the customer using API Explorer or through my code using CustomerAPI, I use Customer id (RNRW1RT1R15TDEAYKBAB8X78G8 ) it returns a customer with id (TSC5T49A2H6D3CRTT885PYEHQW)
Sorry, I’m still not following. Could you provide a snippet of what you’re trying to do? You’re trying to retrieve
RNRW1RT1R15TDEAYKBAB8X78G8 but it’s returning
Where are you seeing these customer_ids?
I retrieve customer Id from OrdersAPI:
customerApiId = orderItem.Tenders.CustomerId;
then from there I retrieve the Customer info from CustomerAPI
var customerInfo = customersApi.RetrieveCustomer(customerId: customerID)
Can you provide the
order_id so I can take a look at it, please?
Just spoke to the Customers API team, and it seems that the customer_id (
RNRW1RT1R15TDEAYKBAB8X78G8) is a merged customer. When customers are merged, it creates an entirely new customer profile with a new customer_id. In this case the
RetrieveCustomer endpoint is returning the new customer_id (
TSC5T49A2H6D3CRTT885PYEHQW) since the old one is no longer relevant.
Is there anyway I can know if this is a merged Customer?
creation_source in the
RetrieveCustomer response says
Thanks. Will the old id always work? Im contemplating if I need to save the new id as well or not.
Well the old id will always be a part of that order, we don’t retroactively update orders/payments after a merge takes place to update to the new customer_id, so as far as I know it should always work.
Is it possible to get both old and new id through the Customer API?
No, the old customer is basically deleted once you merge it.
Alright. I had another question, how many times can a Customer be merged? Im trying to understand whether a customer can have multiple older Ids associated in Orders.
As far as I know there is no limit, but merging can only happen within the Square Dashboard, not via the APIs, just to be clear.
I understand. Thanks.