Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

好像不兼容webman之类的常驻内存的框架 #3

Open
xiaoshuai666 opened this issue Aug 25, 2022 · 7 comments
Open

好像不兼容webman之类的常驻内存的框架 #3

xiaoshuai666 opened this issue Aug 25, 2022 · 7 comments
Assignees
Labels
compatibility Compatibility of equipment, environment and language

Comments

@xiaoshuai666
Copy link

好像不兼容webman之类的常驻内存的框架

@mantoufan
Copy link
Owner

mantoufan commented Aug 25, 2022

感谢反馈,我在 Webman 中测试了现金支付,可以正常返回回调地址,如图所示:
image
SDK 本身是兼容 Webman 的,但是示例 0df0a98 不能在 Webman 中运行,因为缺少所需的 $_SERVER['HTTP_HOST']
我更新了 getCurrentUrl() 方法:

function getCurrentUrl()
{
    if ($opt && isset($opt['webman']) && isset($opt['webman']['request'])) {
        $request = $opt['webman']['request'];
        return 'http' . ($request->getLocalPort() === 443 ? 's' : '') . ':' . $request->fullUrl();
    }
}

在 Webman 下,它可以像这样使用:

namespace app\controller;
use support\Request;
class Index
{
    public function index(Request $request)
    {
        $currentUrl = getCurrentUrl(array(
           'webman' => array('request' => $request)
       ));
       // Then new \Mantoufan\AliPayGlobal ……
    }
}

@mantoufan mantoufan self-assigned this Aug 25, 2022
@mantoufan mantoufan added the compatibility Compatibility of equipment, environment and language label Aug 25, 2022
@xiaoshuai666
Copy link
Author

xiaoshuai666 commented Aug 25, 2022

感谢回答,在支付这里是没问题的,支付成功后,异步回调里因为大量使用了$_SERVER,所以导致抛出异常,我现在是直接使用跳过方法直接使用SignatureTool:verify进行验证的,如果要是用插件里集成的$alipayGlobal->getNotify()该如何进行兼容呢?

@mantoufan
Copy link
Owner

mantoufan commented Aug 26, 2022

Hi, 我们更改了 0.0.3 版便于您直接传参:

composer remove mantoufan/alipay-global-sdk-php // 先移除
composer require mantoufan/alipay-global-sdk-php // 再重新安装
  1. $alipayGlobal->getNotify()时传入参数,值调用 Webman 的 $request 的方法
  2. getNotifyResponseWithRSA(),分别得到 headersbody
  3. 用 Webman 的 response 方法发送响应
$notify = $alipayGlobal->getNotify(array(
    'httpMethod' => $request->method(),
    'path' => $request->uri(),
    'clientId' => $request->header('client-id'),
    'rsqTime' => $request->header('request-time'),
    'rsqBody' => $request->rawBody(),
    'signature' => $request->header('signature')
)); 
$notifyResponseWithRSA =  $notify->getNotifyResponseWithRSA();
response($notifyResponseWithRSA['body'], 200, $notifyResponseWithRSA['headers']);

@xiaoshuai666
Copy link
Author

好的,感谢

@mantoufan
Copy link
Owner

Hi, 您可以在调用 getNotify 时传入参数,示例已更新到上面,您可以试试,任何情况随时联系

@xiaoshuai666
Copy link
Author

问题完美解决,感谢作者的付出,点赞!
另外提个不是问题的问题,根据手册上显示,异步通知最后响应支付宝的时候是不需要签名的,文档截图如下
image
另外建议如果可以把查询支付状态和取消支付这两个比较常用的接口一起集成上,就非常完美了

1 similar comment
@xiaoshuai666
Copy link
Author

问题完美解决,感谢作者的付出,点赞!
另外提个不是问题的问题,根据手册上显示,异步通知最后响应支付宝的时候是不需要签名的,文档截图如下
image
另外建议如果可以把查询支付状态和取消支付这两个比较常用的接口一起集成上,就非常完美了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility Compatibility of equipment, environment and language
Projects
None yet
Development

No branches or pull requests

2 participants