Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes PR #200: Reconcile Supabase with Stripe in createOrRetrieveCustomer #274

Closed
wants to merge 4 commits into from

Conversation

chriscarrollsmith
Copy link
Contributor

Fixes and closes #200, which fails if the customer already exists in both Supabase and Stripe.

The code in that PR looks a Stripe record and then tries to upsert a duplicate record to Supabase without checking if a Supabase record exists first, which raises an error if a Supabase record exists.

I refactored the code so it should perform reconciliation in all edge cases.

  • If both Supabase and Stripe records exist but the IDs don't match, it updates the Supabase record.
  • If a record exists in Stripe but not in Supabase, it inserts a new Supabase record with the existing Stripe ID.
  • If a record exists in Supabase but not in Stripe, it creates a new Stripe record and updates the Supabase record with the new Stripe ID.
  • If no record exists in Stripe, it creates a new customer in both Stripe and Supabase.

This is a fairly aggressive reconciliation process, but it should be robust and should help correct human errors caused by manually deleting database entries.

Copy link

vercel bot commented Nov 19, 2023

@chriscarrollsmith is attempting to deploy a commit to the Vercel Solutions Team on Vercel.

A member of the Team first needs to authorize it.

Handle case where Supabase exists but Stripe does not.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant