Search code examples
javascriptpaypalcheckoutbraintree

PayPal Checkout Braintree Line Items


I'm trying to use Braintree with the PayPal Checkout SDK (sandbox environment) however everytime I try and add in line items, I get a 'create_order_error' 'PayPal error undefined: could not initialise paypal flow'. This is only when I add in the lineItems option:

...
 return paypalCheckoutInstance.createPayment({
                        flow: 'checkout',
                        amount: '100',
                        currency: 'USD',

                        intent: 'capture',

                        displayName: 'Display Test',
                        landingPageType: 'login',
                        lineItems: [
                            {
                                quantity: '1',
                                unitAmount: '50.00',
                                name: 'Test Name',
                                kind: 'debit'
                            },
                            {
                                quanity: '1',
                                unitAmount: '50.00',
                                name: 'Test Name 2',
                                kind: 'debit'
                            }
                        ],

                        enableShippingAddress: true,
...

If I remove the lineItems property or set

...
lineItems: []
...

I get no error, so presumably its the way I'm formatting the items.

Can anyone assist?

Thank you!


Solution

  • Misspelt 'quantity' in line item 2 as pointed out by @Reynadan in comments. Silly mistake, don't know how I didn't spot it! Many thanks to all.