Private
Public Access
1
0

Merge branch 'feature/braintree' into develop

This commit is contained in:
Sander Roosendaal
2019-07-23 19:51:48 +02:00
8 changed files with 74 additions and 18 deletions

View File

@@ -8,13 +8,13 @@ atomicwrites==1.3.0
attrs==19.1.0 attrs==19.1.0
backcall==0.1.0 backcall==0.1.0
beautifulsoup4==4.7.1 beautifulsoup4==4.7.1
billiard==3.5.0.5 billiard==3.6.0.0
bleach==3.1.0 bleach==3.1.0
bokeh==1.0.4 bokeh==1.0.4
boto==2.49.0 boto==2.49.0
braintree==3.51.0 braintree==3.55.0
cairocffi==1.0.2 cairocffi==1.0.2
celery==4.2.2 celery==4.3.0
certifi==2019.3.9 certifi==2019.3.9
cffi==1.12.2 cffi==1.12.2
chardet==3.0.4 chardet==3.0.4
@@ -30,7 +30,7 @@ cycler==0.10.0
dask==1.1.4 dask==1.1.4
decorator==4.4.0 decorator==4.4.0
defusedxml==0.5.0 defusedxml==0.5.0
Django==2.2.1 Django==2.1.7
django-analytical==2.5.0 django-analytical==2.5.0
django-async-messages==0.3.1 django-async-messages==0.3.1
django-braces==1.13.0 django-braces==1.13.0
@@ -46,9 +46,10 @@ django-leaflet==0.24.0
django-mailbox==4.7.1 django-mailbox==4.7.1
django-oauth-toolkit==1.2.0 django-oauth-toolkit==1.2.0
django-oauth2-provider==0.2.6.1 django-oauth2-provider==0.2.6.1
django-redis==4.10.0
django-rest-framework==0.1.0 django-rest-framework==0.1.0
django-rest-swagger==2.2.0 django-rest-swagger==2.2.0
django-rq==2.0 django-rq==1.3.1
django-rq-dashboard==0.3.3 django-rq-dashboard==0.3.3
django-ses==0.8.10 django-ses==0.8.10
django-shell-plus==1.1.7 django-shell-plus==1.1.7
@@ -66,7 +67,9 @@ Faker==1.0.4
fitparse==1.1.0 fitparse==1.1.0
Flask==1.0.2 Flask==1.0.2
future==0.17.1 future==0.17.1
GDAL==2.3.3
geocoder==1.38.1 geocoder==1.38.1
geos==0.2.1
holoviews==1.11.3 holoviews==1.11.3
html5lib==1.0.1 html5lib==1.0.1
htmlmin==0.1.12 htmlmin==0.1.12
@@ -96,7 +99,7 @@ jupyterlab==0.35.4
jupyterlab-server==0.3.0 jupyterlab-server==0.3.0
keyring==18.0.0 keyring==18.0.0
kiwisolver==1.0.1 kiwisolver==1.0.1
kombu==4.3.0 kombu==4.5.0
lxml==4.3.2 lxml==4.3.2
Markdown==3.0.1 Markdown==3.0.1
MarkupSafe==1.1.1 MarkupSafe==1.1.1
@@ -129,9 +132,9 @@ pip-upgrader==1.4.6
pluggy==0.9.0 pluggy==0.9.0
prometheus-client==0.6.0 prometheus-client==0.6.0
prompt-toolkit==2.0.9 prompt-toolkit==2.0.9
psycopg2==2.8.1
ptyprocess==0.6.0 ptyprocess==0.6.0
py==1.8.0 py==1.8.0
pycairo==1.18.0
pycparser==2.19 pycparser==2.19
Pygments==2.3.1 Pygments==2.3.1
pyparsing==2.3.1 pyparsing==2.3.1
@@ -157,10 +160,9 @@ ratelim==0.1.6
redis==3.2.1 redis==3.2.1
requests==2.21.0 requests==2.21.0
requests-oauthlib==1.2.0 requests-oauthlib==1.2.0
rowingdata==2.4.9 rowingdata==2.4.4
rowingphysics==0.5.0 rowingphysics==0.5.0
rq==1.0 rq==0.13.0
rq-dashboard==0.4.0
scipy==1.2.1 scipy==1.2.1
SecretStorage==3.1.1 SecretStorage==3.1.1
Send2Trash==1.5.0 Send2Trash==1.5.0
@@ -188,8 +190,9 @@ VerbalExpressions==0.0.2
vine==1.3.0 vine==1.3.0
wcwidth==0.1.7 wcwidth==0.1.7
webencodings==0.5.1 webencodings==0.5.1
Werkzeug==0.15.2 Werkzeug==0.15.1
widgetsnbextension==3.4.2 widgetsnbextension==3.4.2
winkerberos==0.7.0
xlrd==1.2.0 xlrd==1.2.0
xmltodict==0.12.0 xmltodict==0.12.0
yamjam==0.1.7 yamjam==0.1.7

View File

