|
| 1 | + |
| 2 | +import * as testIds from "../../../src/Utilities/TestUtils.bs"; |
| 3 | +import { getClientURL } from "../support/utils"; |
| 4 | +import { createPaymentBody } from "../support/utils"; |
| 5 | +import { |
| 6 | + changeObjectKeyValue, |
| 7 | + connectorProfileIdMapping, |
| 8 | + connectorEnum, |
| 9 | +} from "../support/utils"; |
| 10 | + |
| 11 | +describe("TrustPay iDEAL Bank Redirect Payment flow test", () => { |
| 12 | + const publishableKey = Cypress.env("HYPERSWITCH_PUBLISHABLE_KEY"); |
| 13 | + const secretKey = Cypress.env("HYPERSWITCH_SECRET_KEY"); |
| 14 | + let getIframeBody: () => Cypress.Chainable<JQuery<HTMLBodyElement>>; |
| 15 | + let iframeSelector = |
| 16 | + "#orca-payment-element-iframeRef-orca-elements-payment-element-payment-element"; |
| 17 | + |
| 18 | + beforeEach(() => { |
| 19 | + getIframeBody = () => cy.iframe(iframeSelector); |
| 20 | + |
| 21 | + changeObjectKeyValue( |
| 22 | + createPaymentBody, |
| 23 | + "profile_id", |
| 24 | + connectorProfileIdMapping.get(connectorEnum.TRUSTPAY), |
| 25 | + ); |
| 26 | + changeObjectKeyValue(createPaymentBody, "currency", "EUR"); |
| 27 | + |
| 28 | + |
| 29 | + createPaymentBody.billing.address.country = "NL"; |
| 30 | + createPaymentBody.billing.address.state = "Noord-Holland"; |
| 31 | + |
| 32 | + createPaymentBody.shipping.address.country = "NL"; |
| 33 | + createPaymentBody.shipping.address.state = "Noord-Holland"; |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | + cy.createPaymentIntent(secretKey, createPaymentBody).then(() => { |
| 38 | + cy.getGlobalState("clientSecret").then((clientSecret) => { |
| 39 | + cy.visit(getClientURL(clientSecret, publishableKey)); |
| 40 | + }); |
| 41 | + }); |
| 42 | + }); |
| 43 | + |
| 44 | + it("title rendered correctly", () => { |
| 45 | + cy.contains("Hyperswitch Unified Checkout").should("be.visible"); |
| 46 | + }); |
| 47 | + |
| 48 | + it("orca-payment-element iframe loaded", () => { |
| 49 | + cy.get(iframeSelector) |
| 50 | + .should("be.visible") |
| 51 | + .its("0.contentDocument") |
| 52 | + .its("body"); |
| 53 | + }); |
| 54 | + |
| 55 | + it("should complete the iDEAL bank redirect payment successfully", () => { |
| 56 | + cy.wait(2000); |
| 57 | + getIframeBody().find(`[data-testid=${testIds.addNewCardIcon}]`).click(); |
| 58 | + getIframeBody().contains("div", "iDEAL").click(); |
| 59 | + getIframeBody() |
| 60 | + .get("#submit") |
| 61 | + .click() |
| 62 | + .then(() => { |
| 63 | + cy.url().should( |
| 64 | + "include", |
| 65 | + "https://pay.ideal.nl/transactions", |
| 66 | + ); |
| 67 | + }); |
| 68 | + }); |
| 69 | +}); |
| 70 | + |
| 71 | +describe("TrustPay Blik Bank Redirect Payment flow test", () => { |
| 72 | + const publishableKey = Cypress.env("HYPERSWITCH_PUBLISHABLE_KEY"); |
| 73 | + const secretKey = Cypress.env("HYPERSWITCH_SECRET_KEY"); |
| 74 | + let getIframeBody: () => Cypress.Chainable<JQuery<HTMLBodyElement>>; |
| 75 | + let iframeSelector = |
| 76 | + "#orca-payment-element-iframeRef-orca-elements-payment-element-payment-element"; |
| 77 | + |
| 78 | + beforeEach(() => { |
| 79 | + getIframeBody = () => cy.iframe(iframeSelector); |
| 80 | + |
| 81 | + |
| 82 | + changeObjectKeyValue( |
| 83 | + createPaymentBody, |
| 84 | + "profile_id", |
| 85 | + connectorProfileIdMapping.get(connectorEnum.TRUSTPAY), |
| 86 | + ); |
| 87 | + changeObjectKeyValue(createPaymentBody, "currency", "PLN"); |
| 88 | + |
| 89 | + createPaymentBody.billing.address.country = "PL"; |
| 90 | + |
| 91 | + createPaymentBody.shipping.address.country = "PL"; |
| 92 | + |
| 93 | + cy.createPaymentIntent(secretKey, createPaymentBody).then(() => { |
| 94 | + cy.getGlobalState("clientSecret").then((clientSecret) => { |
| 95 | + cy.visit(getClientURL(clientSecret, publishableKey)); |
| 96 | + }); |
| 97 | + }); |
| 98 | + }); |
| 99 | + |
| 100 | + it("title rendered correctly", () => { |
| 101 | + cy.contains("Hyperswitch Unified Checkout").should("be.visible"); |
| 102 | + }); |
| 103 | + |
| 104 | + it("orca-payment-element iframe loaded", () => { |
| 105 | + cy.get(iframeSelector) |
| 106 | + .should("be.visible") |
| 107 | + .its("0.contentDocument") |
| 108 | + .its("body"); |
| 109 | + }); |
| 110 | + |
| 111 | + it("should complete the Blik bank redirect payment successfully", () => { |
| 112 | + cy.wait(2000); |
| 113 | + getIframeBody().find(`[data-testid=${testIds.addNewCardIcon}]`).click(); |
| 114 | + getIframeBody().contains("div", "Blik").click(); |
| 115 | + getIframeBody() |
| 116 | + .get("#submit") |
| 117 | + .click() |
| 118 | + .then(() => { |
| 119 | + cy.url().should( |
| 120 | + "include", |
| 121 | + "https://e.blik.com/blik_web/index.html", |
| 122 | + ); |
| 123 | + }); |
| 124 | + }); |
| 125 | +}); |
| 126 | + |
| 127 | +describe("TrustPay EPS Bank Redirect Payment flow test", () => { |
| 128 | + const publishableKey = Cypress.env("HYPERSWITCH_PUBLISHABLE_KEY"); |
| 129 | + const secretKey = Cypress.env("HYPERSWITCH_SECRET_KEY"); |
| 130 | + let getIframeBody: () => Cypress.Chainable<JQuery<HTMLBodyElement>>; |
| 131 | + let iframeSelector = |
| 132 | + "#orca-payment-element-iframeRef-orca-elements-payment-element-payment-element"; |
| 133 | + |
| 134 | + beforeEach(() => { |
| 135 | + getIframeBody = () => cy.iframe(iframeSelector); |
| 136 | + |
| 137 | + changeObjectKeyValue( |
| 138 | + createPaymentBody, |
| 139 | + "profile_id", |
| 140 | + connectorProfileIdMapping.get(connectorEnum.TRUSTPAY), |
| 141 | + ); |
| 142 | + changeObjectKeyValue(createPaymentBody, "currency", "EUR"); |
| 143 | + |
| 144 | + createPaymentBody.billing.address.country = "AT"; |
| 145 | + |
| 146 | + createPaymentBody.shipping.address.country = "AT"; |
| 147 | + |
| 148 | + |
| 149 | + |
| 150 | + |
| 151 | + cy.createPaymentIntent(secretKey, createPaymentBody).then(() => { |
| 152 | + cy.getGlobalState("clientSecret").then((clientSecret) => { |
| 153 | + cy.visit(getClientURL(clientSecret, publishableKey)); |
| 154 | + }); |
| 155 | + }); |
| 156 | + }); |
| 157 | + |
| 158 | + it("title rendered correctly", () => { |
| 159 | + cy.contains("Hyperswitch Unified Checkout").should("be.visible"); |
| 160 | + }); |
| 161 | + |
| 162 | + it("orca-payment-element iframe loaded", () => { |
| 163 | + cy.get(iframeSelector) |
| 164 | + .should("be.visible") |
| 165 | + .its("0.contentDocument") |
| 166 | + .its("body"); |
| 167 | + }); |
| 168 | + |
| 169 | + it("should complete the EPS bank redirect payment successfully", () => { |
| 170 | + cy.wait(2000); |
| 171 | + getIframeBody().find(`[data-testid=${testIds.addNewCardIcon}]`).click(); |
| 172 | + getIframeBody().contains("div", "EPS").click(); |
| 173 | + getIframeBody() |
| 174 | + .get("#submit") |
| 175 | + .click() |
| 176 | + .then(() => { |
| 177 | + cy.url().should( |
| 178 | + "include", |
| 179 | + "https://routing.eps.or.at/appl/epsSO/transinit/bankauswahl.htm", |
| 180 | + ); |
| 181 | + }); |
| 182 | + }); |
| 183 | +}); |
0 commit comments