diff --git a/phplibs/AllPay.Payment.Integration.php b/phplibs/AllPay.Payment.Integration.php new file mode 100644 index 0000000..2cdc3ba --- /dev/null +++ b/phplibs/AllPay.Payment.Integration.php @@ -0,0 +1,1558 @@ +AllInOne(); + $this->PaymentType = 'aio'; + $this->Send = array( + "ReturnURL" => '', + "ClientBackURL" => '', + "OrderResultURL" => '', + "MerchantTradeNo" => '', + "MerchantTradeDate" => '', + "PaymentType" => 'aio', + "TotalAmount" => '', + "TradeDesc" => '', + "ChoosePayment" => PaymentMethod::ALL, + "Remark" => '', + "ChooseSubPayment" => PaymentMethodItem::None, + "NeedExtraPaidInfo" => ExtraPaymentInfo::No, + "DeviceSource" => DeviceType::PC, + "IgnorePayment" => '', + "PlatformID" => '', + "InvoiceMark" => InvoiceState::No, + "Items" => array(), + "EncryptType" => EncryptType::ENC_MD5 + ); + $this->SendExtend = array( + // ATM 延伸參數。 + "ExpireDate" => 3, + // CVS, BARCODE 延伸參數。 + "Desc_1" => '', "Desc_2" => '', "Desc_3" => '', "Desc_4" => '', + // ATM, CVS, BARCODE 延伸參數。 + "ClientRedirectURL" => '', + // Alipay 延伸參數。 + "Email" => '', "PhoneNo" => '', "UserName" => '', + // Tenpay 延伸參數。 + "ExpireTime" => '', + // Credit 分期延伸參數。 + "CreditInstallment" => 0, "InstallmentAmount" => 0, "Redeem" => FALSE, "UnionPay" => FALSE, + // Credit 定期定額延伸參數。 + "PeriodAmount" => '', "PeriodType" => '', "Frequency" => '', "ExecTimes" => '', + // 回傳網址的延伸參數。 + "PaymentInfoURL" => '', "PeriodReturnURL" => '', + // 電子發票延伸參數。 + "CustomerIdentifier" => '', + "CarruerType" => CarruerType::None, + "CustomerID" => '', + "Donation" => Donation::No, + "Print" => PrintMark::No, + "CustomerName" => '', + "CustomerAddr" => '', + "CustomerPhone" => '', + "CustomerEmail" => '', + "ClearanceMark" => '', + "CarruerNum" => '', + "LoveCode" => '', + "InvoiceRemark" => '', + "DelayDay" => 0, + ); + $this->Query = array( + 'MerchantTradeNo' => '', 'TimeStamp' => '' + ); + $this->Action = Array( + 'MerchantTradeNo' => '', 'TradeNo' => '', 'Action' => ActionType::C, 'TotalAmount' => 0 + ); + $this->ChargeBack = Array( + 'MerchantTradeNo' => '', 'TradeNo' => '', 'ChargeBackTotalAmount' => 0, 'Remark' => '' + ); + } + function AllInOne() { + + } + function CheckOut($target = "_self") { + $szHtml = $this->CheckOutString(null, $target); + print $szHtml; + exit(); + die(); + flush(); + return; + } + function CheckOutString($paymentButton, $target = "_self") { + // 變數宣告。 + $arErrors = array(); + $szHtml = ''; + $arParameters = null; + $szItemName = ''; + $szAlipayItemName = ''; + $szAlipayItemCounts = ''; + $szAlipayItemPrice = ''; + $szInvoiceItemName = ''; + $szInvoiceItemCount = ''; + $szInvoiceItemWord = ''; + $szInvoiceItemPrice = ''; + $szInvoiceItemTaxType = ''; + $InvSptr = '|'; + // 檢查資料。 + if (strlen($this->ServiceURL) == 0) { + array_push($arErrors, 'ServiceURL is required.'); + } + if (strlen($this->ServiceURL) > 200) { + array_push($arErrors, 'ServiceURL max langth as 200.'); + } + if (strlen($this->HashKey) == 0) { + array_push($arErrors, 'HashKey is required.'); + } + if (strlen($this->HashIV) == 0) { + array_push($arErrors, 'HashIV is required.'); + } + if (strlen($this->MerchantID) == 0) { + array_push($arErrors, 'MerchantID is required.'); + } + if (strlen($this->MerchantID) > 10) { + array_push($arErrors, 'MerchantID max langth as 10.'); + } + if (strlen($this->Send['ReturnURL']) == 0) { + array_push($arErrors, 'ReturnURL is required.'); + } + if (strlen($this->Send['ClientBackURL']) > 200) { + array_push($arErrors, 'ClientBackURL max langth as 10.'); + } + if (strlen($this->Send['OrderResultURL']) > 200) { + array_push($arErrors, 'OrderResultURL max langth as 10.'); + } + if (strlen($this->Send['MerchantTradeNo']) == 0) { + array_push($arErrors, 'MerchantTradeNo is required.'); + } + if (strlen($this->Send['MerchantTradeNo']) > 20) { + array_push($arErrors, 'MerchantTradeNo max langth as 20.'); + } + if (strlen($this->Send['MerchantTradeDate']) == 0) { + array_push($arErrors, 'MerchantTradeDate is required.'); + } + if (strlen($this->Send['TotalAmount']) == 0) { + array_push($arErrors, 'TotalAmount is required.'); + } + if (strlen($this->Send['TradeDesc']) == 0) { + array_push($arErrors, 'TradeDesc is required.'); + } + if (strlen($this->Send['TradeDesc']) > 200) { + array_push($arErrors, 'TradeDesc max langth as 200.'); + } + if (strlen($this->Send['ChoosePayment']) == 0) { + array_push($arErrors, 'ChoosePayment is required.'); + } + if (strlen($this->Send['NeedExtraPaidInfo']) == 0) { + array_push($arErrors, 'NeedExtraPaidInfo is required.'); + } + if (strlen($this->Send['DeviceSource']) == 0) { + array_push($arErrors, 'DeviceSource is required.'); + } + if (sizeof($this->Send['Items']) == 0) { + array_push($arErrors, 'Items is required.'); + } + // 檢查 Alipay 條件。 + if ($this->Send['ChoosePayment'] == PaymentMethod::Alipay) { + if (strlen($this->SendExtend['Email']) == 0) { + array_push($arErrors, "Email is required."); + } + if (strlen($this->SendExtend['Email']) > 200) { + array_push($arErrors, "Email max langth as 200."); + } + if (strlen($this->SendExtend['PhoneNo']) == 0) { + array_push($arErrors, "PhoneNo is required."); + } + if (strlen($this->SendExtend['PhoneNo']) > 20) { + array_push($arErrors, "PhoneNo max langth as 20."); + } + if (strlen($this->SendExtend['UserName']) == 0) { + array_push($arErrors, "UserName is required."); + } + if (strlen($this->SendExtend['UserName']) > 20) { + array_push($arErrors, "UserName max langth as 20."); + } + } + // 檢查產品名稱。 + if (sizeof($this->Send['Items']) > 0) { + foreach ($this->Send['Items'] as $keys => $value) { + $szItemName .= vsprintf('#%s %d %s x %u', $this->Send['Items'][$keys]); + $szAlipayItemName .= sprintf('#%s', $this->Send['Items'][$keys]['Name']); + $szAlipayItemCounts .= sprintf('#%u', $this->Send['Items'][$keys]['Quantity']); + $szAlipayItemPrice .= sprintf('#%d', $this->Send['Items'][$keys]['Price']); + if (!array_key_exists('ItemURL', $this->Send)) { + $this->Send['ItemURL'] = $this->Send['Items'][$keys]['URL']; + } + } + if (strlen($szItemName) > 0) { + $szItemName = mb_substr($szItemName, 1, 200); + } + if (strlen($szAlipayItemName) > 0) { + $szAlipayItemName = mb_substr($szAlipayItemName, 1, 200); + } + if (strlen($szAlipayItemCounts) > 0) { + $szAlipayItemCounts = mb_substr($szAlipayItemCounts, 1, 100); + } + if (strlen($szAlipayItemPrice) > 0) { + $szAlipayItemPrice = mb_substr($szAlipayItemPrice, 1, 20); + } + } else { + array_push($arErrors, "Goods information not found."); + } + + // 檢查電子發票參數 + if (strlen($this->Send['InvoiceMark']) > 1) { + array_push($arErrors, "InvoiceMark max length as 1."); + } else { + if ($this->Send['InvoiceMark'] == InvoiceState::Yes) { + // RelateNumber(不可為空) + if (strlen($this->SendExtend['RelateNumber']) == 0) { + array_push($arErrors, "RelateNumber is required."); + } else { + if (strlen($this->SendExtend['RelateNumber']) > 30) { + array_push($arErrors, "RelateNumber max length as 30."); + } + } + + // CustomerIdentifier(預設為空字串) + if (strlen($this->SendExtend['CustomerIdentifier']) > 0) { + if (strlen($this->SendExtend['CustomerIdentifier']) != 8) { + array_push($arErrors, "CustomerIdentifier length should be 8."); + } + } + + // CarruerType(預設為None) + if (strlen($this->SendExtend['CarruerType']) > 1) { + array_push($arErrors, "CarruerType max length as 1."); + } else { + // 統一編號不為空字串時,載具類別請設定空字串 + if (strlen($this->SendExtend['CustomerIdentifier']) > 0) { + if ($this->SendExtend['CarruerType'] != CarruerType::None) { + array_push($arErrors, "CarruerType should be None."); + } + } + } + + // CustomerID(預設為空字串) + if (strlen($this->SendExtend['CustomerID']) > 20) { + array_push($arErrors, "CustomerID max length as 20."); + } else { + // 當載具類別為會員載具(Member)時,此參數不可為空字串 + if ($this->SendExtend['CarruerType'] == CarruerType::Member) { + if (strlen($this->SendExtend['CustomerID']) == 0) { + array_push($arErrors, "CustomerID is required."); + } + } + } + + // Donation(預設為No) + if (strlen($this->SendExtend['Donation']) > 1) { + array_push($arErrors, "Donation max length as 1."); + } else { + // 統一編號不為空字串時,請設定不捐贈(No) + if (strlen($this->SendExtend['CustomerIdentifier']) > 0) { + if ($this->SendExtend['Donation'] != Donation::No) { + array_push($arErrors, "Donation should be No."); + } + } else { + if (strlen($this->SendExtend['Donation']) == 0) { + $this->SendExtend['Donation'] = Donation::No; + } + } + } + // Print(預設為No) + if (strlen($this->SendExtend['Print']) > 1) { + array_push($arErrors, "Print max length as 1."); + } else { + // 捐贈註記為捐贈(Yes)時,請設定不列印(No) + if ($this->SendExtend['Donation'] == Donation::Yes) { + if ($this->SendExtend['Print'] != PrintMark::No) { + array_push($arErrors, "Print should be No."); + } + } else { + // 統一編號不為空字串時,請設定列印(Yes) + if (strlen($this->SendExtend['CustomerIdentifier']) > 0) { + if ($this->SendExtend['Print'] != PrintMark::Yes) { + array_push($arErrors, "Print should be Yes."); + } + } else { + if (strlen($this->SendExtend['Print']) == 0) { + $this->SendExtend['Print'] = PrintMark::No; + } + + // 載具類別為會員載具(Member)、買受人自然人憑證(Citizen)、買受人手機條碼(Cellphone)時,請設定不列印(No) + $notPrint = array(CarruerType::Member, CarruerType::Citizen, CarruerType::Cellphone); + if (in_array($this->SendExtend['CarruerType'], $notPrint) and $this->SendExtend['Print'] == PrintMark::Yes) { + array_push($arErrors, "Print should be No."); + } + } + } + + } + + // CustomerName(UrlEncode, 預設為空字串) + if (mb_strlen($this->SendExtend['CustomerName'], 'UTF-8') > 20) { + array_push($arErrors, "CustomerName max length as 20."); + } else { + // 列印註記為列印(Yes)時,此參數不可為空字串 + if ($this->SendExtend['Print'] == PrintMark::Yes) { + if (mb_strlen($this->SendExtend['CustomerName'], 'UTF-8') == 0) { + array_push($arErrors, "CustomerName is required."); + } + } + } + + // CustomerAddr(UrlEncode, 預設為空字串) + if (mb_strlen($this->SendExtend['CustomerAddr'], 'UTF-8') > 200) { + array_push($arErrors, "CustomerAddr max length as 200."); + } else { + // 列印註記為列印(Yes)時,此參數不可為空字串 + if ($this->SendExtend['Print'] == PrintMark::Yes) { + if (mb_strlen($this->SendExtend['CustomerAddr'], 'UTF-8') == 0) { + array_push($arErrors, "CustomerAddr is required."); + } + } + } + + // CustomerPhone(與CustomerEmail擇一不可為空) + if (strlen($this->SendExtend['CustomerPhone']) > 20) { + array_push($arErrors, "CustomerPhone max length as 20."); + } + + // CustomerEmail(UrlEncode, 預設為空字串, 與CustomerPhone擇一不可為空) + if (strlen($this->SendExtend['CustomerEmail']) > 200) { + array_push($arErrors, "CustomerEmail max length as 200."); + } + + if (strlen($this->SendExtend['CustomerPhone']) == 0 and strlen($this->SendExtend['CustomerEmail']) == 0) { + array_push($arErrors, "CustomerPhone or CustomerEmail is required."); + } + + // TaxType(不可為空) + if (strlen($this->SendExtend['TaxType']) > 1) { + array_push($arErrors, "TaxType max length as 1."); + } else { + if (strlen($this->SendExtend['TaxType']) == 0) { + array_push($arErrors, "TaxType is required."); + } + } + + // ClearanceMark(預設為空字串) + if (strlen($this->SendExtend['ClearanceMark']) > 1) { + array_push($arErrors, "ClearanceMark max length as 1."); + } else { + // 請設定空字串,僅課稅類別為零稅率(Zero)時,此參數不可為空字串 + if ($this->SendExtend['TaxType'] == TaxType::Zero) { + if ($this->SendExtend['ClearanceMark'] != ClearanceMark::Yes and $this->SendExtend['ClearanceMark'] != ClearanceMark::No) { + array_push($arErrors, "ClearanceMark is required."); + } + } else { + if (strlen($this->SendExtend['ClearanceMark']) > 0) { + array_push($arErrors, "Please remove ClearanceMark."); + } + } + } + + // CarruerNum(預設為空字串) + if (strlen($this->SendExtend['CarruerNum']) > 64) { + array_push($arErrors, "CarruerNum max length as 64."); + } else { + switch ($this->SendExtend['CarruerType']) { + // 載具類別為無載具(None)或會員載具(Member)時,請設定空字串 + case CarruerType::None: + case CarruerType::Member: + if (strlen($this->SendExtend['CarruerNum']) > 0) { + array_push($arErrors, "Please remove CarruerNum."); + } + break; + // 載具類別為買受人自然人憑證(Citizen)時,請設定自然人憑證號碼,前2碼為大小寫英文,後14碼為數字 + case CarruerType::Citizen: + if (!preg_match('/^[a-zA-Z]{2}\d{14}$/', $this->SendExtend['CarruerNum'])) + { + array_push($arErrors, "Invalid CarruerNum."); + } + break; + // 載具類別為買受人手機條碼(Cellphone)時,請設定手機條碼,第1碼為「/」,後7碼為大小寫英文、數字、「+」、「-」或「.」 + case CarruerType::Cellphone: + if (!preg_match('/^\/{1}[0-9a-zA-Z+-.]{7}$/', $this->SendExtend['CarruerNum'])) { + array_push($arErrors, "Invalid CarruerNum."); + } + break; + default: + array_push($arErrors, "Please remove CarruerNum."); + } + } + + // LoveCode(預設為空字串) + // 捐贈註記為捐贈(Yes)時,參數長度固定3~7碼,請設定全數字或第1碼大小寫「X」,後2~6碼全數字 + if ($this->SendExtend['Donation'] == Donation::Yes) { + if (!preg_match('/^([xX]{1}[0-9]{2,6}|[0-9]{3,7})$/', $this->SendExtend['LoveCode'])) { + array_push($arErrors, "Invalid LoveCode."); + } + } else { + if (strlen($this->SendExtend['LoveCode']) > 0) { + array_push($arErrors, "Please remove LoveCode."); + } + } + + // InvoiceItemName(UrlEncode, 不可為空) + // InvoiceItemCount(不可為空) + // InvoiceItemWord(UrlEncode, 不可為空) + // InvoiceItemPrice(不可為空) + // InvoiceItemTaxType(不可為空) + if (sizeof($this->SendExtend['InvoiceItems']) > 0) { + $tmpItemName = array(); + $tmpItemCount = array(); + $tmpItemWord = array(); + $tmpItemPrice = array(); + $tmpItemTaxType = array(); + foreach ($this->SendExtend['InvoiceItems'] as $tmpItemInfo) { + if (mb_strlen($tmpItemInfo['Name'], 'UTF-8') > 0) { + array_push($tmpItemName, $tmpItemInfo['Name']); + } + if (strlen($tmpItemInfo['Count']) > 0) { + array_push($tmpItemCount, $tmpItemInfo['Count']); + } + if (mb_strlen($tmpItemInfo['Word'], 'UTF-8') > 0) { + array_push($tmpItemWord, $tmpItemInfo['Word']); + } + if (strlen($tmpItemInfo['Price']) > 0) { + array_push($tmpItemPrice, $tmpItemInfo['Price']); + } + if (strlen($tmpItemInfo['TaxType']) > 0) { + array_push($tmpItemTaxType, $tmpItemInfo['TaxType']); + } + } + + if ($this->SendExtend['TaxType'] == TaxType::Mix) { + if (in_array(TaxType::Dutiable, $tmpItemTaxType) and in_array(TaxType::Free, $tmpItemTaxType)) { + // Do nothing + } else { + $tmpItemTaxType = array(); + } + } + if ((count($tmpItemName) + count($tmpItemCount) + count($tmpItemWord) + count($tmpItemPrice) + count($tmpItemTaxType)) == (count($tmpItemName) * 5)) { + $szInvoiceItemName = implode($InvSptr, $tmpItemName); + $szInvoiceItemCount = implode($InvSptr, $tmpItemCount); + $szInvoiceItemWord = implode($InvSptr, $tmpItemWord); + $szInvoiceItemPrice = implode($InvSptr, $tmpItemPrice); + $szInvoiceItemTaxType = implode($InvSptr, $tmpItemTaxType); + } else { + array_push($arErrors, "Invalid Invoice Goods information."); + } + } else { + array_push($arErrors, "Invoice Goods information not found."); + } + // InvoiceRemark(UrlEncode, 預設為空字串) + + // DelayDay(不可為空, 預設為0) + // 延遲天數,範圍0~15,設定為0時,付款完成後立即開立發票 + $this->SendExtend['DelayDay'] = (int)$this->SendExtend['DelayDay']; + if ($this->SendExtend['DelayDay'] < 0 or $this->SendExtend['DelayDay'] > 15) { + array_push($arErrors, "DelayDay should be 0 ~ 15."); + } else { + if (strlen($this->SendExtend['DelayDay']) == 0) { + $this->SendExtend['DelayDay'] = 0; + } + } + + // InvType(不可為空) + if (strlen($this->SendExtend['InvType']) == 0) { + array_push($arErrors, "InvType is required."); + } + } + } + + // 檢查CheckMacValue加密方式 + if (strlen($this->Send['EncryptType']) > 1) { + array_push($arErrors, 'EncryptType max langth as 1.'); + } + + // 輸出表單字串。 + if (sizeof($arErrors) == 0) { + // 信用卡特殊邏輯判斷(行動裝置畫面的信用卡分期處理,不支援定期定額) + if ($this->Send['ChoosePayment'] == PaymentMethod::Credit && $this->Send['DeviceSource'] == DeviceType::Mobile && !$this->SendExtend['PeriodAmount']) { + $this->Send['ChoosePayment'] = PaymentMethod::ALL; + $this->Send['IgnorePayment'] = 'WebATM#ATM#CVS#BARCODE#Alipay#Tenpay#TopUpUsed#APPBARCODE#AccountLink'; + } + // 產生畫面控制項與傳遞參數。 + $arParameters = array( + 'MerchantID' => $this->MerchantID, + 'PaymentType' => $this->PaymentType, + 'ItemName' => $szItemName, + 'ItemURL' => $this->Send['ItemURL'], + 'InvoiceItemName' => $szInvoiceItemName, + 'InvoiceItemCount' => $szInvoiceItemCount, + 'InvoiceItemWord' => $szInvoiceItemWord, + 'InvoiceItemPrice' => $szInvoiceItemPrice, + 'InvoiceItemTaxType' => $szInvoiceItemTaxType, + ); + $arParameters = array_merge($arParameters, $this->Send); + $arParameters = array_merge($arParameters, $this->SendExtend); + // 處理延伸參數 + if (!$this->Send['PlatformID']) { unset($arParameters['PlatformID']); } + // 整理全功能參數。 + if ($this->Send['ChoosePayment'] == PaymentMethod::ALL) { + unset($arParameters['ExecTimes']); + unset($arParameters['Frequency']); + unset($arParameters['PeriodAmount']); + unset($arParameters['PeriodReturnURL']); + unset($arParameters['PeriodType']); + $arParameters = array_merge($arParameters, array( + 'AlipayItemName' => $szAlipayItemName, + 'AlipayItemCounts' => $szAlipayItemCounts, + 'AlipayItemPrice' => $szAlipayItemPrice + )); + if (!$arParameters['CreditInstallment']) { unset($arParameters['CreditInstallment']); } + if (!$arParameters['InstallmentAmount']) { unset($arParameters['InstallmentAmount']); } + if (!$arParameters['Redeem']) { unset($arParameters['Redeem']); } + if (!$arParameters['UnionPay']) { unset($arParameters['UnionPay']); } + if (!$this->Send['IgnorePayment']) { unset($arParameters['IgnorePayment']); } + if (!$this->SendExtend['ClientRedirectURL']) { unset($arParameters['ClientRedirectURL']); } + } + // 整理 Alipay 參數。 + if ($this->Send['ChoosePayment'] == PaymentMethod::Alipay) { + $arParameters = array_merge($arParameters, array( + 'AlipayItemName' => $szAlipayItemName, + 'AlipayItemCounts' => $szAlipayItemCounts, + 'AlipayItemPrice' => $szAlipayItemPrice + )); + unset($arParameters['CreditInstallment']); + unset($arParameters['Desc_1']); + unset($arParameters['Desc_2']); + unset($arParameters['Desc_3']); + unset($arParameters['Desc_4']); + unset($arParameters['ExecTimes']); + unset($arParameters['ExpireDate']); + unset($arParameters['ExpireTime']); + unset($arParameters['Frequency']); + unset($arParameters['InstallmentAmount']); + unset($arParameters['PaymentInfoURL']); + unset($arParameters['PeriodAmount']); + unset($arParameters['PeriodReturnURL']); + unset($arParameters['PeriodType']); + unset($arParameters['Redeem']); + unset($arParameters['UnionPay']); + unset($arParameters['IgnorePayment']); + unset($arParameters['ClientRedirectURL']); + } + // 整理 Tenpay 參數。 + if ($this->Send['ChoosePayment'] == PaymentMethod::Tenpay) { + unset($arParameters['CreditInstallment']); + unset($arParameters['Desc_1']); + unset($arParameters['Desc_2']); + unset($arParameters['Desc_3']); + unset($arParameters['Desc_4']); + unset($arParameters['Email']); + unset($arParameters['ExecTimes']); + unset($arParameters['ExpireDate']); + unset($arParameters['Frequency']); + unset($arParameters['InstallmentAmount']); + unset($arParameters['PaymentInfoURL']); + unset($arParameters['PeriodAmount']); + unset($arParameters['PeriodReturnURL']); + unset($arParameters['PeriodType']); + unset($arParameters['PhoneNo']); + unset($arParameters['Redeem']); + unset($arParameters['UnionPay']); + unset($arParameters['UserName']); + unset($arParameters['IgnorePayment']); + unset($arParameters['ClientRedirectURL']); + } + // 整理 ATM 參數。 + if ($this->Send['ChoosePayment'] == PaymentMethod::ATM) { + unset($arParameters['CreditInstallment']); + unset($arParameters['Desc_1']); + unset($arParameters['Desc_2']); + unset($arParameters['Desc_3']); + unset($arParameters['Desc_4']); + unset($arParameters['Email']); + unset($arParameters['ExecTimes']); + unset($arParameters['ExpireTime']); + unset($arParameters['Frequency']); + unset($arParameters['InstallmentAmount']); + unset($arParameters['PeriodAmount']); + unset($arParameters['PeriodReturnURL']); + unset($arParameters['PeriodType']); + unset($arParameters['PhoneNo']); + unset($arParameters['Redeem']); + unset($arParameters['UnionPay']); + unset($arParameters['UserName']); + unset($arParameters['IgnorePayment']); + if (!$this->SendExtend['ClientRedirectURL']) { unset($arParameters['ClientRedirectURL']); } + } + // 整理 BARCODE OR CVS 參數。 + if ($this->Send['ChoosePayment'] == PaymentMethod::BARCODE || $this->Send['ChoosePayment'] == PaymentMethod::CVS) { + unset($arParameters['CreditInstallment']); + unset($arParameters['Email']); + unset($arParameters['ExecTimes']); + unset($arParameters['ExpireDate']); + unset($arParameters['ExpireTime']); + unset($arParameters['Frequency']); + unset($arParameters['InstallmentAmount']); + unset($arParameters['PeriodAmount']); + unset($arParameters['PeriodReturnURL']); + unset($arParameters['PeriodType']); + unset($arParameters['PhoneNo']); + unset($arParameters['Redeem']); + unset($arParameters['UnionPay']); + unset($arParameters['UserName']); + unset($arParameters['IgnorePayment']); + if (!$this->SendExtend['ClientRedirectURL']) { unset($arParameters['ClientRedirectURL']); } + } + // 整理全功能、WebATM OR TopUpUsed 參數。 + if ($this->Send['ChoosePayment'] == PaymentMethod::WebATM || $this->Send['ChoosePayment'] == PaymentMethod::TopUpUsed) { + unset($arParameters['CreditInstallment']); + unset($arParameters['Desc_1']); + unset($arParameters['Desc_2']); + unset($arParameters['Desc_3']); + unset($arParameters['Desc_4']); + unset($arParameters['Email']); + unset($arParameters['ExecTimes']); + unset($arParameters['ExpireDate']); + unset($arParameters['ExpireTime']); + unset($arParameters['Frequency']); + unset($arParameters['InstallmentAmount']); + unset($arParameters['PaymentInfoURL']); + unset($arParameters['PeriodAmount']); + unset($arParameters['PeriodReturnURL']); + unset($arParameters['PeriodType']); + unset($arParameters['PhoneNo']); + unset($arParameters['Redeem']); + unset($arParameters['UnionPay']); + unset($arParameters['UserName']); + unset($arParameters['IgnorePayment']); + unset($arParameters['ClientRedirectURL']); + } + // 整理 Credit 參數。 + if ($this->Send['ChoosePayment'] == PaymentMethod::Credit) { + // Credit 分期。 + $arParameters['Redeem'] = ($arParameters['Redeem'] ? 'Y' : ''); + $arParameters['UnionPay'] = ($arParameters['UnionPay'] ? 1 : 0); + unset($arParameters['Desc_1']); + unset($arParameters['Desc_2']); + unset($arParameters['Desc_3']); + unset($arParameters['Desc_4']); + unset($arParameters['Email']); + unset($arParameters['ExpireDate']); + unset($arParameters['ExpireTime']); + unset($arParameters['PaymentInfoURL']); + unset($arParameters['PhoneNo']); + unset($arParameters['UserName']); + unset($arParameters['IgnorePayment']); + unset($arParameters['ClientRedirectURL']); + } + unset($arParameters['Items']); + + // 處理電子發票參數 + unset($arParameters['InvoiceItems']); + if ($this->Send['InvoiceMark'] == InvoiceState::Yes) { + $encode_fields = array( + 'CustomerName', + 'CustomerAddr', + 'CustomerEmail', + 'InvoiceItemName', + 'InvoiceItemWord', + 'InvoiceRemark' + ); + foreach ($encode_fields as $tmp_field) { + $arParameters[$tmp_field] = urlencode($arParameters[$tmp_field]); + } + } else { + unset($arParameters['InvoiceMark']); + unset($arParameters['RelateNumber']); + unset($arParameters['CustomerIdentifier']); + unset($arParameters['CarruerType']); + unset($arParameters['CustomerID']); + unset($arParameters['Donation']); + unset($arParameters['Print']); + unset($arParameters['CustomerName']); + unset($arParameters['CustomerAddr']); + unset($arParameters['CustomerPhone']); + unset($arParameters['CustomerEmail']); + unset($arParameters['TaxType']); + unset($arParameters['ClearanceMark']); + unset($arParameters['CarruerNum']); + unset($arParameters['LoveCode']); + unset($arParameters['InvoiceItemName']); + unset($arParameters['InvoiceItemCount']); + unset($arParameters['InvoiceItemWord']); + unset($arParameters['InvoiceItemPrice']); + unset($arParameters['InvoiceItemTaxType']); + unset($arParameters['InvoiceRemark']); + unset($arParameters['DelayDay']); + unset($arParameters['InvType']); + } + + // 資料排序 + // php 5.3以下不支援 + // ksort($arParameters, SORT_NATURAL | SORT_FLAG_CASE); + uksort($arParameters, array('AllInOne','merchantSort')); + $szCheckMacValue = "HashKey=$this->HashKey"; + foreach ($arParameters as $key => $value) { + $szCheckMacValue .= "&$key=$value"; + } + $szCheckMacValue .= "&HashIV=$this->HashIV"; + $szCheckMacValue = strtolower(urlencode($szCheckMacValue)); + // 取代為與 dotNet 相符的字元 + $szCheckMacValue = str_replace('%2d', '-', $szCheckMacValue); + $szCheckMacValue = str_replace('%5f', '_', $szCheckMacValue); + $szCheckMacValue = str_replace('%2e', '.', $szCheckMacValue); + $szCheckMacValue = str_replace('%21', '!', $szCheckMacValue); + $szCheckMacValue = str_replace('%2a', '*', $szCheckMacValue); + $szCheckMacValue = str_replace('%28', '(', $szCheckMacValue); + $szCheckMacValue = str_replace('%29', ')', $szCheckMacValue); + // Customize for Magento + $szCheckMacValue = str_replace('%3f___sid%3d' . session_id(), '', $szCheckMacValue); + $szCheckMacValue = str_replace('%3f___sid%3du', '', $szCheckMacValue); + $szCheckMacValue = str_replace('%3f___sid%3ds', '', $szCheckMacValue); + + // CheckMacValue 壓碼 + $szCheckMacValue = $this->EncCheckMacValue($szCheckMacValue, $this->Send['EncryptType']); + $szHtml = ''; + $szHtml .= '
'; + foreach ($arParameters as $keys => $value) { + $szHtml .=""; + } + $szHtml .= ''; + // 手動或自動送出表單。 + if (!isset($paymentButton)) { + $szHtml .= ''; + } else { + $szHtml .= ''; + } + $szHtml .= '
'; + } + if (sizeof($arErrors) > 0) { + throw new Exception(join('- ', $arErrors)); + } + return $szHtml; + } + function CheckOutFeedback() { + // 變數宣告。 + $arErrors = array(); + $arParameters = array(); + $arFeedback = array(); + $szCheckMacValue = ''; + // 重新整理回傳參數。 + foreach ($_POST as $keys => $value) { + if ($keys != 'CheckMacValue') { + if ($keys == 'PaymentType') { + $value = str_replace('_CVS', '', $value); + $value = str_replace('_BARCODE', '', $value); + $value = str_replace('_Alipay', '', $value); + $value = str_replace('_Tenpay', '', $value); + $value = str_replace('_CreditCard', '', $value); + } + if ($keys == 'PeriodType') { + $value = str_replace('Y', 'Year', $value); + $value = str_replace('M', 'Month', $value); + $value = str_replace('D', 'Day', $value); + } + $arFeedback[$keys] = $value; + } else { + $szCheckMacValue = $value; + } + } + // 回傳參數鍵值轉小寫。 + foreach ($_POST as $keys => $value) { + if ($keys == 'view' || $keys == 'hikashop_front_end_main') { + // Customize to Skip Parameters for HikaShop + } else if ($keys == 'mijoshop_store_id' || $keys == 'language') { + // Customize to Skip Parameters for MijoShop + } else { + $arParameters[strtolower($keys)] = $value; + } + } + unset($arParameters['checkmacvalue']); + ksort($arParameters); + // 驗證檢查碼。 + if (sizeof($arFeedback) > 0) { + $szConfirmMacValue = "HashKey=$this->HashKey"; + foreach ($arParameters as $key => $value) { + $szConfirmMacValue .= "&$key=$value"; + } + $szConfirmMacValue .= "&HashIV=$this->HashIV"; + $szConfirmMacValue = strtolower(urlencode($szConfirmMacValue)); + // 取代為與 dotNet 相符的字元 + $szConfirmMacValue = str_replace('%2d', '-', $szConfirmMacValue); + $szConfirmMacValue = str_replace('%5f', '_', $szConfirmMacValue); + $szConfirmMacValue = str_replace('%2e', '.', $szConfirmMacValue); + $szConfirmMacValue = str_replace('%21', '!', $szConfirmMacValue); + $szConfirmMacValue = str_replace('%2a', '*', $szConfirmMacValue); + $szConfirmMacValue = str_replace('%28', '(', $szConfirmMacValue); + $szConfirmMacValue = str_replace('%29', ')', $szConfirmMacValue); + + // 檢查CheckMacValue加密方式 + if (strlen($this->EncryptType) > 1) { + array_push($arErrors, 'EncryptType max langth as 1.'); + } + + // CheckMacValue 壓碼 + $szConfirmMacValue = $this->EncCheckMacValue($szConfirmMacValue, $this->EncryptType); + if ($szCheckMacValue != strtoupper($szConfirmMacValue)) { + array_push($arErrors, 'CheckMacValue verify fail. [checkMac]: '.$szCheckMacValue.', [confirm]: '.strtoupper($szConfirmMacValue)); // 2016/02/15 add memo + //array_push($arErrors, 'CheckMacValue verify fail.'); + } + } + if (sizeof($arErrors) > 0) { + throw new Exception(join('- ', $arErrors)); + } + return $arFeedback; + } + function QueryTradeInfo() { + // 變數宣告。 + $arErrors = array(); + $this->Query['TimeStamp'] = time(); + $arFeedback = array(); + $arConfirmArgs = array(); + // 檢查資料。 + if (strlen($this->ServiceURL) == 0) { + array_push($arErrors, 'ServiceURL is required.'); + } + if (strlen($this->ServiceURL) > 200) { + array_push($arErrors, 'ServiceURL max langth as 200.'); + } + if (strlen($this->HashKey) == 0) { + array_push($arErrors, 'HashKey is required.'); + } + if (strlen($this->HashIV) == 0) { + array_push($arErrors, 'HashIV is required.'); + } + if (strlen($this->MerchantID) == 0) { + array_push($arErrors, 'MerchantID is required.'); + } + if (strlen($this->MerchantID) > 10) { + array_push($arErrors, 'MerchantID max langth as 10.'); + } + if (strlen($this->Query['MerchantTradeNo']) == 0) { + array_push($arErrors, 'MerchantTradeNo is required.'); + } + if (strlen($this->Query['MerchantTradeNo']) > 20) { + array_push($arErrors, 'MerchantTradeNo max langth as 20.'); + } + if (strlen($this->Query['TimeStamp']) == 0) { + array_push($arErrors, 'TimeStamp is required.'); + } + // 呼叫查詢。 + if (sizeof($arErrors) == 0) { + $arParameters = array("MerchantID" => $this->MerchantID); + $arParameters = array_merge($arParameters, $this->Query); + // 資料排序。 + ksort($arParameters); + // 產生檢查碼。 + $szCheckMacValue = "HashKey=$this->HashKey"; + foreach ($arParameters as $key => $value) { + $szCheckMacValue .= "&$key=$value"; + } + $szCheckMacValue .= "&HashIV=$this->HashIV"; + $szCheckMacValue = strtolower(urlencode($szCheckMacValue)); + // 取代為與 dotNet 相符的字元 + $szCheckMacValue = str_replace('%2d', '-', $szCheckMacValue); + $szCheckMacValue = str_replace('%5f', '_', $szCheckMacValue); + $szCheckMacValue = str_replace('%2e', '.', $szCheckMacValue); + $szCheckMacValue = str_replace('%21', '!', $szCheckMacValue); + $szCheckMacValue = str_replace('%2a', '*', $szCheckMacValue); + $szCheckMacValue = str_replace('%28', '(', $szCheckMacValue); + $szCheckMacValue = str_replace('%29', ')', $szCheckMacValue); + // Customize for Magento + $szCheckMacValue = str_replace('%3f___sid%3d' . session_id(), '', $szCheckMacValue); + $szCheckMacValue = str_replace('%3f___sid%3du', '', $szCheckMacValue); + $szCheckMacValue = str_replace('%3f___sid%3ds', '', $szCheckMacValue); + // MD5 編碼 + $szCheckMacValue = md5($szCheckMacValue); + $arParameters["CheckMacValue"] = $szCheckMacValue; + // 送出查詢並取回結果。 + $szResult = $this->ServerPost($arParameters); + $szResult = str_replace(' ', '%20', $szResult); + $szResult = str_replace('+', '%2B', $szResult); + //$szResult = str_replace('/', '%2F', $szResult); + //$szResult = str_replace('?', '%3F', $szResult); + //$szResult = str_replace('%', '%25', $szResult); + //$szResult = str_replace('#', '%23', $szResult); + //$szResult = str_replace('&', '%26', $szResult); + //$szResult = str_replace('=', '%3D', $szResult); + // 轉結果為陣列。 + parse_str($szResult, $arParameters); + // 重新整理回傳參數。 + foreach ($arParameters as $keys => $value) { + if ($keys == 'CheckMacValue') { + $szCheckMacValue = $value; + } else { + $arFeedback[$keys] = $value; + $arConfirmArgs[strtolower($keys)] = $value; + } + } + ksort($arConfirmArgs); + // 驗證檢查碼。 + if (sizeof($arFeedback) > 0) { + $szConfirmMacValue = "HashKey=$this->HashKey"; + foreach ($arConfirmArgs as $key => $value) { + $szConfirmMacValue .= "&$key=$value"; + } + $szConfirmMacValue .= "&HashIV=$this->HashIV"; + $szConfirmMacValue = strtolower(urlencode($szConfirmMacValue)); + // 取代為與 dotNet 相符的字元 + $szConfirmMacValue = str_replace('%2d', '-', $szConfirmMacValue); + $szConfirmMacValue = str_replace('%5f', '_', $szConfirmMacValue); + $szConfirmMacValue = str_replace('%2e', '.', $szConfirmMacValue); + $szConfirmMacValue = str_replace('%21', '!', $szConfirmMacValue); + $szConfirmMacValue = str_replace('%2a', '*', $szConfirmMacValue); + $szConfirmMacValue = str_replace('%28', '(', $szConfirmMacValue); + $szConfirmMacValue = str_replace('%29', ')', $szConfirmMacValue); + // MD5 編碼 + $szConfirmMacValue = md5($szConfirmMacValue); + if ($szCheckMacValue != strtoupper($szConfirmMacValue)) { + array_push($arErrors, 'CheckMacValue verify fail.'); + } + } + } + if (sizeof($arErrors) > 0) { + throw new Exception(join('- ', $arErrors)); + } + return $arFeedback; + } + + function QueryPeriodCreditCardTradeInfo() { + // 變數宣告。 + $arErrors = array(); + $this->Query['TimeStamp'] = time(); + $arFeedback = array(); + // 檢查資料。 + if (strlen($this->ServiceURL) == 0) { + array_push($arErrors, 'ServiceURL is required.'); + } + if (strlen($this->ServiceURL) > 200) { + array_push($arErrors, 'ServiceURL max langth as 200.'); + } + if (strlen($this->HashKey) == 0) { + array_push($arErrors, 'HashKey is required.'); + } + if (strlen($this->HashIV) == 0) { + array_push($arErrors, 'HashIV is required.'); + } + if (strlen($this->MerchantID) == 0) { + array_push($arErrors, 'MerchantID is required.'); + } + if (strlen($this->MerchantID) > 10) { + array_push($arErrors, 'MerchantID max langth as 10.'); + } + if (strlen($this->Query['MerchantTradeNo']) == 0) { + array_push($arErrors, 'MerchantTradeNo is required.'); + } + if (strlen($this->Query['MerchantTradeNo']) > 20) { + array_push($arErrors, 'MerchantTradeNo max langth as 20.'); + } + if (strlen($this->Query['TimeStamp']) == 0) { + array_push($arErrors, 'TimeStamp is required.'); + } + // 呼叫查詢。 + if (sizeof($arErrors) == 0) { + $arParameters = array("MerchantID" => $this->MerchantID); + $arParameters = array_merge($arParameters, $this->Query); + // 資料排序。 + ksort($arParameters); + // 產生檢查碼。 + $szCheckMacValue = "HashKey=$this->HashKey"; + foreach ($arParameters as $key => $value) { + $szCheckMacValue .= "&$key=$value"; + } + $szCheckMacValue .= "&HashIV=$this->HashIV"; + $szCheckMacValue = strtolower(urlencode($szCheckMacValue)); + // 取代為與 dotNet 相符的字元 + $szCheckMacValue = str_replace('%2d', '-', $szCheckMacValue); + $szCheckMacValue = str_replace('%5f', '_', $szCheckMacValue); + $szCheckMacValue = str_replace('%2e', '.', $szCheckMacValue); + $szCheckMacValue = str_replace('%21', '!', $szCheckMacValue); + $szCheckMacValue = str_replace('%2a', '*', $szCheckMacValue); + $szCheckMacValue = str_replace('%28', '(', $szCheckMacValue); + $szCheckMacValue = str_replace('%29', ')', $szCheckMacValue); + // Customize for Magento + $szCheckMacValue = str_replace('%3f___sid%3d' . session_id(), '', $szCheckMacValue); + $szCheckMacValue = str_replace('%3f___sid%3du', '', $szCheckMacValue); + $szCheckMacValue = str_replace('%3f___sid%3ds', '', $szCheckMacValue); + // MD5 編碼 + $szCheckMacValue = md5($szCheckMacValue); + $arParameters["CheckMacValue"] = $szCheckMacValue; + // 送出查詢並取回結果。 + $szResult = $this->ServerPost($arParameters); + $szResult = str_replace(' ', '%20', $szResult); + $szResult = str_replace('+', '%2B', $szResult); + //$szResult = str_replace('/', '%2F', $szResult); + //$szResult = str_replace('?', '%3F', $szResult); + //$szResult = str_replace('%', '%25', $szResult); + //$szResult = str_replace('#', '%23', $szResult); + //$szResult = str_replace('&', '%26', $szResult); + //$szResult = str_replace('=', '%3D', $szResult); + // 轉結果為陣列。 + parse_str($szResult, $arFeedback); + } + if (sizeof($arErrors) > 0) { + throw new Exception(join('- ', $arErrors)); + } + return $arFeedback; + } + function DoAction() { + // 變數宣告。 + $arErrors = array(); + $arFeedback = array(); + // 檢查資料。 + if (strlen($this->ServiceURL) == 0) { + array_push($arErrors, 'ServiceURL is required.'); + } + if (strlen($this->ServiceURL) > 200) { + array_push($arErrors, 'ServiceURL max langth as 200.'); + } + if (strlen($this->HashKey) == 0) { + array_push($arErrors, 'HashKey is required.'); + } + if (strlen($this->HashIV) == 0) { + array_push($arErrors, 'HashIV is required.'); + } + if (strlen($this->MerchantID) == 0) { + array_push($arErrors, 'MerchantID is required.'); + } + if (strlen($this->MerchantID) > 10) { + array_push($arErrors, 'MerchantID max langth as 10.'); + } + if (strlen($this->Action['MerchantTradeNo']) == 0) { + array_push($arErrors, 'MerchantTradeNo is required.'); + } + if (strlen($this->Action['MerchantTradeNo']) > 20) { + array_push($arErrors, 'MerchantTradeNo max langth as 20.'); + } + if (strlen($this->Action['TradeNo']) == 0) { + array_push($arErrors, 'TradeNo is required.'); + } + if (strlen($this->Action['TradeNo']) > 20) { + array_push($arErrors, 'TradeNo max langth as 20.'); + } + if (strlen($this->Action['Action']) == 0) { + array_push($arErrors, 'Action is required.'); + } + if (strlen($this->Action['Action']) > 1) { + array_push($arErrors, 'Action max length as 1.'); + } + if (strlen($this->Action['TotalAmount']) == 0) { + array_push($arErrors, 'TotalAmount is required.'); + } + // 呼叫信用卡訂單處理。 + if (sizeof($arErrors) == 0) { + $arParameters = array("MerchantID" => $this->MerchantID); + $arParameters = array_merge($arParameters, $this->Action); + // 資料排序。 + ksort($arParameters); + // 產生檢查碼。 + $szCheckMacValue = "HashKey=$this->HashKey"; + foreach ($arParameters as $key => $value) { + $szCheckMacValue .= "&$key=$value"; + } + $szCheckMacValue .= "&HashIV=$this->HashIV"; + $szCheckMacValue = strtolower(urlencode($szCheckMacValue)); + // 取代為與 dotNet 相符的字元 + $szCheckMacValue = str_replace('%2d', '-', $szCheckMacValue); + $szCheckMacValue = str_replace('%5f', '_', $szCheckMacValue); + $szCheckMacValue = str_replace('%2e', '.', $szCheckMacValue); + $szCheckMacValue = str_replace('%21', '!', $szCheckMacValue); + $szCheckMacValue = str_replace('%2a', '*', $szCheckMacValue); + $szCheckMacValue = str_replace('%28', '(', $szCheckMacValue); + $szCheckMacValue = str_replace('%29', ')', $szCheckMacValue); + // Customize for Magento + $szCheckMacValue = str_replace('%3f___sid%3d' . session_id(), '', $szCheckMacValue); + $szCheckMacValue = str_replace('%3f___sid%3du', '', $szCheckMacValue); + $szCheckMacValue = str_replace('%3f___sid%3ds', '', $szCheckMacValue); + // MD5 編碼 + $szCheckMacValue = md5($szCheckMacValue); + $arParameters["CheckMacValue"] = $szCheckMacValue; + // 送出查詢並取回結果。 + $szResult = $this->ServerPost($arParameters); + // 轉結果為陣列。 + parse_str($szResult, $arParameters); + // 重新整理回傳參數。 + foreach ($arParameters as $keys => $value) { + if ($keys == 'CheckMacValue') { + $szCheckMacValue = $value; + } else { + $arFeedback[$keys] = $value; + } + } + if (array_key_exists('RtnCode', $arFeedback) && $arFeedback['RtnCode'] != '1') { + array_push($arErrors, vsprintf('#%s: %s', array($arFeedback['RtnCode'], $arFeedback['RtnMsg']))); + } + } + if (sizeof($arErrors) > 0) { + throw new Exception(join('- ', $arErrors)); + } + return $arFeedback; + } + function AioChargeback() { + // 變數宣告。 + $arErrors = array(); + $arParameters = array("MerchantID" => $this->MerchantID); + $arParameters = array_merge($arParameters, $this->ChargeBack); + $arFeedback = array(); + // 檢查資料。 + if (strlen($this->ServiceURL) == 0) { + array_push($arErrors, 'ServiceURL is required.'); + } + if (strlen($this->ServiceURL) > 200) { + array_push($arErrors, 'ServiceURL max langth as 200.'); + } + if (strlen($this->HashKey) == 0) { + array_push($arErrors, 'HashKey is required.'); + } + if (strlen($this->HashIV) == 0) { + array_push($arErrors, 'HashIV is required.'); + } + if (strlen($this->MerchantID) == 0) { + array_push($arErrors, 'MerchantID is required.'); + } + if (strlen($this->MerchantID) > 10) { + array_push($arErrors, 'MerchantID max langth as 10.'); + } + if (strlen($this->ChargeBack['MerchantTradeNo']) == 0) { + array_push($arErrors, 'MerchantTradeNo is required.'); + } + if (strlen($this->ChargeBack['MerchantTradeNo']) > 20) { + array_push($arErrors, 'MerchantTradeNo max langth as 20.'); + } + if (strlen($this->ChargeBack['TradeNo']) == 0) { + array_push($arErrors, 'TradeNo is required.'); + } + if (strlen($this->ChargeBack['TradeNo']) > 20) { + array_push($arErrors, 'TradeNo max langth as 20.'); + } + if (strlen($this->ChargeBack['ChargeBackTotalAmount']) == 0) { + array_push($arErrors, 'ChargeBackTotalAmount is required.'); + } + if (strlen($this->ChargeBack['Remark']) > 200) { + array_push($arErrors, 'Remark max length as 200.'); + } + // 資料排序。 + ksort($arParameters); + // 產生檢查碼。 + $szCheckMacValue = "HashKey=$this->HashKey"; + foreach ($arParameters as $key => $value) { + $szCheckMacValue .= "&$key=$value"; + } + $szCheckMacValue .= "&HashIV=$this->HashIV"; + $szCheckMacValue = strtolower(urlencode($szCheckMacValue)); + // 取代為與 dotNet 相符的字元 + $szCheckMacValue = str_replace('%2d', '-', $szCheckMacValue); + $szCheckMacValue = str_replace('%5f', '_', $szCheckMacValue); + $szCheckMacValue = str_replace('%2e', '.', $szCheckMacValue); + $szCheckMacValue = str_replace('%21', '!', $szCheckMacValue); + $szCheckMacValue = str_replace('%2a', '*', $szCheckMacValue); + $szCheckMacValue = str_replace('%28', '(', $szCheckMacValue); + $szCheckMacValue = str_replace('%29', ')', $szCheckMacValue); + // Customize for Magento + $szCheckMacValue = str_replace('%3f___sid%3d' . session_id(), '', $szCheckMacValue); + $szCheckMacValue = str_replace('%3f___sid%3du', '', $szCheckMacValue); + $szCheckMacValue = str_replace('%3f___sid%3ds', '', $szCheckMacValue); + // MD5 編碼 + $szCheckMacValue = md5($szCheckMacValue); + $arParameters["CheckMacValue"] = $szCheckMacValue; + // 送出查詢並取回結果。 + $szResult = $this->ServerPost($arParameters); + // 檢查結果資料。 + if ($szResult == '1|OK') { + $arFeedback['RtnCode'] = '1'; + $arFeedback['RtnMsg'] = 'OK'; + } else { + array_push($arErrors, str_replace('-', ': ', $szResult)); + } + if (sizeof($arErrors) > 0) { + throw new Exception(join('- ', $arErrors)); + } + return $arFeedback; + } + private function ServerPost($parameters) { + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $this->ServiceURL); + curl_setopt($ch, CURLOPT_HEADER, FALSE); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); + curl_setopt($ch, CURLOPT_POST, TRUE); + curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($parameters)); + $rs = curl_exec($ch); + curl_close($ch); + return $rs; + } + /** + * 自訂排序使用 + */ + private static function merchantSort($a,$b) + { + return strcasecmp($a, $b); + } + + private function EncCheckMacValue($checkMacValue, $encType = EncryptType::ENC_MD5) { + $szCheckMacValue = $checkMacValue; + switch ($encType) { + case EncryptType::ENC_SHA256: + // SHA256 編碼 + $szCheckMacValue = hash('sha256', $szCheckMacValue); + break; + case EncryptType::ENC_MD5: + default: + // MD5 編碼 + $szCheckMacValue = md5($szCheckMacValue); + } + return $szCheckMacValue; + } + +} \ No newline at end of file diff --git a/phplibs/AllPay_Invoice.php b/phplibs/AllPay_Invoice.php new file mode 100644 index 0000000..1c8852d --- /dev/null +++ b/phplibs/AllPay_Invoice.php @@ -0,0 +1,2078 @@ +AllInvoice(); + $this->TimeStamp = time(); + + $this->Send = array( + "RelateNumber" => '', + "CustomerID" => '', + "CustomerIdentifier" => '', + "CustomerName" => '', + "CustomerAddr" => '', + "CustomerPhone" => '', + "CustomerEmail" => '', + "ClearanceMark" => '', + "Print" => PrintMark::No, + "Donation" => Donation::No, + "LoveCode" => '', + "CarruerType" => CarruerType::None, + "CarruerNum" => '', + "TaxType" => '', + "SalesAmount" => '', + "InvoiceRemark" => '', + "Items" => array(), + "InvType" => '', + "InvCreateDate" => '', + "vat" => VatType::Yes, + "DelayFlag" => '', + "DelayDay" => 0, + "ECBankID" => '', + "Tsr" => '', + "PayType" => '', + "PayAct" => '', + "NotifyURL" => '', + "InvoiceNo" => '', + "AllowanceNotify" => '', + "NotifyMail" => '', + "NotifyPhone" => '', + "AllowanceAmount" => '', + "InvoiceNumber" => '', + "Reason" => '', + "AllowanceNo" => '', + "Phone" => '', + "Notify" => '', + "InvoiceTag" => '', + "Notified" => '' + ); + + } + + function AllInvoice() + { + } + + /** + * 執行發票各項動作 + */ + function Check_Out() + { + // 變數宣告 + $arErrors = '' ; + $aSend_Info = array() ; // 送出參數 + $aSend_CheckMac_Info = array() ; // 送出檢查碼用陣列 + + $aReturn_Info = array() ; // 回傳參數 + $aReturn_CheckMacValue = array() ; // 回傳檢查碼用陣列 + $sReturn_CheckMacValue = '' ; // 回傳回來的CheckMacValue + + // A.一般開立發票、B.延遲或觸發開立發票、C.開立折讓使用 + $sItemName = '' ; // 商品名稱 + $sItemCount = '' ; // 商品數量 + $sItemWord = '' ; // 商品單位 + $sItemPrice = '' ; // 商品價格 + $sItemTaxType = '' ; // 商品課稅別 + $sItemAmount = '' ; // 商品合計 + $nItems_Foreach_Count = 1 ; // 商品計算 + + // 參數檢查 + $arErrors = $this->Check_String() ; + + // 1.有錯誤變數 + if(sizeof($arErrors) > 0) + { + throw new Exception(join('
', $arErrors)); + } + else + { + // 2.整理必要參數 + $aSend_Info = $this->Send ; + + $aSend_Info['TimeStamp'] = $this->TimeStamp ; + $aSend_Info['MerchantID'] = $this->MerchantID ; + + // 3.判斷動作類型 + + // A.一般開立發票 + if( $this->Invoice_Method == InvoiceMethod::INVOICE ) + { + // 3-1過濾不需要的項目 + unset($aSend_Info['DelayFlag']) ; + unset($aSend_Info['DelayDay']) ; + unset($aSend_Info['ECBankID']) ; + unset($aSend_Info['Tsr']) ; + unset($aSend_Info['PayType']) ; + unset($aSend_Info['PayAct']) ; + unset($aSend_Info['NotifyURL']) ; + unset($aSend_Info['InvoiceNo']) ; + unset($aSend_Info['AllowanceNotify']) ; + unset($aSend_Info['NotifyMail']) ; + unset($aSend_Info['NotifyPhone']) ; + unset($aSend_Info['AllowanceAmount']) ; + unset($aSend_Info['InvoiceNumber']) ; + unset($aSend_Info['Reason']) ; + unset($aSend_Info['AllowanceNo']) ; + unset($aSend_Info['Phone']) ; + unset($aSend_Info['Notify']) ; + unset($aSend_Info['InvoiceTag']) ; + unset($aSend_Info['Notified']) ; + + // 3-2商品資訊組合 + $nItems_Count_Total = count($this->Send['Items']) ; // 商品總筆數 + foreach($this->Send['Items'] as $key => $value) + { + $sItemName .= $value['ItemName'] ; + $sItemCount .= (int) $value['ItemCount'] ; + $sItemWord .= $value['ItemWord'] ; + $sItemPrice .= (int) $value['ItemPrice'] ; + $sItemTaxType .= $value['ItemTaxType'] ; + $sItemAmount .= (int) $value['ItemAmount'] ; + + if( $nItems_Foreach_Count < $nItems_Count_Total ) + { + $sItemName .= '|' ; + $sItemCount .= '|' ; + $sItemWord .= '|' ; + $sItemPrice .= '|' ; + $sItemTaxType .= '|' ; + $sItemAmount .= '|' ; + } + + $nItems_Foreach_Count++ ; + } + + $aSend_Info['ItemName'] = urlencode($sItemName); // 商品名稱 + $aSend_Info['ItemCount'] = $sItemCount ; + $aSend_Info['ItemWord'] = urlencode($sItemWord); // 商品單位 + $aSend_Info['ItemPrice'] = $sItemPrice ; + $aSend_Info['ItemTaxType'] = $sItemTaxType ; + $aSend_Info['ItemAmount'] = $sItemAmount ; + + unset($aSend_Info['Items']) ; + + // 如果沒有填入資料,則清除該欄位,預設為當下時間 + if($aSend_Info['InvCreateDate'] == '') + { + unset($aSend_Info['InvCreateDate']) ; + } + + // 3-3產生檢查碼 + $aSend_CheckMac_Info = $aSend_Info ; + + // 過濾不需要參數項目 + unset($aSend_CheckMac_Info['ItemName']) ; + unset($aSend_CheckMac_Info['ItemWord']) ; + unset($aSend_CheckMac_Info['InvoiceRemark']) ; + + // 載具編號內包含+號則改為空白 + $aSend_CheckMac_Info['CarruerNum'] = str_replace ('+',' ',$aSend_CheckMac_Info['CarruerNum']); + + // 產生檢查碼 + $aSend_Info['CheckMacValue'] = $this->GenerateCheckMacValue($aSend_CheckMac_Info) ; + } + + // B.延遲或觸發開立發票 + if( $this->Invoice_Method == InvoiceMethod::INVOICE_DELAY ) + { + // 3-1過濾不需要的項目 + unset($aSend_Info['InvCreateDate']) ; + unset($aSend_Info['vat']) ; + unset($aSend_Info['InvoiceNo']) ; + unset($aSend_Info['AllowanceNotify']) ; + unset($aSend_Info['NotifyMail']) ; + unset($aSend_Info['NotifyPhone']) ; + unset($aSend_Info['AllowanceAmount']) ; + unset($aSend_Info['InvoiceNumber']) ; + unset($aSend_Info['Reason']) ; + unset($aSend_Info['AllowanceNo']) ; + unset($aSend_Info['Phone']) ; + unset($aSend_Info['Notify']) ; + unset($aSend_Info['InvoiceTag']) ; + unset($aSend_Info['Notified']) ; + + if(empty($aSend_Info['CustomerIdentifier'])) + { + unset($aSend_Info['CustomerIdentifier']); + } + else + { + $aSend_Info['CustomerIdentifier'] ; + } + + // 3-2商品資訊組合 + $nItems_Count_Total = count($this->Send['Items']) ; // 商品總筆數 + foreach($this->Send['Items'] as $key => $value) + { + $sItemName .= $value['ItemName'] ; + $sItemCount .= (int) $value['ItemCount'] ; + $sItemWord .= $value['ItemWord'] ; + $sItemPrice .= (int) $value['ItemPrice'] ; + $sItemTaxType .= $value['ItemTaxType'] ; + $sItemAmount .= (int) $value['ItemAmount'] ; + + if( $nItems_Foreach_Count < $nItems_Count_Total ) + { + $sItemName .= '|' ; + $sItemCount .= '|' ; + $sItemWord .= '|' ; + $sItemPrice .= '|' ; + $sItemTaxType .= '|' ; + $sItemAmount .= '|' ; + } + + $nItems_Foreach_Count++ ; + } + + $aSend_Info['ItemName'] = urlencode($sItemName); // 商品名稱 + $aSend_Info['ItemCount'] = $sItemCount ; + $aSend_Info['ItemWord'] = urlencode($sItemWord); // 商品單位 + $aSend_Info['ItemPrice'] = $sItemPrice ; + $aSend_Info['ItemTaxType'] = $sItemTaxType ; + $aSend_Info['ItemAmount'] = $sItemAmount ; + + unset($aSend_Info['Items']) ; + + + // 3-3產生檢查碼 + $aSend_CheckMac_Info = $aSend_Info ; + + // 過濾不需要參數項目 + unset($aSend_CheckMac_Info['ItemName']) ; + unset($aSend_CheckMac_Info['ItemWord']) ; + unset($aSend_CheckMac_Info['InvoiceRemark']) ; + + // 載具編號內包含+號則改為空白 + $aSend_CheckMac_Info['CarruerNum'] = str_replace ('+',' ',$aSend_CheckMac_Info['CarruerNum']); + + // 產生檢查碼 + $aSend_Info['CheckMacValue'] = $this->GenerateCheckMacValue($aSend_CheckMac_Info) ; + } + + // C.開立折讓 + if( $this->Invoice_Method == InvoiceMethod::ALLOWANCE ) + { + // 3-1過濾不需要的項目 + unset($aSend_Info['RelateNumber']) ; + unset($aSend_Info['CustomerID']) ; + unset($aSend_Info['CustomerIdentifier']) ; + unset($aSend_Info['CustomerAddr']) ; + unset($aSend_Info['CustomerPhone']) ; + unset($aSend_Info['CustomerEmail']) ; + unset($aSend_Info['ClearanceMark']) ; + unset($aSend_Info['Print']) ; + unset($aSend_Info['Donation']) ; + unset($aSend_Info['LoveCode']) ; + unset($aSend_Info['CarruerType']) ; + unset($aSend_Info['CarruerNum']) ; + unset($aSend_Info['TaxType']) ; + unset($aSend_Info['SalesAmount']) ; + unset($aSend_Info['InvoiceRemark']) ; + unset($aSend_Info['InvType']) ; + unset($aSend_Info['InvCreateDate']) ; + unset($aSend_Info['vat']) ; + unset($aSend_Info['DelayFlag']) ; + unset($aSend_Info['DelayDay']) ; + unset($aSend_Info['ECBankID']) ; + unset($aSend_Info['Tsr']) ; + unset($aSend_Info['PayType']) ; + unset($aSend_Info['PayAct']) ; + unset($aSend_Info['NotifyURL']) ; + unset($aSend_Info['InvoiceNumber']) ; + unset($aSend_Info['Reason']) ; + unset($aSend_Info['AllowanceNo']) ; + unset($aSend_Info['Phone']) ; + unset($aSend_Info['Notify']) ; + unset($aSend_Info['InvoiceTag']) ; + unset($aSend_Info['Notified']) ; + + // 3-2商品資訊組合 + $nItems_Count_Total = count($this->Send['Items']) ; // 商品總筆數 + foreach($this->Send['Items'] as $key => $value) + { + $sItemName .= $value['ItemName'] ; + $sItemCount .= (int) $value['ItemCount'] ; + $sItemWord .= $value['ItemWord'] ; + $sItemPrice .= (int) $value['ItemPrice'] ; + $sItemTaxType .= $value['ItemTaxType'] ; + $sItemAmount .= (int) $value['ItemAmount'] ; + + if( $nItems_Foreach_Count < $nItems_Count_Total ) + { + $sItemName .= '|' ; + $sItemCount .= '|' ; + $sItemWord .= '|' ; + $sItemPrice .= '|' ; + $sItemTaxType .= '|' ; + $sItemAmount .= '|' ; + } + + $nItems_Foreach_Count++ ; + } + + $aSend_Info['ItemName'] = urlencode($sItemName); // 商品名稱 + $aSend_Info['ItemCount'] = $sItemCount ; + $aSend_Info['ItemWord'] = urlencode($sItemWord); // 商品單位 + $aSend_Info['ItemPrice'] = $sItemPrice ; + $aSend_Info['ItemTaxType'] = $sItemTaxType ; + $aSend_Info['ItemAmount'] = $sItemAmount ; + + unset($aSend_Info['Items']) ; + + + // 3-3產生檢查碼 + $aSend_CheckMac_Info = $aSend_Info ; + + // 過濾不需要參數項目 + unset($aSend_CheckMac_Info['ItemName']) ; + unset($aSend_CheckMac_Info['ItemWord']) ; + + // 產生檢查碼 + $aSend_Info['CheckMacValue'] = $this->GenerateCheckMacValue($aSend_CheckMac_Info) ; + } + + // D.發票作廢 + if( $this->Invoice_Method == InvoiceMethod::INVOICE_VOID ) + { + // 3-1過濾不需要的項目 + unset($aSend_Info['RelateNumber']) ; + unset($aSend_Info['CustomerID']) ; + unset($aSend_Info['CustomerIdentifier']) ; + unset($aSend_Info['CustomerName']) ; + unset($aSend_Info['CustomerAddr']) ; + unset($aSend_Info['CustomerPhone']) ; + unset($aSend_Info['CustomerEmail']) ; + unset($aSend_Info['ClearanceMark']) ; + unset($aSend_Info['Print']) ; + unset($aSend_Info['Donation']) ; + unset($aSend_Info['LoveCode']) ; + unset($aSend_Info['CarruerType']) ; + unset($aSend_Info['CarruerNum']) ; + unset($aSend_Info['TaxType']) ; + unset($aSend_Info['SalesAmount']) ; + unset($aSend_Info['InvoiceRemark']) ; + unset($aSend_Info['ItemName']) ; + unset($aSend_Info['ItemCount']) ; + unset($aSend_Info['ItemWord']) ; + unset($aSend_Info['ItemPrice']) ; + unset($aSend_Info['ItemTaxType']) ; + unset($aSend_Info['ItemAmount']) ; + unset($aSend_Info['InvType']) ; + unset($aSend_Info['InvCreateDate']) ; + unset($aSend_Info['vat']) ; + unset($aSend_Info['DelayFlag']) ; + unset($aSend_Info['DelayDay']) ; + unset($aSend_Info['ECBankID']) ; + unset($aSend_Info['Tsr']) ; + unset($aSend_Info['PayType']) ; + unset($aSend_Info['PayAct']) ; + unset($aSend_Info['NotifyURL']) ; + unset($aSend_Info['InvoiceNo']) ; + unset($aSend_Info['AllowanceNotify']) ; + unset($aSend_Info['NotifyMail']) ; + unset($aSend_Info['NotifyPhone']) ; + unset($aSend_Info['AllowanceAmount']) ; + unset($aSend_Info['AllowanceNo']) ; + unset($aSend_Info['Phone']) ; + unset($aSend_Info['Notify']) ; + unset($aSend_Info['InvoiceTag']) ; + unset($aSend_Info['Notified']) ; + + // 3-2商品資訊組合 + unset($aSend_Info['Items']) ; + + + // 3-3產生檢查碼 + $aSend_CheckMac_Info = $aSend_Info ; + + // 過濾不需要參數項目 + unset($aSend_CheckMac_Info['Reason']) ; + + // 產生檢查碼 + $aSend_Info['CheckMacValue'] = $this->GenerateCheckMacValue($aSend_CheckMac_Info) ; + } + + // E.折讓作廢 + if( $this->Invoice_Method == InvoiceMethod::ALLOWANCE_VOID ) + { + // 3-1過濾不需要的項目 + unset($aSend_Info['RelateNumber']) ; + unset($aSend_Info['CustomerID']) ; + unset($aSend_Info['CustomerIdentifier']) ; + unset($aSend_Info['CustomerName']) ; + unset($aSend_Info['CustomerAddr']) ; + unset($aSend_Info['CustomerPhone']) ; + unset($aSend_Info['CustomerEmail']) ; + unset($aSend_Info['ClearanceMark']) ; + unset($aSend_Info['Print']) ; + unset($aSend_Info['Donation']) ; + unset($aSend_Info['LoveCode']) ; + unset($aSend_Info['CarruerType']) ; + unset($aSend_Info['CarruerNum']) ; + unset($aSend_Info['TaxType']) ; + unset($aSend_Info['SalesAmount']) ; + unset($aSend_Info['InvoiceRemark']) ; + unset($aSend_Info['ItemName']) ; + unset($aSend_Info['ItemCount']) ; + unset($aSend_Info['ItemWord']) ; + unset($aSend_Info['ItemPrice']) ; + unset($aSend_Info['ItemTaxType']) ; + unset($aSend_Info['ItemAmount']) ; + unset($aSend_Info['InvType']) ; + unset($aSend_Info['InvCreateDate']) ; + unset($aSend_Info['vat']) ; + unset($aSend_Info['DelayFlag']) ; + unset($aSend_Info['DelayDay']) ; + unset($aSend_Info['ECBankID']) ; + unset($aSend_Info['Tsr']) ; + unset($aSend_Info['PayType']) ; + unset($aSend_Info['PayAct']) ; + unset($aSend_Info['NotifyURL']) ; + unset($aSend_Info['AllowanceNotify']) ; + unset($aSend_Info['NotifyMail']) ; + unset($aSend_Info['NotifyPhone']) ; + unset($aSend_Info['AllowanceAmount']) ; + unset($aSend_Info['InvoiceNumber']) ; + unset($aSend_Info['Phone']) ; + unset($aSend_Info['Notify']) ; + unset($aSend_Info['InvoiceTag']) ; + unset($aSend_Info['Notified']) ; + + // 3-2商品資訊組合 + unset($aSend_Info['Items']) ; + + + // 3-3產生檢查碼 + $aSend_CheckMac_Info = $aSend_Info ; + + // 過濾不需要參數項目 + unset($aSend_CheckMac_Info['Reason']) ; + + // 產生檢查碼 + $aSend_Info['CheckMacValue'] = $this->GenerateCheckMacValue($aSend_CheckMac_Info) ; + } + + // F.查詢發票 G.查詢作廢發票 + if( $this->Invoice_Method == InvoiceMethod::INVOICE_SEARCH || $this->Invoice_Method == InvoiceMethod::INVOICE_VOID_SEARCH ) + { + // 3-1過濾不需要的項目 + unset($aSend_Info['CustomerID']) ; + unset($aSend_Info['CustomerIdentifier']) ; + unset($aSend_Info['CustomerName']) ; + unset($aSend_Info['CustomerAddr']) ; + unset($aSend_Info['CustomerPhone']) ; + unset($aSend_Info['CustomerEmail']) ; + unset($aSend_Info['ClearanceMark']) ; + unset($aSend_Info['Print']) ; + unset($aSend_Info['Donation']) ; + unset($aSend_Info['LoveCode']) ; + unset($aSend_Info['CarruerType']) ; + unset($aSend_Info['CarruerNum']) ; + unset($aSend_Info['TaxType']) ; + unset($aSend_Info['SalesAmount']) ; + unset($aSend_Info['InvoiceRemark']) ; + unset($aSend_Info['ItemName']) ; + unset($aSend_Info['ItemCount']) ; + unset($aSend_Info['ItemWord']) ; + unset($aSend_Info['ItemPrice']) ; + unset($aSend_Info['ItemTaxType']) ; + unset($aSend_Info['ItemAmount']) ; + unset($aSend_Info['InvType']) ; + unset($aSend_Info['InvCreateDate']) ; + unset($aSend_Info['vat']) ; + unset($aSend_Info['DelayFlag']) ; + unset($aSend_Info['DelayDay']) ; + unset($aSend_Info['ECBankID']) ; + unset($aSend_Info['Tsr']) ; + unset($aSend_Info['PayType']) ; + unset($aSend_Info['PayAct']) ; + unset($aSend_Info['NotifyURL']) ; + unset($aSend_Info['InvoiceNo']) ; + unset($aSend_Info['AllowanceNotify']) ; + unset($aSend_Info['NotifyMail']) ; + unset($aSend_Info['NotifyPhone']) ; + unset($aSend_Info['AllowanceAmount']) ; + unset($aSend_Info['InvoiceNumber']) ; + unset($aSend_Info['Reason']) ; + unset($aSend_Info['AllowanceNo']) ; + unset($aSend_Info['Phone']) ; + unset($aSend_Info['Notify']) ; + unset($aSend_Info['InvoiceTag']) ; + unset($aSend_Info['Notified']) ; + + // 3-2商品資訊組合 + unset($aSend_Info['Items']) ; + + + // 3-3產生檢查碼 + $aSend_CheckMac_Info = $aSend_Info ; + + // 過濾不需要參數項目 + unset($aSend_CheckMac_Info['Reason']) ; + + // 產生檢查碼 + $aSend_Info['CheckMacValue'] = $this->GenerateCheckMacValue($aSend_CheckMac_Info) ; + } + + // H.查詢折讓明細 I.查詢折讓作廢明細 + if( $this->Invoice_Method == InvoiceMethod::ALLOWANCE_SEARCH || $this->Invoice_Method == InvoiceMethod::ALLOWANCE_VOID_SEARCH ) + { + // 3-1過濾不需要的項目 + unset($aSend_Info['RelateNumber']) ; + unset($aSend_Info['CustomerID']) ; + unset($aSend_Info['CustomerIdentifier']) ; + unset($aSend_Info['CustomerName']) ; + unset($aSend_Info['CustomerAddr']) ; + unset($aSend_Info['CustomerPhone']) ; + unset($aSend_Info['CustomerEmail']) ; + unset($aSend_Info['ClearanceMark']) ; + unset($aSend_Info['Print']) ; + unset($aSend_Info['Donation']) ; + unset($aSend_Info['LoveCode']) ; + unset($aSend_Info['CarruerType']) ; + unset($aSend_Info['CarruerNum']) ; + unset($aSend_Info['TaxType']) ; + unset($aSend_Info['SalesAmount']) ; + unset($aSend_Info['InvoiceRemark']) ; + unset($aSend_Info['ItemName']) ; + unset($aSend_Info['ItemCount']) ; + unset($aSend_Info['ItemWord']) ; + unset($aSend_Info['ItemPrice']) ; + unset($aSend_Info['ItemTaxType']) ; + unset($aSend_Info['ItemAmount']) ; + unset($aSend_Info['InvType']) ; + unset($aSend_Info['InvCreateDate']) ; + unset($aSend_Info['vat']) ; + unset($aSend_Info['DelayFlag']) ; + unset($aSend_Info['DelayDay']) ; + unset($aSend_Info['ECBankID']) ; + unset($aSend_Info['Tsr']) ; + unset($aSend_Info['PayType']) ; + unset($aSend_Info['PayAct']) ; + unset($aSend_Info['NotifyURL']) ; + unset($aSend_Info['AllowanceNotify']) ; + unset($aSend_Info['NotifyMail']) ; + unset($aSend_Info['NotifyPhone']) ; + unset($aSend_Info['AllowanceAmount']) ; + unset($aSend_Info['InvoiceNumber']) ; + unset($aSend_Info['Reason']) ; + unset($aSend_Info['Phone']) ; + unset($aSend_Info['Notify']) ; + unset($aSend_Info['InvoiceTag']) ; + unset($aSend_Info['Notified']) ; + + // 3-2商品資訊組合 + unset($aSend_Info['Items']) ; + + // 3-3產生檢查碼 + $aSend_CheckMac_Info = $aSend_Info ; + + // 產生檢查碼 + $aSend_Info['CheckMacValue'] = $this->GenerateCheckMacValue($aSend_CheckMac_Info) ; + } + + // J.發送通知 + if( $this->Invoice_Method == InvoiceMethod::INVOICE_NOTIFY ) + { + // 3-1過濾不需要的項目 + unset($aSend_Info['RelateNumber']) ; + unset($aSend_Info['CustomerID']) ; + unset($aSend_Info['CustomerIdentifier']) ; + unset($aSend_Info['CustomerName']) ; + unset($aSend_Info['CustomerAddr']) ; + unset($aSend_Info['CustomerPhone']) ; + unset($aSend_Info['CustomerEmail']) ; + unset($aSend_Info['ClearanceMark']) ; + unset($aSend_Info['Print']) ; + unset($aSend_Info['Donation']) ; + unset($aSend_Info['LoveCode']) ; + unset($aSend_Info['CarruerType']) ; + unset($aSend_Info['CarruerNum']) ; + unset($aSend_Info['TaxType']) ; + unset($aSend_Info['SalesAmount']) ; + unset($aSend_Info['InvoiceRemark']) ; + unset($aSend_Info['ItemName']) ; + unset($aSend_Info['ItemCount']) ; + unset($aSend_Info['ItemWord']) ; + unset($aSend_Info['ItemPrice']) ; + unset($aSend_Info['ItemTaxType']) ; + unset($aSend_Info['ItemAmount']) ; + unset($aSend_Info['InvType']) ; + unset($aSend_Info['InvCreateDate']) ; + unset($aSend_Info['vat']) ; + unset($aSend_Info['DelayFlag']) ; + unset($aSend_Info['DelayDay']) ; + unset($aSend_Info['ECBankID']) ; + unset($aSend_Info['Tsr']) ; + unset($aSend_Info['PayType']) ; + unset($aSend_Info['PayAct']) ; + unset($aSend_Info['NotifyURL']) ; + unset($aSend_Info['AllowanceNotify']) ; + unset($aSend_Info['NotifyPhone']) ; + unset($aSend_Info['AllowanceAmount']) ; + unset($aSend_Info['InvoiceNumber']) ; + unset($aSend_Info['Reason']) ; + + // 3-2商品資訊組合 + unset($aSend_Info['Items']) ; + + // 3-3產生檢查碼 + $aSend_CheckMac_Info = $aSend_Info ; + + // 產生檢查碼 + $aSend_Info['CheckMacValue'] = $this->GenerateCheckMacValue($aSend_CheckMac_Info) ; + } + + // K.查詢折讓明細 + if( $this->Invoice_Method == InvoiceMethod::INVOICE_TRIGGER ) + { + // 3-1過濾不需要的項目 + unset($aSend_Info['RelateNumber']) ; + unset($aSend_Info['CustomerID']) ; + unset($aSend_Info['CustomerIdentifier']) ; + unset($aSend_Info['CustomerName']) ; + unset($aSend_Info['CustomerAddr']) ; + unset($aSend_Info['CustomerPhone']) ; + unset($aSend_Info['CustomerEmail']) ; + unset($aSend_Info['ClearanceMark']) ; + unset($aSend_Info['Print']) ; + unset($aSend_Info['Donation']) ; + unset($aSend_Info['LoveCode']) ; + unset($aSend_Info['CarruerType']) ; + unset($aSend_Info['CarruerNum']) ; + unset($aSend_Info['TaxType']) ; + unset($aSend_Info['SalesAmount']) ; + unset($aSend_Info['InvoiceRemark']) ; + unset($aSend_Info['ItemName']) ; + unset($aSend_Info['ItemCount']) ; + unset($aSend_Info['ItemWord']) ; + unset($aSend_Info['ItemPrice']) ; + unset($aSend_Info['ItemTaxType']) ; + unset($aSend_Info['ItemAmount']) ; + unset($aSend_Info['InvType']) ; + unset($aSend_Info['InvCreateDate']) ; + unset($aSend_Info['vat']) ; + unset($aSend_Info['DelayFlag']) ; + unset($aSend_Info['DelayDay']) ; + unset($aSend_Info['ECBankID']) ; + unset($aSend_Info['PayAct']) ; + unset($aSend_Info['NotifyURL']) ; + unset($aSend_Info['InvoiceNo']) ; + unset($aSend_Info['AllowanceNotify']) ; + unset($aSend_Info['NotifyMail']) ; + unset($aSend_Info['NotifyPhone']) ; + unset($aSend_Info['AllowanceAmount']) ; + unset($aSend_Info['InvoiceNumber']) ; + unset($aSend_Info['Reason']) ; + unset($aSend_Info['AllowanceNo']) ; + unset($aSend_Info['Phone']) ; + unset($aSend_Info['Notify']) ; + unset($aSend_Info['InvoiceTag']) ; + unset($aSend_Info['Notified']) ; + + // 3-2商品資訊組合 + unset($aSend_Info['Items']) ; + + // 3-3產生檢查碼 + $aSend_CheckMac_Info = $aSend_Info ; + + // 產生檢查碼 + $aSend_Info['CheckMacValue'] = $this->GenerateCheckMacValue($aSend_CheckMac_Info) ; + + + } + + // 4.送出資訊 + if(true) + { + $aReturn_Info = $this->ServerPost($aSend_Info); + } + + // 5.狀態回傳驗證 + if(true) + { + // A. B. C. D. E. + if( $this->Invoice_Method == InvoiceMethod::INVOICE || $this->Invoice_Method == InvoiceMethod::INVOICE_DELAY || $this->Invoice_Method == InvoiceMethod::ALLOWANCE || $this->Invoice_Method == InvoiceMethod::INVOICE_VOID || $this->Invoice_Method == InvoiceMethod::ALLOWANCE_VOID) + { + // 5-1 CheckMac檢查 + if(count($aReturn_Info) > 0 && isset($aReturn_Info['CheckMacValue'])) + { + $aReturn_CheckMacValue = $aReturn_Info ; + $sReturn_CheckMacValue = $aReturn_Info['CheckMacValue'] ; + unset($aReturn_CheckMacValue['CheckMacValue']) ; + + $sCheckMacValueGen = $this->GenerateCheckMacValue($aReturn_CheckMacValue) ; + + if($sCheckMacValueGen != $sReturn_CheckMacValue ) + { + array_push($arErrors, '1000001 CheckMacValue verify fail.'); + } + } + else + { + // 傳出參數錯誤,查無資料 + array_push($arErrors, 'Error:10100050'); + } + } + + // F.查詢發票 + if( $this->Invoice_Method == InvoiceMethod::INVOICE_SEARCH ) + { + // 5-1 CheckMac檢查 + if(count($aReturn_Info) > 0 && isset($aReturn_Info['CheckMacValue'])) + { + $aReturn_CheckMacValue = $aReturn_Info ; + $sReturn_CheckMacValue = $aReturn_Info['CheckMacValue'] ; + + unset($aReturn_CheckMacValue['CheckMacValue']) ; + unset($aReturn_CheckMacValue['ItemName']) ; + unset($aReturn_CheckMacValue['ItemWord']) ; + unset($aReturn_CheckMacValue['InvoiceRemark']) ; + + if($aReturn_Info['RtnCode'] == 1) + { + $aReturn_CheckMacValue['IIS_Customer_Name'] = $this->Replace_Symbol(urlencode($aReturn_CheckMacValue['IIS_Customer_Name'])); + $aReturn_CheckMacValue['IIS_Customer_Addr'] = $this->Replace_Symbol(urlencode($aReturn_CheckMacValue['IIS_Customer_Addr'])); + $aReturn_CheckMacValue['IIS_Customer_Email'] = $this->Replace_Symbol(urlencode($aReturn_CheckMacValue['IIS_Customer_Email'])); + + // EMIAL項目的@不做urlencode還原回來 + $aReturn_CheckMacValue['IIS_Customer_Email'] = str_replace('%40', '@', $aReturn_CheckMacValue['IIS_Customer_Email']); + } + + $sCheckMacValueGen = $this->GenerateCheckMacValue($aReturn_CheckMacValue) ; + + if($sCheckMacValueGen != $sReturn_CheckMacValue ) + { + array_push($arErrors, '1000001 CheckMacValue verify fail.'); + } + } + else + { + // 傳出參數錯誤,查無資料 + array_push($arErrors, 'Error:10100050'); + } + } + + // G.查詢作廢發票 + if( $this->Invoice_Method == InvoiceMethod::INVOICE_VOID_SEARCH ) + { + // 5-1 CheckMac檢查 + if(count($aReturn_Info) > 0 && isset($aReturn_Info['CheckMacValue'])) + { + $aReturn_CheckMacValue = $aReturn_Info ; + $sReturn_CheckMacValue = $aReturn_Info['CheckMacValue'] ; + + unset($aReturn_CheckMacValue['CheckMacValue']) ; + unset($aReturn_CheckMacValue['Reason']) ; + + $sCheckMacValueGen = $this->GenerateCheckMacValue($aReturn_CheckMacValue) ; + if($sCheckMacValueGen != $sReturn_CheckMacValue ) + { + array_push($arErrors, '1000001 CheckMacValue verify fail.'); + } + } + else + { + // 傳出參數錯誤,查無資料 + array_push($arErrors, 'Error:10100050'); + } + } + + // H.查詢折讓明細 + if( $this->Invoice_Method == InvoiceMethod::ALLOWANCE_SEARCH ) + { + + // 5-1 CheckMac檢查 + if(count($aReturn_Info) > 0 && isset($aReturn_Info['CheckMacValue'])) + { + $aReturn_CheckMacValue = $aReturn_Info ; + $sReturn_CheckMacValue = $aReturn_Info['CheckMacValue'] ; + + unset($aReturn_CheckMacValue['CheckMacValue']) ; + unset($aReturn_CheckMacValue['ItemName']) ; + unset($aReturn_CheckMacValue['ItemWord']) ; + + $aReturn_CheckMacValue['IIS_Customer_Name'] = $this->Replace_Symbol(urlencode($aReturn_CheckMacValue['IIS_Customer_Name'])) ; + + $sCheckMacValueGen = $this->GenerateCheckMacValue($aReturn_CheckMacValue) ; + if($sCheckMacValueGen != $sReturn_CheckMacValue ) + { + array_push($arErrors, '1000001 CheckMacValue verify fail.'); + } + } + else + { + // 傳出參數錯誤,查無資料 + array_push($arErrors, 'Error:10100050'); + } + } + + // I.查詢折讓作廢明細 + if( $this->Invoice_Method == InvoiceMethod::ALLOWANCE_VOID_SEARCH ) + { + // 5-1 CheckMac檢查 + if(count($aReturn_Info) > 0 && isset($aReturn_Info['CheckMacValue'])) + { + $aReturn_CheckMacValue = $aReturn_Info ; + $sReturn_CheckMacValue = $aReturn_Info['CheckMacValue'] ; + + unset($aReturn_CheckMacValue['CheckMacValue']) ; + unset($aReturn_CheckMacValue['Reason']) ; + + $sCheckMacValueGen = $this->GenerateCheckMacValue($aReturn_CheckMacValue) ; + if($sCheckMacValueGen != $sReturn_CheckMacValue ) + { + array_push($arErrors, '1000001 CheckMacValue verify fail.'); + } + } + else + { + // 傳出參數錯誤,查無資料 + array_push($arErrors, 'Error:10100050'); + } + } + + // J.發送通知 + if( $this->Invoice_Method == InvoiceMethod::INVOICE_NOTIFY ) + { + // 5-1 CheckMac檢查 + if(count($aReturn_Info) > 0 && isset($aReturn_Info['CheckMacValue'])) + { + $aReturn_CheckMacValue = $aReturn_Info ; + $sReturn_CheckMacValue = $aReturn_Info['CheckMacValue'] ; + + unset($aReturn_CheckMacValue['CheckMacValue']) ; + + $sCheckMacValueGen = $this->GenerateCheckMacValue($aReturn_CheckMacValue) ; + if($sCheckMacValueGen != $sReturn_CheckMacValue ) + { + array_push($arErrors, '1000001 CheckMacValue verify fail.'); + } + } + else + { + // 傳出參數錯誤,查無資料 + array_push($arErrors, 'Error:10100050'); + } + } + + // K.付款完成觸發或延遲開立發票 + if( $this->Invoice_Method == InvoiceMethod::INVOICE_TRIGGER ) + { + // 5-1 CheckMac檢查 + if(count($aReturn_Info) > 0 && isset($aReturn_Info['CheckMacValue'])) + { + $aReturn_CheckMacValue = $aReturn_Info ; + $sReturn_CheckMacValue = $aReturn_Info['CheckMacValue'] ; + + unset($aReturn_CheckMacValue['CheckMacValue']) ; + + $sCheckMacValueGen = $this->GenerateCheckMacValue($aReturn_CheckMacValue) ; + if($sCheckMacValueGen != $sReturn_CheckMacValue ) + { + array_push($arErrors, '1000001 CheckMacValue verify fail.'); + } + } + else + { + // 傳出參數錯誤,查無資料 + array_push($arErrors, 'Error:10100050'); + } + } + + return (count($arErrors) > 0) ? $arErrors : $aReturn_Info ; + } + } + + exit; + } + + /** + * 檢查各個參數是否符合規格 + */ + function Check_String() + { + $arErrors = array(); + + // 檢查是否傳入動作方式 + if($this->Invoice_Method == '' || $this->Invoice_Method == 'Invoice_Method') + { + array_push($arErrors, 'Invoice_Method is required.'); + } + + // 檢查是否有傳入MerchantID + if(strlen($this->MerchantID) == 0) + { + array_push($arErrors, 'MerchantID is required.'); + } + if(strlen($this->MerchantID) > 10) + { + array_push($arErrors, 'MerchantID max langth as 10.'); + } + + // 檢查是否有傳入HashKey + if(strlen($this->HashKey) == 0) + { + array_push($arErrors, 'HashKey is required.'); + } + + // 檢查是否有傳入HashIV + if(strlen($this->HashIV) == 0) + { + array_push($arErrors, 'HashIV is required.'); + } + + // 檢查是否有傳送網址 + if(strlen($this->Invoice_Url) == 0) + { + array_push($arErrors, 'Invoice_Url is required.'); + } + + // 檢查 A.一般開立發票、B.延遲觸發開立發票、F.查詢發票、G.查詢作廢發票 + if( $this->Invoice_Method == InvoiceMethod::INVOICE || $this->Invoice_Method == InvoiceMethod::INVOICE_DELAY || $this->Invoice_Method == InvoiceMethod::INVOICE_SEARCH || $this->Invoice_Method == InvoiceMethod::INVOICE_VOID_SEARCH) + { + // 4.廠商自訂編號 + + // *預設不可為空值 + if(strlen($this->Send['RelateNumber']) == 0) + { + array_push($arErrors, '4:RelateNumber is required.'); + } + // *預設最大長度為30碼 + if(strlen($this->Send['RelateNumber']) > 30) + { + array_push($arErrors, '4:RelateNumber max langth as 30.'); + } + } + + // 檢查 A.一般開立發票、B.延遲觸發開立發票 + if( $this->Invoice_Method == InvoiceMethod::INVOICE || $this->Invoice_Method == InvoiceMethod::INVOICE_DELAY ) + { + // 5.客戶代號 CustomerID + + // *載具類別為1 則客戶代號需有值 + if($this->Send['CarruerType'] == 1) + { + if(strlen($this->Send['CustomerID']) == 0 ) + { + array_push($arErrors, '5:CustomerID is required.'); + } + } + // *預設最大長度為20碼 + if(strlen($this->Send['CustomerID']) > 20 ) + { + array_push($arErrors, '5:CustomerID max langth as 20.'); + } + // *比對客戶代號 只接受英、數字與下底線格式 + if(strlen($this->Send['CustomerID']) > 0) + { + + if( !preg_match('/^[a-zA-Z0-9_]+$/', $this->Send['CustomerID']) ) + { + arRay_push($arErrors, '5:Invalid CustomerID.'); + } + } + + // 6.統一編號判斷 CustomerIdentifier + + // *若統一編號有值時,則固定長度為數字8碼 + if( strlen( $this->Send['CustomerIdentifier'] ) > 0 ) + { + if( !preg_match('/^[0-9]{8}$/', $this->Send['CustomerIdentifier']) ) + { + + array_push($arErrors, '6:CustomerIdentifier length should be 8.'); + } + } + } + + // 檢查 C.開立折讓 + if( $this->Invoice_Method == InvoiceMethod::ALLOWANCE ) + { + // 7.客戶名稱 CustomerName + // x僅能為中英數字格式 + // *預設最大長度為30碼 + if( mb_strlen($this->Send['CustomerName'], 'UTF-8') > 30) + { + array_push($arErrors, '7:CustomerName max length as 30.'); + } + // *UrlEncode + $this->Send['CustomerName'] = urlencode($this->Send['CustomerName']); + $this->Send['CustomerName'] = $this->Replace_Symbol($this->Send['CustomerName']) ; + } + + // 檢查 A.一般開立發票、B.延遲觸發開立發票 + if( $this->Invoice_Method == InvoiceMethod::INVOICE || $this->Invoice_Method == InvoiceMethod::INVOICE_DELAY ) + { + // 7.客戶名稱 CustomerName + // x僅能為中英數字格式 + // *若列印註記 = '1' (列印)時,則客戶名稱須有值 + if ($this->Send['Print'] == PrintMark::Yes) + { + if (mb_strlen($this->Send['CustomerName'], 'UTF-8') == 0) + { + array_push($arErrors, "7:CustomerName is required."); + } + } + // *預設最大長度為30碼 + if( mb_strlen($this->Send['CustomerName'], 'UTF-8') > 30) + { + array_push($arErrors, '7:CustomerName max length as 30.'); + } + // *UrlEncode + $this->Send['CustomerName'] = urlencode($this->Send['CustomerName']); + $this->Send['CustomerName'] = $this->Replace_Symbol($this->Send['CustomerName']) ; + + // 8.客戶地址 CustomerAddr(UrlEncode, 預設為空字串) + + // *若列印註記 = '1' (列印)時,則客戶地址須有值 + if ($this->Send['Print'] == PrintMark::Yes) + { + if (mb_strlen($this->Send['CustomerAddr'], 'UTF-8') == 0) + { + array_push($arErrors, "8:CustomerAddr is required."); + } + } + // *預設最大長度為100碼 + if (mb_strlen($this->Send['CustomerAddr'], 'UTF-8') > 100) + { + array_push($arErrors, "8:CustomerAddr max length as 100."); + } + // *UrlEncode + $this->Send['CustomerAddr'] = urlencode($this->Send['CustomerAddr']); + $this->Send['CustomerAddr'] = $this->Replace_Symbol($this->Send['CustomerAddr']) ; + + // 9.客戶手機號碼 CustomerPhone + + // *預設最小長度為1碼,最大長度為20碼 + if (strlen($this->Send['CustomerPhone']) > 20) + { + array_push($arErrors, "9:CustomerPhone max length as 20."); + } + // *預設格式為數字組成 + if (strlen($this->Send['CustomerPhone']) > 0) + { + if( !preg_match('/^[0-9]*$/', $this->Send['CustomerPhone']) ) + { + array_push($arErrors, '9:Invalid CustomerPhone.'); + } + } + + // 10.客戶電子信箱 CustomerEmail(UrlEncode, 預設為空字串, 與CustomerPhone擇一不可為空) + + // *預設最大長度為80碼 + if (strlen($this->Send['CustomerEmail']) > 80) + { + array_push($arErrors, "10:CustomerEmail max length as 80."); + } + // *若客戶電子信箱有值時,則格式僅能為Email的標準格式 + if(strlen($this->Send['CustomerEmail']) > 0 ) + { + if ( !preg_match('/^[a-z0-9&\'\.\-_\+]+@[a-z0-9\-_]+\.([a-z0-9\-_]+\.)*?[a-z]+$/is', $this->Send['CustomerEmail']) ) + { + array_push($arErrors, '10:Invalid CustomerEmail Format.'); + } + } + // *UrlEncode + $this->Send['CustomerEmail'] = urlencode($this->Send['CustomerEmail']); + $this->Send['CustomerEmail'] = $this->Replace_Symbol($this->Send['CustomerEmail']) ; + + // 9. 10. + + // *若客戶手機號碼為空值時,則客戶電子信箱不可為空值 + if (strlen($this->Send['CustomerPhone']) == 0 && strlen($this->Send['CustomerEmail']) == 0) + { + array_push($arErrors, "9-10:CustomerPhone or CustomerEmail is required."); + } + + // 11.通關方式 ClearanceMark(預設為空字串) + + // *最多1字元 + if (strlen($this->Send['ClearanceMark']) > 1) + { + array_push($arErrors, "11:ClearanceMark max length as 1."); + } + + // *請設定空字串,僅課稅類別為零稅率(Zero)時,此參數不可為空字串 + if ($this->Send['TaxType'] == TaxType::Zero) + { + if ( ( $this->Send['ClearanceMark'] != ClearanceMark::Yes ) && ( $this->Send['ClearanceMark'] != ClearanceMark::No ) ) + { + array_push($arErrors, "11:ClearanceMark is required."); + } + } + else + { + if (strlen($this->Send['ClearanceMark']) > 0) + { + array_push($arErrors, "11:Please remove ClearanceMark."); + } + } + + // 12.列印註記 Print(預設為No) + + // *列印註記僅能為 0 或 1 + if ( ( $this->Send['Print'] != PrintMark::Yes ) && ( $this->Send['Print'] != PrintMark::No ) ) + { + array_push($arErrors, "12:Invalid Print."); + } + // *若捐贈註記 = '1' (捐贈)時,則VAL = '0' (不列印) + if ($this->Send['Donation'] == Donation::Yes) + { + if ($this->Send['Print'] != PrintMark::No) + { + array_push($arErrors, "12:Donation Print should be No."); + } + } + // *若統一編號有值時,則VAL = '1' (列印) + if (strlen($this->Send['CustomerIdentifier']) > 0) + { + if ($this->Send['Print'] != PrintMark::Yes) + { + array_push($arErrors, "12:CustomerIdentifier Print should be Yes."); + } + } + + // 13.捐贈註記 Donation + + // *固定給定下述預設值若為捐贈時,則VAL = '1',若為不捐贈時,則VAL = '2' + if ( ($this->Send['Donation'] != Donation::Yes ) && ( $this->Send['Donation'] != Donation::No ) ) + { + array_push($arErrors, "13:Invalid Donation."); + } + // *若統一編號有值時,則VAL = '2' (不捐贈) + if (strlen($this->Send['CustomerIdentifier']) > 0 && $this->Send['Donation'] == Donation::Yes ) + { + array_push($arErrors, "13:CustomerIdentifier Donation should be No."); + } + + + // 14.愛心碼 LoveCode(預設為空字串) + + // *若捐贈註記 = '1' (捐贈)時,則須有值 + if ($this->Send['Donation'] == Donation::Yes) + { + if ( !preg_match('/^([xX]{1}[0-9]{2,6}|[0-9]{3,7})$/', $this->Send['LoveCode']) ) + { + array_push($arErrors, "14:Invalid LoveCode."); + } + } + else + { + if (strlen($this->Send['LoveCode']) > 0) + { + array_push($arErrors, "14:Please remove LoveCode."); + } + } + + // 15.載具類別 CarruerType(預設為None) + + // *固定給定下述預設值None、Member、Cellphone + if ( ( $this->Send['CarruerType'] != CarruerType::None ) && ( $this->Send['CarruerType'] != CarruerType::Member ) && ( $this->Send['CarruerType'] != CarruerType::Citizen ) && ( $this->Send['CarruerType'] != CarruerType::Cellphone ) ) + { + array_push($arErrors, "15:Invalid CarruerType."); + } + else + { + // *統一編號不為空字串時,則載具類別不可為會載具或自然人憑證載具 + if (strlen($this->Send['CustomerIdentifier']) > 0) + { + if ($this->Send['CarruerType'] == CarruerType::Member || $this->Send['CarruerType'] == CarruerType::Citizen ) + { + array_push($arErrors, "15:Invalid CarruerType."); + } + } + } + + // 16.載具編號 CarruerNum(預設為空字串) + switch ($this->Send['CarruerType']) + { + // *載具類別為無載具(None)或會員載具(Member)時,請設定空字串 + case CarruerType::None: + case CarruerType::Member: + if (strlen($this->Send['CarruerNum']) > 0) + { + array_push($arErrors, "16:Please remove CarruerNum."); + } + break; + + // *載具類別為買受人自然人憑證(Citizen)時,請設定自然人憑證號碼,前2碼為大小寫英文,後14碼為數字 + case CarruerType::Citizen: + if ( !preg_match('/^[a-zA-Z]{2}\d{14}$/', $this->Send['CarruerNum']) ) + { + array_push($arErrors, "16:Invalid CarruerNum."); + } + break; + + // *載具類別為買受人手機條碼(Cellphone)時,請設定手機條碼,第1碼為「/」,後7碼為大小寫英文、數字、「+」、「-」或「.」 + case CarruerType::Cellphone: + if ( !preg_match('/^\/{1}[0-9a-zA-Z+-.]{7}$/', $this->Send['CarruerNum']) ) + { + array_push($arErrors, "16:Invalid CarruerNum."); + } + break; + default: + array_push($arErrors, "16:Please remove CarruerNum."); + } + + // 17.課稅類別 TaxType(不可為空) + + // *不可為空 + if (strlen($this->Send['TaxType']) == 0) + { + array_push($arErrors, "17:TaxType is required."); + } + // *僅能為 1應稅 2零稅率 3免稅 9.應稅與免稅混合 + if ( ( $this->Send['TaxType'] != TaxType::Dutiable ) && ( $this->Send['TaxType'] != TaxType::Zero ) && ( $this->Send['TaxType'] != TaxType::Free ) && ( $this->Send['TaxType'] != TaxType::Mix ) ) + { + array_push($arErrors, "17:Invalid TaxType."); + } + + + // 18.發票金額 SalesAmount + + // *不可為空 + if (strlen($this->Send['SalesAmount']) == 0) + { + array_push($arErrors, "18:SalesAmount is required."); + } + + // 19.備註 InvoiceRemark + + // *請將參數值做UrlEncode + if (strlen($this->Send['InvoiceRemark']) != 0) + { + // *UrlEncode + $this->Send['InvoiceRemark'] = urlencode($this->Send['InvoiceRemark']); + $this->Send['InvoiceRemark'] = $this->Replace_Symbol($this->Send['InvoiceRemark']) ; + } + } + + // 檢查 A.一般開立發票、B.延遲觸發開立發票、C.開立折讓 + if( $this->Invoice_Method == InvoiceMethod::INVOICE || $this->Invoice_Method == InvoiceMethod::INVOICE_DELAY || $this->Invoice_Method == InvoiceMethod::ALLOWANCE ) + { + // 20.21.22.23.24.25. 商品資訊 + + // *不可為空 + if (sizeof($this->Send['Items']) == 0) + { + array_push($arErrors, '20-25:Items is required.'); + } + else + { + // 檢查是否存在保留字元 '|' + $bFind_Tag = true; + $bError_Tag = false; + + foreach($this->Send['Items'] as $key => $value) + { + $bFind_Tag = strpos($value['ItemName'], '|') ; + if($bFind_Tag != false || empty($value['ItemName'])) + { + $bError_Tag = true ; + array_push($arErrors, '20-25:Invalid ItemName.'); + break; + } + + $bFind_Tag = strpos($value['ItemCount'], '|') ; + if($bFind_Tag != false || empty($value['ItemCount'])) + { + $bError_Tag = true ; + array_push($arErrors, '20-25:Invalid ItemCount.'); + break; + } + + $bFind_Tag = strpos($value['ItemWord'], '|') ; + if($bFind_Tag != false || empty($value['ItemWord'])) + { + $bError_Tag = true ; + array_push($arErrors, '20-25:Invalid ItemWord.'); + break; + } + + $bFind_Tag = strpos($value['ItemPrice'], '|') ; + if($bFind_Tag != false || empty($value['ItemPrice'])) + { + $bError_Tag = true ; + array_push($arErrors, '20-25:Invalid ItemPrice.'); + break; + } + + $bFind_Tag = strpos($value['ItemTaxType'], '|') ; + if($bFind_Tag != false || empty($value['ItemTaxType'])) + { + $bError_Tag = true ; + array_push($arErrors, '20-25:Invalid ItemTaxType.'); + break; + } + + $bFind_Tag = strpos($value['ItemAmount'], '|') ; + if($bFind_Tag != false || empty($value['ItemAmount'])) + { + $bError_Tag = true ; + array_push($arErrors, '20-25:Invalid ItemAmount.'); + break; + } + } + + // 檢查商品格式 + if(!$bError_Tag) + { + foreach($this->Send['Items'] as $key => $value) + { + // *ItemCount數字判斷 + if ( !preg_match('/^[0-9]*$/', $value['ItemCount']) ) + { + array_push($arErrors, '20-25:Invalid ItemCount.'); + } + + // *ItemWord 預設最大長度為6碼 + if (strlen($value['ItemWord']) > 6 ) + { + array_push($arErrors, '20-25:ItemWord max length as 6.'); + } + + // *ItemPrice數字判斷 + if ( !preg_match('/^[0-9]*$/', $value['ItemPrice']) ) + { + array_push($arErrors, '20-25:Invalid ItemPrice.'); + } + + // *ItemAmount數字判斷 + if ( !preg_match('/^[0-9]*$/', $value['ItemAmount']) ) + { + array_push($arErrors, '20-25:Invalid ItemAmount.'); + } + } + } + } + } + + // 檢查 A.一般開立發票、B.延遲觸發開立發票 + if( $this->Invoice_Method == InvoiceMethod::INVOICE || $this->Invoice_Method == InvoiceMethod::INVOICE_DELAY ) + { + // 27.字軌類別 + + // *InvType(不可為空) 僅能為 07 或 08 狀態 + if( ( $this->Send['InvType'] != InvType::General ) && ( $this->Send['InvType'] != InvType::Special ) ) + { + array_push($arErrors, "27:Invalid InvType."); + } + } + + // 檢查 A.一般開立發票 + if( $this->Invoice_Method == InvoiceMethod::INVOICE ) + { + // 28.發票開立時間 + + // *UrlEncode + $this->Send['InvCreateDate'] = urlencode($this->Send['InvCreateDate']); + $this->Send['InvCreateDate'] = $this->Replace_Symbol($this->Send['InvCreateDate']) ; + + // 29.商品單價是否含稅(預設為含稅價) + + // *固定給定下述預設值 若為含稅價,則VAL = '1' + if(!empty($this->Send['vat'])) + { + if( ( $this->Send['vat'] != VatType::Yes ) && ( $this->Send['vat'] != VatType::No ) ) + { + array_push($arErrors, "29:Invalid VatType."); + } + } + } + + + // 檢查 B.延遲觸發開立發票 + if( $this->Invoice_Method == InvoiceMethod::INVOICE_DELAY ) + { + // 30.延遲註記 DelayFlag + if( ( $this->Send['DelayFlag'] != DelayFlagType::Delay ) && ( $this->Send['DelayFlag'] != DelayFlagType::Trigger ) ) + { + array_push($arErrors, "30:Invalid DelayFlagType."); + } + + // 31.延遲天數 DelayDay + // 延遲天數,範圍0~15,設定為0時,付款完成後立即開立發票 + + // *DelayDay(不可為空, 預設為0) + $this->Send['DelayDay'] = (int)$this->Send['DelayDay']; + // *若為延遲開立時,延遲天數須介於1至15天內 + if ( $this->Send['DelayFlag'] == DelayFlagType::Delay ) + { + if ($this->Send['DelayDay'] < 1 || $this->Send['DelayDay'] > 15) + { + array_push($arErrors, "31:DelayDay should be 1 ~ 15."); + } + } + // *若為觸發開立時,延遲天數須介於0至15天內 + if ($this->Send['DelayFlag'] == DelayFlagType::Trigger) + { + if ($this->Send['DelayDay'] < 0 || $this->Send['DelayDay'] > 15) + { + array_push($arErrors, "31:DelayDay should be 0 ~ 15."); + } + } + } + + // 檢查 B.延遲觸發開立發票、K.付款完成觸發或延遲開立發票 + if( $this->Invoice_Method == InvoiceMethod::INVOICE_DELAY || $this->Invoice_Method == InvoiceMethod::INVOICE_TRIGGER) + { + // 33.交易單號 Tsr + + // *必填項目 + if(strlen($this->Send['Tsr']) == 0 ) + { + array_push($arErrors, '33:Tsr is required.'); + } + + // *判斷最大字元是否超過30字 + if (strlen($this->Send['Tsr']) > 30) + { + array_push($arErrors, '33:Tsr max length as 30.'); + } + + // 34.交易類別 PayType + + // *僅允許 1.ECBANK 2.ECPAY 3.ALLPAY + if( ( $this->Send['PayType'] != PayTypeCategory::Ecbank ) && ( $this->Send['PayType'] != PayTypeCategory::Ecpay ) && ( $this->Send['PayType'] != PayTypeCategory::Allpay ) ) + { + array_push($arErrors, "34:Invalid PayType."); + } + } + + // 檢查 B.延遲觸發開立發票 + if( $this->Invoice_Method == InvoiceMethod::INVOICE_DELAY ) + { + // 35.交易類別名稱 PayAct + + // *固定給定下述預設值 + switch ($this->Send['PayType']) + { + // *若交易類別='1'時,則VAL = 'ECBANK' + case PayTypeCategory::Ecbank: + $this->Send['PayAct'] = 'ECBANK' ; + break; + + // *若交易類別='2'時,則VAL = 'ECPAY' + case PayTypeCategory::Ecpay: + $this->Send['PayAct'] = 'ECPAY' ; + break; + + // *若交易類別='3'時,則VAL = 'ALLPAY' + case PayTypeCategory::Allpay: + $this->Send['PayAct'] = 'ALLPAY' ; + break; + + default: + $this->Send['PayAct'] = '' ; + } + + // *必填項目 交易類別名稱預設不能為空值 + if(strlen($this->Send['PayAct']) == 0 ) + { + array_push($arErrors, '35:PayAct is required.'); + } + } + + // 檢查 C.開立折讓、E.折讓作廢、H.查詢折讓明細、I.查詢折讓作廢明細、J.發送通知 + if( $this->Invoice_Method == InvoiceMethod::ALLOWANCE || $this->Invoice_Method == InvoiceMethod::ALLOWANCE_VOID || $this->Invoice_Method == InvoiceMethod::ALLOWANCE_SEARCH || $this->Invoice_Method == InvoiceMethod::ALLOWANCE_VOID_SEARCH || $this->Invoice_Method == InvoiceMethod::INVOICE_NOTIFY ) + { + // 37.發票號碼 InvoiceNo + + // *必填項目 + if(strlen($this->Send['InvoiceNo']) == 0 ) + { + array_push($arErrors, '37:InvoiceNo is required.'); + } + // *預設長度固定10碼 + if (strlen($this->Send['InvoiceNo']) != 10) + { + array_push($arErrors, '37:InvoiceNo length as 10.'); + } + } + + // 檢查 C.開立折讓 + if( $this->Invoice_Method == InvoiceMethod::ALLOWANCE ) + { + // 38.通知類別 AllowanceNotify + + // *固定給定下述預設值 + if( ( $this->Send['AllowanceNotify'] != AllowanceNotifyType::Sms ) && ( $this->Send['AllowanceNotify'] != AllowanceNotifyType::Email ) && ( $this->Send['AllowanceNotify'] != AllowanceNotifyType::All ) && ( $this->Send['AllowanceNotify'] != AllowanceNotifyType::None ) ) + { + array_push($arErrors, "38:Invalid AllowanceNotifyType."); + } + + // 39.通知電子信箱 NotifyMail + + // *若客戶電子信箱有值時,則格式僅能為Email的標準格式 + if(strlen($this->Send['NotifyMail']) > 0 ) + { + if ( !preg_match('/^[a-z0-9&\'\.\-_\+]+@[a-z0-9\-_]+\.([a-z0-9\-_]+\.)*?[a-z]+$/is', $this->Send['NotifyMail'] ) ) + { + array_push($arErrors, '39:Invalid Email Format.'); + } + } + // *下述情況通知電子信箱不可為空值(通知類別為E-電子郵件) + if($this->Send['AllowanceNotify'] == AllowanceNotifyType::Email && strlen($this->Send['NotifyMail']) == 0 ) + { + array_push($arErrors, "39:NotifyMail is required."); + } + // *UrlEncode + $this->Send['NotifyMail'] = urlencode($this->Send['NotifyMail']); + $this->Send['NotifyMail'] = $this->Replace_Symbol($this->Send['NotifyMail']) ; + + // 40.通知手機號碼 NotifyPhone + + // *若客戶手機號碼有值時,則預設格式為數字組成 + if(strlen($this->Send['NotifyPhone']) > 0 ) + { + if ( !preg_match('/^[0-9]*$/', $this->Send['NotifyPhone']) ) + { + array_push($arErrors, '40:Invalid NotifyPhone.'); + } + } + // * 最大20字元 + if (strlen($this->Send['NotifyPhone']) > 20) + { + array_push($arErrors, '40:NotifyPhone max length as 20.'); + } + // *下述情況通知手機號碼不可為空值(通知類別為S-簡訊) + if( $this->Send['AllowanceNotify'] == AllowanceNotifyType::Sms && strlen($this->Send['NotifyPhone']) == 0 ) + { + array_push($arErrors, "40:NotifyPhone is required."); + } + + // 39-40 通知電子信箱、通知手機號碼不能全為空值 (如果狀態為SMS 或 EMAIL) + if(strlen($this->Send['NotifyPhone']) == 0 && strlen($this->Send['NotifyMail']) == 0 && ( $this->Send['AllowanceNotify'] == AllowanceNotifyType::Sms || $this->Send['AllowanceNotify'] == AllowanceNotifyType::Email ) ) + { + array_push($arErrors, "39-40:NotifyMail or NotifyPhone is required."); + } + else + { + // *下述情況通知手機號碼與電子信箱不可為空值(通知類別為A-皆通知) + if( $this->Send['AllowanceNotify'] == AllowanceNotifyType::All && ( strlen($this->Send['NotifyMail']) == 0 || strlen($this->Send['NotifyPhone']) == 0 ) ) + { + array_push($arErrors, "39-40:NotifyMail And NotifyPhone is required."); + } + + // *下述情況通知手機號碼與電子信箱為空值(通知類別為N-皆不通知) + if($this->Send['AllowanceNotify'] == AllowanceNotifyType::None && ( strlen($this->Send['NotifyMail']) > 0 || strlen($this->Send['NotifyPhone']) > 0 )) + { + array_push($arErrors, "39-40:Please remove NotifyMail And NotifyPhone."); + } + } + + + + // 41.折讓單總金額 AllowanceAmount + + // *必填項目 + if(strlen($this->Send['AllowanceAmount']) == 0) + { + array_push($arErrors, "41:AllowanceAmount is required."); + } + else + { + // *含稅總金額 + $this->Send['AllowanceAmount'] = (int) $this->Send['AllowanceAmount'] ; + } + } + + + // 檢查 D.發票作廢 + if( $this->Invoice_Method == InvoiceMethod::INVOICE_VOID ) + { + // 42.發票號碼 InvoiceNumber + + // *必填項目 + if(strlen($this->Send['InvoiceNumber']) == 0) + { + array_push($arErrors, "42:InvoiceNumber is required."); + } + // *預設長度固定10碼 + if(strlen($this->Send['InvoiceNumber']) != 10) + { + array_push($arErrors, '42:InvoiceNumber length as 10.'); + } + } + + // 檢查 D.發票作廢、折讓作廢 + if( $this->Invoice_Method == InvoiceMethod::INVOICE_VOID || $this->Invoice_Method == InvoiceMethod::ALLOWANCE_VOID ) + { + // 43.作廢原因 Reason + + // *必填欄位 + if(strlen($this->Send['Reason']) == 0) + { + array_push($arErrors, "43:Reason is required."); + } + // *字數限制在20(含)個字以內 + if(strlen($this->Send['Reason']) > 20) + { + array_push($arErrors, "43:Reason max length as 20."); + } + // *urlencode + $this->Send['Reason'] = urlencode($this->Send['Reason']); + $this->Send['Reason'] = $this->Replace_Symbol($this->Send['Reason']) ; + } + + // 檢查 E.折讓作廢、H.查詢折讓明細 I.查詢折讓作廢明細、J.發送通知 + if( $this->Invoice_Method == InvoiceMethod::ALLOWANCE_VOID || $this->Invoice_Method == InvoiceMethod::ALLOWANCE_SEARCH || $this->Invoice_Method == InvoiceMethod::ALLOWANCE_VOID_SEARCH || $this->Invoice_Method == InvoiceMethod::INVOICE_NOTIFY ) + { + // 44.折讓編號 AllowanceNo + + // *除了J.發送通知非必填不須判斷其他項目都要 + if( $this->Invoice_Method != InvoiceMethod::INVOICE_NOTIFY ) + { + if(strlen($this->Send['AllowanceNo']) == 0) + { + array_push($arErrors, "44:AllowanceNo is required."); + } + } + // *若有值長度固定16字元 + if(strlen($this->Send['AllowanceNo']) != 0 && strlen($this->Send['AllowanceNo']) != 16 ) + { + array_push($arErrors, '44:AllowanceNo length as 16.'); + } + } + + // 檢查J.發送通知 + if( $this->Invoice_Method == InvoiceMethod::INVOICE_NOTIFY ) + { + // 45.NotifyMail 發送電子信箱 + + // *若客戶電子信箱有值時,則格式僅能為Email的標準格式 + if(strlen($this->Send['NotifyMail']) > 0 ) + { + if ( !preg_match('/^[a-z0-9&\'\.\-_\+]+@[a-z0-9\-_]+\.([a-z0-9\-_]+\.)*?[a-z]+$/is', $this->Send['NotifyMail']) ) + { + array_push($arErrors, '45:Invalid Email Format.'); + } + } + // *下述情況通知電子信箱不可為空值(發送方式為E-電子郵件) + if( $this->Send['Notify'] == NotifyType::Email && strlen($this->Send['NotifyMail']) == 0 ) + { + array_push($arErrors, "39:NotifyMail is required."); + } + // *UrlEncode + $this->Send['NotifyMail'] = urlencode($this->Send['NotifyMail']); + $this->Send['NotifyMail'] = $this->Replace_Symbol($this->Send['NotifyMail']) ; + + // 46.通知手機號碼 NotifyPhone + + // *若客戶手機號碼有值時,則預設格式為數字組成 + if(strlen($this->Send['Phone']) > 0 ) + { + if ( !preg_match('/^[0-9]*$/', $this->Send['Phone']) ) + { + array_push($arErrors, '46:Invalid Phone.'); + } + } + // *最大長度為20碼 + if(strlen($this->Send['Phone']) > 20 ) + { + array_push($arErrors, "46:Phone max length as 20."); + } + // *下述情況通知手機號碼不可為空值(發送方式為S-簡訊) + if( $this->Send['Notify'] == NotifyType::Sms && strlen($this->Send['Phone']) == 0 ) + { + array_push($arErrors, "46:Phone is required."); + } + + // 45-46 發送簡訊號碼、發送電子信箱不能全為空值 + if(strlen($this->Send['Phone']) == 0 && strlen($this->Send['NotifyMail']) == 0) + { + array_push($arErrors, "45-46:NotifyMail or Phone is required."); + } + else + { + if( $this->Send['Notify'] == NotifyType::All && ( strlen($this->Send['NotifyMail']) == 0 || strlen($this->Send['Phone']) == 0 ) ) + { + array_push($arErrors, "45-46:NotifyMail and Phone is required."); + } + } + // 47. 發送方式 Notify + + // *固定給定下述預設值 + if( ($this->Send['Notify'] != NotifyType::Sms ) && ( $this->Send['Notify'] != NotifyType::Email ) && ( $this->Send['Notify'] != NotifyType::All ) ) + { + array_push($arErrors, "47:Notify is required."); + } + + // 48.發送內容類型 InvoiceTag + + // *固定給定下述預設值 + if( ( $this->Send['InvoiceTag'] != InvoiceTagType::Invoice ) && ( $this->Send['InvoiceTag'] != InvoiceTagType::Invoice_Void ) && ( $this->Send['InvoiceTag'] != InvoiceTagType::Allowance ) && ( $this->Send['InvoiceTag'] != InvoiceTagType::Allowance_Void ) && ( $this->Send['InvoiceTag'] != InvoiceTagType::Invoice_Winning ) ) + { + array_push($arErrors, "48:InvoiceTag is required."); + } + + // 49.發送對象 Notified + + // *固定給定下述預設值 + if( ( $this->Send['Notified'] != NotifiedType::Customer ) && ( $this->Send['Notified'] != NotifiedType::vendor ) && ( $this->Send['Notified'] != NotifiedType::All ) ) + { + array_push($arErrors, "49:Notified is required."); + } + } + + return $arErrors ; + } + + /** + * 產生檢查碼 + * 傳入 $arParameters 各參數 + * 傳出 $sMacValue 檢查碼 + */ + function GenerateCheckMacValue($arParameters) + { + $sMacValue = '' ; + + if(isset($arParameters)) + { + // 資料排序 + // php 5.3以下不支援 + // ksort($arParameters, SORT_NATURAL | SORT_FLAG_CASE); + uksort($arParameters, array('AllInvoice','merchantSort')); + + // 開始組合字串 + $sMacValue = 'HashKey=' . $this->HashKey ; + foreach($arParameters as $key => $value) + { + $sMacValue .= '&' . $key . '=' . $value ; + } + + $sMacValue .= '&HashIV=' . $this->HashIV ; + + // URL Encode編碼 + $sMacValue = urlencode($sMacValue); + + // 轉成小寫 + $sMacValue = strtolower($sMacValue); + + // 取代為與 dotNet 相符的字元 + $sMacValue = str_replace('%2d', '-', $sMacValue); + $sMacValue = str_replace('%5f', '_', $sMacValue); + $sMacValue = str_replace('%2e', '.', $sMacValue); + $sMacValue = str_replace('%21', '!', $sMacValue); + $sMacValue = str_replace('%2a', '*', $sMacValue); + $sMacValue = str_replace('%28', '(', $sMacValue); + $sMacValue = str_replace('%29', ')', $sMacValue); + + // MD5編碼 + $sMacValue = md5($sMacValue); + $sMacValue = strtoupper($sMacValue); + } + + return $sMacValue ; + + } + + /** + * 參數內特殊字元取代 + * 傳入 $sParameters 參數 + * 傳出 $sReturn_Info 回傳取代後變數 + */ + function Replace_Symbol($sParameters) + { + if(!empty($sParameters)) + { + $sParameters = str_replace('%2D', '-', $sParameters); + $sParameters = str_replace('%2d', '-', $sParameters); + $sParameters = str_replace('%5F', '_', $sParameters); + $sParameters = str_replace('%5f', '_', $sParameters); + $sParameters = str_replace('%2E', '.', $sParameters); + $sParameters = str_replace('%2e', '.', $sParameters); + $sParameters = str_replace('%21', '!', $sParameters); + $sParameters = str_replace('%2A', '*', $sParameters); + $sParameters = str_replace('%2a', '*', $sParameters); + $sParameters = str_replace('%28', '(', $sParameters); + $sParameters = str_replace('%29', ')', $sParameters); + } + return $sParameters ; + } + + /** + * 自訂排序使用 + */ + private static function merchantSort($a,$b) + { + return strcasecmp($a, $b); + } + + /** + * 幕後送出參數 + * 傳入 $aSend_Info 送出參數 + * 傳出 $aReturn_Info 回傳參數 + */ + private function ServerPost($aSend_Info) + { + // 變數宣告 + $sSend_Info = '' ; + $sReturn_Info = '' ; + $aReturn_Info = array() ; + + // 組合字串 + foreach($aSend_Info as $key => $value) + { + if( $sSend_Info == '') + { + $sSend_Info .= $key . '=' . $value ; + } + else + { + $sSend_Info .= '&' . $key . '=' . $value ; + } + } + + // 送出參數 + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $this->Invoice_Url); + curl_setopt($ch, CURLOPT_HEADER, FALSE); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); + curl_setopt($ch, CURLOPT_POST, TRUE); + curl_setopt($ch, CURLOPT_POSTFIELDS, $sSend_Info); + + // 回傳參數 + $sReturn_Info = curl_exec($ch); + curl_close($ch); + + // 轉結果為陣列。 + parse_str($sReturn_Info, $aReturn_Info); + + return $aReturn_Info; + + } +} + +?> \ No newline at end of file diff --git a/phplibs/Altob.Payment.Core.php b/phplibs/Altob.Payment.Core.php new file mode 100644 index 0000000..b395ec1 --- /dev/null +++ b/phplibs/Altob.Payment.Core.php @@ -0,0 +1,200 @@ +d; + $data[BillResultKey::hours] = $interval->h; + $data[BillResultKey::mins] = $interval->i; + $data[BillResultKey::price] = $this->Price; + $data[BillResultKey::price_detail] = $this->PriceDetail; + $data[BillResultKey::price_plan] = $this->PricePlan; + $data[BillResultKey::price_plan_date] = $this->PricePlanDate; + return $data; + } + + /** + * 取得費率資訊 + */ + protected function getPricePlan($stationNo, $txType=PricePlanValue::TYPE_0) + { + $plan = array(); + + // 從 DB 取得費率設定 + $result = $this->ServerPost("{$this->ServiceURL}/get_price_plan/{$stationNo}/{$txType}"); + $decode_result = json_decode($result, true); + + if(! empty($decode_result[0])){ + $plan = json_decode($decode_result[0][PricePlanKey::price_plan], true); + } + + return $plan; + } + + /** + * 取得特殊日期陣列 + */ + protected function getPricePlanDate($inTime, $balanceTime) + { + $result = array(); + $date_plan = $this->getDatePlan($inTime, $balanceTime); // 取得特殊日期 + foreach ($date_plan as $val){ + $day = new DateTime($val[DatePlanKey::p_date]); + $day_key = $this->genLv1Key($day); + $result[$day_key] = $val; + } + return $result; + } + + // 取得特殊日期 + private function getDatePlan($inTime, $balanceTime) + { + $result = array(); + $inTimestamp = strtotime($inTime); + $balanceTimestamp = strtotime($balanceTime); + // 算出週六日 + $weekdays = $this->get_weekdays($inTimestamp, $balanceTimestamp); + foreach ($weekdays as $val){ + $weekday = array(); + $weekday[DatePlanKey::p_type] = DatePlanValue::TYPE_1; + $weekday[DatePlanKey::p_date] = date('Y-m-d H:i:s', $val); + array_push($result, $weekday); + } + // 從 DB 取得其它假日 + $db_result = $this->ServerPost("{$this->ServiceURL}/get_date_plan/{$inTimestamp}/{$balanceTimestamp}"); + $decode_db_result = json_decode($db_result, true); + + if(! empty($decode_db_result)){ + foreach ($decode_db_result as $val){ + $holiday = array(); + $holiday[DatePlanKey::p_type] = $val[DatePlanKey::p_type]; + $holiday[DatePlanKey::p_date] = $val[DatePlanKey::p_date]; //date('Y-m-d H:i:s', ); + array_push($result, $holiday); + } + } + return $result; + } + + // 取得指定期間週末 (timestamp) + private function get_weekdays($from, $to=false) + { + if ($to == false) + $to = $this->last_day_of_month($from); + + $days = array(); + + for ($x = $from; $x < $to; $x+=86400 ) { // 60*60*24 一天的秒數 + //if (date('w', $x) > 0 && date('w', $x) < 6) + if (date('w', $x) == 0 || date('w', $x) == 6) + $days[] = $x; + } + return $days; + } + + // 取得當月最後一天 (timestamp) + private function last_day_of_month($ts=false) + { + $m = date('m', $ts); + $y = date('y', $ts); + return mktime(23, 59, 59, ($m+1), 0, $y); + } + + // 呼叫其它服務 + private function ServerPost($url, $parameters=array()) + { + $ch = curl_init(); + + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_HEADER, FALSE); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); + curl_setopt($ch, CURLOPT_POST, TRUE); + curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($parameters)); + $rs = curl_exec($ch); + + curl_close($ch); + + return $rs; + } + + // 產生日期當 lv1 key + protected function genLv1Key($date) + { + return $date->format('Y-m-d'); + } + + // 產生時間當 lv2 key + protected function genLv2Key($date) + { + return $date->format('H:i:s'); + } + +} diff --git a/phplibs/Altob.Payment.Integration.php b/phplibs/Altob.Payment.Integration.php new file mode 100644 index 0000000..ebf71b2 --- /dev/null +++ b/phplibs/Altob.Payment.Integration.php @@ -0,0 +1,261 @@ +diff($dateEnd); // y, m, d, h, i, s + + // A. 取得費率設定 + $this->PricePlan = $this->getPricePlan($stationNo); // get price plan + + /* + 規則: + 1. 每小時20元,每日最高150元,前30分鐘免費 + 2. 另外停車1小時候未滿30分以10元計,超過30分以20元計 + + ex. 15日18:00進場~16日20:30出場:15日金額120元 + 16日金額150元 =270 + ex. 15日12:00進場~15日16:25出場:80元+10元 + */ + $p0 = $this->PricePlan[PricePlanValueKey::p0]; // 費用 0 (10元 /半小時) + $limit0 = $this->PricePlan[PricePlanValueKey::limit0]; // 上限 0 (150元 /D) + $limit0_start_time = $this->PricePlan[PricePlanValueKey::limit0_start_time]; // 上限 0 開始時間 (00:00:00) + $limit0_end_time = $this->PricePlan[PricePlanValueKey::limit0_end_time]; // 上限 0 結束時間 (23:59:59) + $free0_min = $this->PricePlan[PricePlanValueKey::free0_min]; // 免費 0 (前 30 分) + + // B. 取得特殊日期 + //$this->PricePlanDate = $this->getPricePlanDate($inTime, $balanceTime); + + // C. 開始建立帳單明細 $this->PriceDetail + $this->PriceDetail = array(); + + // D. 取得帳單結算價錢 + + // D.1 前 30 分鐘免費 + if($interval->y == 0 && $interval->m == 0 && $interval->d == 0 && $interval->h == 0 && $interval->i < $free0_min){ + $this->Price = 0; + return $this->genBillResult($interval); + } + + // D.2 依照費率將時間切割, 暫存 $day_array + $day_array = array(); + $dateFront = $dateBegin; + $dateTail = $dateEnd; + $period_of_basic_repeat = new DatePeriod($dateFront, DateInterval::createFromDateString('30 minutes'), $dateTail); + foreach ($period_of_basic_repeat as $basic_part){ + $today_key = $this->genLv1Key($basic_part); + if(!array_key_exists($today_key, $this->PriceDetail)){ + $today_data = array(); + $today_data[PriceDeatilKey::p0] = $p0; + $today_data[PriceDeatilKey::limit0] = $limit0; + $today_data[PriceDeatilKey::limit0_start_time] = $limit0_start_time; + $today_data[PriceDeatilKey::limit0_end_time] = $limit0_end_time; + $today_data[PriceDeatilKey::free0_min] = $free0_min; + $this->PriceDetail[$today_key] = $today_data; + } + $this->genLv2Value(0, $today_key, $basic_part, 0, "init"); + array_push($day_array, $basic_part); + } + $this->PriceDetail["day_array"] = $day_array; + //return $this->genBillResult($interval); + + // 解析 $day_array 建立帳單明細於 $this->PriceDetail + $total_price = 0; + $today_limit0_amt = 0; + $count_period = count($day_array); + for($i = 0 ; $i < $count_period ; $i+=1){ + $price_this = 0; + $day_this = $day_array[$i]; + $today_key = $this->genLv1Key($day_this); + $today_lv2_key = $this->genLv2Key($day_this); + $today_p0 = $this->PriceDetail[$today_key][PriceDeatilKey::p0]; + $today_limit0 = $this->PriceDetail[$today_key][PriceDeatilKey::limit0]; + $today_limit0_start_time = $this->PriceDetail[$today_key][PriceDeatilKey::limit0_start_time]; + $today_limit0_end_time = $this->PriceDetail[$today_key][PriceDeatilKey::limit0_end_time]; + $today_free0_min = $this->PriceDetail[$today_key][PriceDeatilKey::free0_min]; + + // 重置每日收費上限 + $current_h = $day_this->format('H'); + if($current_h == substr($today_limit0_start_time, 0, 2)){ + $today_limit0_amt = 0; + } + + // 記算金額 + $status = PriceDeatilStatusValue::TYPE_0; + if($today_limit0_amt >= $today_limit0){ + // 已達上限值, 免費 + $price_this = 0; + $memo = "B.4 ..FREE.."; + $status = PriceDeatilStatusValue::TYPE_1; + }else{ + // 未達上限值, 取得時段費用 + $price_this = $this->getPrice($today_p0); + + if(array_key_exists($i - 1, $day_array)){ + if(array_key_exists($i + 1, $day_array)){ + if($today_limit0_amt + $price_this >= $today_limit0){ + // 未達上限值, 有上一筆, 有下一筆, 本次達上限 + $price_this = $today_limit0 - $today_limit0_amt; + $today_limit0_amt = $today_limit0; + $memo = "B.3 ..today limit : {$today_limit0}.."; + $status = PriceDeatilStatusValue::TYPE_1; + }else{ + // 未達上限值, 有上一筆, 有下一筆, 本次未達上限 + $today_limit0_amt += $price_this; + $memo = "B.2 ..next.."; + } + }else{ + // 未達上限值, 有上一筆, 最後一筆 + if($today_limit0_amt + $price_this >= $today_limit0){ + // 未達上限值, 有上一筆, 最後一筆, 本次達上限 + $price_this = $today_limit0 - $today_limit0_amt; + $today_limit0_amt = $today_limit0; + $memo = "D.2 ..today limit : {$today_limit0}.."; + $status = PriceDeatilStatusValue::TYPE_1; + }else{ + // 未達上限值, 有上一筆, 最後一筆, 本次未達上限 + $today_limit0_amt += $price_this; + $memo = "D.1 ..next.."; + } + } + }else{ + if(array_key_exists($i + 1, $day_array)){ + // 未達上限值, 第一筆, 有下一筆 + $today_limit0_amt += $price_this; + $memo = "B.1 ..START..a"; + }else{ + // 未達上限值, 第一筆, 最後一筆 + $memo = "C ..done.."; + } + } + } + + // 建立明細資料 + if(array_key_exists($i - 1, $day_array)){ + if(array_key_exists($i + 1, $day_array)){ + // 有上一筆, 有下一筆 + $this->setLv2Value($i, $today_key, $today_lv2_key, $price_this, $memo, $status); + }else{ + // 有上一筆, 最後一筆 + $this->setLv2Value($i, $today_key, $today_lv2_key, $price_this, $memo, $status); + $price_end = 0; + $status = PriceDeatilStatusValue::TYPE_0; + /* + if($day_this->diff($dateEnd)->i < $today_free0_min){ + // 未滿 30 分, 不計 + $memo = "E.3 ..end.."; + }else{ + */ + $price_end = $this->getPrice($today_p0);; + if($today_limit0_amt + $price_end >= $today_limit0){ + // 達上限 + $price_end = $today_limit0 - $today_limit0_amt; + $memo = "E.2 ..today limit : {$today_limit0}.."; + $status = PriceDeatilStatusValue::TYPE_1; + }else{ + $memo = "E.1 ..end.."; + } + + $this->genLv2Value($i + 1, $today_key, $dateEnd, $price_end, $memo, $status); + } + }else{ + if(array_key_exists($i + 1, $day_array)){ + // 第一筆, 有下一筆 + // do nothing + }else{ + // 第一筆, 最後一筆 + $this->genLv2Value($i + 1, $today_key, $dateEnd, $price_this, $memo, $status); + } + } + + // 總結算 + $total_price += $price_this; + } + + $this->Price = $total_price; + return $this->genBillResult($interval); + } + + // 取得目前時段價格 + private function getPrice($today_p0) + { + return $today_p0; + } + + // 建立 lv2 + private function genLv2Info($r_no, $today_lv1_key, $today_lv2_key, $price, $price_type, $meta) + { + $lv1Key = $today_lv1_key; + $lv2Key = $today_lv2_key; + $this->PriceDetail[$lv1Key][$lv2Key][PriceDeatilKey::r_no] = $r_no; + $this->PriceDetail[$lv1Key][$lv2Key][PriceDeatilKey::price] = $price; + $this->PriceDetail[$lv1Key][$lv2Key][PriceDeatilKey::p_type] = $price_type; + $this->PriceDetail[$lv1Key][$lv2Key][PriceDeatilKey::meta] = $meta; + } + + // 建立 lv2 value + private function genLv2Value($r_no, $lv1Key, $day, $price, $meta, $status=PriceDeatilStatusValue::TYPE_0) + { + $lv2Key = $this->genLv2Key($day); + $this->PriceDetail[$lv1Key][$lv2Key][PriceDeatilKey::day] = $day->format('Y-m-d H:i:s'); + $this->setLv2Value($r_no, $lv1Key, $lv2Key, $price, $meta, $status); + } + + // 設定 lv2 value + private function setLv2Value($r_no, $lv1Key, $lv2Key, $price, $meta, $status=PriceDeatilStatusValue::TYPE_0) + { + $this->PriceDetail[$lv1Key][$lv2Key][PriceDeatilKey::r_no] = $r_no; + $this->PriceDetail[$lv1Key][$lv2Key][PriceDeatilKey::price] = $price; + $this->PriceDetail[$lv1Key][$lv2Key][PriceDeatilKey::meta] = $meta; + $this->PriceDetail[$lv1Key][$lv2Key][PriceDeatilKey::status] = $status; + } + +} diff --git a/phplibs/Altob.Sync.Integration.php b/phplibs/Altob.Sync.Integration.php new file mode 100644 index 0000000..3f1e18f --- /dev/null +++ b/phplibs/Altob.Sync.Integration.php @@ -0,0 +1,279 @@ +post_parms = array(); + $this->post_parms['station_no'] = $station_no; + $this->post_parms['io_time'] = $time; + } + + // 檢查基本欄位 + function check_init_parms() + { + if(empty($this->post_parms['station_no'])) + return 'station_no not set'; // 場站編號 + + if(empty($this->post_parms['io_time'])) + return 'io_time not set'; // 進出時間 (若為繳費帶進場時間) + + return false; + } + + // =============================================== + // st_io + // =============================================== + + // 傳送進場記錄 + public function sync_st_in($parms) + { + $error_parms_msg = $this->check_init_parms(); + if(!empty($error_parms_msg)) { return $error_parms_msg; } + + if(empty($this->cario_no)) + return 'cario_no not found'; + + if(empty($parms['lpr'])) + return 'lpr not found'; + + if(empty($parms['io'])) + return 'io not found'; + + $this->post_parms['cario_no'] = $this->cario_no; // 需設定 + $this->post_parms['member_no'] = $this->member_no; // 預設為 0 + + $this->post_parms['lpr'] = $parms['lpr']; + $this->post_parms['io'] = $parms['io']; + $this->post_parms['etag'] = $parms['etag'] == 'NONE' ? '' : $parms['etag']; + $this->post_parms['pic_name'] = empty($parms['pic_name']) ? '' : $parms['pic_name']; + $this->post_parms['ivsno'] = $parms['ivsno']; + $this->post_parms['out_before_time'] = $this->post_parms['io_time']; + + // 初始化網路服務物件。 + $oService = new AltobSyncService(); + $oService->ServiceURL = AltobSyncAgent::SYNC_CARS_URL; + $oService->ServiceCMD = 'st_in'; + + // 傳遞參數至遠端。 + return $oService->ServerPost($this->post_parms); + } + + // 傳送離場記錄 + public function sync_st_out($parms) + { + $error_parms_msg = $this->check_init_parms(); + if(!empty($error_parms_msg)) { return $error_parms_msg; } + + // 有入場記錄時 + if($this->cario_no > 0) + { + $this->post_parms['cario_no'] = $this->cario_no; + + if(empty($this->in_time)) + return 'in_time not found'; // 需設定 + + $this->post_parms['in_time'] = $this->in_time; + $this->post_parms['minutes'] = floor((strtotime($this->post_parms['io_time']) - strtotime($this->in_time)) / 60); // 停車時數 (分鐘) + } + + if(empty($parms['lpr'])) + return 'lpr not found'; + + if(empty($parms['io'])) + return 'io not found'; + + $this->post_parms['member_no'] = $this->member_no; // 預設為 0 + $this->post_parms['finished'] = $this->finished; // 預設為 0 + + $this->post_parms['lpr'] = $parms['lpr']; + $this->post_parms['io'] = $parms['io']; + $this->post_parms['etag'] = $parms['etag'] == 'NONE' ? '' : $parms['etag']; + $this->post_parms['pic_name'] = empty($parms['pic_name']) ? '' : $parms['pic_name']; + $this->post_parms['ivsno'] = $parms['ivsno']; + + // 初始化網路服務物件。 + $oService = new AltobSyncService(); + $oService->ServiceURL = AltobSyncAgent::SYNC_CARS_URL; + $oService->ServiceCMD = 'st_out'; + + // 傳遞參數至遠端。 + return $oService->ServerPost($this->post_parms); + } + + // 傳送付費更新記錄 + public function sync_st_pay($lpr, $pay_time, $pay_type=0, $out_before_time='') + { + $error_parms_msg = $this->check_init_parms(); + if(!empty($error_parms_msg)) { return $error_parms_msg; } + + if(empty($this->cario_no)) + return 'cario_no not found'; + + if(empty($lpr)) + return 'lpr not found'; + + if(empty($pay_time)) + return 'pay_time not found'; + + $this->post_parms['cario_no'] = $this->cario_no; // 需設定 + + $this->post_parms['lpr'] = $lpr; + $this->post_parms['pay_time'] = $pay_time; + $this->post_parms['pay_type'] = $pay_type; + $this->post_parms['out_before_time'] = empty($out_before_time) ? date('Y-m-d H:i:s', strtotime("{$pay_time} + 15 minutes")) : $out_before_time; + + // 初始化網路服務物件。 + $oService = new AltobSyncService(); + $oService->ServiceURL = AltobSyncAgent::SYNC_CARS_URL; + $oService->ServiceCMD = 'st_pay'; + + // 傳遞參數至遠端。 + return $oService->ServerPost($this->post_parms); + } + + // =============================================== + // members + // =============================================== + + // 取得場站會員 + public function get_st_members() + { + if(empty($this->post_parms['station_no'])) + return 'station_no not set'; // 場站編號 + + // 初始化網路服務物件。 + $oService = new AltobSyncService(); + $oService->ServiceURL = AltobSyncAgent::SYNC_ST_URL; + $oService->ServiceCMD = 'member_query_all'; + + // 傳遞參數至遠端。 + return $oService->ServerPost($this->post_parms); + } + + // 同步會員鎖車 (0: 解鎖, 1: 上鎖, 2: 查詢) + public function sync_security_action($lpr, $pswd, $action) + { + if(empty($this->post_parms['station_no'])) + return 'station_no not set'; // 場站編號 + + $station_no = $this->post_parms['station_no']; + $ck = md5($lpr.'i'.$pswd.'iii'.$action); + + // 初始化網路服務物件。 + $oService = new AltobSyncService(); + $oService->ServiceURL = AltobSyncAgent::API_URL; + $oService->ServiceCMD = "sync_security_action/{$lpr}/{$pswd}/{$action}/{$ck}/{$station_no}"; + + // 傳遞參數至遠端。 + return $oService->ServerPost($this->post_parms); + } + + // 同步會員改密碼 + public function sync_change_pwd($lpr, $pswd, $new_pwd) + { + if(empty($this->post_parms['station_no'])) + return 'station_no not set'; // 場站編號 + + $station_no = $this->post_parms['station_no']; + $ck = md5($lpr.'i'.$pswd.'iii'.$new_pwd); + + // 初始化網路服務物件。 + $oService = new AltobSyncService(); + $oService->ServiceURL = AltobSyncAgent::API_URL; + $oService->ServiceCMD = "sync_change_pwd/{$lpr}/{$pswd}/{$new_pwd}/{$ck}/{$station_no}"; + + // 傳遞參數至遠端。 + return $oService->ServerPost($this->post_parms); + } + + // =============================================== + // pks + // =============================================== + + // 在席 + public function upd_pks_groups($data) + { + if(empty($this->post_parms['station_no'])) + return 'station_no not set'; // 場站編號 + + $this->post_parms['data'] = $data; + + // 初始化網路服務物件。 + $oService = new AltobSyncService(); + $oService->ServiceURL = AltobSyncAgent::SYNC_PKS_URL; + $oService->ServiceCMD = 'upd_pks_groups'; + + // 傳遞參數至遠端。 + return $oService->ServerPost($this->post_parms); + } + +} + +/** + * 呼叫網路服務的類別。 + */ +class AltobSyncService { + + /** + * 網路服務類別呼叫的位址。 + */ + public $ServiceURL = 'ServiceURL'; + public $ServiceCMD = 'ServiceCMD'; + + /** + * 網路服務類別的建構式。 + */ + function __construct() {$this->AltobSyncService();} + + /** + * 網路服務類別的實體。 + */ + function AltobSyncService() {} + + /** + * 提供伺服器端呼叫遠端伺服器 Web API 的方法。 + */ + function ServerPost($parameters) { + $ch = curl_init(); + + curl_setopt($ch, CURLOPT_URL, $this->ServiceURL . $this->ServiceCMD); + curl_setopt($ch, CURLOPT_HEADER, FALSE); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); + curl_setopt($ch, CURLOPT_POST, TRUE); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,5); + curl_setopt($ch, CURLOPT_TIMEOUT, 5); //timeout in seconds + curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($parameters)); + $rs = curl_exec($ch); + curl_close($ch); + + return $rs; + } + +} diff --git a/phplibs/Altob.TWGC.Integration.php b/phplibs/Altob.TWGC.Integration.php new file mode 100644 index 0000000..2d20d90 --- /dev/null +++ b/phplibs/Altob.TWGC.Integration.php @@ -0,0 +1,499 @@ +TWGCAgent(); + } + + /** + * 取得TWGC 服務的實體。 + */ + function TWGCAgent() { + } + + /** + * API 1: 查詢 BarCode + * + * 說明: 查詢 BarCode 狀態、餘額及紅利點數 + * + * [data] + * *BarCode:卡號 + */ + public function BalanceInquiry($data) { + extract($data); + + if (empty($POSTime)) { + $POSTime = date('Y/m/d H:i:s', time()); + } + + if (empty($MbrPhone)) { $MbrPhone = ""; } + + $BarCode_str = ''; + if (isset($BarCode)) { + $BarCode_str = ''. $BarCode .''; + } + + $Card_str = $BarCode_str; + + $xml = + ' + '. $this->IssuerID .' + '. $this->StoreID .' + '. $this->POSID .' + + '. $CustTrxNo .' + + '. $Card_str .' + + '. $MbrPhone .' + '. $POSTime .' + '; + + return $this->getResultXml(__FUNCTION__, $xml); + } + + /** + * API 2: 卡片記名 + * + * 說明: 將 BarCode 綁定 UserID + * + * [data] + * *UserID:會員編號 (最多 20 字元) + * UserName:會員姓名 + * UserSex:會員性別 (M/F/空字串 ) + * Birthday:會員生日 (YYYY/MM/DD) + * Addr:會員地址 + * Email:會員電子郵件 + * TelHZone:會員市內電話區碼 + * TelH:會員市內電話 + * MbrPhone:手機號碼 + * Memo:備註 + * *BarCode:記名卡號 + */ + public function Register($data) { + extract($data); + + if (empty($POSTime)) { + $POSTime = date('Y/m/d H:i:s', time()); + } + + if (empty($Birthday)) { + $Birthday = $POSTime; + } + + if (empty($UserName)) { $UserName = ""; } + if (empty($UserSex)) { $UserSex = ""; } + if (empty($Addr)) { $Addr = ""; } + if (empty($Email)) { $Email = ""; } + if (empty($TelHZone)) { $TelHZone = ""; } + if (empty($TelH)) { $TelH = ""; } + if (empty($MbrPhone)) { $MbrPhone = ""; } + if (empty($Memo)) { $Memo = ""; } + if (empty($StaffID)) { $StaffID = ""; } + + $xml = + ' + '. $this->IssuerID .' + '. $this->StoreID .' + '. $this->POSID .' + + '. $CustTrxNo .' + '. $UserID .' + '. $MbrPhone .' + '. $BarCode .' + '. $POSTime .' + '. $StaffID .' + '; + + /* + $xml = + ' + '. $this->IssuerID .' + '. $this->StoreID .' + '. $this->POSID .' + + '. $CustTrxNo .' + '. $UserID .' + '. $UserName .' + '. $UserSex .' + '. $Birthday .' + '. $Addr .' + '. $Email .' + '. $TelHZone .' + '. $TelH .' + '. $MbrPhone .' + '. $Memo .' + '. $BarCode .' + '. $POSTime .' + '. $StaffID .' + '; + */ + + return $this->getResultXml(__FUNCTION__, $xml); + } + + /** + * API 3: 虛擬卡開卡 + * + * 說明: 用 EAN 去建立任意面額的 BarCode, 剛建立好的 BarCode 未綁定 UserID + * + * [data] + * *EAN:卡號前 13碼 + * *Amount:卡片面額 + * Timeout:未收到開卡結果的Timeout時間,0~999 + */ + public function VirtualCardActivation($data) { + extract($data); + + if (empty($TransTime)) { + $TransTime = date('Y/m/d H:i:s', time()); + } + + if (empty($Timeout)) { $Timeout = 100; } // 未收到開卡結果的Timeout時間,0~999 + + $EAN_str = ''; + if (isset($EAN)) { + $EAN_str = ''. $EAN .''; + } + $Amount_str = ''; + if (isset($Amount)) { + $Amount_str = ''. $Amount .''; + } + + $Card_str = $EAN_str.$Amount_str; + + $xml = + ' + '. $this->IssuerID .' + '. $this->StoreID .' + '. $this->POSID .' + + '. $CustTrxNo .' + '. $TransTime .' + '. $Timeout .' + + '. $Card_str .' + + '; + + return $this->getResultXml(__FUNCTION__, $xml); + } + + /** + * API 4: 退款 + * + * 說明: 退款作業 (取消消費交易) + * + * [data] + * *CustTrxNo:原交易序號 + * *AuthCode:原交易授權碼 + */ + public function Refund($data) { + extract($data); + + if (empty($POSTime)) { + $POSTime = date('Y/m/d H:i:s', time()); + } + + if (empty($MbrPhone)) { $MbrPhone = ""; } + if (empty($StaffID)) { $StaffID = ""; } + + $xml = + ' + '. $this->IssuerID .' + '. $this->StoreID .' + '. $this->POSID .' + + '. $CustTrxNo .' + '. $AuthCode .' + '. $MbrPhone .' + '. $POSTime .' + '. $StaffID .' + '; + + return $this->getResultXml(__FUNCTION__, $xml); + } + + /** + * API 5: 確認交易結果 + * + * 說明: 確認交易結果 + * + * [data] + * *CustTrxNo:原交易序號 + */ + public function CheckResult($data) { + extract($data); + + if (empty($POSTime)) { + $POSTime = date('Y/m/d H:i:s', time()); + } + + if (empty($MbrPhone)) { $MbrPhone = ""; } + + $xml = + ' + '. $this->IssuerID .' + '. $this->StoreID .' + '. $this->POSID .' + + '. $CustTrxNo .' + '. $MbrPhone .' + '. $POSTime .' + '; + + return $this->getResultXml(__FUNCTION__, $xml); + } + + /** + * API 6: 會員綁定卡片消費 + * + * 說明: 使用 已綁定 MemberID 的 BarCode 消費 + * + * [data] + * *MemberID:會員編號 (ex. 車號) + * *BarCode:卡號 + * ReqAmount:總交易金額 總交易金額 (包含非 卡片交易金額 ) + * *Amount:卡片 交易金額 (包含使 用紅利點數金額 ) + * ProductID:商品代號 + * ReedemPointsForCash:使用紅利點數折抵功能,會以紅利可折抵的最大金額扣除紅利,並優先扣除 , 使用請填 “Y”,不使用則不填 + */ + public function BalanceMaintenance3($data, $redeem) { + extract($data); + + if (empty($POSTime)) { + $POSTime = date('Y/m/d H:i:s', time()); + } + + $RedeemPointsForCash = ""; + if ($redeem) { + $RedeemPointsForCash = "Y"; // 紅利點數折抵 + } + + if (empty($ReqAmount)) { $ReqAmount = ""; } + if (empty($MbrPhone)) { $MbrPhone = ""; } + if (empty($StaffID)) { $StaffID = ""; } + if (empty($ProductID)) { $ProductID = ""; } + + $xml = + ' + '. $this->IssuerID .' + '. $this->StoreID .' + '. $this->POSID .' + + '. $MemberID .' + '. $BarCode .' + '. $ReqAmount .' + '. $Amount .' + '. $CustTrxNo .' + '. $MbrPhone .' + '. $POSTime .' + '. $StaffID .' + '. $ProductID .' + '. $RedeemPointsForCash .' + '; + + return $this->getResultXml(__FUNCTION__, $xml); + } + + /** + * API 7: 取消卡片記名 + * + * 說明: 取消卡片記名 + * + * [data] + * *UserID:要取消記名的會員編號 + * *MbrPhone:要取消記名的會員電話 + * *BarCode:要取消記名的卡號 + */ + public function UnRegister($data) { + extract($data); + + if (empty($POSTime)) { $POSTime = date('Y/m/d H:i:s', time()); } + if (empty($MbrPhone)) { $MbrPhone = ""; } + if (empty($StaffID)) { $StaffID = ""; } + + $xml = + ' + '. $this->IssuerID .' + '. $this->StoreID .' + '. $this->POSID .' + + '. $CustTrxNo .' + '. $UserID .' + '. $MbrPhone .' + '. $BarCode .' + '. $POSTime .' + '. $StaffID .' + '; + + return $this->getResultXml(__FUNCTION__, $xml); + } + + /** + * API 8: 卡片儲值 + * + * 說明: + * 1. 實體卡: 括開銀漆後會有 PIN 碼, 輸入 PIN 即可代表該卡片 + * 2. 虛擬卡: 要先向 TWGC 取得一個一次性的密碼作為 PIN 碼, 進行儲值交易 (GetOTPin2) + * + * [data] + * *Amount:儲值金額最大共10碼數字,單位為元 + * PromotionID:促銷活動代號 (填空字串即可) + * PIN:儲值碼 + * + */ + public function Reload2($data) { + extract($data); + + if (empty($POSTime)) { $POSTime = date('Y/m/d H:i:s', time()); } + if (empty($PIN)) { $PIN = ""; } + if (empty($MbrPhone)) { $MbrPhone = ""; } + if (empty($StaffID)) { $StaffID = ""; } + if (empty($PromotionID)) { $PromotionID = ""; } + + $xml = + ' + '. $this->IssuerID .' + '. $this->StoreID .' + '. $this->POSID .' + + '. $CustTrxNo .' + '. $PIN .' + '. $Amount .' + '. $MbrPhone .' + '. $POSTime .' + '. $StaffID .' + '. $PromotionID .' + '; + + return $this->getResultXml(__FUNCTION__, $xml); + } + + /** + * API 9: 取得卡片儲值 PIN 碼 + * + * 說明: + * GetOTPin2 會回傳一個圖檔 (以 base64 解碼還原為圖檔), 圖檔裡有 PIN 碼 + * + * [data] + * *RequestTime:本機時間 + * *PasswordType:固定填寫 ‘TWGCAPP’ + * *Size:回傳圖檔大小 (L/M/S) + */ + public function GetOTPin2($data) { + extract($data); + + if (empty($RequestTime)) { $RequestTime = date('Y/m/d H:i:s', time()); } + if (empty($PasswordType)) { $PasswordType = "TWGCAPP"; } + if (empty($Size)) { $Size = "S"; } + + $xml = + ' + '. $RequestTime .' + '. $PasswordType .' + '. $BarCode .' + '. $Size .' + '; + + return $this->getResultXml(__FUNCTION__, $xml); + } + + /** + * API 10: 停用 + * + * 說明: 停用 Barcode + * + * [data] + * *BarCode:要停用的卡號 + * *Reason: 停用原因 (1.遺失, 2.損壞, 3.更換新卡而停用本卡, 4.單純停用) + */ + public function Suspend($data) { + extract($data); + + if (empty($PIN)) { $PIN = ""; } + if (empty($MbrPhone)) { $MbrPhone = ""; } + if (empty($TransTime)) { $TransTime = date('Y-m-d H:i:s', time()); } + if (empty($Reason)) { $Reason = "4"; } // 4.單純停用 + + $xml = + ' + '. $this->IssuerID .' + '. $this->StoreID .' + '. $this->POSID .' + + '. $CustTrxNo .' + '. $BarCode .' + '. $PIN .' + '. $MbrPhone .' + '. $TransTime .' + '. $Reason .' + '; + + return $this->getResultXml(__FUNCTION__, $xml); + } + + /** + * 取得 TWGC 回傳 XML + */ + private function getResultXml($function, $xml) { + $url = $this->ServiceURL.'/'.$function; + $parameters = + array( + 'issuerIdentity' => $this->issuerIdentity, + 'xml' => base64_encode($xml) + ); + $spResult = $this->ServerPost($url, $parameters); + // parse result + $result_decode = base64_decode(substr(simplexml_load_string($spResult), 5)); + //echo json_encode(simplexml_load_string($result_decode)); + return simplexml_load_string($result_decode); + } + + private function ServerPost($url, $parameters=array()) { + $ch = curl_init(); + + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_HEADER, FALSE); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); + curl_setopt($ch, CURLOPT_POST, TRUE); + curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($parameters)); + $rs = curl_exec($ch); + + curl_close($ch); + + return $rs; + } + +} diff --git a/phplibs/ctbcbank/Altob.CTBC.Bank.Integration.php b/phplibs/ctbcbank/Altob.CTBC.Bank.Integration.php new file mode 100644 index 0000000..1ee6d8f --- /dev/null +++ b/phplibs/ctbcbank/Altob.CTBC.Bank.Integration.php @@ -0,0 +1,251 @@ +CTBCAgent(); + } + + function CTBCAgent() { + } + + /** + * 1. CTBC 結帳 + * + * [data] + * *merID : 特店網站專用代號 + * *URLEnc: 交易訊息的密文(URLEnc) + */ + public function CheckOut($data) { + extract($data); + + // 取得url enc + $urlEnc = $this->URLEnc($data); + + // 轉址 + $szHtml = ''; + $szHtml .= '
'; + $szHtml .=""; + $szHtml .=""; + $szHtml .= ''; + $szHtml .= '
'; + echo $szHtml; + } + + /** + * 2. 解密URL 交易訊息的密文(URLDec) + * + * [data] + * *encRes= : 密文 + * debug: 預設(進行交易時)請填0,偵錯時請填1。 + */ + public function Decrypt($data) { + extract($data); + + if (empty($debug)) { $debug = "0"; } + + return gendecrypt( + $encRes, + $this->Key, + $debug); + } + + /** + * 3. 取得 checkmac + */ + public function CheckMac($data) { + extract($data); + + if (empty($debug)) { $debug = "0"; } + + if (!empty($prodcode)) { + $option = $prodcode; // option: 紅利交易 + }else{ + $option = $numberofpay; // option: 一般交易, 分期交易 + } + + return auth_out_mac( + $status, $errcode, $authcode, $authamt, $lidm, $offsetamt, $originalamt, $utilizedpoint, + $option, + $last4digitpan, + $this->Key, + $debug); + } + + /** + * 解密URL 交易訊息的密文(URLDec) + * + * [data] + * *encRes= : 密文 + * debug: 預設(進行交易時)請填0,偵錯時請填1。 + */ + function URLDec($data) { + extract($data); + + if (empty($debug)) { $debug = "0"; } + + $EncArray = gendecrypt( + $encRes, + $this->Key, + $debug); + + $MACString = ''; + $URLEnc = ''; + + //echo "
\n"; + + foreach($EncArray AS $name => $val){ + echo $name ."=>". urlencode(trim($val,"\x00..\x08")) ."\n"; + } + + if(isset($EncArray['status'])){ + $status = isset($EncArray['status']) ? $EncArray['status'] : ""; + $errCode = isset($EncArray['errcode']) ? $EncArray['errcode'] : ""; + $authCode = isset($EncArray['authcode']) ? $EncArray['authcode'] : ""; + $authAmt = isset($EncArray['authamt']) ? $EncArray['authamt'] : ""; + $lidm = isset($EncArray['lidm']) ? $EncArray['lidm'] : ""; + $OffsetAmt = isset($EncArray['offsetamt']) ? $EncArray['offsetamt'] : ""; + $OriginalAmt = isset($EncArray['originalamt']) ? $EncArray['originalamt'] : ""; + $UtilizedPoint = isset($EncArray['utilizedpoint']) ? $EncArray['utilizedpoint'] : ""; + $Option = isset($EncArray['numberofpay']) ? $EncArray[' numberofpay'] : ""; + //紅利交易時請帶入prodcode + //$Option = isset($EncArray['prodcode']) ? $EncArray['prodcode'] : ""; + $Last4digitPAN = isset($EncArray['last4digitpan']) ? $EncArray['last4digitpan'] : ""; + $pidResult= isset($EncArray['pidResult']) ? $EncArray['pidResult'] : ""; + $CardNumber = isset($EncArray['CardNumber']) ? $EncArray['CardNumber'] : ""; + + $MACString = auth_out_mac( + $status, $errCode, $authCode, $authAmt, $lidm, $OffsetAmt, $OriginalAmt, $UtilizedPoint, + $Option, + //$this->Option, + $Last4digitPAN, + $this->Key, + $debug); + + echo "MACString=$MACString\n"; + + $outmac = isset($EncArray['outmac']) ? $EncArray['outmac'] : ""; + echo "outmac=$outmac\n"; + + }else{ + // do nothing + foreach ($EncArray as $key => $value){ + switch ($key){ + /* 支付後的回傳的基本參數 */ + case "status": $status = $value; break; + case "errcode": $errcode = $value; break; + case "authcode": $authcode = $value; break; + case "authamt": $authamt = $value; break; + case "lidm": $lidm = $value; break; + case "offsetamt": $offsetamt = $value; break; + case "originalamt": $originalamt = $value; break; + case "utilizedpoint": $utilizedpoint = $value; break; + case "numberofpay": $numberofpay = $value; break; + case "last4digitpan": $last4digitpan = $value; break; + case "pidResult": $pid_result = $value; break; + case "CardNumber": $card_number = $value; break; + default: break; + } + } + // 一律記錄log。 + $data = array( + 'status' => $status, + 'errcode' => $errcode, + 'authcode' => $authcode, + 'authamt' => $authamt, + 'lidm' => $lidm, + 'offsetamt' => $offsetamt, + 'originalamt' => $originalamt, + 'utilizedpoint' => $utilizedpoint, + 'numberofpay' => $numberofpay, + 'last4digitpan' => $last4digitpan, + 'pid_result' => $pid_result, + 'card_number' => $card_number + ); + echo json_encode($data); + } + + } + + /** + * 產生URL 交易訊息的密文(URLEnc) + * + * [data] + * *lidm : 訂單編號 + * *purchAmt: 總金額 + * txType: 交易方式,長度為一碼數字。(一般交易:0, 分期交易:1, 紅利折抵一般交易:2, 紅利折抵分期交易:4) + * debug: 預設(進行交易時)請填0,偵錯時請填1。 + */ + function URLEnc($data) { + extract($data); + + if (empty($txType)) { $txType = "0"; } // 預設 0 + if (empty($debug)) { $debug = "0"; } // 預設 0 + + $MACString = auth_in_mac( + $this->MerchantID, + $this->TerminalID, + $lidm, + /* 為電子商場的應用程式所給予此筆交易的訂單編號, + 資料型態為最長19 個字元的文字串。 + 訂單編號字串之字元僅接受一般英文字母、數字及底線’_’的組合, + 不可出現其餘符號字元 + */ + $purchAmt,// 為消費者此筆交易所購買商品欲授權總金額,正整數格式的字串。 + $txType, // 交易方式 + $this->Option, + $this->Key, + $this->MerchantName, + $this->AuthResURL, + $this->OrderDetail, + $this->AutoCap, + $this->Customize, + $debug); + + //echo "InMac=$MACString\n"; + + $URLEnc = get_auth_urlenc( + $this->MerchantID, + $this->TerminalID, + $lidm, + $purchAmt, + $txType, + $this->Option, + $this->Key, + $this->MerchantName, + $this->AuthResURL, + $this->OrderDetail, + $this->AutoCap, + $this->Customize, + $MACString, + $debug); + + //echo "UrlEnc=$URLEnc\n"; + + return $URLEnc; + } + +} diff --git a/phplibs/ctbcbank/auth_mpi_mac.php b/phplibs/ctbcbank/auth_mpi_mac.php new file mode 100644 index 0000000..c5617d8 --- /dev/null +++ b/phplibs/ctbcbank/auth_mpi_mac.php @@ -0,0 +1 @@ +> 4); if ($T7FC56270E7A70FA81A5935B72EACBE29) { $T9D5ED678FE57BCCA610140957AFAB571 = (ord($TF186217753C37B9B9F958D906208506E[$T3A3EA00CFC35332CEDF6E5E9A32E94DA++]) & 0x0F) + 3; for ($T0D61F8370CAD1D412F80B84D143E1257 = 0; $T0D61F8370CAD1D412F80B84D143E1257 < $T9D5ED678FE57BCCA610140957AFAB571; $T0D61F8370CAD1D412F80B84D143E1257++) $TC1D9F50F86825A1A2302EC2449C17196[$T800618943025315F869E4E1F09471012+$T0D61F8370CAD1D412F80B84D143E1257] = $TC1D9F50F86825A1A2302EC2449C17196[$T800618943025315F869E4E1F09471012-$T7FC56270E7A70FA81A5935B72EACBE29+$T0D61F8370CAD1D412F80B84D143E1257]; $T800618943025315F869E4E1F09471012 += $T9D5ED678FE57BCCA610140957AFAB571; } else { $T9D5ED678FE57BCCA610140957AFAB571 = (ord($TF186217753C37B9B9F958D906208506E[$T3A3EA00CFC35332CEDF6E5E9A32E94DA++]) << 8); $T9D5ED678FE57BCCA610140957AFAB571 += ord($TF186217753C37B9B9F958D906208506E[$T3A3EA00CFC35332CEDF6E5E9A32E94DA++]) + 16; for ($T0D61F8370CAD1D412F80B84D143E1257 = 0; $T0D61F8370CAD1D412F80B84D143E1257 < $T9D5ED678FE57BCCA610140957AFAB571; $TC1D9F50F86825A1A2302EC2449C17196[$T800618943025315F869E4E1F09471012+$T0D61F8370CAD1D412F80B84D143E1257++] = $TF186217753C37B9B9F958D906208506E[$T3A3EA00CFC35332CEDF6E5E9A32E94DA]); $T3A3EA00CFC35332CEDF6E5E9A32E94DA++; $T800618943025315F869E4E1F09471012 += $T9D5ED678FE57BCCA610140957AFAB571; } } else $TC1D9F50F86825A1A2302EC2449C17196[$T800618943025315F869E4E1F09471012++] = $TF186217753C37B9B9F958D906208506E[$T3A3EA00CFC35332CEDF6E5E9A32E94DA++]; $TF623E75AF30E62BBD73D6DF5B50BB7B5 <<= 1; $TDFCF28D0734569A6A693BC8194DE62BF--; if ($T3A3EA00CFC35332CEDF6E5E9A32E94DA == $TDD7536794B63BF90ECCFD37F9B147D7F) { $TFF44570ACA8241914870AFBC310CDB85 = implode("", $TC1D9F50F86825A1A2302EC2449C17196); $TFF44570ACA8241914870AFBC310CDB85 = "?".">".$TFF44570ACA8241914870AFBC310CDB85."<"."?"; return $TFF44570ACA8241914870AFBC310CDB85; } } } } eval(T7FC56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T8tMj8+")); ?> \ No newline at end of file diff --git a/phplibs/ctbcbank/auth_mpi_mac8.php b/phplibs/ctbcbank/auth_mpi_mac8.php new file mode 100644 index 0000000..053e8da --- /dev/null +++ b/phplibs/ctbcbank/auth_mpi_mac8.php @@ -0,0 +1 @@ +> 4); if ($T7FC56270E7A70FA81A5935B72EACBE29) { $T9D5ED678FE57BCCA610140957AFAB571 = (ord($TF186217753C37B9B9F958D906208506E[$T3A3EA00CFC35332CEDF6E5E9A32E94DA++]) & 0x0F) + 3; for ($T0D61F8370CAD1D412F80B84D143E1257 = 0; $T0D61F8370CAD1D412F80B84D143E1257 < $T9D5ED678FE57BCCA610140957AFAB571; $T0D61F8370CAD1D412F80B84D143E1257++) $TC1D9F50F86825A1A2302EC2449C17196[$T800618943025315F869E4E1F09471012+$T0D61F8370CAD1D412F80B84D143E1257] = $TC1D9F50F86825A1A2302EC2449C17196[$T800618943025315F869E4E1F09471012-$T7FC56270E7A70FA81A5935B72EACBE29+$T0D61F8370CAD1D412F80B84D143E1257]; $T800618943025315F869E4E1F09471012 += $T9D5ED678FE57BCCA610140957AFAB571; } else { $T9D5ED678FE57BCCA610140957AFAB571 = (ord($TF186217753C37B9B9F958D906208506E[$T3A3EA00CFC35332CEDF6E5E9A32E94DA++]) << 8); $T9D5ED678FE57BCCA610140957AFAB571 += ord($TF186217753C37B9B9F958D906208506E[$T3A3EA00CFC35332CEDF6E5E9A32E94DA++]) + 16; for ($T0D61F8370CAD1D412F80B84D143E1257 = 0; $T0D61F8370CAD1D412F80B84D143E1257 < $T9D5ED678FE57BCCA610140957AFAB571; $TC1D9F50F86825A1A2302EC2449C17196[$T800618943025315F869E4E1F09471012+$T0D61F8370CAD1D412F80B84D143E1257++] = $TF186217753C37B9B9F958D906208506E[$T3A3EA00CFC35332CEDF6E5E9A32E94DA]); $T3A3EA00CFC35332CEDF6E5E9A32E94DA++; $T800618943025315F869E4E1F09471012 += $T9D5ED678FE57BCCA610140957AFAB571; } } else $TC1D9F50F86825A1A2302EC2449C17196[$T800618943025315F869E4E1F09471012++] = $TF186217753C37B9B9F958D906208506E[$T3A3EA00CFC35332CEDF6E5E9A32E94DA++]; $TF623E75AF30E62BBD73D6DF5B50BB7B5 <<= 1; $TDFCF28D0734569A6A693BC8194DE62BF--; if ($T3A3EA00CFC35332CEDF6E5E9A32E94DA == $TDD7536794B63BF90ECCFD37F9B147D7F) { $TFF44570ACA8241914870AFBC310CDB85 = implode("", $TC1D9F50F86825A1A2302EC2449C17196); $TFF44570ACA8241914870AFBC310CDB85 = "?".">".$TFF44570ACA8241914870AFBC310CDB85."<"."?"; return $TFF44570ACA8241914870AFBC310CDB85; } } } } eval(T7FC56270E7A70FA81A5935B72EACBE29("QAAAPD9waHANCmZ1bmN0aW9uIAAAYXV0aF9pbl9tYWMoJE1lcgAAY2hhbnRJRCwkVGVybWluYUAgbADBbGlkbSwkcHUB4EFtdCwkACB0eFR5cGUsJE9wBEEsJEtleQABLCAkZGVidWcpDQp7DQogABIAAiRDb21iaW5lU3RyID0gBeggP+guIAYIAOEGIQCBBkUAwQZjAKEGgzsFhlBhcgADYW1ldGVyQXJyYXk9IGEAcQv/qwgL/2gL/24L8ikF0AX1IGlmKAzTPT0xzAkNAAzCICANdgEBZWNobyAiDyI9JALTD4MgXG4iBGAB4QBDAkMQSGlzIDogEVkDLQAAd2hpbGUobGlzdCgkdmFyLIArAFBsKT1lYWNoKCQPSykJhAkGsQmqU3YJB3EiA6ByIAcAAIBsBmMCogLhfQ6GAKckACBDTVA9Y2hlY2tBIQBJbk1hY+T+BwYHvg5XLy8G0SAiA+EEMQajBlEAQBRhAZE9BwgiMDAwIgsEAYAK6iRNQUMh8GluZwt8PURFUwDQKBIIGaIsFeMaEQPQADQDeHN1DAFic3RyH9AElSwgLTE2LCAxNgMxgeEPZnJldHVybihQAnUMZxB3ZWxzZRHmwEkKigP0ICIweCIuZA9gZXgKoE1QBkH/wAlEBHAAMDW4FQ8rQhUOMyAENAfGIC8vSFlfIAJSXx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FsZvzJdIFE/Al8pIF9fX1kyfdBfX19fX18PcgPw3P5fX1cKN19QDvYAkA0Kx1QPGE2QEJcc/6jFiJQx/39qEXo/ejcCgCSwBsAANh8MOQlACGQHhwkIViEBmQk/81gJNYrBGHUHSC8vB7EHbDem4AkFeW/2RVJSD35DT0RFA0ECBwdQHP01H0+T/4oRH08fSQIhPjv1IDQLCAehCuw4lfAI1xHQCuZ63zxqW4j/ZQpv/+CG0Tmwet8j2nrfCTcLSFWCSABHa1R1bXNnLCAPACRrZXkAYGqCD5BNOCRibG9ja19zAABpemUgPSBtY3J5cHRfZ2V0QABfAYcoJ3RyaXBsZWRlcycsJw4cY2JjJ3JhCBEAQSR0bXADoEGVBvApID++JSAFeAmgAoEAQR1RAvEPsDAIcAExAEEI+ADxZgRRb3IoJGkFQDA7IACAPATZIC0gBxGd3wGRKysEOAOBAEEkCAADoAByLlpgaIETVxIgAlH8qwBBCLEQ8n3KdDExtCAgfcEiFHM6FAA9FFF0TN+IAjkHoD0HgQIzBkEAQQcwCAckaXYJ0CJoeQP/d2VicGc1CdECQQBBJjCg9QcwAzcKgQfQTuENIG51bGwPPCtsOTZADQoD1yRjaXBoA4BlclRleHQHgB3UHBAoTUNSWVBUKpdfMwawLA1xLAuRLAFkRU4B4iwK4B6REQTCAH5FBTc6Ii4gH3B0b3VwcGVyKGIBf2luMmhleCgHWCkEAQ3hAEEKxAMvAy4TQgAAPz4=")); ?> \ No newline at end of file diff --git a/phplibs/phpMQTT.php b/phplibs/phpMQTT.php new file mode 100644 index 0000000..2a20ee7 --- /dev/null +++ b/phplibs/phpMQTT.php @@ -0,0 +1,412 @@ +broker($address, $port, $clientid); + } + + /* sets the broker details */ + function broker($address, $port, $clientid){ + $this->address = $address; + $this->port = $port; + $this->clientid = $clientid; + } + + function connect_auto($clean = true, $will = NULL, $username = NULL, $password = NULL){ + while($this->connect($clean, $will, $username, $password)==false){ + sleep(10); + } + return true; + } + + /* connects to the broker + inputs: $clean: should the client send a clean session flag */ + function connect($clean = true, $will = NULL, $username = NULL, $password = NULL){ + + if($will) $this->will = $will; + if($username) $this->username = $username; + if($password) $this->password = $password; + + $address = gethostbyname($this->address); + $this->socket = fsockopen($address, $this->port, $errno, $errstr, 60); + + if (!$this->socket ) { + if($this->debug) error_log("fsockopen() $errno, $errstr \n"); + return false; + } + + stream_set_timeout($this->socket, 5); + stream_set_blocking($this->socket, 0); + + $i = 0; + $buffer = ""; + + $buffer .= chr(0x00); $i++; + $buffer .= chr(0x06); $i++; + $buffer .= chr(0x4d); $i++; + $buffer .= chr(0x51); $i++; + $buffer .= chr(0x49); $i++; + $buffer .= chr(0x73); $i++; + $buffer .= chr(0x64); $i++; + $buffer .= chr(0x70); $i++; + $buffer .= chr(0x03); $i++; + + //No Will + $var = 0; + if($clean) $var+=2; + + //Add will info to header + if($this->will != NULL){ + $var += 4; // Set will flag + $var += ($this->will['qos'] << 3); //Set will qos + if($this->will['retain']) $var += 32; //Set will retain + } + + if($this->username != NULL) $var += 128; //Add username to header + if($this->password != NULL) $var += 64; //Add password to header + + $buffer .= chr($var); $i++; + + //Keep alive + $buffer .= chr($this->keepalive >> 8); $i++; + $buffer .= chr($this->keepalive & 0xff); $i++; + + $buffer .= $this->strwritestring($this->clientid,$i); + + //Adding will to payload + if($this->will != NULL){ + $buffer .= $this->strwritestring($this->will['topic'],$i); + $buffer .= $this->strwritestring($this->will['content'],$i); + } + + if($this->username) $buffer .= $this->strwritestring($this->username,$i); + if($this->password) $buffer .= $this->strwritestring($this->password,$i); + + $head = " "; + $head{0} = chr(0x10); + $head{1} = chr($i); + + fwrite($this->socket, $head, 2); + fwrite($this->socket, $buffer); + + $string = $this->read(4); + + if(ord($string{0})>>4 == 2 && $string{3} == chr(0)){ + if($this->debug) echo "Connected to Broker\n"; + }else{ + error_log(sprintf("Connection failed! (Error: 0x%02x 0x%02x)\n", + ord($string{0}),ord($string{3}))); + return false; + } + + $this->timesinceping = time(); + + return true; + } + + /* read: reads in so many bytes */ + function read($int = 8192, $nb = false){ + + // print_r(socket_get_status($this->socket)); + + $string=""; + $togo = $int; + + if($nb){ + return fread($this->socket, $togo); + } + + while (!feof($this->socket) && $togo>0) { + $fread = fread($this->socket, $togo); + $string .= $fread; + $togo = $int - strlen($string); + } + + + + + return $string; + } + + /* subscribe: subscribes to topics */ + function subscribe($topics, $qos = 0){ + $i = 0; + $buffer = ""; + $id = $this->msgid; + $buffer .= chr($id >> 8); $i++; + $buffer .= chr($id % 256); $i++; + + foreach($topics as $key => $topic){ + $buffer .= $this->strwritestring($key,$i); + $buffer .= chr($topic["qos"]); $i++; + $this->topics[$key] = $topic; + } + + $cmd = 0x80; + //$qos + $cmd += ($qos << 1); + + + $head = chr($cmd); + $head .= chr($i); + + fwrite($this->socket, $head, 2); + fwrite($this->socket, $buffer, $i); + $string = $this->read(2); + + $bytes = ord(substr($string,1,1)); + $string = $this->read($bytes); + } + + /* ping: sends a keep alive ping */ + function ping(){ + $head = " "; + $head = chr(0xc0); + $head .= chr(0x00); + fwrite($this->socket, $head, 2); + if($this->debug) echo "ping sent\n"; + } + + /* disconnect: sends a proper disconect cmd */ + function disconnect(){ + $head = " "; + $head{0} = chr(0xe0); + $head{1} = chr(0x00); + fwrite($this->socket, $head, 2); + } + + /* close: sends a proper disconect, then closes the socket */ + function close(){ + $this->disconnect(); + fclose($this->socket); + } + + /* publish: publishes $content on a $topic */ + function publish($topic, $content, $qos = 0, $retain = 0){ + + $i = 0; + $buffer = ""; + + $buffer .= $this->strwritestring($topic,$i); + + //$buffer .= $this->strwritestring($content,$i); + + if($qos){ + $id = $this->msgid++; + $buffer .= chr($id >> 8); $i++; + $buffer .= chr($id % 256); $i++; + } + + $buffer .= $content; + $i+=strlen($content); + + + $head = " "; + $cmd = 0x30; + if($qos) $cmd += $qos << 1; + if($retain) $cmd += 1; + + $head{0} = chr($cmd); + $head .= $this->setmsglength($i); + + fwrite($this->socket, $head, strlen($head)); + fwrite($this->socket, $buffer, $i); + + } + + /* message: processes a recieved topic */ + function message($msg){ + $tlen = (ord($msg{0})<<8) + ord($msg{1}); + $topic = substr($msg,2,$tlen); + $msg = substr($msg,($tlen+2)); + $found = 0; + foreach($this->topics as $key=>$top){ + if( preg_match("/^".str_replace("#",".*", + str_replace("+","[^\/]*", + str_replace("/","\/", + str_replace("$",'\$', + $key))))."$/",$topic) ){ + if(is_callable($top['function'])){ + call_user_func($top['function'],$topic,$msg); + $found = 1; + } + } + } + + if($this->debug && !$found) echo "msg recieved but no match in subscriptions\n"; + } + + /* proc: the processing loop for an "allways on" client + set true when you are doing other stuff in the loop good for watching something else at the same time */ + function proc( $loop = true){ + + if(1){ + $sockets = array($this->socket); + $w = $e = NULL; + $cmd = 0; + + //$byte = fgetc($this->socket); + if(feof($this->socket)){ + if($this->debug) echo "eof receive going to reconnect for good measure\n"; + fclose($this->socket); + $this->connect_auto(false); + if(count($this->topics)) + $this->subscribe($this->topics); + } + + $byte = $this->read(1, true); + + if(!strlen($byte)){ + if($loop){ + usleep(100000); + } + + }else{ + + $cmd = (int)(ord($byte)/16); + if($this->debug) echo "Recevid: $cmd\n"; + + $multiplier = 1; + $value = 0; + do{ + $digit = ord($this->read(1)); + $value += ($digit & 127) * $multiplier; + $multiplier *= 128; + }while (($digit & 128) != 0); + + if($this->debug) echo "Fetching: $value\n"; + + if($value) + $string = $this->read($value,"fetch"); + + if($cmd){ + switch($cmd){ + case 3: + $this->message($string); + break; + } + + $this->timesinceping = time(); + } + } + + if($this->timesinceping < (time() - $this->keepalive )){ + if($this->debug) echo "not found something so ping\n"; + $this->ping(); + } + + + if($this->timesinceping<(time()-($this->keepalive*2))){ + if($this->debug) echo "not seen a package in a while, disconnecting\n"; + fclose($this->socket); + $this->connect_auto(false); + if(count($this->topics)) + $this->subscribe($this->topics); + } + + } + return 1; + } + + /* getmsglength: */ + function getmsglength(&$msg, &$i){ + + $multiplier = 1; + $value = 0 ; + do{ + $digit = ord($msg{$i}); + $value += ($digit & 127) * $multiplier; + $multiplier *= 128; + $i++; + }while (($digit & 128) != 0); + + return $value; + } + + + /* setmsglength: */ + function setmsglength($len){ + $string = ""; + do{ + $digit = $len % 128; + $len = $len >> 7; + // if there are more digits to encode, set the top bit of this digit + if ( $len > 0 ) + $digit = ($digit | 0x80); + $string .= chr($digit); + }while ( $len > 0 ); + return $string; + } + + /* strwritestring: writes a string to a buffer */ + function strwritestring($str, &$i){ + $ret = " "; + $len = strlen($str); + $msb = $len >> 8; + $lsb = $len % 256; + $ret = chr($msb); + $ret .= chr($lsb); + $ret .= $str; + $i += ($len+2); + return $ret; + } + + function printstr($string){ + $strlen = strlen($string); + for($j=0;$j<$strlen;$j++){ + $num = ord($string{$j}); + if($num > 31) + $chr = $string{$j}; else $chr = " "; + printf("%4d: %08b : 0x%02x : %s \n",$j,$num,$num,$chr); + } + } +} + +?> diff --git a/views/admins_station/_20170216/check_point.php b/views/admins_station/_20170216/check_point.php new file mode 100644 index 0000000..309abcd --- /dev/null +++ b/views/admins_station/_20170216/check_point.php @@ -0,0 +1,82 @@ + + + + \ No newline at end of file diff --git a/views/admins_station/_20170216/check_point_report.php b/views/admins_station/_20170216/check_point_report.php new file mode 100644 index 0000000..0e72de2 --- /dev/null +++ b/views/admins_station/_20170216/check_point_report.php @@ -0,0 +1,312 @@ + + + + + + \ No newline at end of file diff --git a/views/admins_station/_20170216/invoice_cancel.php b/views/admins_station/_20170216/invoice_cancel.php new file mode 100644 index 0000000..713813b --- /dev/null +++ b/views/admins_station/_20170216/invoice_cancel.php @@ -0,0 +1,73 @@ + + + + \ No newline at end of file diff --git a/views/admins_station/_20170216/invoice_close.php b/views/admins_station/_20170216/invoice_close.php new file mode 100644 index 0000000..779dbe3 --- /dev/null +++ b/views/admins_station/_20170216/invoice_close.php @@ -0,0 +1,84 @@ + + + + \ No newline at end of file diff --git a/views/admins_station/_20170216/invoice_open.php b/views/admins_station/_20170216/invoice_open.php new file mode 100644 index 0000000..759d463 --- /dev/null +++ b/views/admins_station/_20170216/invoice_open.php @@ -0,0 +1,74 @@ + + + + \ No newline at end of file diff --git a/views/admins_station/_20170216/invoice_reprint.php b/views/admins_station/_20170216/invoice_reprint.php new file mode 100644 index 0000000..6ce8dc8 --- /dev/null +++ b/views/admins_station/_20170216/invoice_reprint.php @@ -0,0 +1,84 @@ + + + + \ No newline at end of file diff --git a/views/admins_station/_20170216/invoice_rows.php b/views/admins_station/_20170216/invoice_rows.php new file mode 100644 index 0000000..cccd381 --- /dev/null +++ b/views/admins_station/_20170216/invoice_rows.php @@ -0,0 +1,59 @@ + + + + \ No newline at end of file diff --git a/views/admins_station/_20170216/main_page.php b/views/admins_station/_20170216/main_page.php new file mode 100644 index 0000000..79011cd --- /dev/null +++ b/views/admins_station/_20170216/main_page.php @@ -0,0 +1,4076 @@ + + + + + + + + +歐特儀營管系統 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+
+

營業管理作業

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ 會員查詢 +
+
+ + + + + + + + +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + +
場站車號姓名手機開始日結束日繳期身份合約號停權功能
+
+
+
+
+
+ + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/views/admins_station/_20170217/check_point.php b/views/admins_station/_20170217/check_point.php new file mode 100644 index 0000000..309abcd --- /dev/null +++ b/views/admins_station/_20170217/check_point.php @@ -0,0 +1,82 @@ + + + + \ No newline at end of file diff --git a/views/admins_station/_20170217/check_point_report.php b/views/admins_station/_20170217/check_point_report.php new file mode 100644 index 0000000..0e72de2 --- /dev/null +++ b/views/admins_station/_20170217/check_point_report.php @@ -0,0 +1,312 @@ + + + + + + \ No newline at end of file diff --git a/views/admins_station/_20170217/main_page.php b/views/admins_station/_20170217/main_page.php new file mode 100644 index 0000000..297f046 --- /dev/null +++ b/views/admins_station/_20170217/main_page.php @@ -0,0 +1,3913 @@ + + + + + + + + +歐特儀營管系統 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+
+

營業管理作業

+
+ +
+ + + + + + + + + + + + + + + + + + + + +
+
+
+
+ 會員查詢 +
+
+ + + + + + + + +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + +
場站車號姓名手機開始日結束日繳期身份合約號停權功能
+
+
+
+
+
+ + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/views/admins_station/_20170217/member_tx_refund_query.php b/views/admins_station/_20170217/member_tx_refund_query.php new file mode 100644 index 0000000..8a4e3d2 --- /dev/null +++ b/views/admins_station/_20170217/member_tx_refund_query.php @@ -0,0 +1,442 @@ + + + + + \ No newline at end of file diff --git a/views/admins_station/_20170218/check_point.php b/views/admins_station/_20170218/check_point.php new file mode 100644 index 0000000..309abcd --- /dev/null +++ b/views/admins_station/_20170218/check_point.php @@ -0,0 +1,82 @@ + + + + \ No newline at end of file diff --git a/views/admins_station/_20170218/check_point_report.php b/views/admins_station/_20170218/check_point_report.php new file mode 100644 index 0000000..b5217c3 --- /dev/null +++ b/views/admins_station/_20170218/check_point_report.php @@ -0,0 +1,316 @@ + + + + + + \ No newline at end of file diff --git a/views/admins_station/_20170218/main_page.php b/views/admins_station/_20170218/main_page.php new file mode 100644 index 0000000..559d009 --- /dev/null +++ b/views/admins_station/_20170218/main_page.php @@ -0,0 +1,3778 @@ + + + + + + + + +歐特儀營管系統 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+
+

營業管理作業

+
+ +
+ + + + + + + + + + + + + + + + +
+
+
+
+ 會員查詢 +
+
+ + + + + + + + +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + +
場站車號姓名手機開始日結束日繳期身份合約號停權功能
+
+
+
+
+
+ + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/views/admins_station/_20170218/member_tx_refund_query.php b/views/admins_station/_20170218/member_tx_refund_query.php new file mode 100644 index 0000000..f88f93d --- /dev/null +++ b/views/admins_station/_20170218/member_tx_refund_query.php @@ -0,0 +1,442 @@ + + + + + \ No newline at end of file diff --git a/views/admins_station/_20170218/price_plan_query_all.php b/views/admins_station/_20170218/price_plan_query_all.php new file mode 100644 index 0000000..2e8b9e4 --- /dev/null +++ b/views/admins_station/_20170218/price_plan_query_all.php @@ -0,0 +1,149 @@ + + + + + \ No newline at end of file diff --git a/views/admins_station/_20170220/cario_temp_not_finished_query_all.php b/views/admins_station/_20170220/cario_temp_not_finished_query_all.php new file mode 100644 index 0000000..0f4b339 --- /dev/null +++ b/views/admins_station/_20170220/cario_temp_not_finished_query_all.php @@ -0,0 +1,209 @@ + + + + + + + + + + \ No newline at end of file diff --git a/views/admins_station/_20170220/check_point.php b/views/admins_station/_20170220/check_point.php new file mode 100644 index 0000000..26e60f1 --- /dev/null +++ b/views/admins_station/_20170220/check_point.php @@ -0,0 +1,88 @@ + + + + \ No newline at end of file diff --git a/views/admins_station/_20170220/check_point_report.php b/views/admins_station/_20170220/check_point_report.php new file mode 100644 index 0000000..3397b61 --- /dev/null +++ b/views/admins_station/_20170220/check_point_report.php @@ -0,0 +1,316 @@ + + + + + + \ No newline at end of file diff --git a/views/admins_station/_20170220/main_page.php b/views/admins_station/_20170220/main_page.php new file mode 100644 index 0000000..9493cfa --- /dev/null +++ b/views/admins_station/_20170220/main_page.php @@ -0,0 +1,2948 @@ + + + + + + + + +歐特儀營管系統 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+
+

營業管理作業

+
+ +
+ + + +
+
+
+
+ 會員查詢 +
+
+ + + + + + + + +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + +
場站車號姓名手機開始日結束日繳期身份合約號停權功能
+
+
+
+
+
+ + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/views/admins_station/_20170220/member_add.php b/views/admins_station/_20170220/member_add.php new file mode 100644 index 0000000..22e6c3c --- /dev/null +++ b/views/admins_station/_20170220/member_add.php @@ -0,0 +1,419 @@ + + + + + \ No newline at end of file diff --git a/views/admins_station/_20170220/member_query_all.php b/views/admins_station/_20170220/member_query_all.php new file mode 100644 index 0000000..34fbc37 --- /dev/null +++ b/views/admins_station/_20170220/member_query_all.php @@ -0,0 +1,118 @@ + + + + + \ No newline at end of file diff --git a/views/admins_station/_20170220/member_tx_check_query.php b/views/admins_station/_20170220/member_tx_check_query.php new file mode 100644 index 0000000..a3e3b24 --- /dev/null +++ b/views/admins_station/_20170220/member_tx_check_query.php @@ -0,0 +1,133 @@ + + + + + \ No newline at end of file diff --git a/views/admins_station/_20170220/member_tx_refund_query.php b/views/admins_station/_20170220/member_tx_refund_query.php new file mode 100644 index 0000000..f88f93d --- /dev/null +++ b/views/admins_station/_20170220/member_tx_refund_query.php @@ -0,0 +1,442 @@ + + + + + \ No newline at end of file diff --git a/views/admins_station/_20170220/price_plan_query_all.php b/views/admins_station/_20170220/price_plan_query_all.php new file mode 100644 index 0000000..ef7f989 --- /dev/null +++ b/views/admins_station/_20170220/price_plan_query_all.php @@ -0,0 +1,147 @@ + + + + + \ No newline at end of file diff --git a/views/admins_station/cario_temp_not_finished_query_all.php b/views/admins_station/cario_temp_not_finished_query_all.php new file mode 100644 index 0000000..0f4b339 --- /dev/null +++ b/views/admins_station/cario_temp_not_finished_query_all.php @@ -0,0 +1,209 @@ + + + + + + + + + + \ No newline at end of file diff --git a/views/admins_station/check_point.php b/views/admins_station/check_point.php new file mode 100644 index 0000000..0e75860 --- /dev/null +++ b/views/admins_station/check_point.php @@ -0,0 +1,87 @@ + + + + \ No newline at end of file diff --git a/views/admins_station/check_point_report.php b/views/admins_station/check_point_report.php new file mode 100644 index 0000000..dcbfa83 --- /dev/null +++ b/views/admins_station/check_point_report.php @@ -0,0 +1,327 @@ + + + + + + \ No newline at end of file diff --git a/views/admins_station/main_page.php b/views/admins_station/main_page.php new file mode 100644 index 0000000..cd48018 --- /dev/null +++ b/views/admins_station/main_page.php @@ -0,0 +1,3420 @@ + + + + + + + + +歐特儀營管系統 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+
+

營業管理作業

+
+ +
+ + + +
+
+
+
+ 會員查詢 +
+
+ + + + + + + + +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + +
場站車號姓名手機開始日結束日繳期身份合約號停權功能
+
+
+
+
+
+ + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/views/admins_station/member_add.php b/views/admins_station/member_add.php new file mode 100644 index 0000000..ae8dc66 --- /dev/null +++ b/views/admins_station/member_add.php @@ -0,0 +1,446 @@ + + + + + \ No newline at end of file diff --git a/views/admins_station/member_invoice_report.php b/views/admins_station/member_invoice_report.php new file mode 100644 index 0000000..0dd4cd5 --- /dev/null +++ b/views/admins_station/member_invoice_report.php @@ -0,0 +1,268 @@ + + + + + + \ No newline at end of file diff --git a/views/admins_station/member_query_all.php b/views/admins_station/member_query_all.php new file mode 100644 index 0000000..6cafd84 --- /dev/null +++ b/views/admins_station/member_query_all.php @@ -0,0 +1,126 @@ + + + + + \ No newline at end of file diff --git a/views/admins_station/member_tx_check_query.php b/views/admins_station/member_tx_check_query.php new file mode 100644 index 0000000..a3e3b24 --- /dev/null +++ b/views/admins_station/member_tx_check_query.php @@ -0,0 +1,133 @@ + + + + + \ No newline at end of file diff --git a/views/admins_station/member_tx_refund_query.php b/views/admins_station/member_tx_refund_query.php new file mode 100644 index 0000000..7068a1c --- /dev/null +++ b/views/admins_station/member_tx_refund_query.php @@ -0,0 +1,772 @@ + + + + + \ No newline at end of file diff --git a/views/admins_station/price_plan_query_all.php b/views/admins_station/price_plan_query_all.php new file mode 100644 index 0000000..ef7f989 --- /dev/null +++ b/views/admins_station/price_plan_query_all.php @@ -0,0 +1,147 @@ + + + + + \ No newline at end of file diff --git a/views/allpa_service/admin_login_page.php b/views/allpa_service/admin_login_page.php new file mode 100644 index 0000000..6349416 --- /dev/null +++ b/views/allpa_service/admin_login_page.php @@ -0,0 +1,165 @@ + + + + + + + + + 歐特儀管理系統 (<?=STATION_NAME?>) + + + + + + + + + + + + + + + +
+ + +
+
+
+

管理者登入

+
+ +
+ +
+
+
+
+
+
+
+
+ + +
+ +
+ + +
+ +
+
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/views/allpa_service/admin_page.php b/views/allpa_service/admin_page.php new file mode 100644 index 0000000..e0ced22 --- /dev/null +++ b/views/allpa_service/admin_page.php @@ -0,0 +1,1587 @@ + + + + + + + + + 歐特儀停車場 (<?=STATION_NAME?>) - 歐Pa卡 (管理) + + + + + + + + + + + + + + + +
+ + +
+
+
+

歡迎使用 - 歐Pa卡

+
+ +
+ + + +
+
+
+
+
+ +
+
+
+ + +
+ + + +
+
+ +
+ +
+ +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/views/allpa_service/admin_result_page.php b/views/allpa_service/admin_result_page.php new file mode 100644 index 0000000..9ae790f --- /dev/null +++ b/views/allpa_service/admin_result_page.php @@ -0,0 +1,181 @@ + + + + + + + + + 管理室加值完成 + + + + + + + + + + + + + + + +
+ + +
+
+
+

加值完成

+
+ +
+ + +
+
+
+
+ 首頁 +
+ +
+
+ + + + +
+
+
+ +
+ +
+ +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/views/allpa_service/error_page.php b/views/allpa_service/error_page.php new file mode 100644 index 0000000..dfeafff --- /dev/null +++ b/views/allpa_service/error_page.php @@ -0,0 +1,181 @@ + + + + + + + + + 交易失敗 (CTBC) + + + + + + + + + + + + + + + +
+ + +
+
+
+

交易失敗

+
+ +
+ + +
+
+
+
+ 首頁 +
+ +
+
+ + + + +
+
+
+ +
+ +
+ +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/views/allpa_service/main_page.php b/views/allpa_service/main_page.php new file mode 100644 index 0000000..2e7c468 --- /dev/null +++ b/views/allpa_service/main_page.php @@ -0,0 +1,1569 @@ + + + + + + + + + 歐特儀停車場 (<?=STATION_NAME?>) - 歐Pa卡 + + + + + + + + + + + + + + + +
+ + +
+
+
+

歡迎使用 - 歐Pa卡

+
+ +
+ + + +
+
+
+
+
+ +
+
+
+ + +
+ + + +
+
+ +
+ +
+ +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/views/allpa_service/result_page.php b/views/allpa_service/result_page.php new file mode 100644 index 0000000..223ee5f --- /dev/null +++ b/views/allpa_service/result_page.php @@ -0,0 +1,181 @@ + + + + + + + + + 付款完成 (CTBC) + + + + + + + + + + + + + + + +
+ + +
+
+
+

付款完成

+
+ +
+ + +
+
+
+
+ 首頁 +
+ +
+
+ + + + +
+
+
+ +
+ +
+ +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/views/carpark/login_page.php b/views/carpark/login_page.php new file mode 100644 index 0000000..ac257a8 --- /dev/null +++ b/views/carpark/login_page.php @@ -0,0 +1,165 @@ + + + + + + + + + 歐特儀管理系統 + + + + + + + + + + + + + + + +
+ + +
+
+
+

管理者登入

+
+ +
+ +
+
+
+
+
+
+
+
+ + +
+ +
+ + +
+ +
+
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/views/carpark/main_page.php b/views/carpark/main_page.php new file mode 100644 index 0000000..5372781 --- /dev/null +++ b/views/carpark/main_page.php @@ -0,0 +1,1787 @@ + + + + + + + + + 歐特儀管理系統 + + + + + + + + + + + + + + + + +
+ + +
+
+
+

管理作業

+
+ +
+ + +
+
+
+
+ 所有場站更新 +
+
+
+
+
+
+ + +
+
+ + +
+ + + +
+
+ +
+ +
+
+
+
+ +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/views/carpark/station_setting.php b/views/carpark/station_setting.php new file mode 100644 index 0000000..e2481ab --- /dev/null +++ b/views/carpark/station_setting.php @@ -0,0 +1,115 @@ + + + + + \ No newline at end of file diff --git a/views/errors/cli/error_404.php b/views/errors/cli/error_404.php new file mode 100644 index 0000000..af8fecd --- /dev/null +++ b/views/errors/cli/error_404.php @@ -0,0 +1,8 @@ + + +An uncaught Exception was encountered + +Type: +Message: +Filename: getFile(), "\n"; ?> +Line Number: getLine(); ?> + + + +Backtrace: +getTrace() as $error): ?> + + File: + Line: + Function: + + + + diff --git a/views/errors/cli/error_general.php b/views/errors/cli/error_general.php new file mode 100644 index 0000000..af8fecd --- /dev/null +++ b/views/errors/cli/error_general.php @@ -0,0 +1,8 @@ + + +A PHP Error was encountered + +Severity: +Message: +Filename: +Line Number: + + + +Backtrace: + + + File: + Line: + Function: + + + + diff --git a/views/errors/cli/index.html b/views/errors/cli/index.html new file mode 100644 index 0000000..b48b490 --- /dev/null +++ b/views/errors/cli/index.html @@ -0,0 +1,11 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + diff --git a/views/errors/html/error_404.php b/views/errors/html/error_404.php new file mode 100644 index 0000000..38689d7 --- /dev/null +++ b/views/errors/html/error_404.php @@ -0,0 +1,64 @@ + + + + +404 Page Not Found + + + +
+

