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, "证件类型、证件号码不合法"); } }
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 ""; }