mirror of
https://github.com/juspay/hyperswitch.git
synced 2026-03-13 09:02:06 +08:00
test(cypress): add card installment payment flow tests for Adyen (#11444)
This commit is contained in:
@@ -746,6 +746,78 @@ export const connectorDetails = {
|
||||
},
|
||||
},
|
||||
},
|
||||
PaymentIntentWithInstallments: {
|
||||
Request: {
|
||||
currency: "BRL",
|
||||
installment_options: [
|
||||
{
|
||||
payment_method: "card",
|
||||
installments: [
|
||||
{
|
||||
number_of_installments: [3, 6, 12],
|
||||
billing_frequency: "month",
|
||||
interest_rate: 5.0,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
Response: {
|
||||
status: 200,
|
||||
body: {
|
||||
status: "requires_payment_method",
|
||||
},
|
||||
},
|
||||
},
|
||||
CardInstallmentConfirm: {
|
||||
Request: {
|
||||
payment_method: "card",
|
||||
payment_method_type: "credit",
|
||||
payment_method_data: {
|
||||
card: successfulNo3DSCardDetails,
|
||||
},
|
||||
installment_data: {
|
||||
number_of_installments: 3,
|
||||
billing_frequency: "month",
|
||||
},
|
||||
},
|
||||
Response: {
|
||||
status: 200,
|
||||
body: {
|
||||
status: "succeeded",
|
||||
net_amount: 6300,
|
||||
},
|
||||
},
|
||||
},
|
||||
PaymentIntentWithInstallmentsAndConfirmTrue: {
|
||||
Request: {
|
||||
currency: "BRL",
|
||||
confirm: true,
|
||||
installment_options: [
|
||||
{
|
||||
payment_method: "card",
|
||||
installments: [
|
||||
{
|
||||
number_of_installments: [3, 6, 12],
|
||||
billing_frequency: "month",
|
||||
interest_rate: 5.0,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
Response: {
|
||||
status: 422,
|
||||
body: {
|
||||
error: {
|
||||
type: "invalid_request",
|
||||
message:
|
||||
"installment_options and installment_data are not supported when confirm is true.",
|
||||
code: "IR_06",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
bank_transfer_pm: {
|
||||
Pix: {
|
||||
|
||||
@@ -1985,6 +1985,77 @@ export const connectorDetails = {
|
||||
`,
|
||||
},
|
||||
}),
|
||||
PaymentIntentWithInstallments: getCustomExchange({
|
||||
Request: {
|
||||
currency: "BRL",
|
||||
installment_options: [
|
||||
{
|
||||
payment_method: "card",
|
||||
installments: [
|
||||
{
|
||||
number_of_installments: [3, 6, 12],
|
||||
billing_frequency: "month",
|
||||
interest_rate: 5.0,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
Response: {
|
||||
status: 200,
|
||||
body: {
|
||||
status: "requires_payment_method",
|
||||
},
|
||||
},
|
||||
}),
|
||||
CardInstallmentConfirm: getCustomExchange({
|
||||
Request: {
|
||||
payment_method: "card",
|
||||
payment_method_type: "credit",
|
||||
payment_method_data: {
|
||||
card: successfulNo3DSCardDetails,
|
||||
},
|
||||
installment_data: {
|
||||
number_of_installments: 3,
|
||||
billing_frequency: "month",
|
||||
},
|
||||
},
|
||||
Response: {
|
||||
status: 200,
|
||||
body: {
|
||||
status: "succeeded",
|
||||
},
|
||||
},
|
||||
}),
|
||||
PaymentIntentWithInstallmentsAndConfirmTrue: getCustomExchange({
|
||||
Request: {
|
||||
currency: "BRL",
|
||||
confirm: true,
|
||||
installment_options: [
|
||||
{
|
||||
payment_method: "card",
|
||||
installments: [
|
||||
{
|
||||
number_of_installments: [3, 6, 12],
|
||||
billing_frequency: "month",
|
||||
interest_rate: 5.0,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
Response: {
|
||||
status: 422,
|
||||
body: {
|
||||
error: {
|
||||
type: "invalid_request",
|
||||
message:
|
||||
"installment_options and installment_data are not supported when confirm is true.",
|
||||
code: "IR_06",
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
},
|
||||
upi_pm: {
|
||||
PaymentIntent: getCustomExchange({
|
||||
|
||||
@@ -467,6 +467,7 @@ export const CONNECTOR_LISTS = {
|
||||
"worldpayxml",
|
||||
],
|
||||
PAYMENTS_WEBHOOK: ["noon", "stripe", "authorizedotnet"],
|
||||
CARD_INSTALLMENTS: ["adyen"],
|
||||
// Add more inclusion lists
|
||||
},
|
||||
};
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
import * as fixtures from "../../../fixtures/imports";
|
||||
import State from "../../../utils/State";
|
||||
import getConnectorDetails, * as utils from "../../configs/Payment/Utils";
|
||||
|
||||
let connector;
|
||||
let globalState;
|
||||
|
||||
describe("Card - Installment payment flow test", () => {
|
||||
before(function () {
|
||||
let skip = false;
|
||||
|
||||
cy.task("getGlobalState")
|
||||
.then((state) => {
|
||||
globalState = new State(state);
|
||||
connector = globalState.get("connectorId");
|
||||
|
||||
if (
|
||||
utils.shouldIncludeConnector(
|
||||
connector,
|
||||
utils.CONNECTOR_LISTS.INCLUDE.CARD_INSTALLMENTS
|
||||
)
|
||||
) {
|
||||
skip = true;
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
if (skip) {
|
||||
this.skip();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
after("flush global state", () => {
|
||||
cy.task("setGlobalState", globalState.data);
|
||||
});
|
||||
|
||||
context("Card installment payment - Create and Confirm", () => {
|
||||
let shouldContinue = true;
|
||||
|
||||
beforeEach(function () {
|
||||
if (!shouldContinue) {
|
||||
this.skip();
|
||||
}
|
||||
});
|
||||
|
||||
it("create-installment-payment-intent", () => {
|
||||
const data = getConnectorDetails(globalState.get("connectorId"))[
|
||||
"card_pm"
|
||||
]["PaymentIntentWithInstallments"];
|
||||
|
||||
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-installment-payment", () => {
|
||||
const data = getConnectorDetails(globalState.get("connectorId"))[
|
||||
"card_pm"
|
||||
]["CardInstallmentConfirm"];
|
||||
|
||||
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"
|
||||
]["CardInstallmentConfirm"];
|
||||
|
||||
cy.retrievePaymentCallTest({ globalState, data });
|
||||
});
|
||||
});
|
||||
context(
|
||||
"Card installment payment - Create with confirm true should fail",
|
||||
() => {
|
||||
let shouldContinue = true;
|
||||
|
||||
beforeEach(function () {
|
||||
if (!shouldContinue) {
|
||||
this.skip();
|
||||
}
|
||||
});
|
||||
|
||||
it("create+confirm-installment-options-should-error", () => {
|
||||
const data = getConnectorDetails(globalState.get("connectorId"))[
|
||||
"card_pm"
|
||||
]["PaymentIntentWithInstallmentsAndConfirmTrue"];
|
||||
|
||||
cy.createPaymentIntentTest(
|
||||
fixtures.createPaymentBody,
|
||||
data,
|
||||
"no_three_ds",
|
||||
"automatic",
|
||||
globalState
|
||||
);
|
||||
|
||||
if (shouldContinue)
|
||||
shouldContinue = utils.should_continue_further(data);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
90
cypress-tests/cypress/e2e/spec/Payment/00041-Wallet.cy.js
Normal file
90
cypress-tests/cypress/e2e/spec/Payment/00041-Wallet.cy.js
Normal file
@@ -0,0 +1,90 @@
|
||||
import * as fixtures from "../../../fixtures/imports";
|
||||
import State from "../../../utils/State";
|
||||
import getConnectorDetails, * as utils from "../../configs/Payment/Utils";
|
||||
|
||||
let globalState;
|
||||
|
||||
describe("Wallet tests", () => {
|
||||
afterEach("flush global state", () => {
|
||||
cy.task("setGlobalState", globalState.data);
|
||||
});
|
||||
|
||||
context("Bluecode Create and Confirm flow test", () => {
|
||||
let shouldContinue = true;
|
||||
|
||||
before("seed global state", () => {
|
||||
cy.task("getGlobalState").then((state) => {
|
||||
globalState = new State(state);
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
if (!shouldContinue) {
|
||||
this.skip();
|
||||
}
|
||||
});
|
||||
|
||||
it("create-payment-call-test", () => {
|
||||
const data = getConnectorDetails(globalState.get("connectorId"))[
|
||||
"wallet_pm"
|
||||
]["PaymentIntent"]("Bluecode");
|
||||
|
||||
cy.createPaymentIntentTest(
|
||||
fixtures.createPaymentBody,
|
||||
data,
|
||||
"three_ds",
|
||||
"automatic",
|
||||
globalState
|
||||
);
|
||||
if (shouldContinue) shouldContinue = utils.should_continue_further(data);
|
||||
});
|
||||
|
||||
it("payment_methods-call-test", () => {
|
||||
cy.paymentMethodsCallTest(globalState);
|
||||
});
|
||||
|
||||
it("Confirm wallet redirect", () => {
|
||||
const data = getConnectorDetails(globalState.get("connectorId"))[
|
||||
"wallet_pm"
|
||||
]["Bluecode"];
|
||||
|
||||
cy.confirmBankRedirectCallTest(
|
||||
fixtures.confirmBody,
|
||||
data,
|
||||
true,
|
||||
globalState
|
||||
);
|
||||
|
||||
if (shouldContinue) shouldContinue = utils.should_continue_further(data);
|
||||
});
|
||||
|
||||
it("Handle wallet redirection", () => {
|
||||
const expected_redirection = fixtures.confirmBody["return_url"];
|
||||
const payment_method_type = globalState.get("paymentMethodType");
|
||||
const nextActionUrl = globalState.get("nextActionUrl");
|
||||
|
||||
expect(
|
||||
nextActionUrl,
|
||||
"nextActionUrl should be defined before handling wallet redirection"
|
||||
).to.be.a("string");
|
||||
|
||||
cy.handleWalletRedirection(
|
||||
globalState,
|
||||
payment_method_type,
|
||||
expected_redirection
|
||||
);
|
||||
});
|
||||
|
||||
it("Sync payment status", () => {
|
||||
const data = getConnectorDetails(globalState.get("connectorId"))[
|
||||
"wallet_pm"
|
||||
]["Bluecode"];
|
||||
|
||||
cy.retrievePaymentCallTest({
|
||||
globalState,
|
||||
data,
|
||||
expectedIntentStatus: "requires_customer_action",
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user