本文整理匯總了PHP中WapAction::generatePayResultUrl方法的典型用法代碼示例。如果您正苦於以下問題:PHP WapAction::generatePayResultUrl方法的具體用法?PHP WapAction::generatePayResultUrl怎麽用?PHP WapAction::generatePayResultUrl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WapAction
的用法示例。
在下文中一共展示了WapAction::generatePayResultUrl方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: callback
public function callback()
{
Log::record('cftpay callback get:' . print_r($_GET, true));
Log::save();
// 由於二級域名redirect的原因,我們會自動在GET參數裏添加shop=merchant_code,需要顯示的去掉該參數
unset($_GET['shop']);
unset($_GET['_URL_']);
$out_trade_no = $_GET['sp_billno'];
$transaction_id = $_GET['transaction_id'];
if (empty($out_trade_no) || empty($transaction_id)) {
echo 'fail';
exit;
}
// verify whether trade record existing in our db for <order_sn>
$trade = M('b2c_cfttrade')->where(array('order_sn' => $out_trade_no, 'transaction_id' => $transaction_id))->find();
if (empty($trade)) {
Log::record('cftpay callback non existing order_sn get:' . print_r($_GET, true));
Log::save();
$this->error('非法訂單號', U('Wap/Shop/error'));
}
$DECODED_GET = array();
foreach ($_GET as $k => $v) {
$DECODED_GET[$k] = urldecode($v);
}
import("@.ORG.CftWapPayHelper");
// url signature verification
$cftWapPayHelper = new CftWapPayHelper($trade['partnerId'], $trade['partnerkey']);
foreach ($DECODED_GET as $k => $v) {
$cftWapPayHelper->setParameter($k, $v);
}
if (!$cftWapPayHelper->isTenpaySign()) {
// sign mismatch
Log::record('cftpay callback url sign mismatch: .GET:' . print_r($_GET, true));
Log::save();
echo 'fail';
exit;
}
Log::record('cftpay callback url sign verification passed!', Log::INFO);
Log::save();
$audit['trade_callback_timestamp'] = time();
$audit['trade_callback_times'] = $trade['trade_callback_times'] + 1;
M('b2c_cfttrade')->where(array('id' => $trade['id']))->save($audit);
$host_name = C('wx_handler_server');
// update trade table for tracking
if ($trade['n_pay_result'] == 0) {
$redirect = WapAction::generatePayResultUrl('Shop/my', $trade['token'], array('token' => $trade['token'], 'wecha_id' => $trade['wecha_id'], 'success' => 1));
$this->redirect($redirect);
//$this->success('交易成功',U('Wap/Shop/index',array('shop'=> $trade['token'],'wecha_id'=>$trade['wecha_id'])));
} else {
$redirect = WapAction::generatePayResultUrl('Shop/my', $trade['token'], array('token' => $trade['token'], 'wecha_id' => $trade['wecha_id'], 'success' => 0));
$this->redirect($redirect);
//$this->error('交易失敗',U('Wap/Shop/index',array('shop'=> $trade['token'],'wecha_id'=>$trade['wecha_id'])));
}
}
示例2: return_url
public function return_url()
{
$out_trade_no = $_GET['out_trade_no'];
Log::record("return url:" . print_r($_GET, true), Log::INFO);
$shop = null;
$trade = null;
if ($out_trade_no) {
$Model = new Model();
// 實例化一個model對象 沒有對應任何數據表
$shop = $Model->query("select o.token, o.wecha_id, p.pay_config from tp_b2c_order as o JOIN tp_b2c_payment as p on p.token = o.token where p.pay_code ='alipay' and o.sn = '{$out_trade_no}'");
if ($shop == null) {
Log::record("Illegle order sn:" . $out_trade_no, Log::NOTICE);
$this->error('非法訂單號', U('Wap/Shop/error'));
}
if (is_array($shop) && is_string($shop[0]['pay_config'])) {
$store = unserialize($shop[0]['pay_config']);
$shop[0]['pay_account'] = $store['pay_account'];
//合作身份者id,以2088開頭的16位純數字
$shop[0]['partner'] = $store['alipay_pid'];
//安全檢驗碼,以數字和字母組成的32位字符
//如果簽名方式設置為“MD5”時,請設置該參數
$shop[0]['key'] = $store['alipay_key'];
}
}
Log::record("shop_config:" . print_r($shop, true), Log::INFO);
import("@.ORG.AliWapPay.AlipayNotify");
$alipayNotify = new AlipayNotify($this->setconfig($shop[0]['partner'], $shop[0]['key']));
$verify_result = $alipayNotify->verifyReturn();
if ($verify_result) {
//商戶訂單號
$out_trade_no = $_GET['out_trade_no'];
//支付寶交易號
$trade_no = $_GET['trade_no'];
//交易狀態
$trade_status = $_GET['result'];
//用戶付款時間
$gmt_payment_time = time();
$trade_db = M('b2c_trade');
$trade_where = array('order_sn' => $out_trade_no);
$trade = $trade_db->field('trade_id', 'token', 'trade_no')->where($trade_where)->find();
Log::record('return url: status:' . $trade_status . ' trade_no:' . $trade['trade_no'], Log::INFO);
Log::save();
if ($trade_status == 'success' && $trade && empty($trade['trade_no'])) {
$data = array('status' => 2, 'trade_no' => $trade_no, 'alipay_create_time' => time(), 'payment_time' => $gmt_payment_time);
$ret = $trade_db->where($trade_where)->save($data);
if ($ret) {
//2 是訂單已付款
$order_ret = M('b2c_order')->where(array('sn' => $out_trade_no))->save(array('status' => 2));
Log::save();
//echo "交易成功<br />";
$redirect = WapAction::generatePayResultUrl('Shop/my', $shop[0]['token'], array('token' => $shop[0]['token'], 'wecha_id' => $shop[0]['wecha_id'], 'success' => 1));
$this->redirect($redirect);
//$this->success('交易成功',U('Wap/Shop/index',array('shop'=> $trade['token'])));
}
}
if ($trade_status == 'success') {
$redirect = WapAction::generatePayResultUrl('Shop/my', $shop[0]['token'], array('token' => $shop[0]['token'], 'wecha_id' => $shop[0]['wecha_id'], 'success' => 1));
$this->redirect($redirect);
} else {
$redirect = WapAction::generatePayResultUrl('Shop/my', $shop[0]['token'], array('token' => $shop[0]['token'], 'wecha_id' => $shop[0]['wecha_id'], 'success' => 0));
$this->redirect($redirect);
}
} else {
Log::save();
//echo "支付失敗<br />";
$redirect = WapAction::generatePayResultUrl('Shop/my', $shop[0]['token'], array('token' => $shop[0]['token'], 'wecha_id' => $shop[0]['wecha_id'], 'success' => 0));
$this->redirect($redirect);
//$this->error('支付失敗 ,請聯係客服,為您處理',U('Wap/Shop/index'));
}
}