@@ -11,6 +11,7 @@ import * as tracking from 'lib/analytics';
11
11
import localized from 'lib/i18n' ;
12
12
import { emailIsSet } from 'paragons/auth' ;
13
13
import sanitizeAll from 'sanitizers' ;
14
+ import sanitizeLineItems from 'sanitizers/line-items' ;
14
15
15
16
// actions
16
17
import * as actions from 'modules/cart' ;
@@ -49,7 +50,7 @@ type Props = {
49
50
applePayAvailable : boolean ,
50
51
checkApplePay : ( ) => void ,
51
52
location : Object ,
52
- beginApplePay : ( paymentRequest : Object , lineItems : Object ) => Promise < * > ,
53
+ beginApplePay : ( paymentRequest : Object ) => Promise < * > ,
53
54
} ;
54
55
55
56
type State = {
@@ -146,29 +147,9 @@ class Cart extends Component {
146
147
147
148
@autobind
148
149
sanitize ( err ) {
149
- if ( / F o l l o w i n g S K U s a r e o u t / . test ( err ) ) {
150
- const skus = err . split ( '.' ) [ 0 ] . split ( ':' ) [ 1 ] . split ( ',' ) ;
150
+ const sanitizedLineItems = sanitizeLineItems ( err , this . props . skus ) ;
151
151
152
- const products = _ . reduce ( skus , ( acc , outOfStock ) => {
153
- const sku = _ . find ( this . props . skus , { sku : outOfStock . trim ( ) } ) ;
154
- if ( sku ) {
155
- return [
156
- ...acc ,
157
- sku . name ,
158
- ] ;
159
- }
160
-
161
- return acc ;
162
- } , [ ] ) ;
163
-
164
- return (
165
- < span >
166
- Products < strong > { products . join ( ', ' ) } </ strong > are out of stock. Please remove them to complete the checkout.
167
- </ span >
168
- ) ;
169
- }
170
-
171
- return sanitizeAll ( err ) ;
152
+ return sanitizedLineItems ? sanitizedLineItems : sanitizeAll ( err ) ;
172
153
}
173
154
174
155
get errorsLine ( ) {
@@ -196,7 +177,7 @@ class Cart extends Component {
196
177
197
178
@autobind
198
179
beginApplePay ( ) {
199
- const { total, taxes , adjustments } = this . props . totals ;
180
+ const { total } = this . props . totals ;
200
181
const amount = ( parseFloat ( total ) / 100 ) . toFixed ( 2 ) ;
201
182
const paymentRequest = {
202
183
countryCode : 'US' ,
@@ -216,12 +197,7 @@ class Cart extends Component {
216
197
] ,
217
198
} ;
218
199
219
- const lineItems = {
220
- taxes,
221
- promotion : adjustments ,
222
- } ;
223
-
224
- this . props . beginApplePay ( paymentRequest , lineItems ) . then ( ( ) => {
200
+ this . props . beginApplePay ( paymentRequest ) . then ( ( ) => {
225
201
this . setState ( { errors : null } ) ;
226
202
browserHistory . push ( '/checkout/done' ) ;
227
203
} )
0 commit comments