PHP code example of hedeqiang / alchemypay

1. Go to this page and download the library: Download hedeqiang/alchemypay library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hedeqiang / alchemypay example snippets


php artisan vendor:publish --tag=alchemy
or 
php artisan vendor:publish --provider="Hedeqiang\AlchemyPay\ServiceProvider"

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

'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();
shell
Hedeqiang\AlchemyPay\Pay;
$app = new Pay([
    'endpoint'     => 'xxx',
    'merchantCode' => 'xxx',
    'privateKey' => 'xxx',
]);