微信JSAPI支付

2022-08-29 15:15:20 字數 2191 閱讀 7421

private

$snsapi_base_url = '';

$param = array

( 'redirect_uri' => '**位址', //

'response_type' => 'code',

'scope' => 'snsapi_base',

'state' =>』訂單號『

//注意事項

//1.獲取使用者openid 官方文件的寫法如下

$tools = new jsapipay();

$openid = $tools->getopenid();

//改成如下

$tools = new jsapipay();

$openid = $tools->getopenidfrommp($_get['code']); //如果是liunx系統,注意區分大小寫 (官方都是不區分大小寫的)

//2.

$input = new wxpayunifiedorder();

$input->setbody("test"); //商品描述

$input->setattach("test"); //附加資訊

$input->setout_trade_no($order_sn); //商品訂單號

$input->settotal_fee("1"); //商品費用 注意:以』分『為單位

$input->settime_start(date("ymdhis"));

//$input->settime_expire(date("ymdhis", time() + 600)); 直接去掉吧

$input->setgoods_tag("test"); //商品標記

$input->setnotify_url(""); //通知位址,官方文件中的notify.php,作用:處理支付成功後的訂單狀態及相關資訊。

$input->settrade_type("jsapi");

$input->setopenid($openid);

$order = wxpayapi::unifiedorder($input);

//3.注意引用檔案的路徑

7.開啟notify.php

一、將官方文件中的log::全部改成logwx::(因為官方定義的類是logwx,但在這裡引用的時候變成了log,坑啊)。

三、

<?php

ini_set('date.timezone','asia/shanghai');

error_reporting(e_error

);require_once "lib/wxpay.api.php";

require_once 'lib/wxpay.notify.php';

require_once 'log.php';

//初始化日誌

$loghandler= new clogfilehandler("logs/".date('y-m-d').'.log');

$log = logwx::init($loghandler, 15);

class paynotifycallback extends

wxpaynotify

return

false

; }

//重寫**處理函式

public

function notifyprocess($data, &$msg

)

//查詢訂單,判斷訂單真實性

if(!$this->queryorder($data["transaction_id"]))

//通過$data['out_trade_no'],在這裡處理訂單狀態

微信支付 微信JSAPI支付

pay.php baby extend wx pay.php namespace wx class pay 通過redirecturi獲取授權資訊 return mixed public function getauthinfo 通過code換取網頁授權資訊 res this curlgetreq ...

微信支付JSAPI支付

這裡是報錯 下面是前端拿到資料後的一些操作 var jsapi ajax success function str function jsapicall function callpay else if document.attachevent else 把乙個官方sdk整合到thinkphp框架中...

微信支付JSAPI支付

1.介紹 2.商戶號配置 開發jsapi支付時,在統一下單介面中要求必傳使用者openid,而獲取openid則需要您在公眾平台設定獲取openid的網域名稱 只有被設定過的網域名稱才是乙個有效的獲取openid的網域名稱,否則將獲取失敗。由於我們公司只需要獲取code調取後台介面換取openid,...