wannanbigpig / alipay-sdk-php Goto Github PK
View Code? Open in Web Editor NEW📦 对接支付宝最新接口,轻松配置,使用灵活方便。https://alipay.docs.wannanbigpig.com/
License: MIT License
📦 对接支付宝最新接口,轻松配置,使用灵活方便。https://alipay.docs.wannanbigpig.com/
License: MIT License
代码如下
//app支付
public function app_pay($order_mes){
$alipay_config = Config::get("config_third.alipay");
$pay_config = [
// 必要配置
'sys_params' => [
'app_id' => $alipay_config['app_id'],
'notify_url' => $alipay_config['notify_url'],
],
'private_key_path' => $alipay_config['private_key_path'],
'alipay_public_Key_path' => $alipay_config['alipay_public_key_path'],
];
$app = Alipay::payment($pay_config);
$result = $app->pay->app([
'out_trade_no' => $order_mes['out_trade_no'],
'subject' => $order_mes['subject'],
'total_amount' => $order_mes['total_amount'],
]);
return $result;
}
生成得结果:
app_id=123&biz_content=%7B%22timeout_express%22%3A%221c%22%2C%22product_code%22%3A%22QUICK_MSECURITY_PAY%22%2C%22out_trade_no%22%3A%22421535257%22%2C%22subject%22%3A%22%E8%AF%BE%E7%A8%8B%E8%B4%AD%E4%B9%B0%22%2C%22total_amount%22%3A%22100%22%7D&charset=utf-8&format=JSON&method=alipay.trade.app.pay&sign=dM6K4AGg%3D%3D&sign_type=RSA2×tamp=2020-06-30+15%3A42%3A04&version=1.0
composer 库文件 , 是不是这里有问题
/**
* alipay.trade.app.pay(app支付接口2.0).
*
* @param array $params
* @param string|null $returnUrl
*
* @return string
*
* @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException
*/
public function app(array $params, string $returnUrl = null)
{
$method = 'alipay.trade.app.pay';
$params = array_merge([
'timeout_express' => '1c',
'product_code' => 'QUICK_MSECURITY_PAY',
], $params);
$this->app->setEndpointConfig($method, [
'return_url' => $returnUrl ?: $this->app['config']->get('return_url'),
'notify_url' => $this->app['config']->get('notify_url'),
]);
return $this->sdkExecute($method, [
'biz_content' => $params,
]);
}
经过打印断点 $this->app['config']
,发现:
WannanBigPig\Supports\Config Object
(
[items:protected] => Array
(
[http] => Array
(
[timeout] => 6
[base_uri] => https://openapi.alipay.com/gateway.do
[connect_timeout] => 6
[log_template] =>
>>>>>>>>request
--------
{request}
--------
>>>>>>>>response
--------
{response}
--------
>>>>>>>>error
--------
{error}
--------
)
[sys_params] => Array
(
[app_id] => 222
[notify_url] => http://api.test.net/paycall/alipay/
)
[private_key_path] => ../public/alipay/merchant_private_2048.pem
[alipay_public_Key_path] => ../public/alipay/alipay_public_2048.pem
)
)
此处 得 异步地址 是空的,,实际数据在 sys_params 这个数组里
$this->app['config']->get('notify_url')
正确得是
$this->app['config']->sys_params['notify_url']
需要那几个证书,试过几个,结果都是签名错误,通过支付宝官方提供的应用获取到的是两个txt文件,一个csr文件,以及自己从开放平台下载的三个证书文件
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.