PHP code example of zjpay / laravel-cpcn

1. Go to this page and download the library: Download zjpay/laravel-cpcn 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/ */

    

zjpay / laravel-cpcn example snippets


use Zjpay\Cpcn\Facades\Cpcn;

$resp = Cpcn::tx('5011', [
    'PaymentNo' => 'P202604160001',
    'Amount' => '100',
    'SettlementFlag' => '10',
    // ...按文档拼 Body 字段
]);

if (! $resp->isSystemAccepted()) {
    throw new RuntimeException($resp->systemCode() . ':' . $resp->systemMessage());
}

$body = $resp->body();

Cpcn::openAccount([...]);      // 4601
Cpcn::bindCard([...]);         // 4611
Cpcn::bindCardConfirm([...]);  // 4613
Cpcn::queryBindOrOpen([...]);  // 4616
Cpcn::recharge([...]);         // 4641
Cpcn::withdraw([...]);         // 4643
Cpcn::transfer([...]);         // 4645
Cpcn::pay([...]);              // 5011
Cpcn::payPage([...]);          // 5012
Cpcn::refund([...]);           // 5021

use Illuminate\Http\Request;
use Zjpay\Cpcn\Facades\Cpcn;

Route::post('/cpcn/notify', function (Request $request) {
    $message = (string) $request->input('message');
    $signature = (string) $request->input('signature');

    $parsed = Cpcn::parseAndVerifyCallback($message, $signature);
    // TODO: 业务处理
    return response('OK');
});
bash
php artisan vendor:publish --tag=cpcn-config