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

[update] 新增stripe聚合支付方式,采用全新的paymentIntents API #136

Open
wants to merge 24 commits into
base: dev
Choose a base branch
from

Conversation

linusxiong
Copy link

@linusxiong linusxiong commented Jun 5, 2024

[fix] 修复由webman引起的回调验签问题
[fix] 修改支付方式中的小bug
[update] 将stripe-php版本升级至最新
[feat] 新增telegram机器人/start指令监听

[fix] 修改支付方式中的小bug
[update] 将stripe-php版本升级至最新
@lufeiit
Copy link

lufeiit commented Jun 7, 2024

测试正常

@linusxiong
Copy link
Author

linusxiong commented Jun 13, 2024

啥时候merge一下呀 @cedar2025

删除调试冗余代码
@lufeiit
Copy link

lufeiit commented Jun 13, 2024

啥时候merge一下呀 @cedar2025

45f4671038a212e8a0d4dba01f7be999.jpeg

运行出现 Class "App\Http\Controllers\V1\Guest\Payment" not found 的提示,订单支付回调正常,在stripe查看日志,一个订单会有两个回调,两个回调日志最大的不同是 "pending_webhooks" 。如果值为3就会提示出错信息,如果值为1则回调成功

@linusxiong
Copy link
Author

啥时候merge一下呀 @cedar2025

45f4671038a212e8a0d4dba01f7be999.jpeg

运行出现 Class "App\Http\Controllers\V1\Guest\Payment" not found 的提示,订单支付回调正常,在stripe查看日志,一个订单会有两个回调,两个回调日志最大的不同是 "pending_webhooks" 。如果值为3就会提示出错信息,如果值为1则回调成功

stripe里监听一个payment_intent.succeeded事件就可以了,我刚刚测试了微信和支付宝两个接口同时存在的情况下,使用支付宝支付成功的时候会向两个接口地址同时发送回调都是成功的,至于第一个not found我看看是啥情况

@lufeiit
Copy link

lufeiit commented Jun 13, 2024

啥时候merge一下呀 @cedar2025

45f4671038a212e8a0d4dba01f7be999.jpeg
运行出现 Class "App\Http\Controllers\V1\Guest\Payment" not found 的提示,订单支付回调正常,在stripe查看日志,一个订单会有两个回调,两个回调日志最大的不同是 "pending_webhooks" 。如果值为3就会提示出错信息,如果值为1则回调成功

stripe里监听一个payment_intent.succeeded事件就可以了,我刚刚测试了微信和支付宝两个接口同时存在的情况下,使用支付宝支付成功的时候会向两个接口地址同时发送回调都是成功的,至于第一个not found我看看是啥情况

93d0eb67af5351c0c704e28a920a5b6e.png
监听payment_intent.succeeded事件是一直有的,我测试的支付宝和微信,分别应用不同的sk_live和webhook_key

@linusxiong
Copy link
Author

啥时候merge一下呀 @cedar2025

45f4671038a212e8a0d4dba01f7be999.jpeg
运行出现 Class "App\Http\Controllers\V1\Guest\Payment" not found 的提示,订单支付回调正常,在stripe查看日志,一个订单会有两个回调,两个回调日志最大的不同是 "pending_webhooks" 。如果值为3就会提示出错信息,如果值为1则回调成功

stripe里监听一个payment_intent.succeeded事件就可以了,我刚刚测试了微信和支付宝两个接口同时存在的情况下,使用支付宝支付成功的时候会向两个接口地址同时发送回调都是成功的,至于第一个not found我看看是啥情况

93d0eb67af5351c0c704e28a920a5b6e.png 监听payment_intent.succeeded事件是一直有的,我测试的支付宝和微信,分别应用不同的sk_live和webhook_key

啥时候merge一下呀 @cedar2025

45f4671038a212e8a0d4dba01f7be999.jpeg
运行出现 Class "App\Http\Controllers\V1\Guest\Payment" not found 的提示,订单支付回调正常,在stripe查看日志,一个订单会有两个回调,两个回调日志最大的不同是 "pending_webhooks" 。如果值为3就会提示出错信息,如果值为1则回调成功

stripe里监听一个payment_intent.succeeded事件就可以了,我刚刚测试了微信和支付宝两个接口同时存在的情况下,使用支付宝支付成功的时候会向两个接口地址同时发送回调都是成功的,至于第一个not found我看看是啥情况

93d0eb67af5351c0c704e28a920a5b6e.png 监听payment_intent.succeeded事件是一直有的,我测试的支付宝和微信,分别应用不同的sk_live和webhook_key

not found的问题找到了,webhook失败好像也是这个问题导致的,我看看怎么修复
image
这个第45行的报错

image

@raymao9
Copy link

