PluginProbe
PayPlug for WooCommerce (Official) / 2.0.1
PayPlug for WooCommerce (Official) v2.0.1
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 / Front / PayplugOney / OneySimulation.php

OneySimulation.php in PayPlug for WooCommerce (Official) 2.0.1, at src/Front/PayplugOney/OneySimulation.php

67 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\Front\PayplugOney;
4
5 use Payplug\PayplugWoocommerce\Gateway\PayplugGateway;
6
7 class OneySimulation implements InterfaceOneySimulation
8 {
9
10 /**
11 * Dependency Injection
12 * @var \Payplug\PayplugWoocommerce\Front\PayplugOney\Country\OneyBase
13 */
14 private $oney;
15
16 /**
17 * @var
18 */
19 public $simulation = [];
20
21 /**
22 * Dependency injection
23 * @param \Payplug\PayplugWoocommerce\Front\PayplugOney\Country\OneyBase $oney
24 */
25 public function __construct($oney)
26 {
27 $this->oney = $oney;
28 }
29
30 /**
31 * Check if Oney Simulation is possible if it is returnss simulation data
32 * @return array|false|object
33 */
34 public function OneySimulation()
35 {
36 $this->oney->setTotalPrice($_POST['price']);
37
38 if ($this->oney->getTotalPrice() < $this->oney->get_min_amount() || $this->oney->getTotalPrice() > $this->oney->get_max_amount())
39 return false;
40
41 try {
42 $this->simulation = $this->requestOneySimulation();
43
44 } catch (\Exception $e) {
45 PayplugGateway::log("Simulate Oney " . $this->oney->getOneyType() ." Fees Payment, " . $e->getMessage() );
46 return false;
47
48 }
49
50 return $this->simulation;
51 }
52
53 /**
54 * return oney simulation data for the order
55 * @param $class
56 * @return array|object
57 */
58 public function requestOneySimulation()
59 {
60 $class = $this->oney->getSimulatedClass();
61 $api = new \Payplug\PayplugWoocommerce\Gateway\PayplugApi( new $class() );
62 $api->init();
63 return $api->simulate_oney_payment($this->oney->getTotalPrice(), $this->oney->getOneyType());
64 }
65
66 }
67