mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 19:46:48 +08:00
ci(cypress): Add shipping cost test case (#6779)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -96,4 +96,52 @@ describe("Card - NoThreeDS payment flow test", () => {
|
|||||||
cy.retrievePaymentCallTest(globalState, data);
|
cy.retrievePaymentCallTest(globalState, data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
context("Card-NoThreeDS payment with shipping cost", () => {
|
||||||
|
let shouldContinue = true; // variable that will be used to skip tests if a previous test fails
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
if (!shouldContinue) {
|
||||||
|
this.skip();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it("create-payment-call-test", () => {
|
||||||
|
const data = getConnectorDetails(globalState.get("connectorId"))[
|
||||||
|
"card_pm"
|
||||||
|
]["PaymentIntentWithShippingCost"];
|
||||||
|
|
||||||
|
cy.createPaymentIntentTest(
|
||||||
|
fixtures.createPaymentBody,
|
||||||
|
data,
|
||||||
|
"no_three_ds",
|
||||||
|
"automatic",
|
||||||
|
globalState
|
||||||
|
);
|
||||||
|
|
||||||
|
if (shouldContinue) shouldContinue = utils.should_continue_further(data);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("payment_methods-call-test", () => {
|
||||||
|
cy.paymentMethodsCallTest(globalState);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Confirm No 3DS", () => {
|
||||||
|
const data = getConnectorDetails(globalState.get("connectorId"))[
|
||||||
|
"card_pm"
|
||||||
|
]["PaymentConfirmWithShippingCost"];
|
||||||
|
|
||||||
|
cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);
|
||||||
|
|
||||||
|
if (shouldContinue) shouldContinue = utils.should_continue_further(data);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("retrieve-payment-call-test", () => {
|
||||||
|
const data = getConnectorDetails(globalState.get("connectorId"))[
|
||||||
|
"card_pm"
|
||||||
|
]["PaymentConfirmWithShippingCost"];
|
||||||
|
|
||||||
|
cy.retrievePaymentCallTest(globalState, data);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -80,6 +80,40 @@ export const connectorDetails = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
PaymentIntentWithShippingCost: {
|
||||||
|
Request: {
|
||||||
|
currency: "USD",
|
||||||
|
shipping_cost: 50,
|
||||||
|
},
|
||||||
|
Response: {
|
||||||
|
status: 200,
|
||||||
|
body: {
|
||||||
|
status: "requires_payment_method",
|
||||||
|
shipping_cost: 50,
|
||||||
|
amount: 6500,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
PaymentConfirmWithShippingCost: {
|
||||||
|
Request: {
|
||||||
|
payment_method: "card",
|
||||||
|
payment_method_data: {
|
||||||
|
card: successfulNo3DSCardDetails,
|
||||||
|
},
|
||||||
|
customer_acceptance: null,
|
||||||
|
setup_future_usage: "on_session",
|
||||||
|
},
|
||||||
|
Response: {
|
||||||
|
status: 200,
|
||||||
|
body: {
|
||||||
|
status: "succeeded",
|
||||||
|
shipping_cost: 50,
|
||||||
|
amount_received: 6550,
|
||||||
|
amount: 6500,
|
||||||
|
net_amount: 6550,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
"3DSManualCapture": {
|
"3DSManualCapture": {
|
||||||
Request: {
|
Request: {
|
||||||
payment_method: "card",
|
payment_method: "card",
|
||||||
|
|||||||
@ -78,6 +78,40 @@ export const connectorDetails = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
PaymentIntentWithShippingCost: {
|
||||||
|
Request: {
|
||||||
|
currency: "USD",
|
||||||
|
shipping_cost: 50,
|
||||||
|
},
|
||||||
|
Response: {
|
||||||
|
status: 200,
|
||||||
|
body: {
|
||||||
|
status: "requires_payment_method",
|
||||||
|
amount: 6500,
|
||||||
|
shipping_cost: 50,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
PaymentConfirmWithShippingCost: {
|
||||||
|
Request: {
|
||||||
|
payment_method: "card",
|
||||||
|
payment_method_data: {
|
||||||
|
card: successfulNo3DSCardDetails,
|
||||||
|
},
|
||||||
|
customer_acceptance: null,
|
||||||
|
setup_future_usage: "on_session",
|
||||||
|
},
|
||||||
|
Response: {
|
||||||
|
status: 200,
|
||||||
|
body: {
|
||||||
|
status: "succeeded",
|
||||||
|
shipping_cost: 50,
|
||||||
|
amount_received: 6550,
|
||||||
|
amount: 6500,
|
||||||
|
net_amount: 6550,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
"3DSManualCapture": {
|
"3DSManualCapture": {
|
||||||
Request: {
|
Request: {
|
||||||
payment_method: "card",
|
payment_method: "card",
|
||||||
|
|||||||
@ -29,6 +29,41 @@ export const connectorDetails = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
PaymentIntentWithShippingCost: {
|
||||||
|
Request: {
|
||||||
|
currency: "USD",
|
||||||
|
amount: 6500,
|
||||||
|
shipping_cost: 50,
|
||||||
|
},
|
||||||
|
Response: {
|
||||||
|
status: 200,
|
||||||
|
body: {
|
||||||
|
status: "requires_payment_method",
|
||||||
|
amount: 6500,
|
||||||
|
shipping_cost: 50,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
PaymentConfirmWithShippingCost: {
|
||||||
|
Request: {
|
||||||
|
payment_method: "card",
|
||||||
|
payment_method_data: {
|
||||||
|
card: successfulNo3DSCardDetails,
|
||||||
|
},
|
||||||
|
customer_acceptance: null,
|
||||||
|
setup_future_usage: "on_session",
|
||||||
|
},
|
||||||
|
Response: {
|
||||||
|
status: 200,
|
||||||
|
body: {
|
||||||
|
status: "succeeded",
|
||||||
|
shipping_cost: 50,
|
||||||
|
amount_received: 6550,
|
||||||
|
amount: 6500,
|
||||||
|
net_amount: 6550,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
"3DSManualCapture": {
|
"3DSManualCapture": {
|
||||||
Configs: {
|
Configs: {
|
||||||
TRIGGER_SKIP: true,
|
TRIGGER_SKIP: true,
|
||||||
|
|||||||
@ -38,6 +38,38 @@ export const connectorDetails = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
PaymentIntentWithShippingCost: {
|
||||||
|
Request: {
|
||||||
|
currency: "USD",
|
||||||
|
shipping_cost: 50,
|
||||||
|
},
|
||||||
|
Response: {
|
||||||
|
status: 200,
|
||||||
|
body: {
|
||||||
|
status: "requires_payment_method",
|
||||||
|
shipping_cost: 50,
|
||||||
|
amount: 6500,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
PaymentConfirmWithShippingCost: {
|
||||||
|
Request: {
|
||||||
|
payment_method: "card",
|
||||||
|
payment_method_data: {
|
||||||
|
card: successfulNo3DSCardDetails,
|
||||||
|
},
|
||||||
|
customer_acceptance: null,
|
||||||
|
setup_future_usage: "on_session",
|
||||||
|
},
|
||||||
|
Response: {
|
||||||
|
status: 200,
|
||||||
|
body: {
|
||||||
|
status: "processing",
|
||||||
|
shipping_cost: 50,
|
||||||
|
amount: 6500,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
"3DSManualCapture": {
|
"3DSManualCapture": {
|
||||||
Request: {
|
Request: {
|
||||||
payment_method: "card",
|
payment_method: "card",
|
||||||
|
|||||||
@ -637,9 +637,35 @@ export const connectorDetails = {
|
|||||||
status: 200,
|
status: 200,
|
||||||
body: {
|
body: {
|
||||||
status: "requires_payment_method",
|
status: "requires_payment_method",
|
||||||
|
shipping_cost: 50,
|
||||||
|
amount: 6500,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
PaymentIntentWithShippingCost: getCustomExchange({
|
||||||
|
Request: {
|
||||||
|
currency: "USD",
|
||||||
|
shipping_cost: 50,
|
||||||
|
},
|
||||||
|
Response: {
|
||||||
|
status: 200,
|
||||||
|
body: {
|
||||||
|
status: "requires_payment_method",
|
||||||
|
shipping_cost: 50,
|
||||||
|
amount: 6500,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
PaymentConfirmWithShippingCost: getCustomExchange({
|
||||||
|
Request: {
|
||||||
|
payment_method: "card",
|
||||||
|
payment_method_data: {
|
||||||
|
card: successfulNo3DSCardDetails,
|
||||||
|
},
|
||||||
|
customer_acceptance: null,
|
||||||
|
setup_future_usage: "on_session",
|
||||||
|
},
|
||||||
|
}),
|
||||||
"3DSManualCapture": getCustomExchange({
|
"3DSManualCapture": getCustomExchange({
|
||||||
Request: {
|
Request: {
|
||||||
payment_method: "card",
|
payment_method: "card",
|
||||||
|
|||||||
@ -146,6 +146,40 @@ export const connectorDetails = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
PaymentIntentWithShippingCost: {
|
||||||
|
Request: {
|
||||||
|
currency: "USD",
|
||||||
|
shipping_cost: 50,
|
||||||
|
},
|
||||||
|
Response: {
|
||||||
|
status: 200,
|
||||||
|
body: {
|
||||||
|
status: "requires_payment_method",
|
||||||
|
shipping_cost: 50,
|
||||||
|
amount: 6500,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
PaymentConfirmWithShippingCost: {
|
||||||
|
Request: {
|
||||||
|
payment_method: "card",
|
||||||
|
payment_method_data: {
|
||||||
|
card: successfulNo3DSCardDetails,
|
||||||
|
},
|
||||||
|
customer_acceptance: null,
|
||||||
|
setup_future_usage: "on_session",
|
||||||
|
},
|
||||||
|
Response: {
|
||||||
|
status: 200,
|
||||||
|
body: {
|
||||||
|
status: "succeeded",
|
||||||
|
shipping_cost: 50,
|
||||||
|
amount_received: 6550,
|
||||||
|
amount: 6500,
|
||||||
|
net_amount: 6550,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
"3DSManualCapture": {
|
"3DSManualCapture": {
|
||||||
Configs: {
|
Configs: {
|
||||||
CONNECTOR_CREDENTIAL: {
|
CONNECTOR_CREDENTIAL: {
|
||||||
|
|||||||
@ -38,6 +38,38 @@ export const connectorDetails = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
PaymentIntentWithShippingCost: {
|
||||||
|
Request: {
|
||||||
|
currency: "USD",
|
||||||
|
shipping_cost: 50,
|
||||||
|
},
|
||||||
|
Response: {
|
||||||
|
status: 200,
|
||||||
|
body: {
|
||||||
|
status: "requires_payment_method",
|
||||||
|
shipping_cost: 50,
|
||||||
|
amount: 6500,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
PaymentConfirmWithShippingCost: {
|
||||||
|
Request: {
|
||||||
|
payment_method: "card",
|
||||||
|
payment_method_data: {
|
||||||
|
card: successfulNo3DSCardDetails,
|
||||||
|
},
|
||||||
|
customer_acceptance: null,
|
||||||
|
setup_future_usage: "on_session",
|
||||||
|
},
|
||||||
|
Response: {
|
||||||
|
status: 200,
|
||||||
|
body: {
|
||||||
|
status: "processing",
|
||||||
|
shipping_cost: 50,
|
||||||
|
amount: 6500,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
"3DSManualCapture": {
|
"3DSManualCapture": {
|
||||||
Request: {
|
Request: {
|
||||||
payment_method: "card",
|
payment_method: "card",
|
||||||
|
|||||||
@ -115,6 +115,38 @@ export const connectorDetails = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
PaymentIntentWithShippingCost: {
|
||||||
|
Request: {
|
||||||
|
currency: "AED",
|
||||||
|
shipping_cost: 50,
|
||||||
|
},
|
||||||
|
Response: {
|
||||||
|
status: 200,
|
||||||
|
body: {
|
||||||
|
status: "requires_payment_method",
|
||||||
|
shipping_cost: 50,
|
||||||
|
amount: 6500,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
PaymentConfirmWithShippingCost: {
|
||||||
|
Request: {
|
||||||
|
payment_method: "card",
|
||||||
|
payment_method_data: {
|
||||||
|
card: successfulNo3DSCardDetails,
|
||||||
|
},
|
||||||
|
customer_acceptance: null,
|
||||||
|
setup_future_usage: "on_session",
|
||||||
|
},
|
||||||
|
Response: {
|
||||||
|
status: 200,
|
||||||
|
body: {
|
||||||
|
status: "requires_customer_action",
|
||||||
|
shipping_cost: 50,
|
||||||
|
amount: 6500,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
"3DSManualCapture": {
|
"3DSManualCapture": {
|
||||||
Request: {
|
Request: {
|
||||||
payment_method: "card",
|
payment_method: "card",
|
||||||
|
|||||||
@ -48,6 +48,39 @@ export const connectorDetails = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
PaymentIntentWithShippingCost: {
|
||||||
|
Request: {
|
||||||
|
currency: "USD",
|
||||||
|
shipping_cost: 50,
|
||||||
|
},
|
||||||
|
Response: {
|
||||||
|
status: 200,
|
||||||
|
body: {
|
||||||
|
status: "requires_payment_method",
|
||||||
|
shipping_cost: 50,
|
||||||
|
amount: 6500,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
PaymentConfirmWithShippingCost: {
|
||||||
|
Request: {
|
||||||
|
payment_method: "card",
|
||||||
|
payment_method_data: {
|
||||||
|
card: successfulNo3DSCardDetails,
|
||||||
|
},
|
||||||
|
customer_acceptance: null,
|
||||||
|
setup_future_usage: "on_session",
|
||||||
|
},
|
||||||
|
Response: {
|
||||||
|
status: 200,
|
||||||
|
body: {
|
||||||
|
status: "failed",
|
||||||
|
error_code: "AMOUNT_MISMATCH",
|
||||||
|
error_message:
|
||||||
|
"description - Should equal item_total + tax_total + shipping + handling + insurance - shipping_discount - discount., value - 65.50, field - value;",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
"3DSManualCapture": {
|
"3DSManualCapture": {
|
||||||
Configs: {
|
Configs: {
|
||||||
TRIGGER_SKIP: true,
|
TRIGGER_SKIP: true,
|
||||||
|
|||||||
@ -141,6 +141,40 @@ export const connectorDetails = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
PaymentIntentWithShippingCost: {
|
||||||
|
Request: {
|
||||||
|
currency: "USD",
|
||||||
|
shipping_cost: 50,
|
||||||
|
},
|
||||||
|
Response: {
|
||||||
|
status: 200,
|
||||||
|
body: {
|
||||||
|
status: "requires_payment_method",
|
||||||
|
shipping_cost: 50,
|
||||||
|
amount: 6500,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
PaymentConfirmWithShippingCost: {
|
||||||
|
Request: {
|
||||||
|
payment_method: "card",
|
||||||
|
payment_method_data: {
|
||||||
|
card: successfulNo3DSCardDetails,
|
||||||
|
},
|
||||||
|
customer_acceptance: null,
|
||||||
|
setup_future_usage: "on_session",
|
||||||
|
},
|
||||||
|
Response: {
|
||||||
|
status: 200,
|
||||||
|
body: {
|
||||||
|
status: "succeeded",
|
||||||
|
shipping_cost: 50,
|
||||||
|
amount_received: 6550,
|
||||||
|
amount: 6500,
|
||||||
|
net_amount: 6550,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
"3DSManualCapture": {
|
"3DSManualCapture": {
|
||||||
Request: {
|
Request: {
|
||||||
payment_method: "card",
|
payment_method: "card",
|
||||||
|
|||||||
@ -54,6 +54,40 @@ export const connectorDetails = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
PaymentIntentWithShippingCost: {
|
||||||
|
Request: {
|
||||||
|
currency: "USD",
|
||||||
|
shipping_cost: 50,
|
||||||
|
},
|
||||||
|
Response: {
|
||||||
|
status: 200,
|
||||||
|
body: {
|
||||||
|
status: "requires_payment_method",
|
||||||
|
shipping_cost: 50,
|
||||||
|
amount: 6500,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
PaymentConfirmWithShippingCost: {
|
||||||
|
Request: {
|
||||||
|
payment_method: "card",
|
||||||
|
payment_method_data: {
|
||||||
|
card: successfulNo3DSCardDetails,
|
||||||
|
},
|
||||||
|
customer_acceptance: null,
|
||||||
|
setup_future_usage: "on_session",
|
||||||
|
},
|
||||||
|
Response: {
|
||||||
|
status: 200,
|
||||||
|
body: {
|
||||||
|
status: "succeeded",
|
||||||
|
shipping_cost: 50,
|
||||||
|
amount_received: 6550,
|
||||||
|
amount: 6500,
|
||||||
|
net_amount: 6550,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
"3DSAutoCapture": {
|
"3DSAutoCapture": {
|
||||||
Configs: {
|
Configs: {
|
||||||
CONNECTOR_CREDENTIAL: {
|
CONNECTOR_CREDENTIAL: {
|
||||||
|
|||||||
@ -1079,9 +1079,17 @@ Cypress.Commands.add(
|
|||||||
createPaymentBody.setup_future_usage,
|
createPaymentBody.setup_future_usage,
|
||||||
"setup_future_usage"
|
"setup_future_usage"
|
||||||
).to.equal(response.body.setup_future_usage);
|
).to.equal(response.body.setup_future_usage);
|
||||||
|
// If 'shipping_cost' is not included in the request, the 'amount' in 'createPaymentBody' should match the 'amount_capturable' in the response.
|
||||||
|
if (typeof createPaymentBody?.shipping_cost === "undefined") {
|
||||||
expect(createPaymentBody.amount, "amount_capturable").to.equal(
|
expect(createPaymentBody.amount, "amount_capturable").to.equal(
|
||||||
response.body.amount_capturable
|
response.body.amount_capturable
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
expect(
|
||||||
|
createPaymentBody.amount + createPaymentBody.shipping_cost,
|
||||||
|
"amount_capturable"
|
||||||
|
).to.equal(response.body.amount_capturable);
|
||||||
|
}
|
||||||
expect(response.body.amount_received, "amount_received").to.be.oneOf([
|
expect(response.body.amount_received, "amount_received").to.be.oneOf([
|
||||||
0,
|
0,
|
||||||
null,
|
null,
|
||||||
|
|||||||
Reference in New Issue
Block a user