# payplug/3.1.0/src/Gateway/Blocks/PayplugAmex.php

PayPlug for WooCommerce (Official), version 3.1.0. 60 lines.

- Page: https://pluginprobe.com/plugins/payplug/3.1.0/code/src/Gateway/Blocks/PayplugAmex.php
- Raw: https://pluginprobe.com/plugins/payplug/3.1.0/raw/src/Gateway/Blocks/PayplugAmex.php
- Modified: 2026-09-25T08:27:34+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/payplug/3.1.0/code/src/Gateway/Blocks/PayplugAmex.php#L10-L20`.

```php
<?php

namespace Payplug\PayplugWoocommerce\Gateway\Blocks;

class PayplugAmex extends PayplugGenericBlock
{
    /**
     * Payment method name/id/slug.
     *
     * @var string
     */
    protected $name = 'american_express';

    /**
     * Returns an associative array of data to be exposed for the payment method's client side.
     */
    public function get_payment_method_data()
    {
        $data = parent::get_payment_method_data();
        $data['icon'] = [
            'src' => esc_url(PAYPLUG_GATEWAY_PLUGIN_URL . '/assets/images/checkout/' . $this->gateway->image),
            'icon_alt' => $data['name'],
        ];

        $configuration = $this->get_service('configuration');
        $embedded_mode = $configuration->get_option('payment_methods.configuration.payplug.embedded_mode');
        if ('popup' == $embedded_mode) {
            $data['payment_method'] = $this->get_name();
            $data['popup'] = true;
            $data['payplug_create_intent_payment'] = \WC_AJAX::get_endpoint('payplug_create_intent');
            $data['payplug_create_order'] = \WC_AJAX::get_endpoint('payplug_create_order');
            $data['wp_nonce'] = wp_create_nonce('woocommerce-process_checkout');
        }

        return $data;
    }

    /**
     * Returns an array of scripts/handles to be registered for this payment method.
     *
     * @return array
     */
    public function get_payment_method_script_handles()
    {
        $configuration = $this->get_service('configuration');
        $embedded_mode = $configuration->get_option('payment_methods.configuration.payplug.embedded_mode');
        if ('popup' == $embedded_mode) {
            $this->popup_scripts();
        }

        return parent::get_payment_method_script_handles();
    }

    private function popup_scripts(): void
    {
        wp_register_script('payplug', 'https://api.payplug.com/js/1/form.latest.js', [], null, true);
        wp_enqueue_script('payplug');
    }
}

```
