juspay/hyperswitch · error · Error

Payment Method Delete Call Failed with error message: ${resp

Error message

Payment Method Delete Call Failed with error message: ${response.body.error.message}

What it means

Thrown by the deletePaymentMethodTest command (cypress-tests/cypress/support/commands.js:3102) when DELETE of a customer payment method returns non-200 outside the two accepted paths: 200 (deleted), or the localhost-only 500 whose error.code starts with HE_00 — deleting requires the tartarus (Hyperswitch card vault) locker service, and without it the call fails in a known way that the command tolerates on localhost. Any other status throws with the server message.

Source

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

    headers: {
      Accept: "application/json",
      "api-key": apiKey,
    },
    failOnStatusCode: false,
  }).then((response) => {
    logRequestId(response.headers["x-request-id"]);

    cy.wrap(response).then(() => {
      expect(response.headers["content-type"]).to.include("application/json");
      if (response.status === 200) {
        expect(response.body.payment_method_id).to.equal(paymentMethodId);
        expect(response.body.deleted).to.be.true;
      } else if (response.status === 500 && baseUrl.includes("localhost")) {
        // delete payment method api endpoint requires tartarus (hyperswitch card vault) to be set up since it makes a call to the locker service to delete the payment method
        expect(response.body.error.code).to.include("HE_00");
        expect(response.body.error.message).to.include("Something went wrong");
      } else {
        throw new Error(
          `Payment Method Delete Call Failed with error message: ${response.body.error.message}`
        );
      }
    });
  });
});

Cypress.Commands.add("setDefaultPaymentMethodTest", (globalState) => {
  const payment_method_id = globalState.get("paymentMethodId");
  const customer_id = globalState.get("customerId");

  cy.request({
    method: "POST",
    url: `${globalState.get("baseUrl")}/customers/${customer_id}/payment_methods/${payment_method_id}/default`,
    headers: {
      "api-key": globalState.get("apiKey"),
    },
    failOnStatusCode: false,

View on GitHub (pinned to 9b8b89dc37)

Solutions

  1. Identify the environment: if local without tartarus, make baseUrl literally include 'localhost' so the HE_00 branch applies ('127.0.0.1' will not match)
  2. Verify paymentMethodId/customerId in globalState are fresh from this run's create step
  3. If already deleted, remove the duplicate delete step
  4. On non-local environments, check vault/locker service health when a 5xx appears
  5. Correlate via the logged x-request-id

Example fix

// before — local env addressed by IP: the HE_00 exemption never triggers
Cypress.env('baseUrl', 'http://127.0.0.1:9090');
cy.deletePaymentMethodTest(globalState);
// after — use the hostname the command's check matches
cy.deletePaymentMethodTest(globalState); // with baseUrl 'http://localhost:9090', the 500 HE_00 path is accepted
Defensive patterns

Strategy: validation

Validate before calling

const pmId = globalState.get('paymentMethodId');
if (!pmId) throw new Error('paymentMethodId missing — run the create-payment-method step first');
const isLocal = globalState.get('baseUrl').includes('localhost');
if (isLocal) cy.task('cli_log', 'local run: without tartarus the 500 HE_00 path is expected');

Prevention

When it happens

Trigger: paymentMethodId or customerId stale/missing in globalState so the DELETE targets a missing resource (404); the payment method already deleted by an earlier step; on a local environment, baseUrl not literally containing 'localhost' (e.g. 127.0.0.1 or a docker hostname) so the HE_00 exemption never applies; vault/locker service down in staging (non-HE_00 500); invalid api-key (401).

Common situations: Re-running delete steps against state whose payment method was already removed; local dev without tartarus but reaching the app via an IP or container name; vault outage in a shared environment.

Related errors


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