日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

html wap php,wap.php

發布時間:2024/9/27 php 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 html wap php,wap.php 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

header('Content-type:text/html; Charset=utf-8');

/*** 請填寫以下配置信息 ***/

$appid = 'xxxxx'; //https://open.alipay.com 賬戶中心->密鑰管理->開放平臺密鑰,填寫添加了電腦網站支付的應用的APPID

$returnUrl = 'http://www.xxx.com/alipay/return.php'; //付款成功后的同步回調地址

$notifyUrl = 'http://www.xxx.com/alipay/notify.php'; //付款成功后的異步回調地址

$outTradeNo = uniqid(); //你自己的商品訂單號

$payAmount = 0.01; //付款金額,單位:元

$orderName = '支付測試'; //訂單標題

$signType = 'RSA2';//簽名算法類型,支持RSA2和RSA,推薦使用RSA2

$rsaPrivateKey='xxxxx';//商戶私鑰,填寫對應簽名算法類型的私鑰,如何生成密鑰參考:https://docs.open.alipay.com/291/105971和https://docs.open.alipay.com/200/105310

/*** 配置結束 ***/

$aliPay = new AlipayService();

$aliPay->setAppid($appid);

$aliPay->setReturnUrl($returnUrl);

$aliPay->setNotifyUrl($notifyUrl);

$aliPay->setRsaPrivateKey($rsaPrivateKey);

$aliPay->setTotalFee($payAmount);

$aliPay->setOutTradeNo($outTradeNo);

$aliPay->setOrderName($orderName);

$sHtml = $aliPay->doPay();

echo $sHtml;

class AlipayService

{

protected $appId;

protected $charset;

protected $returnUrl;

protected $notifyUrl;

//私鑰值

protected $rsaPrivateKey;

protected $totalFee;

protected $outTradeNo;

protected $orderName;

public function __construct()

{

$this->charset = 'utf8';

}

public function setAppid($appid)

{

$this->appId = $appid;

}

public function setReturnUrl($returnUrl)

{

$this->returnUrl = $returnUrl;

}

public function setNotifyUrl($notifyUrl)

{

$this->notifyUrl = $notifyUrl;

}

public function setRsaPrivateKey($rsaPrivateKey)

{

$this->rsaPrivateKey = $rsaPrivateKey;

}

public function setTotalFee($payAmount)

{

$this->totalFee = $payAmount;

}

public function setOutTradeNo($outTradeNo)

{

$this->outTradeNo = $outTradeNo;

}

public function setOrderName($orderName)

{

$this->orderName = $orderName;

}

/**

* 發起訂單

* @return array

*/

public function doPay()

{

//請求參數

$requestConfigs = array(

'out_trade_no'=>$this->outTradeNo,

'product_code'=>'QUICK_WAP_WAY',

'total_amount'=>$this->totalFee, //單位 元

'subject'=>$this->orderName, //訂單標題

);

$commonConfigs = array(

//公共參數

'app_id' => $this->appId,

'method' => 'alipay.trade.wap.pay', //接口名稱

'format' => 'JSON',

'return_url' => $this->returnUrl,

'charset'=>$this->charset,

'sign_type'=>'RSA2',

'timestamp'=>date('Y-m-d H:i:s'),

'version'=>'1.0',

'notify_url' => $this->notifyUrl,

'biz_content'=>json_encode($requestConfigs),

);

$commonConfigs["sign"] = $this->generateSign($commonConfigs, $commonConfigs['sign_type']);

return $this->buildRequestForm($commonConfigs);

}

/**

* 建立請求,以表單HTML形式構造(默認)

* @param $para_temp 請求參數數組

* @return 提交表單HTML文本

*/

protected function buildRequestForm($para_temp) {

$sHtml = "

";

while (list ($key, $val) = each ($para_temp)) {

if (false === $this->checkEmpty($val)) {

$val = str_replace("'","'",$val);

$sHtml.= "";

}

}

//submit按鈕控件請不要含有name屬性

$sHtml = $sHtml."

";

$sHtml = $sHtml."";

return $sHtml;

}

public function generateSign($params, $signType = "RSA") {

return $this->sign($this->getSignContent($params), $signType);

}

protected function sign($data, $signType = "RSA") {

$priKey=$this->rsaPrivateKey;

$res = "-----BEGIN RSA PRIVATE KEY-----\n" .

wordwrap($priKey, 64, "\n", true) .

"\n-----END RSA PRIVATE KEY-----";

($res) or die('您使用的私鑰格式錯誤,請檢查RSA私鑰配置');

if ("RSA2" == $signType) {

openssl_sign($data, $sign, $res, version_compare(PHP_VERSION,'5.4.0', '

} else {

openssl_sign($data, $sign, $res);

}

$sign = base64_encode($sign);

return $sign;

}

/**

* 校驗$value是否非空

* if not set ,return true;

* if is null , return true;

**/

protected function checkEmpty($value) {

if (!isset($value))

return true;

if ($value === null)

return true;

if (trim($value) === "")

return true;

return false;

}

public function getSignContent($params) {

ksort($params);

$stringToBeSigned = "";

$i = 0;

foreach ($params as $k => $v) {

if (false === $this->checkEmpty($v) && "@" != substr($v, 0, 1)) {

// 轉換成目標字符集

$v = $this->characet($v, $this->charset);

if ($i == 0) {

$stringToBeSigned .= "$k" . "=" . "$v";

} else {

$stringToBeSigned .= "&" . "$k" . "=" . "$v";

}

$i++;

}

}

unset ($k, $v);

return $stringToBeSigned;

}

/**

* 轉換字符集編碼

* @param $data

* @param $targetCharset

* @return string

*/

function characet($data, $targetCharset) {

if (!empty($data)) {

$fileType = $this->charset;

if (strcasecmp($fileType, $targetCharset) != 0) {

$data = mb_convert_encoding($data, $targetCharset, $fileType);

//$data = iconv($fileType, $targetCharset.'//IGNORE', $data);

}

}

return $data;

}

}

一鍵復制

編輯

Web IDE

原始數據

按行查看

歷史

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的html wap php,wap.php的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。