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 / PayplugCreditCard.php

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

110 lines 4.7 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 use Payplug\PayplugWoocommerce\PayplugWoocommerceHelper;
6
7 class PayplugCreditCard extends PayplugGenericBlock
8 {
9
10 /**
11 * Payment method name/id/slug.
12 *
13 * @var string
14 */
15 protected $name = "payplug";
16
17 /**
18 * Returns an associative array of data to be exposed for the payment method's client side.
19 */
20 public function get_payment_method_data() {
21
22 $data = parent::get_payment_method_data();
23 $data['icon'] = [
24 "src" => ('it_IT' === get_locale()) ?
25 PAYPLUG_GATEWAY_PLUGIN_URL . '/assets/images/checkout/logos_scheme_PostePay.svg' :
26 PAYPLUG_GATEWAY_PLUGIN_URL . '/assets/images/checkout/logos_scheme_CB.svg',
27 'icon_alt' => "Visa & Mastercard",
28 ];
29 $data["IP"] = false;
30 $data["popup"] = false;
31 $data['payment_method'] = $this->get_name();
32
33 $options = get_option('woocommerce_payplug_settings', []);
34 if( $options['payment_method'] === "integrated" ){
35 $data["payplug_integrated_payment_cardHolder_error"] = __('payplug_integrated_payment_cardHolder_error', 'payplug');
36 $data["payplug_integrated_payment_empty"] = __('payplug_integrated_payment_empty', 'payplug');
37 $data["payplug_integrated_payment_your_card"] = __('payplug_integrated_payment_your_card', 'payplug');
38 $data["payplug_integrated_payment_pan_error"] = __('payplug_integrated_payment_pan_error', 'payplug');
39 $data["payplug_integrated_payment_exp_error"] = __('payplug_integrated_payment_exp_error', 'payplug');
40 $data["payplug_integrated_payment_cvv_error"] = __('payplug_integrated_payment_cvv_error', 'payplug');
41 $data["payplug_integrated_payment_error"] = __('payplug_integrated_payment_error', 'payplug');
42 $data["payplug_integrated_payment_transaction_secure"] = __('payplug_integrated_payment_transaction_secure', 'payplug');
43 $data['logo'] = PAYPLUG_GATEWAY_PLUGIN_URL . '/assets/images/integrated/logo-payplug.png';
44 $data['lock'] = PAYPLUG_GATEWAY_PLUGIN_URL . '/assets/images/integrated/lock.svg';
45 $data['payplug_integrated_payment_privacy_policy_url'] = __("payplug_integrated_payment_privacy_policy_url", "payplug");
46 $data['payplug_integrated_payment_privacy_policy'] = __('payplug_integrated_payment_privacy_policy', 'payplug');
47 $data["payplug_integrated_payment_cardholder"] = __('payplug_integrated_payment_cardholder', 'payplug');
48 $data["payplug_integrated_payment_card_number"] = __('payplug_integrated_payment_card_number', 'payplug');
49 $data["payplug_integrated_payment_expiration_date"] = __('payplug_integrated_payment_expiration_date', 'payplug');
50 $data["payplug_integrated_payment_cvv"] = __('payplug_integrated_payment_cvv', 'payplug');
51 $data["payplug_invalid_form"] = __('payplug_required_fields_error', 'payplug');
52 $data['payplug_create_intent_payment'] = \WC_AJAX::get_endpoint('payplug_create_intent');
53 $data['payplug_integrated_payment_check_payment_url'] = \WC_AJAX::get_endpoint('payplug_check_payment');
54 $data['payplug_integrated_payment_nonce_field'] = wp_nonce_field('woocommerce-process_checkout', 'woocommerce-process-checkout-nonce');
55 $data['wp_nonce'] = wp_create_nonce( "woocommerce-process_checkout" );
56 $data['mode'] = PayplugWoocommerceHelper::check_mode();
57 $data["IP"] = true;
58
59 }else if( $options['payment_method'] === "popup" ){
60 $data["popup"] = true;
61 $data['payplug_create_intent_payment'] = \WC_AJAX::get_endpoint('payplug_create_intent');
62 $data['payplug_create_order'] = \WC_AJAX::get_endpoint('payplug_create_order');
63 $data['wp_nonce'] = wp_create_nonce( "woocommerce-process_checkout" );
64
65 }
66
67 return $data;
68 }
69
70 /**
71 * Returns an array of scripts/handles to be registered for this payment method.
72 *
73 * @return array
74 */
75 public function get_payment_method_script_handles() {
76
77 $options = get_option('woocommerce_payplug_settings', []);
78 if( $options['payment_method'] === "integrated" && !is_wc_endpoint_url('order-pay')){
79 $this->ip_scripts();
80 }
81
82 if ( $options['payment_method'] == "popup" ) {
83 $this->popup_scripts();
84 }
85
86 return parent::get_payment_method_script_handles();
87 }
88
89 private function ip_scripts(){
90 wp_enqueue_style('payplugIP', PAYPLUG_GATEWAY_PLUGIN_URL . 'assets/css/payplug-integrated-payments.css', [], PAYPLUG_GATEWAY_VERSION);
91 wp_register_script(
92 'payplug-integrated-payments-api',
93 'https://cdn.payplug.com/js/integrated-payment/v1@1/index.js',
94 array(),
95 'v1.1',
96 true
97 );
98
99 wp_register_script('payplug-domain', PAYPLUG_GATEWAY_PLUGIN_URL . 'assets/js/payplug-domain.js', [], 'v1.0');
100 wp_enqueue_script('payplug-domain');
101
102 wp_enqueue_script('payplug-integrated-payments-api');
103 }
104
105 private function popup_scripts(){
106 wp_register_script('payplug-popup', 'https://api.payplug.com/js/1/form.latest.js', [], null, true);
107 wp_enqueue_script('payplug-popup');
108 }
109 }
110