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

  1. Ensure a create-payment step ran successfully and set paymentID and clientSecret in globalState before eligibility
  2. Confirm the publishableKey in globalState belongs to the same profile/environment as the payment
  3. Check the logged x-request-id against server logs for the precise rejection
  4. 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

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


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