PluginProbe
PayPlug for WooCommerce (Official) / 2.9.0
PayPlug for WooCommerce (Official) v2.9.0
3.0.0 2.18.0 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.1.0 1.10.0 1.10.1 1.2.1 1.2.10 1.2.11 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 All 101 releases
payplug / src / Gateway / Blocks / PayplugAmex.php

PayplugAmex.php in PayPlug for WooCommerce (Official) 2.9.0, at src/Gateway/Blocks/PayplugAmex.php

63 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Payplug\PayplugWoocommerce\Gateway\Blocks;
4
5 class PayplugAmex extends PayplugGenericBlock
6 {
7
8 /**
9 * Payment method name/id/slug.
10 *
11 * @var string
12 */
13 protected $name = "american_express";
14
15 /**
16 * Returns an associative array of data to be exposed for the payment method's client side.
17 */
18 public function get_payment_method_data() {
19 $data = parent::get_payment_method_data();
20 $data['icon'] = [
21 "src" => esc_url(PAYPLUG_GATEWAY_PLUGIN_URL . '/assets/images/checkout/' . $this->gateway->image),
22 'icon_alt' => $data['name'],
23 ];
24
25 $options = get_option('woocommerce_payplug_settings', []);
26 if( $options['payment_method'] === "popup" ){
27 $data['payment_method'] = $this->get_name();
28 $data["popup"] = true;
29 $data['payplug_create_intent_payment'] = \WC_AJAX::get_endpoint('payplug_create_intent');
30 $data['payplug_create_order'] = \WC_AJAX::get_endpoint('payplug_create_order');
31 $data['wp_nonce'] = wp_create_nonce( "woocommerce-process_checkout" );
32
33 }
34
35
36 return $data;
37 }
38
39 /**
40 * Returns an array of scripts/handles to be registered for this payment method.
41 *
42 * @return array
43 */
44 public function get_payment_method_script_handles() {
45
46 $options = get_option('woocommerce_payplug_settings', []);
47 if ( $options['payment_method'] == "popup" ) {
48 $this->popup_scripts();
49 }
50
51 return parent::get_payment_method_script_handles();
52 }
53
54
55 private function popup_scripts(){
56 wp_register_script('payplug', 'https://api.payplug.com/js/1/form.latest.js', [], null, true);
57 wp_enqueue_script('payplug');
58 }
59
60
61
62 }
63