juspay/hyperswitch · error · Error
Unsupported payment method type: ${payment_method_type}
Error message
Unsupported payment method type: ${payment_method_type} What it means
Thrown by the default branch of an inner switch over payment_method_type in redirectionHandler.js (cypress-tests-v2). The surrounding block is connector-specific (the else-branch at line ~381 waits 10s when the connector is NOT iatapay), so this switch handles a specific connector's payment method types — only types like 'upi_intent' have cases — and any other payment_method_type aborts.
Source
Thrown at cypress-tests-v2/cypress/support/redirectionHandler.js:377
case "upi_collect":
cy.visit(redirection_url.href);
cy.wait(WAIT_TIME_IATAPAY).then(() => {
verifyUrl = true;
});
break;
case "upi_intent":
cy.request(redirection_url.href).then((response) => {
expect(response.status).to.eq(200);
expect(response.body).to.have.property("iataPaymentId");
expect(response.body).to.have.property("status", "INITIATED");
expect(response.body.qrInfoData).to.be.an("object");
expect(response.body.qrInfoData).to.have.property("qr");
expect(response.body.qrInfoData).to.have.property("qrLink");
});
verifyUrl = false;
break;
default:
throw new Error(
`Unsupported payment method type: ${payment_method_type}`
);
}
} else {
// If connectorId is not iatapay, wait for 10 seconds
cy.wait(WAIT_TIME);
}
cy.then(() => {
verifyReturnUrl(redirection_url, expected_url, verifyUrl);
});
}
function verifyReturnUrl(redirection_url, expected_url, forward_flow) {
if (forward_flow) {
// Handling redirection
if (redirection_url.host.endsWith(expected_url.host)) {
// No CORS workaround neededView on GitHub (pinned to 9b8b89dc37)
Solutions
- Log the exact payment_method_type reaching the switch and match it against the case labels (it must equal a supported literal like 'upi_intent')
- Add a case for the new payment method type describing how its redirect/QR response is verified, falling through to verifyReturnUrl appropriately
- If the type needs no special verification, add a case that just sets verifyUrl = false and breaks instead of throwing
- Skip the spec for payment method types this handler intentionally does not support yet
Example fix
// before
default:
throw new Error(
`Unsupported payment method type: ${payment_method_type}`
);
// after
case 'upi_collect':
// deeplink-based flow: nothing to assert on the redirect itself
verifyUrl = false;
break;
default:
throw new Error(
`Unsupported payment method type: ${payment_method_type}`
); Defensive patterns
Strategy: validation
Validate before calling
// Before the connector-specific branch
const PM_TYPES_WITH_REDIRECT_CASE = new Set(['upi_intent' /* keep in sync with the switch */]);
if (
connectorId === 'iatapay' &&
!PM_TYPES_WITH_REDIRECT_CASE.has(payment_method_type)
) {
cy.log(`No redirect case for ${payment_method_type} on iatapay - skipping verification`);
return;
} Try / catch
cy.on('fail', (err) => {
if (err.message.includes('Unsupported payment method type:')) {
/* record the gap and skip instead of failing the run */
}
}); Prevention
- When enabling a new payment method type for a connector, add its redirect case the same commit
- Assert on exact payment_method_type literals — separators like 'upi-intent' vs 'upi_intent' will not match
- Keep the handled-types set exported next to the switch so callers can pre-check
When it happens
Trigger: Running a redirection test for the connector handled by this block (the iatapay-style branch) with a payment_method_type that has no case here — e.g. 'upi_collect', 'netbanking', or a typo like 'upi-intent' — so execution falls to default and throws.
Common situations: Enabling a new payment method for a connector in the test matrix without adding its redirect-handling case; renaming payment method types in the app while the handler keeps old labels; specs passing payment_method_type with different casing or separators than the switch expects.
Related errors
- Unsupported connector: ${connectorId}
- Failed to fetch QR code image: ${response.statusText}
- computeHmac: 'key' and 'message' are required (got key=${!!k
- Expecting valid response but got an error response
- Missing merchantId, adminApiKey, or baseUrl in globalState
AI-assisted analysis of juspay/hyperswitch@9b8b89dc37 (2026-08-16).
Data as JSON: /api/errors/b64a7467d34b8741.
Report an issue: GitHub.