Example #1
0
 * [WeEngine System] Copyright (c) 2014 WE7.CC
 * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
 */
define('IN_MOBILE', true);
require '../../framework/bootstrap.inc.php';
$_GPC['i'] = !empty($_GPC['i']) ? $_GPC['i'] : $_GET['extra'];
require '../../app/common/bootstrap.app.inc.php';
load()->app('common');
load()->app('template');
$setting = uni_setting($_W['uniacid'], array('payment'));
if (!is_array($setting['payment'])) {
    exit('没有设定支付参数.');
}
$payment = $setting['payment']['baifubao'];
require 'bfb_sdk.php';
$bfb_sdk = new bfb_sdk();
if (!empty($_GPC['pay_result']) && $_GPC['pay_result'] == '1') {
    if (true === $bfb_sdk->check_bfb_pay_result_notify()) {
        $sql = 'SELECT * FROM ' . tablename('core_paylog') . ' WHERE `uniontid`=:uniontid';
        $params = array();
        $params[':uniontid'] = $_GPC['order_no'];
        $log = pdo_fetch($sql, $params);
        if (!empty($log) && $log['status'] == '0') {
            $log['tag'] = iunserializer($log['tag']);
            $log['tag']['bfb_order_no'] = $_POST['bfb_order_no'];
            $record = array();
            $record['status'] = 1;
            $record['tag'] = iserializer($log['tag']);
            pdo_update('core_paylog', $record, array('plid' => $log['plid']));
            if ($log['is_usecard'] == 1 && $log['card_type'] == 1 && !empty($log['encrypt_code']) && $log['acid']) {
                load()->classs('coupon');
Example #2
0
<?php

/**
 * 这个商户的returl_url页面实现的模板
 * 该页面的业务逻辑是:
 * 1. 当商户收到百付宝支付成功的通知后,调用sdk中预处理操作确定该订单支付成功
 * 2. 确认支付成功后,商户自己的业务逻辑,比如记账之类的。
 * 注意,sdk中的query_order_state()方法,必须商户自己实现,
 * 否则会由于收到多次百付宝的支付结果通知,导致商户自己出现资金的不一致。
 */
global $_W, $_GPC;
require_once 'bfb_sdk.php';
$bfb_sdk = new bfb_sdk();
$bfb_sdk->log(sprintf('get the notify from baifubao, the request is [%s]', print_r($_GET, true)));
if (false === $bfb_sdk->check_bfb_pay_result_notify()) {
    $bfb_sdk->log('get the notify from baifubao, but the check work failed');
    return;
}
$order = pdo_fetch("SELECT * FROM " . tablename("uni_payorder") . " WHERE orderid = :orderid", array(":orderid" => $_GET['order_no']));
if (empty($order) || $order["status"] == 1) {
    return;
}
if (pdo_update("uni_payorder", array("status" => 1, "pay_time" => TIMESTAMP), array("orderid" => $_GET['order_no'])) > 0) {
    $bfb_sdk->log('get the notify from baifubao and the check work success');
    user_credits_update($order["uid"], $order["credittype"], $order["money"], array(2, "充值"));
}
/*
 * 此处是商户收到百付宝支付结果通知后需要做的自己的具体业务逻辑,比如记账之类的。 只有当商户收到百付宝支付 结果通知后,
 * 所有的预处理工作都返回正常后,才执行该部分
 */
// 向百付宝发起回执
Example #3
0
<?php

/**
 * 这个是调用bfb_sdk里生成百付宝移动端即时到账支付接口URL(需要登录)的DEMO
 *
 */
if (!defined("BFB_SDK_ROOT")) {
    define("BFB_SDK_ROOT", dirname(__FILE__) . DIRECTORY_SEPARATOR);
}
require_once BFB_SDK_ROOT . 'bfb_sdk.php';
require_once BFB_SDK_ROOT . 'bfb_pay.cfg.php';
$bfb_sdk = new bfb_sdk();
$order_create_time = date("YmdHis");
$expire_time = date('YmdHis', strtotime('+2 day'));
$order_no = $order_create_time . sprintf('%06d', rand(0, 999999));
$good_name = $_POST['goods_name'];
$good_desc = $_POST['goods_desc'];
$goods_url = $_POST['goods_url'];
$unit_amount = $_POST['unit_amount'];
$unit_count = $_POST['unit_count'];
$transport_amount = $_POST['transport_amount'];
$total_amount = $_POST['total_amount'] * 100;
$buyer_sp_username = $_POST['buyer_sp_username'];
$return_url = $_POST['return_url'];
$page_url = $_POST['page_url'];
$pay_type = $_POST['pay_type'];
$bank_no = $_POST['bank_no'];
$extra = $_POST['extra'];
$good_name = iconv("UTF-8", "GBK", urldecode($good_name));
$good_desc = iconv("UTF-8", "GBK", urldecode($good_desc));
$buyer_sp_username = iconv("UTF-8", "GBK", urldecode($buyer_sp_username));
Example #4
0
                $ret['type'] = $log['type'];
                $ret['from'] = 'return';
                $ret['tid'] = $log['tid'];
                $ret['uniontid'] = $log['uniontid'];
                $ret['user'] = $log['openid'];
                $ret['fee'] = $log['fee'];
                $ret['tag'] = $log['tag'];
                $site->{$method}($ret);
                $bfb_sdk->notify_bfb();
                exit('success');
            }
        }
    }
}
$sql = 'SELECT * FROM ' . tablename('core_paylog') . ' WHERE `plid`=:plid';
$paylog = pdo_fetch($sql, array(':plid' => $params['tid']));
if (!empty($paylog) && $paylog['status'] != '0') {
    exit('这个订单已经支付成功, 不需要重复支付.');
}
$auth = sha1($sl . $paylog['uniacid'] . $_W['config']['setting']['authkey']);
if ($auth != $_GPC['auth']) {
    exit('参数传输错误.');
}
$_W['openid'] = intval($paylog['openid']);
$bfb_sdk = new bfb_sdk();
$params = array('service_code' => sp_conf::BFB_PAY_INTERFACE_SERVICE_ID, 'sp_no' => sp_conf::$SP_NO, 'order_create_time' => date("YmdHis"), 'order_no' => $paylog['uniontid'], 'goods_name' => iconv('utf-8', 'gbk', $params['title']), 'total_amount' => $params['fee'] * 100, 'currency' => sp_conf::BFB_INTERFACE_CURRENTCY, 'buyer_sp_username' => $_W['openid'], 'return_url' => $_W['siteroot'] . 'notify.php', 'page_url' => $_W['siteroot'] . 'pay.php', 'pay_type' => '2', 'bank_no' => '201', 'expire_time' => date('YmdHis', strtotime('+15 day')), 'input_charset' => sp_conf::BFB_INTERFACE_ENCODING, 'version' => sp_conf::BFB_INTERFACE_VERSION, 'sign_method' => sp_conf::SIGN_METHOD_MD5, 'extra' => $_W['uniacid']);
$order_url = $bfb_sdk->create_baifubao_pay_order_url($params, sp_conf::BFB_PAY_WAP_DIRECT_URL);
if (false !== $order_url) {
    echo "<script>window.location=\"" . $order_url . "\";</script>";
    exit;
}
Example #5
0
<?php

