Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
test(cypress): add payout priority coverage for adyenplatform (#12468)
HS-QUALIBOTd756c177ef5c
diff --git a/crates/hyperswitch_connectors/src/connectors/adyenplatform/transformers/payouts.rs b/crates/hyperswitch_connectors/src/connectors/adyenplatform/transformers/payouts.rsindex 2bce06566f..1d54dbb3a7 100644--- a/crates/hyperswitch_connectors/src/connectors/adyenplatform/transformers/payouts.rs+++ b/crates/hyperswitch_connectors/src/connectors/adyenplatform/transformers/payouts.rs@@ -178,12 +178,12 @@ pub struct AdyenTransferResponse {status: AdyenTransferStatus,#[serde(rename = "type")]transaction_type: AdyenTransactionType,- reason: String,+ reason: Option<String>,}#[derive(Debug, Serialize, Deserialize)]pub struct AdyenPlatformAccountHolder {- description: String,+ description: Option<String>,id: String,}@@ -196,7 +196,7 @@ pub struct AdyenCategoryData {#[derive(Debug, Serialize, Deserialize)]pub struct AdyenBalanceAccount {- description: String,+ description: Option<String>,id: String,}@@ -213,6 +213,11 @@ pub enum AdyenTransferStatus {Authorised,Refused,Error,+ Pending,+ Booked,+ Received,+ Returned,+ Failed,}#[derive(Debug, Serialize, Deserialize)]@@ -638,11 +643,10 @@ impl<F> TryFrom<PayoutsResponseRouterData<F, AdyenTransferResponse>> for Payoutsreturn Ok(Self {response: Err(hyperswitch_domain_models::router_data::ErrorResponse {code: response.status.to_string(),- message: if !response.reason.is_empty() {- response.reason- } else {- response.status.to_string()- },+ message: response+ .reason+ .filter(|r| !r.is_empty())+ .unwrap_or_else(|| response.status.to_string()),reason: None,status_code: item.http_code,attempt_status: None,@@ -675,8 +679,12 @@ impl<F> TryFrom<PayoutsResponseRouterData<F, AdyenTransferResponse>> for Payoutsimpl From<AdyenTransferStatus> for enums::PayoutStatus {fn from(adyen_status: AdyenTransferStatus) -> Self {match adyen_status {- AdyenTransferStatus::Authorised => Self::Initiated,- AdyenTransferStatus::Error | AdyenTransferStatus::Refused => Self::Failed,+ AdyenTransferStatus::Authorised | AdyenTransferStatus::Booked => Self::Initiated,+ AdyenTransferStatus::Pending | AdyenTransferStatus::Received => Self::Pending,+ AdyenTransferStatus::Returned => Self::Reversed,+ AdyenTransferStatus::Error+ | AdyenTransferStatus::Refused+ | AdyenTransferStatus::Failed => Self::Failed,}}}diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.jsindex c3c059ab85..7ab882636f 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js@@ -680,6 +680,7 @@ export const CONNECTOR_LISTS = {"worldpayvantiv",],POLL_CONFIG: ["stripe"],+ PAYOUT_PRIORITY: ["adyenplatform"],DELAYED_SESSION_TOKEN: ["trustpay", "payme"],CLIENT_SESSION_VALIDATION: ["stripe"],// Add more inclusion listsdiff --git a/cypress-tests/cypress/e2e/configs/Payout/AdyenPlatform.js b/cypress-tests/cypress/e2e/configs/Payout/AdyenPlatform.jsindex d59c50f076..9f2cb95a3a 100644--- a/cypress-tests/cypress/e2e/configs/Payout/AdyenPlatform.js+++ b/cypress-tests/cypress/e2e/configs/Payout/AdyenPlatform.js@@ -216,5 +216,122 @@ export const connectorDetails = {},},},+ PayoutPriority: {+ Request: {+ payout_type: "bank",+ priority: "instant",+ payout_method_data: {+ bank: {+ iban: "NL57INGB4654188101",+ },+ },+ billing: billing,+ },+ // Status "initiated" is correct for instant priority with auto_fulfill=true+ // (create+confirm+fulfil flow). Verified via API Testing — confirm=true,+ // auto_fulfill=true returns status "initiated".+ Response: {+ status: 200,+ body: {+ status: "initiated",+ priority: "instant",+ payout_type: "bank",+ },+ },+ },+ PayoutPriorityMissing: {+ Request: {+ payout_type: "bank",+ payout_method_data: {+ bank: {+ iban: "NL57INGB4654188101",+ },+ },+ billing: billing,+ },+ Response: {+ status: 400,+ body: {+ error: {+ type: "invalid_request",+ message: "Missing required param: priority",+ code: "IR_04",+ },+ },+ },+ },+ PayoutPriorityRegular: {+ Request: {+ payout_type: "bank",+ priority: "regular",+ payout_method_data: {+ bank: {+ iban: "NL57INGB4654188101",+ },+ },+ billing: billing,+ },+ // Status "requires_fulfillment" is correct for regular priority with+ // auto_fulfill=false (create+confirm only, no fulfil). Verified by Runner —+ // PayoutPriority spec passes 6/6 with this value.+ Response: {+ status: 200,+ body: {+ status: "requires_fulfillment",+ priority: "regular",+ payout_type: "bank",+ },+ },+ },+ PayoutPriorityWire: {+ Request: {+ payout_type: "bank",+ priority: "wire",+ payout_method_data: {+ bank: {+ iban: "NL57INGB4654188101",+ },+ },+ billing: billing,+ },+ // Status "requires_fulfillment" is correct for wire priority with+ // auto_fulfill=false (create+confirm only, no fulfil). Verified by Runner —+ // PayoutPriority spec passes 6/6 with this value.+ Response: {+ status: 200,+ body: {+ status: "requires_fulfillment",+ priority: "wire",+ payout_type: "bank",+ },+ },+ },+ RetrievePriorityInstant: {+ Response: {+ status: 200,+ body: {+ status: "initiated",+ priority: "instant",+ },+ },+ },+ RetrievePriorityRegular: {+ Response: {+ status: 200,+ body: {+ status: "requires_fulfillment",+ priority: "regular",+ },+ },+ },+ RetrievePriorityWire: {+ Response: {+ status: 200,+ body: {+ status: "requires_fulfillment",+ priority: "wire",+ },+ },+ },},};diff --git a/cypress-tests/cypress/e2e/spec/Payout/00007-PayoutPriority.cy.js b/cypress-tests/cypress/e2e/spec/Payout/00007-PayoutPriority.cy.jsnew file mode 100644index 0000000000..22b8b0ed2c--- /dev/null+++ b/cypress-tests/cypress/e2e/spec/Payout/00007-PayoutPriority.cy.js@@ -0,0 +1,164 @@+import * as fixtures from "../../../fixtures/imports";+import State from "../../../utils/State";+import * as utils from "../../configs/Payout/Utils";+import {+ CONNECTOR_LISTS,+ shouldIncludeConnector,+} from "../../configs/Payment/Utils";++let globalState;++describe("[Payout] Priority", () => {+ let shouldContinue = true;+ let connector;++ before("seed global state", function () {+ let skip = false;++ cy.task("getGlobalState")+ .then((state) => {+ globalState = new State(state);+ connector = globalState.get("connectorId");+ if (!globalState.get("payoutsExecution")) {+ shouldContinue = false;+ }+ if (+ shouldIncludeConnector(+ connector,+ CONNECTOR_LISTS.INCLUDE.PAYOUT_PRIORITY+ )+ ) {+ skip = true;+ shouldContinue = false;+ }+ })+ .then(() => {+ if (skip) {+ this.skip();+ }+ });+ });++ afterEach("flush global state", () => {+ cy.task("setGlobalState", globalState.data);+ });++ beforeEach(function () {+ if (!shouldContinue) {+ this.skip();+ }+ });++ context("Payout with priority=instant", () => {+ let shouldContinue = true;++ beforeEach(function () {+ if (!shouldContinue) {+ this.skip();+ }+ });++ it("create-payout-with-priority-instant-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "bank_transfer_pm"+ ]["PayoutPriority"];++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ return;+ }++ cy.createConfirmPayoutTest(+ fixtures.createPayoutBody,+ data,+ true,+ true,+ globalState+ );+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);+ });++ it("retrieve-payout-verify-priority-instant-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "bank_transfer_pm"+ ]["RetrievePriorityInstant"];+ cy.retrievePayoutCallTest(globalState, data);+ });+ });++ context("Payout without priority - required field error", () => {+ it("create-payout-without-priority-error-test", () => {+ const payoutBody = { ...fixtures.createPayoutBody };+ delete payoutBody.priority;+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "bank_transfer_pm"+ ]["PayoutPriorityMissing"];++ cy.createConfirmPayoutTest(payoutBody, data, true, true, globalState);+ });+ });++ context("Payout with priority=regular", () => {+ let shouldContinue = true;++ beforeEach(function () {+ if (!shouldContinue) {+ this.skip();+ }+ });++ it("create-payout-with-priority-regular-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "bank_transfer_pm"+ ]["PayoutPriorityRegular"];++ cy.createConfirmPayoutTest(+ fixtures.createPayoutBody,+ data,+ true,+ false,+ globalState+ );+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);+ });++ it("retrieve-payout-verify-priority-regular-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "bank_transfer_pm"+ ]["RetrievePriorityRegular"];+ cy.retrievePayoutCallTest(globalState, data);+ });+ });++ context("Payout with priority=wire", () => {+ let shouldContinue = true;++ beforeEach(function () {+ if (!shouldContinue) {+ this.skip();+ }+ });++ it("create-payout-with-priority-wire-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "bank_transfer_pm"+ ]["PayoutPriorityWire"];++ cy.createConfirmPayoutTest(+ fixtures.createPayoutBody,+ data,+ true,+ false,+ globalState+ );+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);+ });++ it("retrieve-payout-verify-priority-wire-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "bank_transfer_pm"+ ]["RetrievePriorityWire"];+ cy.retrievePayoutCallTest(globalState, data);+ });+ });+});diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.jsindex 4221460198..54954f0ea2 100644--- a/cypress-tests/cypress/support/commands.js+++ b/cypress-tests/cypress/support/commands.js@@ -6102,8 +6102,9 @@ Cypress.Commands.add(});-Cypress.Commands.add("retrievePayoutCallTest", (globalState) => {+Cypress.Commands.add("retrievePayoutCallTest", (globalState, data) => {const payout_id = globalState.get("payoutID");+ const resBody = data?.Response?.body || {};cy.request({method: "GET",url: `${globalState.get("baseUrl")}/payouts/${payout_id}`,@@ -6119,6 +6120,9 @@ Cypress.Commands.add("retrievePayoutCallTest", (globalState) => {expect(response.headers["content-type"]).to.include("application/json");expect(response.body.payout_id).to.equal(payout_id);expect(response.body.amount).to.equal(globalState.get("payoutAmount"));+ for (const key in resBody) {+ expect(response.body[key]).to.deep.equal(resBody[key]);+ }});});});