2019-08-29 16:41:04 +00:00
|
|
|
|
/**
|
|
|
|
|
* External dependencies
|
|
|
|
|
*/
|
2020-03-15 21:45:19 +00:00
|
|
|
|
import { __, sprintf } from '@wordpress/i18n';
|
2020-03-27 23:24:32 +00:00
|
|
|
|
import classnames from 'classnames';
|
2020-03-16 11:09:29 +00:00
|
|
|
|
import { cloneElement, Component } from '@wordpress/element';
|
2019-08-29 16:41:04 +00:00
|
|
|
|
import { compose } from '@wordpress/compose';
|
2020-03-15 21:45:19 +00:00
|
|
|
|
import { Button, FormToggle } from '@wordpress/components';
|
2019-10-03 16:03:29 +00:00
|
|
|
|
import { withDispatch } from '@wordpress/data';
|
2019-08-29 16:41:04 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* WooCommerce dependencies
|
|
|
|
|
*/
|
2020-04-16 23:58:36 +00:00
|
|
|
|
import { Card, H, Plugins } from '@woocommerce/components';
|
2020-02-14 02:23:21 +00:00
|
|
|
|
import {
|
2020-03-15 21:45:19 +00:00
|
|
|
|
getHistory,
|
|
|
|
|
getNewPath,
|
|
|
|
|
updateQueryString,
|
|
|
|
|
} from '@woocommerce/navigation';
|
2020-05-28 08:51:40 +00:00
|
|
|
|
import {
|
|
|
|
|
ONBOARDING_STORE_NAME,
|
2020-06-10 23:49:27 +00:00
|
|
|
|
OPTIONS_STORE_NAME,
|
2020-05-28 08:51:40 +00:00
|
|
|
|
PLUGINS_STORE_NAME,
|
2020-06-10 23:49:27 +00:00
|
|
|
|
pluginNames,
|
2020-06-22 22:18:35 +00:00
|
|
|
|
SETTINGS_STORE_NAME,
|
2020-05-28 08:51:40 +00:00
|
|
|
|
} from '@woocommerce/data';
|
2019-08-29 16:41:04 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Internal dependencies
|
|
|
|
|
*/
|
2019-10-07 20:27:34 +00:00
|
|
|
|
import { recordEvent } from 'lib/tracks';
|
|
|
|
|
import { getCountryCode } from 'dashboard/utils';
|
2019-08-29 16:41:04 +00:00
|
|
|
|
import withSelect from 'wc-api/with-select';
|
2020-03-16 11:09:29 +00:00
|
|
|
|
import { getPaymentMethods } from './methods';
|
2019-08-29 16:41:04 +00:00
|
|
|
|
|
|
|
|
|
class Payments extends Component {
|
2020-03-16 11:09:29 +00:00
|
|
|
|
constructor( props ) {
|
2019-08-29 16:41:04 +00:00
|
|
|
|
super( ...arguments );
|
2020-03-16 11:09:29 +00:00
|
|
|
|
const { methods } = props;
|
|
|
|
|
|
|
|
|
|
const enabledMethods = {};
|
|
|
|
|
methods.forEach(
|
|
|
|
|
( method ) => ( enabledMethods[ method.key ] = method.isEnabled )
|
|
|
|
|
);
|
|
|
|
|
this.state = {
|
2020-06-12 09:38:02 +00:00
|
|
|
|
busyMethod: null,
|
2020-03-16 11:09:29 +00:00
|
|
|
|
enabledMethods,
|
2020-06-12 09:38:02 +00:00
|
|
|
|
recommendedMethod: this.getRecommendedMethod(),
|
2020-03-16 11:09:29 +00:00
|
|
|
|
};
|
2019-10-03 16:03:29 +00:00
|
|
|
|
|
2020-03-15 21:45:19 +00:00
|
|
|
|
this.completeTask = this.completeTask.bind( this );
|
2019-10-03 16:03:29 +00:00
|
|
|
|
this.markConfigured = this.markConfigured.bind( this );
|
2020-03-15 21:45:19 +00:00
|
|
|
|
this.skipTask = this.skipTask.bind( this );
|
2019-10-03 16:03:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-06-12 09:38:02 +00:00
|
|
|
|
componentDidUpdate() {
|
|
|
|
|
const { recommendedMethod } = this.state;
|
2020-06-04 09:36:57 +00:00
|
|
|
|
|
2020-06-12 09:38:02 +00:00
|
|
|
|
const method = this.getRecommendedMethod();
|
|
|
|
|
if ( recommendedMethod !== method ) {
|
2020-06-04 09:36:57 +00:00
|
|
|
|
this.setState( {
|
2020-06-12 09:38:02 +00:00
|
|
|
|
recommendedMethod: method,
|
2020-06-04 09:36:57 +00:00
|
|
|
|
} );
|
|
|
|
|
}
|
2020-03-16 11:09:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-06-12 09:38:02 +00:00
|
|
|
|
getRecommendedMethod() {
|
|
|
|
|
const { methods } = this.props;
|
|
|
|
|
return methods.find( ( m ) => m.key === 'wcpay' && m.visible )
|
|
|
|
|
? 'wcpay'
|
|
|
|
|
: 'stripe';
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-10 23:49:27 +00:00
|
|
|
|
async completeTask() {
|
2020-03-16 11:09:29 +00:00
|
|
|
|
const { createNotice, methods, updateOptions } = this.props;
|
2020-03-15 21:45:19 +00:00
|
|
|
|
|
2020-06-10 23:49:27 +00:00
|
|
|
|
const update = await updateOptions( {
|
2020-03-15 21:45:19 +00:00
|
|
|
|
woocommerce_task_list_payments: {
|
|
|
|
|
completed: 1,
|
2020-05-04 11:33:11 +00:00
|
|
|
|
timestamp: Math.floor( Date.now() / 1000 ),
|
2020-03-15 21:45:19 +00:00
|
|
|
|
},
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
recordEvent( 'tasklist_payment_done', {
|
2020-03-16 11:09:29 +00:00
|
|
|
|
configured: methods
|
|
|
|
|
.filter( ( method ) => method.isConfigured )
|
|
|
|
|
.map( ( method ) => method.key ),
|
2020-03-15 21:45:19 +00:00
|
|
|
|
} );
|
2020-01-06 15:27:09 +00:00
|
|
|
|
|
2020-06-10 23:49:27 +00:00
|
|
|
|
if ( update.success ) {
|
|
|
|
|
createNotice(
|
|
|
|
|
'success',
|
|
|
|
|
__(
|
|
|
|
|
'💰 Ka-ching! Your store can now accept payments 💳',
|
|
|
|
|
'woocommerce-admin'
|
|
|
|
|
)
|
|
|
|
|
);
|
2020-01-06 15:27:09 +00:00
|
|
|
|
|
2020-06-10 23:49:27 +00:00
|
|
|
|
getHistory().push( getNewPath( {}, '/', {} ) );
|
|
|
|
|
} else {
|
|
|
|
|
createNotice(
|
|
|
|
|
'error',
|
|
|
|
|
__(
|
|
|
|
|
'There was a problem updating settings',
|
|
|
|
|
'woocommerce-admin'
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
2019-08-29 16:41:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-15 21:45:19 +00:00
|
|
|
|
skipTask() {
|
2020-03-16 11:09:29 +00:00
|
|
|
|
const { methods, updateOptions } = this.props;
|
2020-03-15 21:45:19 +00:00
|
|
|
|
|
|
|
|
|
updateOptions( {
|
|
|
|
|
woocommerce_task_list_payments: {
|
2020-05-04 11:33:11 +00:00
|
|
|
|
skipped: 1,
|
|
|
|
|
timestamp: Math.floor( Date.now() / 1000 ),
|
2020-03-15 21:45:19 +00:00
|
|
|
|
},
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
recordEvent( 'tasklist_payment_skip_task', {
|
2020-03-16 11:09:29 +00:00
|
|
|
|
options: methods.map( ( method ) => method.key ),
|
2020-03-15 21:45:19 +00:00
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
getHistory().push( getNewPath( {}, '/', {} ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
markConfigured( method ) {
|
2020-03-16 11:57:23 +00:00
|
|
|
|
const { enabledMethods } = this.state;
|
|
|
|
|
|
|
|
|
|
this.setState( {
|
|
|
|
|
enabledMethods: {
|
|
|
|
|
...enabledMethods,
|
|
|
|
|
[ method ]: true,
|
|
|
|
|
},
|
|
|
|
|
} );
|
|
|
|
|
|
2020-03-15 21:45:19 +00:00
|
|
|
|
getHistory().push( getNewPath( { task: 'payments' }, '/', {} ) );
|
2019-08-29 16:41:04 +00:00
|
|
|
|
|
2020-03-15 21:45:19 +00:00
|
|
|
|
recordEvent( 'tasklist_payment_connect_method', {
|
|
|
|
|
payment_method: method,
|
2019-10-03 16:03:29 +00:00
|
|
|
|
} );
|
2019-08-29 16:41:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-15 21:45:19 +00:00
|
|
|
|
getCurrentMethod() {
|
2020-03-16 11:09:29 +00:00
|
|
|
|
const { methods, query } = this.props;
|
2019-10-03 16:03:29 +00:00
|
|
|
|
|
2020-03-15 21:45:19 +00:00
|
|
|
|
if ( ! query.method ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-10-03 16:03:29 +00:00
|
|
|
|
|
2020-03-15 21:45:19 +00:00
|
|
|
|
return methods.find( ( method ) => method.key === query.method );
|
2019-10-07 20:27:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-15 21:45:19 +00:00
|
|
|
|
getInstallStep() {
|
|
|
|
|
const currentMethod = this.getCurrentMethod();
|
2019-10-03 16:03:29 +00:00
|
|
|
|
|
2020-03-15 21:45:19 +00:00
|
|
|
|
if ( ! currentMethod.plugins || ! currentMethod.plugins.length ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-10-03 16:03:29 +00:00
|
|
|
|
|
2020-03-15 21:45:19 +00:00
|
|
|
|
const { activePlugins } = this.props;
|
|
|
|
|
const pluginsToInstall = currentMethod.plugins.filter(
|
|
|
|
|
( method ) => ! activePlugins.includes( method )
|
|
|
|
|
);
|
|
|
|
|
const pluginNamesString = currentMethod.plugins
|
|
|
|
|
.map( ( pluginSlug ) => pluginNames[ pluginSlug ] )
|
|
|
|
|
.join( ' ' + __( 'and', 'woocommerce-admin' ) + ' ' );
|
2019-08-29 16:41:04 +00:00
|
|
|
|
|
2020-03-15 21:45:19 +00:00
|
|
|
|
return {
|
|
|
|
|
key: 'install',
|
|
|
|
|
label: sprintf(
|
|
|
|
|
__( 'Install %s', 'woocommerce-admin' ),
|
|
|
|
|
pluginNamesString
|
|
|
|
|
),
|
|
|
|
|
content: (
|
|
|
|
|
<Plugins
|
|
|
|
|
onComplete={ () => {
|
|
|
|
|
recordEvent( 'tasklist_payment_install_method', {
|
|
|
|
|
plugins: currentMethod.plugins,
|
|
|
|
|
} );
|
|
|
|
|
} }
|
|
|
|
|
autoInstall
|
|
|
|
|
pluginSlugs={ currentMethod.plugins }
|
|
|
|
|
/>
|
|
|
|
|
),
|
|
|
|
|
isComplete: ! pluginsToInstall.length,
|
|
|
|
|
};
|
2019-08-29 16:41:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-16 11:09:29 +00:00
|
|
|
|
toggleMethod( key ) {
|
|
|
|
|
const { methods, options, updateOptions } = this.props;
|
|
|
|
|
const { enabledMethods } = this.state;
|
|
|
|
|
const method = methods.find( ( option ) => option.key === key );
|
|
|
|
|
|
|
|
|
|
enabledMethods[ key ] = ! enabledMethods[ key ];
|
|
|
|
|
this.setState( { enabledMethods } );
|
|
|
|
|
|
|
|
|
|
recordEvent( 'tasklist_payment_toggle', {
|
|
|
|
|
enabled: ! method.isEnabled,
|
|
|
|
|
payment_method: key,
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
updateOptions( {
|
|
|
|
|
[ method.optionName ]: {
|
|
|
|
|
...options[ method.optionName ],
|
|
|
|
|
enabled: method.isEnabled ? 'no' : 'yes',
|
|
|
|
|
},
|
|
|
|
|
} );
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-12 09:38:02 +00:00
|
|
|
|
async handleClick( method ) {
|
|
|
|
|
const { methods } = this.props;
|
|
|
|
|
const { key, onClick } = method;
|
|
|
|
|
|
|
|
|
|
recordEvent( 'tasklist_payment_setup', {
|
|
|
|
|
options: methods.map( ( option ) => option.key ),
|
|
|
|
|
selected: key,
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
if ( onClick ) {
|
|
|
|
|
this.setState( { busyMethod: key } );
|
|
|
|
|
await new Promise( onClick )
|
|
|
|
|
.then( () => {
|
|
|
|
|
this.setState( { busyMethod: null } );
|
|
|
|
|
} )
|
|
|
|
|
.catch( () => {
|
|
|
|
|
this.setState( { busyMethod: null } );
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateQueryString( {
|
|
|
|
|
method: key,
|
|
|
|
|
} );
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-29 16:41:04 +00:00
|
|
|
|
render() {
|
2020-03-15 21:45:19 +00:00
|
|
|
|
const currentMethod = this.getCurrentMethod();
|
2020-06-12 09:38:02 +00:00
|
|
|
|
const { busyMethod, enabledMethods, recommendedMethod } = this.state;
|
2020-06-10 23:49:27 +00:00
|
|
|
|
const { methods, query, requesting } = this.props;
|
2020-06-15 05:43:22 +00:00
|
|
|
|
const hasEnabledMethods = Object.keys( enabledMethods ).filter(
|
|
|
|
|
( method ) => enabledMethods[ method ]
|
2020-03-16 11:09:29 +00:00
|
|
|
|
).length;
|
2020-03-15 21:45:19 +00:00
|
|
|
|
|
|
|
|
|
if ( currentMethod ) {
|
|
|
|
|
return (
|
|
|
|
|
<Card className="woocommerce-task-payment-method is-narrow">
|
|
|
|
|
{ cloneElement( currentMethod.container, {
|
|
|
|
|
query,
|
|
|
|
|
installStep: this.getInstallStep(),
|
2020-03-16 11:09:29 +00:00
|
|
|
|
markConfigured: this.markConfigured,
|
2020-04-08 23:17:32 +00:00
|
|
|
|
hasCbdIndustry: currentMethod.hasCbdIndustry,
|
2020-03-15 21:45:19 +00:00
|
|
|
|
} ) }
|
|
|
|
|
</Card>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-29 16:41:04 +00:00
|
|
|
|
return (
|
2020-03-15 21:45:19 +00:00
|
|
|
|
<div className="woocommerce-task-payments">
|
|
|
|
|
{ methods.map( ( method ) => {
|
|
|
|
|
const {
|
|
|
|
|
before,
|
|
|
|
|
container,
|
|
|
|
|
content,
|
2020-03-16 11:09:29 +00:00
|
|
|
|
isConfigured,
|
2020-03-15 21:45:19 +00:00
|
|
|
|
key,
|
|
|
|
|
title,
|
|
|
|
|
visible,
|
|
|
|
|
} = method;
|
|
|
|
|
|
|
|
|
|
if ( ! visible ) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-27 23:24:32 +00:00
|
|
|
|
const classes = classnames(
|
|
|
|
|
'woocommerce-task-payment',
|
|
|
|
|
'is-narrow',
|
|
|
|
|
! isConfigured &&
|
|
|
|
|
'woocommerce-task-payment-not-configured',
|
|
|
|
|
'woocommerce-task-payment-' + key
|
|
|
|
|
);
|
|
|
|
|
|
2020-03-31 12:58:11 +00:00
|
|
|
|
const isRecommended =
|
2020-06-04 09:36:57 +00:00
|
|
|
|
key === recommendedMethod && ! isConfigured;
|
2020-03-31 12:58:11 +00:00
|
|
|
|
const showRecommendedRibbon =
|
2020-06-04 09:36:57 +00:00
|
|
|
|
isRecommended && key !== 'wcpay';
|
2020-03-31 12:58:11 +00:00
|
|
|
|
const showRecommendedPill =
|
2020-06-04 09:36:57 +00:00
|
|
|
|
isRecommended && key === 'wcpay';
|
2020-03-31 12:58:11 +00:00
|
|
|
|
|
2019-08-29 16:41:04 +00:00
|
|
|
|
return (
|
2020-03-27 23:24:32 +00:00
|
|
|
|
<Card key={ key } className={ classes }>
|
2020-03-15 21:45:19 +00:00
|
|
|
|
<div className="woocommerce-task-payment__before">
|
2020-03-31 12:58:11 +00:00
|
|
|
|
{ showRecommendedRibbon && (
|
|
|
|
|
<div className="woocommerce-task-payment__recommended-ribbon">
|
|
|
|
|
<span>
|
|
|
|
|
{ __(
|
|
|
|
|
'Recommended',
|
|
|
|
|
'woocommerce-admin'
|
|
|
|
|
) }
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
) }
|
2020-03-15 21:45:19 +00:00
|
|
|
|
{ before }
|
|
|
|
|
</div>
|
|
|
|
|
<div className="woocommerce-task-payment__text">
|
|
|
|
|
<H className="woocommerce-task-payment__title">
|
|
|
|
|
{ title }
|
2020-03-31 12:58:11 +00:00
|
|
|
|
{ showRecommendedPill && (
|
|
|
|
|
<span className="woocommerce-task-payment__recommended-pill">
|
|
|
|
|
{ __(
|
|
|
|
|
'Recommended',
|
|
|
|
|
'woocommerce-admin'
|
|
|
|
|
) }
|
|
|
|
|
</span>
|
|
|
|
|
) }
|
2020-03-15 21:45:19 +00:00
|
|
|
|
</H>
|
2020-04-08 23:17:32 +00:00
|
|
|
|
<div className="woocommerce-task-payment__content">
|
2020-03-15 21:45:19 +00:00
|
|
|
|
{ content }
|
2020-04-08 23:17:32 +00:00
|
|
|
|
</div>
|
2020-03-15 21:45:19 +00:00
|
|
|
|
</div>
|
|
|
|
|
<div className="woocommerce-task-payment__after">
|
2020-03-16 11:09:29 +00:00
|
|
|
|
{ container && ! isConfigured ? (
|
2020-03-15 21:45:19 +00:00
|
|
|
|
<Button
|
2020-06-04 09:36:57 +00:00
|
|
|
|
isPrimary={ key === recommendedMethod }
|
2020-06-11 19:22:20 +00:00
|
|
|
|
isSecondary={
|
|
|
|
|
key !== recommendedMethod
|
|
|
|
|
}
|
2020-06-12 09:38:02 +00:00
|
|
|
|
isBusy={ busyMethod === key }
|
|
|
|
|
disabled={ busyMethod }
|
|
|
|
|
onClick={ () =>
|
|
|
|
|
this.handleClick( method )
|
|
|
|
|
}
|
2020-03-15 21:45:19 +00:00
|
|
|
|
>
|
|
|
|
|
{ __( 'Set up', 'woocommerce-admin' ) }
|
|
|
|
|
</Button>
|
|
|
|
|
) : (
|
2020-03-16 11:09:29 +00:00
|
|
|
|
<FormToggle
|
|
|
|
|
checked={ enabledMethods[ key ] }
|
|
|
|
|
onChange={ () =>
|
|
|
|
|
this.toggleMethod( key )
|
|
|
|
|
}
|
|
|
|
|
onClick={ ( e ) => e.stopPropagation() }
|
|
|
|
|
/>
|
2020-03-15 21:45:19 +00:00
|
|
|
|
) }
|
|
|
|
|
</div>
|
|
|
|
|
</Card>
|
2019-08-29 16:41:04 +00:00
|
|
|
|
);
|
2020-03-15 21:45:19 +00:00
|
|
|
|
} ) }
|
|
|
|
|
<div className="woocommerce-task-payments__actions">
|
2020-06-15 05:43:22 +00:00
|
|
|
|
{ ! hasEnabledMethods ? (
|
2020-03-15 21:45:19 +00:00
|
|
|
|
<Button isLink onClick={ this.skipTask }>
|
|
|
|
|
{ __(
|
|
|
|
|
'My store doesn’t take payments',
|
|
|
|
|
'woocommerce-admin'
|
|
|
|
|
) }
|
|
|
|
|
</Button>
|
|
|
|
|
) : (
|
2020-06-10 23:49:27 +00:00
|
|
|
|
<Button
|
|
|
|
|
isPrimary
|
|
|
|
|
isBusy={ requesting }
|
|
|
|
|
onClick={ this.completeTask }
|
|
|
|
|
>
|
2020-03-15 21:45:19 +00:00
|
|
|
|
{ __( 'Done', 'woocommerce-admin' ) }
|
|
|
|
|
</Button>
|
|
|
|
|
) }
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2019-08-29 16:41:04 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default compose(
|
2020-06-12 09:38:02 +00:00
|
|
|
|
withDispatch( ( dispatch ) => {
|
|
|
|
|
const { createNotice } = dispatch( 'core/notices' );
|
|
|
|
|
const { installAndActivatePlugins } = dispatch( PLUGINS_STORE_NAME );
|
|
|
|
|
const { updateOptions } = dispatch( OPTIONS_STORE_NAME );
|
|
|
|
|
return {
|
|
|
|
|
createNotice,
|
|
|
|
|
installAndActivatePlugins,
|
|
|
|
|
updateOptions,
|
|
|
|
|
};
|
|
|
|
|
} ),
|
|
|
|
|
withSelect( ( select, props ) => {
|
|
|
|
|
const { createNotice, installAndActivatePlugins } = props;
|
2020-05-28 08:51:40 +00:00
|
|
|
|
const { getProfileItems } = select( ONBOARDING_STORE_NAME );
|
2020-06-10 23:49:27 +00:00
|
|
|
|
const { getOption, isOptionsUpdating } = select( OPTIONS_STORE_NAME );
|
2020-04-16 23:58:36 +00:00
|
|
|
|
const { getActivePlugins, isJetpackConnected } = select(
|
|
|
|
|
PLUGINS_STORE_NAME
|
|
|
|
|
);
|
2020-06-22 22:18:35 +00:00
|
|
|
|
const { getSettings } = select( SETTINGS_STORE_NAME );
|
|
|
|
|
const { general: generalSettings = {} } = getSettings( 'general' );
|
2020-06-10 23:49:27 +00:00
|
|
|
|
|
2020-03-16 11:09:29 +00:00
|
|
|
|
const activePlugins = getActivePlugins();
|
|
|
|
|
const profileItems = getProfileItems();
|
2020-06-10 23:49:27 +00:00
|
|
|
|
|
|
|
|
|
const optionNames = [
|
2020-03-27 23:24:32 +00:00
|
|
|
|
'woocommerce_woocommerce_payments_settings',
|
2020-03-16 11:09:29 +00:00
|
|
|
|
'woocommerce_stripe_settings',
|
|
|
|
|
'woocommerce_ppec_paypal_settings',
|
|
|
|
|
'woocommerce_payfast_settings',
|
|
|
|
|
'woocommerce_square_credit_card_settings',
|
|
|
|
|
'woocommerce_klarna_payments_settings',
|
|
|
|
|
'woocommerce_kco_settings',
|
|
|
|
|
'wc_square_refresh_tokens',
|
2020-03-16 11:57:23 +00:00
|
|
|
|
'woocommerce_cod_settings',
|
|
|
|
|
'woocommerce_bacs_settings',
|
|
|
|
|
'woocommerce_bacs_accounts',
|
2020-06-10 23:49:27 +00:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const options = optionNames.reduce( ( result, name ) => {
|
|
|
|
|
result[ name ] = getOption( name );
|
|
|
|
|
return result;
|
|
|
|
|
}, {} );
|
2020-02-14 02:23:21 +00:00
|
|
|
|
const countryCode = getCountryCode(
|
2020-06-22 22:18:35 +00:00
|
|
|
|
generalSettings.woocommerce_default_country
|
2020-02-14 02:23:21 +00:00
|
|
|
|
);
|
2019-10-03 16:03:29 +00:00
|
|
|
|
|
2020-03-16 11:09:29 +00:00
|
|
|
|
const methods = getPaymentMethods( {
|
|
|
|
|
activePlugins,
|
|
|
|
|
countryCode,
|
2020-06-12 09:38:02 +00:00
|
|
|
|
createNotice,
|
|
|
|
|
installAndActivatePlugins,
|
2020-04-09 23:10:47 +00:00
|
|
|
|
isJetpackConnected: isJetpackConnected(),
|
2020-02-14 02:23:21 +00:00
|
|
|
|
options,
|
2020-03-16 11:09:29 +00:00
|
|
|
|
profileItems,
|
|
|
|
|
} );
|
|
|
|
|
|
2020-06-10 23:49:27 +00:00
|
|
|
|
const requesting = isOptionsUpdating();
|
2019-10-03 16:03:29 +00:00
|
|
|
|
|
2019-08-29 16:41:04 +00:00
|
|
|
|
return {
|
|
|
|
|
countryCode,
|
2020-03-16 11:09:29 +00:00
|
|
|
|
profileItems,
|
|
|
|
|
activePlugins,
|
2019-10-03 16:03:29 +00:00
|
|
|
|
options,
|
2020-03-16 11:09:29 +00:00
|
|
|
|
methods,
|
|
|
|
|
requesting,
|
2019-10-03 16:03:29 +00:00
|
|
|
|
};
|
2019-08-29 16:41:04 +00:00
|
|
|
|
} )
|
|
|
|
|
)( Payments );
|