Deva Subbu

Deva Subbu

  • NA
  • 40
  • 29.4k

Bluesnap api implementation

Jun 8 2016 10:24 AM
Hi all,
 
I am always getting authentication required window.when i call bluesnap sandbox url.I have googled and read some article which says because of CORS the Authentication required message box is appearing. i tried adding the basic authentication in the header itself but no luck .my code is below. any help will be appreciated
 
my code below
 
<script> $(document).ready(function() {          $('#paymentsubmit').click(function (e) {               xmlstring = "<?xml version='1.0'?>"+ "<card-transaction xmlns='http://ws.plimus.com'>" + "<card-transaction-type>AUTH_ONLY</card-transaction-type>" + "<recurring-transaction>ECOMMERCE</recurring-transaction>" + "<soft-descriptor>DescTest</soft-descriptor>" + "<amount>11.00</amount>" + "<currency>USD</currency>" + "<card-holder-info>" + "<first-name>test first name</first-name>" + "<last-name>test last name</last-name>" + "</card-holder-info>" + "<credit-card>" + "<card-number>4263982640269299</card-number>"+ "<security-code>837</security-code>"+ "<expiration-month>02</expiration-month>"+ "<expiration-year>2018</expiration-year>"+ "</credit-card>"+ "</card-transaction>";                $.ajax({                 data: xmlstring, Authorization: "Basic " + btoa("API_14655582321891175640599" + ":" + "Aut0mat!c"),                 dataType: 'jsonp',                 xhrFields: {                     withCredentials: true },                 contentType: 'application/xml',                 bluesnapversion:'2.0',                 type: 'POST', // beforeSend: function (xhr) { xhr.setRequestHeader('Authorization', 'Basic ' + btoa('API_14655582321891175640599' + ':' + 'Aut0mat!c')); },                 url: 'https://sandbox.bluesnap.com/services/2/transactions' }).done(function (data) {                 alert('Registered Successfully'); }).error(function (jqXHR, textStatus, errorThrown) {                 alert(jqXHR.responseText || textStatus); }) });     }) </script>
 
 
Thanks
Dev