raymao9 commented Jun 19, 2024

作者你好,求助一下
Stripe 后台两种报错
405 (Method Not Allowed)
500 (Internal Server Error)

Webhook 地址尝试填写
/payment/stripe/return
/api/v1/guest/payment/notify/StripeALLInOne/XXXXXX

都无法正常回调,付款网站收不到通知
能否指教一下可能配置哪里不对吗
这个 All in One 貌似也不能给 Stripe 支付宝用 Test Mode 调试对吗

@linusxiong
Copy link
Author

作者你好,求助一下 Stripe 后台两种报错 405 (Method Not Allowed) 500 (Internal Server Error)

Webhook 地址尝试填写 /payment/stripe/return /api/v1/guest/payment/notify/StripeALLInOne/XXXXXX

都无法正常回调,付款网站收不到通知 能否指教一下可能配置哪里不对吗 这个 All in One 貌似也不能给 Stripe 支付宝用 Test Mode 调试对吗

回调地址是https://域名/api/v1/guest/payment/notify/StripeALLInOne/xxxxxxxx
在stripe监听payment_intent.succeeded事件,test mode只要使用测试模式的api密钥sk_test_xxx,和测试模式webhook中的Signing secret,whsec_xxxx即可,记得要填写是alipay还是wechat_pay

@raymao9
Copy link

raymao9 commented Jun 19, 2024

谢谢回复,所以我 Webhook 地址填写 https://域名/api/v1/guest/payment/notify/StripeALLInOne/xxxxxxxx 应该无误了

最开始测试的时候,按支付弹出如下错误
The statement_descriptor parameter is not supported for the payment_method_type card. To continue supporting payment_method_type card, please pass in statement_descriptor_suffix or remove the statement_descriptor parameter altogether. Please see https://support.stripe.com/questions/use-of-the-statement-descriptor-parameter-on-paymentintents-for-card-charges for additional details.

将 StripeALLInOne.php 里面的 statement_descriptor 改为statement_descriptor_suffix 可以跳转到支付宝扫码页面(只限 Live Mode),但不回调,出现上面我提到的两种错误,由于我是前后端分离的,默认通知到后端地址,不回调,改为通知到前端地址,也不行,我用网上的魔法手段把 405 变成 200 OK,Webhook 是绿勾勾了,但是前后端还是都不回调...... 会不会是我套 CDN 的原因....

如果用 Test Mode 会报如下错误
The PaymentMethod provided (alipay) is not allowed for this PaymentIntent. Please attach a PaymentMethod of one of the following types: card, klarna, link, cashapp. Alternatively, update the allowed payment_method_types for this PaymentIntent to include "alipay".

@linusxiong
Copy link
Author

linusxiong commented Jun 19, 2024

谢谢回复,所以我 Webhook 地址填写 https://域名/api/v1/guest/payment/notify/StripeALLInOne/xxxxxxxx 应该无误了

最开始测试的时候,按支付弹出如下错误 The statement_descriptor parameter is not supported for the payment_method_type card. To continue supporting payment_method_type card, please pass in statement_descriptor_suffix or remove the statement_descriptor parameter altogether. Please see https://support.stripe.com/questions/use-of-the-statement-descriptor-parameter-on-paymentintents-for-card-charges for additional details.

将 StripeALLInOne.php 里面的 statement_descriptor 改为statement_descriptor_suffix 可以跳转到支付宝扫码页面(只限 Live Mode),但不回调,出现上面我提到的两种错误,由于我是前后端分离的,默认通知到后端地址,不回调,改为通知到前端地址,也不行,我用网上的魔法手段把 405 变成 200 OK,Webhook 是绿勾勾了,但是前后端还是都不回调...... 会不会是我套 CDN 的原因....

如果用 Test Mode 会报如下错误 The PaymentMethod provided (alipay) is not allowed for this PaymentIntent. Please attach a PaymentMethod of one of the following types: card, klarna, link, cashapp. Alternatively, update the allowed payment_method_types for this PaymentIntent to include "alipay".

这套代码只支持支付宝和微信,暂时不支持信用卡和储蓄卡等其他方式,你可以看看数据库里的log信息的报错。然后根据第二个报错查看,似乎你根本就没有在stripe开启支付宝收款?然后我2套环境测试都是没有问题的,上面好像也有一个老哥测试是正常的

@raymao9
Copy link

raymao9 commented Jun 19, 2024

