Commit Graph

199 Commits

Author SHA1 Message Date
Jean-Baptiste Bellet
4ad2a1a723 Prefer a concern that set a variable instead of a global helper
Therefor, for the right controllers, simply implements:

```
include WhiteLabel

before_action :hide_ofn_navigation, only: [:show, :edit]
```

This is mort robust, since we're working in a controller level, not parsing URLs...
2023-03-30 09:17:57 +11:00
Matt-Yorkley
8dc743f2d4 Extract update_payment_total method 2022-02-08 12:27:42 +00:00
Matt-Yorkley
7235d1813d Update totals and payment explicitly in current (non-split) checkout 2022-02-01 11:39:07 +00:00
Matt-Yorkley
1ee3d0f7a1 Drop embedded shops code 2022-01-26 19:58:39 +00:00
Matt-Yorkley
dfbd384c95 Refactor embedding to a Concern 2022-01-18 12:22:06 +00:00
Matt-Yorkley
789c29f678 Extract #load_checkout_order 2022-01-14 19:41:08 +00:00
Matt-Yorkley
76647863e8 Add new Stripe controller 2022-01-14 19:41:08 +00:00
Matt-Yorkley
28d89103eb Extract #gateway_error 2022-01-14 19:41:08 +00:00
Matt-Yorkley
414e1eb299 Tidy up OrdersController#load_order 2022-01-14 19:41:08 +00:00
Matt-Yorkley
6385d9a782 Simplify interface of #order_completion_route 2022-01-14 19:41:08 +00:00
Matt-Yorkley
7cbdb7c1a2 Remove paypal-specific workaround from OrdersController
The previous commit means this is no longer needed here.
2022-01-14 19:41:08 +00:00
Matt-Yorkley
1b459b2491 Extract #processing_failed 2022-01-14 19:41:08 +00:00
Matt-Yorkley
c1defdb1ff Extract #order_processing_error 2022-01-14 19:41:08 +00:00
Matt-Yorkley
5c44614a8d Extract and standardise payment/checkout #processing_succeeded 2022-01-14 19:41:08 +00:00
Matt-Yorkley
1e21a6a32f Extract and standardise use of #handle_insufficient_stock 2022-01-14 19:41:08 +00:00
Matt-Yorkley
b6cf6483f2 Extract and standardise use of order loading around checkout processing 2022-01-14 19:41:08 +00:00
Matt-Yorkley
4d6c4f850f Remove pointless callbacks in CheckoutController
These exact same checks are already made in #load_order (and #order_invalid_for_checkout?), which is called before these other two (later) callbacks.
2022-01-14 19:41:08 +00:00
Matt-Yorkley
77d89ec7d0 Extract and standardise use of #order_completion_route 2022-01-14 19:41:08 +00:00
Matt-Yorkley
9b6d4da8d5 Pull related lines into OrderCompletion#order_completion_reset 2022-01-14 19:41:08 +00:00
Matt-Yorkley
02995530e2 Pull apart OrderCompletionReset service 2022-01-14 19:41:08 +00:00
Matt-Yorkley
67b8a55273 Separate OrderCompletionReset from Checkout::PostCheckoutActions and don't pass controller objects to Checkout::PostCheckoutActions
We need to separate some of these bits to make them easier to call in different contexts. Also there's some weird stuff happening here with the controller being passed in to the service, and it seems like a code smell to me...
2022-01-14 19:41:08 +00:00
Matt-Yorkley
ad60f2392a Delete unused return statement 2022-01-14 19:41:08 +00:00
Matt-Yorkley
06eb98bdf4 Extract #valid_order_line_items? 2022-01-14 19:41:08 +00:00
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