Added customer's billing and shipping data to paypal checkout fields
This commit is contained in:
@@ -76,7 +76,31 @@ router.post('/create-order', validateCreateOrder, async (req, res) => {
|
||||
currency: currency || 'USD',
|
||||
description: description || `Order #${wc_order_id} from ${wcOrder?.order?.billing?.first_name || 'Test Customer'}`,
|
||||
items: items || [],
|
||||
brand_name: 'Your Store Name' // Customize this
|
||||
brand_name: 'Fashion Store', // Customize this
|
||||
|
||||
// ADD CUSTOMER DETAILS FROM WOOCOMMERCE:
|
||||
payer: wcOrder ? {
|
||||
email: wcOrder.order.billing.email,
|
||||
first_name: wcOrder.order.billing.first_name,
|
||||
last_name: wcOrder.order.billing.last_name,
|
||||
phone: wcOrder.order.billing.phone
|
||||
} : null,
|
||||
|
||||
shipping: wcOrder ? {
|
||||
first_name: wcOrder.order.shipping.first_name,
|
||||
last_name: wcOrder.order.shipping.last_name,
|
||||
address_1: wcOrder.order.shipping.address_1,
|
||||
address_2: wcOrder.order.shipping.address_2,
|
||||
city: wcOrder.order.shipping.city,
|
||||
state: wcOrder.order.shipping.state,
|
||||
postcode: wcOrder.order.shipping.postcode,
|
||||
country: wcOrder.order.shipping.country
|
||||
} : null,
|
||||
|
||||
// Optional: Add breakdown
|
||||
items_total: wcOrder ? wcOrder.order.total : total,
|
||||
shipping_total: wcOrder ? wcOrder.order.shipping_total : '0.00',
|
||||
tax_total: wcOrder ? wcOrder.order.total_tax : '0.00'
|
||||
};
|
||||
|
||||
// Create PayPal order
|
||||
@@ -262,14 +286,31 @@ router.get('/order-status/:wc_order_id', async (req, res) => {
|
||||
total: item.total,
|
||||
image: item.image?.src || null
|
||||
})),
|
||||
shipping: {
|
||||
total: wcOrder.order.shipping_total,
|
||||
method: wcOrder.order.shipping_lines[0]?.method_title
|
||||
},
|
||||
billing: {
|
||||
first_name: wcOrder.order.billing.first_name,
|
||||
last_name: wcOrder.order.billing.last_name,
|
||||
email: wcOrder.order.billing.email
|
||||
company: wcOrder.order.billing.company,
|
||||
address_1: wcOrder.order.billing.address_1,
|
||||
address_2: wcOrder.order.billing.address_2,
|
||||
city: wcOrder.order.billing.city,
|
||||
state: wcOrder.order.billing.state,
|
||||
postcode: wcOrder.order.billing.postcode,
|
||||
country: wcOrder.order.billing.country,
|
||||
email: wcOrder.order.billing.email,
|
||||
phone: wcOrder.order.billing.phone
|
||||
},
|
||||
shipping: {
|
||||
total: wcOrder.order.shipping_total,
|
||||
method: wcOrder.order.shipping_lines[0]?.method_title,
|
||||
first_name: wcOrder.order.shipping.first_name,
|
||||
last_name: wcOrder.order.shipping.last_name,
|
||||
company: wcOrder.order.shipping.company,
|
||||
address_1: wcOrder.order.shipping.address_1,
|
||||
address_2: wcOrder.order.shipping.address_2,
|
||||
city: wcOrder.order.shipping.city,
|
||||
state: wcOrder.order.shipping.state,
|
||||
postcode: wcOrder.order.shipping.postcode,
|
||||
country: wcOrder.order.shipping.country
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user