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

如何在其他框架下使用$app->payment->handleNotify #574

Closed
skyred opened this issue Jan 18, 2017 · 4 comments
Closed

如何在其他框架下使用$app->payment->handleNotify #574

skyred opened this issue Jan 18, 2017 · 4 comments

Comments

@skyred
Copy link
Contributor

skyred commented Jan 18, 2017

我用的环境

PHP 版本:7.0.14
overtrue/wechat 版本:3.1

问题及现象

在支付通知API接口使用的时候,文档只给出了以下方法

$response = $app->payment->handleNotify(function($notify, $successful){
    // 你的逻辑
    return true; // 或者错误消息
});
$response->send(); // Laravel 里请使用:return $response;

但是在其他框架使用时,例如, 在Drupal里, 我能拿到的是
Symfony\Component\HttpFoundation\Request $request 这个对象,

$app->payment->handleNotify不接收任何的$request对象,现在不知道如何把微信对服务器接的请求传给$app->payment

@overtrue
Copy link
Collaborator

你不需要传给它啊,你有看过 $notify 的内容吗

@skyred
Copy link
Contributor Author

skyred commented Jan 19, 2017

谢谢你的回复,我看了一下$notify的内容,它自己会创建一个Request https://github.com/overtrue/wechat/blob/b56b7360c48211a11ad2610cbd1d41a7bb13865b/src/Payment/Notify.php#L64

但看完后,我发现了一个新的问题,就是在没有处理Request之前,我如何创建一个Application (因为我的应用里有很多apps,换句话说帐号), 我本来打算:

$app = new Application(null);

    $response = $app->payment->handleNotify(function($notify, $successful){
      // 通过订单号码找到相对应的application id等还有其他而外信息
    });

但是,看了代码后,我发现Application的__constructor()不能为空,这样似乎变成了一个鸡生蛋,还是蛋生鸡的问题了。

难道,我可以所便找个帐号生成application, 然后拿到通知内容后,在改帐号的配置?

@overtrue
Copy link
Collaborator

new app 之前不能拿到你要的账号?多账号能共用一个接口?建议你在 URL 做区别

@skyred
Copy link
Contributor Author

skyred commented Jan 19, 2017

多账号能共用一个接口?

我以为可以,所以现在设计的routing是 path: '/payment/notify/{commerce_payment_gateway}'

我也去考虑修改routing, 把它变成 path: '/payment/notify/{commerce_payment_gateway}/{commerce_order_id}}'

@skyred skyred closed this as completed Jan 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants