PHP code example of code-lives / ali

1. Go to this page and download the library: Download code-lives/ali 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/ */

    

code-lives / ali example snippets


composer 


//引入命名空间
use Applet\Assemble\Ali;

// 小程序下单
$pay= Ali::init($config)->set("订单号","金额","描述",'openid')->getParam();


$code="";
$data= Ali::init($config)->getOpenid($code);
//返回参数
$data = array(
    [alipay_system_oauth_token_response] => Array
        (
            [access_token] => 123
            [alipay_user_id] => 123
            [auth_start] => 2023-03-26 20:56:36
            [expires_in] => 1296000
            [re_expires_in] => 2592000
            [refresh_token] => auth
            [user_id] => 123
        )
    [sign] =>
    )

$data= Ali::init($config)->decryptPhone($session_key, $iv, $encryptedData);
echo $phone['mobile'];

$data = Ali::init($config)->findOrder(['out_trade_no' => '1679838318']);

$orders = [
        'out_order_no' => $order['out_order_no'],
        'refund_amount' => $order['refund_amount'],
    ];
$data= Ali::init($config)->applyOrderRefund($order);

$data = [
        'to_user_id' => '用户uid',
        'user_template_id' => '模版id',
        'page' => 'pages/index/index',
        'data' => json_encode([
            'keyword1' => ['value' => '1'],
            'keyword2' =>  ['value' => '2'],
            'keyword3' => ['value' => '3'],
        ]),
    ];
$data= Ali::init($config)->sendMsg($data,$token);

$pay = Ali::init($config);
$status = $pay->notifyCheck(); //验证
if ($status) {
    $order = $pay->getNotifyOrder(); //订单数据
    //$order['out_trade_no']//平台订单号
}