| 1 |
<?php |
| 2 |
namespace Hyperpay\Gateways\Brands; |
| 3 |
|
| 4 |
use Hyperpay\Gateways\App\DefaultGateway; |
| 5 |
use Hyperpay\Gateways\Main; |
| 6 |
use WC_Order; |
| 7 |
|
| 8 |
|
| 9 |
class ClickToPay extends DefaultGateway |
| 10 |
{ |
| 11 |
public $trans_mode = 'EXTERNAL'; |
| 12 |
|
| 13 |
/** |
| 14 |
* should be lower case and unique |
| 15 |
* @var string $id |
| 16 |
*/ |
| 17 |
public $id = 'hyperpay_clicktopay'; |
| 18 |
|
| 19 |
/** |
| 20 |
* The title which appear next to gateway on setting page |
| 21 |
* @var string $method_title |
| 22 |
*/ |
| 23 |
public $method_title = 'Click To Pay Gateway'; |
| 24 |
|
| 25 |
/** |
| 26 |
* Description of gateways which will appear next to title |
| 27 |
* @var string $method_description |
| 28 |
*/ |
| 29 |
public $method_description = 'Click To Pay Plugin for Woocommerce'; |
| 30 |
|
| 31 |
/** |
| 32 |
* |
| 33 |
* the Brands supported by the gateway |
| 34 |
* @var array $supported_brands |
| 35 |
*/ |
| 36 |
protected $supported_brands = [ |
| 37 |
'MASTER' => 'Master Card', |
| 38 |
'VISA' => 'Visa', |
| 39 |
'AMEX' => 'American Express', |
| 40 |
'JCB' => 'Japan Credit Bureau', |
| 41 |
'CLICK_TO_PAY' => 'Click to pay', |
| 42 |
]; |
| 43 |
|
| 44 |
public function __construct() |
| 45 |
{ |
| 46 |
parent::__construct(); |
| 47 |
$this->blackBins = require_once(Main::ROOT_PATH . '/App/blackBins.php'); |
| 48 |
$this->brands = \array_keys($this->supported_brands); |
| 49 |
unset($this->form_fields['hyper_pay_brands']); |
| 50 |
} |
| 51 |
|
| 52 |
public function renderPaymentForm(WC_Order $order, $result) |
| 53 |
{ |
| 54 |
parent::renderPaymentForm($order,$result); |
| 55 |
wp_enqueue_script('CLICK_TO_PAY_JS', HYPERPAY_PLUGIN_DIR . '/src/assets/js/click_to_pay.js', ['jquery'], '1.0.0', true); |
| 56 |
wp_localize_script('CLICK_TO_PAY_JS', 'hyperpay_dataObj_click_to_pay', ["email" => $order->get_billing_email()]); |
| 57 |
} |
| 58 |
|
| 59 |
public function iconSrc() |
| 60 |
{ |
| 61 |
$img = HYPERPAY_PLUGIN_DIR . '/src/assets/images/default.png'; |
| 62 |
if (file_exists(Main::ROOT_PATH . '/assets/images/click-to-pay.png')) |
| 63 |
$img = HYPERPAY_PLUGIN_DIR . '/src/assets/images/click-to-pay.png'; |
| 64 |
|
| 65 |
return [$img]; |
| 66 |
} |
| 67 |
|
| 68 |
|
| 69 |
} |
| 70 |
|