示例#1
0
文件: pay_wap.php 项目: aspnmy/weizan
$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));
/*
 * 字符编码转换,百付宝默认的编码是GBK,商户网页的编码如果不是,请转码。涉及到中文的字段请参见接口文档
 * 步骤:
 * 1. URL转码
 * 2. 字符编码转码,转成GBK
 * 
 * $good_name = iconv("UTF-8", "GBK", urldecode($good_name));
 * $good_desc = iconv("UTF-8", "GBK", urldecode($good_desc));
 * 
 */
// 用于测试的商户请求支付接口的表单参数,具体的表单参数各项的定义和取值参见接口文档
$params = array('service_code' => sp_conf::BFB_PAY_INTERFACE_SERVICE_ID, 'sp_no' => sp_conf::SP_NO, 'order_create_time' => $order_create_time, 'order_no' => $order_no, 'goods_name' => $good_name, 'goods_desc' => $good_desc, 'goods_url' => $goods_url, 'unit_amount' => $unit_amount, 'unit_count' => $unit_count, 'transport_amount' => $transport_amount, 'total_amount' => $total_amount, 'currency' => sp_conf::BFB_INTERFACE_CURRENTCY, 'buyer_sp_username' => $buyer_sp_username, 'return_url' => $return_url, 'page_url' => $page_url, 'pay_type' => $pay_type, 'bank_no' => $bank_no, 'expire_time' => $expire_time, 'input_charset' => sp_conf::BFB_INTERFACE_ENCODING, 'version' => sp_conf::BFB_INTERFACE_VERSION, 'sign_method' => sp_conf::SIGN_METHOD_MD5, 'extra' => $extra);
$order_url = $bfb_sdk->create_baifubao_pay_order_url($params, sp_conf::BFB_PAY_WAP_DIRECT_URL);
if (false === $order_url) {
    $bfb_sdk->log('create the url for baifubao pay interface failed');
} else {
    $bfb_sdk->log(sprintf('create the url for baifubao pay interface success, [URL: %s]', $order_url));
    echo "<script>window.location=\"" . $order_url . "\";</script>";
}
示例#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, "充值"));
}
/*
 * 此处是商户收到百付宝支付结果通知后需要做的自己的具体业务逻辑,比如记账之类的。 只有当商户收到百付宝支付 结果通知后,
 * 所有的预处理工作都返回正常后,才执行该部分
 */
// 向百付宝发起回执
示例#3
0
/**
 * 这个是调用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;
}