-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(cypress): verify payment status after payment redirection #6187
refactor(cypress): verify payment status after payment redirection #6187
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
other than that, looks good to me!
@pixincreate I have made all the suggested changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
other than that, looks good to me!
Co-authored-by: Pa1NarK <[email protected]>
bd3174d
if ( | ||
payment_status !== "succeeded" && | ||
payment_status !== "processing" && | ||
payment_status !== "partially_captured" && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to include failed status and have to remove partially_captured state as we shouldn't get this status in authorize call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed this.
we'll now check only for terminal statuses. if we get anything other than that, then we throw the error. and take a screenshot.
![image](https://private-user-images.githubusercontent.com/69745008/400417367-a90f0440-1b16-4914-843e-397be1492604.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDAwMDA5OTcsIm5iZiI6MTc0MDAwMDY5NywicGF0aCI6Ii82OTc0NTAwOC80MDA0MTczNjctYTkwZjA0NDAtMWIxNi00OTE0LTg0M2UtMzk3YmUxNDkyNjA0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE5VDIxMzEzN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTYyYmIzMWQ5NTQwNDU1OGJkYTIxMGU3NDY2ODRjMDgyNTMzNTQ0Njk5ZjM0YTczMjMyMGEzNmE2YmZmZjI5ZTgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.GykedyF20LgILcH5-GC-H66onoorXv-71cjr_dqQ4sc)
tested with:
context.only("[Payment - 3DS] Capture greater amount", () => {
let shouldContinue = true; // variable that will be used to skip tests if a previous test fails
before("seed global state", () => {
cy.task("getGlobalState").then((state) => {
globalState = new State(state);
});
});
after("flush global state", () => {
cy.task("setGlobalState", globalState.data);
});
beforeEach(function () {
if (!shouldContinue) {
this.skip();
}
});
it("Create payment intent and confirm", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSFailPayment"];
cy.createConfirmPaymentTest(
paymentCreateConfirmBody,
data,
"three_ds",
"manual",
globalState
);
if (shouldContinue) shouldContinue = utils.should_continue_further(data);
});
it("Handle redirection", () => {
const expected_redirection = fixtures.confirmBody["return_url"];
cy.handleRedirection(globalState, expected_redirection);
});
it("Capture call", () => {
const data = getConnectorDetails(globalState.get("commons"))["card_pm"][
"CaptureGreaterAmount"
];
cy.retrievePaymentCallTest(globalState, data);
cy.captureCallTest(fixtures.captureBody, data, 65000, globalState);
if (shouldContinue) shouldContinue = utils.should_continue_further(data);
});
});
…tiple smaller functions and also handle for failed case
c74aa11
…r-verifyurl-in-redirection-handler * 'main' of github.com:juspay/hyperswitch: (30 commits) test(cypress): add test for In Memory Cache (juspay#6961) chore(version): 2025.01.09.1 fix(dummyconnector): add tenant id in dummyconnector requests (juspay#7008) chore(version): 2025.01.09.0 fix(cypress): backup and restore sessions when using user apis (juspay#6978) feat(users): handle edge features for users in tenancy (juspay#6990) chore(dynamic-fields): [Worldpay] update dynamic fields for payments (juspay#7002) chore(version): 2025.01.08.0 fix: consider status of payment method before filtering wallets in list pm (juspay#7004) feat(core): add columns unified error code and error message in refund table (juspay#6933) feat(connector): [Fiuu] Consume transaction id for error cases for Fiuu (juspay#6998) docs(cypress): update cypress documentation (juspay#6956) chore(version): 2025.01.07.0 chore(keymanager): add tenant-id to keymanager requests (juspay#6968) ci(cypress): Add Session Token Testcases (juspay#6683) Ci(Cypress): Add PML test and Dynamic Fields Test for Novalnet (juspay#6544) chore(version): 2025.01.06.0 ci(cypress): fix adyen sofort in cypress (juspay#6984) chore: add migrations for Currency type in DB (juspay#6980) chore(version): 2025.01.03.0 ...
…into multiple smaller functions and also handle for failed case" This reverts commit c74aa11.
8a2314d
Type of Change
This pull request Resolve #5915
Description
This PR refactors the verifyReturnUrl function to validate the redirection_url and ensure that the payment status is either succeeded or processing. If the status is invalid, the test will now fail, preventing false positives in redirection tests like 3DS or bank redirects.
###Key Changes:
Additional Changes
Motivation and Context
This change improves the reliability of Cypress redirection tests by ensuring that the final redirection URL reflects a valid payment status, preventing false positives and ensuring tests behave as expected for flows like 3DS and bank redirects.
How did you test it?
Ran against Integ environment for Stripe:
when the validation fails, below is the kind of error we get:
Checklist
cargo +nightly fmt --all
cargo clippy