Skip to content

Commit b2159c4

Browse files
committed
feat: move orderdo and pre-authorize to global settings
Moved "What to do after payment?" and "Pre-Authorize" settings from individual payment method settings to global MONEI settings for better consistency and easier configuration. Changes: - Added monei_orderdo and monei_pre_authorize to global MONEI settings - Removed orderdo from CC, PayPal, Bizum, MBWay, Multibanco settings - Removed pre-authorize from CC and PayPal settings - Updated all gateway classes with backward compatible fallback logic - Old per-gateway settings still work, new installs use global settings - Pre-authorize only affects payment methods that support it (CC, PayPal) Backward compatibility: Local settings take precedence over global settings, ensuring existing configurations continue to work after upgrade.
1 parent 0e1dfe6 commit b2159c4

12 files changed

+66
-101
lines changed

includes/admin/monei-apple-google-settings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
'title' => __( 'Description', 'monei' ),
3636
'type' => 'textarea',
3737
'description' => __( 'Payment method description shown to customers during checkout.', 'monei' ),
38-
'default' => __( 'Pay with Apple Pay or Google Pay. Powered by MONEI.', 'monei' ),
38+
'default' => __( 'You will be redirected to Apple Pay or Google Pay to complete the payment. Powered by MONEI.', 'monei' ),
3939
'desc_tip' => true,
4040
),
4141
'payment_request_style' => array(

includes/admin/monei-bizum-settings.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
'title' => __( 'Description', 'monei' ),
4343
'type' => 'textarea',
4444
'description' => __( 'This description is only displayed when using redirect mode. It will be shown to customers before they are redirected to the payment page.', 'monei' ),
45-
'default' => __( 'Pay with Bizum. Powered by MONEI.', 'monei' ),
45+
'default' => __( 'You will be redirected to Bizum to complete the payment. Powered by MONEI.', 'monei' ),
4646
'class' => 'monei-bizum-description-field',
4747
),
4848
'bizum_style' => array(
@@ -75,15 +75,5 @@
7575
'description' => __( 'Hide payment method logo in the checkout.', 'monei' ),
7676
'desc_tip' => true,
7777
),
78-
'orderdo' => array(
79-
'title' => __( 'What to do after payment?', 'monei' ),
80-
'type' => 'select',
81-
'description' => __( 'Chose what to do after the customer pay the order.', 'monei' ),
82-
'default' => 'processing',
83-
'options' => array(
84-
'processing' => __( 'Mark as Processing (default & recommended)', 'monei' ),
85-
'completed' => __( 'Mark as Complete', 'monei' ),
86-
),
87-
),
8878
)
8979
);

includes/admin/monei-cc-settings.php

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
'title' => __( 'Description', 'monei' ),
4343
'type' => 'textarea',
4444
'description' => __( 'This description is only displayed when using redirect mode. It will be shown to customers before they are redirected to the payment page.', 'monei' ),
45-
'default' => __( 'Pay with credit card. Powered by MONEI.', 'monei' ),
45+
'default' => __( 'You will be redirected to the payment page to complete the payment. Powered by MONEI.', 'monei' ),
4646
'class' => 'monei-cc-description-field',
4747
),
4848
'card_input_style' => array(
@@ -83,22 +83,5 @@
8383
'description' => __( 'If enabled, customers will be able to pay with a saved card during checkout. Card details are saved on MONEI servers, not on your store.', 'monei' ),
8484
'desc_tip' => true,
8585
),
86-
'pre-authorize' => array(
87-
'title' => __( 'Pre-Authorize', 'monei' ),
88-
'type' => 'checkbox',
89-
'label' => __( 'Manually capture payments', 'monei' ),
90-
'description' => __( 'Place a hold on the funds when the customer authorizes the payment, but don’t capture the funds until later.<br>You can capture the payment changing order status to <strong>Completed</strong> or <strong>Processing</strong>.<br> You can cancel the Payment changing order to <strong>Cancelled</strong> or <strong>Refunded</strong>.', 'monei' ),
91-
'default' => 'no',
92-
),
93-
'orderdo' => array(
94-
'title' => __( 'What to do after payment?', 'monei' ),
95-
'type' => 'select',
96-
'description' => __( 'Chose what to do after the customer pay the order.', 'monei' ),
97-
'default' => 'processing',
98-
'options' => array(
99-
'processing' => __( 'Mark as Processing (default & recommended)', 'monei' ),
100-
'completed' => __( 'Mark as Complete', 'monei' ),
101-
),
102-
),
10386
)
10487
);

