Home Backend Development PHP Tutorial PHP做支付宝即时到账需注意

PHP做支付宝即时到账需注意

Jun 23, 2016 pm 01:43 PM

注意:1按照人家的参数规则,规范填写参数列表;2商家信息填写正确;3然后提交走后注意此时告别了咱们的服务器,将在咱们服务器的订单信息提交到了支付宝服务器,然后支付宝服务器进行支付宝支付流程,当如果支付成功了显示@@@@@@不要高兴太早,这才是个开始噢,然后就是支付宝一个异步回调一个同步通知环节。同步一般就是告诉用户支付成功,也就是你的钱已经给了别人了,,此时用户关心,给到了没有,也就是异步操作************特别注意回调环节首先支付宝自己会对该笔订单进行安全等验证---包括签名验证://计算得出通知验证结果
$alipayNotify = new AlipayNotify($alipay_config);
$verify_result = $alipayNotify->verifyNotify();


这个$verify_result 是签名等验证是否成功的返回结果,具体验证环节就在$alipayNotify->verifyNotify();所调用的这个函数里,我被坑了一下

 /**
     * 获取返回时的签名验证结果
     * @param $para_temp 通知返回来的参数数组
     * @param $sign 返回的签名结果
     * @return 签名验证结果
     */
function getSignVeryfy($para_temp, $sign) {
unset($para_temp['_URL_']);
//除去待签名参数数组中的空值和签名参数
$para_filter = paraFilter($para_temp);

//对待签名参数数组排序
$para_sort = argSort($para_filter);

//把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
$prestr = createLinkstring($para_sort); 
 
$isSgin = false;
switch (strtoupper(trim($this->alipay_config['sign_type']))) {
case "MD5" :
$isSgin = md5Verify($prestr, $sign, trim($this->alipay_config['key']));
break;
default :
$isSgin = false;
}

return $isSgin;
}

这个签名验证$para_temp也就是人家返回的参数列表,thinkPHP 的URL是pathinfo模式,返回的是?&正常的参数串,不知道为什么自己给参数串加了个_URL_这个作为参数弄进去了,结果造成



/**
 * 验证签名
 * @param $prestr 需要签名的字符串
 * @param $sign 签名结果
 * @param $key 私钥
 * return 签名结果
 */
function md5Verify($prestr, $sign, $key) {
$prestr = $prestr . $key;
$mysgin = md5($prestr);
return $mysgin;
if($mysgin == $sign) {        //造成mysgin和人家返回的sign签名不一致,,,无语喽!!想都想不到是pathinfo搞得,,,用unset($para_temp['_URL_']);删掉了这个参数解决了!
return true;
}
else {
return false;
}
}


这个问题告别了,又来了一个,,,是我个人二了!!!嘿嘿没有搞清楚当前服务器是我还是支付宝,,,我操作异步回调,给数据库里面,加入订单支付的订单信息,但是获取当前用户session中存的uid,呵呵了!!!就是获取不到,人家现在在支付宝服务器,而你的session是存在了咱自己的服务器,,,所以就呵呵了啊!!想把办法把你的uid让他会传给你,,,自己想办法吧



这个问题告别了,,又又来了一个,,还是自己二二了,,,没看人家回调函数的要求,,,当你操作完订单什么的,,,然后给人家输出success  注意啊注意,之前不要有任何的输出,,,你返回的这个success是告诉支付宝,你操作订单是否完成的一个标志,,如果支付宝服务器接收到了success,然后人家就停止回调传参数了,,,如果人家查不到你返回的信息是success,,这个时候支付宝孩子就会不断的调用回调方法

,,,这个时候就会造成,用户存了一毛,然后支付宝不断回调你的回调方法,,,造成订单表不断修改……………………无语楼!!!大家注意一下!!!

http://help.alipay.com/support/help_detail.htm?help_id=397375&keyword=%B6%E0%B4%CE%D2%EC%B2%BD%BB%D8%B5%F7


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 AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

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)

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

How does session hijacking work and how can you mitigate it in PHP? How does session hijacking work and how can you mitigate it in PHP? Apr 06, 2025 am 12:02 AM

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

What are Enumerations (Enums) in PHP 8.1? What are Enumerations (Enums) in PHP 8.1? Apr 03, 2025 am 12:05 AM

The enumeration function in PHP8.1 enhances the clarity and type safety of the code by defining named constants. 1) Enumerations can be integers, strings or objects, improving code readability and type safety. 2) Enumeration is based on class and supports object-oriented features such as traversal and reflection. 3) Enumeration can be used for comparison and assignment to ensure type safety. 4) Enumeration supports adding methods to implement complex logic. 5) Strict type checking and error handling can avoid common errors. 6) Enumeration reduces magic value and improves maintainability, but pay attention to performance optimization.

Describe the SOLID principles and how they apply to PHP development. Describe the SOLID principles and how they apply to PHP development. Apr 03, 2025 am 12:04 AM

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to debug CLI mode in PHPStorm? How to debug CLI mode in PHPStorm? Apr 01, 2025 pm 02:57 PM

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

How to send a POST request containing JSON data using PHP's cURL library? How to send a POST request containing JSON data using PHP's cURL library? Apr 01, 2025 pm 03:12 PM

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

How to automatically set permissions of unixsocket after system restart? How to automatically set permissions of unixsocket after system restart? Mar 31, 2025 pm 11:54 PM

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

See all articles