支付宝接口开发集成支付环境小结
本文主要给大家分享的是在做支付宝接口开发集成支付环境的全过程,非常的详细,搭配示例代码,是篇非常不错的文章,这里推荐给大家,有需要的小伙伴参考下。
关于支付宝的接口集成气死是很简单,目前大概有3种类型,即时到帐、双功能、担保交易,只需要集成一次担保交易,其他的比如即时到帐集成很容易,担保交易的状态有几种,比如:是否支付成功,卖家是否发货,买家确认收获等。而即时到帐只有一种,就是是否已付款!最多还有个退款的功能。一般都没用到。
通过之前做项目:配资平台,有个预付费的功能,用到了支付宝的双功能收款,其实就是提供两种付款方式,即时到帐和担保交易。一般买家谨慎会选择担保。
下面说下具体的集成过程,第一:下载对应的集成接口包,比如即时到帐就下载即时到帐,担保下载担保,非常不建议将即时到帐修改成担保或者反之。案例中我下载的 双功能接口文件,utf8-php接口。
下载来的文件都大同小异,即时到帐和担保的文件也相差不大,反正可以肯定的说,只要配置一次担保支付宝接口,就能配置即时到帐。
我们需要修改的文件有如下:alipay.config.php[配置文件,只是用于修改配置接口开发者id和key]
alipayapi.php[主调文件,将需要发送的post数据交给该文件,然后负责跳转到支付页面]
index.php[demo演示页面,可以不做修改,但是其中传递的参数名陈需要看懂]
notify_url.php 返回数据页面,在其中将返回交易的状态,更具状态我们可以更改数据库订单信息,,该文件是通过post方式接受。
return_url.php 返回数据页面,在其中将返回交易的状态,更具状态我们可以更改数据库订单信息,该文件是通过GET方式。
具体过程:
第一步,修改配置信息:
复制代码 代码如下:
$alipay_config['partner'] = 'xxx8511073xxxxxxxx';
//安全检验码,以数字和字母组成的32位字符
$alipay_config['key'] ='xxxxxxxxnow07oajbflskxxxxxxxxxx';
第二:拼post数据,一般只需要修改请求参数
复制代码 代码如下:
/**************************请求参数**************************/
//支付类型
$payment_type = "1";
//必填,不能修改
//服务器异步通知页面路径
$notify_url = "http://你的域名/alipay/notify_url.php";
//需格式的完整路径,不能加?id=123这类自定义参数
//页面跳转同步通知页面路径
$return_url = "http://你的域名/alipay/return_url.php";
//需格式的完整路径,不能加?id=123这类自定义参数,不能写成
//卖家支付宝帐户
$seller_email = $_POST['WIDseller_email'];//demo[index.php]传过来的
//必填
//商户订单号
$out_trade_no = $_POST['WIDout_trade_no'];//传过来的
//商户网站订单系统中唯一订单号,必填
//订单名称
$subject = $_POST['WIDsubject'];//同上
//必填
//付款金额
$price = $_POST['WIDprice'];//传过来的,是你的表单中填写的值
//必填
//商品数量
$quantity = "1";
//必填,建议默认为1,不改变值,把一次交易看成是一次下订单而非购买一件商品
//物流费用
$logistics_fee = "0.00";
//必填,即运费
//物流类型
$logistics_type = "EXPRESS";
//必填,三个值可选:EXPRESS(快递)、POST(平邮)、EMS(EMS)
//物流支付方式
$logistics_payment = "SELLER_PAY";
//必填,两个值可选:SELLER_PAY(卖家承担运费)、BUYER_PAY(买家承担运费)
//订单描述
$body = $_POST['WIDbody'];
//商品展示地址
$show_url = $_POST['WIDshow_url'];
//需以开头的完整路径,如:
//收货人姓名
$receive_name = '萤火';
//如:张三
//收货人地址
$receive_address = $_POST['WIDreceive_address'];
//如:XX省XXX市XXX区XXX路XXX小区XXX栋XXX单元XXX号
//收货人邮编
$receive_zip = $_POST['WIDreceive_zip'];
//如:123456
//收货人电话号码
$receive_phone = $_POST['WIDreceive_phone'];
//如:0571-88158090
//收货人手机号码
$receive_mobile = $_POST['WIDreceive_mobile'];
//如:13312341234
第三:数据构造完成后就可以在页面上付款,测试能不能正确的打开支付页面。如果能打开,这时候就可以进行付款了,但是买家付款的状态我们还无法获知,比如有没有成功付款,卖家是否已经发货等。那么接下来开始做返回状态的业务逻辑处理。
打开return_url.php文件,根据提示修改,做对因的处理。
复制代码 代码如下:

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Alipay PHP...

Problem Description When calling Alipay EasySDK using PHP, after filling in the parameters according to the official code, an error message was reported during operation: "Undefined...

The OKX trading platform offers a variety of rates, including transaction fees, withdrawal fees and financing fees. For spot transactions, transaction fees vary according to transaction volume and VIP level, and adopt the "market maker model", that is, the market charges a lower handling fee for each transaction. In addition, OKX also offers a variety of futures contracts, including currency standard contracts, USDT contracts and delivery contracts, and the fee structure of each contract is also different.

This article provides a detailed guide to safe download of Ouyi OKX App in China. Due to restrictions on domestic app stores, users are advised to download the App through the official website of Ouyi OKX, or use the QR code provided by the official website to scan and download. During the download process, be sure to verify the official website address, check the application permissions, perform a security scan after installation, and enable two-factor verification. During use, please abide by local laws and regulations, use a safe network environment, protect account security, be vigilant against fraud, and invest rationally. This article is for reference only and does not constitute investment advice. Digital asset transactions are at your own risk.

H5. The main difference between mini programs and APP is: technical architecture: H5 is based on web technology, and mini programs and APP are independent applications. Experience and functions: H5 is light and easy to use, with limited functions; mini programs are lightweight and have good interactiveness; APPs are powerful and have smooth experience. Compatibility: H5 is cross-platform compatible, applets and APPs are restricted by the platform. Development cost: H5 has low development cost, medium mini programs, and highest APP. Applicable scenarios: H5 is suitable for information display, applets are suitable for lightweight applications, and APPs are suitable for complex functions.

The main difference between an abstract class and an interface is that an abstract class can contain the implementation of a method, while an interface can only define the signature of a method. 1. Abstract class is defined using abstract keyword, which can contain abstract and concrete methods, suitable for providing default implementations and shared code. 2. The interface is defined using the interface keyword, which only contains method signatures, which is suitable for defining behavioral norms and multiple inheritance.

Gate.io (Sesame Open Door) is the world's leading cryptocurrency trading platform. This article provides a complete tutorial on spot trading of Gate.io. The tutorial covers steps such as account registration and login, KYC certification, fiat currency and digital currency recharge, trading pair selection, limit/market transaction orders, and orders and transaction records viewing, helping you quickly get started on the Gate.io platform for cryptocurrency trading. Whether a beginner or a veteran, you can benefit from this tutorial and easily master the Gate.io trading skills.

The choice of H5 and applet depends on the requirements. For applications with cross-platform, rapid development and high scalability, choose H5; for applications with native experience, rich functions and platform dependencies, choose applets.