includes/admin/monei-mbway-settings.php

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
)
1616
);
1717

18-
/**
19-
* Monei mbway Gateway Settings.
20-
*/
18+
/** Monei mbway Gateway Settings. */
2119
return apply_filters(
2220
'wc_monei_mbway_settings',
2321
array(
@@ -37,7 +35,7 @@
3735
'title' => __( 'Description', 'monei' ),
3836
'type' => 'textarea',
3937
'description' => __( 'Payment method description shown to customers during checkout.', 'monei' ),
40-
'default' => __( 'Pay with MBWay. Powered by MONEI.', 'monei' ),
38+
'default' => __( 'Pay with MBWay, you will be redirected to MBWay to complete the payment. Powered by MONEI.', 'monei' ),
4139
'class' => 'monei-mbway-description-field',
4240
),
4341
'title' => array(
@@ -63,15 +61,5 @@
6361
'description' => __( 'Hide payment method logo in the checkout.', 'monei' ),
6462
'desc_tip' => true,
6563
),
66-
'orderdo' => array(
67-
'title' => __( 'What to do after payment?', 'monei' ),
68-
'type' => 'select',
69-
'description' => __( 'Chose what to do after the customer pay the order.', 'monei' ),
70-
'default' => 'processing',
71-
'options' => array(
72-
'processing' => __( 'Mark as Processing (default & recommended)', 'monei' ),
73-
'completed' => __( 'Mark as Complete', 'monei' ),
74-
),
75-
),
7664
)
7765
);

includes/admin/monei-multibanco-settings.php

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
)
1616
);
1717

18-
/**
19-
* Monei Multibanco Gateway Settings.
20-
*/
18+
/** Monei Multibanco Gateway Settings. */
2119
return apply_filters(
2220
'wc_monei_multibanco_settings',
2321
array(
@@ -37,7 +35,7 @@
3735
'title' => __( 'Description', 'monei' ),
3836
'type' => 'textarea',
3937
'description' => __( 'Payment method description shown to customers during checkout.', 'monei' ),
40-
'default' => __( 'Pay with Multibanco. Powered by MONEI.', 'monei' ),
38+
'default' => __( 'You will be redirected to Multibanco to complete the payment. Powered by MONEI.', 'monei' ),
4139
'class' => 'monei-multibanco-description-field',
4240
),
4341
'title' => array(
@@ -63,15 +61,5 @@
6361
'description' => __( 'Hide payment method logo in the checkout.', 'monei' ),
6462
'desc_tip' => true,
6563
),
66-
'orderdo' => array(
67-
'title' => __( 'What to do after payment?', 'monei' ),
68-
'type' => 'select',
69-
'description' => __( 'Chose what to do after the customer pay the order.', 'monei' ),
70-
'default' => 'processing',
71-
'options' => array(
72-
'processing' => __( 'Mark as Processing (default & recommended)', 'monei' ),
73-
'completed' => __( 'Mark as Complete', 'monei' ),
74-
),
75-
),
7664
)
7765
);

includes/admin/monei-paypal-settings.php

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,84 +15,65 @@
1515
)
1616
);
1717

