Fix PayPal MULTI_CURRENCY_ORDER error by using consistent GBP
All store items are priced in GBP (filtered by price_gbp > 0). Hardcode GBP currency throughout the checkout and order creation flow to prevent currency mismatches between the PayPal SDK, order items, and purchase unit amounts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
e410bd1b0a
commit
6e74f4e360
|
|
@ -59,8 +59,9 @@ export async function POST(request: NextRequest) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate total with shipping
|
// Calculate total with shipping
|
||||||
|
// All store items are priced in GBP (store filters by price_gbp > 0)
|
||||||
const subtotal = items.reduce((sum, item) => sum + item.price * item.quantity, 0);
|
const subtotal = items.reduce((sum, item) => sum + item.price * item.quantity, 0);
|
||||||
const currency = items[0].currency;
|
const currency = 'GBP';
|
||||||
const shippingCost = getShippingCost(shipping.country, currency);
|
const shippingCost = getShippingCost(shipping.country, currency);
|
||||||
const total = subtotal + shippingCost;
|
const total = subtotal + shippingCost;
|
||||||
|
|
||||||
|
|
@ -94,11 +95,11 @@ export async function POST(request: NextRequest) {
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create PayPal order
|
// Create PayPal order — all items use the same currency
|
||||||
const paypalItems: PayPalItem[] = items.map(item => ({
|
const paypalItems: PayPalItem[] = items.map(item => ({
|
||||||
name: item.artworkName,
|
name: item.artworkName,
|
||||||
unit_amount: {
|
unit_amount: {
|
||||||
currency_code: item.currency,
|
currency_code: currency,
|
||||||
value: item.price.toFixed(2),
|
value: item.price.toFixed(2),
|
||||||
},
|
},
|
||||||
quantity: String(item.quantity),
|
quantity: String(item.quantity),
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,9 @@ export default function CheckoutPage() {
|
||||||
setFormValid(required.every(f => updated[f].trim() !== ''));
|
setFormValid(required.every(f => updated[f].trim() !== ''));
|
||||||
};
|
};
|
||||||
|
|
||||||
const currency = items[0]?.artwork?.currency || 'GBP';
|
// All store items are priced in GBP
|
||||||
const currencySymbol = currency === 'GBP' ? '\u00a3' : '$';
|
const currency = 'GBP';
|
||||||
|
const currencySymbol = '\u00a3';
|
||||||
const shippingCost = getShippingCost(formData.country, currency);
|
const shippingCost = getShippingCost(formData.country, currency);
|
||||||
const total = subtotal + shippingCost;
|
const total = subtotal + shippingCost;
|
||||||
|
|
||||||
|
|
@ -54,7 +55,7 @@ export default function CheckoutPage() {
|
||||||
artworkId: parseInt(item.id),
|
artworkId: parseInt(item.id),
|
||||||
artworkName: item.title,
|
artworkName: item.title,
|
||||||
price: item.price,
|
price: item.price,
|
||||||
currency: item.artwork.currency || 'GBP',
|
currency: 'GBP',
|
||||||
quantity: item.quantity,
|
quantity: item.quantity,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue