Skip to content

Commit b4d81fa

Browse files
authored
Merge pull request #73 from craftcms/bugfix/69-sync-changed-user-emails-to-stripe
use old email to search for stripe customers
2 parents 3600d20 + ad66108 commit b4d81fa

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Unreleased
44

5+
- Fixed a bug where Craft user’s email address was not synced to Stripe even if `syncChangedUserEmailsToStripe` was set to `true`. ([#69](https://github.com/craftcms/stripe/issues/69))
56
- Fixed a bug where the plugin was attempting to create missing users when `createUserIfMissing` was `true` but the Craft edition didn’t allow for multiple users. ([#72](https://github.com/craftcms/stripe/pull/72))
67

78
## 1.3.2 - 2024-12-11

src/Plugin.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -619,10 +619,10 @@ private function handleUserElementChanges(): void
619619
$oldEmail = $userRecord->getAttribute('email');
620620
$newEmail = $user->email;
621621
if ($oldEmail && $newEmail && ($oldEmail != $newEmail)) {
622-
$customers = $user->getStripeCustomers();
623-
if ($customers->isNotEmpty()) {
622+
$customers = Plugin::getInstance()->getCustomers()->getCustomersByEmail($oldEmail);
623+
if (!empty($customers)) {
624624
$client = $this->getApi()->getClient();
625-
foreach ($customers->all() as $customer) {
625+
foreach ($customers as $customer) {
626626
try {
627627
$updatedCustomer = $client->customers->update($customer->stripeId, ['email' => $newEmail]);
628628
$this->getCustomers()->createOrUpdateCustomer($updatedCustomer);

0 commit comments

Comments
 (0)