| 1 |
<?php |
| 2 |
|
| 3 |
namespace Payplug\PayplugWoocommerce\Admin; |
| 4 |
|
| 5 |
use Payplug\PayplugWoocommerce\Admin\Vue\Component; |
| 6 |
use Payplug\PayplugWoocommerce\Admin\Vue\PaymentMethods; |
| 7 |
use Payplug\PayplugWoocommerce\Controller\ApplePay; |
| 8 |
use Payplug\PayplugWoocommerce\Gateway\PayplugApi; |
| 9 |
use Payplug\PayplugWoocommerce\Gateway\PayplugGateway; |
| 10 |
use Payplug\PayplugWoocommerce\Gateway\PayplugGatewayRequirements; |
| 11 |
use Payplug\PayplugWoocommerce\PayplugWoocommerceHelper; |
| 12 |
use Payplug\PayplugWoocommerce\Traits\GatewayGetter; |
| 13 |
|
| 14 |
/** |
| 15 |
* PayPlug admin Vue.js dashboard handler. |
| 16 |
*/ |
| 17 |
class Vue |
| 18 |
{ |
| 19 |
use GatewayGetter; |
| 20 |
|
| 21 |
private $configuration; |
| 22 |
private $options; |
| 23 |
private $payplug_api; |
| 24 |
|
| 25 |
public function __construct() |
| 26 |
{ |
| 27 |
$payplug = (new PayplugGateway()); |
| 28 |
$this->configuration = $payplug->get_configuration(); |
| 29 |
$this->options = $payplug->settings; |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* @return array |
| 34 |
*/ |
| 35 |
public function init() |
| 36 |
{ |
| 37 |
if ($this->get_gateway('account')->is_logged()) { |
| 38 |
$header = $this->payplug_section_header(); |
| 39 |
$logged = $this->payplug_section_logged(); |
| 40 |
|
| 41 |
unset($this->options['api_key']); |
| 42 |
unset($this->options['company_id']); |
| 43 |
unset($this->options['jwt']); |
| 44 |
unset($this->options['oauth_client_data']); |
| 45 |
unset($this->options['oauth_client_id']); |
| 46 |
unset($this->options['oauth_code_verifier']); |
| 47 |
unset($this->options['oauth_company_id']); |
| 48 |
|
| 49 |
return [ |
| 50 |
'payplug_wooc_settings' => $this->options, |
| 51 |
'header' => $header, |
| 52 |
'oauth_login' => $this->payplug_section_oauth_login(), |
| 53 |
'logged' => $logged, |
| 54 |
'payment_methods' => $this->payplug_section_payment_methods($this->options), |
| 55 |
'payment_paylater' => $this->payplug_section_paylater(), |
| 56 |
'status' => $this->payplug_section_status($this->options), |
| 57 |
'footer' => $this->payplug_section_footer(), |
| 58 |
]; |
| 59 |
} |
| 60 |
|
| 61 |
return [ |
| 62 |
'header' => $this->payplug_section_header(), |
| 63 |
'oauth_login' => $this->payplug_section_oauth_login(), |
| 64 |
'subscribe' => $this->payplug_section_subscribe(), |
| 65 |
'payment_methods' => $this->payplug_section_payment_methods(), |
| 66 |
'payment_paylater' => $this->payplug_section_paylater(), |
| 67 |
'status' => $this->payplug_section_status(), |
| 68 |
'footer' => $this->payplug_section_footer(), |
| 69 |
]; |
| 70 |
} |
| 71 |
|
| 72 |
/** |
| 73 |
* @return array |
| 74 |
*/ |
| 75 |
public function payplug_section_logged() |
| 76 |
{ |
| 77 |
$inactive = false; |
| 78 |
if (empty(PayplugWoocommerceHelper::get_live_key())) { |
| 79 |
$inactive = true; |
| 80 |
} |
| 81 |
$this->payplug_api = new PayplugApi($this); |
| 82 |
$callback_uri = get_admin_url(null, '/admin.php?page=wc-settings&tab=checkout§ion=payplug'); |
| 83 |
$register_url = $this->payplug_api->retrieve_register_url($callback_uri); |
| 84 |
|
| 85 |
return [ |
| 86 |
'title' => __('payplug_section_logged_title', 'payplug'), |
| 87 |
'descriptions' => [ |
| 88 |
'live' => [ |
| 89 |
'description' => __('payplug_section_logged_description', 'payplug'), |
| 90 |
'logout' => __('payplug_section_logged_logout', 'payplug'), |
| 91 |
'mode' => __('payplug_section_logged_mode', 'payplug'), |
| 92 |
'mode_description' => __('payplug_section_logged_live_description', 'payplug'), |
| 93 |
'link_learn_more' => [ |
| 94 |
'text' => __('payplug_learn_more', 'payplug'), |
| 95 |
'url' => __('payplug_mode_learn_more_url', 'payplug'), |
| 96 |
'target' => '_blank', |
| 97 |
], |
| 98 |
'link_access_portal' => [ |
| 99 |
'text' => __('payplug_section_logged_link_access_portal', 'payplug'), |
| 100 |
'url' => 'https://portal.payplug.com/', |
| 101 |
'target' => '_blank', |
| 102 |
], |
| 103 |
], |
| 104 |
'sandbox' => [ |
| 105 |
'description' => __('payplug_section_logged_description', 'payplug'), |
| 106 |
'logout' => __('payplug_section_logged_logout', 'payplug'), |
| 107 |
'mode' => __('payplug_section_logged_mode', 'payplug'), |
| 108 |
'mode_description' => __('payplug_section_logged_test_description', 'payplug'), |
| 109 |
'link_learn_more' => [ |
| 110 |
'text' => __('payplug_learn_more', 'payplug'), |
| 111 |
'url' => __('payplug_mode_learn_more_url', 'payplug'), |
| 112 |
'target' => '_blank', |
| 113 |
], |
| 114 |
'link_access_portal' => [ |
| 115 |
'text' => __('payplug_section_logged_link_access_portal', 'payplug'), |
| 116 |
'url' => 'https://portal.payplug.com/', |
| 117 |
'target' => '_blank', |
| 118 |
], |
| 119 |
], |
| 120 |
], |
| 121 |
'options' => [ |
| 122 |
[ |
| 123 |
'name' => 'payplug_sandbox', |
| 124 |
'label' => 'Test', |
| 125 |
'value' => 1, //test |
| 126 |
'checked' => !PayplugWoocommerceHelper::check_mode(), |
| 127 |
], |
| 128 |
[ |
| 129 |
'name' => 'payplug_sandbox', |
| 130 |
'label' => 'Live', |
| 131 |
'value' => 0, //live |
| 132 |
'checked' => PayplugWoocommerceHelper::check_mode(), |
| 133 |
], |
| 134 |
], |
| 135 |
'inactive_modal' => [ |
| 136 |
'inactive' => $inactive, |
| 137 |
'title' => __('payplug_live_mode', 'payplug'), |
| 138 |
'description' => __('payplug_section_logged_modal_description', 'payplug'), |
| 139 |
'description_1' => __('payplug_section_logged_modal_description_1_uauth', 'payplug'), |
| 140 |
'description_2' => __('payplug_section_logged_modal_description_2_uauth', 'payplug'), |
| 141 |
'password_label' => __('payplug_section_login_password_label', 'payplug'), |
| 142 |
'cancel' => __('payplug_cancel', 'payplug'), |
| 143 |
'ok' => __('payplug_ok', 'payplug'), |
| 144 |
'oauth' => __('payplug_reconnect', 'payplug'), |
| 145 |
'oauth_url' => $register_url, |
| 146 |
], |
| 147 |
'inactive_account' => [ |
| 148 |
'warning' => [ |
| 149 |
'title' => __('payplug_inactive_account_warning_title', 'payplug'), |
| 150 |
'description' => __('payplug_inactive_account_warning_description1', 'payplug') . |
| 151 |
__('payplug_inactive_account_warning_description2', 'payplug') . |
| 152 |
__('payplug_inactive_account_warning_description3', 'payplug'), |
| 153 |
], |
| 154 |
'error' => [ |
| 155 |
'title' => __('payplug_inactive_account_error_title', 'payplug'), |
| 156 |
'description' => __('payplug_inactive_account_error_description', 'payplug'), |
| 157 |
], |
| 158 |
], |
| 159 |
]; |
| 160 |
} |
| 161 |
|
| 162 |
/** |
| 163 |
* @return array[] |
| 164 |
*/ |
| 165 |
public function payplug_section_login() |
| 166 |
{ |
| 167 |
$login = [ |
| 168 |
'name' => 'generalLogin', |
| 169 |
'title' => __('payplug_section_logged_title', 'payplug'), |
| 170 |
'descriptions' => [ |
| 171 |
'live' => [ |
| 172 |
'description' => __('payplug_section_login_description', 'payplug'), |
| 173 |
'not_registered' => __('payplug_section_login_not_registered', 'payplug'), |
| 174 |
'connect' => __('payplug_section_login_connect', 'payplug'), |
| 175 |
'email_label' => __('payplug_section_login_email_label', 'payplug'), |
| 176 |
'email_placeholder' => __('payplug_section_login_email_label', 'payplug'), |
| 177 |
'password_label' => __('payplug_section_login_password_label', 'payplug'), |
| 178 |
'password_placeholder' => __('payplug_section_login_password_label', 'payplug'), |
| 179 |
'link_forgot_password' => [ |
| 180 |
'text' => __('payplug_section_login_forgot_password', 'payplug'), |
| 181 |
'url' => 'https://portal.payplug.com/forgot_password', |
| 182 |
'target' => '_blank', |
| 183 |
], |
| 184 |
], |
| 185 |
'sandbox' => [ |
| 186 |
'description' => __('payplug_section_login_description', 'payplug'), |
| 187 |
'not_registered' => __('payplug_section_login_not_registered', 'payplug'), |
| 188 |
'connect' => __('payplug_section_login_connect', 'payplug'), |
| 189 |
'email_label' => __('payplug_section_login_email_label', 'payplug'), |
| 190 |
'email_placeholder' => __('payplug_section_login_email_label', 'payplug'), |
| 191 |
'password_label' => __('payplug_section_login_password_label', 'payplug'), |
| 192 |
'password_placeholder' => __('payplug_section_login_password_label', 'payplug'), |
| 193 |
'link_forgot_password' => [ |
| 194 |
'text' => __('payplug_section_login_forgot_password', 'payplug'), |
| 195 |
'url' => 'https://portal.payplug.com/forgot_password', |
| 196 |
'target' => '_blank', |
| 197 |
], |
| 198 |
], |
| 199 |
], |
| 200 |
]; |
| 201 |
|
| 202 |
return $login; |
| 203 |
} |
| 204 |
|
| 205 |
/** |
| 206 |
* @return array[] |
| 207 |
*/ |
| 208 |
public function payplug_section_oauth_login() |
| 209 |
{ |
| 210 |
$this->payplug_api = new PayplugApi($this); |
| 211 |
$callback_uri = get_admin_url(null, '/admin.php?page=wc-settings&tab=checkout§ion=payplug'); |
| 212 |
$register_url = $this->payplug_api->retrieve_register_url($callback_uri); |
| 213 |
|
| 214 |
$oauth_login = [ |
| 215 |
'name' => 'oauthLogin', |
| 216 |
'title' => __('payplug_section_logged_title', 'payplug'), |
| 217 |
'descriptions' => [ |
| 218 |
'live' => [ |
| 219 |
'description' => __('payplug_section_oauth_login_description', 'payplug'), |
| 220 |
'form' => [ |
| 221 |
'email' => [ |
| 222 |
'label' => __('payplug_section_login_email_label', 'payplug'), |
| 223 |
'placeholder' => __('payplug_section_login_email_label', 'payplug'), |
| 224 |
], |
| 225 |
'password' => [ |
| 226 |
'label' => __('payplug_section_login_password_label', 'payplug'), |
| 227 |
'placeholder' => __('payplug_section_login_password_label', 'payplug'), |
| 228 |
], |
| 229 |
'connexion' => __('payplug_section_login_connect', 'payplug'), |
| 230 |
'create_account' => __('payplug_section_login_not_registered', 'payplug'), |
| 231 |
'forgot_password' => __('payplug_section_login_forgot_password', 'payplug'), |
| 232 |
'error' => __('payplug_section_login_error', 'payplug'), |
| 233 |
'create_account_url' => 'https://portal.payplug.com/auth/signup', |
| 234 |
'forgot_password_url' => 'https://portal.payplug.com/forgot_password', |
| 235 |
], |
| 236 |
'sso' => [ |
| 237 |
'title' => __('payplug_section_oauth_login_title', 'payplug'), |
| 238 |
'description' => __('payplug_section_oauth_login_description', 'payplug'), |
| 239 |
'information' => __('payplug_section_oauth_info', 'payplug'), |
| 240 |
'button' => __('payplug_section_oauth_login_btn_connect', 'payplug'), |
| 241 |
'button_url' => $register_url, |
| 242 |
], |
| 243 |
], |
| 244 |
'sandbox' => [ |
| 245 |
'description' => __('payplug_section_oauth_login_description', 'payplug'), |
| 246 |
'form' => [ |
| 247 |
'email' => [ |
| 248 |
'label' => __('payplug_section_login_email_label', 'payplug'), |
| 249 |
'placeholder' => __('payplug_section_login_email_label', 'payplug'), |
| 250 |
], |
| 251 |
'password' => [ |
| 252 |
'label' => __('payplug_section_login_password_label', 'payplug'), |
| 253 |
'placeholder' => __('payplug_section_login_password_label', 'payplug'), |
| 254 |
], |
| 255 |
'connexion' => __('payplug_section_login_connect', 'payplug'), |
| 256 |
'create_account' => __('payplug_section_login_not_registered', 'payplug'), |
| 257 |
'forgot_password' => __('payplug_section_login_forgot_password', 'payplug'), |
| 258 |
'error' => __('payplug_section_login_error', 'payplug'), |
| 259 |
'create_account_url' => 'https://portal.payplug.com/auth/signup', |
| 260 |
'forgot_password_url' => 'https://portal.payplug.com/forgot_password', |
| 261 |
], |
| 262 |
'sso' => [ |
| 263 |
'title' => __('payplug_section_oauth_login_title', 'payplug'), |
| 264 |
'description' => __('payplug_section_oauth_login_description', 'payplug'), |
| 265 |
'information' => __('payplug_section_oauth_info', 'payplug'), |
| 266 |
'button' => __('payplug_section_oauth_login_btn_connect', 'payplug'), |
| 267 |
'button_url' => $register_url, |
| 268 |
], |
| 269 |
], |
| 270 |
], |
| 271 |
]; |
| 272 |
|
| 273 |
return $oauth_login; |
| 274 |
} |
| 275 |
|
| 276 |
/** |
| 277 |
* @return array |
| 278 |
*/ |
| 279 |
public function payplug_section_subscribe() |
| 280 |
{ |
| 281 |
return [ |
| 282 |
'name' => 'generalSubscribe', |
| 283 |
'title' => __('payplug_section_logged_title', 'payplug'), |
| 284 |
'descriptions' => [ |
| 285 |
'live' => [ |
| 286 |
'description' => __('payplug_section_subscribe_description', 'payplug'), |
| 287 |
'link_create_account' => [ |
| 288 |
'text' => __('payplug_section_subscribe_link_create_account', 'payplug'), |
| 289 |
'url' => 'https://portal.payplug.com/auth/signup', |
| 290 |
'target' => '_blank', |
| 291 |
], |
| 292 |
'content_description' => __('payplug_section_subscribe_content_description', 'payplug'), |
| 293 |
'already_have_account' => __('payplug_section_subscribe_already_have_account', 'payplug'), |
| 294 |
], |
| 295 |
'sandbox' => [ |
| 296 |
'description' => __('payplug_section_subscribe_description', 'payplug'), |
| 297 |
'link_create_account' => [ |
| 298 |
'text' => __('payplug_section_subscribe_link_create_account', 'payplug'), |
| 299 |
'url' => 'https://portal.payplug.com/signup', |
| 300 |
'target' => '_blank', |
| 301 |
], |
| 302 |
'content_description' => __('payplug_section_subscribe_content_description', 'payplug'), |
| 303 |
'already_have_account' => __('payplug_section_subscribe_already_have_account', 'payplug'), |
| 304 |
], |
| 305 |
], |
| 306 |
]; |
| 307 |
} |
| 308 |
|
| 309 |
/** |
| 310 |
* @return array |
| 311 |
*/ |
| 312 |
public function payplug_section_header() |
| 313 |
{ |
| 314 |
$enable = isset($this->options['enabled']) && $this->options['enabled']; |
| 315 |
$enable = $enable && $this->payplug_requirements(); |
| 316 |
$disabled = !$this->payplug_requirements(); |
| 317 |
|
| 318 |
return [ |
| 319 |
'title' => __('payplug_section_header_title', 'payplug'), |
| 320 |
'descriptions' => [ |
| 321 |
'live' => [ |
| 322 |
'description' => __('payplug_section_header_live_description', 'payplug'), |
| 323 |
'plugin_version' => PAYPLUG_GATEWAY_VERSION, |
| 324 |
], |
| 325 |
'sandbox' => [ |
| 326 |
'description' => __('payplug_section_header_test_description', 'payplug'), |
| 327 |
'plugin_version' => PAYPLUG_GATEWAY_VERSION, |
| 328 |
], |
| 329 |
], |
| 330 |
'options' => [ |
| 331 |
'type' => 'select', |
| 332 |
'name' => 'payplug_enable', |
| 333 |
'disabled' => $disabled, |
| 334 |
'options' => [ |
| 335 |
[ |
| 336 |
'value' => 1, |
| 337 |
'label' => __('payplug_section_header_enable_label', 'payplug'), |
| 338 |
'checked' => $enable === true ? true : false, |
| 339 |
], |
| 340 |
[ |
| 341 |
'value' => 0, |
| 342 |
'label' => __('payplug_section_header_disable_label', 'payplug'), |
| 343 |
'checked' => $enable === false ? true : false, |
| 344 |
], |
| 345 |
], |
| 346 |
], |
| 347 |
]; |
| 348 |
} |
| 349 |
|
| 350 |
/** |
| 351 |
* @return array |
| 352 |
*/ |
| 353 |
public function payplug_section_payment_methods($options = []) |
| 354 |
{ |
| 355 |
$payment_configuration = $this->options['payment_methods']['configuration']; |
| 356 |
|
| 357 |
// get applepay carriers |
| 358 |
$carriers = json_decode($payment_configuration['apple_pay']['carriers'], true); |
| 359 |
$carriers = empty($carriers) ? [] : $carriers; |
| 360 |
|
| 361 |
$section = [ |
| 362 |
'name' => 'paymentMethodsBlock', |
| 363 |
'title' => __('payplug_section_payment_methods_title', 'payplug'), |
| 364 |
'descriptions' => [ |
| 365 |
'live' => [ |
| 366 |
'description' => __('payplug_section_payment_methods_description', 'payplug'), |
| 367 |
], |
| 368 |
'sandbox' => [ |
| 369 |
'description' => __('payplug_section_payment_methods_description', 'payplug'), |
| 370 |
], |
| 371 |
], |
| 372 |
'options' => [ |
| 373 |
(new PaymentMethods($this->options))->payment_method_standard(), |
| 374 |
PaymentMethods::payment_method_amex($payment_configuration['american_express']['active']), |
| 375 |
PaymentMethods::payment_method_applepay($payment_configuration['apple_pay']['active'], $this->options, $carriers), |
| 376 |
PaymentMethods::payment_method_bancontact($payment_configuration['bancontact']['active']), |
| 377 |
PaymentMethods::payment_method_satispay($payment_configuration['satispay']['active']), |
| 378 |
PaymentMethods::payment_method_mybank($payment_configuration['mybank']['active']), |
| 379 |
PaymentMethods::payment_method_ideal($payment_configuration['ideal']['active']), |
| 380 |
PaymentMethods::payment_method_wero($payment_configuration['wero']['active']), |
| 381 |
PaymentMethods::payment_method_bizum($payment_configuration['bizum']['active']), |
| 382 |
PaymentMethods::payment_method_scalapay($payment_configuration['scalapay']['active']), |
| 383 |
], |
| 384 |
]; |
| 385 |
|
| 386 |
return $section; |
| 387 |
} |
| 388 |
|
| 389 |
/** |
| 390 |
* @param $active |
| 391 |
* |
| 392 |
* @return array |
| 393 |
*/ |
| 394 |
public function payplug_section_paylater() |
| 395 |
{ |
| 396 |
$custom_amounts = json_decode($this->options['payment_methods']['configuration']['oney']['custom_amounts'], true); |
| 397 |
$default_amounts = json_decode($this->options['payment_methods']['configuration']['oney']['default_amounts'], true); |
| 398 |
|
| 399 |
$max = !empty($custom_amounts['max']) ? $custom_amounts['max'] : $default_amounts['max']; |
| 400 |
$min = !empty($custom_amounts['min']) ? $custom_amounts['min'] : $default_amounts['min']; |
| 401 |
$product_page = $this->options['payment_methods']['configuration']['oney']['cta_product']; |
| 402 |
|
| 403 |
$section = [ |
| 404 |
'name' => 'paymentMethodsBlock', |
| 405 |
'title' => __('payplug_section_paylater_title', 'payplug'), |
| 406 |
'descriptions' => [ |
| 407 |
'live' => [ |
| 408 |
'description' => __('payplug_section_paylater_description', 'payplug'), |
| 409 |
], |
| 410 |
'sandbox' => [ |
| 411 |
'description' => __('payplug_section_paylater_description', 'payplug'), |
| 412 |
], |
| 413 |
], |
| 414 |
'options' => [ |
| 415 |
'name' => 'oney', |
| 416 |
'title' => __('payplug_section_oney_title', 'payplug'), |
| 417 |
'image' => esc_url(PAYPLUG_GATEWAY_PLUGIN_URL . 'assets/images/lg-oney.png'), |
| 418 |
'checked' => (bool) $this->options['payment_methods']['configuration']['oney']['active'], |
| 419 |
'descriptions' => [ |
| 420 |
'live' => [ |
| 421 |
'description' => __('payplug_section_paylater_description_oney', 'payplug'), |
| 422 |
'link_know_more' => Component::link(__('payplug_know_more_label', 'payplug'), 'https://support.payplug.com/hc/fr/articles/4408142346002', '_blank'), |
| 423 |
], |
| 424 |
'sandbox' => [ |
| 425 |
'description' => __('payplug_section_paylater_description_oney', 'payplug'), |
| 426 |
'link_know_more' => Component::link(__('payplug_know_more_label', 'payplug'), 'https://support.payplug.com/hc/fr/articles/4408142346002', '_blank'), |
| 427 |
], |
| 428 |
'advanced' => [ |
| 429 |
'description' => __('payplug_advanced_settings', 'payplug'), '', |
| 430 |
], |
| 431 |
], |
| 432 |
'options' => [ |
| 433 |
[ |
| 434 |
'name' => 'payplug_oney_type', |
| 435 |
'className' => '_paylaterLabel', |
| 436 |
'label' => __('payplug_label_with_fees', 'payplug'), |
| 437 |
'subText' => __('payplug_text_with_fees', 'payplug'), |
| 438 |
'value' => 'with_fees', |
| 439 |
'checked' => (bool) $this->options['payment_methods']['configuration']['oney']['with_fees'], |
| 440 |
], |
| 441 |
[ |
| 442 |
'name' => 'payplug_oney_type', |
| 443 |
'className' => '_paylaterLabel', |
| 444 |
'label' => __('payplug_label_without_fees', 'payplug'), |
| 445 |
'subText' => __('payplug_text_without_fees', 'payplug'), |
| 446 |
'value' => 'without_fees', |
| 447 |
'checked' => !(bool) $this->options['payment_methods']['configuration']['oney']['with_fees'], |
| 448 |
], |
| 449 |
], |
| 450 |
'advanced_options' => [ |
| 451 |
$this->thresholds_option($max, $min), |
| 452 |
$this->show_oney_popup_product($product_page), |
| 453 |
], |
| 454 |
], |
| 455 |
]; |
| 456 |
|
| 457 |
return $section; |
| 458 |
} |
| 459 |
|
| 460 |
/** |
| 461 |
* @return array |
| 462 |
*/ |
| 463 |
public function thresholds_option($max, $min) |
| 464 |
{ |
| 465 |
$default_amounts = json_decode($this->options['payment_methods']['configuration']['oney']['default_amounts'], true); |
| 466 |
|
| 467 |
// Convert cents |
| 468 |
$min = $min / 100; |
| 469 |
$max = $max / 100; |
| 470 |
$default_amounts['min'] = $default_amounts['min'] / 100; |
| 471 |
$default_amounts['max'] = $default_amounts['max'] / 100; |
| 472 |
// |
| 473 |
|
| 474 |
$thresholds = [ |
| 475 |
'name' => 'thresholds', |
| 476 |
'image_url' => esc_url(PAYPLUG_GATEWAY_PLUGIN_URL . 'assets/images/thresholds.svg'), |
| 477 |
'title' => __('payplug_thresholds_oney_title', 'payplug'), |
| 478 |
'descriptions' => [ |
| 479 |
'description' => __('payplug_thresholds_oney_description', 'payplug'), |
| 480 |
'min_amount' => [ |
| 481 |
'name' => 'oney_min_amounts', |
| 482 |
'value' => $min, |
| 483 |
'placeholder' => $min, |
| 484 |
'default' => $default_amounts['min'], |
| 485 |
], |
| 486 |
'inter' => __('and', 'payplug'), |
| 487 |
'max_amount' => [ |
| 488 |
'name' => 'oney_max_amounts', |
| 489 |
'value' => $max, |
| 490 |
'placeholder' => $max, |
| 491 |
'default' => $default_amounts['max'], |
| 492 |
], |
| 493 |
'error' => [ |
| 494 |
'text' => __('payplug_thresholds_error_msg', 'payplug'), |
| 495 |
'maxtext' => __('payplug_thresholds_error_maxtext_msg', 'payplug'), |
| 496 |
'mintext' => __('payplug_thresholds_error_mintext_msg', 'payplug'), |
| 497 |
], |
| 498 |
], |
| 499 |
'switch' => false, |
| 500 |
]; |
| 501 |
|
| 502 |
return $thresholds; |
| 503 |
} |
| 504 |
|
| 505 |
/** |
| 506 |
* @param $active |
| 507 |
* |
| 508 |
* @return array |
| 509 |
*/ |
| 510 |
public function show_oney_popup_product($active = false) |
| 511 |
{ |
| 512 |
return [ |
| 513 |
'name' => 'oney_product_animation', |
| 514 |
'image_url' => esc_url(PAYPLUG_GATEWAY_PLUGIN_URL . 'assets/images/product.svg'), |
| 515 |
'title' => __('display_the_oney_installments_pop_up_on_the_product_page', 'payplug'), |
| 516 |
'descriptions' => [[ |
| 517 |
'description' => __('payplug_oney_product_page_description', 'payplug'), |
| 518 |
'link_know_more' => Component::link(__('payplug_know_more_label', 'payplug'), 'https://support.payplug.com/hc/fr/articles/4408142346002', '_blank'), |
| 519 |
]], |
| 520 |
'switch' => true, |
| 521 |
'checked' => $active, |
| 522 |
]; |
| 523 |
} |
| 524 |
|
| 525 |
/** |
| 526 |
* @return array |
| 527 |
*/ |
| 528 |
public function payplug_section_status($options = []) |
| 529 |
{ |
| 530 |
$payplug_requirements = new PayplugGatewayRequirements(new PayplugGateway()); |
| 531 |
$checked = (bool) $options['debug']; |
| 532 |
|
| 533 |
$status = [ |
| 534 |
'error' => !$this->payplug_requirements(), |
| 535 |
'title' => __('payplug_section_status_title', 'payplug'), |
| 536 |
'descriptions' => [ |
| 537 |
'live' => [ |
| 538 |
'description' => __('payplug_section_status_description', 'payplug'), |
| 539 |
'errorMessage' => __('payplug_section_status_errorMessage', 'payplug'), |
| 540 |
'check' => __('payplug_section_status_check', 'payplug'), |
| 541 |
'check_success' => __('payplug_section_status_check_success', 'payplug'), |
| 542 |
], |
| 543 |
'sandbox' => [ |
| 544 |
'description' => __('payplug_section_status_description', 'payplug'), |
| 545 |
'errorMessage' => __('payplug_section_status_errorMessage', 'payplug'), |
| 546 |
'check' => __('payplug_section_status_check', 'payplug'), |
| 547 |
'check_success' => __('payplug_section_status_check_success', 'payplug'), |
| 548 |
], |
| 549 |
], |
| 550 |
'requirements' => [ |
| 551 |
$payplug_requirements->curl_requirement(), |
| 552 |
$payplug_requirements->php_requirement(), |
| 553 |
$payplug_requirements->openssl_requirement(), |
| 554 |
$payplug_requirements->currency_requirement(), //MISSING THIS MESSAGES |
| 555 |
$payplug_requirements->account_requirement(), |
| 556 |
], |
| 557 |
'debug' => [ |
| 558 |
'live' => [ |
| 559 |
'title' => __('payplug_section_status_debug_label', 'payplug'), |
| 560 |
'description' => __('payplug_section_status_debug_description', 'payplug'), |
| 561 |
], |
| 562 |
'sandbox' => [ |
| 563 |
'title' => __('payplug_section_status_debug_label', 'payplug'), |
| 564 |
'description' => __('payplug_section_status_debug_description', 'payplug'), |
| 565 |
], |
| 566 |
], |
| 567 |
'enable_debug_check' => $checked, |
| 568 |
]; |
| 569 |
|
| 570 |
return $status; |
| 571 |
} |
| 572 |
|
| 573 |
/** |
| 574 |
* check if there's any requirement missing |
| 575 |
* |
| 576 |
* @return bool |
| 577 |
*/ |
| 578 |
private function payplug_requirements() |
| 579 |
{ |
| 580 |
$payplug_requirements = new PayplugGatewayRequirements(new PayplugGateway()); |
| 581 |
|
| 582 |
return $payplug_requirements->satisfy_requirements(); |
| 583 |
} |
| 584 |
|
| 585 |
/** |
| 586 |
* @return array |
| 587 |
*/ |
| 588 |
public function payplug_section_footer() |
| 589 |
{ |
| 590 |
return [ |
| 591 |
'save_changes_text' => __('payplug_save_changes_text', 'payplug'), |
| 592 |
'description' => [ |
| 593 |
__('payplug_section_help_description1', 'payplug'), |
| 594 |
__('payplug_section_help_description2', 'payplug'), |
| 595 |
], |
| 596 |
'link_help' => Component::link( |
| 597 |
__('payplug_section_help_link_help_text', 'payplug'), |
| 598 |
__('payplug_section_help_link_help_url', 'payplug'), |
| 599 |
'_blank' |
| 600 |
), |
| 601 |
]; |
| 602 |
} |
| 603 |
} |
| 604 |
|