PHP code example of digitsrl / php-wom-connector

1. Go to this page and download the library: Download digitsrl/php-wom-connector 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/ */

    

digitsrl / php-wom-connector example snippets


date_default_timezone_set("UTC");

\WOM\Logger::Initialize(array(
    new \Monolog\Handler\StreamHandler('php://stdout', \Monolog\Logger::DEBUG)
));

\WOM\Config\Domain::SetDomain('dev.wom.social');



$instrument = new \WOM\Instrument(
    INSTRUMENT_ID,
    INSTRUMENT_PRIVATE_KEY,
    INSTRUMENT_PRIVATE_KEY_PASSWORD
);

$vouchers[] = \WOM\Voucher::Create('H', 40.12319, 12.83548, new DateTime('NOW'));

$vouchers[] = \WOM\Voucher::Create('H', 40.12319, 12.83548, new DateTime('NOW'), 100);

$values = $instrument->RequestVouchers($vouchers);

$otc = $values['otc'];
$pin = $values['password'];

$POS = new \WOM\POS(
    POS_ID,
    POS_PRIVATE_KEY,
    POS_PRIVATE_KEY_PASSWORD
);

$filter = \WOM\Filter::Create('H', array(46.0, -17.0), array(12.0, 160.0), 14);

$filter = \WOM\Filter::Create();

$values = $POS->RequestPayment(
    100, // Number of WOM vouchers ation URL, will be opened by Pocket on payment completion, can be null if Pocket should only display payment confirmation on screen
    $filter, // Filter that determines which vouchers are accepted
    'https://myserver.io/backend/confirm', // Optional Registry confirmation URL, which receives a webhook request from the Registry on payment completion, can be null
    null // Optional boolean indicating whether this is a persistent payment (can be performed multiple times) or not
);

$otc = $values['otc'];
$pin = $values['password'];

composer