mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 12:06:56 +08:00
ci(cypress): Add field level verification (#6153)
This commit is contained in:
@ -2,6 +2,5 @@
|
||||
"trailingComma": "es5",
|
||||
"tabWidth": 2,
|
||||
"semi": true,
|
||||
"singleQuote": false,
|
||||
"printWidth": 120
|
||||
"singleQuote": false
|
||||
}
|
||||
|
||||
@ -9,11 +9,11 @@ const successfulNo3DSCardDetails = {
|
||||
};
|
||||
|
||||
const successfulThreeDSTestCardDetails = {
|
||||
card_number: "4349940199004549",
|
||||
card_exp_month: "12",
|
||||
card_exp_year: "30",
|
||||
card_holder_name: "joseph Doe",
|
||||
card_cvc: "396",
|
||||
card_number: "4349940199004549",
|
||||
card_exp_month: "12",
|
||||
card_exp_year: "30",
|
||||
card_holder_name: "joseph Doe",
|
||||
card_cvc: "396",
|
||||
};
|
||||
|
||||
export const connectorDetails = {
|
||||
@ -37,21 +37,21 @@ export const connectorDetails = {
|
||||
payment_method: "card",
|
||||
billing: {
|
||||
address: {
|
||||
line1: "1467",
|
||||
line2: "CA",
|
||||
line3: "CA",
|
||||
city: "Florence",
|
||||
state: "Tuscany",
|
||||
zip: "12345",
|
||||
country: "IT",
|
||||
first_name: "Max",
|
||||
last_name: "Mustermann"
|
||||
line1: "1467",
|
||||
line2: "CA",
|
||||
line3: "CA",
|
||||
city: "Florence",
|
||||
state: "Tuscany",
|
||||
zip: "12345",
|
||||
country: "IT",
|
||||
first_name: "Max",
|
||||
last_name: "Mustermann",
|
||||
},
|
||||
email: "mauro.morandi@nexi.it",
|
||||
phone: {
|
||||
number: "9123456789",
|
||||
country_code: "+91"
|
||||
}
|
||||
number: "9123456789",
|
||||
country_code: "+91",
|
||||
},
|
||||
},
|
||||
payment_method_data: {
|
||||
card: successfulThreeDSTestCardDetails,
|
||||
@ -71,21 +71,21 @@ export const connectorDetails = {
|
||||
payment_method: "card",
|
||||
billing: {
|
||||
address: {
|
||||
line1: "1467",
|
||||
line2: "CA",
|
||||
line3: "CA",
|
||||
city: "Florence",
|
||||
state: "Tuscany",
|
||||
zip: "12345",
|
||||
country: "IT",
|
||||
first_name: "Max",
|
||||
last_name: "Mustermann"
|
||||
line1: "1467",
|
||||
line2: "CA",
|
||||
line3: "CA",
|
||||
city: "Florence",
|
||||
state: "Tuscany",
|
||||
zip: "12345",
|
||||
country: "IT",
|
||||
first_name: "Max",
|
||||
last_name: "Mustermann",
|
||||
},
|
||||
email: "mauro.morandi@nexi.it",
|
||||
phone: {
|
||||
number: "9123456789",
|
||||
country_code: "+91"
|
||||
}
|
||||
number: "9123456789",
|
||||
country_code: "+91",
|
||||
},
|
||||
},
|
||||
payment_method_data: {
|
||||
card: successfulThreeDSTestCardDetails,
|
||||
|
||||
@ -50,6 +50,46 @@ const multiUseMandateData = {
|
||||
},
|
||||
};
|
||||
|
||||
const payment_method_data_3ds = {
|
||||
card: {
|
||||
last4: "3155",
|
||||
card_type: "CREDIT",
|
||||
card_network: "Visa",
|
||||
card_issuer: "INTL HDQTRS-CENTER OWNED",
|
||||
card_issuing_country: "UNITEDSTATES",
|
||||
card_isin: "400000",
|
||||
card_extended_bin: null,
|
||||
card_exp_month: "10",
|
||||
card_exp_year: "25",
|
||||
card_holder_name: null,
|
||||
payment_checks: null,
|
||||
authentication_data: null,
|
||||
},
|
||||
billing: null,
|
||||
};
|
||||
|
||||
const payment_method_data_no3ds = {
|
||||
card: {
|
||||
last4: "4242",
|
||||
card_type: "CREDIT",
|
||||
card_network: "Visa",
|
||||
card_issuer: "STRIPE PAYMENTS UK LIMITED",
|
||||
card_issuing_country: "UNITEDKINGDOM",
|
||||
card_isin: "424242",
|
||||
card_extended_bin: null,
|
||||
card_exp_month: "10",
|
||||
card_exp_year: "25",
|
||||
card_holder_name: null,
|
||||
payment_checks: {
|
||||
cvc_check: "pass",
|
||||
address_line1_check: "pass",
|
||||
address_postal_code_check: "pass",
|
||||
},
|
||||
authentication_data: null,
|
||||
},
|
||||
billing: null,
|
||||
};
|
||||
|
||||
export const connectorDetails = {
|
||||
card_pm: {
|
||||
PaymentIntent: {
|
||||
@ -62,6 +102,7 @@ export const connectorDetails = {
|
||||
status: 200,
|
||||
body: {
|
||||
status: "requires_payment_method",
|
||||
setup_future_usage: "on_session",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -75,6 +116,7 @@ export const connectorDetails = {
|
||||
status: 200,
|
||||
body: {
|
||||
status: "requires_payment_method",
|
||||
setup_future_usage: "off_session",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -91,10 +133,13 @@ export const connectorDetails = {
|
||||
Response: {
|
||||
status: 200,
|
||||
body: {
|
||||
status: "requires_capture",
|
||||
status: "requires_customer_action",
|
||||
setup_future_usage: "on_session",
|
||||
payment_method_data: payment_method_data_3ds,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
"3DSAutoCapture": {
|
||||
Request: {
|
||||
payment_method: "card",
|
||||
@ -109,6 +154,8 @@ export const connectorDetails = {
|
||||
status: 200,
|
||||
body: {
|
||||
status: "requires_customer_action",
|
||||
setup_future_usage: "on_session",
|
||||
payment_method_data: payment_method_data_3ds,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -126,6 +173,9 @@ export const connectorDetails = {
|
||||
status: 200,
|
||||
body: {
|
||||
status: "requires_capture",
|
||||
payment_method: "card",
|
||||
attempt_count: 1,
|
||||
payment_method_data: payment_method_data_no3ds,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -143,6 +193,9 @@ export const connectorDetails = {
|
||||
status: 200,
|
||||
body: {
|
||||
status: "succeeded",
|
||||
payment_method: "card",
|
||||
attempt_count: 1,
|
||||
payment_method_data: payment_method_data_no3ds,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@ -822,13 +822,67 @@ Cypress.Commands.add(
|
||||
globalState.set("paymentID", response.body.payment_id);
|
||||
cy.log(clientSecret);
|
||||
for (const key in res_data.body) {
|
||||
expect(res_data.body[key]).to.equal(response.body[key]);
|
||||
expect(res_data.body[key]).to.equal(
|
||||
response.body[key],
|
||||
`Expected ${res_data.body[key]} but got ${response.body[key]}`
|
||||
);
|
||||
}
|
||||
expect(createPaymentBody.amount).to.equal(response.body.amount);
|
||||
expect(null).to.equal(response.body.amount_received);
|
||||
expect(createPaymentBody.amount).to.equal(
|
||||
expect(createPaymentBody.amount, "amount").to.equal(
|
||||
response.body.amount
|
||||
);
|
||||
expect(createPaymentBody.currency, "currency").to.equal(
|
||||
response.body.currency
|
||||
);
|
||||
expect(createPaymentBody.capture_method, "capture_method").to.equal(
|
||||
response.body.capture_method
|
||||
);
|
||||
expect(
|
||||
createPaymentBody.authentication_type,
|
||||
"authentication_type"
|
||||
).to.equal(response.body.authentication_type);
|
||||
expect(createPaymentBody.description, "description").to.equal(
|
||||
response.body.description
|
||||
);
|
||||
expect(createPaymentBody.email, "email").to.equal(response.body.email);
|
||||
expect(createPaymentBody.email, "customer.email").to.equal(
|
||||
response.body.customer.email
|
||||
);
|
||||
expect(createPaymentBody.customer_id, "customer.id").to.equal(
|
||||
response.body.customer.id
|
||||
);
|
||||
expect(createPaymentBody.metadata, "metadata").to.deep.equal(
|
||||
response.body.metadata
|
||||
);
|
||||
expect(
|
||||
createPaymentBody.setup_future_usage,
|
||||
"setup_future_usage"
|
||||
).to.equal(response.body.setup_future_usage);
|
||||
expect(createPaymentBody.amount, "amount_capturable").to.equal(
|
||||
response.body.amount_capturable
|
||||
);
|
||||
expect(response.body.amount_received, "amount_received").to.be.oneOf([
|
||||
0,
|
||||
null,
|
||||
]);
|
||||
expect(response.body.connector, "connector").to.be.null;
|
||||
expect(createPaymentBody.capture_method, "capture_method").to.equal(
|
||||
response.body.capture_method
|
||||
);
|
||||
expect(response.body.payment_method, "payment_method").to.be.null;
|
||||
expect(response.body.payment_method_data, "payment_method_data").to.be
|
||||
.null;
|
||||
expect(response.body.merchant_connector_id, "merchant_connector_id").to
|
||||
.be.null;
|
||||
expect(response.body.payment_method_id, "payment_method_id").to.be.null;
|
||||
expect(response.body.payment_method_id, "payment_method_status").to.be
|
||||
.null;
|
||||
expect(response.body.profile_id, "profile_id").to.not.be.null;
|
||||
expect(
|
||||
response.body.merchant_order_reference_id,
|
||||
"merchant_order_reference_id"
|
||||
).to.be.null;
|
||||
expect(response.body.connector_mandate_id, "connector_mandate_id").to.be
|
||||
.null;
|
||||
} else {
|
||||
defaultErrorHandler(response, res_data);
|
||||
}
|
||||
@ -911,6 +965,24 @@ Cypress.Commands.add(
|
||||
if (response.status === 200) {
|
||||
globalState.set("paymentID", paymentIntentID);
|
||||
globalState.set("connectorId", response.body.connector);
|
||||
expect(response.body.connector, "connector").to.equal(
|
||||
globalState.get("connectorId")
|
||||
);
|
||||
expect(response.body.payment_id, "payment_id").to.equal(
|
||||
paymentIntentID
|
||||
);
|
||||
expect(response.body.payment_method_data, "payment_method_data").to.not
|
||||
.be.empty;
|
||||
expect(response.body.merchant_connector_id, "connector_id").to.equal(
|
||||
globalState.get("merchantConnectorId")
|
||||
);
|
||||
expect(response.body.customer, "customer").to.not.be.empty;
|
||||
expect(response.body.billing, "billing_address").to.not.be.empty;
|
||||
expect(response.body.profile_id, "profile_id").to.not.be.null;
|
||||
expect(
|
||||
response.body.connector_transaction_id,
|
||||
"connector_transaction_id"
|
||||
).to.not.be.null;
|
||||
if (response.body.capture_method === "automatic") {
|
||||
if (response.body.authentication_type === "three_ds") {
|
||||
expect(response.body)
|
||||
@ -921,11 +993,15 @@ Cypress.Commands.add(
|
||||
response.body.next_action.redirect_to_url
|
||||
);
|
||||
for (const key in res_data.body) {
|
||||
expect(res_data.body[key]).to.equal(response.body[key]);
|
||||
expect(res_data.body[key], [key]).to.deep.equal(
|
||||
response.body[key]
|
||||
);
|
||||
}
|
||||
} else if (response.body.authentication_type === "no_three_ds") {
|
||||
for (const key in res_data.body) {
|
||||
expect(res_data.body[key]).to.equal(response.body[key]);
|
||||
expect(res_data.body[key], [key]).to.deep.equal(
|
||||
response.body[key]
|
||||
);
|
||||
}
|
||||
} else {
|
||||
throw new Error(
|
||||
@ -941,9 +1017,16 @@ Cypress.Commands.add(
|
||||
"nextActionUrl",
|
||||
response.body.next_action.redirect_to_url
|
||||
);
|
||||
for (const key in res_data.body) {
|
||||
expect(res_data.body[key], [key]).to.deep.equal(
|
||||
response.body[key]
|
||||
);
|
||||
}
|
||||
} else if (response.body.authentication_type === "no_three_ds") {
|
||||
for (const key in res_data.body) {
|
||||
expect(res_data.body[key]).to.equal(response.body[key]);
|
||||
expect(res_data.body[key], [key]).to.deep.equal(
|
||||
response.body[key]
|
||||
);
|
||||
}
|
||||
} else {
|
||||
throw new Error(
|
||||
@ -1212,10 +1295,28 @@ Cypress.Commands.add(
|
||||
logRequestId(response.headers["x-request-id"]);
|
||||
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);
|
||||
expect(response.body.connector, "connector").to.equal(
|
||||
globalState.get("connectorId")
|
||||
);
|
||||
expect(response.body.payment_id, "payment_id").to.equal(
|
||||
globalState.get("paymentID")
|
||||
);
|
||||
expect(response.body.payment_method_data, "payment_method_data").to.not
|
||||
.be.empty;
|
||||
expect(response.body.merchant_connector_id, "connector_id").to.equal(
|
||||
globalState.get("merchantConnectorId")
|
||||
);
|
||||
expect(response.body.customer, "customer").to.not.be.empty;
|
||||
expect(response.body.billing, "billing_address").to.not.be.empty;
|
||||
expect(response.body.profile_id, "profile_id").to.not.be.null;
|
||||
expect(
|
||||
response.body.connector_transaction_id,
|
||||
"connector_transaction_id"
|
||||
).to.not.be.null;
|
||||
expect(response.body).to.have.property("status");
|
||||
if (response.body.capture_method === "automatic") {
|
||||
expect(response.body).to.have.property("status");
|
||||
globalState.set("paymentAmount", createConfirmPaymentBody.amount);
|
||||
globalState.set("paymentID", response.body.payment_id);
|
||||
if (response.body.authentication_type === "three_ds") {
|
||||
expect(response.body)
|
||||
.to.have.property("next_action")
|
||||
@ -1224,9 +1325,16 @@ Cypress.Commands.add(
|
||||
"nextActionUrl",
|
||||
response.body.next_action.redirect_to_url
|
||||
);
|
||||
for (const key in res_data.body) {
|
||||
expect(res_data.body[key], [key]).to.deep.equal(
|
||||
response.body[key]
|
||||
);
|
||||
}
|
||||
} else if (response.body.authentication_type === "no_three_ds") {
|
||||
for (const key in res_data.body) {
|
||||
expect(res_data.body[key]).to.equal(response.body[key]);
|
||||
expect(res_data.body[key], [key]).to.deep.equal(
|
||||
response.body[key]
|
||||
);
|
||||
}
|
||||
} else {
|
||||
throw new Error(
|
||||
@ -1234,9 +1342,6 @@ Cypress.Commands.add(
|
||||
);
|
||||
}
|
||||
} else if (response.body.capture_method === "manual") {
|
||||
expect(response.body).to.have.property("status");
|
||||
globalState.set("paymentAmount", createConfirmPaymentBody.amount);
|
||||
globalState.set("paymentID", response.body.payment_id);
|
||||
if (response.body.authentication_type === "three_ds") {
|
||||
expect(response.body)
|
||||
.to.have.property("next_action")
|
||||
@ -1245,9 +1350,16 @@ Cypress.Commands.add(
|
||||
"nextActionUrl",
|
||||
response.body.next_action.redirect_to_url
|
||||
);
|
||||
for (const key in res_data.body) {
|
||||
expect(res_data.body[key], [key]).to.deep.equal(
|
||||
response.body[key]
|
||||
);
|
||||
}
|
||||
} else if (response.body.authentication_type === "no_three_ds") {
|
||||
for (const key in res_data.body) {
|
||||
expect(res_data.body[key]).to.equal(response.body[key]);
|
||||
expect(res_data.body[key], [key]).to.deep.equal(
|
||||
response.body[key]
|
||||
);
|
||||
}
|
||||
} else {
|
||||
throw new Error(
|
||||
@ -1409,11 +1521,33 @@ 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);
|
||||
expect(response.body.amount).to.equal(globalState.get("paymentAmount"));
|
||||
globalState.set("paymentID", response.body.payment_id);
|
||||
expect(response.body.profile_id, "profile_id").to.not.be.null;
|
||||
expect(response.body.billing, "billing_address").to.not.be.empty;
|
||||
expect(response.body.customer, "customer").to.not.be.empty;
|
||||
if (
|
||||
["succeeded", "processing", "requires_customer_action"].includes(
|
||||
response.body.status
|
||||
)
|
||||
) {
|
||||
expect(response.body.connector, "connector").to.equal(
|
||||
globalState.get("connectorId")
|
||||
);
|
||||
expect(response.body.payment_method_data, "payment_method_data").to.not
|
||||
.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")
|
||||
);
|
||||
expect(
|
||||
response.body.connector_transaction_id,
|
||||
"connector_transaction_id"
|
||||
).to.not.be.null;
|
||||
}
|
||||
|
||||
if (autoretries) {
|
||||
expect(response.body).to.have.property("attempts");
|
||||
@ -1835,7 +1969,9 @@ Cypress.Commands.add(
|
||||
{ redirection_url, expected_url },
|
||||
connectorId,
|
||||
payment_method_type,
|
||||
{ next_action_type }
|
||||
{
|
||||
next_action_type,
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user