/** * @test */ public function testParallelPay() { $parallelPay = new Pay(); $response = $parallelPay->parallelPay(); $this->assertEquals("Success", $response->responseEnvelope->ack); $this->assertNotNull($response->payKey); }
/** * @covers pay\Pay::createOrder * @todo Implement testCreateOrder(). */ public function testCreateOrder() { //扫码支付 $data = array('product_id' => '123', 'body' => '测试交易', 'out_trade_no' => date('Ymd') . mt_rand(10000, 99999), 'total_fee' => 520, 'spbill_create_ip' => '112.95.195.168', 'openid' => 'oK14vt-2cevUlgcPvuzZJOZqp7_k'); $this->object->instance->setMode(2); $result = $this->object->createOrder($data); $this->assertNotFalse($result); }
public function actionIndex() { $model = new Pay(); $model->unsetAttributes(); $model->attributes = $this->aRequest('Pay'); $model->type = Pay::TYPE_REGISTRATION; if ($this->user->isOrganizer() && $model->type_id == null) { $model->type_id = 0; } if ($this->user->isOrganizer() && $model->competition && !isset($model->competition->organizers[$this->user->id])) { Yii::app()->user->setFlash('danger', '权限不足!'); $this->redirect(array('/board/pay/index')); } $this->render('index', array('model' => $model)); }
public function actionDelete($id) { $this->checkLogin(); $pay = Pay::model()->findByPk((int) $id); if ($pay) { if ($pay->delete()) { $this->redirect(array('Index')); } } }
public static function groupAction($dataManager, $ids, $actionParams, $adInfo) { $pays = Pay::getList(['where' => [['id', $ids, 'IN'], ['pay_status_id', 1]]]); foreach ($pays as $pay) { $pay->pay_status_id = 2; $pay->save(); if ($pay->callback_module && $pay->callback_method) { \App::$primary->{$pay->callback_module}->{$pay->callback_method}(['status' => 'success', 'payId' => $pay->id, 'pay' => $pay]); } } $count = count($pays); return 'Оплачено <b>' . $count . '</b> ' . \Tools::getNumEnding($pays, ['счет', 'счета', 'счетов']); }
public function actionParams() { $id = $this->iGet('id'); $isMobile = $this->iRequest('is_mobile'); $channel = $this->sRequest('channel'); $model = Pay::model()->findByPk($id); if ($model === null || $model->user_id !== Yii::app()->user->id) { throw new CHttpException(401, 'Unauthorized Access'); } $params = array(); if ($model->isPaid()) { switch ($model->type) { case Pay::TYPE_REGISTRATION: $competition = $model->competition; $params['url'] = $competition->getUrl('registration'); break; } } else { $params = $model->generateParams($isMobile, $channel); } $this->ajaxOk($params); }
public function initCallBackData(array $data, $name) { /*{{{*/ list($sn, $type) = Pay::explodeSN($data['out_trade_no']); Pay::checkNameInValidNames($name); $this->sn = $sn; $this->name = $name; $this->type = Pay::$typeDescs[$type]; $this->content = $data; $this->total_fee = $data['total_fee']; $this->trade_status = $data['trade_status']; $this->data = $data; return $this; }
public function initCallBackData(array $data, $name) { /*{{{*/ $waperAlipayFunction = wap_alipay_function::getInstance(); $out_trade_no = $waperAlipayFunction->getDataForXML($data["notify_data"], '/notify/out_trade_no'); list($sn, $type) = Pay::explodeSN($out_trade_no); Pay::checkNameInValidNames($name); $this->sn = $sn; $this->name = $name; $this->type = Pay::$typeDescs[$type]; $arrcontent = XString::xmlToArray($data["notify_data"]); $arrcontent['name'] = $name; $arrcontent = XString::convertEncoding($arrcontent, 'gbk', 'utf8'); $this->content = $arrcontent; $this->total_fee = $waperAlipayFunction->getDataForXML($data["notify_data"], '/notify/total_fee'); $this->total_fee = (array) $this->total_fee; $this->total_fee = $this->total_fee[0]; $this->trade_status = $waperAlipayFunction->getDataForXML($data["notify_data"], '/notify/trade_status'); $this->trade_status = (array) $this->trade_status; $this->trade_status = $this->trade_status[0]; $this->data = $arrcontent; return $this; }
/** * 发起支付 * * @author yangyifan <*****@*****.**> */ public function getIndex1(EximbayPayRequest $request) { $data = $request->all(); //发起支付 Pay::drive('EximbayPay')->createPay($data['order_sn'], $data['price'], $data); }
private function paystate($criteria) { if($this->state_pay==1) { $payment_table = Pay::model()->tableName(); $paid_status_sql = "(select CASE WHEN (select sum(amount) from $payment_table where $payment_table.exp_id = t.id) >0 THEN 1 ELSE 0 END)"; } else if($this->state_pay==2) { $payment_table = Pay::model()->tableName(); $paid_status_sql = "(select CASE WHEN ((t.amount>(select sum(amount) from $payment_table where $payment_table.exp_id = t.id))OR((select sum(amount) from $payment_table where $payment_table.exp_id = t.id)IS NULL)) THEN 2 ELSE 0 END)"; } else if($this->state_pay==3) { $payment_table = Inv::model()->tableName(); $paid_status_sql = "(select CASE WHEN (select sum(amount) from $payment_table where $payment_table.exp_id = t.id) >0 THEN 3 ELSE 0 END)"; } else if($this->state_pay==4) { $payment_table = Inv::model()->tableName(); $paid_status_sql = "(select CASE WHEN ((t.amount>(select sum(amount) from $payment_table where $payment_table.exp_id = t.id))OR((select sum(amount) from $payment_table where $payment_table.exp_id = t.id)IS NULL)) THEN 4 ELSE 0 END)"; } $criteria->select = array( '*', $paid_status_sql." as state_pay", ); // $criteria->addCondition(" (".$paid_status_sql.") =".$this->state_pay); $criteria->compare($paid_status_sql, $this->state_pay); }
/** * IOS IAP 支付验证 * $uid * $token * $item_id * $receipt */ public function actionIosVerify() { // error_log(json_encode($_POST)); if (!isset($_REQUEST['receipt']) || !isset($_REQUEST['uid']) || !isset($_REQUEST['token']) || !isset($_REQUEST['trade_no'])) { $this->_return('MSG_ERR_LESS_PARAM'); } /*沙盒测试开关,正式发布时,需置为false**********************************/ $isSandbox = true; /********************************************************************/ $receipt = Yii::app()->request->getParam('receipt'); $uid = trim(Yii::app()->request->getParam('uid')); $token = trim(Yii::app()->request->getParam('token')); $trade_no = Yii::app()->request->getParam('trade_no'); $now = date('Y-m-d H:i:s'); if (!Token::model()->verifyToken($uid, $token, $GLOBALS['__APPID'])) { $this->_return('MSG_ERR_TOKEN'); //#token 错误 } $param = array('uid' => $uid, 'receipt' => $receipt, 'create_ts' => $now, 'trade_no' => $trade_no); $trade_info = Pay::model()->getTradeInfo($trade_no); if ($trade_info['uid'] != $uid || $trade_info['status'] != 0) { Pay::model()->recordIOSIAPInfo($param); Log::model()->_pay_log($uid, 'ORDER_IOS_IAP_VERIFY_WRONG', $now, $trade_no, "无效或重复的订单"); $this->_return('MSG_ISO_PAY_WRONG'); } if ($isSandbox) { $endpoint = 'https://sandbox.itunes.apple.com/verifyReceipt'; } else { $endpoint = 'https://buy.itunes.apple.com/verifyReceipt'; } $postData = json_encode(array('receipt-data' => $receipt)); $ch = curl_init($endpoint); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); //curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); //curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); //这两行一定要加,不加会报SSL 错误 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); $response = curl_exec($ch); $errno = curl_errno($ch); $errmsg = curl_error($ch); curl_close($ch); if ($errno != 0) { Log::model()->_pay_log($uid, 'ORDER_IOS_IAP_VERIFY_WRONG', $now, trade_no, $errno . ">" . $errmsg); Pay::model()->recordIOSIAPInfo($param); $this->_return('MSG_ISO_PAY_WRONG'); } $param['verify_data'] = $response; $data = json_decode($response); if (!is_object($data)) { Log::model()->_pay_log($uid, 'ORDER_IOS_IAP_VERIFY_WRONG', $now, $trade_no, '不能解析返回数据>' . $response); Pay::model()->recordIOSIAPInfo($param); $this->_return('MSG_ISO_PAY_WRONG'); //throw new Exception('Invalid response data'); } if (!isset($data->status) || $data->status != 0) { Log::model()->_pay_log($uid, 'ORDER_IOS_IAP_VERIFY_FAIL', $now, $trade_no); Pay::model()->recordIOSIAPInfo($param); $this->_return('MSG_ISO_PAY_FAIL'); } $add_coin = $trade_info['coin'] + $trade_info['free']; Pay::model()->iosPaySuccess($uid, $trade_no, $add_coin); Pay::model()->recordIOSIAPInfo($param); Log::model()->_pay_log($uid, 'ORDER_IOS_IAP_VERIFY_OK', $now, $trade_no); $res = array('gold' => $add_coin); $this->_return('MSG_SUCCESS', $res); }
public function actionAjaxReq() { $val1 = $_POST['val_id']; sscanf($val1, "js:_id=%d;_pay=%d;", $id, $pay); if ($id == null) { echo "R:" . $val1; return; } $ret .= ""; // $ret.="<div id='mydialog_buts'>".CHtml::link('Новый платеж',array('pay/createID','id'=>$id), array('target'=>'_blank','class'=>'menuitem'))."</div>"; $dataReader = Pay::model()->findAll('exp_id=:id', array(':id' => $id)); $ret .= "<table class='acctable'>"; $ret .= "<tr>" . "<th>№</th>" . "<th>Инфо.</th>" . "<th>Дата</th>" . "<th>Получен</th>" . "<th>Сумма</th>" . "</tr>"; $res = 0; foreach ($dataReader as $row) { $ret .= "<tr><td>" . $row['id'] . "</td><td>" . $row['name'] . "</td>\n"; $ret .= "<td>" . Yii::app()->dateFormatter->formatDateTime($row['date'], 'short', null) . "</td>\n"; $ret .= "<td>" . Yii::app()->dateFormatter->formatDateTime($row['date_g'], 'short', null) . "</td>\n"; // $ret.="<td>".$row->account['name']."</td>\n"; // $ret.="<td style='text-align:right;'>".Yii::app()->numberFormatter->formatCurrency($row['amount'], '')."</td></tr>\n"; // if( Yii::app()->Controller->permit>2) $ret .= "<td style='text-align:right;'>" . CHtml::link(Yii::app()->numberFormatter->formatCurrency($row['amount'], ''), array('pay/update', 'id' => $row['id'], 'ret' => 1)) . "</td></tr>"; // $ret.="<td style='text-align:right;'>".CHtml::link(Yii::app()->numberFormatter->formatCurrency($row['amount'], ''),array('pay/update','id'=>$row['id']),array('target'=>'_blank'))."</td></tr>"; // else // $ret.="<td style='text-align:right;'>".Yii::app()->numberFormatter->formatCurrency($row['amount'], '')."</td></tr>"; $res += $row['amount']; } $ret .= "<tr><td colspan='4'>Оплачено:</td><td style='font-weight: bold;text-align:right;'>" . Yii::app()->numberFormatter->formatCurrency($res, '') . "</td></tr>\n"; $ret .= "</table>\n"; echo $ret; }
public function encryptOrderInfo($sn, $type, $price, $callBackUrl, $name, $description = '') { /*{{{*/ $callBackUrl = urlencode($callBackUrl); $sn = Pay::makeSN($sn, $type); $partner = $this->partner; $seller = $this->seller; $out_trade_no = $sn; $subject = $name . "-订单号({$sn})"; $body = $description; $total_fee = number_format($price, 2, '.', ''); $notifyurl = $callBackUrl; //异步返回 $waitSign = 'partner="' . $partner . '"&seller="' . $seller . '"&out_trade_no="' . $out_trade_no . '"&subject="' . $subject . '"&body="' . $body . '"&total_fee="' . $total_fee . '"¬ify_url="' . $notifyurl . '"'; // $waitSignArr = array('partner' => $partner, 'seller' => $seller, 'out_trade_no' => $out_trade_no, 'subject' => $subject, 'body' => $body, 'total_fee' => $total_fee, 'notify_url' => $notifyurl, 'signType' => 'RSA'); // $waitSign = $this->create_linkstring($waitSignArr); $waitSign_utf8 = XString::convertToUnicode($waitSign); //utf-8 $sign = $this->sign($waitSign_utf8); $sign = urlencode($sign); $string = $waitSign . '&sign_type="RSA"' . '&sign="' . $sign . '"'; return $string; }
public function initCallBackData($request) { /*{{{*/ //判断数据来源是否是快钱的 //if($this->checkSourceIPValid() == false){ // return self::PAYED_STATUS_SIGNITURE_ERROR; //} //注意顺序不能变 $params = array(); $params['merchantAcctId'] = $request->merchantAcctId; $params['version'] = $request->version; $params['language'] = $request->language; $params['signType'] = $request->signType; $params['payType'] = $request->payType; $params['bankId'] = $request->bankId; $params['orderId'] = $request->orderId; $params['orderTime'] = $request->orderTime; $params['orderAmount'] = $request->orderAmount; $params['dealId'] = $request->dealId; $params['bankDealId'] = $request->bankDealId; $params['dealTime'] = $request->dealTime; $params['payAmount'] = $request->payAmount; $params['fee'] = $request->fee; $params['ext1'] = $request->ext1; $params['ext2'] = $request->ext2; $params['payResult'] = $request->payResult; $params['errCode'] = $request->errCode; $signMsg = $request->signMsg; DBC::requireNotEmpty($params, '参数信息不可为空'); DBC::requireNotEmpty($signMsg, '签名信息不可为空'); list($sn, $type) = Pay::explodeSN($request->orderId); $this->orderId = $sn; $this->type = Pay::$typeDescs[$type]; $this->name = Pay::NAME_TYPE_QPAY_NOTIFY; $content = $params; $content['signMsg'] = $signMsg; $this->content = $content; $this->amount = $request->payAmount / 100; //这个要在最后执行 $this->status = $this->checkQpayData(); return $this; }
public function alipayChannel4Recharge($request, $response) { /*{{{*/ $needPay = $request->getRequest('needPay', 0); $needPay = XString::calculateBalancePrice($needPay); DBC::requireTrue($needPay > 0, '价格有错误 或 余额可够支付'); $user = DAL::get()->find('user', $request->userid); DBC::requireFalse($user->isNull(), '用户不存在'); $depositeOrderId = $request->getRequest('depositeOrderId', 0); $depositeOrder = DAL::get()->find('depositeOrder', $depositeOrderId); if ($depositeOrder->isNull()) { $depositeOrder = OrderClient::getInstance()->createDepositeOrder($user, $needPay, DepositeOrder::RECHARGE_TYPE_ALIPAYWAP); } DBC::requireFalse($depositeOrder->isNull(), '无效订单!'); if ($request->appType == 'mobileapp') { $returnUrl = WaperAlipay::getDefaultReturnUrl(); $sellerUrl = WaperAlipay::getDefaultSellerUrl(); } else { $returnUrl = WaperAlipay::getDefaultReturnUrl4TouchRecharge(); $sellerUrl = WaperAlipay::getDefaultSellerUrl4TouchRecharge($depositeOrder->id); } $notifyUrl = WaperAlipay::getDefaultNotifyUrl(); $aliPayUrl = WaperAlipay::getAliWapPayUrl($depositeOrder->id, Pay::TYPE_RECHARGE, $needPay, $notifyUrl, $returnUrl, $sellerUrl, Pay::getTypeDesc(Pay::TYPE_RECHARGE), $user->name . "在线充值"); $response->setRedirect($aliPayUrl); return parent::DIRECT_OUTPUT; }
public function createPay() { $pay = new Pay(); $pay->user_id = $this->user_id; $pay->type = Pay::TYPE_REGISTRATION; $pay->type_id = $this->competition_id; $pay->sub_type_id = $this->id; $pay->amount = $this->total_fee * 100; $pay->order_name = $this->competition->name_zh . '报名费'; $r = $pay->save(); return $pay; }
$object = new Pay($instance); $data = array('subject' => 'test', 'out_trade_no' => date('Ymd') . mt_rand(10000, 99999), 'total_amount' => 0.01); try { $result = $object->createOrder($data); var_dump('alipay_qrcode:'); var_dump($result); } catch (\Exception $e) { var_dump('alipay_qrcode:' . $e->getMessage()); } //手机网站即时到账支付 $instance = Gateway::getPayment(['alipay' => 'wap']); $object = new Pay($instance); $data = array('subject' => 'test', 'out_trade_no' => date('Ymd') . mt_rand(10000, 99999), 'total_fee' => 0.01, 'show_url' => 'http://www.lohas100.com'); try { $result = $object->createOrder($data); var_dump('alipay_wap:'); var_dump($result); } catch (\Exception $e) { var_dump('alipay_wap:' . $e->getMessage()); } //即时到账支付 $instance = Gateway::getPayment(['alipay' => 'wap']); $object = new Pay($instance); $data = array('subject' => 'test', 'out_trade_no' => date('Ymd') . mt_rand(10000, 99999), 'total_fee' => 0.01); try { $result = $object->createOrder($data); var_dump('alipay_web:'); var_dump($result); } catch (\Exception $e) { var_dump('alipay_web:' . $e->getMessage()); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Pay the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Pay::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
/** * Retrieves a list of models based on the current search/filter conditions. * * Typical usecase: * - Initialize the model fields with values from filter form. * - Execute this method to get CActiveDataProvider instance which will filter * models according to data in model fields. * - Pass data provider to CGridView, CListView or any similar widget. * * @return CActiveDataProvider the data provider that can return the models * based on the search/filter conditions. */ public function search() { // @todo Please modify the following code to remove attributes that should not be searched. $criteria = new CDbCriteria(); $criteria->compare('id', $this->id, true); $criteria->compare('user_id', $this->user_id, true); $criteria->compare('channel', $this->channel, true); $criteria->compare('type', $this->type); $criteria->compare('type_id', $this->type_id); $criteria->compare('sub_type_id', $this->sub_type_id, true); $criteria->compare('order_no', $this->order_no, true); $criteria->compare('order_name', $this->order_name, true); $criteria->compare('amount', $this->amount, true); $criteria->compare('device_type', $this->device_type); $criteria->compare('pay_channel', $this->pay_channel, true); $criteria->compare('pay_account', $this->pay_account, true); $criteria->compare('trade_no', $this->trade_no, true); $criteria->compare('status', $this->status); $criteria->compare('create_time', $this->create_time, true); $criteria->compare('update_time', $this->update_time, true); self::$_criteria = $criteria; return new CActiveDataProvider($this, array('criteria' => $criteria, 'sort' => array('defaultOrder' => 'id DESC'), 'pagination' => array('pageSize' => 100))); }