mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 12:25:15 +08:00
Refactor: extract logic to corresponding modules
This commit is contained in:
parent
c4232e3957
commit
9f18f2e899
13 changed files with 2549 additions and 451 deletions
|
@ -5,9 +5,8 @@ import {
|
|||
} from '../../../ppcp-button/resources/js/modules/Helper/CheckoutMethodState';
|
||||
import { loadScript } from '@paypal/paypal-js';
|
||||
import ErrorHandler from '../../../ppcp-button/resources/js/modules/ErrorHandler';
|
||||
|
||||
import Configuration from './Configuration';
|
||||
import RenderCardFields from './RenderCardFields';
|
||||
import { buttonConfiguration, cardFieldsConfiguration } from './Configuration';
|
||||
import { renderFields } from '../../../ppcp-card-fields/resources/js/Render';
|
||||
import {
|
||||
setVisible,
|
||||
setVisibleByClass,
|
||||
|
@ -55,30 +54,32 @@ import {
|
|||
);
|
||||
errorHandler.clear();
|
||||
|
||||
const configuration = new Configuration(
|
||||
ppcp_add_payment_method,
|
||||
errorHandler
|
||||
);
|
||||
|
||||
const paypalButtonContainer = document.querySelector(
|
||||
`#ppc-button-${ PaymentMethods.PAYPAL }-save-payment-method`
|
||||
);
|
||||
|
||||
if ( paypalButtonContainer ) {
|
||||
paypal
|
||||
.Buttons( configuration.buttonConfiguration() )
|
||||
.Buttons(
|
||||
buttonConfiguration(
|
||||
ppcp_add_payment_method,
|
||||
errorHandler
|
||||
)
|
||||
)
|
||||
.render(
|
||||
`#ppc-button-${ PaymentMethods.PAYPAL }-save-payment-method`
|
||||
);
|
||||
}
|
||||
|
||||
const cardFields = paypal.CardFields(
|
||||
configuration.cardFieldsConfiguration()
|
||||
cardFieldsConfiguration(
|
||||
ppcp_add_payment_method,
|
||||
errorHandler
|
||||
)
|
||||
);
|
||||
|
||||
if ( cardFields.isEligible() ) {
|
||||
const renderCardFields = new RenderCardFields( cardFields );
|
||||
renderCardFields.render();
|
||||
renderFields( cardFields );
|
||||
}
|
||||
|
||||
document
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue