diff --git a/src/components/mainPage/paypal.jsx b/src/components/mainPage/paypal.jsx index 8975b4b..5035626 100644 --- a/src/components/mainPage/paypal.jsx +++ b/src/components/mainPage/paypal.jsx @@ -16,16 +16,17 @@ const PayPal = ({cart}) => { const createOrder = (data, actions) => { - // No idea why "cart" is still empty array... data is showing in the state (React Dev Tools) - console.log(cart); return actions.order.create({ - purchase_units: [{ - description: "Fatek B1-14MR2 PLC", - amount: { - currency_code: "USD", - value: 89.99, - } - }] + purchase_units: cart.map(item => { + return { + reference_id: item.ID, + description: item.productName, + amount: { + currency_code: "USD", + value: item.price, // using price rather than discounted price for now, (item ID 2 has discounted price: "0.00") + } + }; + }) }); } @@ -45,13 +46,13 @@ const PayPal = ({cart}) => { fundingSource={FUNDING.PAYPAL} style={{ height: 25 }} forceReRender={[cart]} + disabled={cart.length === 0} createOrder={createOrder} onApprove={onApprove} /> - {/* This is a nice touch */} {showInvoice && } );