Skip to content

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

fix(payouts): restrict confirmation to API key auth (#15180)

Sakil Mostak6eb31aa2f9ae
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.json
index c0f0bbb604..d93e390c4a 100644
--- a/api-reference/v1/openapi_spec_v1.json
+++ b/api-reference/v1/openapi_spec_v1.json
@@ -40200,9 +40200,6 @@
},
"PayoutConfirmRequest": {
"type": "object",
- "required": [
- "client_secret"
- ],
"properties": {
"merchant_order_reference_id": {
"type": "string",
@@ -40302,10 +40299,6 @@
],
"nullable": true
},
- "client_secret": {
- "type": "string",
- "description": "It's a token used for client side verification."
- },
"return_url": {
"type": "string",
"description": "The URL to redirect after the completion of the operation",
@@ -40397,7 +40390,7 @@
"session_expiry": {
"type": "integer",
"format": "int32",
- "description": "Will be used to expire client secret after certain amount of time to be supplied in seconds\n(900) for 15 mins",
+ "description": "Lifetime of the payout link in seconds, for example 900 for 15 minutes.",
"example": 900,
"nullable": true,
"minimum": 0
@@ -40631,7 +40624,7 @@
},
"client_secret": {
"type": "string",
- "description": "It's a token used for client side verification.",
+ "description": "Legacy client secret retained for compatibility. Payout execution requires an API key.",
"example": "pay_U42c409qyHwOkWo3vK60_secret_el9ksDkiB8hi6j9N78yo"
},
"return_url": {
@@ -41401,12 +41394,6 @@
],
"nullable": true
},
- "client_secret": {
- "type": "string",
- "description": "It's a token used for client side verification.",
- "example": "pay_U42c409qyHwOkWo3vK60_secret_el9ksDkiB8hi6j9N78yo",
- "nullable": true
- },
"return_url": {
"type": "string",
"description": "The URL to redirect after the completion of the operation",
@@ -41498,7 +41485,7 @@
"session_expiry": {
"type": "integer",
"format": "int32",
- "description": "Will be used to expire client secret after certain amount of time to be supplied in seconds\n(900) for 15 mins",
+ "description": "Lifetime of the payout link in seconds, for example 900 for 15 minutes.",
"example": 900,
"nullable": true,
"minimum": 0
@@ -41762,7 +41749,7 @@
"session_expiry": {
"type": "integer",
"format": "int32",
- "description": "Will be used to expire client secret after certain amount of time to be supplied in seconds\n(900) for 15 mins",
+ "description": "Lifetime of the payout link in seconds, for example 900 for 15 minutes.",
"example": 900,
"nullable": true,
"minimum": 0
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.json
index 8bf18ada2f..ae6b2fa24c 100644
--- a/api-reference/v2/openapi_spec_v2.json
+++ b/api-reference/v2/openapi_spec_v2.json
@@ -28318,7 +28318,8 @@
},
"client_secret": {
"type": "string",
- "description": "It's a token used for client side verification.",
+ "description": "Deprecated. Payout execution requires an API key; this value is not used for authentication.",
+ "deprecated": true,
"example": "pay_U42c409qyHwOkWo3vK60_secret_el9ksDkiB8hi6j9N78yo",
"nullable": true
},
@@ -28413,7 +28414,7 @@
"session_expiry": {
"type": "integer",
"format": "int32",
- "description": "Will be used to expire client secret after certain amount of time to be supplied in seconds\n(900) for 15 mins",
+ "description": "Lifetime of the payout link in seconds, for example 900 for 15 minutes.",
"example": 900,
"nullable": true,
"minimum": 0
@@ -28574,7 +28575,7 @@
},
"client_secret": {
"type": "string",
- "description": "It's a token used for client side verification.",
+ "description": "Legacy client secret retained for compatibility. Payout execution requires an API key.",
"example": "pay_U42c409qyHwOkWo3vK60_secret_el9ksDkiB8hi6j9N78yo"
},
"return_url": {
diff --git a/crates/api_models/src/payouts.rs b/crates/api_models/src/payouts.rs
index b2c174df97..54884af40c 100644
--- a/crates/api_models/src/payouts.rs
+++ b/crates/api_models/src/payouts.rs
@@ -126,10 +126,9 @@ pub struct PayoutCreateRequest {
#[schema(value_type = Option<CustomerDetails>)]
pub customer: Option<payments::CustomerDetails>,
- /// It's a token used for client side verification.
- #[schema(value_type = Option<String>, example = "pay_U42c409qyHwOkWo3vK60_secret_el9ksDkiB8hi6j9N78yo")]
- #[remove_in(PayoutsCreateRequest)]
- #[mandatory_in(PayoutConfirmRequest = String)]
+ /// Deprecated. Payout execution requires an API key; this value is not used for authentication.
+ #[schema(deprecated, value_type = Option<String>, example = "pay_U42c409qyHwOkWo3vK60_secret_el9ksDkiB8hi6j9N78yo")]
+ #[remove_in(PayoutsCreateRequest, PayoutUpdateRequest, PayoutConfirmRequest)]
pub client_secret: Option<String>,
/// The URL to redirect after the completion of the operation
@@ -184,8 +183,7 @@ pub struct PayoutCreateRequest {
#[schema(value_type = Option<PayoutCreatePayoutLinkConfig>)]
pub payout_link_config: Option<PayoutCreatePayoutLinkConfig>,
- /// Will be used to expire client secret after certain amount of time to be supplied in seconds
- /// (900) for 15 mins
+ /// Lifetime of the payout link in seconds, for example 900 for 15 minutes.
#[schema(value_type = Option<u32>, example = 900)]
pub session_expiry: Option<u32>,
@@ -938,7 +936,7 @@ pub struct PayoutCreateResponse {
#[schema(value_type = Option<CustomerDetailsResponse>)]
pub customer: Option<payments::CustomerDetailsResponse>,
- /// It's a token used for client side verification.
+ /// Legacy client secret retained for compatibility. Payout execution requires an API key.
#[schema(value_type = String, example = "pay_U42c409qyHwOkWo3vK60_secret_el9ksDkiB8hi6j9N78yo")]
pub client_secret: Option<String>,
diff --git a/crates/router/src/core/payouts.rs b/crates/router/src/core/payouts.rs
index f12b0e5090..dcd84280f3 100644
--- a/crates/router/src/core/payouts.rs
+++ b/crates/router/src/core/payouts.rs
@@ -3804,24 +3804,6 @@ pub async fn make_payout_data(
todo!()
}
-#[cfg(feature = "v1")]
-fn authenticate_payout_client_secret(
- request_client_secret: Option<&str>,
- stored_client_secret: Option<&str>,
-) -> Result<(), errors::ApiErrorResponse> {
- match request_client_secret {
- Some(request_client_secret)
- if stored_client_secret.is_some_and(|secret| secret == request_client_secret) =>
- {
- Ok(())
- }
- Some(_) => Err(errors::ApiErrorResponse::ClientSecretInvalid),
- // Merchant-authenticated requests do not carry a client secret. Client-authenticated
- // requests are required to provide one before reaching this validation.
- None => Ok(()),
- }
-}
-
#[cfg(feature = "v1")]
pub async fn make_payout_data(
state: &SessionState,
@@ -3883,13 +3865,6 @@ pub async fn make_payout_data(
.await
.to_not_found_response(errors::ApiErrorResponse::PayoutNotFound)?;
- if let payouts::PayoutRequest::PayoutCreateRequest(request) = req {
- authenticate_payout_client_secret(
- request.client_secret.as_deref(),
- payouts.client_secret.as_deref(),
- )?;
- }
-
core_utils::validate_profile_id_from_auth_layer(auth_profile_id, &payouts)?;
if let payouts::PayoutRequest::PayoutCreateRequest(request) = req {
diff --git a/crates/router/src/routes/payouts.rs b/crates/router/src/routes/payouts.rs
index e520f0ed13..43cedfb0ca 100644
--- a/crates/router/src/routes/payouts.rs
+++ b/crates/router/src/routes/payouts.rs
@@ -11,19 +11,17 @@ use hyperswitch_domain_models::payments::HeaderPayload;
use router_env::{instrument, tracing, Flow};
use super::app::AppState;
+#[cfg(any(feature = "olap", feature = "v1"))]
+use crate::services::authorization::permissions::Permission;
use crate::{
core::{
api_locking::{self, GetLockingInput},
- errors::{self, RouterResult},
+ errors::RouterResult,
payouts::*,
},
logger,
routes::lock_utils,
- services::{
- api,
- authentication::{self as auth},
- authorization::permissions::Permission,
- },
+ services::{api, authentication as auth},
types::{api::payouts as payout_types, transformers::ForeignTryFrom},
};
@@ -197,30 +195,6 @@ pub async fn payouts_confirm(
tracing::Span::current().record("payout_id", payout_id.get_string_repr());
payload.payout_id = Some(payout_id);
payload.confirm = Some(true);
- let api_auth = auth::ApiKeyAuth::default();
-
- let (auth_type, auth_flow) = {
- #[cfg(feature = "v1")]
- {
- match auth::check_sdk_auth_and_get_auth(req.headers(), &payload, api_auth) {
- Ok(auth) => auth,
- Err(e) => return api::log_and_return_error_response(e),
- }
- }
- #[cfg(feature = "v2")]
- {
- match auth::check_client_secret_and_get_auth(req.headers(), &payload, api_auth) {
- Ok(auth) => auth,
- Err(e) => return api::log_and_return_error_response(e),
- }
- }
- };
-
- if auth_flow == api::AuthFlow::Client {
- if let Err(err) = validate_client_payout_confirm_request(&payload) {
- return api::log_and_return_error_response(err);
- }
- }
let header_payload = match HeaderPayload::foreign_try_from(req.headers()) {
Ok(headers) => headers,
@@ -235,14 +209,8 @@ pub async fn payouts_confirm(
state,
&req,
payload,
- |state, auth, mut req, _| {
+ |state, auth: auth::AuthenticationData, req, _| {
let profile_id = get_authenticated_profile_id(&auth);
-
- #[cfg(feature = "v1")]
- if let Some(client_secret) = auth.client_secret {
- req.client_secret = Some(client_secret);
- }
-
payouts_confirm_core(
state,
auth.platform,
@@ -251,39 +219,15 @@ pub async fn payouts_confirm(
header_payload.clone(),
)
},
- &*auth_type,
+ &auth::HeaderAuth(auth::ApiKeyAuth {
+ allow_connected_scope_operation: false,
+ allow_platform_self_operation: false,
+ }),
locking_action,
))
.await
}
-fn validate_client_payout_confirm_request(
- payload: &payout_types::PayoutCreateRequest,
-) -> RouterResult<()> {
- let merchant_owned_fields = [
- payload.amount.is_some().then_some("amount"),
- payload.auto_fulfill.is_some().then_some("auto_fulfill"),
- payload.currency.is_some().then_some("currency"),
- payload.connector.is_some().then_some("connector"),
- payload.routing.is_some().then_some("routing"),
- ]
- .into_iter()
- .flatten()
- .collect::<Vec<_>>();
-
- if merchant_owned_fields.is_empty() {
- Ok(())
- } else {
- Err(errors::ApiErrorResponse::InvalidRequestData {
- message: format!(
- "The following fields cannot be provided for client-authenticated payout confirmation: {}",
- merchant_owned_fields.join(", ")
- ),
- }
- .into())
- }
-}
-
/// Payouts - Cancel
#[instrument(skip_all, fields(flow = ?Flow::PayoutsCancel))]
pub async fn payouts_cancel(
diff --git a/crates/router/src/services/authentication.rs b/crates/router/src/services/authentication.rs
index 56661d5e16..6761a3eb7b 100644
--- a/crates/router/src/services/authentication.rs
+++ b/crates/router/src/services/authentication.rs
@@ -6,8 +6,6 @@ use api_models::payment_methods::PaymentMethodIntentConfirm;
#[cfg(feature = "v1")]
use api_models::payment_methods::{PaymentMethodCreate, PaymentMethodListRequest};
use api_models::payments;
-#[cfg(feature = "payouts")]
-use api_models::payouts;
use async_trait::async_trait;
use base64::Engine;
use common_enums::{MerchantAccountType, TokenPurpose};
@@ -5833,13 +5831,6 @@ where
pub trait ClientSecretFetch {
fn get_client_secret(&self) -> Option<&String>;
}
-#[cfg(feature = "payouts")]
-impl ClientSecretFetch for payouts::PayoutCreateRequest {
- fn get_client_secret(&self) -> Option<&String> {
- self.client_secret.as_ref()
- }
-}
-
#[cfg(feature = "v1")]
impl ClientSecretFetch for payments::PaymentsRequest {
fn get_client_secret(&self) -> Option<&String> {
diff --git a/cypress-tests/cypress/e2e/configs/Payout/Commons.js b/cypress-tests/cypress/e2e/configs/Payout/Commons.js
index 68420b5478..a5ce9556fd 100644
--- a/cypress-tests/cypress/e2e/configs/Payout/Commons.js
+++ b/cypress-tests/cypress/e2e/configs/Payout/Commons.js
@@ -32,6 +32,17 @@ const billing = {
},
};
+const clientAuthRejection = {
+ status: 401,
+ body: {
+ error: {
+ type: "invalid_request",
+ message: "API key not provided or invalid API key used",
+ code: "IR_01",
+ },
+ },
+};
+
export const connectorDetails = {
card_pm: {
Create: getCustomExchange({
@@ -305,14 +316,8 @@ export const connectorDetails = {
}),
},
wallet_pm: {
- // Cross-connector skeleton for wallet payouts. Wallet payouts are only
- // supported by wallet-capable payout connectors, so the connector-driven
- // success keys (Create / ConfirmMerchantAuth / ConfirmClientAuth /
- // RetrieveAfterConfirm) default to the 501 not-implemented response —
- // connectors override them with their real responses. The client-auth
- // restricted-field validations are enforced by the router before the
- // payout state is loaded or mutated, so their error envelopes are
- // connector-agnostic and shared here as the default.
+ // Wallet connectors override create/merchant-confirm success responses.
+ // Publishable-key confirmation is rejected before payout processing.
Create: getCustomExchange({
Request: {
payout_type: "wallet",
@@ -323,17 +328,7 @@ export const connectorDetails = {
amount: 10000,
payout_type: "wallet",
},
- Response: {
- status: 422,
- body: {
- error: {
- type: "invalid_request",
- message:
- "The following fields cannot be provided for client-authenticated payout confirmation: amount",
- code: "IR_06",
- },
- },
- },
+ Response: clientAuthRejection,
}),
ConfirmClientAuthMultipleRestrictedFields: getCustomExchange({
Request: {
@@ -342,17 +337,7 @@ export const connectorDetails = {
auto_fulfill: false,
payout_type: "wallet",
},
- Response: {
- status: 422,
- body: {
- error: {
- type: "invalid_request",
- message:
- "The following fields cannot be provided for client-authenticated payout confirmation: amount, auto_fulfill, currency",
- code: "IR_06",
- },
- },
- },
+ Response: clientAuthRejection,
}),
ConfirmClientAuthMissingClientSecret: getCustomExchange({
Request: {
@@ -360,16 +345,7 @@ export const connectorDetails = {
amount: 10000,
payout_type: "wallet",
},
- Response: {
- status: 400,
- body: {
- error: {
- type: "invalid_request",
- message: "Missing required param: client_secret",
- code: "IR_04",
- },
- },
- },
+ Response: clientAuthRejection,
}),
ConfirmMerchantAuth: getCustomExchange({
Request: {
@@ -381,6 +357,7 @@ export const connectorDetails = {
Request: {
payout_type: "wallet",
},
+ Response: clientAuthRejection,
}),
RetrieveAfterClientAuthErrors: getCustomExchange({
Response: {
diff --git a/cypress-tests/cypress/e2e/configs/Payout/Paypal.js b/cypress-tests/cypress/e2e/configs/Payout/Paypal.js
index 4ce1c64f05..b4694c798d 100644
--- a/cypress-tests/cypress/e2e/configs/Payout/Paypal.js
+++ b/cypress-tests/cypress/e2e/configs/Payout/Paypal.js
@@ -2,6 +2,17 @@ const wallet_data = {
telephone_number: "16608213349",
};
+const clientAuthRejection = {
+ status: 401,
+ body: {
+ error: {
+ type: "invalid_request",
+ message: "API key not provided or invalid API key used",
+ code: "IR_01",
+ },
+ },
+};
+
export const connectorDetails = {
wallet_pm: {
Create: {
@@ -33,13 +44,7 @@ export const connectorDetails = {
},
},
},
- Response: {
- status: 200,
- body: {
- status: "pending",
- payout_type: "wallet",
- },
- },
+ Response: clientAuthRejection,
},
ConfirmClientAuthRestrictedFields: {
Request: {
@@ -51,17 +56,7 @@ export const connectorDetails = {
},
},
},
- Response: {
- status: 422,
- body: {
- error: {
- type: "invalid_request",
- message:
- "The following fields cannot be provided for client-authenticated payout confirmation: amount",
- code: "IR_06",
- },
- },
- },
+ Response: clientAuthRejection,
},
ConfirmClientAuthMultipleRestrictedFields: {
Request: {
@@ -75,17 +70,7 @@ export const connectorDetails = {
},
},
},
- Response: {
- status: 422,
- body: {
- error: {
- type: "invalid_request",
- message:
- "The following fields cannot be provided for client-authenticated payout confirmation: amount, auto_fulfill, currency",
- code: "IR_06",
- },
- },
- },
+ Response: clientAuthRejection,
},
ConfirmClientAuthMissingClientSecret: {
Request: {
@@ -98,16 +83,7 @@ export const connectorDetails = {
},
},
},
- Response: {
- status: 400,
- body: {
- error: {
- type: "invalid_request",
- message: "Missing required param: client_secret",
- code: "IR_04",
- },
- },
- },
+ Response: clientAuthRejection,
},
ConfirmMerchantAuth: {
Request: {
diff --git a/cypress-tests/cypress/e2e/configs/Payout/Utils.js b/cypress-tests/cypress/e2e/configs/Payout/Utils.js
index adaab8f093..ef92f3479c 100644
--- a/cypress-tests/cypress/e2e/configs/Payout/Utils.js
+++ b/cypress-tests/cypress/e2e/configs/Payout/Utils.js
@@ -115,9 +115,6 @@ export const CONNECTOR_LISTS = {
// Payout recurring feature - only verified connectors
PAYOUT_RECURRING: ["adyenplatform"],
PAYOUT_LINK: ["wise"],
- // Client-authenticated payout confirm (PR #14547) - only verified
- // connectors
- CLIENT_AUTH_CONFIRM: ["paypal"],
WALLET_PAYOUT: ["paypal"],
BANK_TRANSFER_OPEN_BANKING: ["truelayer", "trustly"],
BANK_TRANSFER_OPEN_BANKING_INVALID_REFERENCE_FULFILL: [],
diff --git a/cypress-tests/cypress/e2e/spec/Payout/00009-ClientAuthPayoutConfirm.cy.js b/cypress-tests/cypress/e2e/spec/Payout/00009-ClientAuthPayoutConfirm.cy.js
index 9f2e6b4c97..afd0b02b83 100644
--- a/cypress-tests/cypress/e2e/spec/Payout/00009-ClientAuthPayoutConfirm.cy.js
+++ b/cypress-tests/cypress/e2e/spec/Payout/00009-ClientAuthPayoutConfirm.cy.js
@@ -5,24 +5,47 @@ import * as utils from "../../configs/Payout/Utils";
let globalState;
let payoutBody;
-describe("[Payout] Client Auth Confirm", () => {
- let shouldContinue = true; // variable that will be used to skip tests if a previous test fails
+const executionEndpoints = [
+ { name: "create", method: "POST", path: "/create" },
+ { name: "update", method: "PUT", path: "" },
+ { name: "confirm", method: "POST", path: "/confirm" },
+ { name: "cancel", method: "POST", path: "/cancel" },
+ { name: "fulfill", method: "POST", path: "/fulfill" },
+];
+
+const retrievalEndpoints = [
+ { name: "retrieve" },
+ { name: "sync", qs: { force_sync: true } },
+];
+
+// An invalid JWT is sufficient to distinguish the auth paths: execution must
+// report the missing API key (IR_01), while retrieve and dashboard APIs validate JWTs.
+const invalidJwt = "payout-execution-auth-regression";
+
+function getAuthHeaders(authMode) {
+ switch (authMode) {
+ case "publishable-key":
+ return { "api-key": globalState.get("publishableKey") };
+ case "jwt":
+ return { Authorization: `Bearer ${invalidJwt}` };
+ case "sdk":
+ return {
+ Authorization: btoa(
+ `profile_id=${globalState.get("profileId")},publishable_key=${globalState.get("publishableKey")},client_secret=${globalState.get("payoutClientSecret") || "payout_client_secret"}`
+ ),
+ };
+ default:
+ return {};
+ }
+}
+
+describe("[Payout] Execution Authentication", () => {
+ let shouldContinue = true;
before("seed global state", () => {
cy.task("getGlobalState").then((state) => {
globalState = new State(state);
-
- if (!globalState.get("payoutsExecution")) {
- shouldContinue = false;
- }
-
- if (
- !utils.CONNECTOR_LISTS.INCLUDE.CLIENT_AUTH_CONFIRM.includes(
- globalState.get("connectorId")
- )
- ) {
- shouldContinue = false;
- }
+ shouldContinue = Boolean(globalState.get("payoutsExecution"));
});
});
@@ -37,106 +60,166 @@ describe("[Payout] Client Auth Confirm", () => {
payoutBody = Cypress._.cloneDeep(fixtures.createPayoutBody);
});
- context("[Payout] Client Auth Confirm - Restricted Fields", () => {
- let shouldContinue = true; // variable that will be used to skip tests if a previous test fails
-
- beforeEach(function () {
- if (!shouldContinue) {
- this.skip();
- }
- });
-
- it("create-payout-for-client-auth-confirm-test", () => {
- const data = utils.getConnectorDetails(globalState.get("connectorId"))[
- "wallet_pm"
- ]["Create"];
-
- cy.createConfirmPayoutTest(payoutBody, data, false, true, globalState);
- if (shouldContinue) shouldContinue = utils.should_continue_further(data);
- });
-
- it("client-auth-confirm-with-restricted-field-test", () => {
- const data = utils.getConnectorDetails(globalState.get("connectorId"))[
- "wallet_pm"
- ]["ConfirmClientAuthRestrictedFields"];
-
- cy.confirmPayoutCallTest({}, data, true, globalState);
- });
-
- it("client-auth-confirm-with-multiple-restricted-fields-test", () => {
- const data = utils.getConnectorDetails(globalState.get("connectorId"))[
- "wallet_pm"
- ]["ConfirmClientAuthMultipleRestrictedFields"];
-
- cy.confirmPayoutCallTest({}, data, true, globalState);
- });
-
- it("client-auth-confirm-without-client-secret-test", () => {
- const data = utils.getConnectorDetails(globalState.get("connectorId"))[
- "wallet_pm"
- ]["ConfirmClientAuthMissingClientSecret"];
-
- cy.confirmPayoutCallTest({}, data, true, globalState);
- });
-
- it("retrieve-payout-after-client-auth-errors-test", () => {
- const data = utils.getConnectorDetails(globalState.get("connectorId"))[
- "wallet_pm"
- ]["RetrieveAfterClientAuthErrors"];
-
- cy.retrievePayoutCallTest(globalState, data);
- });
-
- it("merchant-auth-confirm-with-restricted-fields-test", () => {
- const data = utils.getConnectorDetails(globalState.get("connectorId"))[
- "wallet_pm"
- ]["ConfirmMerchantAuth"];
-
- cy.confirmPayoutCallTest({}, data, false, globalState);
- });
-
- it("retrieve-payout-after-merchant-auth-confirm-test", () => {
- const data = utils.getConnectorDetails(globalState.get("connectorId"))[
- "wallet_pm"
- ]["RetrieveAfterConfirm"];
-
- cy.retrievePayoutCallTest(globalState, data);
+ context("[Payout] Execution requires an API key", () => {
+ ["publishable-key", "jwt", "sdk", "no-credentials"].forEach((authMode) => {
+ executionEndpoints.forEach((endpoint) => {
+ it(`rejects-${authMode}-on-${endpoint.name}`, () => {
+ const payoutId =
+ globalState.get("payoutID") || "payout_auth_scope_regression";
+ const path =
+ endpoint.name === "create"
+ ? endpoint.path
+ : `/${payoutId}${endpoint.path}`;
+
+ cy.request({
+ method: endpoint.method,
+ url: `${globalState.get("baseUrl")}/payouts${path}`,
+ headers: {
+ "Content-Type": "application/json",
+ ...getAuthHeaders(authMode),
+ },
+ qs: endpoint.qs,
+ body:
+ endpoint.method === "GET"
+ ? undefined
+ : {
+ ...payoutBody,
+ confirm: false,
+ client_secret:
+ globalState.get("payoutClientSecret") ||
+ "payout_client_secret",
+ },
+ failOnStatusCode: false,
+ }).then((response) => {
+ expect(response.status).to.equal(401);
+ expect(response.body.error.code).to.equal("IR_01");
+ expect(response.body.error.message).to.equal(
+ "API key not provided or invalid API key used"
+ );
+ });
+ });
+ });
});
});
- context("[Payout] Client Auth Confirm - Valid Request", () => {
- let shouldContinue = true; // variable that will be used to skip tests if a previous test fails
-
- beforeEach(function () {
- if (!shouldContinue) {
- this.skip();
- }
+ context("[Payout] Retrieve keeps API-key and JWT authentication", () => {
+ retrievalEndpoints.forEach((endpoint) => {
+ it(`validates-jwt-on-${endpoint.name}`, () => {
+ const payoutId =
+ globalState.get("payoutID") || "payout_auth_scope_regression";
+
+ cy.request({
+ method: "GET",
+ url: `${globalState.get("baseUrl")}/payouts/${payoutId}`,
+ headers: getAuthHeaders("jwt"),
+ qs: endpoint.qs,
+ failOnStatusCode: false,
+ }).then((response) => {
+ expect(response.status).to.equal(401);
+ expect(response.body.error.code).to.equal("IR_17");
+ });
+ });
+
+ ["publishable-key", "sdk", "no-credentials"].forEach((authMode) => {
+ it(`rejects-${authMode}-on-${endpoint.name}`, () => {
+ const payoutId =
+ globalState.get("payoutID") || "payout_auth_scope_regression";
+
+ cy.request({
+ method: "GET",
+ url: `${globalState.get("baseUrl")}/payouts/${payoutId}`,
+ headers: getAuthHeaders(authMode),
+ qs: endpoint.qs,
+ failOnStatusCode: false,
+ }).then((response) => {
+ expect(response.status).to.equal(401);
+ expect(response.body.error.code).to.equal("IR_01");
+ expect(response.body.error.message).to.equal(
+ "API key not provided or invalid API key used"
+ );
+ });
+ });
+ });
});
+ });
- it("create-payout-for-client-auth-confirm-test", () => {
- const data = utils.getConnectorDetails(globalState.get("connectorId"))[
- "wallet_pm"
- ]["Create"];
-
- cy.createConfirmPayoutTest(payoutBody, data, false, true, globalState);
- if (shouldContinue) shouldContinue = utils.should_continue_further(data);
- });
-
- it("client-auth-confirm-test", () => {
- const data = utils.getConnectorDetails(globalState.get("connectorId"))[
- "wallet_pm"
- ]["ConfirmClientAuth"];
-
- cy.confirmPayoutCallTest({}, data, true, globalState);
- if (shouldContinue) shouldContinue = utils.should_continue_further(data);
- });
-
- it("retrieve-payout-after-client-auth-confirm-test", () => {
- const data = utils.getConnectorDetails(globalState.get("connectorId"))[
- "wallet_pm"
- ]["RetrieveAfterConfirm"];
-
- cy.retrievePayoutCallTest(globalState, data);
+ context("[Payout] Dashboard keeps JWT authentication", () => {
+ ["/list", "/v2/filter"].forEach((path) => {
+ it(`validates-jwt-on-${path}`, () => {
+ cy.request({
+ method: "GET",
+ url: `${globalState.get("baseUrl")}/payouts${path}`,
+ headers: getAuthHeaders("jwt"),
+ failOnStatusCode: false,
+ }).then((response) => {
+ expect(response.status).to.equal(401);
+ expect(response.body.error.code).to.equal("IR_17");
+ });
+ });
});
});
+
+ context(
+ "[Payout] Confirm rejects client auth and accepts merchant auth",
+ () => {
+ beforeEach(function () {
+ if (
+ !utils.CONNECTOR_LISTS.INCLUDE.WALLET_PAYOUT.includes(
+ globalState.get("connectorId")
+ )
+ ) {
+ this.skip();
+ }
+ });
+
+ it("create-payout-for-auth-confirm-test", () => {
+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[
+ "wallet_pm"
+ ]["Create"];
+
+ cy.createConfirmPayoutTest(payoutBody, data, false, true, globalState);
+ if (shouldContinue)
+ shouldContinue = utils.should_continue_further(data);
+ });
+
+ [
+ "ConfirmClientAuth",
+ "ConfirmClientAuthRestrictedFields",
+ "ConfirmClientAuthMultipleRestrictedFields",
+ "ConfirmClientAuthMissingClientSecret",
+ ].forEach((key) => {
+ it(`rejects-${key}`, () => {
+ const data = utils.getConnectorDetails(
+ globalState.get("connectorId")
+ )["wallet_pm"][key];
+
+ cy.confirmPayoutCallTest({}, data, true, globalState);
+ });
+ });
+
+ it("retrieve-payout-after-client-auth-errors-test", () => {
+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[
+ "wallet_pm"
+ ]["RetrieveAfterClientAuthErrors"];
+
+ cy.retrievePayoutCallTest(globalState, data);
+ });
+
+ it("merchant-auth-confirm-with-amount-test", () => {
+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[
+ "wallet_pm"
+ ]["ConfirmMerchantAuth"];
+
+ cy.confirmPayoutCallTest({}, data, false, globalState);
+ });
+
+ it("retrieve-payout-after-merchant-auth-confirm-test", () => {
+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[
+ "wallet_pm"
+ ]["RetrieveAfterConfirm"];
+
+ cy.retrievePayoutCallTest(globalState, data);
+ });
+ }
+ );
});
diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js
index 3fd2232508..42c8e11de5 100644
--- a/cypress-tests/cypress/support/commands.js
+++ b/cypress-tests/cypress/support/commands.js
@@ -7959,26 +7959,10 @@ Cypress.Commands.add(
);
/**
- * Confirms a payout via POST /payouts/{payout_id}/confirm, supporting both
- * authentication modes of the payout confirm API. This is the payout-side
- * analogue of confirmCallTest (payments): it confirms an EXISTING payout on
- * its dedicated confirm endpoint. It cannot be replaced by
- * createConfirmPayoutTest, which always creates a NEW payout on
- * POST /payouts/create — a route with merchant-key-only auth where the
- * client-authenticated confirm flow is unreachable.
- * - client-authenticated (clientAuth=true): publishable key in the api-key
- * header and the client_secret (stashed in globalState as
- * payoutClientSecret by createConfirmPayoutTest) in the request body.
- * Restricted fields (amount, auto_fulfill, currency, connector, routing)
- * in the config Request exercise the client-auth field restrictions.
- * A config Request may pin client_secret (e.g. null) to exercise the
- * missing-client_secret error path.
- * - merchant-authenticated (clientAuth=false): merchant secret key in the
- * api-key header and no client_secret in the request body.
- * @param {Object} payoutConfirmBody - Base request body (config Request fields are merged on top)
- * @param {Object} data - Connector config entry with Request/Response
- * @param {boolean} clientAuth - true for publishable-key auth, false for merchant secret-key auth
- * @param {Object} globalState - The global state object
+ * Confirms an existing payout. Set clientAuth=true to verify that publishable
+ * keys and client secrets are rejected; merchant API keys remain supported.
+ * Config Request fields are merged onto the body, including an explicit null
+ * client_secret when testing a request without a client secret.
*/
Cypress.Commands.add(
"confirmPayoutCallTest",
@@ -8017,6 +8001,8 @@ Cypress.Commands.add(
cy.wrap(response).then(() => {
expect(response.headers["content-type"]).to.include("application/json");
+ expect(response.status).to.equal(resData.status);
+
if (response.status === 200) {
if (resData.body) {
for (const key in resData.body) {
@@ -8026,7 +8012,6 @@ Cypress.Commands.add(
}
}
} else {
- expect(response.status).to.equal(resData.status);
defaultErrorHandler(response, resData);
}
});