PHP code example of vochina / heepay-customer

1. Go to this page and download the library: Download vochina/heepay-customer 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/ */

    

vochina / heepay-customer example snippets


use Vochina\HeepayCustomer\HeepayCustomer;

$sm2PrivateKeyPath = __DIR__ . '/test_sm2_private_key.pem';
$sm2publicKeyPath = __DIR__ . '/test_sm2_public_key.pem';
$handler = new HeepayCustomer($sm2PrivateKeyPath, $sm2publicKeyPath);

$result = $handler->sign('This is the string that needs to be signed!');

$verify_result = $handler->verifySign($sign_content, $sign);

$data = [
   "app_id" => "100000000000000",
        "method" => "customer.entry.apply",
        "version" => "1.0",
        "charset" => "utf-8",
        "format" => "json",
        "timestamp" => date('Y-m-d H:i:s'),
        "notify_url" => "https://www.google.com",
        "sign_type" => "SM2",
        "biz_content" => [
             "apply_no" => "1233231212212",
        ],
   ];
$sm2PrivateKeyPath = __DIR__ . '/test_sm2_private_key.pem';
$sm2publicKeyPath = __DIR__ . '/test_sm2_public_key.pem';
$handler = new HeepayCustomer($sm2PrivateKeyPath, $sm2publicKeyPath);
$sign_text = $handler->parameterText($data, '&', true, null);
var_dump($sign_text);

    .
    .
    .
     'heepay-customer' => [
        'sm2PrivateKeyPath' => storage_path('cert/sm2_private_key.pem'),
        'sm2publicKeyPath' => storage_path('cert/sm2_public_key.pem'),
    ],

    .
    .
    .
    public function edit(HeepayCustomer $HeepayCustomer)
    {
        $response = $HeepayCustomer->sign('This is the string that needs to be signed!');
    }
    .
    .
    .

    .
    .
    .
    public function edit()
    {
        $response = app('heepay-customer')->sign('This is the string that needs to be signed!');
    }
    .
    .
    .