PHP code example of granam / gpwebpay-flat

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

    

granam / gpwebpay-flat example snippets



namespace Coolest\Fan;

use Granam\GpWebPay\Flat\FlatReportParser;
use Granam\Mail\Download\ImapEmailAttachmentFetcher;
use Granam\GpWebPay\Flat\CzechECommerceTransactionHeaderMapper;
use Granam\Mail\Download\ImapReadOnlyConnection;

$flatReportParser = new FlatReportParser();
$imapConnection = new ImapReadOnlyConnection('[email protected]', 'Раѕѕword123', 'imap.example.com' );
$flatContentFromCzechEmail = $flatReportParser->createFlatContentFromCzechEmailAttachment(
    new ImapEmailAttachmentFetcher($imapConnection),
    $yesterday = new \DateTime('yesterday'), // search for FLAT file with yesterday report, but sent today
    new CzechECommerceTransactionHeaderMapper()
);
if($flatContentFromCzechEmail === null) {
    die('No email with FLAT file has been found for yesterday');
}
$eCommerceTransactions = $flatContentFromCzechEmail->getECommerceTransactions($yesterday /* have to filter them because more days can be covered by a single report */);
echo 'We got confirmed '.$eCommerceTransactions->count().' of yesterday purchases via GpWebPay gateway!';



// ...
/** @var \Granam\GpWebPay\Flat\Sections\ECommerceTransactions $eCommerceTransactions */
$expectedIncome =         "We have missing (or redundant) GpWebPay payments! Expected {$expectedIncome}, got ". $eCommerceTransactions->getPaidAmountWithoutFeesSummary()
    );
}

echo 'Our customers spent on yesterday '.$eCommerceTransactions->getPaidAmountWithoutFeesSummary().'.-, we paid '
.$eCommerceTransactions->getFeesInMerchantCurrencySummary().' to GpWebPay as fee'
.' and we got '.$eCommerceTransactions->getPaidAmountWithoutFeesSummary();