-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d3591d2
commit 5161fbf
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
59 changes: 59 additions & 0 deletions
59
ecpay-ecommerce-for-woocommerce/includes/services/payment/ecpay-gateway-applepay.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
class Wooecpay_Gateway_Applepay extends Wooecpay_Gateway_Base | ||
{ | ||
|
||
public function __construct() | ||
{ | ||
$this->id = 'Wooecpay_Gateway_Applepay'; | ||
$this->payment_type = 'ApplePay'; | ||
$this->icon = plugins_url('images/icon.png', dirname(dirname( __FILE__ )) ); | ||
$this->has_fields = false; | ||
$this->method_title = '綠界ApplePay'; | ||
$this->method_description = '使用綠界ApplePay付款'; | ||
|
||
$this->title = $this->get_option('title'); | ||
$this->description = $this->get_option('description'); | ||
$this->min_amount = (int) $this->get_option('min_amount', 0); | ||
|
||
$this->form_fields = include WOOECPAY_PLUGIN_INCLUDE_DIR . '/config/payment/settings-gateway-applepay.php' ; | ||
$this->init_settings(); | ||
|
||
parent::__construct(); | ||
|
||
add_action('woocommerce_update_options_payment_gateways_' . $this->id, [$this, 'process_admin_options']); | ||
} | ||
|
||
public function process_admin_options() | ||
{ | ||
parent::process_admin_options(); | ||
} | ||
|
||
public function is_available() | ||
{ | ||
if ('yes' == $this->enabled && WC()->cart) { | ||
$total = $this->get_order_total(); | ||
|
||
if ($total > 0) { | ||
if ($this->min_amount > 0 and $total < $this->min_amount) { | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
return parent::is_available(); | ||
} | ||
|
||
public function process_payment($order_id){ | ||
|
||
$order = wc_get_order($order_id); | ||
$order->add_order_note(__('Pay via ECPay Applepay', 'ecpay-ecommerce-for-woocommerce')); | ||
wc_maybe_reduce_stock_levels($order_id); | ||
wc_release_stock_for_order($order); | ||
|
||
return [ | ||
'result' => 'success', | ||
'redirect' => $order->get_checkout_payment_url(true), | ||
]; | ||
} | ||
} |