@easypayment/medusa-payment-paypal 1.3.8 → 1.3.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/.medusa/server/src/admin/index.js +261 -94
  2. package/.medusa/server/src/admin/index.mjs +196 -31
  3. package/.medusa/server/src/api/admin/paypal/merchant-status/route.d.ts +11 -0
  4. package/.medusa/server/src/api/admin/paypal/merchant-status/route.d.ts.map +1 -0
  5. package/.medusa/server/src/api/admin/paypal/merchant-status/route.js +32 -0
  6. package/.medusa/server/src/api/admin/paypal/merchant-status/route.js.map +1 -0
  7. package/.medusa/server/src/api/store/paypal/create-order/route.d.ts +4 -1
  8. package/.medusa/server/src/api/store/paypal/create-order/route.d.ts.map +1 -1
  9. package/.medusa/server/src/api/store/paypal/create-order/route.js +113 -108
  10. package/.medusa/server/src/api/store/paypal/create-order/route.js.map +1 -1
  11. package/.medusa/server/src/api/utils/request-logger.d.ts.map +1 -1
  12. package/.medusa/server/src/api/utils/request-logger.js +4 -2
  13. package/.medusa/server/src/api/utils/request-logger.js.map +1 -1
  14. package/.medusa/server/src/modules/paypal/service.d.ts +33 -0
  15. package/.medusa/server/src/modules/paypal/service.d.ts.map +1 -1
  16. package/.medusa/server/src/modules/paypal/service.js +138 -34
  17. package/.medusa/server/src/modules/paypal/service.js.map +1 -1
  18. package/.medusa/server/src/modules/paypal/types/config.d.ts.map +1 -1
  19. package/.medusa/server/src/modules/paypal/types/config.js +2 -1
  20. package/.medusa/server/src/modules/paypal/types/config.js.map +1 -1
  21. package/.medusa/server/src/modules/paypal/utils/merchant-status.d.ts +48 -0
  22. package/.medusa/server/src/modules/paypal/utils/merchant-status.d.ts.map +1 -0
  23. package/.medusa/server/src/modules/paypal/utils/merchant-status.js +106 -0
  24. package/.medusa/server/src/modules/paypal/utils/merchant-status.js.map +1 -0
  25. package/.medusa/server/src/modules/paypal/utils/order-context.d.ts +61 -0
  26. package/.medusa/server/src/modules/paypal/utils/order-context.d.ts.map +1 -0
  27. package/.medusa/server/src/modules/paypal/utils/order-context.js +127 -0
  28. package/.medusa/server/src/modules/paypal/utils/order-context.js.map +1 -0
  29. package/.medusa/server/src/modules/paypal/utils/request-logger.d.ts +12 -0
  30. package/.medusa/server/src/modules/paypal/utils/request-logger.d.ts.map +1 -1
  31. package/.medusa/server/src/modules/paypal/utils/request-logger.js +26 -2
  32. package/.medusa/server/src/modules/paypal/utils/request-logger.js.map +1 -1
  33. package/CHANGELOG.md +102 -0
  34. package/README.md +4 -4
  35. package/package.json +1 -1
  36. package/src/admin/routes/settings/paypal/_components/MerchantStatusNotices.tsx +116 -0
  37. package/src/admin/routes/settings/paypal/additional-settings/page.tsx +54 -12
  38. package/src/admin/routes/settings/paypal/advanced-card-payments/page.tsx +2 -0
  39. package/src/admin/routes/settings/paypal/connection/page.tsx +73 -6
  40. package/src/api/admin/paypal/merchant-status/route.ts +36 -0
  41. package/src/api/store/paypal/create-order/route.ts +191 -165
  42. package/src/api/utils/request-logger.ts +7 -3
  43. package/src/modules/paypal/service.ts +192 -43
  44. package/src/modules/paypal/types/config.ts +3 -2
  45. package/src/modules/paypal/utils/merchant-status.ts +187 -0
  46. package/src/modules/paypal/utils/order-context.ts +163 -0
  47. package/src/modules/paypal/utils/request-logger.ts +30 -2
@@ -17,12 +17,31 @@ import {
17
17
  updatePayPalSessionData,
18
18
  } from "../../../../modules/paypal/utils/payment-session"
19
19
  import { resolveStorefrontUrl } from "../../../../modules/paypal/utils/storefront-url"
