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

Sync cards via webhook #41

Merged
merged 6 commits into from Jan 9, 2018

Conversation

hash
Copy link

@hash hash commented Jan 5, 2018

No description provided.

@hash hash requested a review from pkrzyzaniak January 5, 2018 17:14
@coveralls
Copy link

coveralls commented Jan 5, 2018

Coverage Status

Coverage decreased (-0.1%) to 91.793% when pulling 3b78fee on feature/sync-cards-via-webhook into 0b9b0d4 on feature/multiple-cards.

else:
raise StripeWebhookParseError(_("Card with this id does not exists at Stripe API"))
else:
raise StripeWebhookParseError(_("Card with this id and customer already exists"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we'll have this error each time a new card gets created

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, i'll ignore this case

@@ -583,6 +594,35 @@ def _parse_coupon_notification(self, action):
elif action == "deleted":
StripeCoupon.objects.filter(coupon_id=coupon_id, created=created).delete()

def _parse_customer_source_notification(self, action):
stripe_card_id = self.raw_data["data"]["object"]["id"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if type != card:
return

elif action == "updated":
try:
card = StripeCard.objects.get(stripe_card_id=stripe_card_id, customer=customer)
for updated_field in StripeCard.STRIPE_UPDATABLE_FIELDS & set(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment above deleted - it was invalid. Anyway, it would be best to just call here "retrieve from stripe" & update the card based on the newest data.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

@@ -125,6 +126,16 @@ def create_at_stripe(self):
self.save()
return self

def sync_with_stripe(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to refresh_from_stripe in other places.

except StripeCustomer.DoesNotExist:
raise StripeWebhookParseError(
_("There is no customer with id that is assigned to this card in our database"))
if action == "created":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line break before it for better readable.

@coveralls
Copy link

coveralls commented Jan 8, 2018

Coverage Status

Coverage decreased (-0.009%) to 91.895% when pulling e751c25 on feature/sync-cards-via-webhook into 0b9b0d4 on feature/multiple-cards.

@hash hash force-pushed the feature/sync-cards-via-webhook branch from e751c25 to f59c7a2 Compare January 8, 2018 16:11
@coveralls
Copy link

coveralls commented Jan 8, 2018

Coverage Status

Coverage decreased (-0.01%) to 92.03% when pulling f59c7a2 on feature/sync-cards-via-webhook into 42b5c46 on feature/multiple-cards.

@coveralls
Copy link

coveralls commented Jan 8, 2018

Coverage Status

Coverage decreased (-0.01%) to 92.03% when pulling 1db3843 on feature/sync-cards-via-webhook into 42b5c46 on feature/multiple-cards.

@hash hash merged commit 4691632 into feature/multiple-cards Jan 9, 2018
@hash hash deleted the feature/sync-cards-via-webhook branch January 9, 2018 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants