/** * Redirect to allPay */ public function receipt_page($order_id) { # Clean the cart global $woocommerce; $woocommerce->cart->empty_cart(); $order = new WC_Order($order_id); try { $this->invoke_allpay_module(); $aio = new AllInOne(); $aio->Send['MerchantTradeNo'] = ''; $service_url = ''; if ($this->allpay_test_mode == 'yes') { $service_url = 'http://payment-stage.allpay.com.tw/Cashier/AioCheckOut'; $aio->Send['MerchantTradeNo'] = date('YmdHis'); } else { $service_url = 'https://payment.allpay.com.tw/Cashier/AioCheckOut'; } $aio->MerchantID = $this->allpay_merchant_id; $aio->HashKey = $this->allpay_hash_key; $aio->HashIV = $this->allpay_hash_iv; $aio->ServiceURL = $service_url; $aio->Send['ReturnURL'] = add_query_arg('wc-api', 'WC_Gateway_Allpay', home_url('/')); $aio->Send['ClientBackURL'] = home_url('?page_id=' . get_option('woocommerce_myaccount_page_id') . '&view-order=' . $order->id); $aio->Send['MerchantTradeNo'] .= $order->id; $aio->Send['MerchantTradeDate'] = date('Y/m/d H:i:s'); # Set the product info $aio->Send['TotalAmount'] = $order->get_total(); array_push($aio->Send['Items'], array('Name' => '網路商品一批', 'Price' => $aio->Send['TotalAmount'], 'Currency' => $order->get_order_currency(), 'Quantity' => 1)); $aio->Send['TradeDesc'] = 'allPay_module_woocommerce_1_0_3'; # Get the chosen payment and installment $notes = $order->get_customer_order_notes(); $choose_payment = ''; $choose_installment = ''; if (isset($notes[0])) { list($choose_payment, $choose_installment) = explode('_', $notes[0]->comment_content); } $aio->Send['ChoosePayment'] = $choose_payment; # Set the extend information switch ($aio->Send['ChoosePayment']) { case 'Credit': # Do not support UnionPay $aio->SendExtend['UnionPay'] = false; # Credit installment parameters if (!empty($choose_installment)) { $aio->SendExtend['CreditInstallment'] = $choose_installment; $aio->SendExtend['InstallmentAmount'] = $aio->Send['TotalAmount']; $aio->SendExtend['Redeem'] = false; } break; case 'WebATM': break; case 'ATM': $aio->SendExtend['ExpireDate'] = 3; $aio->SendExtend['PaymentInfoURL'] = $aio->Send['ReturnURL']; break; case 'CVS': case 'BARCODE': $aio->SendExtend['Desc_1'] = ''; $aio->SendExtend['Desc_2'] = ''; $aio->SendExtend['Desc_3'] = ''; $aio->SendExtend['Desc_4'] = ''; $aio->SendExtend['PaymentInfoURL'] = $aio->Send['ReturnURL']; break; case 'Alipay': $aio->SendExtend['Email'] = $order->billing_email; $aio->SendExtend['PhoneNo'] = $order->billing_phone; $aio->SendExtend['UserName'] = $order->billing_first_name . ' ' . $order->billing_last_name; break; case 'Tenpay': $aio->SendExtend['ExpireTime'] = date('Y/m/d H:i:s', strtotime('+3 days')); break; case 'TopUpUsed': break; default: throw new Exception($this->tran('Invalid payment method.')); break; } $aio->CheckOut(); exit; } catch (Exception $e) { $this->add_error($e->getMessage()); } }
$obj->Send['TradeDesc'] = "good to drink"; //交易描述 $obj->Send['ChoosePayment'] = PaymentMethod::WebATM; //付款方式:WebATM //訂單的商品資料 array_push($obj->Send['Items'], array('Name' => "歐付寶黑芝麻豆漿", 'Price' => (int) "2000", 'Currency' => "元", 'Quantity' => 1, 'URL' => "dedwed")); # 電子發票參數 /* $obj->Send['InvoiceMark'] = InvoiceState::Yes; $obj->SendExtend['RelateNumber'] = $MerchantTradeNo; $obj->SendExtend['CustomerEmail'] = '*****@*****.**'; $obj->SendExtend['CustomerPhone'] = '0911222333'; $obj->SendExtend['TaxType'] = TaxType::Dutiable; $obj->SendExtend['CustomerAddr'] = '台北市南港區三重路19-2號5樓D棟'; $obj->SendExtend['InvoiceItems'] = array(); // 將商品加入電子發票商品列表陣列 foreach ($obj->Send['Items'] as $info) { array_push($obj->SendExtend['InvoiceItems'],array('Name' => $info['Name'],'Count' => $info['Quantity'],'Word' => '個','Price' => $info['Price'],'TaxType' => TaxType::Dutiable)); } $obj->SendExtend['InvoiceRemark'] = '測試發票備註'; $obj->SendExtend['DelayDay'] = '0'; $obj->SendExtend['InvType'] = InvType::General; */ //產生訂單(auto submit至AllPay) //$obj->CheckOut(); echo $obj->CheckOut(); } catch (Exception $e) { echo $e->getMessage(); }
//付款方式:Tenpay財付通 //訂單的商品資料 array_push($obj->Send['Items'], array('Name' => "歐付寶黑芝麻豆漿", 'Price' => (int) "2000", 'Currency' => "元", 'Quantity' => (int) "1", 'URL' => "dedwed")); //Tenpay財付通延伸參數(可依系統需求選擇是否代入) $obj->SendExtend['ExpireTime'] = ''; //付款截止時間只能帶入送出交易後的 72 小時(三天)之內時間。不填則預設為送出交易後的 72 小 //時。 # 電子發票參數 /* $obj->Send['InvoiceMark'] = InvoiceState::Yes; $obj->SendExtend['RelateNumber'] = $MerchantTradeNo; $obj->SendExtend['CustomerEmail'] = '*****@*****.**'; $obj->SendExtend['CustomerPhone'] = '0911222333'; $obj->SendExtend['TaxType'] = TaxType::Dutiable; $obj->SendExtend['CustomerAddr'] = '台北市南港區三重路19-2號5樓D棟'; $obj->SendExtend['InvoiceItems'] = array(); // 將商品加入電子發票商品列表陣列 foreach ($obj->Send['Items'] as $info) { array_push($obj->SendExtend['InvoiceItems'],array('Name' => $info['Name'],'Count' => $info['Quantity'],'Word' => '個','Price' => $info['Price'],'TaxType' => TaxType::Dutiable)); } $obj->SendExtend['InvoiceRemark'] = '測試發票備註'; $obj->SendExtend['DelayDay'] = '0'; $obj->SendExtend['InvType'] = InvType::General; */ //產生訂單(auto submit至AllPay) $obj->CheckOut(); } catch (Exception $e) { echo $e->getMessage(); }