Skip to content
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

feat(cypress): add iatapay connector #5093

Merged
merged 16 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
951 changes: 476 additions & 475 deletions cypress-tests/cypress/e2e/PaymentTest/00008-RefundPayment.cy.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe("Card - Mandates using Payment Method Id flow test", () => {
this.skip();
}
});

it("Create No 3DS Payment Intent", () => {
let data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
Expand Down
179 changes: 179 additions & 0 deletions cypress-tests/cypress/e2e/PaymentTest/00019-UPI.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
import confirmBody from "../../fixtures/confirm-body.json";
import createPaymentBody from "../../fixtures/create-payment-body.json";
import refundBody from "../../fixtures/refund-flow-body.json";
import State from "../../utils/State";
import getConnectorDetails, * as utils from "../PaymentUtils/utils";

let globalState;

describe("UPI Payments - Hyperswitch", () => {
let should_continue = true; // variable that will be used to skip tests if a previous test fails

context("[Payment] [UPI - UPI Collect] Create & Confirm + Refund", () => {
should_continue = true; // variable that will be used to skip tests if a previous test fails
pixincreate marked this conversation as resolved.
Show resolved Hide resolved

before("seed global state", () => {
pixincreate marked this conversation as resolved.
Show resolved Hide resolved
cy.task("getGlobalState").then((state) => {
globalState = new State(state);
});
});

afterEach("flush global state", () => {
cy.task("setGlobalState", globalState.data);
});

beforeEach(function () {
if (!should_continue) {
this.skip();
}
});

it("Create payment intent", () => {
let data = getConnectorDetails(globalState.get("connectorId"))["upi_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("List Merchant payment methods", () => {
cy.paymentMethodsCallTest(globalState);
});

it("Confirm payment", () => {
let data = getConnectorDetails(globalState.get("connectorId"))["upi_pm"][
"UpiCollect"
];
let req_data = data["Request"];
let res_data = data["Response"];

cy.confirmUpiCall(confirmBody, req_data, res_data, true, globalState);

if (should_continue)
should_continue = utils.should_continue_further(res_data);
});

it("Handle UPI Redirection", () => {
let expected_redirection = confirmBody["return_url"];
let payment_method_type = globalState.get("paymentMethodType");
cy.handleUpiRedirection(
globalState,
payment_method_type,
expected_redirection
);
});

it("Retrieve payment", () => {
cy.retrievePaymentCallTest(globalState);
});

it("Refund payment", () => {
let data = getConnectorDetails(globalState.get("connectorId"))["upi_pm"][
"Refund"
];
let req_data = data["Request"];
let res_data = data["Response"];
cy.refundCallTest(refundBody, req_data, res_data, 6500, globalState);

if (should_continue)
should_continue = utils.should_continue_further(res_data);
});
});

// Skipping UPI Intent intentionally as connector is throwing 5xx during redirection
context.skip("[Payment] [UPI - UPI Intent] Create & Confirm", () => {
let should_continue = true; // variable that will be used to skip tests if a previous test fails
pixincreate marked this conversation as resolved.
Show resolved Hide resolved

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 (!should_continue) {
this.skip();
}
});

it("Create payment intent", () => {
let data = getConnectorDetails(globalState.get("connectorId"))["upi_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("List Merchant payment methods", () => {
cy.paymentMethodsCallTest(globalState);
});

it("Confirm payment", () => {
let data = getConnectorDetails(globalState.get("connectorId"))["upi_pm"][
"UpiIntent"
];
let req_data = data["Request"];
let res_data = data["Response"];

cy.confirmUpiCall(confirmBody, req_data, res_data, true, globalState);

if (should_continue)
should_continue = utils.should_continue_further(res_data);
});

it("Handle UPI Redirection", () => {
let expected_redirection = confirmBody["return_url"];
let payment_method_type = globalState.get("paymentMethodType");
cy.handleUpiRedirection(
globalState,
payment_method_type,
expected_redirection
);
});

it("Retrieve payment", () => {
cy.retrievePaymentCallTest(globalState);
});
});
});

// TODO: This test is incomplete. Above has to be replicated here with changes to support SCL
describe.skip("UPI Payments -- Hyperswitch Stripe Compatibility Layer", () => {
before("seed global state", () => {
cy.task("getGlobalState").then((state) => {
globalState = new State(state);
});
});

after("flush global state", () => {
cy.task("setGlobalState", globalState.data);
});
});
62 changes: 61 additions & 1 deletion cypress-tests/cypress/e2e/PaymentUtils/Adyen.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ export const connectorDetails = {
card: successfulNo3DSCardDetails,
},
currency: "USD",
mandate_data: singleUseMandateData
mandate_data: singleUseMandateData,
},
Response: {
status: 200,
Expand Down Expand Up @@ -736,4 +736,64 @@ export const connectorDetails = {
},
},
},

