PHP code example of meilunzhi / baiwang-sdk

1. Go to this page and download the library: Download meilunzhi/baiwang-sdk 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/ */

    

meilunzhi / baiwang-sdk example snippets




elon\Baiwang\BaiwangClient;

$baiwang = new BaiwangClient(array(
    'username' => 'xxx',
    'password' => 'xxx',
    'appKey' => 'xxx',
    'appSecret' => 'xxx',
    'secret' => 'xxx',
    'salesAccount' => 'xxx',
    'salesPassword' => 'xxx',
    'outputTaxNumber' => '913500000000000000',
    'invoicingPoint' => 'dzpzd008',
    'env' => 'test', // test/sandbox or prod
    'autoSign' => true,
    'timeout' => 10000,
    'maxRetries' => 1,
));

$token = $baiwang->authenticate();

$invoice = $baiwang->invoicing(array(
    'taxNo' => '913500000000000000',
    'invoiceTerminalCode' => 'dzpzd008',
    'formatGenerate' => true,
    'data' => array(
        'buyerName' => 'Example Company',
        'buyerTaxNo' => '91500000747150890S',
        'invoiceType' => '0',
        'invoiceTypeCode' => '026',
        'invoiceTotalPrice' => 100.00,
        'invoiceTotalTax' => 13.00,
        'invoiceTotalPriceTax' => 113.00,
        'invoiceDetailsList' => array(
            array(
                'goodsName' => 'Service fee',
                'goodsPrice' => 100.00,
                'goodsQuantity' => 1,
                'goodsTaxRate' => 0.13,
                'goodsTotalPrice' => 100.00,
                'goodsTotalTax' => 13.00,
            ),
        ),
    ),
));

$baiwang = Melon\Baiwang\createInvoice($config);

use Melon\Baiwang\Contracts\CacheInterface;

final class AppCache implements CacheInterface
{
    public function get(string $key)
    {
        return null; // return the stored token array when available
    }

    public function set(string $key, $value, int $ttl): void
    {
        // Store $value for $ttl seconds.
    }
}
bash
composer dump-autoload