Underpayment - Allow customer to pay more
blockonomics opened this issue · 9 comments
Currently on underpayment customer has no option than to wait for merchant. He can be given an invoice to pay the pending amount. Also we have think if underpayment slack will still work
Check woocommerce order actions . Merchant has option to accept order or send invoice to customer for more payment
The idea here is the following. On underpayment, the merchant should get following options to do on opening Woocommerce > Orders > Order Details
- Show the received USD amount vs Order Amount clearly to the merchant. Eg 18USD was received for 20USD other
- Merchant has two options:
i. Accept the order
ii. Invoice the customer for remaining 2USD. On receiving this we have to mark invoice paid, lets think on how we can handle this - Also indicate underpayment slack option to merchant avoid future problems
Sounds an interesting problem to work upon.
Order details after underpayment for an order (Merchant setting has 0% underpayment slack).
Note that (i) it is marked as failed so it is no longer editable, and (ii) merchant can send "Note to Customer".
Show the received USD amount vs Order Amount clearly to the merchant
We can add 2 more fields for this as seen here:
i. Accept the order
For this merchant only need update the order status to "Completed":
ii. Invoice the customer for remaining 2USD. On receiving this we have to mark invoice paid
The first thing merchant has to do is change the status back to "Pending Payment" so as to make the order editable again. Now merchant can email invoice order details from order action.
Here is the email customer receives:
The link in email will generate this payment page for customer:
Now, currently when we click pay with bitcoin here, it takes to underpayment error page.
We can rethink how we handle the underpayment error. Here the remaining amount can be shown with a link to "Complete the checkout by paying remainder amount".
Also indicate underpayment slack option to merchant avoid future problems
We should add a dedicated article on https://help.blockonomics.co/support/home regarding this. Currently we have this mentioned under FAQ for our wordpress plugin.
Here is doc about more on existing 'Underpayment' or 'Partial Payment' flows.
Conclusion: I have made underpaid order to keep 'Pending Payment' status and showing checkout again for the same order. I also modified callback function for 2nd callback, it didn't work. This doc also mentions how other payment gateways are handling such payment flows. On Woocommerce, these flows already specify multiple payments before placing the order (ex. in multiple installments , or partly paid on delivery).
Best is to move to Coupons
Here is the phasewise plans on how to move forward on this - Lets make tasks on asana
Phase 1
- Research creating and applying automated coupons via woocommerce functions and later delete them ?
- Coupon is applied automatically on confirmed callback if it is an underpayment
- Refreshing Order checkout page now shows the updated partial amount to pay
Phase 2
- Remove paid_btc and expected_btc custom fields. We will require new custom fields - paid_order_amount . Note that the for remaining partial amount again, we need to generate new address, so one order will have multiple addresses and may require DB changes. Let visit how we are doing this in whmcs and then finalize DB structure
- Partial payment callbacks are now working and all custom fields in woocomerce orders are updating properly
Phase 3
- Checkout page auto refreshes on underpayment and show the following - Existing order amount paid is shown and a message is shown to explain what to do to avoid same error again
- Code refactoring, testing edge cases and release
Update on Phase 1: Using WC_Coupon, I am able to create and apply a coupon to the order on underpaid callback, in check_paid_amount function. For now I am using a hardcoded value of 200 instead of amount paid in the underpayment transaction. If the store currency is not btc, I need to convert the callback value to the store currency. So I need to store the conversion rate at time order was last updated. Or I can use remaining btc to paid and use that to get amount paid in fiat.
Here is such coupon applied after underpayment:
This is the customer payment page after coupon is applied:
For deleting coupon, we can use set_usage_limit to 1 and later delete it.
Note: I have also tried WC_Order_Item_Coupon but it is not updating the cart total, as seen here. I did try the solution given using add_action
and another one given here to apply coupon to each product in the order individually, but these didn't work.
Closing as already addressed