thinkphp and micro-payment implementation of the payment plug-in, called in the JSSDK implementation payment, here are detailed code and tutorials, specifically see here:
The implementation of the Wxpay hook method public Function Wxpay ($param) {require './addons/wxpay/wxpaypubhelper/wxpaypubhelper.php '; $jsApi = new \jsapi_pub (); ========= Step 1: Web authorization to get user openid============ if (!isset ($_get[' code ')) {//Trigger return code code $URL = $jsApi-& Gt;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 to get OpenID $code = $_get[' code '); $jsApi->setcode ($code); $openid = $jsApi->getopenid (); //========= Step 2: Use unified payment interface, get prepay_id============//Use unified Payment Interface $unifiedOrder = new \uniFiedorder_pub (); $unifiedOrder->setparameter ("OpenID", "$openid");//Description $unifiedOrder->setparameter ("Body", "online booking")//Product Description/ /custom order number, for example only $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 $prepa y_id = $unifiedOrder->getprepayid (); ========= Step 3: Use JsApi to adjust the payment ============ $jsApi->setprepayid ($prepay _id); $jsApiParameters = $jsApi->getparameters (); $this->assign (' jsapiparameters ', $jsApiParameters); $this->display (' pay '); }
The above is the whole content of this article, I hope that you learn PHP programming help.
The above describes the thinkphp and Onethink implementation of payment plug-ins, including the thinkphp aspects of the content, I hope that the PHP tutorial interested in a friend helpful.