data-order-id parameter for checkout JS SDK is not working

GeorgesSG
Contributor
Contributor

Hi,

 

I'm creating the order on the server side with the PHP SDK then I add the order ID created in the JS script as required :

 

<script src="https://www.paypal.com/sdk/js?client-id=MY-CLIENT-ID&currency=EUR&disable-funding=card" data-order-id="MY-ORDER-ID"></script>

 

But it seems that the JS is not taking it into account, as when i click on the payment button the amount is not set correctly (it's 0.01 EUR instead of 40.00 EUR as I've set on the server side at the creation of the order)

Login to Me Too
3 REPLIES 3

johncarter00
Contributor
Contributor

Hey @GeorgesSG - Did you ever fix this issue?

Login to Me Too

kaufhold
New Community Member

I think you are searching for:


createOrder: function(data, actions) {
  return new Promise(function(resolve, reject) {
    resolve("MY-ORDER-ID");
  });
}

Login to Me Too

pilias
New Community Member

Sorry, I'm not sure what to do with the code snippet provided.  I'm simply following the example in the documentation....how would what you've posted as a solution fit into this: 

 

<script>
  paypal.Buttons({
     createOrder: function(data, actions) {
        return actions.order.create({
            purchase_units: [{
                amount: {
                   currency_code: "CAD",[Removed. Phone #s not permitted]p;           }
            }],
            application_context: {
            shipping_preference: 'NO_SHIPPING'
            },
            payment_method: {
               payee_preferred: "IMMEDIATE_PAYMENT_REQUIRED"
            }
        });
    },

  onApprove: function(data, actions) {
          return actions.order.capture().then(function(details) {
                console.log(JSON.stringify(details));
          });
    }

}).render('#paypal-button-container');
</script>

 

 

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.