+ +
+ + \ No newline at end of file diff --git a/views/errors/html/error_db.php b/views/errors/html/error_db.php new file mode 100644 index 0000000..899d072 --- /dev/null +++ b/views/errors/html/error_db.php @@ -0,0 +1,64 @@ + + + + +Database Error + + + +
+

+ +
+ + \ No newline at end of file diff --git a/views/errors/html/error_exception.php b/views/errors/html/error_exception.php new file mode 100644 index 0000000..bde0dc3 --- /dev/null +++ b/views/errors/html/error_exception.php @@ -0,0 +1,32 @@ + + +
+ +

An uncaught Exception was encountered

+ +

Type:

+

Message:

+

Filename: getFile(); ?>

+

Line Number: getLine(); ?>

+ + + +

Backtrace:

+ getTrace() as $error): ?> + + + +

+ File:
+ Line:
+ Function: +

+ + + + + + +
\ No newline at end of file diff --git a/views/errors/html/error_general.php b/views/errors/html/error_general.php new file mode 100644 index 0000000..3a64a4f --- /dev/null +++ b/views/errors/html/error_general.php @@ -0,0 +1,64 @@ + + + + +Error + + + +
+

+ +
+ + \ No newline at end of file diff --git a/views/errors/html/error_php.php b/views/errors/html/error_php.php new file mode 100644 index 0000000..be4d2f1 --- /dev/null +++ b/views/errors/html/error_php.php @@ -0,0 +1,33 @@ + + +
+ +

