|
4 | 4 | */ |
5 | 5 |
|
6 | 6 | define([ |
7 | | - 'jquery', |
8 | 7 | 'Magento_Checkout/js/model/quote', |
9 | | - 'Magento_Checkout/js/model/url-builder', |
10 | | - 'mage/storage', |
11 | | - 'Magento_Checkout/js/model/error-processor', |
12 | | - 'Magento_Customer/js/model/customer', |
13 | | - 'Magento_Checkout/js/model/full-screen-loader' |
14 | | -], function ($, quote, urlBuilder, storage, errorProcessor, customer, fullScreenLoader) { |
| 8 | + 'Magento_Checkout/js/action/set-payment-information' |
| 9 | +], function (quote, setPaymentInformation) { |
15 | 10 | 'use strict'; |
16 | 11 |
|
17 | 12 | return function (messageContainer) { |
18 | | - var serviceUrl, |
19 | | - payload, |
20 | | - paymentData = quote.paymentMethod(); |
21 | | - |
22 | | - /** |
23 | | - * Checkout for guest and registered customer. |
24 | | - */ |
25 | | - if (!customer.isLoggedIn()) { |
26 | | - serviceUrl = urlBuilder.createUrl('/guest-carts/:cartId/set-payment-information', { |
27 | | - cartId: quote.getQuoteId() |
28 | | - }); |
29 | | - payload = { |
30 | | - cartId: quote.getQuoteId(), |
31 | | - email: quote.guestEmail, |
32 | | - paymentMethod: paymentData |
33 | | - }; |
34 | | - } else { |
35 | | - serviceUrl = urlBuilder.createUrl('/carts/mine/set-payment-information', {}); |
36 | | - payload = { |
37 | | - cartId: quote.getQuoteId(), |
38 | | - paymentMethod: paymentData |
39 | | - }; |
40 | | - } |
41 | | - fullScreenLoader.startLoader(); |
42 | | - |
43 | | - return storage.post( |
44 | | - serviceUrl, JSON.stringify(payload) |
45 | | - ).fail(function (response) { |
46 | | - errorProcessor.process(response, messageContainer); |
47 | | - }).always(function () { |
48 | | - fullScreenLoader.stopLoader(); |
49 | | - }); |
| 13 | + return setPaymentInformation(messageContainer, quote.paymentMethod()); |
50 | 14 | }; |
51 | 15 | }); |
0 commit comments