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