juspay/hyperswitch · error · Error
Eligibility check failed with status: ${response.status} and
Error message
Eligibility check failed with status: ${response.status} and message: ${response.body?.error?.message} What it means
Thrown by paymentsEligibilityCheck when POST /payments/{paymentId}/eligibility responds non-200. The call authenticates with the publishable key and sends client_secret from globalState; bad credentials, a stale secret, or a wrong/absent paymentId are the usual causes.
Source
Thrown at cypress-tests/cypress/support/commands.js:7835
expect(response.body.sdk_next_action).to.have.property(
"next_action"
);
expect(response.body.sdk_next_action.next_action).to.have.property(
"deny"
);
expect(response.body.sdk_next_action.next_action.deny)
.to.have.property("message")
.to.equal(resData.body.sdk_next_action.next_action.deny.message);
} else {
// For non-blocklisted cards, we expect no deny action
if (response.body.sdk_next_action?.next_action?.deny) {
throw new Error(
"Expected no deny action for non-blocklisted card"
);
}
}
} else {
throw new Error(
`Eligibility check failed with status: ${response.status} and message: ${response.body?.error?.message}`
);
}
});
});
}
);
// DDC Race Condition Test Commands
Cypress.Commands.add(
"ddcServerSideRaceConditionTest",
(confirmData, globalState) => {
const ddcConfig = confirmData.DDCConfig;
const paymentId = globalState.get("paymentID");
const merchantId = globalState.get("merchantId");
const completeUrl = `${Cypress.env("BASEURL")}/payments/${paymentId}/${merchantId}${ddcConfig.completeUrlPath}`;
cy.request({View on GitHub (pinned to 9b8b89dc37)
Solutions
- Ensure a create-payment step ran successfully and set paymentID and clientSecret in globalState before eligibility
- Confirm the publishableKey in globalState belongs to the same profile/environment as the payment
- Check the logged x-request-id against server logs for the precise rejection
- If the payment already advanced state, re-create the payment to get a fresh client_secret
Example fix
// before cy.paymentsEligibilityCheck(body, data, globalState); // no payment created yet // after cy.createPaymentIntentTest(createBody, createData, globalState); cy.paymentsEligibilityCheck(body, data, globalState);
Defensive patterns
Strategy: validation
Validate before calling
// precondition: fresh payment with valid secret/key
const paymentId = globalState.get('paymentID');
const clientSecret = globalState.get('clientSecret');
if (!paymentId || !clientSecret) {
throw new Error('Create the payment before running eligibility');
}
expect(globalState.get('publishableKey'), 'publishableKey').to.not.be.empty; Try / catch
cy.wrap(null)
.then(() => cy.paymentsEligibilityCheck(body, data, globalState))
.catch((e) => {
if (/Eligibility check failed with status: 40[0-9]/.test(e.message)) {
// stale payment/secret — recreate and retry once
cy.createPaymentIntentTest(createBody, createData, globalState);
return cy.paymentsEligibilityCheck(body, data, globalState);
}
throw e;
}); Prevention
- Always run eligibility immediately after create, before confirm consumes or rotates the client_secret
- Use the publishable key (not the secret key) for the eligibility endpoint
- Assert paymentID and clientSecret are set in globalState before invoking the command
When it happens
Trigger: paymentID or clientSecret missing from globalState (eligibility run before payment create, or URL becomes /payments/undefined/eligibility → 404); client_secret invalid because the payment was already confirmed/rotated; publishable key wrong for the profile (401/403).
Common situations: Spec ordering changes so eligibility runs before create; clientSecret captured at create time but consumed/expired by confirm steps; using the secret vs publishable key mixup; cross-environment key and baseUrl mismatch.
Related errors
- List payment methods failed with status code "${response.sta
- No user info token available
- Expected no deny action for non-blocklisted card
- Refund Manual Update Call Failed with error code "${response
- Unsupported connector: ${connectorId}
AI-assisted analysis of juspay/hyperswitch@9b8b89dc37 (2026-08-16).
Data as JSON: /api/errors/0aa2e10bb8b6fdb1.
Report an issue: GitHub.