Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow merchant to choose which Woo order status upon invoice "paid" IPN message #68

Closed
shaunek-hero opened this issue Jan 10, 2024 · 2 comments

Comments

@shaunek-hero
Copy link
Contributor

shaunek-hero commented Jan 10, 2024

Current behavior is that the the Woo order is created in "Pending" status (wc-pending in the db) and then when the BitPay invoice is paid and the IPN message is processed the Woo order status changes to "Processing" (wc-processing). This order status is not configurable, it is hard coded in BitPayIpnProcess->process_processing(). Then later when the invoice changes to confirmed and complete the plugin updates the Woo order status again - but in these cases the Woo order status is configurable from the "Woocommerce Settings > Payments > BitPay Checkout for WooCommerce" screen, specifically the "BitPay Confirmed Invoice Status" and "BitPay Complete Invoice Status" settings. For example, the merchant can choose to have the order status changed to wc-on-hold, or some other status, when the confirmed IPN is received.

I would like to suggest that the plugin be updated so the paid invoice status message has a configuration option similar to the confirmed and complete statuses. I believe the exact same mechanism, of a setting field called "BitPay Paid Invoice Status" could be added. And specifically allow the merchant user the ability to choose the WcGatewayBitpay::IGNORE_STATUS_VALUE so that the order status does not update at all.

Rationale:

  1. Our Woocommerce system is setup to send out transactional emails to our customer when order statuses change, in our case when an order goes into wc-processing status the customer gets an email saying "Your order is now in the shipping queue." (As a side note, our website has several interesting payment methods besides credit card such as echeck, wire, and even snailmail checks! and so many of our customers are waiting days for their payments to be received and clear, so having an email go out when their order changes from wc-pending/wc-on-hold to wc-processing makes sense for us). So it will be confusing to our customers if they get an email right after they pay the BitPay invoice saying that is now in the shipping queue since we really aren't even sure if the crypto transaction will be fully accepted on the blockchain. We prefer that they only get that email notification when the BitPay invoice has reached complete status.
  2. Aside from that our internal warehouse folks don't want an order to go into wc-processing status unless payment has been 100% fully cleared, and when the BitPay status is paid your docs say that there is a chance the transaction might not be fully accepted.

So, in our case we have temporarily deleted the line that updates the Woo order status in BitPayIpnProcess->process_processing(). Below is our current diff.

--- build/BitPayLib/class-bitpayipnprocess.php.orig     2024-01-05 11:59:23
+++ build/BitPayLib/class-bitpayipnprocess.php  2024-01-10 15:41:08
@@ -212,9 +212,8 @@
         $order->update_status('refunded', __('BitPay payment refunded', 'woocommerce'));
     }
     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 processing.');
-        $order->update_status('processing', __('BitPay payment processing', 'woocommerce'));
+        $order->add_order_note($this->get_start_order_note($bitpay_invoice->getId()) . 'is paid and awaiting confirmation.');
     }
 }

This change works well for us but it may not be ideal for all your customers, I'm not sure. So this is why I am suggesting a new configuration option similar to the "BitPay Confirmed Invoice Status", and this process_processing() method could be adjusted to update the Woo order status to the user-specified status OR to ignore and not update the Woo order status at all.

I could submit a PR for this if it would help, but I wanted to check with you to see if this would be something you would be willing to consider, and if you had other, better ideas to accomplish the same thing.

@bobbrodie
Copy link
Contributor

@shaunek-hero this is a fantastic idea. Thank you so much for sharing, and with so much thought behind the idea. Making the WooCommerce status configurable when an invoice is set paid makes sense.

I agree that this would be best for a BitPay Paid Invoice Status setting, with a default matching today so we maintain backwards compatibility. We would release this as part of 5.4.0.

If you can submit a PR, that would be incredible! If you have other things on your plate to take care of internally, we totally recognize that. This is worthwhile, so if you'd want us to tackle it we could.

Thanks again!

@shaunek-hero
Copy link
Contributor Author

This was fixed in #69

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants