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_coupon_from_stripe_data: handle livemode #86

Merged
merged 1 commit into from
Nov 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pinax/stripe/actions/coupons.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def sync_coupon_from_stripe_data(coupon, stripe_account=None):
currency=coupon["currency"] or "",
duration=coupon["duration"],
duration_in_months=coupon["duration_in_months"],
livemode=coupon["livemode"],
max_redemptions=coupon["max_redemptions"],
metadata=coupon["metadata"],
percent_off=coupon["percent_off"],
Expand Down
4 changes: 3 additions & 1 deletion pinax/stripe/tests/test_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,7 @@ def test_sync_coupon_from_stripe_data(self):
"currency": None,
"duration": "repeating",
"duration_in_months": 3,
"livemode": False,
"livemode": True,
"max_redemptions": None,
"metadata": {
},
Expand All @@ -1228,9 +1228,11 @@ def test_sync_coupon_from_stripe_data(self):
"valid": True
}
cs1 = coupons.sync_coupon_from_stripe_data(coupon)
self.assertTrue(cs1.livemode)
c1 = Coupon.objects.get(stripe_id=coupon["id"], stripe_account=None)
self.assertEquals(c1, cs1)
self.assertEquals(c1.percent_off, decimal.Decimal(35.00))

cs2 = coupons.sync_coupon_from_stripe_data(coupon, stripe_account=account)
c2 = Coupon.objects.get(stripe_id=coupon["id"], stripe_account=account)
self.assertEquals(c2, cs2)
Expand Down