| 1 |
<?php |
| 2 |
|
| 3 |
namespace Payplug\PayplugWoocommerce\Gateway\Blocks; |
| 4 |
|
| 5 |
class PayplugOney extends PayplugGenericBlock { |
| 6 |
|
| 7 |
/** |
| 8 |
* Payment method name/id/slug. |
| 9 |
* |
| 10 |
* @var string |
| 11 |
*/ |
| 12 |
protected $name = "oney"; |
| 13 |
|
| 14 |
protected $icon = ''; |
| 15 |
|
| 16 |
protected $cart; |
| 17 |
|
| 18 |
protected $total_price; |
| 19 |
|
| 20 |
/** |
| 21 |
* Returns an associative array of data to be exposed for the payment method's client side. |
| 22 |
*/ |
| 23 |
public function get_payment_method_data() { |
| 24 |
|
| 25 |
$data = parent::get_payment_method_data(); |
| 26 |
|
| 27 |
if ( is_checkout() ) { |
| 28 |
$this->cart = WC()->cart; |
| 29 |
$this->total_price = floatval( WC()->cart->total ); |
| 30 |
} |
| 31 |
|
| 32 |
$data['icon'] = [ |
| 33 |
'src' => esc_url( PAYPLUG_GATEWAY_PLUGIN_URL . '/assets/images/checkout/' . $this->icon ), |
| 34 |
'class' => 'payplug-payment-icon', |
| 35 |
'alt' => $this->gateway->title |
| 36 |
]; |
| 37 |
$data['description'] = $this->gateway->description; |
| 38 |
$data['oney_response'] = $this->gateway->api->simulate_oney_payment( $this->total_price, 'with_fees' ); |
| 39 |
|
| 40 |
$data['currency'] = get_woocommerce_currency_symbol( get_option( 'woocommerce_currency' ) ); |
| 41 |
|
| 42 |
$data['translations']['bring'] = __( 'Bring', 'payplug' ); |
| 43 |
$data['translations']['oney_financing_cost'] = __( 'oney_financing_cost', 'payplug' ); |
| 44 |
$data['translations']['1st_monthly_payment'] = __( '1st monthly payment', 'payplug' ); |
| 45 |
$data['translations']['2nd_monthly_payment'] = __( '2nd monthly payment', 'payplug' ); |
| 46 |
$data['translations']['oney_total'] = __( 'oney_total', 'payplug' ); |
| 47 |
$data['allowed_country_codes'] = $this->gateway->allowed_country_codes; |
| 48 |
|
| 49 |
$data['requirements'] = [ |
| 50 |
'max_quantity' => $this->gateway::ONEY_PRODUCT_QUANTITY_MAXIMUM, |
| 51 |
'max_threshold' => $this->gateway->oney_thresholds_max * 100, |
| 52 |
'min_threshold' => $this->gateway->oney_thresholds_min * 100, |
| 53 |
'allowed_country_codes' => $this->gateway->allowed_country_codes |
| 54 |
]; |
| 55 |
|
| 56 |
return $data; |
| 57 |
|
| 58 |
} |
| 59 |
|
| 60 |
} |
| 61 |
|