误会了,我没有使用信用卡,是报错信息提示他 Test Mode 支持范围只有信用卡和其他...
我一直是用 Stripe Alipay 在测试哈,跳转支付宝扫码也是成功的,如果没有开通,跳转到扫码那里是跳不过去的,但我微信没有开通,这个应该是不影响,因为我的后台支付一直只填 alipay
我已经在 Live Mode 付了五六笔都成功了,Stripe 都有入账,但是网站不回调
然后在 Test Mode 是连跳转都跳转不过去的,直接弹窗提示的不支持
请问你的机器是 X86 环境吗?我是甲骨文 ARM,但 LNMP 该弄的环境都弄好了,Checkout 走 Test Mode 没问题,真钱就只有测过支付宝了,然后队列是用 pm2 启动的

@raymao9
Copy link

raymao9 commented Jun 19, 2024

请问你们上面提到的 500 报错是在目前的代码已经解决了吗?因为我也有这个报错
提供我这边的报错记录还请参考下,谢谢作者了

浏览器报错路径:/api/v1/user/order/checkout
内容:
Symfony \ Component\ HttpKernel \ Exception\MethodNotAllowedHttpException
PHP 8.1.19
10.48.13
The GET method is not supported for route api/v1/user/order/checkout. Supported methods: POST.

数据库里的报错记录
ErrorException: Undefined global variable $HTTP_RAW_POST_DATA in /www/wwwroot/xboard/app/Payments/StripeALLInOne.php:124
Stack trace:
#0 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(255): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError()
#1 /www/wwwroot/xboard/app/Payments/StripeALLInOne.php(124): Illuminate\Foundation\Bootstrap\HandleExceptions->Illuminate\Foundation\Bootstrap{closure}()
#2 /www/wwwroot/xboard/app/Services/PaymentService.php(37): App\Payments\StripeALLInOne->notify()
#3 /www/wwwroot/xboard/app/Http/Controllers/V1/Guest/PaymentController.php(20): App\Services\PaymentService->notify()
#4 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): App\Http\Controllers\V1\Guest\PaymentController->notify()
#5 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(43): Illuminate\Routing\Controller->callAction()
#6 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Routing/Route.php(260): Illuminate\Routing\ControllerDispatcher->dispatch()
#7 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Routing/Route.php(205): Illuminate\Routing\Route->runController()
#8 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Routing/Router.php(806): Illuminate\Routing\Route->run()
#9 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(144): Illuminate\Routing\Router->Illuminate\Routing{closure}()
#10 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(50): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}()
#11 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\Routing\Middleware\SubstituteBindings->handle()
#12 /www/wwwroot/xboard/app/Http/Middleware/Language.php(15): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}()
#13 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): App\Http\Middleware\Language->handle()
#14 /www/wwwroot/xboard/app/Http/Middleware/ForceJson.php(20): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}()
#15 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): App\Http\Middleware\ForceJson->handle()
#16 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(119): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}()
#17 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Routing/Router.php(807): Illuminate\Pipeline\Pipeline->then()
#18 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Routing/Router.php(784): Illuminate\Routing\Router->runRouteWithinStack()
#19 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Routing/Router.php(748): Illuminate\Routing\Router->runRoute()
#20 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Routing/Router.php(737): Illuminate\Routing\Router->dispatchToRoute()
#21 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(200): Illuminate\Routing\Router->dispatch()
#22 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(144): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http{closure}()
#23 /www/wwwroot/xboard/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(66): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}()
#24 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Barryvdh\Debugbar\Middleware\InjectDebugbar->handle()
#25 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}()
#26 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle()
#27 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull->handle()
#28 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}()
#29 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle()
#30 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\Foundation\Http\Middleware\TrimStrings->handle()
#31 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}()
#32 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle()
#33 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(99): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}()
#34 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle()
#35 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(39): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}()
#36 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\Http\Middleware\TrustProxies->handle()
#37 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(62): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}()
#38 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\Http\Middleware\HandleCors->handle()
#39 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(119): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}()
#40 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(175): Illuminate\Pipeline\Pipeline->then()
#41 /www/wwwroot/xboard/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(144): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter()
#42 /www/wwwroot/xboard/public/index.php(55): Illuminate\Foundation\Http\Kernel->handle()
#43 {main}

@linusxiong
Copy link
Author

linusxiong commented Jun 19, 2024

误会了,我没有使用信用卡,是报错信息提示他 Test Mode 支持范围只有信用卡和其他... 我一直是用 Stripe Alipay 在测试哈,跳转支付宝扫码也是成功的,如果没有开通,跳转到扫码那里是跳不过去的,但我微信没有开通,这个应该是不影响,因为我的后台支付一直只填 alipay 我已经在 Live Mode 付了五六笔都成功了,Stripe 都有入账,但是网站不回调 然后在 Test Mode 是连跳转都跳转不过去的,直接弹窗提示的不支持 请问你的机器是 X86 环境吗?我是甲骨文 ARM,但 LNMP 该弄的环境都弄好了,Checkout 走 Test Mode 没问题,真钱就只有测过支付宝了,然后队列是用 pm2 启动的

