PHP code example of mynameiszanders / cashflows

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

    

mynameiszanders / cashflows example snippets




    use Nosco\Cashflows\Client as CashflowsClient;
    use Nosco\Cashflows\Exceptions as Error;

    $cashflows = new CashflowsClient('authorisation_id', 'p@55w0rd');
    $request = $cashflows->paymentRequest();
    $request->attributes([
        'card_num' => '1234567890123452',
        'card_cvv' => '123',
        'card_expiry' => '0317',
        ...
    ]);

    try {
        $response = $request->send();
        var_dump($response);

        # object(Nosco\Cashflows\Response\Authorised)[1]
        #   protected 'transactionId' => string '01S00001722' (length=11)
        #   protected 'cvvCheck' => int 2
        #   protected 'addressCheck' => int 3
        #   protected 'postcodeCheck' => int 2
        #   protected 'authCode' => string '031971' (length=6)

    }

    // Catch any errors that occur before or during the API call to Cashflows (request exceptions):
    catch(Error\Validation $e) {}
    catch(Error\Transport $e) {}

    // Catch any errors that occur after the API call to Cashflows (response exceptions):
    # You can use the Error\Response\NotAuthorisedException to cover the first four, or Error\ResponseException to
    # cover all five.
    catch(Error\Response\NotAuthorised\Blocked $e) {}
    catch(Error\Response\NotAuthorised\Cancelled $e) {}
    catch(Error\Response\NotAuthorised\Declined $e) {}
    catch(Error\Response\NotAuthorised\InvalidRequest $e) {}
    catch(Error\Response\InvalidResponse $e) {}

    // Catch any errors that Cashflows had:
    catch(Error\System $e) {}

    // Catch any other errors that happened within the library during the API call:
    # You can just use this catch block to catch everything, without any of the above catch blocks.
    catch(Error\BaseException $e) {}