PHP tutorial Alipay interface program source code (full version with examples)
Now popular web site support platform, Alipay doing my part, and now we will tell you how to use Alipay api to do third-party payment, Alipay into their own website to Kazakhstan.
* /
//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"; // courier fee
$ selleremail = ""; // Alipay account
$ payalikey = ""; / / safety code
$ imgurl = "pay.gif"; // button image source
$ imgtitle = "Buy with Alipay"; // button image caption
?>
<? 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 ($ 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;
}
}
?>
pay.php page
<?
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 = 'Product Description';
$ order_no = $ aliorder;
$ price = $ alimoney;
$ url = 'www.jzread.com'; // your web site
$ 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
);
?>
<html>
<head>
<title> Simple PayPal payment php version </ title>
<link href = "admin_style.css tutorial" rel = stylesheet>
<meta http-equiv = content-type content = "text / html; charset = gb2312">
</ head>
<body>
<table class = border id = table1 style = "font-size: 9pt" height = 185 cellspacing = 0
cellpadding = 0 width = 492 align = center border = 0>
<tbody>
<tr>
<td class = topbg height = 30>
<div align = center> <strong> Simple PayPal payment php version </ strong> </ div> </ td> </ tr>
<tr>
<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>
<td width = "14%"> Order Number: </ td>
<td width = "86%"> <? echo $ aliorder;?> </ td> </ tr>
<tr class = tdbg>
<td width = "14%"> Consignee: </ td>
<td width = "86%"> <? echo $ aliname;?> </ td> </ tr>
<tr class = tdbg>
<td width = "14%"> Payment Amount: </ td>
<td width = "86%"> <b> <? echo $ alimoney;?> </ b> </ td> </ tr>
<tr class = tdbg>
<td width = "14%"> Shipping Address: </ td>
<td width = "86%"> <? echo $ aliaddress;?> </ td> </ tr>
<tr class = tdbg>
<td> Logistics: </ td>
<td> <? echo $ alimailtype;?> (1. Plain mail 2. Express 3. Virtual items) </ td> </ tr>
<tr class = tdbg>
<td> Contact Number: </ td>
<td> <? echo $ aliphone;?> </ td> </ tr>
<tr class = tdbg>
<td> Postal Code: </ td>
<td> <? echo $ alizipcode;?> </ td> </ tr>
<tr class = tdbg>
<td> phone number: </ td>
<td> <? echo $ alimob;?> </ td> </ tr>
<tr class = tdbg>
<td> Guestbook: </ td>
<td> <? echo $ alibody;?> </ td> </ tr>
<tr class = tdbg>
<td> </ td>
<td> <input type = "button" name = "submit21" onclick = "webpage special effects: history.go (-1)" value = "return to change order"> & nbsp; & nbsp; & nbsp; & nbsp ; <a href="<?php echo $ link ?> "target =" _ blank "> <img src =" <? php echo $ imgurl?> "alt =" <? php echo $ imgtitle?> "border =" 0 "align = 'absmiddle' border = '0' /> </a> </ td> </ tr> </ tbody> </ table> </ td> </ tr> </ tbody> </ table>
</ body> </ html>