Does a second call to Paypal button JS SDK createOrder method result in two orders?

264 Views Asked by At

If you create an order id, and then create a button adding the order is like this:

paypal.buttons({
    createOrder: function(data, actions) {
        return orderId;
    },
    .
    .
}).render('#my-paypal-container');

Then create a second order id, passing an object with a different createOrder method that returns a different order ID. Will the customer be charged for two orders or just the second one?

If the customer is charged for both orders, how do I clean up the first button/order before initiating the second one?

1

There are 1 best solutions below

4
On

The createOrder function is called when a button is clicked. No one is charged unless (1) they finish approving the order, and (2) the order is captured.

That first step is done by the user by entering all their information and confirming their approval. The last step is then done from the onApprove function.