test mode和正式环境是没差的,按理来说都应该要支持。我这边感觉你是环境的问题,试试使用docker的方式安装呢?
可以使用ghcr.io/linusxiong/xboard:latest来部署,之前说的500错误是作者那边的代码问题,我已经告诉他让他修复了。

@raymao9
Copy link

raymao9 commented Jun 20, 2024

作者你好,我用了你的镜像部署,但我的数据库是从 wyx2685 那里迁移过来的,在此条件下基本上报错情况都一样
但全新创建 cedar2025 版本的数据库后再拉你的镜像,情况如下:
Test Mode 还是不能用
Live Mode 回调成功了
/api/v1/guest/payment/notify/StripeALLInOne/XXXXXX 这个通知地址用浏览器访问也能正常显示 json 内容了,之前显示的是包含 fail 的内容。

Test Mode 的报错如下
The statement_descriptor parameter is not supported for the payment_method_type card. To continue supporting payment_method_type card, please pass in statement_descriptor_suffix or remove the statement_descriptor parameter altogether. Please see https://support.stripe.com/questions/use-of-the-statement-descriptor-parameter-on-paymentintents-for-card-charges for additional details.

修改那个 suffix 之后就会改成报不支持 alipay,如果作者有空能修也是用户福音,毕竟真钱测试有点肉疼~~
无论如何,非常感谢🙏

@lufeiit
Copy link

lufeiit commented Jun 21, 2024

建议修改下原v2board中StripeCheckout.php的代码,修改public function notify($params)这一段跟作者的一样,修复由webman引起的回调验签问题。

StripeCheckout能支持你账户的所有付款方式。

我这里经过测试,修改原v2board中三个Stripe的支付文件中回调验证方式,均可正常运行

@linusxiong
Copy link
Author

linusxiong commented Jun 23, 2024

作者你好,我用了你的镜像部署,但我的数据库是从 wyx2685 那里迁移过来的,在此条件下基本上报错情况都一样 但全新创建 cedar2025 版本的数据库后再拉你的镜像,情况如下: Test Mode 还是不能用 Live Mode 回调成功了 /api/v1/guest/payment/notify/StripeALLInOne/XXXXXX 这个通知地址用浏览器访问也能正常显示 json 内容了,之前显示的是包含 fail 的内容。

Test Mode 的报错如下 The statement_descriptor parameter is not supported for the payment_method_type card. To continue supporting payment_method_type card, please pass in statement_descriptor_suffix or remove the statement_descriptor parameter altogether. Please see https://support.stripe.com/questions/use-of-the-statement-descriptor-parameter-on-paymentintents-for-card-charges for additional details.

修改那个 suffix 之后就会改成报不支持 alipay,如果作者有空能修也是用户福音,毕竟真钱测试有点肉疼~~ 无论如何,非常感谢🙏

你是不是没更新stripe的api版本和包版本呢,说实话我这里是一点问题也没有的,我也不清楚是啥问题说实话

@titaniumingjing
Copy link

怎么对接哇。全网无教程,那个端点URL我找了半天都不知道在哪。请大佬赐教

@raymao9
Copy link

raymao9 commented Aug 31, 2024

怎么对接哇。全网无教程,那个端点URL我找了半天都不知道在哪。请大佬赐教

你仔细看下上面别人的截图~

@titaniumingjing
Copy link

怎么对接哇。全网无教程,那个端点URL我找了半天都不知道在哪。请大佬赐教

你仔细看下上面别人的截图~

好了。现在我也遇到了支付的时候提示500 Internal Server Error的问题了。

@RebelliousWhiz
Copy link

@cedar2025 consider merging, please?

@RebelliousWhiz
Copy link

@linusxiong Hi linusxiong, would you consider merging upstream actively since @ cedar2025 is taking a bit longer to make the decision to merge? I am switching to your fork due to the need for Stripe. Not switching to wyx2685/v2board due to the lack of docker support... I would love to buy you a coffee.

@linusxiong
Copy link
Author

@linusxiong Hi linusxiong, would you consider merging upstream actively since @ cedar2025 is taking a bit longer to make the decision to merge? I am switching to your fork due to the need for Stripe. Not switching to wyx2685/v2board due to the lack of docker support... I would love to buy you a coffee.

You can just simply use ghcr.io/linusxiong/xboard:latest
My own branch not only adds Stripe support but also closely follows the current project's commits.

@RebelliousWhiz
Copy link

You can just simply use ghcr.io/linusxiong/xboard:latest My own branch not only adds Stripe support but also closely follows the current project's commits.

Already switched. Thanks!

Coffee is still valid 😉

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

Successfully merging this pull request may close these issues.

5 participants