Skip to content

Commit

Permalink
增加支付頁語系更換功能
Browse files Browse the repository at this point in the history
  • Loading branch information
payuni committed May 21, 2024
1 parent 61f7229 commit 8803a1d
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions class-payuni.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ public function __construct()
'PAYUNi_Logistic_Tcat_Cold' => 3,
];

// 支付方式
$this->paymentArr = [
'Credit', 'ICash', 'Aftee', 'LinePay', 'ATM', 'CVS', 'CreditUnionPay',
'CreditRed', 'CreditInst', 'ApplePay', 'GooglePay', 'SamsungPay'
];

// Test Mode
if ($this->TestMode == 'yes') {
$this->gateway = "https://sandbox-api.payuni.com.tw/api/upp"; //測試網址
Expand Down Expand Up @@ -140,6 +146,15 @@ function init_form_fields()
'description' => __("選擇是否開啟測試模式", 'woocommerce'),
'default' => 'yes'
),
'LangSettings' => array(
'title' => __('支付頁語系', 'woocommerce'),
'type' => 'select',
'default' => 'zh-tw',
'options' => [
'zh-tw' => __('zh-tw', 'LangSettings', 'woocommerce'),
'en' => __('en', 'LangSettings', 'woocommerce'),
]
),
'LogisticSettings' => array(
'title' => __('物流設定', 'woocommerce'),
'type' => 'title',
Expand Down Expand Up @@ -572,27 +587,25 @@ private function uppOnePointHandler($order)
}

$encryptInfo = [
'MerID' => $this->MerchantID,
'MerID' => $this->MerchantID,
'MerTradeNo' => $order->get_id(),
'TradeAmt' => (int) $order->get_total(),
'TradeAmt' => (int) $order->get_total(),
'ExpireDate' => date('Y-m-d', strtotime("+" . $this->ExpireDate . " days")),
'ProdDesc' => implode(';', $prodDesc),
'UsrMail' => $order->get_billing_email(),
'ReturnURL' => $this->get_return_url($order),
"NotifyURL" => $this->notify_url, //幕後
'Timestamp' => time()
'ProdDesc' => implode(';', $prodDesc),
'UsrMail' => $order->get_billing_email(),
'ReturnURL' => $this->get_return_url($order),
"NotifyURL" => $this->notify_url, //幕後
"Lang" => $this->settings['LangSettings'],
'Timestamp' => time()
];

// 物流參數
foreach ($order->get_items('shipping') as $item) {
$item_data = $item->get_data();
$shipping_data_method_id = $item_data['method_id'];
}
$paymentArr = [
'Credit', 'ICash', 'Aftee', 'LinePay', 'ATM', 'CVS', 'CreditUnionPay',
'CreditRed', 'CreditInst', 'ApplePay', 'GooglePay', 'SamsungPay'
];
foreach ($paymentArr as $payment) {

foreach ($this->paymentArr as $payment) {
if ($this->settings[$payment] == 'yes') {
$encryptInfo[$payment] = 1;
}
Expand Down

0 comments on commit 8803a1d

Please sign in to comment.