Quantcast
Channel: Active questions tagged paypal - Stack Overflow
Viewing all articles
Browse latest Browse all 511

PayPal documentation always tell to use Node.js, but there is a client-only script that works even better

$
0
0

For PayPal integration all their documentation tells you to call server-side script running on Node.js, and here the client-side call to the CreateOrder function in the server:

        async createOrder() {                const response = await fetch("/api/orders", {                    method: "POST",                    headers: {"Content-Type": "application/json",                    },                    body: JSON.stringify({                        cart: [                            {                                id: "NQ888P",                                quantity: "3",                            },                        ],                    }),                });

But there is not a single document on this much better alternative: The code below, 100% running from client, does not call any server-side script at all. It goes straight to PayPal's site and does the same or even better job than the mechanism above:

    createOrder: function (data, actions) {        return actions.order.create({            intent: 'CAPTURE',            purchase_units: [{                amount: {                    value: "14.99",                    currency_code: "USD"                }            }]        })    },

This code can only be found in stackoverflow and other forums. So does anyone know why PayPal suppresses the client-only mechanism from all the documents?


Viewing all articles
Browse latest Browse all 511

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>