{"record":{"id":"0aa2e10bb8b6fdb1","repo":"juspay/hyperswitch","slug":"eligibility-check-failed-with-status-response-s","errorCode":null,"errorMessage":"Eligibility check failed with status: ${response.status} and message: ${response.body?.error?.message}","messagePattern":"Eligibility check failed with status: (.+?) and message: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cypress-tests/cypress/support/commands.js","lineNumber":7835,"sourceCode":"            expect(response.body.sdk_next_action).to.have.property(\n              \"next_action\"\n            );\n            expect(response.body.sdk_next_action.next_action).to.have.property(\n              \"deny\"\n            );\n            expect(response.body.sdk_next_action.next_action.deny)\n              .to.have.property(\"message\")\n              .to.equal(resData.body.sdk_next_action.next_action.deny.message);\n          } else {\n            // For non-blocklisted cards, we expect no deny action\n            if (response.body.sdk_next_action?.next_action?.deny) {\n              throw new Error(\n                \"Expected no deny action for non-blocklisted card\"\n              );\n            }\n          }\n        } else {\n          throw new Error(\n            `Eligibility check failed with status: ${response.status} and message: ${response.body?.error?.message}`\n          );\n        }\n      });\n    });\n  }\n);\n\n// DDC Race Condition Test Commands\nCypress.Commands.add(\n  \"ddcServerSideRaceConditionTest\",\n  (confirmData, globalState) => {\n    const ddcConfig = confirmData.DDCConfig;\n    const paymentId = globalState.get(\"paymentID\");\n    const merchantId = globalState.get(\"merchantId\");\n    const completeUrl = `${Cypress.env(\"BASEURL\")}/payments/${paymentId}/${merchantId}${ddcConfig.completeUrlPath}`;\n\n    cy.request({","sourceCodeStart":7817,"sourceCodeEnd":7853,"githubUrl":"https://github.com/juspay/hyperswitch/blob/9b8b89dc378b62c9a6feda647bad4719d2de7699/cypress-tests/cypress/support/commands.js#L7817-L7853","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\ncy.paymentsEligibilityCheck(body, data, globalState); // no payment created yet\n// after\ncy.createPaymentIntentTest(createBody, createData, globalState);\ncy.paymentsEligibilityCheck(body, data, globalState);","handlingStrategy":"validation","validationCode":"// precondition: fresh payment with valid secret/key\nconst paymentId = globalState.get('paymentID');\nconst clientSecret = globalState.get('clientSecret');\nif (!paymentId || !clientSecret) {\n  throw new Error('Create the payment before running eligibility');\n}\nexpect(globalState.get('publishableKey'), 'publishableKey').to.not.be.empty;","typeGuard":null,"tryCatchPattern":"cy.wrap(null)\n  .then(() => cy.paymentsEligibilityCheck(body, data, globalState))\n  .catch((e) => {\n    if (/Eligibility check failed with status: 40[0-9]/.test(e.message)) {\n      // stale payment/secret — recreate and retry once\n      cy.createPaymentIntentTest(createBody, createData, globalState);\n      return cy.paymentsEligibilityCheck(body, data, globalState);\n    }\n    throw e;\n  });","preventionTips":["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"],"tags":["cypress","eligibility","client-secret","publishable-key","precondition"],"backgroundTag":null,"analyzedSha":"9b8b89dc378b62c9a6feda647bad4719d2de7699","analyzedAt":"2026-08-16T09:01:53.433Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}