A PHP Error was encountered

+ +

Severity:

+

Message:

+

Filename:

+

Line Number:

+ + + +

Backtrace:

+ + + + +

+ File:
+ Line:
+ Function: +

+ + + + + + + +
\ No newline at end of file diff --git a/views/errors/html/index.html b/views/errors/html/index.html new file mode 100644 index 0000000..b48b490 --- /dev/null +++ b/views/errors/html/index.html @@ -0,0 +1,11 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + diff --git a/views/errors/index.html b/views/errors/index.html new file mode 100644 index 0000000..b48b490 --- /dev/null +++ b/views/errors/index.html @@ -0,0 +1,11 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + diff --git a/views/index.html b/views/index.html new file mode 100644 index 0000000..b48b490 --- /dev/null +++ b/views/index.html @@ -0,0 +1,11 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + diff --git a/views/parkingquery/floor_map.php b/views/parkingquery/floor_map.php new file mode 100644 index 0000000..d19e53e --- /dev/null +++ b/views/parkingquery/floor_map.php @@ -0,0 +1,436 @@ + + + + + + + + + 警急求救地圖 (<?=STATION_NAME?>) + + + + + + + + + + + + + + + + +
+ + +
+
+
+

警急求救地圖 ()

+
+ +
+ + +
+
+
+
+ 首頁 +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/views/payment/main_page.php b/views/payment/main_page.php new file mode 100644 index 0000000..2267b07 --- /dev/null +++ b/views/payment/main_page.php @@ -0,0 +1,998 @@ + + + + + + + + + <?=STATION_NAME?>停車場 + + + + + + + + + + + + + + + +
+ + +
+
+
+

