Luehang / react-paypal-button-v2

An easy and simple to use React button component to implement PayPal Checkout with Smart Payment Buttons V2 (Version 2).
https://luehangs.site/lue_hang/projects/react-paypal-button-v2
MIT License
274 stars 81 forks source link

How to create an order with multiple items? [QUESTION] #113

Open mpbunch opened 2 years ago

mpbunch commented 2 years ago

To Do First

Ask your Question I have a form where users can select some quantity or product. For example: 1 sock or 10 socks.

Sure I can sock.quantity * sock.price = payapl.amount But within paypal it then shows quantity 1 at a rate of total. The merchant doesn't know if this is 1 expensive sock, or 10 cheap socks.

Tags Quantity, Multiple Products, Multiple Items

mpbunch commented 2 years ago

Hope this helps someone else.

        createOrder={(data, actions) => {
            return actions.order.create({
                purchase_units: [
                    {
                        reference_id: "some_id",
                        description: `Some description ${this.state.something}`,
                        custom_id: "some_value_will_show_up_in_the_pay_pal_interface",
                        soft_descriptor: "product description",
                        amount: {
                            currency_code: "USD",
                            value: "20.00",
                            breakdown: {
                                item_total: {
                                    currency_code: "USD",
                                    value: "20.00"
                                }
                            }
                        },
                        items: [
                            {
                                name: "ITEM 1",
                                description: `ITEM 1 DESC: ${this.state.description}`,
                                sku: {this.state.item.skew},
                                unit_amount: {
                                    currency_code: "USD",
                                    value: "20.00"
                                },
                                quantity: this.state.quantity
                            },
                        ]
                    }
                ],
                application_context: {
                    shipping_preference: 'NO_SHIPPING'
                }
            })
        }}
jayenashar commented 1 year ago

is there not a way to tell paypal it's 10 pairs of socks and paypal already knows the unit price of each pair?