Home Backend Development PHP Tutorial php支付宝接口用法分析_php技巧

php支付宝接口用法分析_php技巧

May 16, 2016 pm 08:26 PM
php interface Alipay usage

本文实例讲述了php支付宝接口用法。分享给大家供大家参考。具体分析如下:

现在流行的网站支持平台,支付宝当仁不让的老大了,现在我们就来告诉你如何使用支付宝api来做第三方支付,把支付宝放到自己网站来,代码如下:

alipay_config.php配置程序如下:

复制代码 代码如下:
*/
//alipay_config.php 配置程序
$interfaceurl = "https://www.alipay.com/payto:";
$sitename  = "网站名称";
$weburl   = "http://网站网址";
$o_fee   = "0.00";              //平邮费
$e_fee   = "0.00";              //快递费
$selleremail  = "";//支付宝账号
$payalikey  = "";//安全校验码
$imgurl   = "pay.gif"; //按钮图片源
$imgtitle  = "使用支付宝购买";           //按钮图片说明
?>

alipay.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;
 
 }
}
?>

 
pay.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  = "订单号:".$aliorder;
$body   = '商品介绍';
$order_no  = $aliorder;
$price   = $alimoney;
$url   = 'www.jb51.net';//你的网址
$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
 );
?>


简易支付宝付款php版



 

cellpadding=0 width=492 align=center border=0>
 
 
   
     
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

How To Set Up Visual Studio Code (VS Code) for PHP Development

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

How do you parse and process HTML/XML in PHP?

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

PHP Program to Count Vowels in a String

Sesame Open Door Login Registration Entrance gate.io Exchange Registration Official Website Entrance Sesame Open Door Login Registration Entrance gate.io Exchange Registration Official Website Entrance Mar 04, 2025 pm 04:51 PM

Sesame Open Door Login Registration Entrance gate.io Exchange Registration Official Website Entrance

How to get started with buying virtual coins? 2025 Ethereum Virtual Currency Newcomers' Guide How to get started with buying virtual coins? 2025 Ethereum Virtual Currency Newcomers' Guide Feb 21, 2025 pm 06:54 PM

How to get started with buying virtual coins? 2025 Ethereum Virtual Currency Newcomers' Guide

How to buy Bitcoin on Alipay? Alipay Buy BTC Complete Tutorial How to buy Bitcoin on Alipay? Alipay Buy BTC Complete Tutorial Mar 05, 2025 pm 06:03 PM

How to buy Bitcoin on Alipay? Alipay Buy BTC Complete Tutorial

List of handling fees for okx trading platform List of handling fees for okx trading platform Feb 15, 2025 pm 03:09 PM

List of handling fees for okx trading platform

See all articles