2021-09-27 10:04:21 +00:00
|
|
|
/// <reference types="cypress"/>
|
|
|
|
/// <reference types="../../../support"/>
|
|
|
|
|
2021-07-23 09:46:44 +00:00
|
|
|
import faker from "faker";
|
|
|
|
|
|
|
|
import {
|
|
|
|
addShippingMethod,
|
|
|
|
completeCheckout,
|
2022-06-27 16:49:35 +00:00
|
|
|
createCheckout,
|
2021-09-27 10:04:21 +00:00
|
|
|
} from "../../../support/api/requests/Checkout";
|
|
|
|
import { getOrder } from "../../../support/api/requests/Order";
|
2022-11-14 14:56:50 +00:00
|
|
|
import { updatePlugin } from "../../../support/api/requests/Plugins";
|
2021-09-27 10:04:21 +00:00
|
|
|
import { getDefaultChannel } from "../../../support/api/utils/channelsUtils";
|
2022-01-31 08:37:49 +00:00
|
|
|
import {
|
|
|
|
addAdyenPayment,
|
2022-06-27 16:49:35 +00:00
|
|
|
getShippingMethodIdFromCheckout,
|
2022-01-31 08:37:49 +00:00
|
|
|
} from "../../../support/api/utils/ordersUtils";
|
2021-07-23 09:46:44 +00:00
|
|
|
import {
|
|
|
|
createProductInChannel,
|
|
|
|
createTypeAttributeAndCategoryForProduct,
|
2022-06-27 16:49:35 +00:00
|
|
|
deleteProductsStartsWith,
|
2021-09-27 10:04:21 +00:00
|
|
|
} from "../../../support/api/utils/products/productsUtils";
|
2021-07-23 09:46:44 +00:00
|
|
|
import {
|
|
|
|
createShipping,
|
2022-06-27 16:49:35 +00:00
|
|
|
deleteShippingStartsWith,
|
2021-09-27 10:04:21 +00:00
|
|
|
} from "../../../support/api/utils/shippingUtils";
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
describe("Adyen payments", () => {
|
2022-08-16 10:49:22 +00:00
|
|
|
const startsWith = "Adyen";
|
2022-06-27 09:30:51 +00:00
|
|
|
const name = startsWith + faker.datatype.number();
|
2022-08-16 10:49:22 +00:00
|
|
|
const email = `example@example.com`;
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
let address;
|
|
|
|
let defaultChannel;
|
|
|
|
let warehouse;
|
|
|
|
let shippingMethod;
|
|
|
|
let variantsList;
|
|
|
|
let checkout;
|
|
|
|
let paymentCards;
|
|
|
|
let cardData;
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
before(() => {
|
|
|
|
cy.clearSessionData().loginUserViaRequest();
|
|
|
|
deleteProductsStartsWith(startsWith);
|
|
|
|
deleteShippingStartsWith(startsWith);
|
|
|
|
cy.fixture("cards").then(cardsResp => {
|
|
|
|
paymentCards = cardsResp.adyen;
|
|
|
|
cardData = {
|
|
|
|
clientData: paymentCards.clientData,
|
|
|
|
encryptedExpiryMonth: paymentCards.encryptedExpiryMonth,
|
|
|
|
encryptedExpiryYear: paymentCards.encryptedExpiryYear,
|
2022-06-27 16:49:35 +00:00
|
|
|
encryptedSecurityCode: paymentCards.encryptedSecurityCodes.matches,
|
2022-06-27 09:30:51 +00:00
|
|
|
};
|
2021-07-23 09:46:44 +00:00
|
|
|
});
|
2022-06-27 09:30:51 +00:00
|
|
|
cy.fixture("addresses")
|
|
|
|
.then(addresses => {
|
|
|
|
address = addresses.usAddress;
|
|
|
|
getDefaultChannel();
|
2021-07-23 09:46:44 +00:00
|
|
|
})
|
2022-06-27 09:30:51 +00:00
|
|
|
.then(channelResp => {
|
|
|
|
defaultChannel = channelResp;
|
|
|
|
createShipping({
|
|
|
|
channelId: channelResp.id,
|
|
|
|
name,
|
|
|
|
address,
|
2022-06-27 16:49:35 +00:00
|
|
|
price: 10,
|
2021-07-23 09:46:44 +00:00
|
|
|
});
|
2022-06-27 09:30:51 +00:00
|
|
|
})
|
|
|
|
.then(
|
2022-11-14 14:56:50 +00:00
|
|
|
({ warehouse: warehouseResp, shippingMethod: shippingMethodResp }) => {
|
2022-06-27 09:30:51 +00:00
|
|
|
warehouse = warehouseResp;
|
|
|
|
shippingMethod = shippingMethodResp;
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2022-11-14 14:56:50 +00:00
|
|
|
)
|
|
|
|
.then(() => {
|
|
|
|
updatePlugin(
|
|
|
|
"mirumee.payments.adyen",
|
|
|
|
"adyen-auto-capture",
|
|
|
|
true,
|
|
|
|
defaultChannel.id,
|
|
|
|
);
|
|
|
|
});
|
2022-06-27 09:30:51 +00:00
|
|
|
createTypeAttributeAndCategoryForProduct({ name })
|
|
|
|
.then(({ productType, attribute, category }) => {
|
|
|
|
createProductInChannel({
|
|
|
|
name,
|
|
|
|
channelId: defaultChannel.id,
|
|
|
|
warehouseId: warehouse.id,
|
|
|
|
productTypeId: productType.id,
|
|
|
|
attributeId: attribute.id,
|
2022-06-27 16:49:35 +00:00
|
|
|
categoryId: category.id,
|
2022-06-27 09:30:51 +00:00
|
|
|
});
|
|
|
|
})
|
|
|
|
.then(({ variantsList: variants }) => (variantsList = variants));
|
|
|
|
});
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
beforeEach(() => {
|
|
|
|
cy.clearSessionData().loginUserViaRequest();
|
|
|
|
createCheckout({
|
|
|
|
channelSlug: defaultChannel.slug,
|
|
|
|
email,
|
|
|
|
variantsList,
|
|
|
|
address,
|
|
|
|
billingAddress: address,
|
2022-06-27 16:49:35 +00:00
|
|
|
auth: "token",
|
2022-06-27 09:30:51 +00:00
|
|
|
})
|
|
|
|
.then(({ checkout: checkoutResp }) => {
|
|
|
|
const shippingMethodId = getShippingMethodIdFromCheckout(
|
|
|
|
checkoutResp,
|
2022-06-27 16:49:35 +00:00
|
|
|
shippingMethod.name,
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
|
|
|
checkout = checkoutResp;
|
|
|
|
addShippingMethod(checkout.id, shippingMethodId);
|
|
|
|
})
|
|
|
|
.then(({ checkout: checkoutResp }) => {
|
|
|
|
addAdyenPayment(checkout.id, checkoutResp.totalPrice.gross.amount);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it(
|
|
|
|
"should purchase products with simple card",
|
|
|
|
{ tags: ["@payments", "@stagedOnly"] },
|
|
|
|
() => {
|
2021-07-23 09:46:44 +00:00
|
|
|
const simpleCard = cardData;
|
|
|
|
simpleCard.encryptedCardNumber =
|
|
|
|
paymentCards.cards.simpleCard.encryptedCardNumber;
|
|
|
|
simpleCard.brand = paymentCards.cards.simpleCard.brand;
|
|
|
|
completeCheckout(checkout.id, simpleCard)
|
|
|
|
.then(({ order }) => {
|
|
|
|
getOrder(order.id);
|
|
|
|
})
|
|
|
|
.then(order => {
|
|
|
|
expect(order.paymentStatus).to.eq("FULLY_CHARGED");
|
|
|
|
});
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
it(
|
|
|
|
"should purchase product with 3D secure 2 Auth",
|
|
|
|
{ tags: ["@payments", "@stagedOnly"] },
|
|
|
|
() => {
|
2021-07-23 09:46:44 +00:00
|
|
|
const threeDSecureCard = cardData;
|
|
|
|
threeDSecureCard.encryptedCardNumber =
|
|
|
|
paymentCards.cards.threeDSecureTwoAuth.encryptedCardNumber;
|
|
|
|
threeDSecureCard.brand = paymentCards.cards.threeDSecureTwoAuth.brand;
|
|
|
|
completeCheckout(checkout.id, threeDSecureCard)
|
|
|
|
.then(({ order }) => {
|
|
|
|
getOrder(order.id);
|
|
|
|
})
|
|
|
|
.then(order => {
|
|
|
|
expect(order.paymentStatus).to.eq("FULLY_CHARGED");
|
|
|
|
});
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
it(
|
|
|
|
"should purchase product with 3D secure 1 Auth",
|
|
|
|
{ tags: ["@payments", "@stagedOnly"] },
|
|
|
|
() => {
|
2021-07-23 09:46:44 +00:00
|
|
|
const threeDSecureCardOneAuth = cardData;
|
|
|
|
threeDSecureCardOneAuth.encryptedCardNumber =
|
|
|
|
paymentCards.cards.threeDSecureOneAuth.encryptedCardNumber;
|
|
|
|
threeDSecureCardOneAuth.brand =
|
|
|
|
paymentCards.cards.threeDSecureOneAuth.brand;
|
|
|
|
completeCheckout(checkout.id, threeDSecureCardOneAuth)
|
|
|
|
.then(({ order }) => {
|
|
|
|
getOrder(order.id);
|
|
|
|
})
|
|
|
|
.then(order => {
|
|
|
|
expect(order.paymentStatus).to.eq("FULLY_CHARGED");
|
|
|
|
});
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
it(
|
|
|
|
"should fail with unknown security number",
|
|
|
|
{ tags: ["@payments", "@stagedOnly"] },
|
|
|
|
() => {
|
2021-07-23 09:46:44 +00:00
|
|
|
const simpleCard = cardData;
|
|
|
|
simpleCard.encryptedCardNumber =
|
|
|
|
paymentCards.cards.simpleCard.encryptedCardNumber;
|
|
|
|
simpleCard.brand = paymentCards.cards.simpleCard.brand;
|
|
|
|
simpleCard.encryptedSecurityCode =
|
|
|
|
paymentCards.encryptedSecurityCodes.unknown;
|
2022-02-11 14:39:10 +00:00
|
|
|
completeCheckout(checkout.id, simpleCard).then(({ errors }) => {
|
|
|
|
expect(errors).to.have.length(1);
|
2021-07-23 09:46:44 +00:00
|
|
|
});
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
it(
|
|
|
|
"should fail with timeout in 3D authorization",
|
|
|
|
{ tags: ["@payments", "@stagedOnly"] },
|
|
|
|
() => {
|
2021-07-23 09:46:44 +00:00
|
|
|
const errorCard = cardData;
|
|
|
|
errorCard.encryptedCardNumber =
|
|
|
|
paymentCards.cards.errorCard.encryptedCardNumber;
|
|
|
|
errorCard.brand = paymentCards.cards.errorCard.brand;
|
2022-02-11 14:39:10 +00:00
|
|
|
completeCheckout(checkout.id, errorCard).then(({ errors }) => {
|
|
|
|
expect(errors).to.have.length(1);
|
2021-07-23 09:46:44 +00:00
|
|
|
});
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
it(
|
|
|
|
"should fail with closed account",
|
|
|
|
{ tags: ["@payments", "@stagedOnly"] },
|
|
|
|
() => {
|
2021-07-23 09:46:44 +00:00
|
|
|
const closeAccount = cardData;
|
|
|
|
closeAccount.encryptedCardNumber =
|
|
|
|
paymentCards.cards.closeAccount.encryptedCardNumber;
|
|
|
|
closeAccount.brand = paymentCards.cards.closeAccount.brand;
|
2022-02-11 14:39:10 +00:00
|
|
|
completeCheckout(checkout.id, closeAccount).then(({ errors }) => {
|
|
|
|
expect(errors).to.have.length(1);
|
2021-07-23 09:46:44 +00:00
|
|
|
});
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
2021-07-23 09:46:44 +00:00
|
|
|
});
|