Exemplo n.º 1
0
 * 第 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>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Wechat SDK</title>
</head>
<body ontouchstart="">