expressCart/views/partials/payments/authorizenet.hbs

58 lines
2.2 KiB
Handlebars
Raw Normal View History

2018-02-05 07:39:42 +10:00
<script type="text/javascript"
2019-11-14 21:13:29 +10:00
{{#ifCond @root.paymentConfig.mode '==' 'test'}}
2018-02-05 07:39:42 +10:00
src="https://jstest.authorize.net/v3/AcceptUI.js"
{{else}}
src="https://js.authorize.net/v3/AcceptUI.js"
2019-11-14 21:13:29 +10:00
{{/ifCond}}
2018-02-05 07:39:42 +10:00
charset="utf-8">
</script>
<script>
function responseHandler(data){
// Set fields from the form
data.shipEmail = $('#shipEmail').val();
data.shipFirstname = $('#shipFirstname').val();
data.shipLastname = $('#shipLastname').val();
data.shipAddr1 = $('#shipAddr1').val();
data.shipAddr2 = $('#shipAddr2').val();
data.shipCountry = $('#shipCountry').val();
data.shipState = $('#shipState').val();
data.shipPostcode = $('#shipPostcode').val();
data.shipPhoneNumber = $('#shipPhoneNumber').val();
$.ajax({
method: 'POST',
url: '/authorizenet/checkout_action',
dataType: 'json',
contentType: 'application/json',
data: JSON.stringify(data)
})
.done(function(data){
if(data.orderId){
window.location = '/payment/' + data.orderId;
}else{
showNotification('Transaction approved', 'success', true);
}
})
.fail(function(data){
if(data.orderId){
window.location = '/payment/' + data.orderId;
}else{
showNotification('Your payment has declined. Please try again.', 'danger');
}
});
}
</script>
2018-02-14 06:21:22 +10:00
<div class="col-sm-12 col s12 text-center">
2018-02-05 07:39:42 +10:00
<form id="paymentForm" method="POST">
<input type="hidden" name="dataValue" id="dataValue" />
<input type="hidden" name="dataDescriptor" id="dataDescriptor" />
<button type="button"
2018-02-14 06:21:22 +10:00
class="AcceptUI btn btn-success waves-effect waves-light blue darken-3"
2018-02-05 07:39:42 +10:00
data-billingAddressOptions='{"show":false, "required":false}'
2019-11-14 21:13:29 +10:00
data-apiLoginID="{{@root.paymentConfig.loginId}}"
data-clientKey="{{@root.paymentConfig.clientKey}}"
2018-02-05 07:39:42 +10:00
data-acceptUIFormBtnTxt="Submit"
data-acceptUIFormHeaderTxt="Card Information"
data-responseHandler="responseHandler">Process payment
</button>
</form>
</div>