feat: Enhanced Stripe customer data with duplicate prevention#13
feat: Enhanced Stripe customer data with duplicate prevention#13jimtyrro wants to merge 1 commit intoInvoiceShelf:mainfrom
Conversation
- Add duplicate customer prevention via email search - Include complete customer data (name, email, phone, address) - Retrieve company name from custom fields - Add comprehensive metadata for reporting - Improve payment descriptions with invoice number - Support automatic Stripe receipt emails - Add flexible address handling for multiple InvoiceShelf versions - Implement robust country code detection Fixes InvoiceShelf#8
|
Hey @jimtyrro thanks for the PR, I will review this PR in the following weeks if time allows. In the interim, I appreciate this is generated by AI, but please clean up the PR body to be concise and to the point, you have a lot of “froth” on top. Summary and what this adds is mostly all I need, all the sections after are just noise and padding. Lastly, please indicate how much of the code is written by the AI and how much was written by you. Use of AI is not bad per se, but I need to know beforehand. |
|
It’s all AI. I’ve asked you to help fix the missing data for the Stripe payment an year ago, you’re apparently very busy so asked AI to help and now I have a working add-on that does everything I need and decided to share. I will clean up PR description per your suggestion and you can use it or not use it, it’s totally up to you. |
Enhanced Stripe Customer Data & Duplicate Prevention
Summary
This PR enhances the Stripe payment integration to prevent duplicate customer creation and sync complete customer data to Stripe. Currently, each payment creates a new Stripe customer with minimal information. This change searches for existing customers by email and includes comprehensive customer data.
What This Adds
CUSTOM_CUSTOMER_COMPANY_NAME)Technical Changes
New Methods
findExistingStripeCustomer($email)- Search Stripe for existing customer by emailgetOrCreateStripeCustomer($invoice, $customer)- Get existing or create new customer with full datagetCustomerCompanyName($customer)- Retrieve company name from custom fieldstring_answercolumngetCustomerBilling($customer)- Flexible billing address retrieval supporting multiple address relationship patternsgetCountryCode($country)- Country code detection supporting multiple field name patterns (iso2, code, short_code)Modified Method
generatePayment(Company $company, $invoice)- Now creates/reuses customers and includes complete dataBackward Compatibility
Fully backward compatible. Gracefully handles:
Testing
Tested with:
Fixes #8