search
HomeBackend DevelopmentPHP TutorialPHP干支付宝即时到账需注意

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

注意: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
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
How do you create and use an interface in PHP?How do you create and use an interface in PHP?Apr 30, 2025 pm 03:40 PM

The article explains how to create, implement, and use interfaces in PHP, focusing on their benefits for code organization and maintainability.

What is the difference between crypt() and password_hash()?What is the difference between crypt() and password_hash()?Apr 30, 2025 pm 03:39 PM

The article discusses the differences between crypt() and password_hash() in PHP for password hashing, focusing on their implementation, security, and suitability for modern web applications.

How can you prevent Cross-Site Scripting (XSS) in PHP?How can you prevent Cross-Site Scripting (XSS) in PHP?Apr 30, 2025 pm 03:38 PM

Article discusses preventing Cross-Site Scripting (XSS) in PHP through input validation, output encoding, and using tools like OWASP ESAPI and HTML Purifier.

What is autoloading in PHP?What is autoloading in PHP?Apr 30, 2025 pm 03:37 PM

Autoloading in PHP automatically loads class files when needed, improving performance by reducing memory use and enhancing code organization. Best practices include using PSR-4 and organizing code effectively.

What are PHP streams?What are PHP streams?Apr 30, 2025 pm 03:36 PM

PHP streams unify handling of resources like files, network sockets, and compression formats via a consistent API, abstracting complexity and enhancing code flexibility and efficiency.

What is the maximum size of a file that can be uploaded using PHP ?What is the maximum size of a file that can be uploaded using PHP ?Apr 30, 2025 pm 03:35 PM

The article discusses managing file upload sizes in PHP, focusing on the default limit of 2MB and how to increase it by modifying php.ini settings.

What is Nullable types in PHP ?What is Nullable types in PHP ?Apr 30, 2025 pm 03:34 PM

The article discusses nullable types in PHP, introduced in PHP 7.1, allowing variables or parameters to be either a specified type or null. It highlights benefits like improved readability, type safety, and explicit intent, and explains how to declar

What is the difference between the unset() and unlink() functions ?What is the difference between the unset() and unlink() functions ?Apr 30, 2025 pm 03:33 PM

The article discusses the differences between unset() and unlink() functions in programming, focusing on their purposes and use cases. Unset() removes variables from memory, while unlink() deletes files from the filesystem. Both are crucial for effec

See all articles

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

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool