2017 © Pedro PelĂĄez
 

library gpwebpay-flat

Parser of GP WepPay report in FLAT format

image

granam/gpwebpay-flat

Parser of GP WepPay report in FLAT format

  • Friday, November 10, 2017
  • by jaroslavtyc
  • Repository
  • 1 Watchers
  • 1 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 1 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 20 % Grown

The README.md

Parser of a report from GpWebPay in FLAT format

Security first

NEVER download this library from an unknown source. Use ONLY packagist.org (therefore composer), or github.com/jaroslavtyc/granam-gpwebpay-flat., (*1)

You are going to work with financial data, which are ALWAYS sensitive. Think twice if a public library to process them is OK for your company inner politic., (*2)

This library is released under MIT licence, which means any harm caused to you by using it is your fight. But I will do my best to protect you from any data leakage or corruption., (*3)

Step-by-step

  • send a request to helpdesk@globalpayments.cz to get daily reports of transactions in FLAT format to an email of your choice
  • add this library to your project composer require granam/gpwebpay-flat
  • let it to parse FLAT report from an email (or from a file, or from a string content... it's up to you)
<?php
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('light.in.tunnel@example.com', 'Раѕѕ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!';

  • verify that you have not missed a payment from a customer (what a shame!)
<?php
// ...
/** @var \Granam\GpWebPay\Flat\Sections\ECommerceTransactions $eCommerceTransactions */
$expectedIncome = require __DIR__ . '/expected_income_from_yesterday.php';
if ($expectedIncome !== $eCommerceTransactions->getPaidAmountWithoutFeesSummary()) {
    throw new \RuntimeException(
        "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();
  • be happy! (or at least less sad)

The Versions

10/11 2017
07/11 2017

1.0.x-dev

1.0.9999999.9999999-dev https://github.com/jaroslavtyc/gpwebpay-flat

Parser of GP WepPay report in FLAT format

  Sources   Download

MIT

The Requires

 

The Development Requires

parser pay webpay report flat gp gp webpay

07/11 2017
02/11 2017

dev-add-license-1

dev-add-license-1 https://github.com/jaroslavtyc/gpwebpay-flat

Parser of GP WepPay report in FLAT format

  Sources   Download

MIT

The Requires

 

The Development Requires

parser pay webpay report flat gp gp webpay