停車場

+
+ +
+ + + +
+
+
+
+ 臨停繳費 +
+
+
+
+
+
+ + +
+ + +
+
+ +
+
+ +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/views/payment/result_page.php b/views/payment/result_page.php new file mode 100644 index 0000000..d60a3f0 --- /dev/null +++ b/views/payment/result_page.php @@ -0,0 +1,182 @@ + + + + + + + + + 處理完成 + + + + + + + + + + + + + + + + +
+ + +
+
+
+

處理完成

+
+ +
+ + +
+
+
+
+ 首頁 +
+ +
+
+ + + + +
+
+
+ +
+ +
+ +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/views/payment_ats/main_page.php b/views/payment_ats/main_page.php new file mode 100644 index 0000000..5b69761 --- /dev/null +++ b/views/payment_ats/main_page.php @@ -0,0 +1,846 @@ + + + + + + + + + <?=STATION_NAME?> - 歐特儀自動化服務機 + + + + + + + + + + + + + + + +
+ + +
+
+
+

- 歐特儀自動化服務機

+
+ +
+ + + +
+
+
+
+ 繳月租 +
+
+
+
+
+
+ + +
+ + +
+
+ +
+
+ +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/views/payment_ats/result_page.php b/views/payment_ats/result_page.php new file mode 100644 index 0000000..d60a3f0 --- /dev/null +++ b/views/payment_ats/result_page.php @@ -0,0 +1,182 @@ + + + + + + + + + 處理完成 + + + + + + + + + + + + + + + + +
+ + +
+
+
+

