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

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

61 lines 1.9 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 PayplugOney extends PayplugGenericBlock {
6
7 /**
8 * Payment method name/id/slug.
9 *
10 * @var string
11 */
12 protected $name = "oney";
13
14 protected $icon = '';
15
16 protected $cart;
17
18 protected $total_price;
19
20 /**
21 * Returns an associative array of data to be exposed for the payment method's client side.
22 */
23 public function get_payment_method_data() {
24
25 $data = parent::get_payment_method_data();
26
27 if ( is_checkout() ) {
28 $this->cart = WC()->cart;
29 $this->total_price = floatval( WC()->cart->total );
30 }
31
32 $data['icon'] = [
33 'src' => esc_url( PAYPLUG_GATEWAY_PLUGIN_URL . '/assets/images/checkout/' . $this->icon ),
34 'class' => 'payplug-payment-icon',
35 'alt' => $this->gateway->title
36 ];
37 $data['description'] = $this->gateway->description;
38 $data['oney_response'] = $this->gateway->api->simulate_oney_payment( $this->total_price, 'with_fees' );
39
40 $data['currency'] = get_woocommerce_currency_symbol( get_option( 'woocommerce_currency' ) );
41
42 $data['translations']['bring'] = __( 'Bring', 'payplug' );
43 $data['translations']['oney_financing_cost'] = __( 'oney_financing_cost', 'payplug' );
44 $data['translations']['1st_monthly_payment'] = __( '1st monthly payment', 'payplug' );
45 $data['translations']['2nd_monthly_payment'] = __( '2nd monthly payment', 'payplug' );
46 $data['translations']['oney_total'] = __( 'oney_total', 'payplug' );
47 $data['allowed_country_codes'] = $this->gateway->allowed_country_codes;
48
49 $data['requirements'] = [
50 'max_quantity' => $this->gateway::ONEY_PRODUCT_QUANTITY_MAXIMUM,
51 'max_threshold' => $this->gateway->oney_thresholds_max * 100,
52 'min_threshold' => $this->gateway->oney_thresholds_min * 100,
53 'allowed_country_codes' => $this->gateway->allowed_country_codes
54 ];
55
56 return $data;
57
58 }
59
60 }
61