refactor(checkout): move VAT rates, pricing and the PayPal order into pure modules
src/checkout/ holds code without the PayPal SDK or Strapi at runtime, so it can be unit tested without node_modules: - vat.ts: vatIncludedDecimal and vatDecimal. config/constants.ts re-exports them under the same names and keeps vatDecimalExcluded. - pricing.ts: calculateTotalProductPrice, unchanged. The product service re-exports it, so every importer keeps working. - paypal-order.ts: the order request createSessionOrThrow builds, in two halves. buildPayPalOrderItems (the total guard and the unsent items) still runs before the try block, and buildPayPalOrderRequest inside it. Errors and log lines stay as they were, for every input. The SDK enums are replaced by their string values (CAPTURE, SET_PROVIDED_ADDRESS). No behaviour change. Refs libretech/mp#71
This commit is contained in:
+2
-4
@@ -1,4 +1,5 @@
|
||||
import { Environment } from "@paypal/paypal-server-sdk";
|
||||
import { vatDecimal } from "../src/checkout/vat";
|
||||
|
||||
export const pdfApiUrl = process.env.PDF_API_ADDRESS!;
|
||||
export const mailApiUrl = process.env.MAIL_API_ADDRESS!;
|
||||
@@ -18,10 +19,7 @@ export const shopEmail = process.env.SHOP_EMAIL ?? process.env.ADMIN_EMAIL_ADDRE
|
||||
export const shopLogoUrl = process.env.SHOP_LOGO_URL ?? "";
|
||||
export const shopSecondaryLogoUrl = process.env.SHOP_SECONDARY_LOGO_URL ?? "";
|
||||
|
||||
// TODO: Should be retrieved from DepotApi
|
||||
export const vatIncludedDecimal = 1.19;
|
||||
// TODO: Should be retrieved from DepotApi
|
||||
export const vatDecimal = 0.19;
|
||||
export { vatIncludedDecimal, vatDecimal } from "../src/checkout/vat";
|
||||
export const vatDecimalExcluded = 1 - vatDecimal;
|
||||
|
||||
export const maxProductsSitemap = 500;
|
||||
|
||||
Reference in New Issue
Block a user