20
+ import {
21
+ buildPayPalShipping,
22
+ isShippingAddressRejection,
23
+ resolveLandingPage,
24
+ sameShipping,
25
+ shippingFingerprint,
26
+ type PayPalShipping,
27
+ } from "../../../../modules/paypal/utils/order-context"
20
28
 
21
29
  type Body = {
22
30
  cart_id: string
23
31
  is_card_payment?: boolean
24
32
  }
25
33
 
34
+ /**
35
+ * A merchant-entered name setting, or "" when it is unset. The admin form
36
+ * pre-filled "PayPal" for the brand and card-statement names until 1.3.10, so
37
+ * stores that saved it sent "PayPal" as their own business name; that value
38
+ * is treated as unset (the brand name then falls back to the store's name).
39
+ */
40
+ function merchantName(setting: unknown): string {
41
+ const name = typeof setting === "string" ? setting.trim() : ""
42
+ return name.toLowerCase() === "paypal" ? "" : name
43
+ }
44
+
26
45
  function resolveIdempotencyKey(
27
46
  req: MedusaRequest,
28
47
  suffix: string,
@@ -81,7 +100,10 @@ async function getExistingPayPalOrderId(req: MedusaRequest, cartId: string) {
81
100
  *
82
101
  * Returns `{ id }` — the PayPal order id the storefront hands to the JS SDK.
83
102
  * Line items and an amount breakdown are sent when `sendItemDetails` is on,
84
- * with rounding drift reconciled so PayPal's strict total checks pass.
103
+ * with rounding drift reconciled so PayPal's strict total checks pass. The
104
+ * shipping address the buyer entered at checkout is sent with
105
+ * `shipping_preference: SET_PROVIDED_ADDRESS` unless `sendShippingAddress` is
106
+ * turned off.
85
107
  */
86
108
  export async function POST(req: MedusaRequest, res: MedusaResponse) {
87
109
  const paypal = req.scope.resolve<PayPalModuleService>("paypal_onboarding")
@@ -191,8 +213,56 @@ export async function POST(req: MedusaRequest, res: MedusaResponse) {
191
213
  const totalMajor = Number(cart.total || 0)
192
214
  const value = totalMajor.toFixed(exponent)
193
215
 
216
+ // The buyer enters the shipping address in the storefront before paying, so
217
+ // it is sent with the order (`shipping_preference: SET_PROVIDED_ADDRESS`)
218
+ // and PayPal shows it as fixed instead of offering the addresses on the
219
+ // buyer's PayPal account. Required by PayPal's partner review, and PayPal
220
+ // only applies Seller Protection to the address on the order. On by
221
+ // default; `sendShippingAddress: false` (or
222
+ // PAYPAL_SEND_SHIPPING_ADDRESS=false) turns it off. Deliberately a
223
+ // SEPARATE query: adding relation fields to the totals query above has
224
+ // broken the totals decorator before (see the shipping_methods warning).
225
+ const sendShippingAddress =
226
+ additionalSettings.sendShippingAddress !== false &&
227
+ String(process.env.PAYPAL_SEND_SHIPPING_ADDRESS || "")
228
+ .trim()
229
+ .toLowerCase() !== "false"
230
+ let paypalShipping: PayPalShipping | null = null
231
+ if (sendShippingAddress) {
232
+ try {
233
+ const { data: addrData } = await query.graph({
234
+ entity: "cart",
235
+ fields: [
236
+ "id",
237
+ "shipping_address.first_name",
238
+ "shipping_address.last_name",
239
+ "shipping_address.address_1",
240
+ "shipping_address.address_2",
241
+ "shipping_address.city",
242
+ "shipping_address.province",
243
+ "shipping_address.postal_code",
244
+ "shipping_address.country_code",
245
+ ],
246
+ filters: { id: cartId },
247
+ })
248
+ // Null for a cart without a complete address (e.g. digital goods):
249
+ // PayPal rejects incomplete addresses, so none is sent then.
250
+ paypalShipping = buildPayPalShipping(
251
+ (addrData?.[0] as any)?.shipping_address
252
+ )
253
+ } catch (e: unknown) {
254
+ // The address is an addition to the order, never a checkout blocker.
255
+ logger.warn(
256
+ `[paypal] create-order: could not read the shipping address (request_id=${requestId}): ${
257
+ e instanceof Error ? e.message : String(e)
258
+ }`
259
+ )
260
+ }
261
+ }
262
+
194
263
  // Reuse the stored PayPal order only when it still matches the cart: same
195
- // amount, same currency, and still in a reusable (pre-terminal) state. On
264
+ // amount, same currency, same shipping address, and still in a reusable
265
+ // (pre-terminal) state. On
196
266
  // mismatch fall through and create a fresh order (which replaces the
197
267
  // stored id on the session). If PayPal can't be reached for the check,
198
268
  // reuse the stored id — matching the previous behavior rather than
@@ -226,7 +296,15 @@ export async function POST(req: MedusaRequest, res: MedusaResponse) {
226
296
  String(existingAmount?.value || "") === value &&
227
297
  String(existingAmount?.currency_code || "").toUpperCase() ===
228
298
  currency
229
- if (reusableStatus && amountMatches) {
299
+ // An order created for a previous address would show (and protect)
300
+ // the wrong destination, so it is replaced when the address changed.
301
+ const shippingMatches =
302
+ !paypalShipping ||
303
+ sameShipping(
304
+ existingOrder?.purchase_units?.[0]?.shipping,
305
+ paypalShipping
306
+ )
307
+ if (reusableStatus && amountMatches && shippingMatches) {
230
308
  return res.json({ id: existingOrderId })
231
309
  }
232
310
  if (existingStatus === "COMPLETED") {
@@ -234,7 +312,7 @@ export async function POST(req: MedusaRequest, res: MedusaResponse) {
234
312
  return res.json({ id: existingOrderId })
235
313
  }
236
314
  logger.info(
237
- `[paypal] create-order: stored order ${existingOrderId} is stale (status=${existingStatus}, amount=${existingAmount?.value} ${existingAmount?.currency_code} vs cart ${value} ${currency}) — creating a fresh order (request_id=${requestId})`
315
+ `[paypal] create-order: stored order ${existingOrderId} is stale (status=${existingStatus}, amount=${existingAmount?.value} ${existingAmount?.currency_code} vs cart ${value} ${currency}, shipping_matches=${shippingMatches}) — creating a fresh order (request_id=${requestId})`
238
316
  )
239
317
  } else if (checkResp.status !== 404) {
240
318
  // Transient PayPal-side failure: reuse rather than block checkout.
@@ -253,31 +331,16 @@ export async function POST(req: MedusaRequest, res: MedusaResponse) {
253
331
  : "capture"
254
332
  const paymentAction =
255
333
  paymentActionRaw === "authorize" ? "AUTHORIZE" : "CAPTURE"
256
- const brandName =
257
- typeof additionalSettings.brandName === "string"
258
- ? additionalSettings.brandName
259
- : undefined
260
- const landingPageRaw =
261
- typeof additionalSettings.landingPage === "string"
262
- ? additionalSettings.landingPage
263
- : undefined
264
- const landingPage =
265
- landingPageRaw === "login"
266
- ? "LOGIN"
267
- : landingPageRaw === "billing"
268
- ? "BILLING"
269
- : landingPageRaw === "no_preference"
270
- ? "NO_PREFERENCE"
271
- : undefined
334
+ const brandName = merchantName(additionalSettings.brandName) || undefined
335
+ const landingPage = resolveLandingPage(additionalSettings.landingPage)
272
336
  const requireInstantPayment =
273
337
  typeof additionalSettings.requireInstantPayment === "boolean"
274
338
  ? additionalSettings.requireInstantPayment
275
339
  : undefined
276
340
  const sendItemDetails = additionalSettings.sendItemDetails !== false
277
- const statementName =
278
- typeof additionalSettings.creditCardStatementName === "string"
279
- ? additionalSettings.creditCardStatementName.trim()
280
- : ""
341
+ const statementName = merchantName(
342
+ additionalSettings.creditCardStatementName
343
+ )
281
344
  const invoicePrefix =
282
345
  typeof additionalSettings.invoicePrefix === "string"
283
346
  ? additionalSettings.invoicePrefix
@@ -314,13 +377,13 @@ export async function POST(req: MedusaRequest, res: MedusaResponse) {
314
377
  // PayPal deprecated the order-level application_context: the checkout
315
378
  // experience now rides on payment_source.paypal.experience_context (and
316
379
  // payment_source.card.experience_context for the 3DS redirect URLs).
317
- // landing_page LOGIN and user_action PAY_NOW are the partner-recommended
318
- // defaults; the admin landingPage setting still overrides.
380
+ // landing_page LOGIN and user_action PAY_NOW are what PayPal's partner
381
+ // review asks for; the admin can still pick the guest checkout page.
319
382
  const experienceContext: Record<string, any> = {
320
383
  ...(resolvedBrandName
321
384
  ? { brand_name: resolvedBrandName.slice(0, 127) }
322
385
  : {}),
323
- landing_page: landingPage ?? "LOGIN",
386
+ landing_page: landingPage,
324
387
  user_action: "PAY_NOW",
325
388
  ...(requireInstantPayment
326
389
  ? { payment_method_preference: "IMMEDIATE_PAYMENT_REQUIRED" }
@@ -496,155 +559,118 @@ export async function POST(req: MedusaRequest, res: MedusaResponse) {
496
559
  `[paypal] create-order line items (request_id=${requestId}): send_item_details=${sendItemDetails}, cart_items=${lineItems.length}, sent_items=${finalPurchaseItems.length}, items_total=${itemsTotalMajor}, subtotal=${subtotalMajor}, total=${totalMajor}`
497
560
  )
498
561
 
499
- // Opt-in: attach the cart's shipping address to the PayPal order
500
- // (`SET_PROVIDED_ADDRESS`). Improves PayPal Seller Protection eligibility —
501
- // PayPal only protects shipments to the address on the order. Deliberately
502
- // a SEPARATE query: adding relation fields to the totals query above has
503
- // broken the totals decorator before (see the shipping_methods warning).
504
- const sendShippingAddress =
505
- additionalSettings.sendShippingAddress === true ||
506
- String(process.env.PAYPAL_SEND_SHIPPING_ADDRESS || "")
507
- .trim()
508
- .toLowerCase() === "true"
509
- let paypalShipping: Record<string, any> | null = null
510
- if (sendShippingAddress && !isCardPayment) {
511
- try {
512
- const { data: addrData } = await query.graph({
513
- entity: "cart",
514
- fields: [
515
- "id",
516
- "shipping_address.first_name",
517
- "shipping_address.last_name",
518
- "shipping_address.address_1",
519
- "shipping_address.address_2",
520
- "shipping_address.city",
521
- "shipping_address.province",
522
- "shipping_address.postal_code",
523
- "shipping_address.country_code",
524
- ],
525
- filters: { id: cartId },
526
- })
527
- const addr = (addrData?.[0] as any)?.shipping_address
528
- const line1 = String(addr?.address_1 || "").trim()
529
- const postal = String(addr?.postal_code || "").trim()
530
- const country = String(addr?.country_code || "")
531
- .trim()
532
- .toUpperCase()
533
- // PayPal rejects incomplete addresses — only send a usable one.
534
- if (addr && line1 && postal && country.length === 2) {
535
- const fullName = [addr.first_name, addr.last_name]
536
- .map((part: unknown) => String(part || "").trim())
537
- .filter(Boolean)
538
- .join(" ")
539
- paypalShipping = {
540
- ...(fullName
541
- ? { name: { full_name: fullName.slice(0, 300) } }
542
- : {}),
543
- address: {
544
- address_line_1: line1.slice(0, 300),
545
- ...(addr.address_2
546
- ? { address_line_2: String(addr.address_2).slice(0, 300) }
547
- : {}),
548
- ...(addr.city
549
- ? { admin_area_2: String(addr.city).slice(0, 120) }
550
- : {}),
551
- ...(addr.province
552
- ? { admin_area_1: String(addr.province).slice(0, 300) }
553
- : {}),
554
- postal_code: postal.slice(0, 60),
555
- country_code: country,
556
- },
557
- }
558
- experienceContext.shipping_preference = "SET_PROVIDED_ADDRESS"
559
- }
560
- } catch (e: unknown) {
561
- // Seller protection is an optimization, never a checkout blocker.
562
- logger.warn(
563
- `[paypal] create-order: could not attach shipping address (request_id=${requestId}): ${
564
- e instanceof Error ? e.message : String(e)
565
- }`
566
- )
567
- }
568
- }
569
-
570
562
  // Use the module's cached app access token (single-flight refresh, ~9h TTL)
571
563
  // instead of minting a fresh OAuth token on every create-order call.
572
564
  const base = getPayPalApiBase(creds.environment)
573
565
  const accessToken = await paypal.getAppAccessToken()
574
566
 
575
- // Deterministic-per-(cart, amount, currency) idempotency key for the PayPal
576
- // call. The amount/currency MUST be part of the key: PayPal replays the
577
- // cached response for a reused PayPal-Request-Id, so a key derived from the
578
- // cart id alone would return the ORIGINAL order (at the original total)
579
- // when the buyer changes the cart and a fresh order is minted — silently
580
- // re-charging the stale amount and defeating the staleness check above.
581
- // Kept distinct from `requestId` (the log/response correlation id declared
582
- // at the top of POST) so the two never shadow each other.
583
- const paypalRequestId = resolveIdempotencyKey(
584
- req,
585
- `create-order-${cart.id}-${value}-${currency}`,
586
- `pp-create-${cart.id}-${value}-${currency}`
587
- )
567
+ // Deterministic-per-(cart, amount, currency, address) idempotency key for
568
+ // the PayPal call. The amount/currency MUST be part of the key: PayPal
569
+ // replays the cached response for a reused PayPal-Request-Id, so a key
570
+ // derived from the cart id alone would return the ORIGINAL order (at the
571
+ // original total) when the buyer changes the cart and a fresh order is
572
+ // minted — silently re-charging the stale amount and defeating the
573
+ // staleness check above. The same goes for the shipping address now that
574
+ // it is part of the order. Kept distinct from `requestId` (the
575
+ // log/response correlation id declared at the top of POST) so the two
576
+ // never shadow each other.
577
+ const buildRequestId = (shipping: PayPalShipping | null) => {
578
+ const shippingKey = shipping ? `-${shippingFingerprint(shipping)}` : ""
579
+ return resolveIdempotencyKey(
580
+ req,
581
+ `create-order-${cart.id}-${value}-${currency}${shippingKey}`,
582
+ `pp-create-${cart.id}-${value}-${currency}${shippingKey}`
583
+ )
584
+ }
588
585
 
589
- const ppResp = await paypalFetch(`${base}/v2/checkout/orders`, {
590
- method: "POST",
591
- headers: {
592
- Authorization: `Bearer ${accessToken}`,
593
- "Content-Type": "application/json",
594
- "PayPal-Request-Id": paypalRequestId,
595
- "PayPal-Partner-Attribution-Id": BN_CODE,
596
- },
597
- body: JSON.stringify({
598
- intent: paymentAction,
599
- purchase_units: [
600
- {
601
- reference_id: "default",
602
- // Set custom_id on the purchase unit (not just the order) so PayPal
603
- // propagates the cart id onto capture/refund webhook resources,
604
- // letting webhooks resolve the session directly without a scan.
605
- custom_id: cart.id,
606
- invoice_id: invoiceId,
607
- ...(statementName
608
- ? { soft_descriptor: statementName.slice(0, 22) }
609
- : {}),
610
- amount: {
611
- currency_code: currency,
612
- value,
613
- ...(Object.keys(breakdown).length > 0 ? { breakdown } : {}),
586
+ const sendCreateOrder = (shipping: PayPalShipping | null) =>
587
+ paypalFetch(`${base}/v2/checkout/orders`, {
588
+ method: "POST",
589
+ headers: {
590
+ Authorization: `Bearer ${accessToken}`,
591
+ "Content-Type": "application/json",
592
+ "PayPal-Request-Id": buildRequestId(shipping),
593
+ "PayPal-Partner-Attribution-Id": BN_CODE,
594
+ },
595
+ body: JSON.stringify({
596
+ intent: paymentAction,
597
+ purchase_units: [
598
+ {
599
+ reference_id: "default",
600
+ // custom_id belongs on the purchase unit (the order object has
601
+ // no such field): PayPal copies it onto capture/refund webhook
602
+ // resources, letting webhooks resolve the session directly
603
+ // without a scan.
604
+ custom_id: cart.id,
605
+ invoice_id: invoiceId,
606
+ ...(statementName
607
+ ? { soft_descriptor: statementName.slice(0, 22) }
608
+ : {}),
609
+ amount: {
610
+ currency_code: currency,
611
+ value,
612
+ ...(Object.keys(breakdown).length > 0 ? { breakdown } : {}),
613
+ },
614
+ ...(finalPurchaseItems.length > 0
615
+ ? { items: finalPurchaseItems }
616
+ : {}),
617
+ ...(shipping ? { shipping } : {}),
614
618
  },
615
- ...(finalPurchaseItems.length > 0
616
- ? { items: finalPurchaseItems }
617
- : {}),
618
- ...(paypalShipping ? { shipping: paypalShipping } : {}),
619
- },
620
- ],
621
- payment_source: isCardPayment
622
- ? {
623
- card: {
624
- ...(threeDsMethod
625
- ? {
626
- attributes: {
627
- verification: { method: threeDsMethod },
628
- },
629
- }
630
- : {}),
631
- // Card orders only take the 3DS redirect URLs here; the rest
632
- // of experience_context is a PayPal-wallet concept.
633
- experience_context: {
634
- ...(returnUrl ? { return_url: returnUrl } : {}),
635
- ...(cancelUrl ? { cancel_url: cancelUrl } : {}),
619
+ ],
620
+ payment_source: isCardPayment
621
+ ? {
622
+ card: {
623
+ ...(threeDsMethod
624
+ ? {
625
+ attributes: {
626
+ verification: { method: threeDsMethod },
627
+ },
628
+ }
629
+ : {}),
630
+ // Card orders only take the 3DS redirect URLs here; the rest
631
+ // of experience_context (shipping_preference included) is a
632
+ // PayPal-wallet concept.
633
+ experience_context: {
634
+ ...(returnUrl ? { return_url: returnUrl } : {}),
635
+ ...(cancelUrl ? { cancel_url: cancelUrl } : {}),
636
+ },
637
+ },
638
+ }
639
+ : {
640
+ paypal: {
641
+ experience_context: {
642
+ ...experienceContext,
643
+ ...(shipping
644
+ ? { shipping_preference: "SET_PROVIDED_ADDRESS" }
645
+ : {}),
646
+ },
636
647
  },
637
648
  },
638
- }
639
- : {
640
- paypal: { experience_context: experienceContext },
641
- },
642
- custom_id: cart.id,
643
- }),
644
- })
649
+ }),
650
+ })
645
651
 
646
- const ppText = await ppResp.text()
652
+ let ppResp = await sendCreateOrder(paypalShipping)
653
+ let ppText = await ppResp.text()
647
654
  debugId = ppResp.headers.get("paypal-debug-id")
655
+
656
+ // PayPal validates a provided address and rejects ones it cannot use. An
657
+ // address problem must not cost the sale: create the order without it and
658
+ // let the buyer pick an address in PayPal, as before 1.3.9.
659
+ if (
660
+ !ppResp.ok &&
661
+ paypalShipping &&
662
+ isShippingAddressRejection(ppResp.status, ppText)
663
+ ) {
664
+ logger.warn(
665
+ `[paypal] create-order: PayPal rejected the shipping address (debug_id=${
666
+ debugId ?? "n/a"
667
+ }, request_id=${requestId}) — retrying without it: ${ppText.slice(0, 500)}`
668
+ )
669
+ ppResp = await sendCreateOrder(null)
670
+ ppText = await ppResp.text()
671
+ debugId = ppResp.headers.get("paypal-debug-id")
672
+ }
673
+
648
674
  if (!ppResp.ok) {
649
675
  throw new Error(
650
676
  `PayPal create order error (${ppResp.status}): ${ppText}${
@@ -60,9 +60,13 @@ export function createInboundLogger() {
60
60
  try {
61
61
  logInbound({
62
62
  method: req.method,
63
- path: (req as any).baseUrl
64
- ? `${(req as any).baseUrl}${req.path || ""}`
65
- : (req as any).originalUrl || req.path || req.url || "",
63
+ // Path only: `originalUrl` carries the query string, which the
64
+ // logger appends itself from `query` (it used to appear twice).
65
+ path: String(
66
+ (req as any).baseUrl
67
+ ? `${(req as any).baseUrl}${req.path || ""}`
68
+ : (req as any).originalUrl || req.path || req.url || ""
69
+ ).split("?")[0],
66
70
  query: req.query,
67
71
  requestHeaders: req.headers,
68
72
  requestBody: (req as any).body,