I have a yoga studio system. Students can buy individual class cards or subscriptions.
I use the customer API get a square customer id for each new student. I save the returned ID in as primary key in my database ‘students’ table.,
I refer to webhooks like ‘payment.created’ and ‘payment.updated’ to track student payments. These webhooks have ‘customer_id’ info. I move info into a ‘studentpayments’ table.
What I now see is that some payment’s ‘customer_id’ has a value that doesn’t match any ‘students’ record.
If I use the API explorer, I can find a record for this unknown square id. The API explorer shows source ‘Merge’
I can manually search my database for the name, email, etc., and usually can find a database record that shows the ORIGINAL square customer_id saved in the database.
If I use the API Customer explorer, I can find that earlier original square record showing the with source ‘Merge’
I see that I was not well informed about Square Customer_IDs
These are not appropriate for database primary keys, as they can be changed arbitrarily with a Square “merge” operation.
So relating ‘studentpayments’ to the orginal customer_id creates a lot of problems. Customer_ids identified in Payment webhooks may not have any info in my database.
I can’t find any API that shows the customer_ids that were merged into Square’s new customer_id.
I was unaware that NEW Square customer records were being createrd by Square outside of my control. I create “customer” updates via API when students change their information, so I haven’t been tracking ‘customer.created’ webhooks.
I assume that there’s a suggested method for handling customer-created webhooks for a merge? Not shown as an individual webhook – It appears to be included a ‘merge’ event found in a custtomer_created webhook? (I don’t see any way to initate a test “CreateCustomer” webhook that includes the context of a customer_merge, however.)
From the documentation on “merge” it t looks like Square treats the new Merged id as the customer primary key? Also apparently deletes customer records with previous ids?
Am I going to have to update all previous database records to reflect this change? Is the previous ‘customer_id’ useless?
Some of our students use the same name, email address, etc. to create different types of studio database accounts (one for subsriptions, another for one-off purchases like workshops, tshirts, etd), with different usernames and passwords, and these got different square customer ids saved in the database as my database primary key. In at least one instance these records were merged to a new customer_id, even though in my view they represent different student records, based on the STUDENT’s desire to have separate records
I need more understanding of
-
When and how Square decides to merge customer_ids
This seems to be an internal decision not based on an event my system intiated? -
How better to use the merge events? Records deleted even though my database thinks they exist? Similar records I created now must be reflect merged ids?
-
Whether existing Square payment/subscription and other data reflects the original customer_id or the new merged id
-
How to find records of all existing customer_ids: the current customer_id and previous ids – since I have not been following along all these ‘customer-created / merged’ webhooks.
It looks like I’ll have to establish a different primary key, and then develop a resolving table “studentSquareIDs” to do much more complicated database selections.
Also from an answer to an earlier question
…/forums/t/merged-customer-id-confusion/22030
you replied:
The merge operation prioritizes older data over newer data. That’s why the old names were retained in the merged profile.
So apparently your merge will alter names/email addresses, etc.? Square decides that 2 customers are the ‘same’, and merge, but decides to use older data instead of newer? Really?
Any thoughts on this that might be helpful?