- PHP >= 7.1
- Composer >= 2.0
支持主流框架 Laravel
、Hyperf
、Yii2
快捷使用,具体使用方法请滑到底部
$ composer require hedeqiang/alchemypay -vvv
require __DIR__ .'/vendor/autoload.php';
use Hedeqiang\AlchemyPay\Pay;
$app = new Pay([
'endpoint' => 'xxx',
'merchantCode' => 'xxx',
'privateKey' => 'xxx',
]);
$uri = 'openApi/createOrder';
$params = [
"amount" => "10.0",
"fiatType" => "CNY",
"callbackUrl" => "http://147.243.170.11:9091/transnotify",
"merchantOrderNum" => "testqwe1234567891035",
"payMent" => "w1",
"email" => "123456@qq.com",
];
$response = $app->request($uri,$params);
$result = $app->handleNotify();
// TODO
return 'SUCCESS' ; // retuen 'Fail';
php artisan vendor:publish --tag=alchemy
or
php artisan vendor:publish --provider="Hedeqiang\AlchemyPay\ServiceProvider"
ALCHEMY_PAY_ENDPOINT=
ALCHEMY_PAY_MERCHANT_CODE=
ALCHEMY_PAY_PRIVATE_KEY=
public function index()
{
return app('pay')->request($uri,$params);
}
use Hedeqiang\AlchemyPay\Facades\Pay;
public function index()
{
return Pay::pay()->request($uri,$params)
}
public function notify(Request $request)
{
$result = Pay::pay()->handleNotify();
}
php bin/hyperf.php vendor:publish hedeqiang/alchemypay
ALCHEMY_PAY_ENDPOINT=
ALCHEMY_PAY_MERCHANT_CODE=
ALCHEMY_PAY_PRIVATE_KEY=
<?php
use Hedeqiang\AlchemyPay\Pay;
use Hyperf\Utils\ApplicationContext;
// 请求
response = ApplicationContext::getContainer()->get(Pay::class)->request($uri,$parmas);
// 回调
$response = ApplicationContext::getContainer()->get(Pay::class)->handleNotify();
在 Yii2
配置文件 config/main.php
的 components
中添加:
'components' => [
// ...
'pay' => [
'class' => 'Hedeqiang\AlchemyPay\YiiPay',
'options' => [
'endpoint' => 'xxx',
'merchantCode' => 'xxx',
'privateKey' => 'xxx',
],
],
// ...
]
Yii::$app->response->format = Response::FORMAT_JSON;
// 请求
$results = Yii::$app->pay->getPay()->request($uri,$params);
// 回调
$results = Yii::$app->pay->getPay()->handleNotify();
Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects.
You can contribute in one of three ways:
- File bug reports using the issue tracker.
- Answer questions or fix bugs on the issue tracker.
- Contribute new features or update the wiki.
The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.
MIT