@@ -101,6 +101,11 @@ def get_plans_costs():
def make_payment(rower,data): def make_payment(rower,data):
nonce_from_the_client = data['payment_method_nonce'] nonce_from_the_client = data['payment_method_nonce']
nonce = gateway.payment_method_nonce.find(nonce_from_the_client)
info = nonce.three_d_secure_info
if info is None or not info.liability_shifted:
return False,0
amount = data['amount'] amount = data['amount']
amount = '{amount:.f2}'.format(amount=amount) amount = '{amount:.f2}'.format(amount=amount)
@@ -131,6 +136,10 @@ def update_subscription(rower,data,method='up'):
planid = data['plan'] planid = data['plan']
plan = PaidPlan.objects.get(id=planid) plan = PaidPlan.objects.get(id=planid)
nonce_from_the_client = data['payment_method_nonce'] nonce_from_the_client = data['payment_method_nonce']
nonce = gateway.payment_method_nonce.find(nonce_from_the_client)
info = nonce.three_d_secure_info
if info is None or not info.liability_shifted:
return False,0
amount = data['amount'] amount = data['amount']
amount = '{amount:.2f}'.format(amount=amount) amount = '{amount:.2f}'.format(amount=amount)
@@ -229,6 +238,10 @@ def update_subscription(rower,data,method='up'):
def create_subscription(rower,data): def create_subscription(rower,data):
nonce_from_the_client = data['payment_method_nonce'] nonce_from_the_client = data['payment_method_nonce']
nonce = gateway.payment_method_nonce.find(nonce_from_the_client)
info = nonce.three_d_secure_info
if info is None or not info.liability_shifted:
return False,0
amount = data['amount'] amount = data['amount']
planid = data['plan'] planid = data['plan']

View File

@@ -1,12 +1,27 @@
<script src="https://js.braintreegateway.com/web/dropin/1.14.1/js/dropin.min.js"></script> {% load rowerfilters %}
<script src="https://js.braintreegateway.com/web/dropin/1.19.0/js/dropin.min.js"></script>
<script> <script>
var form = document.querySelector('#payment-form'); var form = document.querySelector('#payment-form');
var hiddenNonceInput = document.querySelector('#nonce');
var paymenterrordiv = document.getElementById("paymenterror");
var client_token = '{{ client_token }}'; var client_token = '{{ client_token }}';
braintree.dropin.create({ braintree.dropin.create({
authorization: client_token, authorization: client_token,
container: '#bt-dropin', container: '#bt-dropin',
paypal: { paypal: {
flow: 'vault' flow: 'vault'
},
threeDSecure: {
amount: '{{ plan.price|amount }}',
email: '{{ rower.user.email }}',
billingAddress: {
givenName: '{{ user.first_name }}',
surname: '{{ user.last_name }}',
streetAddress: '{{ user.rower.street_address }}',
locality: '{{ user.rower.city }}',
postalCode: '{{ user.rower.postal_code }}',
countryCodeAlpha2: '{{ user.rower.country }}'
},
} }
}, function (createErr, instance) { }, function (createErr, instance) {
form.addEventListener('submit', function (event) { form.addEventListener('submit', function (event) {
@@ -16,10 +31,18 @@
console.log('Error', err); console.log('Error', err);
return; return;
} }
// Add the nonce to the form and submit if (payload.liabilityShifted || payload.type !== 'CreditCard') {
document.querySelector('#nonce').value = payload.nonce; document.querySelector('#nonce').value = payload.nonce;
hiddenNonceInput.value = payload.nonce;
form.submit(); form.submit();
} else {
// Decide if you will force the user to enter a different
// payment method if liablity was not shifted
instance.clearSelectedPaymentMethod();
paymenterrordiv.innerHTML = '<p class="message">3D Secure Card Verification Error. Please check your card details.</p>';
}
}); });
}); });
}); });
</script> </script>
@@ -30,5 +53,5 @@
$('#payment-form').submit(function() { $('#payment-form').submit(function() {
$(this).find("button[type='submit']").prop('disabled',true); $(this).find("button[type='submit']").prop('disabled',true);
console.log("disabled"); console.log("disabled");
} });
</script> </script>

View File

@@ -1,8 +1,13 @@
{% extends "newbase.html" %} {% extends "newbase.html" %}
{% block title %}Rowsandall Paid Membership{% endblock title %} {% block title %}Rowsandall Paid Membership{% endblock title %}
{% load rowerfilters %} {% load rowerfilters %}
{% block main %} {% block main %}
<div id="paymenterror">
</div>
<h1>Confirm Your Payment</h1> <h1>Confirm Your Payment</h1>
<h2>Order Overview</h2> <h2>Order Overview</h2>

View File

@@ -3,6 +3,9 @@
{% load rowerfilters %} {% load rowerfilters %}
{% block main %} {% block main %}
<div id="paymenterror">
</div>
<h1>Confirm Your Payment</h1> <h1>Confirm Your Payment</h1>
<h2>Order Overview</h2> <h2>Order Overview</h2>

View File

@@ -484,8 +484,17 @@ def future_date_only(the_date):
def is_future_date(the_date): def is_future_date(the_date):
return the_date >= date.today() return the_date >= date.today()
@register.filter
def amount(value):
vs = '{v}.00'.format(v=int(value))
return vs
@register.filter @register.filter
def date_dif(the_date): def date_dif(the_date):
if the_date == date(1970,1,1):
return 1
if the_date: if the_date:
return the_date - date.today() return the_date - date.today()
else: else:

Binary file not shown.