PHP Payment Treasure Interface Usage Analysis _php skill

Source: Internet
Author: User

This example describes the use of the PHP Alipay interface. Share to everyone for your reference. The specific analysis is as follows:

Now popular website support platform, Alipay is the boss, now we will tell you how to use the Alipay API to do third-party payments, put Alipay to their website, the code is as follows:

The alipay_config.php configuration program is as follows:

Copy Code code as follows:
<?php
*/
alipay_config.php Configuration Program
$interfaceurl = "Https://www.alipay.com/payto:";
$sitename = "website name";
$weburl = "http://website url";
$o _fee = "0.00"; Flat postage
$e _fee = "0.00"; Express Fee
$selleremail = "";//Alipay account number
$payalikey = "";//Safe Check code
$imgurl = "Pay.gif"; Button Picture Source
$imgtitle = "Buy with Alipay"; Button Picture Description
?>

The alipay.php code is as follows:
Copy Code code as follows:
<?php
/*********************************************************************
filename:alipay.php
Author:dboyzhang
Version:ver 2.0.0 Beta1
Contact_me:wangwang:dboyzhang
*********************************************************************/

alipay.php Code
Require_once ("alipay_config.php");
Class Alipay
{
function Geturl ($s 1, $s 2, $s 3, $s 4, $s 5, $s 6, $s 7, $s 8, $s 9, $s, $s, $s, $s, $s, $s, $s, $s, $s $s 21 , $s $s 23)
{
$parameter = Array (
' cmd ' => $s 1,
' Subject ' => $s 2,
' Body ' => $s 3,
' Order_no ' => $s 4,
' Price ' => $s 5,
' URL ' => $s 6,
' Type ' => $s 7,
' Number ' => $s 8,
' Transport ' => $s 9,
' Ordinary_fee ' => $s 10,
' Express_fee ' => $s 11,
' ReadOnly ' => $s 12,
' Buyer_msg ' => $s 13,
' Seller ' => $s 14,
' Buyer ' => $s 15,
' Buyer_name ' => $s 16,
' Buyer_address ' => $s 17,
' Buyer_zipcode ' => $s 18,
' Buyer_tel ' => $s 19,
' Buyer_mobile ' => $s 20,
' Partner ' => $s 21,
);

$url = $s $s 14. "?";
foreach ($parameter as $key => $value) {
if ($value) {
$url. = $key. " = ". UrlEncode ($value)." & ";
$acsouce. = $key. $value;
}
}
$url. = ' ac= ' MD5 ($acsouce. $s 23);
return $url;

}
}
?>


The pay.php page is as follows:
Copy Code code as follows:
<?php
error_reporting (0);
$aliname =$_post["Aliname"];
$alizipcode =$_post["Alizipcode"];
$aliphone =$_post["Aliphone"];
$aliaddress =$_post["Aliaddress"];
$aliorder =$_post["Aliorder"];
$alimailtype =$_post["Alimailtype"];
$alimoney =$_post["Alimoney"];
$alimob =$_post["Alimob"];
$alibody =$_post["Alibody"];

Require_once ("alipay_config.php");
Require_once ("alipay.php");

$cmd = ' 0001 ';
$subject = "Order number:". $aliorder;
$body = ' commodity introduction ';
$order _no = $aliorder;
$price = $alimoney;
$url = ' www.jb51.net ';//Your website
$type = ' 1 ';
$number = ' 1 ';
$transport = $alimailtype;
$ordinary _fee = ' 0.00 ';
$express _fee = ' 0.00 ';
$readonly = ' true ';
$buyer _msg = $alibody;
$seller = $selleremail;
$buyer = ';
$buyer _name = $aliname;
$buyer _address = $aliaddress;
$buyer _zipcode = $alizipcode;
$buyer _tel = $aliphone;
$buyer _mobile = $alimob;
$partner = ' 2088002008096997 ';

$geturl = new Alipay;
$link = $geturl->geturl
(
$cmd, $subject, $body, $order _no, $price, $url, $type, $number, $transport,
$ordinary _fee, $express _fee, $readonly, $buyer _msg, $seller, $buyer,
$buyer _name, $buyer _address, $buyer _zipcode, $buyer _tel, $buyer _mobile, $partner,
$interfaceurl, $payalikey
);
?>


<title> Easy Alipay Payment PHP version </title>
<link href= "Admin_style.css Tutorial" rel=stylesheet>
<meta http-equiv=content-type content= "text/html; charset=gb2312 ">


<body>
<table class=border id=table1 style= "font-size:9pt" height=185 cellspacing=0
Cellpadding=0 width=492 Align=center border=0>
<tbody>
<tr>
&LT;TD CLASS=TOPBG height=30>
<div align=center><strong> Easy Alipay payment PHP version </strong></div></td></tr>
<tr>
&LT;TD style= "Border-left: #e4e4e4 1px solid; Border-bottom: #e4e4e4 1px solid "colspan=3 height=150>
<table style= "font-size:9pt" height=137 width= "100%" Align=center bgcolor= #ffffff >
<tbody>
<tr class=tdbg>
&LT;TD width= "14%" > Order number:</td>
&LT;TD width= "86%" &GT;&LT;? echo $aliorder;?></td></tr>
<tr class=tdbg>
&LT;TD width= "14%" > Consignee:</td>
&LT;TD width= "86%" &GT;&LT;? echo $aliname;?></td></tr>
<tr class=tdbg>
&LT;TD width= "14%" > Payment amount:</td>
&LT;TD width= "86%" &GT;&LT;B&GT;&LT;? echo $alimoney;?></b></td></tr>
<tr class=tdbg>
&LT;TD width= "14%" > Delivery address:</td>
&LT;TD width= "86%" &GT;&LT;? echo $aliaddress;?></td></tr>
<tr class=tdbg>
<td> Logistics Mode:</td>
<td><? Echo $alimailtype?> (1.2 Express 3. Virtual goods) </td></tr>
<tr class=tdbg>
<td> Contact Tel:</td>
<td><? echo $aliphone;?></td></tr>
<tr class=tdbg>
<td> Postal Code:</td>
<td><? echo $alizipcode;?></td></tr>
<tr class=tdbg>
<td> Mobile phone number:</td>
<td><? echo $alimob;?></td></tr>
<tr class=tdbg>
<td> Customer Message:</td>
<td><? echo $alibody;?></td></tr>
<tr class=tdbg>
<td></td>
<td><input type= "button" Name= "submit21" onclick= "Web Effects: History.go ( -1)" value= "Return to modify Order" > <a href= " PHP echo $link?> "target=" _blank "> "alt=" <?php Echo $imgtitle?> " Border= "0" align= ' absmiddle ' border= ' 0 '/></a> </td></tr></tbody></table></td ></tr></tbody></table>
</body>

I hope this article will help you with your PHP program design.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.