예제 #1
0
$business = new Business();
$business->appid(APPID);
$business->appsecret(APPSECRET);
$business->mch_id(MCHID);
$business->mch_key(MCHKEY);
// print_r($business->getParams());
/**
 * 第 2 步:定义订单
 */
$order = new Order();
$order->body('iphone 6 plus');
$order->out_trade_no(date('Y-m-dHis') . mt_rand(10000, 99999));
$order->total_fee('1');
// $order->openid($_SESSION['openid']);
$order->openid('oWY-5jjLjo7pYUK86JPpwvcnF2Js');
$order->notify_url('http://code.1999.me/Wechat/example/payment_notify.php');
// print_r($order->getParams());
/**
 * 第 3 步:统一下单
 */
$unifiedorder = new Unifiedorder();
$unifiedorder->setBusiness($business);
$unifiedorder->setOrder($order);
/**
 * 第 4 步:生成支付配置文件
 */
$o = new Payment($unifiedorder);
$configJSON = $o->getConfig();
?>

<!DOCTYPE html>
예제 #2
0
 * $business->setClientKey('/your/path/to/apiclient_key.pem');
 */
$business = new Business();
$business->appid(APPID);
$business->appsecret(APPSECRET);
$business->mch_id(MCHID);
$business->mch_key(MCHKEY);
/**
 * 第 2 步:定义订单
 */
$order = new Order();
$order->body('iphone 6 plus');
$order->out_trade_no(date('Y-m-dHis') . mt_rand(10000, 99999));
$order->total_fee('1');
$order->openid($_SESSION['openid']);
$order->notify_url(NOTIFY_URL);
/**
 * 第 3 步:统一下单
 */
$unifiedorder = new Unifiedorder();
$unifiedorder->setBusiness($business);
$unifiedorder->setOrder($order);
/**
 * 第 4 步:生成支付配置文件
 */
try {
    $payment = new Payment($unifiedorder);
    $config = $payment->getConfigJssdk();
} catch (Exception $e) {
    exit($e->getMessage());
}
예제 #3
0
//     "sign" => "1ED0F1A052F5212009E7C5DB89C57789"
// );
/**
 * 统一下单
 */
$business = new Business();
$business->appid(APPID);
$business->appsecret(APPSECRET);
$business->mch_id(MCHID);
$business->mch_key(MCHKEY);
$order = new Order();
$order->body('iphone 6 plus');
$order->out_trade_no(date('Y-m-dHis') . mt_rand(10000, 99999));
$order->total_fee('1');
$order->openid($request['openid']);
$order->notify_url('Your notify url');
$unifiedorder = new Unifiedorder($business, $order);
$response = $unifiedorder->getResponse();
/**
 * 响应订单
 */
$params = array('return_code' => 'SUCCESS', 'result_code' => 'SUCCESS', 'return_msg' => 'return message', 'appid' => $request['appid'], 'err_code_des' => 'err code description', 'mch_id' => $request['mch_id'], 'nonce_str' => $request['nonce_str'], 'prepay_id' => $response['prepay_id']);
$signGenerator = new SignGenerator($params);
$signGenerator->onSortAfter(function ($that) {
    $that->addParams('key', MCHKEY);
});
$params['sign'] = $signGenerator->getResult();
$xml = Util::array2XML($params);
echo $xml;
// {
//     "appid":"wx345f3830c28971f4",
예제 #4
0
$business = new Business();
$business->appid(APPID);
$business->appsecret(APPSECRET);
$business->mch_id(MCHID);
$business->mch_key(MCHKEY);
// print_r($business->getParams());
/**
 * 第 2 步:定义订单
 */
$order = new Order();
$order->body('iphone 6 plus');
$order->out_trade_no(date('Y-m-dHis') . mt_rand(10000, 99999));
$order->total_fee('1');
// $order->openid($_SESSION['openid']);
$order->openid('oWY-5jjLjo7pYUK86JPpwvcnF2Js');
$order->notify_url(Util::currentUrl());
// print_r($order->getParams());
/**
 * 第 3 步:统一下单
 */
$unifiedorder = new Unifiedorder();
$unifiedorder->setBusiness($business);
$unifiedorder->setOrder($order);
/**
 * 第 4 步:生成支付配置文件
 */
$o = new Payment($unifiedorder);
$configJSON = $o->getConfigJssdk();
?>

<!DOCTYPE html>