18-
/**
19-
* Monei Paypal Gateway Settings.
20-
*/
18+
/** Monei Paypal Gateway Settings. */
2119
return apply_filters(
2220
'wc_monei_paypal_settings',
2321
array(
24-
'top_link' => array(
22+
'top_link' => array(
2523
'title' => '',
2624
'type' => 'title',
2725
'description' => '<a href="' . $settings_link . '" class="button">' . __( 'Go to MONEI Api key Settings', 'monei' ) . '</a>',
2826
'id' => 'paypal_monei_top_link',
2927
),
30-
'enabled' => array(
28+
'enabled' => array(
3129
'title' => __( 'Enable/Disable', 'monei' ),
3230
'type' => 'checkbox',
3331
'label' => __( 'Enable PayPal by MONEI', 'monei' ),
3432
'default' => 'no',
3533
),
36-
'paypal_mode' => array(
34+
'paypal_mode' => array(
3735
'title' => __( 'Use Redirect Flow', 'monei' ),
3836
'type' => 'checkbox',
3937
'label' => __( 'This will redirect the customer to the Hosted Payment Page.', 'monei' ),
4038
'default' => 'no',
4139
'description' => sprintf( __( 'If disabled the PayPal button will be rendered directly on the checkout page. It is recommended to enable redirection in cases where PayPal payments do not function correctly.', 'monei' ) ),
4240
),
43-
'description' => array(
41+
'description' => array(
4442
'title' => __( 'Description', 'monei' ),
4543
'type' => 'textarea',
4644
'description' => __( 'This description is only displayed when using redirect mode. It will be shown to customers before they are redirected to the payment page.', 'monei' ),
47-
'default' => __( 'Pay with PayPal. Powered by MONEI.', 'monei' ),
45+
'default' => __( 'You will be redirected to PayPal to complete the payment. Powered by MONEI. ', 'monei' ),
4846
'class' => 'monei-paypal-description-field',
4947
),
50-
'paypal_style' => array(
48+
'paypal_style' => array(
5149
'title' => __( 'PayPal Style', 'monei' ),
5250
'type' => 'textarea',
5351
'description' => __( 'Configure in JSON format the style of the PayPal component. Documentation: ', 'monei' ) . '<a href="https://docs.monei.com/docs/monei-js/reference/#paypal-options" target="_blank">MONEI PayPal Style</a>',
5452
'default' => '{"height": "50px", "disableMaxWidth": true}',
5553
'css' => 'min-height: 80px;',
5654
),
57-
'title' => array(
55+
'title' => array(
5856
'title' => __( 'Title', 'monei' ),
5957
'type' => 'text',
6058
'description' => __( 'The payment method title a user sees during checkout.', 'monei' ),
6159
'default' => __( 'PayPal', 'monei' ),
6260
'desc_tip' => true,
6361
),
64-
'hide_title' => array(
62+
'hide_title' => array(
6563
'title' => __( 'Hide Title', 'monei' ),
6664
'type' => 'checkbox',
6765
'label' => __( 'Hide payment method title', 'monei' ),
6866
'default' => 'no',
6967
'description' => __( 'Hide payment method title in the checkout, showing only the logo.', 'monei' ),
7068
'desc_tip' => true,
7169
),
72-
'hide_logo' => array(
70+
'hide_logo' => array(
7371
'title' => __( 'Hide Logo', 'monei' ),
7472
'type' => 'checkbox',
7573
'label' => __( 'Hide payment method logo', 'monei' ),
7674
'default' => 'no',
7775
'description' => __( 'Hide payment method logo in the checkout.', 'monei' ),
7876
'desc_tip' => true,
7977
),
80-
'pre-authorize' => array(
81-
'title' => __( 'Pre-Authorize', 'monei' ),
82-
'type' => 'checkbox',
83-
'label' => __( 'Manually capture payments', 'monei' ),
84-
'description' => __( 'Place a hold on the funds when the customer authorizes the payment, but don’t capture the funds until later.<br>You can capture the payment changing order status to <strong>Completed</strong> or <strong>Processing</strong>.<br> You can cancel the Payment changing order to <strong>Cancelled</strong> or <strong>Refunded</strong>.', 'monei' ),
85-
'default' => 'no',
86-
),
87-
'orderdo' => array(
88-
'title' => __( 'What to do after payment?', 'monei' ),
89-
'type' => 'select',
90-
'description' => __( 'Chose what to do after the customer pay the order.', 'monei' ),
91-
'default' => 'processing',
92-
'options' => array(
93-
'processing' => __( 'Mark as Processing (default & recommended)', 'monei' ),
94-
'completed' => __( 'Mark as Complete', 'monei' ),
95-
),
96-
),
9778
)
9879
);

src/Gateways/PaymentMethods/WCGatewayMoneiBizum.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@ public function __construct(
6767
if ( $this->testmode && ! empty( $this->title ) ) {
6868
$this->title .= ' (' . __( 'Test Mode', 'monei' ) . ')';
6969
}
70-
$this->description = ( ! empty( $this->get_option( 'description' ) ) ) ? $this->get_option( 'description' ) : '';
71-
$this->status_after_payment = ( ! empty( $this->get_option( 'orderdo' ) ) ) ? $this->get_option( 'orderdo' ) : '';
70+
$this->description = ( ! empty( $this->get_option( 'description' ) ) ) ? $this->get_option( 'description' ) : '';
71+
// Backward compatible: try local setting first, then global setting
72+
$local_orderdo = $this->get_option( 'orderdo' );
73+
$this->status_after_payment = ! empty( $local_orderdo ) ? $local_orderdo : get_option( 'monei_orderdo', 'processing' );
7274
$this->api_key = $this->getApiKey();
7375
$this->account_id = $this->getAccountId();
7476
$this->shop_name = get_bloginfo( 'name' );

src/Gateways/PaymentMethods/WCGatewayMoneiCC.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,20 @@ public function __construct(
101101
if ( $this->testmode && ! empty( $this->title ) ) {
102102
$this->title .= ' (' . __( 'Test Mode', 'monei' ) . ')';
103103
}
104-
$this->description = ( ! empty( $this->get_option( 'description' ) ) ) ? $this->get_option( 'description' ) : '';
105-
$this->status_after_payment = ( ! empty( $this->get_option( 'orderdo' ) ) ) ? $this->get_option( 'orderdo' ) : '';
104+
$this->description = ( ! empty( $this->get_option( 'description' ) ) ) ? $this->get_option( 'description' ) : '';
105+
// Backward compatible: try local setting first, then global setting
106+
$local_orderdo = $this->get_option( 'orderdo' );
107+
$this->status_after_payment = ! empty( $local_orderdo ) ? $local_orderdo : get_option( 'monei_orderdo', 'processing' );
106108
$this->account_id = $this->getAccountId();
107109
$this->api_key = $this->getApiKey();
108110
$this->shop_name = get_bloginfo( 'name' );
109111
$this->password = ( ! empty( $this->get_option( 'password' ) ) ) ? $this->get_option( 'password' ) : '';
110112
$this->tokenization = ( ! empty( $this->get_option( 'tokenization' ) && 'yes' === $this->get_option( 'tokenization' ) ) ) ? true : false;
111-
$this->pre_auth = ( ! empty( $this->get_option( 'pre-authorize' ) && 'yes' === $this->get_option( 'pre-authorize' ) ) ) ? true : false;
112-
$this->logging = ( ! empty( get_option( 'monei_debug' ) ) && 'yes' === get_option( 'monei_debug' ) ) ? true : false;
113+
// Backward compatible: try local setting first, then global setting
114+
$local_preauth = $this->get_option( 'pre-authorize' );
115+
$global_preauth = get_option( 'monei_pre_authorize', 'no' );
116+
$this->pre_auth = ( ! empty( $local_preauth ) && 'yes' === $local_preauth ) || ( empty( $local_preauth ) && 'yes' === $global_preauth );
117+
$this->logging = ( ! empty( get_option( 'monei_debug' ) ) && 'yes' === get_option( 'monei_debug' ) ) ? true : false;
113118

114119
// IPN callbacks
115120
$this->notify_url = WC_Monei()->get_ipn_url();

src/Gateways/PaymentMethods/WCGatewayMoneiMBWay.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@ public function __construct(
6161
if ( $this->testmode && ! empty( $this->title ) ) {
6262
$this->title .= ' (' . __( 'Test Mode', 'monei' ) . ')';
6363
}
64-
$this->description = ( ! empty( $this->get_option( 'description' ) ) ) ? $this->get_option( 'description' ) : '';
65-
$this->status_after_payment = ( ! empty( $this->get_option( 'orderdo' ) ) ) ? $this->get_option( 'orderdo' ) : '';
64+
$this->description = ( ! empty( $this->get_option( 'description' ) ) ) ? $this->get_option( 'description' ) : '';
65+
// Backward compatible: try local setting first, then global setting
66+
$local_orderdo = $this->get_option( 'orderdo' );
67+
$this->status_after_payment = ! empty( $local_orderdo ) ? $local_orderdo : get_option( 'monei_orderdo', 'processing' );
6668
$this->api_key = $this->getApiKey();
6769
$this->account_id = $this->getAccountId();
6870
$this->shop_name = get_bloginfo( 'name' );

src/Gateways/PaymentMethods/WCGatewayMoneiMultibanco.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ public function __construct(
6060
if ( $this->testmode && ! empty( $this->title ) ) {
6161
$this->title .= ' (' . __( 'Test Mode', 'monei' ) . ')';
6262
}
63-
$this->description = ( ! empty( $this->get_option( 'description' ) ) ) ? $this->get_option( 'description' ) : '';
64-
$this->status_after_payment = ( ! empty( $this->get_option( 'orderdo' ) ) ) ? $this->get_option( 'orderdo' ) : '';
63+
$this->description = ( ! empty( $this->get_option( 'description' ) ) ) ? $this->get_option( 'description' ) : '';
64+
// Backward compatible: try local setting first, then global setting
65+
$local_orderdo = $this->get_option( 'orderdo' );
66+
$this->status_after_payment = ! empty( $local_orderdo ) ? $local_orderdo : get_option( 'monei_orderdo', 'processing' );
6567
$this->api_key = $this->getApiKey();
6668
$this->account_id = $this->getAccountId();
6769
$this->shop_name = get_bloginfo( 'name' );

0 commit comments

Comments
 (0)