Skip to content

Commit 45e8028

Browse files
Add default value to order status fetch
1 parent ea40628 commit 45e8028

9 files changed

Lines changed: 28 additions & 28 deletions

woocommerce-gateway-checkout-com/includes/api/class-wc-checkoutcom-api-request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public static function create_payment( WC_Order $order, $arg, $subscription = nu
121121
private static function get_request_param( WC_Order $order, $arg, $subscription = null ) {
122122
global $woocommerce, $wp_version;
123123

124-
$auto_capture = WC_Admin_Settings::get_option( 'ckocom_card_autocap' ) == 1 ? true : false;
124+
$auto_capture = WC_Admin_Settings::get_option( 'ckocom_card_autocap', 1 ) == 1;
125125
$amount = $order->get_total();
126126
$amount_cents = WC_Checkoutcom_Utility::valueToDecimal( $amount, $order->get_currency() );
127127
$three_d = WC_Admin_Settings::get_option( 'ckocom_card_threed' ) == 1 && $subscription == null ? true : false;

woocommerce-gateway-checkout-com/includes/apms/class-wc-checkoutcom-fawry.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function process_payment( $order_id )
5555
}
5656

5757

58-
$status = WC_Admin_Settings::get_option('ckocom_order_authorised');
58+
$status = WC_Admin_Settings::get_option('ckocom_order_authorised', 'on-hold');
5959
$message = "";
6060

6161
if ($result['source']['type'] == self::PAYMENT_METHOD) {
@@ -66,7 +66,7 @@ public function process_payment( $order_id )
6666
$message = __("Checkout.com - Fawry payment " ."</br>". " Action ID : {$result['id']} - Fawry reference number : {$result['source']['reference_number']} ", 'wc_checkout_com');
6767

6868
if ($result['status'] == 'Captured') {
69-
$status = WC_Admin_Settings::get_option('ckocom_order_captured');
69+
$status = WC_Admin_Settings::get_option('ckocom_order_captured', 'processing');
7070
$message = __("Checkout.com Payment Captured " ."</br>". " Action ID - {$result['id']} ", 'wc_checkout_com');
7171
}
7272
}

woocommerce-gateway-checkout-com/includes/apms/class-wc-checkoutcom-sepa.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function process_payment( $order_id ) {
8181
return;
8282
}
8383

84-
$status = WC_Admin_Settings::get_option( 'ckocom_order_authorised' );
84+
$status = WC_Admin_Settings::get_option( 'ckocom_order_authorised', 'on-hold' );
8585
$message = '';
8686

8787
if ( ! empty( $result['source'] ) && self::PAYMENT_METHOD === $result['source']['type'] ) {

woocommerce-gateway-checkout-com/includes/class-wc-gateway-checkout-com-apple-pay.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,13 +550,13 @@ public function process_payment( $order_id ) {
550550
update_post_meta( $order_id, '_cko_payment_id', $result['id'] );
551551

552552
// Get cko auth status configured in admin
553-
$status = WC_Admin_Settings::get_option( 'ckocom_order_authorised' );
553+
$status = WC_Admin_Settings::get_option( 'ckocom_order_authorised', 'on-hold' );
554554
$message = __( "Checkout.com Payment Authorised " . "</br>" . " Action ID : {$result['action_id']} ", 'wc_checkout_com' );
555555

556556
// check if payment was flagged
557557
if ( $result['risk']['flagged'] ) {
558558
// Get cko auth status configured in admin
559-
$status = WC_Admin_Settings::get_option( 'ckocom_order_flagged' );
559+
$status = WC_Admin_Settings::get_option( 'ckocom_order_flagged', 'flagged' );
560560
$message = __( "Checkout.com Payment Flagged " . "</br>" . " Action ID : {$result['action_id']} ", 'wc_checkout_com' );
561561
}
562562

woocommerce-gateway-checkout-com/includes/class-wc-gateway-checkout-com-cards.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -392,14 +392,14 @@ public function process_payment( $order_id )
392392
update_post_meta( $order_id, '_cko_payment_id', $result['id'] );
393393

394394
// Get cko auth status configured in admin.
395-
$status = WC_Admin_Settings::get_option( 'ckocom_order_authorised' );
395+
$status = WC_Admin_Settings::get_option( 'ckocom_order_authorised', 'on-hold' );
396396
$message = sprintf( esc_html__( 'Checkout.com Payment Authorised - Action ID : %s', 'wc_checkout_com' ), $result['action_id'] );
397397

398398

399399
// Check if payment was flagged.
400400
if ( $result['risk']['flagged'] ) {
401401
// Get cko auth status configured in admin.
402-
$status = WC_Admin_Settings::get_option( 'ckocom_order_flagged' );
402+
$status = WC_Admin_Settings::get_option( 'ckocom_order_flagged', 'flagged' );
403403
$message = sprintf( esc_html__( 'Checkout.com Payment Flagged - Action ID : %s', 'wc_checkout_com' ), $result['action_id'] );
404404
}
405405

@@ -498,24 +498,24 @@ public function callback_handler()
498498
update_post_meta($order_id, '_cko_payment_id', $result['id']);
499499

500500
// Get cko auth status configured in admin
501-
$status = WC_Admin_Settings::get_option('ckocom_order_authorised');
501+
$status = WC_Admin_Settings::get_option('ckocom_order_authorised', 'on-hold');
502502
$message = __("Checkout.com Payment Authorised " ."</br>". " Action ID : {$action['0']['id']} ", 'wc_checkout_com');
503503

504504
// check if payment was flagged
505505
if ($result['risk']['flagged']) {
506506
// Get cko auth status configured in admin
507-
$status = WC_Admin_Settings::get_option('ckocom_order_flagged');
507+
$status = WC_Admin_Settings::get_option('ckocom_order_flagged', 'flagged');
508508
$message = __("Checkout.com Payment Flagged " ."</br>". " Action ID : {$action['0']['id']} ", 'wc_checkout_com');
509509
}
510510

511511
if ( 'Canceled' === $result['status'] ) {
512-
$status = WC_Admin_Settings::get_option( 'ckocom_order_void' );
512+
$status = WC_Admin_Settings::get_option( 'ckocom_order_void', 'cancelled' );
513513
$message = __( "Checkout.com Payment Canceled" . "</br>" . " Action ID : {$action['0']['id']} ", 'wc_checkout_com' );
514514
}
515515

516516
if ($result['status'] == 'Captured') {
517517
update_post_meta($order_id, 'cko_payment_captured', true);
518-
$status = WC_Admin_Settings::get_option('ckocom_order_captured');
518+
$status = WC_Admin_Settings::get_option('ckocom_order_captured', 'processing');
519519
$message = __("Checkout.com Payment Captured" ."</br>". " Action ID : {$action['0']['id']} ", 'wc_checkout_com');
520520
}
521521

@@ -719,12 +719,12 @@ public function process_refund($order_id, $amount = null, $reason = '')
719719
update_post_meta($order_id, 'cko_payment_refunded', true);
720720

721721
// Get cko auth status configured in admin
722-
$status = WC_Admin_Settings::get_option('ckocom_order_refunded');
722+
$status = WC_Admin_Settings::get_option('ckocom_order_refunded', 'refunded');
723723
$message = __("Checkout.com Payment refunded from Admin " ."</br>". " Action ID : {$result['action_id']} ", 'wc_checkout_com');
724724

725725
if(isset($_SESSION['cko-refund-is-less'])){
726726
if($_SESSION['cko-refund-is-less']){
727-
$status = WC_Admin_Settings::get_option('ckocom_order_captured');
727+
$status = WC_Admin_Settings::get_option('ckocom_order_captured', 'processing');
728728
$order->add_order_note( __("Checkout.com Payment Partially refunded from Admin " ."</br>". " Action ID : {$result['action_id']}", 'wc_checkout_com') );
729729

730730
unset($_SESSION['cko-refund-is-less']);

woocommerce-gateway-checkout-com/includes/class-wc-gateway-checkout-com-google-pay.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,13 +324,13 @@ public function process_payment( $order_id )
324324
update_post_meta($order_id, '_cko_payment_id', $result['id']);
325325

326326
// Get cko auth status configured in admin
327-
$status = WC_Admin_Settings::get_option('ckocom_order_authorised');
327+
$status = WC_Admin_Settings::get_option('ckocom_order_authorised', 'on-hold');
328328
$message = __("Checkout.com Payment Authorised " ."</br>". " Action ID : {$result['action_id']} ", 'wc_checkout_com');
329329

330330
// check if payment was flagged
331331
if ($result['risk']['flagged']) {
332332
// Get cko auth status configured in admin
333-
$status = WC_Admin_Settings::get_option('ckocom_order_flagged');
333+
$status = WC_Admin_Settings::get_option('ckocom_order_flagged', 'flagged');
334334
$message = __("Checkout.com Payment Flagged " ."</br>". " Action ID : {$result['action_id']} ", 'wc_checkout_com');
335335
}
336336

@@ -372,12 +372,12 @@ public function process_refund($order_id, $amount = null, $reason = '')
372372
update_post_meta($order_id, '_transaction_id', $result['action_id']);
373373

374374
// Get cko auth status configured in admin
375-
$status = WC_Admin_Settings::get_option('ckocom_order_refunded');
375+
$status = WC_Admin_Settings::get_option('ckocom_order_refunded', 'refunded');
376376
$message = __("Checkout.com Payment refunded " ."</br>". " Action ID : {$result['action_id']} ", 'wc_checkout_com');
377377

378378
if(isset($_SESSION['cko-refund-is-less'])){
379379
if($_SESSION['cko-refund-is-less']){
380-
$status = WC_Admin_Settings::get_option('ckocom_order_captured');
380+
$status = WC_Admin_Settings::get_option('ckocom_order_captured', 'processing');
381381
$order->add_order_note( __("Checkout.com Payment Partially refunded " ."</br>". " Action ID : {$result['action_id']}", 'wc_checkout_com') );
382382

383383
unset($_SESSION['cko-refund-is-less']);

woocommerce-gateway-checkout-com/includes/class-wc-gateway-checkout-com-webhook.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static function authorize_payment($data)
3131
}
3232

3333
$already_authorized = get_post_meta($order_id, 'cko_payment_authorized', true);
34-
$auth_status = WC_Admin_Settings::get_option('ckocom_order_authorised');
34+
$auth_status = WC_Admin_Settings::get_option('ckocom_order_authorised', 'on-hold');
3535
$message = 'Webhook received from checkout.com. Payment Authorized';
3636

3737
// Add note to order if Authorized already
@@ -82,7 +82,7 @@ public static function card_verified($data)
8282
update_post_meta($order_id, '_transaction_id', $action_id);
8383

8484
// Get cko capture status configured in admin
85-
$status = WC_Admin_Settings::get_option('ckocom_order_captured');
85+
$status = WC_Admin_Settings::get_option('ckocom_order_captured', 'processing');
8686

8787
// update status of the order
8888
$order->update_status($status);
@@ -144,7 +144,7 @@ public static function capture_payment($data)
144144
update_post_meta($order_id, 'cko_payment_captured', true);
145145

146146
// Get cko capture status configured in admin
147-
$status = WC_Admin_Settings::get_option('ckocom_order_captured');
147+
$status = WC_Admin_Settings::get_option('ckocom_order_captured', 'processing');
148148
$order_message = __("Checkout.com Payment Captured " ."</br>". " Action ID : {$action_id} ", 'wc_checkout_com');
149149

150150
// Check if webhook amount is less than order amount
@@ -226,7 +226,7 @@ public static function void_payment($data)
226226
update_post_meta($order_id, 'cko_payment_voided', true);
227227

228228
// Get cko capture status configured in admin
229-
$status = WC_Admin_Settings::get_option('ckocom_order_void');
229+
$status = WC_Admin_Settings::get_option('ckocom_order_void', 'cancelled');
230230
$order_message = __("Checkout.com Payment Voided " ."</br>". " Action ID : {$action_id} ", 'wc_checkout_com');
231231

232232
// add notes for the order and update status

woocommerce-gateway-checkout-com/includes/subscription/class-wc-checkout-com-subscription.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ public static function update_order_status($payment_result, $renewal_order, $ord
4949
}
5050

5151
// Get cko auth status configured in admin
52-
$status = WC_Admin_Settings::get_option('ckocom_order_authorised');
52+
$status = WC_Admin_Settings::get_option('ckocom_order_authorised', 'on-hold');
5353
$message = __("Checkout.com Payment Authorised " ."</br>". " Action ID : {$payment_result['action_id']} ", 'wc_checkout_com');
5454

5555
// check if payment was flagged
5656
if ($payment_result['risk']['flagged']) {
5757
// Get cko auth status configured in admin
58-
$status = WC_Admin_Settings::get_option('ckocom_order_flagged');
58+
$status = WC_Admin_Settings::get_option('ckocom_order_flagged', 'flagged');
5959
$message = __("Checkout.com Payment Flagged " ."</br>". " Action ID : {$payment_result['action_id']} ", 'wc_checkout_com');
6060
}
6161

woocommerce-gateway-checkout-com/woocommerce-gateway-checkout-com.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ function cko_refund() {
244244
function action_woocommerce_order_item_add_action_buttons( $order ) {
245245

246246
$order_status = $order->get_status();
247-
$auth_status = str_replace('wc-', '', WC_Admin_Settings::get_option('ckocom_order_authorised'));
248-
$capture_status = str_replace('wc-', '', WC_Admin_Settings::get_option('ckocom_order_captured'));
247+
$auth_status = str_replace('wc-', '', WC_Admin_Settings::get_option('ckocom_order_authorised', 'on-hold'));
248+
$capture_status = str_replace('wc-', '', WC_Admin_Settings::get_option('ckocom_order_captured', 'processing'));
249249

250250
if($order->get_payment_method() == 'wc_checkout_com_cards'
251251
|| $order->get_payment_method() == 'wc_checkout_com_google_pay') {
@@ -328,7 +328,7 @@ function renew_save_again( $post_id, $post, $update ) {
328328
update_post_meta( sanitize_text_field( $_POST['post_ID'] ), 'cko_payment_captured', true );
329329

330330
// Get cko capture status configured in admin.
331-
$status = WC_Admin_Settings::get_option( 'ckocom_order_captured' );
331+
$status = WC_Admin_Settings::get_option( 'ckocom_order_captured', 'processing' );
332332
$message = sprintf( esc_html__( "Checkout.com Payment Captured from Admin - Action ID : %s", 'wc_checkout_com' ), $result['action_id'] );
333333

334334
// add notes for the order and update status.
@@ -353,7 +353,7 @@ function renew_save_again( $post_id, $post, $update ) {
353353
update_post_meta( sanitize_text_field( $_POST['post_ID'] ), 'cko_payment_voided', true );
354354

355355
// Get cko capture status configured in admin.
356-
$status = WC_Admin_Settings::get_option( 'ckocom_order_void' );
356+
$status = WC_Admin_Settings::get_option( 'ckocom_order_void', 'cancelled' );
357357
$message = sprintf( esc_html__( "Checkout.com Payment Voided from Admin - Action ID : %s", 'wc_checkout_com' ), $result['action_id'] );
358358

359359
// add notes for the order and update status.

0 commit comments

Comments
 (0)