Skip to content

Commit

Permalink
ci(cypress): Add bank redirects for stripe (#4772)
Browse files Browse the repository at this point in the history
Co-authored-by: Likhin Bopanna <[email protected]>
  • Loading branch information
likhinbopanna and Likhin Bopanna authored Jun 6, 2024
1 parent b1cb053 commit 0553476
Show file tree
Hide file tree
Showing 7 changed files with 273 additions and 4 deletions.
60 changes: 59 additions & 1 deletion cypress-tests/cypress/e2e/PaymentTest/00017-BankRedirect.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,65 @@ describe("Bank Redirect tests", () => {
cy.handleBankRedirectRedirection(
globalState,
payment_method_type,
expected_redirection,
expected_redirection
);
});
});

context("Przelewy24 Create and Confirm flow test", () => {
let should_continue = true; // variable that will be used to skip tests if a previous test fails

beforeEach(function () {
if (!should_continue) {
this.skip();
}
});
it("create-payment-call-test", () => {
let data = getConnectorDetails(globalState.get("connectorId"))[
"bank_redirect_pm"
]["PaymentIntent"];
let req_data = data["Request"];
let res_data = data["Response"];
cy.createPaymentIntentTest(
createPaymentBody,
req_data,
res_data,
"three_ds",
"automatic",
globalState
);
if (should_continue)
should_continue = utils.should_continue_further(res_data);
});

it("payment_methods-call-test", () => {
cy.paymentMethodsCallTest(globalState);
});

it("Confirm bank redirect", () => {
let data = getConnectorDetails(globalState.get("connectorId"))[
"bank_redirect_pm"
]["przelewy24"];
let req_data = data["Request"];
let res_data = data["Response"];
cy.confirmBankRedirectCallTest(
confirmBody,
req_data,
res_data,
true,
globalState
);
if (should_continue)
should_continue = utils.should_continue_further(res_data);
});

it("Handle bank redirect redirection", () => {
let expected_redirection = confirmBody["return_url"];
let payment_method_type = globalState.get("paymentMethodType");
cy.handleBankRedirectRedirection(
globalState,
payment_method_type,
expected_redirection
);
});
});
Expand Down
28 changes: 27 additions & 1 deletion cypress-tests/cypress/e2e/PaymentUtils/Adyen.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,6 @@ export const connectorDetails = {
bank_name: "",
bank_account_bic: "",
bank_account_iban: "",
preferred_language: "en",
country: "DE",
},
},
Expand Down Expand Up @@ -493,6 +492,33 @@ export const connectorDetails = {
},
},
},
przelewy24: {
Request: {
payment_method: "bank_redirect",
payment_method_type: "przelewy24",
payment_method_data: {
bank_redirect: {
przelewy24: {
bank_name: "citi",
billing_details: {
email: "[email protected]",
},
},
},
},
},
Response: {
status: 400,
body: {
error: {
type: "invalid_request",
message: "Payment method type not supported",
code: "HE_03",
reason: "automatic for przelewy24 is not supported by adyen",
},
},
},
},
blik: {
Request: {
payment_method: "bank_redirect",
Expand Down
16 changes: 16 additions & 0 deletions cypress-tests/cypress/e2e/PaymentUtils/Commons.js
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,22 @@ export const connectorDetails = {
},
},
}),
przelewy24: getCustomExchange({
Request: {
payment_method: "bank_redirect",
payment_method_type: "przelewy24",
payment_method_data: {
bank_redirect: {
przelewy24: {
bank_name: "citi",
billing_details: {
email: "[email protected]",
},
},
},
},
},
}),
blikPaymentIntent: getCustomExchange({
Request: {
currency: "PLN",
Expand Down
135 changes: 135 additions & 0 deletions cypress-tests/cypress/e2e/PaymentUtils/Stripe.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { getCustomExchange } from "./Commons";

const successfulTestCard = "4242424242424242";
const successful3DSCard = "4000002760003184";

Expand Down Expand Up @@ -370,4 +372,137 @@ export const connectorDetails = {
},
},
},
bank_redirect_pm: {
PaymentIntent: getCustomExchange({
Request: {
currency: "EUR",
},
Response: {
status: 200,
body: {
status: "requires_payment_method",
},
},
}),
ideal: {
Request: {
payment_method: "bank_redirect",
payment_method_type: "ideal",
payment_method_data: {
bank_redirect: {
ideal: {
bank_name: "ing",
country: "NL",
},
},
},
},
Response: {
status: 200,
body: {
status: "requires_customer_action",
},
},
},
giropay: {
Request: {
payment_method: "bank_redirect",
payment_method_type: "giropay",
payment_method_data: {
bank_redirect: {
giropay: {
country: "DE",
},
},
},
},
Response: {
status: 200,
body: {
status: "requires_customer_action",
},
},
},
sofort: {
Request: {
payment_method: "bank_redirect",
payment_method_type: "sofort",
payment_method_data: {
bank_redirect: {
sofort: {
country: "DE",
preferred_language: "en",
},
},
},
},
Response: {
status: 200,
body: {
status: "requires_customer_action",
},
},
},
eps: {
Request: {
payment_method: "bank_redirect",
payment_method_type: "eps",
payment_method_data: {
bank_redirect: {
eps: {
bank_name: "bank_austria",
},
},
},
},
Response: {
status: 200,
body: {
status: "requires_customer_action",
},
},
},
blik: {
Request: {
payment_method: "bank_redirect",
payment_method_type: "blik",
payment_method_data: {
bank_redirect: {
blik: {
blik_code: "777987",
},
},
},
},
Response: {
status: 200,
body: {
status: "failed",
error_code: "payment_intent_invalid_parameter",
},
},
},
przelewy24: {
Request: {
payment_method: "bank_redirect",
payment_method_type: "przelewy24",
payment_method_data: {
bank_redirect: {
przelewy24: {
bank_name: "citi",
billing_details: {
email: "[email protected]",
},
},
},
},
},
Response: {
status: 200,
body: {
status: "requires_customer_action",
},
},
},
},
};
1 change: 0 additions & 1 deletion cypress-tests/cypress/e2e/PaymentUtils/Trustpay.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,6 @@ export const connectorDetails = {
bank_name: "",
bank_account_bic: "",
bank_account_iban: "",
preferred_language: "en",
country: "DE",
},
},
Expand Down
11 changes: 11 additions & 0 deletions cypress-tests/cypress/fixtures/create-connector-body.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,17 @@
"maximum_amount": 68607706,
"recurring_enabled": true,
"installment_payment_enabled": true
},
{
"payment_method_type": "przelewy24",
"payment_experience": null,
"card_networks": null,
"accepted_currencies": null,
"accepted_countries": null,
"minimum_amount": 1,
"maximum_amount": 68607706,
"recurring_enabled": true,
"installment_payment_enabled": true
}
]
}
Expand Down
26 changes: 25 additions & 1 deletion cypress-tests/cypress/support/redirectionHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,31 @@ function bankRedirectRedirection(
break;
default:
throw new Error(
`Unsupported payment method type: ${payment_method_type}`,
`Unsupported payment method type: ${payment_method_type}`
);
}
verifyUrl = true;
break;
case "stripe":
switch (payment_method_type) {
case "eps":
cy.get('a[name="success"]').click();
break;
case "ideal":
cy.get('a[name="success"]').click();
break;
case "giropay":
cy.get('a[name="success"]').click();
break;
case "sofort":
cy.get('a[name="success"]').click();
break;
case "przelewy24":
cy.get('a[name="success"]').click();
break;
default:
throw new Error(
`Unsupported payment method type: ${payment_method_type}`
);
}
verifyUrl = true;
Expand Down

0 comments on commit 0553476

Please sign in to comment.