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

在larave项目 自定义本扩展插件访问某接口 该如何自定义呢 例如访问阿里接口 ant.merchant.expand.indirect.image.upload #1005

Open
mathuse opened this issue Jul 2, 2024 · 6 comments

Comments

@mathuse
Copy link

mathuse commented Jul 2, 2024

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

@mathuse mathuse changed the title 在larave项目 自定义插件访问某接口 该如何自定义呢 例如访问阿里接口 ant.merchant.expand.indirect.image.upload 在larave项目 自定义本扩展插件访问某接口 该如何自定义呢 例如访问阿里接口 ant.merchant.expand.indirect.image.upload Jul 2, 2024
@mathuse
Copy link
Author

mathuse commented Jul 3, 2024

请问你的阿里接口是基于阿里的SDK还是自构建请求呢?因为对参数有不同要求
https://opendocs.alipay.com/open/028py4

@mathuse
Copy link
Author

mathuse commented Jul 3, 2024

@mathuse
Copy link
Author

mathuse commented Jul 3, 2024

我的是web 阿里支付通方案 里面有上传图片的接口 ant.merchant.expand.indirect.image.upload 我用的是laravel 框架 安装了你这个包,怎么重写才能比较好的实现自定义你的包的插件呢 例如在app/ 目录里自定义一个目录 Pluge 然后创建实现文件 uploadImage.php 有没有更完善的例子呢 谢谢

@mathuse
Copy link
Author

mathuse commented Jul 3, 2024

怎么传图上来,图片提交上来,打不开。已经参照着插件代码例子做了,最后报错:
参数异常: [App\YansongdaPayCustomPlugins\Alipay\AlipayUploadImagePlugin] 插件未实现 PluginInterface
在调用 $result = app('alipay_zft')->pay($allPlugins, $params); 时出现

代码:
在app/YansongdaPayCustomPlugins/Alipay/ImageUploadPlugin.php

$rocket]); $this->loadAlipayServiceProvider($rocket); $rocket->setDirection(ResponseDirection::class) ->mergePayload([ 'charset' => 'utf-8', 'sign_type' => 'RSA2', // 商户生成签名字符串所使用的签名算法类型 'method' => 'ant.merchant.expand.indirect.image.upload', 'biz_content' => $rocket->getParams(), ]); Logger::info('[Alipay][Pay][Web][UploadImagePlugin] 插件装载完毕', ['rocket' => $rocket]); return $next($rocket); } } 在vendor/yansongda/pay/src/Shortcut/Alipay/AppShortcut.php有: declare(strict_types=1); namespace Yansongda\Pay\Shortcut\Alipay; use Yansongda\Artful\Contract\ShortcutInterface; use Yansongda\Artful\Plugin\ParserPlugin; use Yansongda\Pay\Plugin\Alipay\V2\AddPayloadSignaturePlugin; use Yansongda\Pay\Plugin\Alipay\V2\FormatPayloadBizContentPlugin; use Yansongda\Pay\Plugin\Alipay\V2\Pay\App\PayPlugin; use Yansongda\Pay\Plugin\Alipay\V2\ResponseInvokeStringPlugin; use Yansongda\Pay\Plugin\Alipay\V2\StartPlugin; use App\YansongdaPayCustomPlugins\Alipay\AlipayUploadImagePlugin; class AppShortcut implements ShortcutInterface { public function getPlugins(array $params): array { return [ StartPlugin::class, PayPlugin::class, FormatPayloadBizContentPlugin::class, AddPayloadSignaturePlugin::class, ResponseInvokeStringPlugin::class, ParserPlugin::class, AlipayUploadImagePlugin::class, ]; } }

@mathuse
Copy link
Author

mathuse commented Jul 3, 2024

在vendor/yansongda/pay/src/Shortcut/Alipay/AppShortcut.php有:

declare(strict_types=1);
namespace Yansongda\Pay\Shortcut\Alipay;
use Yansongda\Artful\Contract\ShortcutInterface;
use Yansongda\Artful\Plugin\ParserPlugin;
use Yansongda\Pay\Plugin\Alipay\V2\AddPayloadSignaturePlugin;
use Yansongda\Pay\Plugin\Alipay\V2\FormatPayloadBizContentPlugin;
use Yansongda\Pay\Plugin\Alipay\V2\Pay\App\PayPlugin;
use Yansongda\Pay\Plugin\Alipay\V2\ResponseInvokeStringPlugin;
use Yansongda\Pay\Plugin\Alipay\V2\StartPlugin;
use App\YansongdaPayCustomPlugins\Alipay\AlipayUploadImagePlugin;
class AppShortcut implements ShortcutInterface
{
public function getPlugins(array $params): array
{
return [
StartPlugin::class,
PayPlugin::class,
FormatPayloadBizContentPlugin::class,
AddPayloadSignaturePlugin::class,
ResponseInvokeStringPlugin::class,
ParserPlugin::class,
AlipayUploadImagePlugin::class,
];
}
}

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