| 1 |
<?php |
| 2 |
|
| 3 |
namespace Payplug\PayplugWoocommerce\Front; |
| 4 |
|
| 5 |
class PayplugOneyWithoutFees extends PayplugPayWithOney |
| 6 |
{ |
| 7 |
|
| 8 |
public function __construct() |
| 9 |
{ |
| 10 |
parent::__construct(); |
| 11 |
|
| 12 |
$this->setIcon('oney-without-fees-3x4x'); |
| 13 |
$this->setSimulatedClass('Payplug\\PayplugWoocommerce\\Gateway\\PayplugGatewayOney3xWithoutFees'); |
| 14 |
$this->setOneyType("without_fees"); |
| 15 |
|
| 16 |
add_action( 'wp_ajax_simulate_oney_payment', [ $this, 'simulate_oney_payment' ]); |
| 17 |
add_action( 'wp_ajax_nopriv_simulate_oney_payment', [ $this, 'simulate_oney_payment' ]); |
| 18 |
add_action( 'template_redirect', [ $this, 'check_oney_frontend' ] ); |
| 19 |
} |
| 20 |
|
| 21 |
/** |
| 22 |
* Simulate Oney Payment |
| 23 |
* |
| 24 |
* @return void |
| 25 |
*/ |
| 26 |
public function simulate_oney_payment() { |
| 27 |
$simulation = $this->handleOneySimulation(); |
| 28 |
wp_send_json_success( |
| 29 |
array( |
| 30 |
'popup' => $this->get_simulate_oney_payment_popup($simulation) |
| 31 |
) |
| 32 |
); |
| 33 |
|
| 34 |
wp_die(); |
| 35 |
} |
| 36 |
|
| 37 |
/** |
| 38 |
* Show oney simulation details |
| 39 |
* |
| 40 |
* @param $oney_response |
| 41 |
* @return string |
| 42 |
*/ |
| 43 |
public function get_simulate_oney_payment_popup($oney_response) { |
| 44 |
$cgv = $this->popupfooter(); |
| 45 |
|
| 46 |
if($oney_response) { |
| 47 |
$popup_content = is_array($oney_response) ? PayplugOney::simulationPopupContent($this, $oney_response['x3_without_fees'], $oney_response['x4_without_fees']) : $oney_response; |
| 48 |
|
| 49 |
$popup = <<<HTML |
| 50 |
$popup_content |
| 51 |
$cgv |
| 52 |
HTML; |
| 53 |
|
| 54 |
return $popup; |
| 55 |
} |
| 56 |
return "<div class='oney-content oney-cgv-content'></div>"; |
| 57 |
} |
| 58 |
|
| 59 |
/** |
| 60 |
* @return string |
| 61 |
*/ |
| 62 |
private function popupfooter() |
| 63 |
{ |
| 64 |
$f = function($fn) { return $fn; }; |
| 65 |
|
| 66 |
$footer = <<<HTML |
| 67 |
<div class='oney-cgv-content oney-cgv-footer'> |
| 68 |
{$f(sprintf( |
| 69 |
esc_html__("Offre de financement sans assurance avec apport obligatoire, réservée aux particuliers et valable pour tout achat de %s€ à %s€. Sous réserve d’acceptation par Oney Bank. Vous disposez d’un délai de 14 jours pour renoncer à votre crédit. Oney Bank - SA au capital de 51286585€ - 34 Avenue de Flandre 59 170 Croix - 546 380 197 RCS Lille Métropole - n° Orias 07023 261 %s . Correspondance : CS 60 006 - 59895 Lille Cedex - %s", "payplug"), |
| 70 |
$this->get_min_amount(), |
| 71 |
$this->get_max_amount(), |
| 72 |
__("<a href='https://www.orias.fr' target='_empty' > www.orias.fr </a>"), |
| 73 |
__("<a href=\"https://www.oney.fr\" target=\"_empty\" > www.oney.fr </a>") |
| 74 |
))} |
| 75 |
</div> |
| 76 |
HTML; |
| 77 |
|
| 78 |
return $footer; |
| 79 |
|
| 80 |
} |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
} |
| 87 |
|