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
- Confirm the prerequisite createPaymentIntentTest ran and stored clientSecret (dump via cy.task('getGlobalState'))
- Verify publishableKey belongs to the same environment as baseUrl
- Check the client_secret isn't left over from a previous run's expired intent
- Use the logged x-request-id to inspect server logs
- 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
- Never reuse clientSecret across runs — intents expire
- Keep spec order: create intent before listing payment methods
- Match publishableKey to the baseUrl environment
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
- Payment Method Delete Call Failed with error message: ${resp
- Business Profile call failed ${response.body.error.message}
- Business Profile Update Failed: ${response.body.error?.messa
- API Key create call failed with status ${response.status} an
- No credentials found for ${connectorName} in creds.json — sk
AI-assisted analysis of juspay/hyperswitch@9b8b89dc37 (2026-08-16).
Data as JSON: /api/errors/f401de77e2b7d409.
Report an issue: GitHub.