PHP code example of beakerboy / cashid-library

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

    

beakerboy / cashid-library example snippets





    use CashID\Services\RequestGenerator;
    use Paillechat\ApcuSimpleCache\ApcuCache;

    // Specify your server details
    $domain = 'mydomain.com';
    $listener_script = '/api/parse.php';
    
    // Create your cache
    $cache = new ApcuCache();
    
    // Create a request generator
    $generator = new RequestGenerator($domain, $listener_script, $cache);

    // Create a minimal request
    $requestURI = $generator->createRequest();

    // Validate that the request was created
    if($requestURI !== false)
    {
        // Show a QR code / share with NFC the $requestURI
    }


    use CashID\Services\ResponseHandler;
    use Paillechat\ApcuSimpleCache\ApcuCache;

    // Specify your server details
    $domain = 'mydomain.com';
    $listener_script = '/api/parse.php';

    // Create your cache
    $cache = new ApcuCache();

    // Create a response handler
    $handler = new ResponseHandler($domain, $listener_script, $cache);

    // Capture the response
    $response = file_get_contents('php://input');

    // Parse the request.
    $request = $handler->validateRequest($response);

    // Validate the request.
    if($request !== false)
    {
        // Perform the $request['action'] using $request['data'] and $request['metadata'].
    }

    // Send the request confirmation.
    $handler->confirmRequest();
bash
$ php composer.phar install

$ php composer.phar