Example #1
0
 private function _checkParams($fields)
 {
     $errCode = 0;
     $errMsg = '';
     do {
         $gateway = substr($fields['gateway'], 1);
         $channel = substr($fields['channel'], 1);
         $merRechargeNo = substr($fields['mer_recharge_no'], 1);
         $gatewayCode = Util\GatewayUtil::checkGateway($gateway);
         if (!$gatewayCode) {
             $errCode = 1;
             $errMsg = sprintf('gateway not exists gateway=%s', $gateway);
             break;
         }
         if (false === Util\ChannelUtil::checkChannel($channel)) {
             $errCode = 2;
             $errMsg = sprintf('channel not exists channel=%s', $channel);
             break;
         }
         $gatewayObj = Util\GatewayUtil::getGatewayObj($gateway);
         if (false == $gatewayObj->checkSign($fields)) {
             $errCode = 3;
             $errMsg = '参数验证失败';
             break;
         }
         if (!$merRechargeNo) {
             $errCode = 4;
             $errMsg = '参数传递错误';
             break;
         }
     } while (0);
     return array('err_code' => $errCode, 'err_msg' => $errMsg, 'channel' => $channel, 'gateway' => $gateway, 'mer_recharge_no' => $merRechargeNo);
 }
 public function checkChannel()
 {
     $channel = \Input::get('channel', 0);
     if (false === ChannelUtil::checkChannel($channel)) {
         $this->ret['err_code'] = ErrCode::ERR_PARAM;
         return $this->render();
     }
 }
 public function getAccount()
 {
     self::$userId = \Input::get('user_id', '');
     self::$accChannel = ChannelUtil::calculateAccountChannel(\Input::get('channel', 0));
     $account = AccountBiz::getInstance()->getAccount(self::$userId, self::$accChannel);
     if (!$account) {
         throw new PayException(ErrCode::ERR_ACCOUNT_NO_EXISTS);
     }
     return $account;
 }
Example #4
0
 public function getOrCreateAccount($userId, $channel = 1)
 {
     $accChannel = ChannelUtil::calculateAccountChannel($channel);
     $account = $this->getAccount($userId, $accChannel);
     if (!$account) {
         $primaryId = $this->_accountModel->calculPrimaryId();
         $this->_accountModel->id = $primaryId;
         $this->_accountModel->user_id = $userId;
         $this->_accountModel->acc_channel = $accChannel;
         $this->_accountModel->create_time = time();
         $this->_accountModel->save();
         return $this->_accountModel;
     }
     return $account;
 }
Example #5
0
 private function _checkParams($channel, $gateway)
 {
     $errCode = 0;
     $errMsg = '';
     do {
         $gatewayCode = Util\GatewayUtil::checkGateway($gateway);
         if (!$gatewayCode) {
             $errCode = 1;
             $errMsg = sprintf('gateway not exists gateway=%s', $gateway);
             break;
         }
         if (false === Util\ChannelUtil::checkChannel($channel)) {
             $errCode = 1;
             $errMsg = sprintf('channel not exists channel=%s', $channel);
             break;
         }
     } while (0);
     return array('err_code' => $errCode, 'err_msg' => $errMsg, 'channel' => $channel, 'gateway' => $gateway);
 }
Example #6
0
 public function transThirdParty($batchNo)
 {
     $transArr = TransModel::where('batch_no', $batchNo)->get();
     foreach ($transArr as $trans) {
         $fields[] = ['channel' => ChannelUtil::calculateAccountChannel($trans['channel']), 'gateway' => $trans['gateway'], 'mer_trans_no' => $trans['mer_trans_no'], 'batch_no' => $trans['batch_no'], 'bank_code' => $trans['bank_code'], 'timestamp' => $trans['create_time'], 'trans_amount' => $trans['trans_amount'], 'subject' => $trans['subject'], 'user_name' => $trans['person_name'], 'user_account' => $trans['person_account'], 'notify_url' => PayVars::getNotifyUrl() . "notify/trans/{$trans['channel']}/{$trans['gateway']}"];
     }
     $gatewayObj = GatewayUtil::getGatewayObj($fields[0]['gateway']);
     return $gatewayObj->trans($fields);
 }
 public function seConfirmTrans($job, $data)
 {
     $errCode = 0;
     $transOrder = TransModel::find($data['id'])->first();
     do {
         if (!$transOrder || $transOrder->status != TransModel::STATUS_DEFAULT) {
             $errCode = 1;
             break;
         }
         if (!$transOrder->gateway || !$transOrder->channel) {
             $errCode = 2;
             break;
         }
         if (false === ($channel = ChannelUtil::calculateAccountChannel($transOrder->channel))) {
             $errCode = 3;
             break;
         }
         $gatewayObj = gatewayUtil::getGatewayObj($transOrder->gateway);
         if (!$gatewayObj) {
             $errCode = 4;
             break;
         }
         if (!method_exists($gatewayObj, 'transQuery')) {
             $errCode = 5;
             break;
         }
     } while (0);
     if ($errCode == 0) {
         $order = ['channel' => $channel, 'gateway' => $transOrder->gateway, 'batch_no' => $transOrder->batch_no, 'mer_trans_no' => $transOrder->mer_trans_no];
         $notice = $gatewayObj->transQuery($order);
         $ret = SerNotifyBiz::getInstance()->payNotify($notice, 'trans');
         if ($ret->is_success == 'T') {
             $job->delete();
         } else {
             $job->release(60 * 60);
         }
     } else {
         $job->delete();
     }
 }
Example #8
0
 public function directThirdParty($rechargeOrder)
 {
     $fields['channel'] = Util\ChannelUtil::calculateAccountChannel($rechargeOrder['channel']);
     $fields['gateway'] = $rechargeOrder['gateway'];
     $fields['plat'] = $rechargeOrder['plat'];
     $fields['mer_recharge_no'] = $rechargeOrder['mer_recharge_no'];
     $fields['bank_code'] = $rechargeOrder['bank_code'];
     $fields['timestamp'] = $rechargeOrder['create_time'];
     $fields['amount'] = $rechargeOrder['recharge_amount'];
     $fields['expire_time'] = $rechargeOrder['expire_time'];
     $fields['subject'] = $rechargeOrder['subject'];
     $fields['body'] = $rechargeOrder['body'];
     $fields['open_id'] = $rechargeOrder['gateway_account'];
     $gatewayObj = Util\GatewayUtil::getGatewayObj($fields['gateway']);
     $fields['notify_url'] = PayVars::getNotifyUrl() . "notify/direct/{$fields['channel']}/{$fields['gateway']}";
     $fields['return_url'] = PayVars::getReturnUrl() . 'return/' . $gatewayObj->makeReturnUri($fields);
     return $gatewayObj->direct($fields);
 }