Skip to content

Commit

Permalink
Added support for new (sia.eu) Poštová banka's iTerminal service sand…
Browse files Browse the repository at this point in the history
…box and production (ITERMINAL2 introduced)
  • Loading branch information
Sibyx committed Feb 11, 2021
1 parent 8841647 commit 3bc8942
Show file tree
Hide file tree
Showing 12 changed files with 176 additions and 24 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## Changelog

### v0.20.2: 2021/01/07

Added support for new (sia.eu) Poštová banka's iTerminal service sandbox and production environments
(available as `PBIterminal2` driver / `ITERMINAL2` service).

### v0.20.1: 2020/08/13

Always format SLSPSporoPay amount to two decimal places.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2020 BACKBONE, s.r.o.
Copyright (c) 2021 BACKBONE, s.r.o.
http://www.backbone.sk/en/

Permission is hereby granted, free of charge, to any person obtaining a copy of
Expand Down
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@

Simple and unified object-oriented library written in PHP for e-commerce services offered by Slovak banks and financial institutions.

* [CardPay](https://www.tatrabanka.sk/sk/business/ucty-platby-karty/elektronicke-bankovnictvo/cardpay.html) with optional addition for [ComfortPay](http://www.tatrabanka.sk/cardpay/CardPay_ComfortPay_technicka_prirucka.pdf) service -- Tatra banka, a.s.
* [TatraPay](http://www.tatrabanka.sk/sk/business/ucty-platby-karty/elektronicke-bankovnictvo/tatrapay.html) -- Tatra banka, a.s.
* [CardPay](https://www.tatrabanka.sk/sk/business/ucty-platby/prijimanie-platieb/cardpay/) with optional addition for [ComfortPay](http://www.tatrabanka.sk/cardpay/CardPay_ComfortPay_technicka_prirucka.pdf) service -- Tatra banka, a.s.
* [TatraPay](https://www.tatrabanka.sk/sk/business/ucty-platby/prijimanie-platieb/tatrapay/) -- Tatra banka, a.s.

* [ePlatby VÚB](https://www.vub.sk/pre-podnikatelov/nonstop-banking/e-commerce-pre-internetovych-obchodnikov/e-platby-vub/) -- VÚB, a.s.
* [ePlatby VÚB](https://www.vub.sk/firmy-podnikatelia/platby/eplatby/) -- VÚB, a.s.

* [VÚB eCard](http://www.vub.sk/pre-firmy/nonstop-banking/e-commerce-pre-internetovych-obchodnikov/ecard/) -- VÚB, a.s.
* [VÚB eCard](https://www.vub.sk/firmy-podnikatelia/platby/ecard/) -- VÚB, a.s.

* [SporoPay](http://www.slsp.sk/6415/sporopay-elektronicke-platby-na-internete.html) -- Slovenská sporiteľna, a.s.
* [SporoPay](https://www.slsp.sk/sk/biznis/prijimanie-platieb/sporopay) -- Slovenská sporiteľna, a.s.

* [iTerminal](https://www.postovabanka.sk/pre-firmy/eft-pos-terminal/iterminal/) -- Poštová banka, a.s.
* [iTerminal](https://www.postovabanka.sk/korporatni-klienti/eft-pos-terminal/iterminal/) -- Poštová banka, a.s.

* [GP webpay](http://gpwebpay.cz/Content/downloads/GP_webpay_Seznameni_se_systemem_072013.pdf) -- Global Payments Europe, s.r.o.
* [GP webpay](https://gpwebpay.cz/downloads/GP_webpay_Gateway.pdf) -- Global Payments Europe, s.r.o.

* [TrustCard](http://www.trustpay.eu/contact-references-payment-methods-news/dokumenty-na-stiahnutie-en-GB/) -- TrustPay, a.s.
* [TrustCard](https://doc.trustpay.eu/v02?ShowDirectDebits=true&ShowDirectBanking=true&ShowApiBanking=true&ShowApiBankingVibans=true#overview) -- TrustPay, a.s.

* [PayPal](http://www.paypal.com) -- PayPal (Europe) S.à r.l. et Cie, S.C.A.

The current version of the library is v0.20.1 and requires PHP 5.4 or PHP 7+ to work. Even though there are things to make better, it is already being used in production without any sort of problems.
The current version of the library is v0.20.2 and requires PHP 5.4 or PHP 7+ to work. Even though there are things to make better, it is already being used in production without any sort of problems.

Chaching library is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).

Expand All @@ -28,7 +28,7 @@ The recommended way to install the library is to use [composer](http://getcompos

{
"require": {
"backbone/chaching": "0.20.1"
"backbone/chaching": "0.20.2"
}
}

Expand All @@ -47,7 +47,7 @@ The library follows the PSR-0 convention of naming classes and after installing

$chaching = new Chaching($driver, $authorization, $options);

As already mentioned in the introduction, currently there are eight different payment methods that are supported with each having it's own driver constant: `Chaching::CARDPAY`, `Chaching::TATRAPAY`, `Chaching::TRUSTPAY`, `Chaching::EPLATBY`, `Chaching::ECARD`, `Chaching::PAYPAL`, `Chaching::GPWEBPAY` and `Chaching::ITERMINAL`.
As already mentioned in the introduction, currently there are eight different payment methods that are supported with each having it's own driver constant: `Chaching::CARDPAY`, `Chaching::TATRAPAY`, `Chaching::TRUSTPAY`, `Chaching::EPLATBY`, `Chaching::ECARD`, `Chaching::PAYPAL`, `Chaching::GPWEBPAY`, `Chaching::ITERMINAL` and `Chaching::ITERMINAL2`.

In case of `Chaching::GPWEBPAY` use an associated array instead of password, so authentication information would look like this:

Expand All @@ -61,7 +61,7 @@ In case of `Chaching::GPWEBPAY` use an associated array instead of password, so

Public and private key needs to be created according to GP webpay's documentation.

And in case of `Chaching::ITERMINAL` use an associated array as well:
And in case of `Chaching::ITERMINAL` or `Chaching::ITERMINAL2` use an associated array as well:

$authorization = [
NULL, [
Expand All @@ -73,7 +73,7 @@ And in case of `Chaching::ITERMINAL` use an associated array as well:
Beforementioned empty `$options` array may at the moment contain these keys:

* `ecdsa_keys_file` - Absolute file path to file with Tatra banka's ECDSA keys (used only with HMAC message signing in CardPay and TatraPay)
* `sandbox` - Would you like to use sandbox or production URLs when communicating with the bank or financial institution? Default value is `FALSE`. Due to their limitations, sandbox is available only for `Chaching::TRUSTPAY`, `Chaching::ECARD`, `Chaching::PAYPAL`, `Chaching::GPWEBPAY` and `Chaching::ITERMINAL` (if not listed here, production URLs will be used even in sandbox mode).
* `sandbox` - Would you like to use sandbox or production URLs when communicating with the bank or financial institution? Default value is `FALSE`. Due to their limitations, sandbox is available only for `Chaching::TRUSTPAY`, `Chaching::ECARD`, `Chaching::PAYPAL`, `Chaching::GPWEBPAY`, `Chaching::ITERMINAL` and `Chaching::ITERMINAL2` (if not listed here, production URLs will be used even in sandbox mode).

Afterwards, we need to create a request for the external service with specific information about the payment.

Expand All @@ -90,7 +90,7 @@ Afterwards, we need to create a request for the external service with specific i

By running the `process` method in the next code block, we are getting back (when `$auto_redirect` is set to `FALSE`) the URL to redirect the user to, where the user will make the payment.

(Note that with `Chaching::ITERMINAL` the `$auto_redirect` will not ever work as the transaction identifier that is provided for you is strictly needed for thereafter. Only after you succesfully create the transaction you can use the redirection URL. For more information read bank's documentation.)
(Note that with `Chaching::ITERMINAL` or `Chaching::ITERMINAL2` the `$auto_redirect` will not ever work as the transaction identifier that is provided for you is strictly needed for thereafter. Only after you succesfully create the transaction you can use the redirection URL. For more information read bank's documentation.)

try
{
Expand All @@ -105,7 +105,7 @@ By running the `process` method in the next code block, we are getting back (whe
// General error with authentication or the request itself.
}

Remember the `callback` key in the request options? It is an absolute URL that the banking service will redirect to upon completion of the payment. Chaching also has methods to help with handling the response, checking it's validity, etc. However, if you are running with `Chaching::ITERMINAL`'s driver, you do not need to provide a callback as it is set in the merchant's centre provided by the bank.
Remember the `callback` key in the request options? It is an absolute URL that the banking service will redirect to upon completion of the payment. Chaching also has methods to help with handling the response, checking it's validity, etc. However, if you are running with `Chaching::ITERMINAL`'s (or `Chaching::ITERMINAL2`'s) driver, you do not need to provide a callback as it is set in the merchant's centre provided by the bank.

try
{
Expand Down Expand Up @@ -199,4 +199,4 @@ To release a proper v1.0 code of the library needs to have a more thorough tutor

---

© 2020 BACKBONE, s.r.o.
© 2021 BACKBONE, s.r.o.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "backbone/chaching",
"type": "library",
"version": "0.20.1",
"version": "0.20.2",
"license": "MIT",
"description": "Universal payment library for banking services in Slovakia",
"keywords": [
Expand Down
6 changes: 4 additions & 2 deletions src/Chaching/Chaching.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

class Chaching
{
const VERSION = '0.20.1';
const VERSION = '0.20.2';

const CARDPAY = 'cardpay';
const SPOROPAY = 'sporopay';
Expand All @@ -27,6 +27,7 @@ class Chaching
const PAYPAL = 'paypal';
const GPWEBPAY = 'gpwebpay';
const ITERMINAL = 'iterminal';
const ITERMINAL2 = 'iterminal2';

const PRODUCTION = 'production';
const SANDBOX = 'sandbox';
Expand All @@ -40,7 +41,8 @@ class Chaching
self::ECARD => 'VUBeCard',
self::PAYPAL => 'PayPal',
self::GPWEBPAY => 'GPwebpay',
self::ITERMINAL => 'PBiTerminal'
self::ITERMINAL => 'PBiTerminal',
self::ITERMINAL2 => 'PBiTerminal2'
];

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Chaching/Drivers/PBiTerminal/Refund.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ protected function validate()
return $this->status;
}

private function request_server_url()
protected function request_server_url()
{
return ($this->environment === Chaching::SANDBOX)
? 'https://secureshop-test.firstdata.lv:8443/ecomm/MerchantHandler'
Expand Down
4 changes: 2 additions & 2 deletions src/Chaching/Drivers/PBiTerminal/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,14 @@ public function process($redirect = TRUE)
));
}

private function request_server_url()
protected function request_server_url()
{
return ($this->environment === Chaching::SANDBOX)
? 'https://secureshop-test.firstdata.lv:8443/ecomm/MerchantHandler'
: 'https://secureshop.firstdata.lv:8443/ecomm/MerchantHandler';
}

private function request_client_url()
protected function request_client_url()
{
return ($this->environment === Chaching::SANDBOX)
? 'https://secureshop-test.firstdata.lv/ecomm/ClientHandler'
Expand Down
2 changes: 1 addition & 1 deletion src/Chaching/Drivers/PBiTerminal/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ protected function validate()
return $this->status;
}

private function request_server_url()
protected function request_server_url()
{
return ($this->environment === Chaching::SANDBOX)
? 'https://secureshop-test.firstdata.lv:8443/ecomm/MerchantHandler'
Expand Down
58 changes: 58 additions & 0 deletions src/Chaching/Drivers/PBiTerminal2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

/*
* This file is part of Chaching.
*
* (c) 2020 BACKBONE, s.r.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Chaching\Drivers;


class PBiTerminal2 extends \Chaching\Driver
{
public function request(Array $attributes)
{
static $request = NULL;

if ($request === NULL)
{
$request = new \Chaching\Drivers\PBiTerminal2\Request(
$this->authorization, $attributes, $this->options
);
}

return $request;
}

public function response(Array $attributes)
{
static $response = NULL;

if ($response === NULL)
{
$response = new \Chaching\Drivers\PBiTerminal2\Response(
$this->authorization, $attributes, $this->options
);
}

return $response;
}

public function refund(Array $attributes)
{
static $refund = NULL;

if ($refund === NULL)
{
$refund = new \Chaching\Drivers\PBiTerminal2\Refund(
$this->authorization, $attributes, $this->options
);
}

return $refund;
}
}
26 changes: 26 additions & 0 deletions src/Chaching/Drivers/PBiTerminal2/Refund.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/*
* This file is part of Chaching.
*
* (c) 2021 BACKBONE, s.r.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Chaching\Drivers\PBiTerminal2;

use \Chaching\Chaching;
use \Chaching\Drivers\PBiTerminal\Refund as PBiTerminalRefund;


class Refund extends PBiTerminalRefund
{
protected function request_server_url()
{
return ($this->environment === Chaching::SANDBOX)
? 'https://vpos.te.sia.eu:8443/ecomm/MerchantHandler'
: 'https://vpos.sia.eu:8443/ecomm/MerchantHandler';
}
}
33 changes: 33 additions & 0 deletions src/Chaching/Drivers/PBiTerminal2/Request.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/*
* This file is part of Chaching.
*
* (c) 2021 BACKBONE, s.r.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Chaching\Drivers\PBiTerminal2;

use \Chaching\Chaching;
use \Chaching\Drivers\PBiTerminal\Request as PBiTerminalRequest;


class Request extends PBiTerminalRequest
{
protected function request_server_url()
{
return ($this->environment === Chaching::SANDBOX)
? 'https://vpos.te.sia.eu:8443/ecomm/MerchantHandler'
: 'https://vpos.sia.eu:8443/ecomm/MerchantHandler';
}

protected function request_client_url()
{
return ($this->environment === Chaching::SANDBOX)
? 'https://vpos.te.sia.eu/ecomm/ClientHandler'
: 'https://vpos.sia.eu/ecomm/ClientHandler';
}
}
28 changes: 28 additions & 0 deletions src/Chaching/Drivers/PBiTerminal2/Response.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

/*
* This file is part of Chaching.
*
* (c) 2021 BACKBONE, s.r.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Chaching\Drivers\PBiTerminal2;

use \Chaching\Chaching;
use \Chaching\Drivers\PBiTerminal\Response as PBiTerminalResponse;


class Response extends PBiTerminalResponse
{
protected function request_server_url()
{
return ($this->environment === Chaching::SANDBOX)
? 'https://vpos.te.sia.eu:8443/ecomm/MerchantHandler'
: 'https://vpos.sia.eu:8443/ecomm/MerchantHandler';
}
}


0 comments on commit 3bc8942

Please sign in to comment.