Thinkphp and micro-payment implementation of the micro-payment plug-in, in the micro-letter call micro-letter JSSDK Implementation Payment, here are detailed code and tutorials, specifically look here:
Implemented Wxpay Hook method public Function Wxpay ($param) {require './addons/wxpay/wxpaypubhelper/wxpaypubhelper.php ';
$jsApi = new \jsapi_pub (); ========= Step 1: Web page authorization to obtain user openid============ if (!isset ($_get[' code ')) {//Trigger micro-letter return code $url = $j Sapi->createoauthurlforcode (\wxpayconf_pub::js_api_call_url. ')
/order_id/'. $param [' order_id ']);
Header ("Location: $url");
}else {$order _id = $param [' order_id '];
$info = M (' order ')->where (' id= '. $order _id)->find ();
if (Empty ($info) | | | | $info [' is_pay '] = = 1) {dump (' The order does not exist or has been paid '. $order _id);
Exit ();
$this->assign (' info ', $info);
$a = $info [' Money '];
$b = 100;
$c = $a * $b;
Get the code code to get the OpenID $code = $_get[' code '];
$jsApi->setcode ($code);
$openid = $jsApi->getopenid (); //========= Step 2: Use the unified payment interface to obtain prepay_id============//Use UnifiedPayment interface $unifiedOrder = new \unifiedorder_pub ();
$unifiedOrder->setparameter ("OpenID", "$openid");//Product Description $unifiedOrder->setparameter ("Body", "online booking");//Product Description
Custom order number, here for example $timeStamp = time (); $out _trade_no = \wxpayconf_pub::appid. "
$timeStamp ";
$out _trade_no = $info [' ORDERSN ']; $unifiedOrder->setparameter ("Out_trade_no", "$out _trade_no");//Merchant Order number $unifiedOrder->setparameter ("Total_ Fee "," $c ")//Total amount $unifiedOrder->setparameter (" Notify_url ", \wxpayconf_pub::notify_url. ') /order_id/'. $param [' order_id '])//Notification address $unifiedOrder->setparameter ("Trade_type", "Jsapi");//transaction type $PR
epay_id = $unifiedOrder->getprepayid ();
========= Step 3: Use Jsapi to adjust payment ============ $jsApi->setprepayid ($prepay _id);
$jsApiParameters = $jsApi->getparameters ();
$this->assign (' jsapiparameters ', $jsApiParameters);
$this->display (' pay '); }
The above is the entire content of this article, I hope that you learn PHP program help.