PHP code example of cyvelnet / laravel-billplz

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

    

cyvelnet / laravel-billplz example snippets


Cyvelnet\LaravelBillplz\LaravelBillplzServiceProvider::class

Cyvelnet\LaravelBillplz\Facades\Billplz::class
 
\Billplz::issue(function (Cyvelnet\LaravelBillplz\Messages\BillMessage $bill)
    {
        // bill with a amount RM50
        $bill->to('name', 'email', 'mobile')
             ->amount(50) // will multiply with 100 automatically, so a RM500 bill, you just pass 500 instead of 50000
             ->callbackUrl('http://foorbar.com/foo/bar/webhook/')
             ->description('description');
    });


\Billplz::send(new MonthlyManagementBill())
        ->to('foobar')
        ->viaEmail('[email protected]') // you may use viaSms('mobile no') or viaEmailAndSms('email', 'mobile no')



$request = \Billplz::delete('bill_id');

if($request->isSuccess())
{
    // perform after deletion operation 
}


$bill = \Billplz::get('bill_id')->toArray();


    $request = \Billplz::collection('collection title');
    
    if($request->isSuccess())
    {
        $collection = $request->toArray() // you can call getRawBillplzResponse(false) to get response in POPO
    }


    $request = \Billplz::collection('collection title', function (\Cyvelnet\LaravelBillplz\Messages\CollectionMessage $collection) {
    
        // split a payment by RM50
        $collection->logo(storage_path('/billplz/my-logo.jpg'))
                   ->splitPaymentByFixed('[email protected]', 50)     // will convert into 5000 cents automatically
    });


    // create a open collection with a fixed amount RM500
    $request = \Billplz::openCollection('collection title', 'collection description', 500);
    
    if($request->isSuccess())
    {
        $collection = $request->toArray() // you can call getRawBillplzResponse(false) to get response in POPO
    }

    // create a open collection with a fixed amount RM500
    $request = \Billplz::openCollection('collection title', 'collection description', function (\Cyvelnet\LaravelBillplz\Messages\OpenCollectionMessage $collection) {
    
        $collection->anyAmountAndQty();
        //         ->splitPaymentByVariable('[email protected]', 50);  // split payment by 50%
        //         ->tax(6)   // 6% tax
        //         ->photo(storage_path('/billplz/my-photo.jpg'))
        //         ->reference1('your references')
    
    });
    
    if($request->isSuccess())
    {
        $collection = $request->toArray() // you can call getRawBillplzResponse(false) to get response in POPO
    }