protected function checkRequest() { if (!DataVerifier::isValidDate($this->request["BatchDate"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1100, "订单日期不合法!"); } if (!DataVerifier::isValidTime($this->request["BatchTime"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1100, "订单时间不合法!"); } if ($this->request["SerialNumber"] == null) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1100, "未设定批量编号!"); } if (strlen($this->request["SerialNumber"]) > 30) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "批量编号不合法!"); } }
protected function checkRequest() { if (!DataVerifier::isValidString($this->request["OrderNo"], ILength::ORDERID_LEN)) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1101, "交易编号不合法"); } if (!DataVerifier::isValidDate($this->request["RequestDate"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "订单日期格式不正确"); } if (!DataVerifier::isValidTime($this->request["RequestTime"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "订单时间格式不正确"); } if ($this->request["AgentSignNo"] == null) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "设置签约协议号不合法"); } }
protected function checkRequest() { //1.验证是否为空 if (!DataVerifier::isValidString($this->request["OrderNo"], ILength::ORDERID_LEN)) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1101, "交易编号长度不合法"); } if (!DataVerifier::isValidBankCardNo($this->request["CardNo"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1101, "签约账号不合法"); } if (!DataVerifier::isValid($this->request["MobileNo"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1101, "签约手机号不合法"); } //5::校验定单日期合法性 if (!DataVerifier::isValidDate($this->request["OrderDate"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "订单日期格式不正确"); } //6.校验定单日期合法性 if (!DataVerifier::isValidTime($this->request["OrderTime"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "订单时间格式不正确"); } if (!DataVerifier::isValidDate($this->request["InvaidDate"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "签约有效期格式不正确"); } if (!($this->request["IsSign"] === "Sign")) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "设置签约标识不合法"); } //检验证件类型、证件号码合法性 if (!DataVerifier::isValidCertificate($this->request["CertificateType"], $this->request["CertificateNo"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "证件类型、证件号码不合法"); } //验证客户姓名 if ($this->request["AccName"] == null) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1100, "客户姓名未设置"); } if ($this->request["CardType"] === 3) { //验证贷记卡CVV2 if (!DataVerifier::isValidString($this->request["CVV2"], 3)) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1100, "贷记卡CVV2未设置"); } //验证贷记卡有效期 if (!DataVerifier::isValidString($this->request["CardDueDate"], 4)) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1100, "贷记卡有效期未设置"); } } }
protected function checkRequest() { if (!DataVerifier::isValidDate($this->request["OrderDate"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "订单日期格式不正确"); } if (!DataVerifier::isValidTime($this->request["OrderTime"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "订单时间格式不正确"); } if (!DataVerifier::isValidString($this->request["OrderNo"], ILength::ORDERID_LEN)) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1101, "交易编号不合法"); } if (!DataVerifier::isValidString($this->request["AgentSignNo"], ILength::ORDERID_LEN)) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1101, "签约协议号不合法"); } if ($this->request["CurrencyCode"] !== "156") { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1101, "账单币种不合法"); } if (!DataVerifier::isValidAmount($this->request["Amount"], 2)) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1101, "账单金额不合法"); } if (!ICommodityType::InArray($this->request["CommodityType"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1101, "商品种类不合法"); } if (!($this->request["InstallmentMark"] === IInstallmentmark::INSTALLMENTMARK_YES) && !($this->request["InstallmentMark"] === IInstallmentmark::INSTALLMENTMARK_NO)) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "分期标识为空或输入非法"); } if ($this->request["InstallmentMark"] === IInstallmentmark::INSTALLMENTMARK_YES) { if (strlen($this->request["InstallmentCode"]) !== 8) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "分期代码长度应该为8位"); } if (!DataVerifier::isValid($this->request["InstallmentNum"]) || strlen($this->request["InstallmentNum"]) > 2) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "分期期数非有效数字或者长度超过2"); } } else { unset($this->order["InstallmentCode"]); unset($this->order["InstallmentNum"]); } if ($this->request["IsBreakAccount"] !== IIsBreakAccountType::IsBreak_TYPE_YES && $this->request["IsBreakAccount"] !== IIsBreakAccountType::IsBreak_TYPE_NO) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "交易是否分账设置异常,必须为:0或1"); } $tError = $this->isValid(); if (strlen($tError) !== 0) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "订单信息不合法![" . $tError . "]"); } }
protected function checkRequest() { #region 验证request信息 if (!DataVerifier::isValidDate($this->request["BatchDate"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1100, "订单日期不合法!"); } if (!DataVerifier::isValidTime($this->request["BatchTime"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1100, "订单时间不合法!"); } if ($this->request["BatchNo"] == null) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1100, "批次号不合法!"); } if ($this->request["TotalCount"] <= 0) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1101, "退款交易总笔数不能小于1笔"); } if ($this->request["TotalCount"] > ILength::MAXSUMCOUNT) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1101, "退款交易总笔数不能大于10000笔"); } if (!DataVerifier::isValidAmount($this->request["TotalAmount"], 2)) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "退款交易总金额不合法!"); } #endregion #region if (count($this->order, COUNT_NORMAL) < 1) { return "退款明细为空"; } foreach ($this->order as $orderitem) { if (!DataVerifier::isValidString($orderitem["OrderNo"], ILength::ORDERID_LEN)) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "退款订单原交易编号不允许为空"); } if (!DataVerifier::isValidString($orderitem["NewOrderNo"], ILength::ORDERID_LEN)) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "退款订单编号不允许为空"); } if ($orderitem["CurrencyCode"] !== "156") { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "交易币种非法"); } if (!DataVerifier::isValidAmount($orderitem["RefundAmount"], 2)) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "退款金额非法"); } } #endregion }
protected function checkRequest() { if (!DataVerifier::isValidString($this->request["OrderNo"], ILength::ORDERID_LEN)) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1100, "原交易编号不合法!"); } if (!DataVerifier::isValidString($this->request["NewOrderNo"], ILength::ORDERID_LEN)) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1100, "交易编号不合法!"); } if (!DataVerifier::isValidDate($this->request["OrderDate"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1100, "订单日期不合法!"); } if (!DataVerifier::isValidTime($this->request["OrderTime"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1100, "订单时间不合法!"); } if ($this->request["CurrencyCode"] !== "156") { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1100, "设定交易币种不合法!"); } if (!DataVerifier::isValidAmount($this->request["TrxAmount"], 2)) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "交易金额不合法!"); } }
private function isValid() { if (strlen($this->order["OrderNo"]) == null) { return "交易编号为空"; } if (!DataVerifier::isValidAmount($this->order["OrderAmount"], 2)) { return "订单金额不合法"; } if (strlen($this->order["OrderNo"]) > ILength::ORDERID_LEN) { return "交易编号超长"; } if (!DataVerifier::isValidDate($this->order["OrderDate"])) { return "订单日期不合法"; } if (!DataVerifier::isValidTime($this->order["OrderTime"])) { return "订单时间不合法"; } if ($this->order["CurrencyCode"] !== "156") { return "设定交易币种错误"; } return ""; }
protected function checkRequest() { //1.验证是否为空 if (!($this->request["NotifyType"] === INotifyType::NOTIFY_TYPE_URL) && !($this->request["NotifyType"] === INotifyType::NOTIFY_TYPE_SERVER)) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "通知类型不合法!"); } //2.检验证件类型、证件号码合法性 if (!DataVerifier::isValidCertificate($this->request["CertificateType"], $this->request["CertificateNo"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "证件类型、证件号码不合法"); } // 3.检验结果接收URL合法性 if (!DataVerifier::isValidURL($this->request["ResultNotifyURL"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "结果回传网址不合法"); } if (strlen($this->request["ResultNotifyURL"]) > ILength::RESULT_NOTIFY_URL_LEN) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "验证结果回传网址不合法!"); } //4.校验定单最大长度 if (!DataVerifier::isValidString($this->request["OrderNo"], ILength::ORDERID_LEN)) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1101, "交易编号长度不合法"); } //5.校验定单日期合法性 if (!DataVerifier::isValidDate($this->request["OrderDate"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "订单日期格式不正确"); } //6.校验定单日期合法性 if (!DataVerifier::isValidTime($this->request["OrderTime"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "订单时间格式不正确"); } if (!DataVerifier::isValidDate($this->request["InvaidDate"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "有效期时间格式不正确"); } if (!($this->request["IsSign"] === "Sign")) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "设置签约/标识不合法"); } if (!($this->request["NotifyType"] === INotifyType::NOTIFY_TYPE_URL) && !($this->request["NotifyType"] === INotifyType::NOTIFY_TYPE_SERVER)) { return "支付通知类型不合法!"; } }
protected function checkRequest() { $customType = $this->request["CustomType"]; if (!($customType === "0") && !($customType === "1")) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1101, "客户类型不合法"); } if (!DataVerifier::isValidURL($this->request["ResultNotifyURL"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1101, "验证结果回传网址不合法"); } if (!DataVerifier::isValidDate($this->request["OrderDate"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1101, "订单日期不合法"); } if (!DataVerifier::isValidTime($this->request["OrderTime"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1101, "订单时间不合法"); } if (!DataVerifier::isValidBankCardNo($this->request["BankCardNo"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "银行卡号不合法"); } if (!DataVerifier::isValidCertificate($this->request["CertificateType"], $this->request["CertificateNo"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "证件类型、证件号码不合法"); } }
protected function checkRequest() { if (!($this->order["OperateType"] === IPreAuthPayType::PREAUTHPAY_TYPE_CANCEL) && !($this->order["OperateType"] === IPreAuthPayType::PREAUTHPAY_TYPE_CONFIRM)) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1101, "交易类型不合法"); } if (!DataVerifier::isValidString($this->order["OrderNo"], ILength::ORDERID_LEN)) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1101, "原交易编号不合法"); } if (!DataVerifier::isValidString($this->order["OriginalOrderNo"], ILength::ORDERID_LEN)) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1101, "交易编号不合法"); } if (!DataVerifier::isValidDate($this->order["OrderDate"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1101, "订单日期不合法"); } if (!DataVerifier::isValidTime($this->order["OrderTime"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1101, "订单时间不合法"); } if (!DataVerifier::isValidAmount($this->order["OrderAmount"], 2)) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1101, "订单金额不合法"); } if ($this->order["CurrencyCode"] !== "156") { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1101, "交易币种不合法"); } }
private function isValid() { #region 验证$this->request信息 if (!DataVerifier::isValidBankCardNo($this->request["CardNo"])) { return "支付账号不合法!"; } if (!DataVerifier::isValid($this->request["MobileNo"])) { return "手机号不合法!"; } if (!ICommodityType::InArray($this->request["CommodityType"])) { return "商品种类不合法"; } if (!$this->request["Installment"] === IInstallmentmark::INSTALLMENTMARK_YES && !$this->request["Installment"] === IInstallmentmark::INSTALLMENTMARK_NO) { return "分期标识为空或输入非法"; } $payTypeId = $this->order["PayTypeID"]; if ($payTypeId === IPayTypeID::PAY_TYPE_INSTALLMENTPAY) { if ($this->request["Installment"] === IInstallmentmark::INSTALLMENTMARK_YES) { if (strlen($this->request["ProjectID"]) !== 8) { return "分期代码长度应该为8位"; } if (!DataVerifier::isValid($this->request["Period"]) || strlen($this->request["Period"]) > 2) { return "分期期数非有效数字或者长度超过2"; } } } if ($this->request["IsBreakAccount"] !== IIsBreakAccountType::IsBreak_TYPE_YES && $this->request["IsBreakAccount"] !== IIsBreakAccountType::IsBreak_TYPE_NO) { return "交易是否分账设置异常,必须为:0或1"; } #endregion #region 验证order信息 if (!$this->order["PayTypeID"] === IPayTypeID::PAY_TYPE_DIRECTPAY && !$this->order["PayTypeID"] === IPayTypeID::PAY_TYPE_INSTALLMENTPAY) { return "设定交易类型错误"; } if ($this->order["OrderAmount"] <= 0) { return "订单金额小于等于零"; } if (!DataVerifier::isValidString($this->order["OrderNo"], ILength::ORDERID_LEN)) { return "交易编号不合法"; } if (strlen($this->order["OrderDesc"]) > ILength::ORDER_DESC_LEN) { return "订单说明超长"; } if (!DataVerifier::isValidDate($this->order["OrderDate"])) { return "订单日期不合法"; } if (!DataVerifier::isValidTime($this->order["OrderTime"])) { return "订单时间不合法"; } if (!DataVerifier::isValidAmount($this->order["OrderAmount"], 2)) { return "订单金额不合法"; } if ($this->order["CurrencyCode"] !== "156") { return "设定交易币种错误"; } #endregion #region 验证$orderitems信息(订单明细) if (count($this->orderitems, COUNT_NORMAL) < 1) { return "商品明细为空"; } foreach ($this->orderitems as $orderitem) { if (!DataVerifier::isValidString($orderitem["ProductName"], ILength::PRODUCTNAME_LEN)) { return "产品名称不合法"; } } #endregion return ""; }
protected function checkRequest() { if (count($this->agentBatch, COUNT_NORMAL) === 0) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "批次信息不允许为空"); } if ((int) $this->agentBatch["AgentCount"] !== count($this->details, COUNT_NORMAL)) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "批内明细合计笔数(" . count($this->details, COUNT_NORMAL) . ")与批次的总笔数(" . $this->agentBatch["AgentCount"] . ")不符"); } if (count($this->details, COUNT_NORMAL) > ILength::MAXSUMCOUNT) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "批次的总笔数(" . count($this->details, COUNT_NORMAL) . ")超过最大限制(" . ILength::MAXSUMCOUNT . ")"); } $sAgentAmount = $this->agentBatch["AgentAmount"]; if (!((double) $sAgentAmount === (double) $this->iSumAmount)) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "批内明细合计金额(" . $this->agentBatch["AgentAmount"] . ")与批次的总金额(" . $this->iSumAmount . ")不符"); } if (!DataVerifier::isValidString($this->agentBatch["BatchNo"], ILength::ORDERID_LEN)) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "批次号长度超过限制或为空"); } if (!DataVerifier::isValidDate($this->agentBatch["BatchDate"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "批次日期格式不正确"); } if (!DataVerifier::isValidTime($this->agentBatch["BatchTime"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "批次时间格式不正确"); } if (!DataVerifier::isValidAmount($this->agentBatch["AgentAmount"], 2)) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "批量授权扣款总金额不正确"); } if ($this->request["CurrencyCode"] !== "156") { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "币种不合法"); } #endregion //验证dic信息 foreach ($this->details as $detail) { if (!DataVerifier::isValid($detail["SeqNo"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1101, "序列号不合法"); } if (!DataVerifier::isValidString($detail["OrderNo"], ILength::ORDERID_LEN)) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1101, "交易编号不合法"); } if (!DataVerifier::isValidString($detail["AgentSignNo"], ILength::ORDERID_LEN)) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1101, "授权支付签约号不合法"); } if (!DataVerifier::isValidAmount($detail["OrderAmount"], 2)) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1101, "账单金额不合法"); } //if (!($detail["CommodityType"] === ICommodityType :: COMMODITY_TYPE_RECHARGE) && !($detail["CommodityType"] === ICommodityType :: COMMODITY_TYPE_CONFSUME) && !($detail["CommodityType"] === ICommodityType :: COMMODITY_TYPE_TRANSFER)) if (!ICommodityType::InArray($detail["CommodityType"])) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "序列号" . $detail["SeqNo"] . "商品种类不合法"); } if (!($detail["InstallmentMark"] === IInstallmentmark::INSTALLMENTMARK_YES) && !($detail["InstallmentMark"] === IInstallmentmark::INSTALLMENTMARK_NO)) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "分期标识为空或输入非法"); } if ($detail["InstallmentMark"] === IInstallmentmark::INSTALLMENTMARK_YES) { if (strlen($detail["InstallmentCode"]) !== 8) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "分期代码长度应该为8位"); } if (!DataVerifier::isValid($detail["InstallmentNum"]) || strlen($detail["InstallmentNum"]) > 2) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "分期期数非有效数字或者长度超过2"); } } if (!DataVerifier::isValidString($detail["ProductName"], ILength::PRODUCTNAME_LEN)) { throw new TrxException(TrxException::TRX_EXC_CODE_1100, TrxException::TRX_EXC_MSG_1101, "商品名称不合法"); } if ($detail["IsBreakAccount"] !== IIsBreakAccountType::IsBreak_TYPE_YES && $detail["IsBreakAccount"] !== IIsBreakAccountType::IsBreak_TYPE_NO) { throw new TrxException(TrxException::TRX_EXC_CODE_1101, TrxException::TRX_EXC_MSG_1101, "交易是否分账设置异常,必须为:0或1"); } } }
private function isValid() { if ($this->request["PaymentType"] === IPaymentType::PAY_TYPE_UCBP && $this->request["PaymentLinkType"] === IChannelType::PAY_LINK_TYPE_MOBILE) { if (!($this->request["UnionPayLinkType"] === IChannelType::UPMPLINK_TYPE_WAP) && !($this->request["UnionPayLinkType"] === IChannelType::UPMPLINK_TYPE_CLIENT)) { return "银联跨行移动支付接入方式不合法"; } } else { unset($this->request["UnionPayLinkType"]); } if (!($this->request["NotifyType"] === INotifyType::NOTIFY_TYPE_URL) && !($this->request["NotifyType"] === INotifyType::NOTIFY_TYPE_SERVER)) { return "支付通知类型不合法!"; } if (!DataVerifier::isValidURL($this->request["ResultNotifyURL"])) { return "支付结果回传网址不合法!"; } if (strlen($this->request["MerchantRemarks"]) > 100) { return "附言长度大于100"; } if ($this->request["IsBreakAccount"] !== IIsBreakAccountType::IsBreak_TYPE_YES && $this->request["IsBreakAccount"] !== IIsBreakAccountType::IsBreak_TYPE_NO) { return "交易是否分账设置异常,必须为:0或1"; } //验证order信息 $payTypeId = $this->order["PayTypeID"]; if (!($payTypeId === IPayTypeID::PAY_TYPE_DIRECTPAY) && !($payTypeId === IPayTypeID::PAY_TYPE_PREAUTH) && !($payTypeId === IPayTypeID::PAY_TYPE_INSTALLMENTPAY)) { return "设定交易类型错误"; } if ($payTypeId === IPayTypeID::PAY_TYPE_INSTALLMENTPAY) { if (!($this->order["InstallmentMark"] === IInstallmentmark::INSTALLMENTMARK_YES)) { return "分期标识为空或输入非法"; } else { if (strlen($this->order["InstallmentCode"]) !== 8) { return "分期代码长度应该为8位"; } if (!DataVerifier::isValid($this->order["InstallmentNum"]) || strlen($this->order["InstallmentNum"]) > 2) { return "分期期数非有效数字或者长度超过2"; } } } else { unset($this->order["InstallmentCode"]); unset($this->order["InstallmentNum"]); } if (($payTypeId === IPayTypeID::PAY_TYPE_DIRECTPAY || $payTypeId === IPayTypeID::PAY_TYPE_PREAUTH) && $this->order["InstallmentMark"] === IInstallmentmark::INSTALLMENTMARK_YES) { return "交易类型为直接支付或预授权支付时,分期标识不允许输入为“1”"; } if (!DataVerifier::isValidString($this->order["OrderNo"], ILength::ORDERID_LEN)) { return "交易编号不合法"; } if (!DataVerifier::isValidDate($this->order["OrderDate"])) { return "订单日期不合法"; } if (!DataVerifier::isValidTime($this->order["OrderTime"])) { return "订单时间不合法"; } if (!ICommodityType::InArray($this->order["CommodityType"])) { return "商品种类不合法"; } if (!DataVerifier::isValidAmount($this->order["OrderAmount"], 2)) { return "订单金额不合法"; } if ($this->order["CurrencyCode"] !== "156") { return "设定交易币种错误"; } #region 验证$orderitems信息(订单明细) if (count($this->orderitems, COUNT_NORMAL) < 1) { return "商品明细为空"; } foreach ($this->orderitems as $orderitem) { if (!DataVerifier::isValidString($orderitem["ProductName"], ILength::PRODUCTNAME_LEN)) { return "产品名称不合法"; } } return ""; }