@@ -32,8 +32,6 @@ export type CheckoutState = {
3232 billingAddress : ShippingAddress ,
3333} ;
3434
35- export const checkApplePay = ( ) => foxApi . applePay . available ( ) ;
36-
3735export const selectCreditCard = createAction ( 'CHECKOUT_SET_CREDIT_CARD' ) ;
3836export const setEditStage = createAction ( 'CHECKOUT_SET_EDIT_STAGE' ) ;
3937export const setBillingData = createAction ( 'CHECKOUT_SET_BILLING_DATA' , ( key , value ) => [ key , value ] ) ;
@@ -43,6 +41,7 @@ export const setBillingAddress = createAction('CHECKOUT_SET_BILLING_ADDRESS');
4341export const toggleShippingModal = createAction ( 'TOGGLE_SHIPPING_MODAL' ) ;
4442export const toggleDeliveryModal = createAction ( 'TOGGLE_DELIVERY_MODAL' ) ;
4543export const togglePaymentModal = createAction ( 'TOGGLE_PAYMENT_MODAL' ) ;
44+ const applePayAvailable = createAction ( 'APPLE_PAY_AVAILABLE' ) ;
4645const markAddressAsDeleted = createAction ( 'CHECKOUT_MARK_ADDRESS_AS_DELETED' ) ;
4746const markAddressAsRestored = createAction (
4847 'CHECKOUT_MARK_ADDRESS_AS_RESTORED' ,
@@ -107,6 +106,36 @@ function addressToPayload(address) {
107106 return payload ;
108107}
109108
109+ const _checkApplePay = createAsyncActions (
110+ 'checkApplePay' ,
111+ function ( ) {
112+ const { dispatch } = this ;
113+
114+ return foxApi . applePay . available ( )
115+ . then ( ( resp ) => {
116+ dispatch ( applePayAvailable ( resp ) ) ;
117+ } ) ;
118+ }
119+ ) ;
120+
121+ export const checkApplePay = _checkApplePay . perform ;
122+
123+ const _beginApplePay = createAsyncActions (
124+ 'beginApplePay' ,
125+ function ( payment ) {
126+ return foxApi . applePay . beginApplePay ( payment )
127+ . then ( ( ) => {
128+ console . log ( 'payment is successfull, from checkout.js' ) ;
129+ } )
130+ . catch ( ( err ) => {
131+ console . log ( 'error occurred in checkout.js, _beginApplePay' ) ;
132+ throw new Error ( err ) ;
133+ } ) ;
134+ }
135+ ) ;
136+
137+ export const beginApplePay = _beginApplePay . perform ;
138+
110139const _removeShippingMethod = createAsyncActions (
111140 'removeShippingMethod' ,
112141 function ( ) {
@@ -465,6 +494,7 @@ const initialState: CheckoutState = {
465494 shippingModalVisible : false ,
466495 deliveryModalVisible : false ,
467496 paymentModalVisible : false ,
497+ applePayAvailable : false ,
468498} ;
469499
470500function sortAddresses ( addresses : Array < Address > ) : Array < Address > {
@@ -505,6 +535,12 @@ const reducer = createReducer({
505535 billingData,
506536 } ;
507537 } ,
538+ [ applePayAvailable ] : ( state , available ) => {
539+ return {
540+ ...state ,
541+ applePayAvailable : available ,
542+ } ;
543+ } ,
508544 [ shippingMethodsActions . succeeded ] : ( state , list ) => {
509545 return {
510546 ...state ,
0 commit comments