juspay/hyperswitch · error · Error

List payment methods failed with status code "${response.sta

Error message

List payment methods failed with status code "${response.status}" and error message "${response.body.error.message}"

What it means

Thrown by the paymentMethodListTestWithRequiredFields command (cypress-tests/cypress/support/commands.js:2614) when GET {baseUrl}/account/payment_methods?client_secret={clientSecret} returns non-200. The request authenticates with the publishableKey and the clientSecret stored in globalState by an earlier create-payment-intent step, so failures are almost always stale or missing state rather than a problem with the endpoint itself.

Source

Thrown at cypress-tests/cypress/support/commands.js:2614

          Object.keys(expectedRequiredFields).forEach((key) => {
            const expectedField = expectedRequiredFields[key];
            const responseField = responseRequiredFields[key];

            expect(responseField).to.exist;
            expect(responseField.required_field).to.equal(
              expectedField.required_field
            );
            expect(responseField.display_name).to.equal(
              expectedField.display_name
            );
            expect(responseField.field_type).to.deep.equal(
              expectedField.field_type
            );
            expect(responseField.value).to.equal(expectedField.value);
          });
        } else {
          throw new Error(
            `List payment methods failed with status code "${response.status}" and error message "${response.body.error.message}"`
          );
        }
      });
    });
  }
);

Cypress.Commands.add(
  "paymentMethodListTestTwoConnectorsForOnePaymentMethodCredit",
  (resData, globalState) => {
    cy.request({
      method: "GET",
      url: `${globalState.get("baseUrl")}/account/payment_methods?client_secret=${globalState.get("clientSecret")}`,
      headers: {
        "Content-Type": "application/json",
        Accept: "application/json",
        "api-key": globalState.get("publishableKey"),

View on GitHub (pinned to 9b8b89dc37)

Solutions

  1. Confirm the prerequisite createPaymentIntentTest ran and stored clientSecret (dump via cy.task('getGlobalState'))
  2. Verify publishableKey belongs to the same environment as baseUrl
  3. Check the client_secret isn't left over from a previous run's expired intent
  4. Use the logged x-request-id to inspect server logs
  5. Re-run the full flow fresh: intent creation then list
Defensive patterns

Strategy: validation

Validate before calling

const clientSecret = globalState.get('clientSecret');
if (!clientSecret) {
  throw new Error('clientSecret missing in globalState — run createPaymentIntentTest before listing payment methods');
}

Prevention

When it happens

Trigger: clientSecret undefined because createPaymentIntentTest was not run or failed (400/401); publishableKey rotated so the api-key header is rejected; the intent behind the client_secret already consumed or expired; 5xx from the payments service.

Common situations: Reordered specs putting the payment-method list before intent creation; globalState reused across runs so the old clientSecret is dead; env mismatch between publishable key and baseUrl.

Related errors


AI-assisted analysis of juspay/hyperswitch@9b8b89dc37 (2026-08-16). Data as JSON: /api/errors/f401de77e2b7d409. Report an issue: GitHub.