| 1 |
<?php |
| 2 |
|
| 3 |
namespace Hyperpay\Gateways\Brands; |
| 4 |
|
| 5 |
use Hyperpay\Gateways\App\DefaultGateway; |
| 6 |
use Hyperpay\Gateways\Traits\HyperpayExpressBlock; |
| 7 |
use Hyperpay\Gateways\Helpers\View; |
| 8 |
|
| 9 |
class ApplePay extends DefaultGateway |
| 10 |
{ |
| 11 |
use HyperpayExpressBlock; |
| 12 |
|
| 13 |
/** |
| 14 |
* should be lower case and unique |
| 15 |
* @var string $id |
| 16 |
*/ |
| 17 |
public $id = 'hyperpay_applepay'; |
| 18 |
|
| 19 |
|
| 20 |
public $isExpress = true; |
| 21 |
|
| 22 |
public $action_button = true; |
| 23 |
public $action_style = ''; |
| 24 |
public $action_type = ''; |
| 25 |
public $form_fields = []; |
| 26 |
|
| 27 |
/** |
| 28 |
* The title which appear next to gateway on setting page |
| 29 |
* @var string $method_title |
| 30 |
*/ |
| 31 |
public $method_title = 'ApplePay'; |
| 32 |
|
| 33 |
/** |
| 34 |
* Description of gateways which will appear next to title |
| 35 |
* @var string $method_description |
| 36 |
*/ |
| 37 |
public $method_description = 'ApplePay Plugin for Woocommerce'; |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
/** |
| 42 |
* |
| 43 |
* the Brands supported by the gateway |
| 44 |
* @var array $supported_brands |
| 45 |
*/ |
| 46 |
protected $supported_brands = [ |
| 47 |
'APPLEPAY' => 'ApplePay', |
| 48 |
'APPLEPAYTKN' => 'ApplePay Token', |
| 49 |
]; |
| 50 |
|
| 51 |
|
| 52 |
protected $button_types = [ |
| 53 |
"buy" => "buy", |
| 54 |
"donate" => "donate", |
| 55 |
"plain" => "plain", |
| 56 |
"book" => "book", |
| 57 |
"check-out" => "check-out", |
| 58 |
"subscribe" => "subscribe", |
| 59 |
"add-money" => "add-money", |
| 60 |
"order" => "order", |
| 61 |
"reload" => "reload", |
| 62 |
"rent" => "rent", |
| 63 |
"support" => "support", |
| 64 |
]; |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
public function boot() |
| 69 |
{ |
| 70 |
/** |
| 71 |
* add supported_network field to position number 6 |
| 72 |
*/ |
| 73 |
$extra_fields['supported_network'] = [ |
| 74 |
'title' => __('Supported Network', 'hyperpay-gateways'), |
| 75 |
'type' => 'multiselect', |
| 76 |
'options' => [ |
| 77 |
"visa" => "Visa", |
| 78 |
"masterCard" => "Master", |
| 79 |
"amex" => "Amex", |
| 80 |
"mada" => "Mada" |
| 81 |
], |
| 82 |
'default' => ["visa", "masterCard", "amex"] |
| 83 |
]; |
| 84 |
|
| 85 |
$extra_fields['icon'] = [ |
| 86 |
'title' => __('Preview action button', 'hyperpay-gateways'), |
| 87 |
'type' => 'icon', |
| 88 |
'tip' => __('This will be the apple pay style on checkout', 'hyperpay-gateways'), |
| 89 |
]; |
| 90 |
|
| 91 |
|
| 92 |
$extra_fields['action_type'] = [ |
| 93 |
'title' => __('Action button', 'hyperpay-gateways'), |
| 94 |
'type' => 'select', |
| 95 |
'options' => $this->button_types, |
| 96 |
'default' => "plain", |
| 97 |
]; |
| 98 |
|
| 99 |
$extra_fields['action_style'] = [ |
| 100 |
'title' => __('Action style', 'hyperpay-gateways'), |
| 101 |
'type' => 'select', |
| 102 |
'options' => ["black" => "black", "white-with-line" => "white"], |
| 103 |
'default' => "white-with-line" |
| 104 |
]; |
| 105 |
|
| 106 |
|
| 107 |
$this->form_fields = array_merge(array_slice($this->form_fields, 0, 7), $extra_fields, array_slice($this->form_fields, 7)); |
| 108 |
$this->supported_network = $this->get_option('supported_network'); |
| 109 |
$this->action_type = $this->get_option('action_type'); |
| 110 |
$this->action_style = $this->get_option('action_style'); |
| 111 |
$this->action_button = HYPERPAY_PLUGIN_DIR . "/src/assets/images/applePayButtons/button-{$this->action_type}-{$this->action_style}-min.png"; |
| 112 |
} |
| 113 |
|
| 114 |
public function extraScriptData() |
| 115 |
{ |
| 116 |
return [ |
| 117 |
"action_type" => $this->action_type, |
| 118 |
"action_style" => $this->action_style, |
| 119 |
'testMode' => $this->testMode |
| 120 |
]; |
| 121 |
} |
| 122 |
|
| 123 |
|
| 124 |
public function generate_icon_html($key, $data) |
| 125 |
{ |
| 126 |
ob_start(); |
| 127 |
View::render('fields/icon.html', compact('data')); |
| 128 |
return ob_get_clean(); |
| 129 |
} |
| 130 |
} |
| 131 |
|