Skip to content
This repository was archived by the owner on Mar 15, 2018. It is now read-only.

Commit 86400a5

Browse files
author
Andy McKay
committed
use the currency selection
1 parent a483c0a commit 86400a5

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

mkt/purchase/tests/test_views.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,20 @@ def check(*args, **kw):
8888
.returns(('some-pay-key', '')))
8989
self.client.post_ajax(self.purchase_url, data={'tier': 0})
9090

91+
@fudge.patch('paypal.get_paykey')
92+
def test_paykey_default_currency(self, get_paykey):
93+
PreApprovalUser.objects.create(user=self.user, currency='BRL',
94+
paypal_key='foo')
95+
96+
def check(*args, **kw):
97+
return (args[0]['currency'] == 'BRL' and
98+
args[0]['amount'] == Decimal('0.99'))
99+
(get_paykey.expects_call()
100+
.with_args(arg.passes_test(check))
101+
.returns(('some-pay-key', '')))
102+
self.client.post_ajax(self.purchase_url, data={'tier': 0})
103+
104+
91105
@fudge.patch('paypal.get_paykey')
92106
def test_paykey_error(self, get_paykey):
93107
get_paykey.expects_call().raises(PaypalError())

mkt/purchase/views.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ def purchase(request, addon):
6060
preapproval = None
6161
if waffle.flag_is_active(request, 'allow-pre-auth') and request.amo_user:
6262
preapproval = request.amo_user.get_preapproval()
63+
# User the users default currency.
64+
if currency == 'USD' and preapproval.currency:
65+
currency = preapproval.currency
6366

6467
try:
6568
paykey, status = paypal.get_paykey(dict(

0 commit comments

Comments
 (0)