fix(webhook): get currency from channel.currency_code instead of top-level
Some checks failed
Build and Deploy / build (push) Has been cancelled
Some checks failed
Build and Deploy / build (push) Has been cancelled
Saleor webhook payload stores currency in channel.currency_code, not as a top-level currency field. Updated interfaces and conversion function to use the correct location.
This commit is contained in:
@@ -48,7 +48,10 @@ interface SaleorOrderPayload {
|
||||
lines: SaleorLineItemPayload[];
|
||||
total_gross_amount: string;
|
||||
shipping_price_gross_amount?: string;
|
||||
currency: string;
|
||||
channel: {
|
||||
currency_code: string;
|
||||
};
|
||||
currency?: string; // Fallback for line items
|
||||
language_code?: string;
|
||||
metadata?: Record<string, string>;
|
||||
}
|
||||
@@ -160,20 +163,20 @@ function convertPayloadToOrder(payload: SaleorOrderPayload): SaleorOrder {
|
||||
totalPrice: {
|
||||
gross: {
|
||||
amount: parseInt(line.total_price_gross_amount),
|
||||
currency: line.currency,
|
||||
currency: line.currency || payload.channel.currency_code,
|
||||
},
|
||||
},
|
||||
})),
|
||||
total: {
|
||||
gross: {
|
||||
amount: parseInt(payload.total_gross_amount),
|
||||
currency: payload.currency,
|
||||
currency: payload.channel.currency_code,
|
||||
},
|
||||
},
|
||||
shippingPrice: payload.shipping_price_gross_amount ? {
|
||||
gross: {
|
||||
amount: parseInt(payload.shipping_price_gross_amount),
|
||||
currency: payload.currency,
|
||||
currency: payload.channel.currency_code,
|
||||
},
|
||||
} : undefined,
|
||||
languageCode: payload.language_code?.toUpperCase(),
|
||||
|
||||
Reference in New Issue
Block a user