PHP code example of topphp / topphp-nuonuo-invoice

1. Go to this page and download the library: Download topphp/topphp-nuonuo-invoice 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/ */

    

topphp / topphp-nuonuo-invoice example snippets



//获取token
function testGetMerchantToken()
{
    try {
        $res = NuoNuo::instance()
            ->setAppKey("xxx")
            ->setAppSecret("xxx")
            ->getMerchantToken();
        $res = json_decode($res, true);
        var_dump($res);

    } catch (NuonuoException $e) {
        var_dump($e->errorMessage());
    }
}

//查询开票记录
function testQueryInvoiceQuantity()
{
    try {
        $senId = md5(uniqid());
        $res   = NuoNuo::instance()
            ->setAppKey("SD15125971")
            ->setAppSecret("SD354602BB0B48D0")
            ->sendPostSyncRequest(
                $senId,
                'xxx',
                'xxxx',
                'nuonuo.electronInvoice.queryInvoiceQuantity',
                json_encode([
                    'taxnum'           => 'xxxx',
                    'invoiceTimeStart' => '2018-03-19 00:00:00',
                    'invoiceTimeEnd'   => '2019-04-23 23:59:59',
                ])
            );
        var_dump($res);
    } catch (NuonuoException $e) {
        var_dump($e->errorMessage());
    }
}