[Woo POS] Handle card reader power off gracefully
Turning the reader off
It's not possible to turn the reader off while it's primed to accept payment, so it doesn't matter that we don't get an opportunity to cancel the payment like we do when disconnecting it.
If you turn it off while a payment is processing, we get the full-screen
Connect your readerview, with either a purple or green background depending which screen you do it on.I think we should handle that on a separate PR, as this one's getting a little large and in fixing it, there are some risks to overcome, particularly when the reader gets turned off on the card payment success screen.
Originally posted by @joshheald in https://github.com/woocommerce/woocommerce-ios/issues/13720#issuecomment-2310542826
Risks
If you turn off the reader on the card payment success screen, then tap Connect your reader and reconnect, you're taken to the checkout view again.
If you don't change the order, just go back to the product selector and forwards again, it correctly tells you the order is already paid for.
However, if you go back to the cart and change the order, then go forward again, it will still tell you that the order's been paid for without any further card tap. Worse, it will show you the new total as well. This is because you're in the same order still, and it datePaid != nil
This presents the risk that a merchant may get confused and think they've made a new order, and give away items that aren't paid for to the new customer.
This was true before the PR above, where we discovered this issue.
Thanks for reporting! 👍
This could potentially lead to quite some confusions - we shouldn't navigate anywhere from the success screen upon card-reader status change. I'm moving this to our current backlog.
P.S. I haven't tested whether this issue is still present.
I can't reproduce this right now. Turning off the reader doesn't actually update the Reader connected status, so you can't tap Connect your reader because the POS thinks you still are connected. It's also not possible to disconnect the reader on the success screen.
That said, this issue may still exist when we fix whatever's causing the reader connected status not to change.
After fixing the issue where Reader connected didn't update to Connect your reader after turning off the reader, this becomes reproducible again. I'll work on this next.