Skip to content

Commit

Permalink
fix govpay metadata flow parsing for invite-to-pay cases
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamcinchak committed Dec 13, 2023
1 parent f5f90a8 commit 9ff3765
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions api.planx.uk/modules/pay/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,12 @@ export async function buildPaymentPayload(
return_url: req.query.returnURL as string,
metadata: {
source: "PlanX",
// Payment requests have /pay path suffix, so get flow-slug from second-to-last position
flow:
new URL(req.query.returnURL as string).pathname.split("/")[0] ||
(req.query.returnURL as string),
(req.query.returnURL as string)
.split("?")?.[0]
?.split("/")
?.slice(-2, -1)?.[0] || "Could not parse service name",
inviteToPay: true,
},
};
Expand Down

0 comments on commit 9ff3765

Please sign in to comment.