@dodopayments/express 0.2.5 → 0.2.6

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.
package/dist/index.cjs CHANGED
@@ -7611,18 +7611,33 @@ function checkoutHandler(config) {
7611
7611
  };
7612
7612
  }
7613
7613
 
7614
+ // Helper to extract a string value from Express query params
7615
+ const getQueryString = (value) => {
7616
+ if (value === undefined)
7617
+ return undefined;
7618
+ if (typeof value === "string")
7619
+ return value;
7620
+ if (Array.isArray(value)) {
7621
+ const first = value[0];
7622
+ return typeof first === "string" ? first : undefined;
7623
+ }
7624
+ return undefined;
7625
+ };
7614
7626
  const CustomerPortal = ({ bearerToken, environment, }) => {
7615
7627
  const getHandler = async (req, res) => {
7616
7628
  // Extract customerId from query parameters
7617
7629
  const { customer_id: customerId, send_email } = req.query;
7618
- const params = {
7619
- send_email: false,
7620
- };
7621
- const sendEmail = Boolean(send_email);
7622
- if (sendEmail) {
7623
- params.send_email = sendEmail;
7624
- }
7625
- if (!customerId) {
7630
+ // Normalize customer_id to string
7631
+ const customerIdValue = getQueryString(customerId);
7632
+ const params = {};
7633
+ if (send_email !== undefined) {
7634
+ // Normalize to string
7635
+ const sendEmailValue = Array.isArray(send_email)
7636
+ ? send_email[0]
7637
+ : send_email;
7638
+ params.send_email = sendEmailValue === "true";
7639
+ }
7640
+ if (!customerIdValue) {
7626
7641
  return res.status(400).send("Missing customerId in query parameters");
7627
7642
  }
7628
7643
  const dodopayments = new DodoPayments({
@@ -7630,7 +7645,7 @@ const CustomerPortal = ({ bearerToken, environment, }) => {
7630
7645
  environment,
7631
7646
  });
7632
7647
  try {
7633
- const session = await dodopayments.customers.customerPortal.create(customerId, params);
7648
+ const session = await dodopayments.customers.customerPortal.create(customerIdValue, params);
7634
7649
  return res.redirect(session.link);
7635
7650
  }
7636
7651
  catch (error) {