Matt-Yorkley
f0d54dd083
Tidy up #redirect_to_payment_gateway
2021-12-22 09:58:08 +00:00
Matt-Yorkley
b77ff346a3
Replace #raise with #return in Checkout::StripeRedirect
...
The (potential) unhappy code path here was raising an error which would not be explicitly handled, and would in theory not return a useful message / response.
2021-12-15 21:20:58 +00:00
Matt-Yorkley
0fc4b851f2
Refactor payment gateway redirects handling
...
The checkout was holding a lot of responsibility for knowing which kinds of payment gateways are available and how to initiate the process of redirecting to the external payment page (if needed). This was being hidden somewhat by the way the logic was tucked away in services.
PaymentMethod objects now know whether or not they require an external payment process, and know how that process should be started and how to build the required URL.
So we can now *ask* any payment method if it requires external payment processing or not, and *tell* it to start the process and return the relevant URL (if needed).
2021-12-15 21:20:58 +00:00
Matt-Yorkley
dcad00d047
Merge pull request #8484 from Matt-Yorkley/stripe-session-checks
...
Stripe checkout alerting
2021-12-05 12:04:00 +00:00
Matt-Yorkley
ac5766b00b
Report current order info on all checkout failures
2021-11-14 20:01:32 +00:00
Matt-Yorkley
f8349434bf
Skip address setup logic if we're coming from Stripe
...
The code here runs from a callback which was originally designed to make sure the checkout page was set up correctly in the "normal" checkout workflow. It wasn't really designed to be run when the page is being loaded a second time due to the user being redirected back from Stripe (with SCA). The things it's doing here are necessary in the former case, but a really bad idea in the latter (potentially messing up the order's ship and bill addresses in certain cases like guest checkout).
2021-11-14 16:54:44 +00:00
Matt-Yorkley
f83d0a766f
Memoize Checkout#valid_payment_intent_provided?
2021-11-14 14:24:23 +00:00
Matt-Yorkley
bbb47964db
Notify Bugsnag if the order loaded at checkout is invalid after being redirected back from Stripe during payment processing.
2021-11-14 13:58:15 +00:00
Matt-Yorkley
1bf4e6fa56
Reorder conditions for performance
...
A little micro-optimisation: `@order.checkout_allowed?` requires a database query, whereas `@order.completed?` does not. So in cases where the order is completed we can return early here before hitting the database.
2021-11-14 13:58:15 +00:00
Matt-Yorkley
8d0cbe886a
Rename method for clarity
2021-11-14 13:58:15 +00:00
Matt-Yorkley
00862844d5
Memoize Checkout#valid_payment_intent_provided?
2021-11-14 11:39:36 +00:00
Matt-Yorkley
3bcfc673f7
Ensure selected shipping method is actually selected
...
Hashes with symbol keys != hashes with string keys 🙈
2021-09-06 20:58:22 +01:00
Matt-Yorkley
e1393c96ca
Correctly void transactions when payments are cancelled due to stock issues
2021-07-27 23:24:00 +01:00
Matt-Yorkley
8e1631bfc7
Set adjustments associated with voided payments to ineligible.
...
Otherwise we can end up with duplicate transaction fees for voided payments.
2021-07-12 08:28:32 +01:00
Matt-Yorkley
e6d9545c30
Use :incomplete scope when voiding payments that can't be processed due to stock changes
2021-07-09 13:31:00 +01:00
Matt-Yorkley
9bcf0d5b38
Handle Stripe payments when checkout fails due to stock issues
...
This can occur when stock is reduced after the user is redirected to Stripe and before they are redirected back. The stock is insufficient, the order is not complete, the user is bounced back to the cart, but a *pending* Stripe payment is left on the order.
2021-07-09 13:13:20 +01:00
Andy Brett
aa8067f96b
process payments separately from completing the order
2021-06-29 11:54:48 -07:00
Andy Brett
334b9b520a
removed deprecated calls to force_ssl; rely on config.force_ssl
2021-06-24 11:58:33 -07:00
Pau Pérez Fabregat
db993652c4
Merge branch 'master' into payment-states
2021-06-18 12:20:26 +02:00
Andy Brett
b41302d5d8
update state transitions for new requires_authorization state
2021-06-17 14:23:59 -07:00
Luis Ramos
23627c5453
Run rubocop -a (safe corrections) removing all exceptions so all possible fixes are applied
...
9290 issues fixed
2021-06-17 22:19:26 +01:00
Luis Ramos
b2e97fe1d2
Rename order.update! to order.update_order! and adjustment.update! to adjustment.update_adjustment!
2021-05-19 09:54:22 -07:00
Maikel Linke
4d242af007
Use pessimistic locking processing Stripe payment
...
We used pessimistic locking around the `update` action already but when
Stripe redirects back to us we complete the payment in the `edit` action.
2021-03-25 15:17:30 +11:00
Luis Ramos
c4c5bbc9a3
Adapt helpers to rails 5.2
2021-03-16 23:37:24 +00:00
Luis Ramos
f55150745e
Add checkout helper to checkout controller
2021-03-16 23:37:24 +00:00
Luis Ramos
d4cbf47226
Add T and Cs helper to checkout controller
2021-03-16 23:37:24 +00:00
Matt-Yorkley
f28cd4a4e5
Adapt checkout FormDataAdapter
2021-03-11 12:06:00 +00:00
Matt-Yorkley
c5a47b51a6
Update order totals during CheckoutController#update
2021-03-11 11:20:01 +00:00
Luis Ramos
f3da7afd55
Replace spree_order_path with order_path so we can use scope in the routes file
2021-01-25 19:55:42 +00:00
Luis Ramos
6e7ee02191
Change spree.order_path to spree_order_path everywhere
2021-01-25 19:52:48 +00:00
Luis Ramos
7a22367b4a
Make controllers use ::Basecontroller instead of StoreController
2021-01-15 21:59:16 +00:00
Matt-Yorkley
2fa2a30c67
Add spec coverage, refactor, avoid double-render errors
...
👍
2020-11-22 18:37:31 +00:00
Matt-Yorkley
87df44764f
Extract stock-check logic to controller concern and inject prior to final Paypal payment confirmation.
2020-11-22 18:02:52 +00:00
Andy Brett
17202ff39c
move gateway_error require to lib/spree/core.rb
2020-11-10 14:55:56 -08:00
Luis Ramos
032075c04a
Merge pull request #6119 from arku/chore/fire-event-removal
...
Remove fire_event method usage
2020-10-21 21:21:35 +01:00
Arun Kumar Mohan
b0fa1464f8
Remove fire_event method usage
2020-10-18 20:36:38 -05:00
Luis Ramos
a34c18451c
Add spree helper
2020-09-17 13:59:41 +01:00
Luis Ramos
27fa04114e
Add require for gateway error
2020-09-17 13:59:41 +01:00
Luis Ramos
e0cb7a29bf
Add helper prefix to helper calls
2020-09-17 13:58:45 +01:00
Matt-Yorkley
0fd163602d
Rename method for clarity
2020-08-17 11:17:42 +01:00
Matt-Yorkley
de22ad0000
Fix flash error issues in checkout requests
2020-08-14 12:41:56 +01:00
Luis Ramos
9e9e0d0bd8
Remove rescue_from and just add the rescue to the edit action, the update action has a different logic where there is a generic rescue StandardError after the GatewayError rescue
2020-07-29 22:50:25 +01:00
Luis Ramos
da4abf6617
Add a comment to explain the necessity of the first rescue in the update action
2020-07-29 22:50:20 +01:00
Luis Ramos
ad00971ca8
Improve readability and add bugsnag error (now in the checkout_failed method) when checkout_fails while handling stripe redirect
2020-07-29 22:50:18 +01:00
Luis Ramos
07005594ff
Move payments persistence code to order workflow service
2020-07-28 23:56:43 +01:00
Luis Ramos
9cbcf14485
Move shipping method id setting code to OrderWorkflow service
2020-07-28 23:50:47 +01:00
Luis Ramos
c3f99050fd
Move advance_order_state from checkout_controller to OrderWorkflow service
2020-07-28 23:43:07 +01:00
Luis Ramos
734fce5ce7
Add code to persist payments after failed payments. The state machine
...
rollbacks the transactions, with this we keep record of what went wrong.
2020-07-28 23:29:49 +01:00
Luis Ramos
ec0d06af54
Reuse update_failed method as the code needed is exactly the same
2020-07-25 19:39:46 +01:00
Luis Ramos
b23b707b5d
Notify bugsnag and execute post checkout actions (reset to cart state) whenever there's a payment gateway exceeption raised
2020-07-25 19:39:46 +01:00