From 5161fbf85537d86b9c30a9e246195534d55650ab Mon Sep 17 00:00:00 2001 From: "allen.chang" Date: Wed, 26 Oct 2022 09:58:24 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A3=9C=E4=B8=8Aapple=20pay=20=E7=9A=84?= =?UTF-8?q?=E7=A8=8B=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ecpay-ecommerce-for-woocommerce.zip | Bin 216044 -> 216044 bytes .../payment/ecpay-gateway-applepay.php | 59 ++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 ecpay-ecommerce-for-woocommerce/includes/services/payment/ecpay-gateway-applepay.php diff --git a/ecpay-ecommerce-for-woocommerce.zip b/ecpay-ecommerce-for-woocommerce.zip index 4f39276ab6e61b703fef2e97323ca38886b72642..e09a5fd061a231c110042edd121383680767bfb1 100644 GIT binary patch delta 3899 zcmY+GdtA=v8^`xt_j5nR^9`X;vvLS6bYRLD$wZkcUS?yYZHzG;97;m9R!!$gcdJDu zwkD;6mP1OhEGeeZPjncm97;4R$6fdL{^s}l{r7%-?$7bR^>y( zQO(4&7K`g!S@Tiw)|9WDzkRblVl$6{kLFpXoOtRO`1kUR0toKq^98`@OFPdl z5B9~c5KDX9I6nOqLV6t`g^)n?L%BTaIHXAWS%@vQs;4Pk3s_D$3}&~EgOA$iPpr7| z1bm};qeiaSasncS>U$E?>W*0QRjN;6y^!VJn3i%1($pN8V-f75p+Q`1D}q$oqPrO} z`ZQ!xm*_2s_QjAw-3mB17elgwp(Ut(d6TQ-&tUHYOV7X#jowwc+MH4drek`1(NR?j zyEG}Svb?wq8&bHT3`2w^_$=1mZn6#CZ=ZuOX^zSoTdq|tas0uRHRZtIJuU0|vBq=Y zr{*rU@;BTL*^k>%=yAhUY{y&W5ULJxL_)`(@VZ&W@IY0rNNyyT$m6^KeMe zPrt)KI%gv8a6T*cQXV@VYxt1W-UIQMGE6r_I%QUo2l1j&+3y@*}ZH)x4iv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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), + ]; + } +}