Skip to content

Commit

Permalink
Correctly handle webhooks
Browse files Browse the repository at this point in the history
  • Loading branch information
bakura10 committed Mar 28, 2015
1 parent f44c86c commit a071f10
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 1.2.3

* Fix a bug where discount webhook were not correctly handled, which resulted in updates not being updated
* Fix a bug where subscription webhook were not correctly handled, which resulted in updates not being updated

## 1.2.2

* Fix logic for the `isExpired` method on card entity
Expand Down
10 changes: 5 additions & 5 deletions src/Listener/WebhookListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ private function handleCustomerDiscountEvent(array $stripeEvent)
if (null !== $customer && ($discount = $customer->getDiscount())) {
$customerDiscountService->remove($discount);
}
} else {
$customerDiscountService->syncFromStripeResource($stripeDiscount);
}

$customerDiscountService->syncFromStripeResource($stripeEvent);

return 'Event has been properly processed';
}

Expand All @@ -179,10 +179,10 @@ private function handleSubscriptionDiscountEvent(array $stripeEvent)
if (null !== $subscription && ($discount = $subscription->getDiscount())) {
$subscriptionDiscountService->remove($discount);
}
} else {
$subscriptionDiscountService->syncFromStripeResource($stripeDiscount);
}

$subscriptionDiscountService->syncFromStripeResource($stripeEvent);

return 'Event has been properly processed';
}

Expand Down Expand Up @@ -212,7 +212,7 @@ private function handleSubscriptionEvent(array $stripeEvent)
{
/** @var SubscriptionService $subscriptionService */
$subscriptionService = $this->serviceLocator->get(SubscriptionService::class);
$subscriptionService->syncFromStripeResource($stripeEvent);
$subscriptionService->syncFromStripeResource($stripeEvent['data']['object']);

return 'Event has been properly processed';
}
Expand Down
2 changes: 1 addition & 1 deletion src/Service/SubscriptionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public function syncFromStripeResource(array $stripeSubscription)
}

/** @var Subscription $subscription */
$subscription = $this->subscriptionRepository->findOneBy(['stripe_id' => $stripeSubscription['id']]);
$subscription = $this->subscriptionRepository->findOneBy(['stripeId' => $stripeSubscription['id']]);

if (null === $subscription) {
return; // We do not handle creation
Expand Down

0 comments on commit a071f10

Please sign in to comment.