PHP code example of manyun / lakala-ccss

1. Go to this page and download the library: Download manyun/lakala-ccss 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/ */

    

manyun / lakala-ccss example snippets


$lakala = new \My\LakalaCcss\Lakala([
    'appid' => 'OP00000xxx',
    'merchantNo' => 'xxx',
    'mchSerialNo' => 'xxx',
    'merchantPrivateKeyPath' => '/lakala/key/xxx.pem',
    'lklCertificatePath' => '/lakala/key/xxx.cer',
    'notifyUrl' => 'http://127.0.0.1/notify',
    'callbackUrl' => 'http://127.0.0.1/callback',
]);

// 金额 分
$result = $lakala->orderCreate('订单标题', '订单号', '200');

$returnData = [
    "code" => "SUCCESS",
    "message" => "执行成功"
];

$authorization = $_SERVER['HTTP_AUTHORIZATION'];
$response = file_get_contents("php://input");

$lakala = new \My\LakalaCcss\Lakala([
    'appid' => 'OP00000xxx',
    'merchantNo' => 'xxx',
    'mchSerialNo' => 'xxx',
    'merchantPrivateKeyPath' => '/lakala/key/xxx.pem',
    'lklCertificatePath' => '/lakala/key/xxx.cer',
]);

if(!$lakala->signatureVerification($authorization, $response)) {
    //签名不通过
    $returnData = [
        "code" => "ERROR",
        "message" => "签名不通过"
    ];
}

return $returnData;