From 783900b51c6a969fcb004bb0870d58492af8c23f Mon Sep 17 00:00:00 2001 From: Remco Tolsma <869674+remcotolsma@users.noreply.github.com> Date: Mon, 26 Jun 2023 12:54:12 +0200 Subject: [PATCH 1/2] Add filter for merchant order reference. --- docs/hooks.md | 31 ++++++++++++++++++++++++++++--- src/PaymentRequestHelper.php | 20 +++++++++++++++++++- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/docs/hooks.md b/docs/hooks.md index 0f2dd752..bea60096 100644 --- a/docs/hooks.md +++ b/docs/hooks.md @@ -33,7 +33,7 @@ Argument | Type | Description -------- | ---- | ----------- `$payment` | `\Pronamic\WordPress\Pay\Payments\Payment` | Payment. -Source: [./src/NotificationsController.php](../src/NotificationsController.php), [line 184](../src/NotificationsController.php#L184-L189) +Source: [./src/NotificationsController.php](../src/NotificationsController.php), [line 192](../src/NotificationsController.php#L192-L197) ## Filters @@ -53,7 +53,32 @@ Version | Description ------- | ----------- `1.2.0` | Added. -Source: [./src/Gateway.php](../src/Gateway.php), [line 364](../src/Gateway.php#L364-L371) +Source: [./src/Gateway.php](../src/Gateway.php), [line 417](../src/Gateway.php#L417-L424) + +### `pronamic_pay_adyen_merchant_order_reference` + +*Filters the Adyen merchant order reference.* + +This reference allows linking multiple transactions to each other +for reporting purposes (i.e. order auth-rate). The reference should +be unique per billing cycle. The same merchant order reference +should never be reused after the first authorised attempt. If used, +this field should be supplied for all incoming authorisations. + +**Arguments** + +Argument | Type | Description +-------- | ---- | ----------- +`$merchant_order_reference` | `string` | Merchant order reference. +`$payment` | `\Pronamic\WordPress\Pay\Payments\Payment` | Payment. + +**Changelog** + +Version | Description +------- | ----------- +`4.5.0` | Added. + +Source: [./src/PaymentRequestHelper.php](../src/PaymentRequestHelper.php), [line 38](../src/PaymentRequestHelper.php#L38-L52) ### `pronamic_pay_adyen_payment_metadata` @@ -74,7 +99,7 @@ Version | Description ------- | ----------- `1.1.1` | Added. -Source: [./src/PaymentRequestHelper.php](../src/PaymentRequestHelper.php), [line 231](../src/PaymentRequestHelper.php#L231-L241) +Source: [./src/PaymentRequestHelper.php](../src/PaymentRequestHelper.php), [line 249](../src/PaymentRequestHelper.php#L249-L259)
Generated by Pronamic WordPress Documentor 1.2.0
diff --git a/src/PaymentRequestHelper.php b/src/PaymentRequestHelper.php
index 766f10e8..412de520 100644
--- a/src/PaymentRequestHelper.php
+++ b/src/PaymentRequestHelper.php
@@ -33,7 +33,25 @@ public static function complement( Payment $payment, AbstractPaymentRequest $req
* @link https://docs.adyen.com/api-explorer/#/CheckoutService/v68/post/payments__reqParam_merchantOrderReference
* @link https://docs.adyen.com/api-explorer/#/CheckoutService/v68/post/sessions__reqParam_merchantOrderReference
*/
- $request->set_merchant_order_reference( $payment->format_string( $config->get_merchant_order_reference() ) );
+ $merchant_order_reference = $payment->format_string( $config->get_merchant_order_reference() );
+
+ /**
+ * Filters the Adyen merchant order reference.
+ *
+ * This reference allows linking multiple transactions to each other
+ * for reporting purposes (i.e. order auth-rate). The reference should
+ * be unique per billing cycle. The same merchant order reference
+ * should never be reused after the first authorised attempt. If used,
+ * this field should be supplied for all incoming authorisations.
+ *
+ * @param string $merchant_order_reference Merchant order reference.
+ * @param Payment $payment Payment.
+ * @link https://docs.adyen.com/api-explorer/Checkout/68/post/payments#request-merchantOrderReference
+ * @since 4.5.0 Added.
+ */
+ $merchant_order_reference = apply_filters( 'pronamic_pay_adyen_merchant_order_reference', $merchant_order_reference, $payment );
+
+ $request->set_merchant_order_reference( $merchant_order_reference );
/**
* Country code.
From 9a55d3961ce1936c52a6fd7c9b35ac920083a163 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Re=C3=BCel=20van=20der=20Steege?=