Skip to content

Commit

Permalink
Merge pull request #86 from blueyed/fix-sync_coupon_from_stripe_data
Browse files Browse the repository at this point in the history
sync_coupon_from_stripe_data: handle livemode
  • Loading branch information
blueyed authored Nov 20, 2017
2 parents 6826caa + a664932 commit 9952de6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
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

0 comments on commit 9952de6

Please sign in to comment.