From 54046cd307b45fd8241979399d8434afbe76f6e7 Mon Sep 17 00:00:00 2001
From: Philipp Stracker
Date: Wed, 5 Mar 2025 15:27:43 +0100
Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Restore=20correct=20order?=
=?UTF-8?q?=20of=20payload=20creation?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The token must be added after the last filter, to maintain backwards compatibility!
---
.../src/Repository/PartnerReferralsData.php | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/modules/ppcp-api-client/src/Repository/PartnerReferralsData.php b/modules/ppcp-api-client/src/Repository/PartnerReferralsData.php
index 2bb6514a6..a33230631 100644
--- a/modules/ppcp-api-client/src/Repository/PartnerReferralsData.php
+++ b/modules/ppcp-api-client/src/Repository/PartnerReferralsData.php
@@ -67,7 +67,6 @@ class PartnerReferralsData {
'woocommerce_paypal_payments_partner_config_override_return_url',
admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-gateway' )
);
- $return_url = add_query_arg( array( 'ppcpToken' => $onboarding_token ), $return_url );
/**
* Filter the label of the "Return to your shop" button.
@@ -118,8 +117,16 @@ class PartnerReferralsData {
);
/**
- * Returns the partners referrals data.
+ * Filter the final partners referrals data collection.
*/
- return apply_filters( 'ppcp_partner_referrals_data', $payload );
+ $payload = apply_filters( 'ppcp_partner_referrals_data', $payload );
+
+ // Add the nonce in the end, to maintain backwards compatibility of filters.
+ $payload['partner_config_override']['return_url'] = add_query_arg(
+ array( 'ppcpToken' => $onboarding_token ),
+ $payload['partner_config_override']['return_url']
+ );
+
+ return $payload;
}
}