mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 13:44:42 +08:00
Add ApplePay preview in admin settings.
This commit is contained in:
parent
eb956d9db6
commit
118e49cfde
10 changed files with 343 additions and 19 deletions
|
@ -89,6 +89,8 @@ class ApplepayModule implements ModuleInterface {
|
|||
$module->render_buttons( $c, $apple_payment_method );
|
||||
|
||||
$apple_payment_method->bootstrap_ajax_request();
|
||||
|
||||
$module->load_admin_assets( $c, $apple_payment_method );
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -180,6 +182,43 @@ class ApplepayModule implements ModuleInterface {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers and enqueues the assets.
|
||||
*
|
||||
* @param ContainerInterface $c The container.
|
||||
* @param ApplePayButton $button The button.
|
||||
* @return void
|
||||
*/
|
||||
public function load_admin_assets( ContainerInterface $c, ApplePayButton $button ): void {
|
||||
// Enqueue backend scripts.
|
||||
add_action(
|
||||
'admin_enqueue_scripts',
|
||||
static function () use ( $c, $button ) {
|
||||
if ( ! is_admin() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should add this to the ButtonInterface.
|
||||
*
|
||||
* @psalm-suppress UndefinedInterfaceMethod
|
||||
*/
|
||||
$button->enqueue_admin();
|
||||
}
|
||||
);
|
||||
|
||||
// Adds ApplePay component to the backend button preview settings.
|
||||
add_action(
|
||||
'woocommerce_paypal_payments_admin_gateway_settings',
|
||||
function( array $settings ) use ( $c ): array {
|
||||
if ( is_array( $settings['components'] ) ) {
|
||||
$settings['components'][] = 'applepay';
|
||||
}
|
||||
return $settings;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the Apple Pay buttons in the enabled places.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue