spree/spree — pull request #5206 by HoyaBoya (2014-08-13 20:39:58+00:00)
Title: prevent checkout with all invalid payments

This commit attempts to address an issue where it is possible to checkout with only invalid / failed payments. I believe the issue is due to process_payments! only considers pending payments. If every payment is failed / invalid, it will return true, this allowing the ```after_transition: :payment``` to continue to the next steps.

The results is that if a payment process fails legitimately for the first try i.e. Gateway rejects or invalid to Active Merchant, someone can simply do order.next! a second time and just move on. This is regardless of capture true/false or the Spree configuration on ```allow_checkout_on_gateway_error```.

What's contained in this PR.

1) break out of after_transition block to make testing easier.
2) explicit return false when conditions not met
3) add check for no valid payments after process_payments
4) test changes and additions

Steps To Replicate
1) Add a known bad payment to Stripe Gateway i.e. card_XXXXX
2) Invoke order.next and receive a gateway error.
3) Invole order.next again.

Expected
1) Failure and still at payment state.

Actual
1) Moved on to confirm state and no errors.