php支付寶接口用法分析
php支付寶接口用法,以實例形式較為詳細的'分析了php支付寶接口的使用技巧,具有一定參考借鑒價值,需要的朋友可以參考下.
現(xiàn)在流行的網(wǎng)站支持平臺,支付寶當(dāng)仁不讓的老大了,現(xiàn)在我們就來告訴你如何使用支付寶api來做第三方支付,把支付寶放到自己網(wǎng)站來,代碼如下:
alipay_config.php配置程序如下:
復(fù)制代碼 代碼如下:
<?php
*/
//alipay_config.php 配置程序
$interfaceurl = "https://www.alipay.com/payto:";
$sitename = "網(wǎng)站名稱";
$weburl = "http://網(wǎng)站網(wǎng)址";
$o_fee = "0.00"; //平郵費
$e_fee = "0.00"; //快遞費
$selleremail = "";//支付寶賬號
$payalikey = "";//安全校驗碼
$imgurl = "pay.gif"; //按鈕圖片源
$imgtitle = "使用支付寶購買"; //按鈕圖片說明
?>
alipay.php代碼如下:
復(fù)制代碼 代碼如下:
<?php
/*********************************************************************
filename: alipay.php
author: dboyzhang
version: ver 2.0.0 beta1
contact_me: wangwang:dboyzhang
*********************************************************************/
//alipay.php代碼
require_once("alipay_config.php");
class alipay
{
function geturl($s1,$s2,$s3,$s4,$s5,$s6,$s7,$s8,$s9,$s10,$s11,$s12,$s13,$s14,$s15,$s16,$s17,$s18,$s19,$s20,$s21,$s22,$s23)
{
$parameter = array(
'cmd' => $s1,
'subject' => $s2,
'body' => $s3,
'order_no' => $s4,
'price' => $s5,
'url' => $s6,
'type' => $s7,
'number' => $s8,
'transport' => $s9,
'ordinary_fee' => $s10,
'express_fee' => $s11,
'readonly' => $s12,
'buyer_msg' => $s13,
'seller' => $s14,
'buyer' => $s15,
'buyer_name' => $s16,
'buyer_address' => $s17,
'buyer_zipcode' => $s18,
'buyer_tel' => $s19,
'buyer_mobile' => $s20,
'partner' => $s21,
);
$url = $s22.$s14."?";
foreach($parameter as $key => $value){
if($value){
$url .= $key."=".urlencode($value)."&";
$acsouce .=$key.$value;
}
}
$url .= 'ac='.md5($acsouce.$s23);
return $url;
}
}