PluginProbe
HyperPay Payments / trunk
HyperPay Payments vtrunk
6.6.0 trunk 1.7 1.8 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.1.0 2.2.0 2.3.0 2.3.1 2.3.2 2.3.3 3.0.0 3.0.5 4.0.0 4.0.2 All 34 releases
hyperpay-gateways / src / Brands / GooglePay.php

GooglePay.php in HyperPay Payments trunk, at src/Brands/GooglePay.php

101 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Hyperpay\Gateways\Brands;
4
5 use Hyperpay\Gateways\App\DefaultGateway;
6 use Hyperpay\Gateways\Helpers\View;
7 use WC_Order;
8
9 class GooglePay extends DefaultGateway
10 {
11
12 public $trans_mode = 'EXTERNAL';
13
14 /**
15 * should be lower case and unique
16 * @var string $id
17 */
18 public $id = "hyperpay_googlepay";
19
20 /**
21 * The title which appear next to gateway on setting page
22 * @var string $method_title
23 */
24 public $method_title = "Google Pay";
25
26 public $merchant_id = "";
27
28 /**
29 * Description of gateways which will appear next to title
30 * @var string $method_description
31 */
32 public $method_description = "Google Pay Plugin for Woocommerce";
33
34
35 /**
36 * the Brands supported by the gateway
37 * @var array $supported_brands
38 */
39 protected $supported_brands = [
40 "GOOGLEPAY" => "Google Pay",
41 ];
42
43
44 public function boot()
45 {
46 $extra_fields = [];
47 $extra_fields['merchant_id'] = [
48 'title' => __('Merchant ID', 'hyperpay-gateways'),
49 'type' => 'text',
50 'default' => ''
51 ];
52
53
54 $this->form_fields = array_merge(array_slice($this->form_fields, 0, 7), $extra_fields, array_slice($this->form_fields, 7));
55
56 $this->merchant_id = $this->get_option('merchant_id');
57 }
58
59 public function renderPaymentForm(WC_Order $order, $result)
60 {
61
62
63 $token = $result['response']['id'];
64 $postBackURL = $result['postBackURL'];
65
66 $payment_brands = $this->brands;
67
68 if (is_array($this->brands))
69 $payment_brands = implode(' ', $this->brands);
70
71
72 $dataObj = [
73 'is_arabic' => esc_js($this->is_arabic),
74 'style' => esc_html($this->payment_style),
75 'postBackURL' => ($postBackURL),
76 'payment_brands' => esc_html($payment_brands),
77 'custom_style' => esc_html($this->custom_style),
78 'scriptURL' => esc_html($this->script_url),
79 'checkoutId' => $token,
80 'integrity' => esc_html($result['integrity'] ?? ''),
81 'orderId' => $order->id,
82 'nonce' => $this->NONCE,
83 'id' => $this->id,
84 'entityId' => $this->entityId,
85 'merchantId' => $this->merchant_id
86 ];
87
88
89 if ($this->supported_network) {
90 $dataObj['supported_network'] = $this->supported_network;
91 }
92
93
94 add_action('wp_head', [$this, 'custom_add_to_head']);
95
96 $scriptSrc = "googlepay-script.js";
97
98 return View::render('copy-and-pay.html', compact('dataObj', 'scriptSrc'));
99 }
100 }
101