Expected an order id to be passed

AlexKom
New Community Member

Implementing PayPal smart buttons on the site. On localhost (with sanbox accounts), everything is well paid. Then I created a live app, transferred it to production, and when I clicked on the button, I get an error Error: Expected an order id to be passed

Paypal account for an individual. It turns out that I cannot use the smart buttons of an individual's account?

Login to Me Too
1 REPLY 1

JackieDaytona
Contributor
Contributor

Try this: Obviously remove the jquery stuff in there for me

 

// Set up the transaction
createOrder: function(data, actions) {
$('#paypalmsg').hide();
$('#transmsg').show();
$('#transmsg').html('<b>'+'WAITING ON AUTHORIZATION...'+'</b>');
$('#chkoutmsg').hide()
return actions.order.create({
purchase_units: [{
description: 'GnG Order',   ****MUST BE HERE***
amount: {
value: cartTotal     ****ALSO MUST HAVE A VALUE***
}
}],
application_context: {
shipping_preference: 'NO_SHIPPING'    ****ALTER FOR YOUR NEEDS***
}

});
},

// Finalize the transaction
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
/*return actions.order.get().then(function(orderDetails) { */
// Show a success message to the buyer
$('#transmsg').html('<b>' + 'AUTHORIZED...' + '</b>');
$('#transmsg').append('<br>'+'Transaction completed by: ' + details.payer.name.given_name +' '+ details.payer.name.surname + '<br>' + "Order Id: " + details.id + '<br>' + 'Status: PAID & APPROVED' + '<br>'+ 'Thank You For Your Order'+ '<br>');
if (details.status === "COMPLETED") {
window.setTimeout(function() {}, 500)
$('#transmsg').append('<b>' + 'Sending Order...Please Wait' + '</b>'+'<br>');
/* var getId = '#'+ $('span:contains("Market")').attr('id');
var getmrktDiv = '#'+ $(getId).offsetParent().attr('id');
var mrktchkId = '#'+ $(getmrktDiv).closest(getmrktDiv).find(".chkbox").attr('id');
var mrktpriceId = '#'+ $(getmrktDiv).closest(getmrktDiv).find(".price").attr('id');
var chkboxId = "#chk6";
var hidpriceId = "#pricef";
var marketLocation = $(mrktchkId);

if (marketLocation.length > 0 ) {
var checked = $(mrktchkId).prop('checked');
if (!checked) {
var storedVal = $(mrktpriceId).val();
if ($(mrktpriceId+':not([data-val])')) {
$(mrktpriceId).attr("data-val", storedVal);
}
$(mrktpriceId).val("");
}
} */

$('#transid').val(details.id);
$('#orderstat').val('APPROVED');
$('#orderform').submit();
}
});

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.