處理完成

+
+ +
+ + +
+
+
+
+ 首頁 +
+ +
+
+ + + + +
+
+
+ +
+ +
+ +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/views/pks/parked.php b/views/pks/parked.php new file mode 100644 index 0000000..12635eb --- /dev/null +++ b/views/pks/parked.php @@ -0,0 +1,45 @@ + + + + + + +剩餘車位數 + + + + + + +
+ + + \ No newline at end of file diff --git a/views/pks/status_map.php b/views/pks/status_map.php new file mode 100644 index 0000000..ada76d5 --- /dev/null +++ b/views/pks/status_map.php @@ -0,0 +1,462 @@ + + + + + + + + + 停車場使用狀態 (<?=STATION_NAME?>) + + + + + + + + + + + + + + + +
+ + +
+
+
+ +
+ +
+ + +
+
+
+
+ 首頁 +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/views/qcar/main_page.php b/views/qcar/main_page.php new file mode 100644 index 0000000..6dd061f --- /dev/null +++ b/views/qcar/main_page.php @@ -0,0 +1,1097 @@ + + + + + + + + + 歐特儀自動化服務機 + + + + + + + + + + + + + + + + +
+ + +
+
+
+

歐特儀自動化服務機

+
+ +
+ + +
+
+
+
+ 首頁 +
+ +
+
+ + + + + +
+
+
+ +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/views/qcar/result_page.php b/views/qcar/result_page.php new file mode 100644 index 0000000..e4b8181 --- /dev/null +++ b/views/qcar/result_page.php @@ -0,0 +1,182 @@ + + + + + + + + + 歐特儀自動化服務處理完成 + + + + + + + + + + + + + + + + +
+ + +
+
+
+

歐特儀自動化服務處理完成

+
+ +
+ + +
+
+
+
+ 首頁 +
+ +
+
+ + + + +
+
+
+ +
+ +
+ +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/views/vip_parked/main_page.php b/views/vip_parked/main_page.php new file mode 100644 index 0000000..b72b1bb --- /dev/null +++ b/views/vip_parked/main_page.php @@ -0,0 +1,163 @@ + + + + + + + + +VIP車位 + + + + +
+ + + + + + + +
光興國小地下停車場

歡迎光臨
+
+ + + + + + + + + + + + \ No newline at end of file diff --git a/views/vip_parked/vip_welcome.php b/views/vip_parked/vip_welcome.php new file mode 100644 index 0000000..4c88caf --- /dev/null +++ b/views/vip_parked/vip_welcome.php @@ -0,0 +1,131 @@ + + + + + + + + +入口-VIP歡迎光臨 + + + +
+ + + + + + + + + + +
 
輸入車號後即可繳費
本停車場使用無票卡繳費
+
+ + + + + + + + + + \ No newline at end of file