I have a website for a client and they requested debit/credit payments on their site, I've set up the smart payment settings and it seems to work ok on the site, however, I just added a function to retrieve a variable (price) from the URL the smart buttons are throwing an error code and im assuming its because of the javascript portion to get the amount variable from the URL However the payments are processing as they should regardless of the error code.
Below is the sample of my code
function getQueryVariable(variable)
{
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){return pair[1];}
}
return(false);
}
var sel = getQueryVariable("price");
paypal.Buttons({
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: sel
}
}]
});
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
alert('Transaction completed by ' + details.payer.name.given_name);
});
}
}).render('#paypal-button-container');