upi_pm: {
PaymentIntent: {
Request: {
currency: "INR",
},
Response: {
status: 200,
body: {
status: "requires_payment_method",
},
},
},
UpiCollect: {
Request: {
payment_method: "upi",
payment_method_type: "upi_collect",
payment_method_data: {
upi: {
upi_collect: {
vpa_id: "successtest@iata",
},
},
},
},
Response: {
status: 400,
body: {
error: {
type: "invalid_request",
message: "Payment method type not supported",
code: "HE_03",
reason: "automatic for upi_collect is not supported by adyen",
},
},
},
},
UpiIntent: {
Request: {
payment_method: "upi",
payment_method_type: "upi_intent",
payment_method_data: {
upi: {
upi_intent: {},
},
},
},
Response: {
status: 400,
body: {
error: {
type: "invalid_request",
message: "Payment method type not supported",
code: "HE_03",
reason: "automatic for upi_intent is not supported by adyen",
},
},
},
},
},
};
30 changes: 15 additions & 15 deletions cypress-tests/cypress/e2e/PaymentUtils/BankOfAmerica.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ export const connectorDetails = {
card: successfulThreeDSTestCardDetails,
},
currency: "USD",
mandate_data: singleUseMandateData
},
mandate_data: singleUseMandateData,
},
Response: {
status: 200,
body: {
Expand All @@ -217,7 +217,7 @@ export const connectorDetails = {
card: successfulThreeDSTestCardDetails,
},
currency: "USD",
mandate_data: singleUseMandateData
mandate_data: singleUseMandateData,
},
Response: {
status: 200,
Expand All @@ -228,11 +228,11 @@ export const connectorDetails = {
},
MandateSingleUseNo3DSAutoCapture: {
Request: {
payment_method_data: {
payment_method_data: {
card: successfulNo3DSCardDetails,
},
currency: "USD",
mandate_data: singleUseMandateData
mandate_data: singleUseMandateData,
},
Response: {
status: 200,
Expand All @@ -243,11 +243,11 @@ export const connectorDetails = {
},
MandateSingleUseNo3DSManualCapture: {
Request: {
payment_method_data: {
payment_method_data: {
card: successfulNo3DSCardDetails,
},
currency: "USD",
mandate_data: singleUseMandateData
mandate_data: singleUseMandateData,
},
Response: {
status: 200,
Expand All @@ -258,11 +258,11 @@ export const connectorDetails = {
},
MandateMultiUseNo3DSAutoCapture: {
Request: {
payment_method_data: {
payment_method_data: {
card: successfulNo3DSCardDetails,
},
currency: "USD",
mandate_data: multiUseMandateData
mandate_data: multiUseMandateData,
},
Response: {
status: 200,
Expand All @@ -273,11 +273,11 @@ export const connectorDetails = {
},
MandateMultiUseNo3DSManualCapture: {
Request: {
payment_method_data: {
payment_method_data: {
card: successfulNo3DSCardDetails,
},
currency: "USD",
mandate_data: multiUseMandateData
mandate_data: multiUseMandateData,
},
Response: {
status: 200,
Expand All @@ -292,7 +292,7 @@ export const connectorDetails = {
card: successfulThreeDSTestCardDetails,
},
currency: "USD",
mandate_data: multiUseMandateData
mandate_data: multiUseMandateData,
},
Response: {
status: 200,
Expand All @@ -307,7 +307,7 @@ export const connectorDetails = {
card: successfulThreeDSTestCardDetails,
},
currency: "USD",
mandate_data: multiUseMandateData
mandate_data: multiUseMandateData,
},
Response: {
status: 200,
Expand All @@ -318,11 +318,11 @@ export const connectorDetails = {
},
ZeroAuthMandate: {
Request: {
payment_method_data: {
payment_method_data: {
card: successfulNo3DSCardDetails,
},
currency: "USD",
mandate_data: singleUseMandateData
mandate_data: singleUseMandateData,
},
Response: {
status: 200,
Expand Down
Loading
Loading