mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-11-01 02:57:02 +08:00 
			
		
		
		
	 64383915bd
			
		
	
	64383915bd
	
	
	
		
			
			Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
		
			
				
	
	
		
			259 lines
		
	
	
		
			6.7 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			259 lines
		
	
	
		
			6.7 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| import * as fixtures from "../../fixtures/imports";
 | |
| import State from "../../utils/State";
 | |
| import * as utils from "../RoutingUtils/Utils";
 | |
| 
 | |
| let globalState;
 | |
| 
 | |
| describe("Volume Based Routing Test", () => {
 | |
|   context("Login", () => {
 | |
|     before("seed global state", () => {
 | |
|       cy.task("getGlobalState").then((state) => {
 | |
|         globalState = new State(state);
 | |
|       });
 | |
|     });
 | |
| 
 | |
|     after("flush global state", () => {
 | |
|       cy.task("setGlobalState", globalState.data);
 | |
|     });
 | |
| 
 | |
|     it("User login", () => {
 | |
|       cy.userLogin(globalState);
 | |
|       cy.terminate2Fa(globalState);
 | |
|       cy.userInfo(globalState);
 | |
|     });
 | |
| 
 | |
|     it("merchant retrieve call", () => {
 | |
|       cy.merchantRetrieveCall(globalState);
 | |
|     });
 | |
|   });
 | |
| 
 | |
|   context("Volume based routing with 100% of stripe", () => {
 | |
|     before("seed global state", () => {
 | |
|       cy.task("getGlobalState").then((state) => {
 | |
|         globalState = new State(state);
 | |
|       });
 | |
|     });
 | |
| 
 | |
|     after("flush global state", () => {
 | |
|       cy.task("setGlobalState", globalState.data);
 | |
|     });
 | |
| 
 | |
|     it("list-mca-by-mid", () => {
 | |
|       cy.ListMcaByMid(globalState);
 | |
|     });
 | |
| 
 | |
|     it("api-key-create-call-test", () => {
 | |
|       cy.apiKeyCreateTest(fixtures.apiKeyCreateBody, globalState);
 | |
|     });
 | |
| 
 | |
|     it("customer-create-call-test", () => {
 | |
|       cy.createCustomerCallTest(fixtures.customerCreateBody, globalState);
 | |
|     });
 | |
| 
 | |
|     it("add-routing-config", () => {
 | |
|       const data = utils.getConnectorDetails("common")["volumeBasedRouting"];
 | |
|       const routing_data = [
 | |
|         {
 | |
|           connector: {
 | |
|             connector: "stripe",
 | |
|             merchant_connector_id: globalState.get("stripeMcaId"),
 | |
|           },
 | |
|           split: 100,
 | |
|         },
 | |
|       ];
 | |
| 
 | |
|       cy.addRoutingConfig(
 | |
|         fixtures.routingConfigBody,
 | |
|         data,
 | |
|         "volume_split",
 | |
|         routing_data,
 | |
|         globalState
 | |
|       );
 | |
|     });
 | |
| 
 | |
|     it("retrieve-routing-call-test", () => {
 | |
|       const data = utils.getConnectorDetails("common")["volumeBasedRouting"];
 | |
| 
 | |
|       cy.retrieveRoutingConfig(data, globalState);
 | |
|     });
 | |
| 
 | |
|     it("activate-routing-call-test", () => {
 | |
|       const data = utils.getConnectorDetails("common")["volumeBasedRouting"];
 | |
| 
 | |
|       cy.activateRoutingConfig(data, globalState);
 | |
|     });
 | |
| 
 | |
|     it("payment-routing-test", () => {
 | |
|       const data =
 | |
|         utils.getConnectorDetails("stripe")["card_pm"]["No3DSAutoCapture"];
 | |
| 
 | |
|       cy.createConfirmPaymentTest(
 | |
|         fixtures.createConfirmPaymentBody,
 | |
|         data,
 | |
|         "no_three_ds",
 | |
|         "automatic",
 | |
|         globalState
 | |
|       );
 | |
|     });
 | |
| 
 | |
|     it("retrieve-payment-call-test", () => {
 | |
|       cy.retrievePaymentCallTest(globalState, null);
 | |
|     });
 | |
| 
 | |
|     it("create-payment-call-test-for-eps", () => {
 | |
|       const data =
 | |
|         utils.getConnectorDetails("stripe")["bank_redirect_pm"][
 | |
|           "PaymentIntent"
 | |
|         ];
 | |
| 
 | |
|       cy.createPaymentIntentTest(
 | |
|         fixtures.createPaymentBody,
 | |
|         data,
 | |
|         "three_ds",
 | |
|         "automatic",
 | |
|         globalState
 | |
|       );
 | |
|     });
 | |
| 
 | |
|     it("payment_methods-call-test", () => {
 | |
|       cy.paymentMethodsCallTest(globalState);
 | |
|     });
 | |
| 
 | |
|     it("Confirm bank redirect", () => {
 | |
|       const data =
 | |
|         utils.getConnectorDetails("stripe")["bank_redirect_pm"]["eps"];
 | |
| 
 | |
|       cy.confirmBankRedirectCallTest(
 | |
|         fixtures.confirmBody,
 | |
|         data,
 | |
|         true,
 | |
|         globalState
 | |
|       );
 | |
|     });
 | |
| 
 | |
|     it("Handle bank redirect redirection", () => {
 | |
|       // return_url is a static url (https://hyperswitch.io) taken from confirm-body fixture and is not updated
 | |
|       const expected_redirection = fixtures.confirmBody["return_url"];
 | |
|       const payment_method_type = globalState.get("paymentMethodType");
 | |
|       cy.handleBankRedirectRedirection(
 | |
|         globalState,
 | |
|         payment_method_type,
 | |
|         expected_redirection
 | |
|       );
 | |
|     });
 | |
|   });
 | |
| 
 | |
|   context("Volume based routing with 100% of adyen", () => {
 | |
|     before("seed global state", () => {
 | |
|       cy.task("getGlobalState").then((state) => {
 | |
|         globalState = new State(state);
 | |
|       });
 | |
|     });
 | |
| 
 | |
|     after("flush global state", () => {
 | |
|       cy.task("setGlobalState", globalState.data);
 | |
|     });
 | |
|     it("list-mca-by-mid", () => {
 | |
|       cy.ListMcaByMid(globalState);
 | |
|     });
 | |
| 
 | |
|     it("api-key-create-call-test", () => {
 | |
|       cy.apiKeyCreateTest(fixtures.apiKeyCreateBody, globalState);
 | |
|     });
 | |
| 
 | |
|     it("customer-create-call-test", () => {
 | |
|       cy.createCustomerCallTest(fixtures.customerCreateBody, globalState);
 | |
|     });
 | |
| 
 | |
|     it("add-routing-config", () => {
 | |
|       const data = utils.getConnectorDetails("common")["volumeBasedRouting"];
 | |
|       const routing_data = [
 | |
|         {
 | |
|           connector: {
 | |
|             connector: "adyen",
 | |
|             merchant_connector_id: globalState.get("adyenMcaId"),
 | |
|           },
 | |
|           split: 100,
 | |
|         },
 | |
|       ];
 | |
| 
 | |
|       cy.addRoutingConfig(
 | |
|         fixtures.routingConfigBody,
 | |
|         data,
 | |
|         "volume_split",
 | |
|         routing_data,
 | |
|         globalState
 | |
|       );
 | |
|     });
 | |
| 
 | |
|     it("retrieve-routing-call-test", () => {
 | |
|       const data = utils.getConnectorDetails("common")["volumeBasedRouting"];
 | |
| 
 | |
|       cy.retrieveRoutingConfig(data, globalState);
 | |
|     });
 | |
| 
 | |
|     it("activate-routing-call-test", () => {
 | |
|       const data = utils.getConnectorDetails("common")["volumeBasedRouting"];
 | |
| 
 | |
|       cy.activateRoutingConfig(data, globalState);
 | |
|     });
 | |
| 
 | |
|     it("payment-routing-test-for-card", () => {
 | |
|       const data =
 | |
|         utils.getConnectorDetails("adyen")["card_pm"]["No3DSAutoCapture"];
 | |
| 
 | |
|       cy.createConfirmPaymentTest(
 | |
|         fixtures.createConfirmPaymentBody,
 | |
|         data,
 | |
|         "no_three_ds",
 | |
|         "automatic",
 | |
|         globalState
 | |
|       );
 | |
|     });
 | |
| 
 | |
|     it("retrieve-payment-call-test", () => {
 | |
|       cy.retrievePaymentCallTest(globalState, null);
 | |
|     });
 | |
| 
 | |
|     it("create-payment-call-test-for-eps", () => {
 | |
|       const data =
 | |
|         utils.getConnectorDetails("adyen")["bank_redirect_pm"]["PaymentIntent"];
 | |
| 
 | |
|       cy.createPaymentIntentTest(
 | |
|         fixtures.createPaymentBody,
 | |
|         data,
 | |
|         "three_ds",
 | |
|         "automatic",
 | |
|         globalState
 | |
|       );
 | |
|     });
 | |
| 
 | |
|     it("payment_methods-call-test", () => {
 | |
|       cy.paymentMethodsCallTest(globalState);
 | |
|     });
 | |
| 
 | |
|     it("Confirm bank redirect", () => {
 | |
|       const data =
 | |
|         utils.getConnectorDetails("adyen")["bank_redirect_pm"]["eps"];
 | |
| 
 | |
|       cy.confirmBankRedirectCallTest(
 | |
|         fixtures.confirmBody,
 | |
|         data,
 | |
|         true,
 | |
|         globalState
 | |
|       );
 | |
|     });
 | |
| 
 | |
|     it("Handle bank redirect redirection", () => {
 | |
|       // return_url is a static url (https://hyperswitch.io) taken from confirm-body fixture and is not updated
 | |
|       const expected_redirection = fixtures.confirmBody["return_url"];
 | |
|       const payment_method_type = globalState.get("paymentMethodType");
 | |
|       cy.handleBankRedirectRedirection(
 | |
|         globalState,
 | |
|         payment_method_type,
 | |
|         expected_redirection
 | |
|       );
 | |
|     });
 | |
|   });
 | |
| });
 |