/**
 * 这个是调用bfb_sdk里通过百付宝订单号查询接口查询订单信息的DEMO
 *
 */
if (!defined("BFB_SDK_ROOT")) {
    define("BFB_SDK_ROOT", dirname(__FILE__) . DIRECTORY_SEPARATOR);
}
require_once BFB_SDK_ROOT . 'bfb_sdk.php';
require_once BFB_SDK_ROOT . 'bfb_pay.cfg.php';
$bfb_sdk = new bfb_sdk();
$order_no = $_POST['order_no'];
/*
 * 字符编码转换,百付宝默认的编码是GBK,商户网页的编码如果不是,请转码。涉及到中文的字段请参见接口文档
 * 步骤:
 * 1. URL转码
 * 2. 字符编码转码,转成GBK
 * 
 * $good_name = iconv("UTF-8", "GBK", urldecode($good_name));
 * $good_desc = iconv("UTF-8", "GBK", urldecode($good_desc));
 * 
 */
// 用于测试的商户请求支付接口的表单参数,具体的表单参数各项的定义和取值参见接口文档
$content = $bfb_sdk->query_baifubao_pay_result_by_order_no($order_no);
if (false === $content) {
    $bfb_sdk->log('create the url for baifubao query interface failed');
} else {
    $bfb_sdk->log('create the url for baifubao query interface success');
    echo "查询成功\n";
    echo $content;