Private
Public Access
1
0

starting to work with 3DS now

This commit is contained in:
Sander Roosendaal
2019-07-23 18:52:39 +02:00
parent ac3b2d101c
commit 6ec8bfc03b
2 changed files with 22 additions and 3 deletions

View File

@@ -1,27 +1,39 @@
{% load rowerfilters %}
<script src="https://js.braintreegateway.com/web/dropin/1.19.0/js/dropin.min.js"></script>
<script>
var form = document.querySelector('#payment-form');
var hiddenNonceInput = document.querySelector('#nonce');
var client_token = '{{ client_token }}';
braintree.dropin.create({
authorization: client_token,
container: '#bt-dropin',
paypal: {
flow: 'vault'
},
threeDSecure: {
amount: '{{ plan.price|amount }}'
}
}, function (createErr, instance) {
form.addEventListener('submit', function (event) {
event.preventDefault();
event.preventDefault();
instance.requestPaymentMethod(function (err, payload) {
if (err) {
console.log('Error', err);
return;
}
// Add the nonce to the form and submit
if (payload.liabilityShifted || payload.type !== 'CreditCard') {
document.querySelector('#nonce').value = payload.nonce;
hiddenNonceInput.value = payload.nonce;
form.submit();
} else {
// Decide if you will force the user to enter a different
// payment method if liablity was not shifted
dropinInstance.clearSelectedPaymentMethod();
}
});
});
});
});
</script>
<script type='text/javascript'
src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js'>

View File

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