PluginProbe
PayPlug for WooCommerce (Official) / 2.10.0
PayPlug for WooCommerce (Official) v2.10.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.10.0, at src/Gateway/Blocks/PayplugCreditCard.php

112 lines 4.8 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 $data['supports'] = $this->get_supported_features();
33 $data['showSaveOption'] = !empty($this->gateway->oneclick) ? $this->gateway->oneclick : false;
34
35 $options = get_option('woocommerce_payplug_settings', []);
36 if( $options['payment_method'] === "integrated" ){
37 $data["payplug_integrated_payment_cardHolder_error"] = __('payplug_integrated_payment_cardHolder_error', 'payplug');
38 $data["payplug_integrated_payment_empty"] = __('payplug_integrated_payment_empty', 'payplug');
39 $data["payplug_integrated_payment_your_card"] = __('payplug_integrated_payment_your_card', 'payplug');
40 $data["payplug_integrated_payment_pan_error"] = __('payplug_integrated_payment_pan_error', 'payplug');
41 $data["payplug_integrated_payment_exp_error"] = __('payplug_integrated_payment_exp_error', 'payplug');
42 $data["payplug_integrated_payment_cvv_error"] = __('payplug_integrated_payment_cvv_error', 'payplug');
43 $data["payplug_integrated_payment_error"] = __('payplug_integrated_payment_error', 'payplug');
44 $data["payplug_integrated_payment_transaction_secure"] = __('payplug_integrated_payment_transaction_secure', 'payplug');
45 $data['logo'] = PAYPLUG_GATEWAY_PLUGIN_URL . '/assets/images/integrated/logo-payplug.png';
46 $data['lock'] = PAYPLUG_GATEWAY_PLUGIN_URL . '/assets/images/integrated/lock.svg';
47 $data['payplug_integrated_payment_privacy_policy_url'] = __("payplug_integrated_payment_privacy_policy_url", "payplug");
48 $data['payplug_integrated_payment_privacy_policy'] = __('payplug_integrated_payment_privacy_policy', 'payplug');
49 $data["payplug_integrated_payment_cardholder"] = __('payplug_integrated_payment_cardholder', 'payplug');
50 $data["payplug_integrated_payment_card_number"] = __('payplug_integrated_payment_card_number', 'payplug');
51 $data["payplug_integrated_payment_expiration_date"] = __('payplug_integrated_payment_expiration_date', 'payplug');
52 $data["payplug_integrated_payment_cvv"] = __('payplug_integrated_payment_cvv', 'payplug');
53 $data["payplug_invalid_form"] = __('payplug_required_fields_error', 'payplug');
54 $data['payplug_create_intent_payment'] = \WC_AJAX::get_endpoint('payplug_create_intent');
55 $data['payplug_integrated_payment_check_payment_url'] = \WC_AJAX::get_endpoint('payplug_check_payment');
56 $data['payplug_integrated_payment_nonce_field'] = wp_nonce_field('woocommerce-process_checkout', 'woocommerce-process-checkout-nonce');
57 $data['wp_nonce'] = wp_create_nonce( "woocommerce-process_checkout" );
58 $data['mode'] = PayplugWoocommerceHelper::check_mode();
59 $data["IP"] = true;
60
61 }else if( $options['payment_method'] === "popup" ){
62 $data["popup"] = true;
63 $data['payplug_create_intent_payment'] = \WC_AJAX::get_endpoint('payplug_create_intent');
64 $data['payplug_create_order'] = \WC_AJAX::get_endpoint('payplug_create_order');
65 $data['wp_nonce'] = wp_create_nonce( "woocommerce-process_checkout" );
66
67 }
68
69 return $data;
70 }
71
72 /**
73 * Returns an array of scripts/handles to be registered for this payment method.
74 *
75 * @return array
76 */
77 public function get_payment_method_script_handles() {
78
79 $options = get_option('woocommerce_payplug_settings', []);
80 if( $options['payment_method'] === "integrated" && !is_wc_endpoint_url('order-pay')){
81 $this->ip_scripts();
82 }
83
84 if ( $options['payment_method'] == "popup" ) {
85 $this->popup_scripts();
86 }
87
88 return parent::get_payment_method_script_handles();
89 }
90
91 private function ip_scripts(){
92 wp_enqueue_style('payplugIP', PAYPLUG_GATEWAY_PLUGIN_URL . 'assets/css/payplug-integrated-payments.css', [], PAYPLUG_GATEWAY_VERSION);
93 wp_register_script(
94 'payplug-integrated-payments-api',
95 'https://cdn.payplug.com/js/integrated-payment/v1@1/index.js',
96 array(),
97 'v1.1',
98 true
99 );
100
101 wp_register_script('payplug-domain', PAYPLUG_GATEWAY_PLUGIN_URL . 'assets/js/payplug-domain.js', [], 'v1.0');
102 wp_enqueue_script('payplug-domain');
103
104 wp_enqueue_script('payplug-integrated-payments-api');
105 }
106
107 private function popup_scripts(){
108 wp_register_script('payplug-popup', 'https://api.payplug.com/js/1/form.latest.js', [], null, true);
109 wp_enqueue_script('payplug-popup');
110 }
111 }
112