Skip to content

Commit

Permalink
fix: inconsistencies
Browse files Browse the repository at this point in the history
  • Loading branch information
pixincreate committed Nov 25, 2024
1 parent 4d7a2bb commit 06ab242
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1598,6 +1598,10 @@ describe("Card - Refund flow - 3DS", () => {
});

it("Confirm 3DS", () => {
let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][
"3DSManualCapture"
];

let configs = validateConfig(data["Configs"]);
let req_data = data["Request"];
let res_data = data["Response"];
Expand Down
29 changes: 17 additions & 12 deletions cypress-tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,7 @@ Cypress.Commands.add(
createPaymentBody.capture_method = capture_method;
createPaymentBody.customer_id = globalState.get("customerId");
createPaymentBody.profile_id = profile_id;

globalState.set("paymentAmount", createPaymentBody.amount);

cy.request({
Expand Down Expand Up @@ -1144,7 +1145,6 @@ Cypress.Commands.add(
confirmBody.confirm = confirm;
confirmBody.profile_id = profile_id;

console.log(config_info, confirmBody.profile_id);
for (const key in req_data) {
confirmBody[key] = req_data[key];
}
Expand Down Expand Up @@ -1513,8 +1513,11 @@ Cypress.Commands.add(
body: createConfirmPaymentBody,
}).then((response) => {
logRequestId(response.headers["x-request-id"]);

globalState.set("clientSecret", response.body.client_secret);

expect(response.headers["content-type"]).to.include("application/json");

if (response.status === 200) {
globalState.set("paymentAmount", createConfirmPaymentBody.amount);
globalState.set("paymentID", response.body.payment_id);
Expand All @@ -1533,6 +1536,7 @@ Cypress.Commands.add(
expect(response.body.billing, "billing_address").to.not.be.empty;
expect(response.body.profile_id, "profile_id").to.not.be.null;
expect(response.body).to.have.property("status");

if (response.body.capture_method === "automatic") {
if (response.body.authentication_type === "three_ds") {
expect(response.body)
Expand Down Expand Up @@ -1774,8 +1778,13 @@ Cypress.Commands.add(

Cypress.Commands.add(
"retrievePaymentCallTest",
(globalState, autoretries = false, attempt = 1) => {
(globalState, configs, autoretries = false, attempt = 1) => {
const config_info = execConfig(configs);
const payment_id = globalState.get("paymentID");
const merchant_connector_id = globalState.get(
config_info.merchant_connector_id
);

cy.request({
method: "GET",
url: `${globalState.get("baseUrl")}/payments/${payment_id}?force_sync=true&expand_attempts=true`,
Expand All @@ -1786,7 +1795,6 @@ Cypress.Commands.add(
failOnStatusCode: false,
}).then((response) => {
logRequestId(response.headers["x-request-id"]);
globalState.set("paymentID", response.body.payment_id);

expect(response.headers["content-type"]).to.include("application/json");
expect(response.body.payment_id).to.equal(payment_id);
Expand All @@ -1806,7 +1814,7 @@ Cypress.Commands.add(
.be.empty;
expect(response.body.payment_method, "payment_method").to.not.be.null;
expect(response.body.merchant_connector_id, "connector_id").to.equal(
globalState.get("merchantConnectorId")
merchant_connector_id
);
}

Expand Down Expand Up @@ -1929,7 +1937,7 @@ Cypress.Commands.add(
requestBody.confirm = confirm;
requestBody.customer_id = globalState.get("customerId");
requestBody.payment_type = payment_type;
requestBody.profile_id = globalState.get(profile_id);
requestBody.profile_id = profile_id;

globalState.set("paymentAmount", requestBody.amount);

Expand All @@ -1953,7 +1961,7 @@ Cypress.Commands.add(
expect(response.body.connector, "connector").to.equal(
globalState.get("connectorId")
);
expect(globalState.get("merchantConnectorId"), "connector_id").to.equal(
expect(merchant_connector_id, "connector_id").to.equal(
response.body.merchant_connector_id
);
expect(response.body.customer, "customer").to.not.be.empty;
Expand Down Expand Up @@ -2042,7 +2050,7 @@ Cypress.Commands.add(
requestBody.capture_method = capture_method;
requestBody.customer_id = globalState.get("customerId");
requestBody.mandate_id = globalState.get("mandateId");
requestBody.profile_id = globalState.get(profile_id);
requestBody.profile_id = profile_id;

globalState.set("paymentAmount", requestBody.amount);
cy.request({
Expand All @@ -2064,7 +2072,7 @@ Cypress.Commands.add(
expect(response.body.connector, "connector").to.equal(
globalState.get("connectorId")
);
expect(globalState.get("merchantConnectorId"), "connector_id").to.equal(
expect(merchant_connector_id, "connector_id").to.equal(
response.body.merchant_connector_id
);
expect(response.body.customer, "customer").to.not.be.empty;
Expand Down Expand Up @@ -2136,15 +2144,12 @@ Cypress.Commands.add(
(requestBody, amount, confirm, capture_method, globalState, configs) => {
const config_info = execConfig(configs);
const profile_id = globalState.get(config_info.profile_id);
const merchant_connector_id = globalState.get(
config_info.merchant_connector_id
);

requestBody.amount = amount;
requestBody.capture_method = capture_method;
requestBody.confirm = confirm;
requestBody.customer_id = globalState.get("customerId");
requestBody.profile_id = globalState.get(profile_id);
requestBody.profile_id = profile_id;
requestBody.recurring_details.data = globalState.get("paymentMethodId");

cy.request({
Expand Down
5 changes: 4 additions & 1 deletion cypress-tests/cypress/utils/featureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ export function execConfig(configs) {
typeof configs?.CONNECTOR_CREDENTIAL === "undefined" ||
typeof configs?.CONNECTOR_CREDENTIAL === "null"
) {
return "profileId";
return {
profile_id: "profileId",
merchant_connector_id: "merchantConnectorId",
};
} else {
if (configs.CONNECTOR_CREDENTIAL === "connector_1") {
return {
Expand Down

0 comments on commit 06ab242

Please sign in to comment.