diff --git a/BitPayLib/class-bitpayipnprocess.php b/BitPayLib/class-bitpayipnprocess.php index a3d63a7..bb73175 100644 --- a/BitPayLib/class-bitpayipnprocess.php +++ b/BitPayLib/class-bitpayipnprocess.php @@ -262,8 +262,14 @@ private function process_refunded( Invoice $bitpay_invoice, WC_Order $order ): v private function process_processing( Invoice $bitpay_invoice, WC_Order $order ): void { $this->validate_bitpay_status_in_available_statuses( $bitpay_invoice, array( 'paid' ) ); + $order->add_order_note( $this->get_start_order_note( $bitpay_invoice->getId() ) . 'is paid and awaiting confirmation.' ); - $order->add_order_note( $this->get_start_order_note( $bitpay_invoice->getId() ) . 'is processing.' ); - $order->update_status( 'processing', __( 'BitPay payment processing', 'woocommerce' ) ); + $wordpress_order_status = $this->get_gateway_settings()['bitpay_checkout_order_process_paid_status']; + if ( WcGatewayBitpay::IGNORE_STATUS_VALUE === $wordpress_order_status ) { + return; + } + + $new_status = $this->get_wc_order_statuses()[ $wordpress_order_status ] ?? 'processing'; + $order->update_status( $new_status, __( 'BitPay payment processing', 'woocommerce' ) ); } } diff --git a/BitPayLib/class-wcgatewaybitpay.php b/BitPayLib/class-wcgatewaybitpay.php index 2e84d7a..a83983f 100644 --- a/BitPayLib/class-wcgatewaybitpay.php +++ b/BitPayLib/class-wcgatewaybitpay.php @@ -56,14 +56,14 @@ public function init_form_fields() { $wc_statuses_arr[ self::IGNORE_STATUS_VALUE ] = 'Do not change status'; // add an ignore option. $this->form_fields = array( - 'enabled' => array( + 'enabled' => array( 'title' => __( 'Enable/Disable', 'woocommerce' ), 'label' => __( 'Enable BitPay', 'woocommerce' ), 'type' => 'checkbox', 'description' => '', 'default' => 'no', ), - 'bitpay_logo' => array( + 'bitpay_logo' => array( 'title' => __( 'BitPay Logo', 'woocommerce' ), 'type' => 'select', 'description' => '', @@ -84,34 +84,34 @@ public function init_form_fields() { ), 'default' => 'BitPay-Accepted-CardGroup', ), - 'bitpay_logo_image_white' => array( + 'bitpay_logo_image_white' => array( 'id' => 'bitpay_logo', 'description' => '', 'type' => 'title', ), - 'bitpay_logo_image_dark' => array( + 'bitpay_logo_image_dark' => array( 'id' => 'bitpay_logo', 'description' => '', 'type' => 'title', ), - 'bitpay_checkout_info' => array( + 'bitpay_checkout_info' => array( 'description' => __( 'You should not ship any products until BitPay has finalized your transaction.
The order will stay in a Hold and/or Processing state, and will automatically change to Completed after the payment has been confirmed.', 'woocommerce' ), 'type' => 'title', ), - 'bitpay_checkout_merchant_info' => array( + 'bitpay_checkout_merchant_info' => array( 'description' => __( 'If you have not created a BitPay Merchant Token, you can create one on your BitPay Dashboard.
(Test) or (Production)

', 'woocommerce' ), 'type' => 'title', ), - 'bitpay_checkout_tier_info' => array( + 'bitpay_checkout_tier_info' => array( 'description' => __( '*** If you are having trouble creating BitPay invoices, verify your Tier settings on your BitPay Dashboard.', 'woocommerce' ), 'type' => 'title', ), - 'description' => array( + 'description' => array( 'title' => __( 'Description', 'woocommerce' ), 'type' => 'text', 'description' => __( 'This is the message box that will appear on the checkout page when they select BitPay.', 'woocommerce' ), @@ -119,7 +119,7 @@ public function init_form_fields() { ), - 'bitpay_checkout_token_dev' => array( + 'bitpay_checkout_token_dev' => array( 'title' => __( 'Development Token', 'woocommerce' ), 'label' => __( 'Development Token', 'woocommerce' ), 'type' => 'text', @@ -127,7 +127,7 @@ public function init_form_fields() { 'default' => '', ), - 'bitpay_checkout_token_prod' => array( + 'bitpay_checkout_token_prod' => array( 'title' => __( 'Production Token', 'woocommerce' ), 'label' => __( 'Production Token', 'woocommerce' ), 'type' => 'text', @@ -136,7 +136,7 @@ public function init_form_fields() { ), - 'bitpay_checkout_endpoint' => array( + 'bitpay_checkout_endpoint' => array( 'title' => __( 'Endpoint', 'woocommerce' ), 'type' => 'select', 'description' => __( 'Select Test for testing the plugin, Production when you are ready to go live.' ), @@ -147,7 +147,7 @@ public function init_form_fields() { 'default' => 'test', ), - 'bitpay_checkout_flow' => array( + 'bitpay_checkout_flow' => array( 'title' => __( 'Checkout Flow', 'woocommerce' ), 'type' => 'select', 'description' => __( 'If this is set to Redirect, then the customer will be redirected to BitPay to checkout, and return to the checkout page once the payment is made.
If this is set to Modal, the user will stay on ' . get_bloginfo( 'name', null ) . ' and complete the transaction.', 'woocommerce' ), // phpcs:ignore @@ -157,22 +157,22 @@ public function init_form_fields() { ), 'default' => '2', ), - 'bitpay_checkout_slug' => array( + 'bitpay_checkout_slug' => array( 'title' => __( 'Checkout Page', 'woocommerce' ), 'type' => 'text', 'description' => __( 'If you have a different custom checkout page, enter the page slug.
ie. ' . get_home_url() . '/checkout

View your pages here, your current checkout page should have Checkout Page next to the title.

Click the "quick edit" and copy and paste a custom slug here if needed.', 'woocommerce' ), // phpcs:ignore ), - 'bitpay_custom_redirect' => array( + 'bitpay_custom_redirect' => array( 'title' => __( 'Custom Redirect Page', 'woocommerce' ), 'type' => 'text', 'description' => __( 'Set the full url (ie. https://yoursite.com/custompage) if you would like the customer to be redirected to a custom page after completing theh purchase. Note: this will only work if the REDIRECT mode is used ', 'woocommerce' ), ), - 'bitpay_close_url' => array( + 'bitpay_close_url' => array( 'title' => __( 'Close URL', 'woocommerce' ), 'type' => 'text', 'description' => __( 'Set the close url
Note: this will only work if the REDIRECT mode is used ', 'woocommerce' ), ), - 'bitpay_checkout_mini' => array( + 'bitpay_checkout_mini' => array( 'title' => __( 'Show in mini cart ', 'woocommerce' ), 'type' => 'select', 'description' => __( 'Set to YES if you would like to show BitPay as an immediate checkout option in the mini cart', 'woocommerce' ), @@ -183,7 +183,7 @@ public function init_form_fields() { 'default' => '2', ), - 'bitpay_checkout_capture_email' => array( + 'bitpay_checkout_capture_email' => array( 'title' => __( 'Auto-Capture Email', 'woocommerce' ), 'type' => 'select', 'description' => __( 'Should BitPay try to auto-add the client\'s email address? If Yes, the client will not be able to change the email address on the BitPay invoice. If No, they will be able to add their own email address when paying the invoice.', 'woocommerce' ), @@ -194,24 +194,34 @@ public function init_form_fields() { ), 'default' => '1', ), - 'bitpay_checkout_checkout_message' => array( + 'bitpay_checkout_checkout_message' => array( 'title' => __( 'Checkout Message', 'woocommerce' ), 'type' => 'textarea', 'description' => __( 'Insert your custom message for the Order Received page, so the customer knows that the order will not be completed until BitPay releases the funds.', 'woocommerce' ), 'default' => 'Thank you. We will notify you when BitPay has processed your transaction.', ), - 'bitpay_checkout_error' => array( + 'bitpay_checkout_error' => array( 'title' => __( 'Error handling', 'woocommerce' ), 'type' => 'text', 'description' => __( 'If there is an error with creating the invoice, enter the page slug.
ie. ' . get_home_url() . '/error

View your pages here,.

Click the "quick edit" and copy and paste a custom slug here.', 'woocommerce' ), // phpcs:ignore ), - 'bitpay_checkout_error_message' => array( + 'bitpay_checkout_error_message' => array( 'title' => __( 'Error Message', 'woocommerce' ), 'type' => 'textarea', 'description' => __( 'Insert your custom message for the Error page, so the customer knows that there is some issue in paying the invoice', 'woocommerce' ), 'default' => 'Transaction Cancelled', ), + 'bitpay_checkout_order_process_paid_status' => array( + 'title' => __( 'BitPay Paid Invoice Status', 'woocommerce' ), + 'type' => 'select', + 'description' => __( + 'Map the BitPay paid invoice status to one of the available WooCommerce order states.
All WooCommerce status options are listed here for your convenience.


Click here for more information about BitPay invoice statuses.', // phpcs:ignore + 'woocommerce', + ), + 'options' => $wc_statuses_arr, + 'default' => 'wc-processing', + ), 'bitpay_checkout_order_process_confirmed_status' => array( 'title' => __( 'BitPay Confirmed Invoice Status', 'woocommerce' ), 'type' => 'select', @@ -240,7 +250,7 @@ public function init_form_fields() { 'options' => $wc_statuses_arr, 'default' => 'wc-processing', ), - 'bitpay_checkout_order_expired_status' => array( + 'bitpay_checkout_order_expired_status' => array( 'title' => __( 'BitPay Expired Status', 'woocommerce' ), 'type' => 'select', 'description' => __( 'If set to Yes, automatically set the order to canceled when the invoice has expired and has been notified by the BitPay IPN.', 'woocommerce' ), @@ -252,7 +262,7 @@ public function init_form_fields() { 'default' => '0', ), - 'bitpay_log_mode' => array( + 'bitpay_log_mode' => array( 'title' => __( 'Developer Logging', 'woocommerce' ), 'type' => 'select', 'description' => __( 'Errors will be logged to the plugin log directory automatically. Set to Enabled to also log transactions, ie invoices and IPN updates', 'woocommerce' ),