first commit

This commit is contained in:
2025-03-12 17:06:23 +01:00
commit 2241f7131f
13185 changed files with 1692479 additions and 0 deletions

View File

@@ -0,0 +1,124 @@
<?php
namespace Eservice;
class Config
{
static $SessionTokenRequestUrl;
static $PaymentOperationActionUrl;
static $BaseUrl;
static $JavaScriptUrl;
static $DEFAULT_CASHIER_URL_TEST = "https://cashierui-apiuat.test.myriadpayments.com/ui/cashier";
static $DEFAULT_JAVASCRIPT_URL_TEST = "https://cashierui-apiuat.test.myriadpayments.com/js/api.js";
static $DEFAULT_TOKEN_URL_TEST = "https://apiuat.test.myriadpayments.com/token";
static $DEFAULT_ACTION_URL_TEST = "https://apiuat.test.myriadpayments.com/payments";
static $DEFAULT_CASHIER_URL_PRODUCTION = "https://cashierui-api.myriadpayments.com/ui/cashier";
static $DEFAULT_JAVASCRIPT_URL_PRODUCTION = "https://cashierui-apiuat.test.myriadpayments.com/js/api.js";
static $DEFAULT_TOKEN_URL_PRODUCTION = "https://api.myriadpayments.com/token";
static $DEFAULT_ACTION_URL_PRODUCTION = "https://api.myriadpayments.comm/payments";
static $TestUrls = [
"SessionTokenRequestUrl" => "",
"PaymentOperationActionUrl" => "",
"JavaScriptUrl" => "",
"BaseUrl" => "",
];
static $ProductionUrls = [
"SessionTokenRequestUrl" => "",
"PaymentOperationActionUrl" => "",
"JavaScriptUrl" => "",
"BaseUrl" => "",
];
static $Protocol = "https";
static $Method = "POST";
static $ContentType = "application/x-www-form-urlencoded";
static $MerchantId = "";
static $Password = "";
public static function buildEvoEnv4Test($baseUrl, $javascriptUrl, $tokenUrl, $actionUrl) {
if(empty($tokenUrl)){
$tokenUrl = self::$DEFAULT_TOKEN_URL_TEST;
}
if(empty($actionUrl)) {
$actionUrl = self::$DEFAULT_ACTION_URL_TEST;
}
if(empty($baseUrl)){
$baseUrl = self::$DEFAULT_CASHIER_URL_TEST;
}
if(empty($javascriptUrl)){
$javascriptUrl = self::$DEFAULT_JAVASCRIPT_URL_TEST;
}
self::$TestUrls['BaseUrl'] = $baseUrl;
self::$TestUrls['JavaScriptUrl'] = $javascriptUrl;
self::$TestUrls['SessionTokenRequestUrl'] = $tokenUrl;
self::$TestUrls['PaymentOperationActionUrl'] = $actionUrl;
self::test();
}
public static function buildEvoEnv4Prod($baseUrl, $javascriptUrl, $tokenUrl, $actionUrl) {
if(empty($tokenUrl)){
$tokenUrl = self::$DEFAULT_TOKEN_URL_PRODUCTION;
}
if(empty($actionUrl)) {
$actionUrl = self::$DEFAULT_ACTION_URL_PRODUCTION;
}
if(empty($baseUrl)){
$baseUrl = self::$DEFAULT_CASHIER_URL_PRODUCTION;
}
if(empty($javascriptUrl)){
$javascriptUrl = self::$DEFAULT_JAVASCRIPT_URL_PRODUCTION;
}
self::$ProductionUrls['BaseUrl'] = $baseUrl;
self::$ProductionUrls['JavaScriptUrl'] = $javascriptUrl;
self::$ProductionUrls['SessionTokenRequestUrl'] = $tokenUrl;
self::$ProductionUrls['PaymentOperationActionUrl'] = $actionUrl;
self::production();
}
public static function factory()
{
foreach (func_get_args()[0] as $var => $value) {
self::${ucfirst($var)} = $value;
}
}
private static function test()
{
self::$SessionTokenRequestUrl = self::$TestUrls["SessionTokenRequestUrl"];
self::$PaymentOperationActionUrl = self::$TestUrls["PaymentOperationActionUrl"];
self::$BaseUrl = self::$TestUrls["BaseUrl"];
self::$JavaScriptUrl = self::$TestUrls["JavaScriptUrl"];
}
private static function production()
{
self::$SessionTokenRequestUrl = self::$ProductionUrls["SessionTokenRequestUrl"];
self::$PaymentOperationActionUrl = self::$ProductionUrls["PaymentOperationActionUrl"];
self::$BaseUrl = self::$ProductionUrls["BaseUrl"];
self::$JavaScriptUrl = self::$ProductionUrls["JavaScriptUrl"];
}
public static function baseUrl()
{
return self::$BaseUrl;
}
public static function javaScriptUrl()
{
return self::$JavaScriptUrl;
}
}

View File

@@ -0,0 +1,235 @@
<?php
namespace Eservice;
class Configurable implements \ArrayAccess, \Iterator, \Serializable
{
protected $_data = [];
protected $_rc;
const ACTION_TOKENIZE = "TOKENIZE";
const ACTION_AUTH = "AUTH";
const ACTION_CAPTURE = "CAPTURE";
const ACTION_VOID = "VOID";
const ACTION_PURCHASE = "PURCHASE";
const ACTION_REFUND = "REFUND";
const ACTION_STATUS_CHECK = "STATUS_CHECK";
const CHANNEL_ECOM = "ECOM";
const CHANNEL_MOTO = "MOTO";
const USER_DEVICE_MOBILE = "MOBILE";
const USER_DEVICE_DESKTOP = "DESKTOP";
const USER_DEVICE_UNKNOWN = "UNKNOWN";
const DOCUMENT_TYPE_PASSPORT = "PASSPORT";
const DOCUMENT_TYPE_NATIONAL_ID = "NATIONAL_ID";
const DOCUMENT_TYPE_DRIVING_LICENSE = "DRIVING_LICENSE";
const DOCUMENT_TYPE_UNIQUE_TAXPAYER_REFERENCE = "UNIQUE_TAXPAYER_REFERENCE";
const DOCUMENT_TYPE_OTHER = "OTHER";
const SEX_M = "M";
const SEX_F = "F";
public function __construct()
{
$this->_rc = new \ReflectionClass($this);
}
public function __call($name, $value)
{
try {
if (($this->_request instanceof Request) and ($this->_request->_rc->hasMethod("_{$name}"))) {
return call_user_func_array([$this->_request, "_{$name}"], $value);
}
switch (strtolower($name)) {
case "auth":
case "capture":
case "purchase":
case "refund":
case "statuscheck":
case "status_check":
case "void":
case "tokenize":
return call_user_func_array([$this->_request, $name], $this->_data);
break;
case "merchantid":
Config::$MerchantId = $value[0];
break;
case "password":
Config::$Password = $value[0];
break;
}
if (!isset($value[0])) {
if (isset($this->_data[$name])) {
return $this->_data[$name];
} else {
return null;
}
} else {
if (is_array($value[0])) {
foreach ($value[0] as $k => $v) {
$this->_data[$k] = $v;
}
} else {
$this->_data[$name] = $value[0];
}
}
return $this;
} catch (Exception $e) {
throw $e;
}
}
protected function _set($data = [])
{
try {
if ((is_array($data)) and (count($data) > 0)) {
foreach ($data as $name => $value) {
if (is_array($value)) {
call_user_func_array([$this, "_set"], $value);
} else {
switch (strtolower($name)) {
case "merchantid":
Config::$MerchantId = $value;
break;
case "password":
Config::$Password = $value;
break;
default:
$this->_data[$name] = $value;
break;
}
}
}
}
return $this;
} catch (Exception $e) {
throw $e;
}
}
public function __set($name, $value)
{
switch (strtolower($name)) {
case "merchantid":
Config::$MerchantId = $value;
break;
case "password":
Config::$Password = $value;
break;
default:
$this->_data[$name] = $value;
break;
}
}
public function __get($name)
{
return isset($this->_data[$name]) ? $this->_data[$name] : null;
}
public function __isset($name)
{
return isset($this->_data[$name]);
}
public function __unset($name)
{
unset($this->_data[$name]);
}
public function offsetSet($offset, $value)
{
if (is_null($offset)) {
$this->_data[] = $value;
} else {
$this->_data[$offset] = $value;
}
}
public function offsetExists($offset)
{
return isset($this->_data[$offset]);
}
public function offsetUnset($offset)
{
unset($this->_data[$offset]);
}
public function offsetGet($offset)
{
return isset($this->_data[$offset]) ? $this->_data[$offset] : null;
}
function rewind()
{
return reset($this->_data);
}
function current()
{
return current($this->_data);
}
function key()
{
return key($this->_data);
}
function next()
{
return next($this->_data);
}
function valid()
{
return key($this->_data) !== null;
}
public function serialize()
{
return serialize($this->_data);
}
public function unserialize($data)
{
$this->_data = unserialize($data);
}
public function __debugInfo()
{
return $this->_data;
}
public function testEnvironment()
{
Config::buildEvoEnv4Test(null, null, null, null);
foreach (func_get_args()[0] as $k => $v) {
$this->$k = $v;
}
return $this;
}
public function productionEnvironment()
{
Config::buildEvoEnv4Prod(null, null, null, null);
foreach (func_get_args()[0] as $k => $v) {
$this->$k = $v;
}
return $this;
}
public function baseUrl()
{
return Config::$BaseUrl;
}
public function javaScriptUrl()
{
return Config::$JavaScriptUrl;
}
}

View File

@@ -0,0 +1,8 @@
<?php
namespace Eservice;
class PaymentsExceptionConfigurationEndpointNotSet extends \Exception
{
}

View File

@@ -0,0 +1,8 @@
<?php
namespace Eservice;
class PaymentsExceptionExecuteNetworkError extends \Exception
{
}

View File

@@ -0,0 +1,8 @@
<?php
namespace Eservice;
class PaymentsExceptionMethodNotFound extends \Exception
{
}

View File

@@ -0,0 +1,8 @@
<?php
namespace Eservice;
class PaymentsExceptionParamNotExisting extends \Exception
{
}

View File

@@ -0,0 +1,8 @@
<?php
namespace Eservice;
class PaymentsExceptionParamNotSet extends \Exception
{
}

View File

@@ -0,0 +1,8 @@
<?php
namespace Eservice;
class PaymentsExceptionParamValueNotExisting extends \Exception
{
}

View File

@@ -0,0 +1,8 @@
<?php
namespace Eservice;
class PaymentsExceptionProcessDataNotSet extends \Exception
{
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Eservice;
abstract class Executable extends Configurable
{
public abstract function validate();
public abstract function execute($callback = null, $result_from_prev = []);
}

View File

@@ -0,0 +1,15 @@
<?php
namespace Eservice;
class Payments extends Request
{
protected $_request;
public function __construct()
{
parent::__construct();
$this->_request = new Request();
}
}

View File

@@ -0,0 +1,176 @@
<?php
namespace Eservice;
class Request extends Executable
{
protected $_token_request;
protected $_action_request;
protected $_keys = [
"token" => "token",
"merchantId" => "merchantId",
];
public function __construct()
{
parent::__construct();
ini_set('precision',30);
$this->_data["timestamp"] = (string)round(microtime(true) * 1000);
call_user_func_array([$this, "_set"], func_get_args());
}
public function __call($name, $value)
{
switch ($name) {
case "tokenize":
return new RequestTokenize($value);
break;
case "auth":
return new RequestAuth($value);
break;
case "capture":
return new RequestCapture($value);
break;
case "purchase":
return new RequestPurchase($value);
break;
case "refund":
return new RequestRefund($value);
break;
case "statuscheck":
case "status_check":
return new RequestStatusCheck($value);
break;
case "void":
return new RequestVoid($value);
break;
}
return parent::__call($name, $value);
}
public function validate()
{
$data = $this->_data;
if ((is_array($this->_params)) and (count($this->_params) > 0) and (is_array($this->_data))) {
foreach ($this->_params as $key => $value) {
if ($value["type"] == "mandatory") {
if (!isset($this->_data[$key])) {
$ex = new PaymentsExceptionParamNotSet($key, null, isset($ex) ? $ex : null);
}
} else {
if ($value["type"] == "conditional") {
if (is_array($value["mandatory"])) {
foreach ($value["mandatory"] as $check => $value) {
if ((isset($this->_data[$check])) and ($this->_data[$check] == $value) and (!isset($this->_data[$key]))) {
$ex = new PaymentsExceptionParamNotSet($key, null, isset($ex) ? $ex : null);
}
}
}
}
}
}
foreach ($this->_data as $check => $value) {
if (!isset($this->_params[$check])) {
unset($data[$check]);
}
}
}
if (isset($ex)) {
throw $ex;
}
return $data;
}
public function execute($callback = null, $result_from_prev = [])
{
try {
$this->_data["merchantId"] = Config::$MerchantId;
$this->_data["password"] = Config::$Password;
$token_result = $this->_token_request->execute(null, $this->_data);
if (is_a($token_result, "Payments\ResponseError")) {
return $token_result;
}
foreach ($token_result as $k => $v) {
$this->_data[$this->_keys($k)] = $v;
}
return $this->_action_request->execute($callback, $this->_data);
} catch (\Exception $e) {
throw $e;
}
}
protected function _keys($k)
{
if (isset($this->_keys[$k])) {
return $this->_keys[$k];
}
return $k;
}
protected function _exec_post($url, $data, $callback = null)
{
if (empty($url)) {
throw new PaymentsExceptionConfigurationEndpointNotSet;
}
if ((empty($data)) or (!is_array($data)) or (count($data) == 0)) {
throw new PaymentsExceptionProcessDataNotSet;
}
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, Config::$Method);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
$response = curl_exec($ch);
$info = curl_getinfo($ch);
if ($response === false) {
throw new PaymentsExceptionExecuteNetworkError(curl_error($ch), curl_errno($ch));
}
curl_close($ch);
$response = json_decode(trim($response), true);
if ((!is_null($callback)) && (is_callable($callback))) {
call_user_func($callback, $response);
} else {
if (!isset($response["result"]) or $response["result"] != "success") {
return new ResponseError($response, $data, $info);
}
return new ResponseSuccess($response, $info);
}
}
public function token()
{
$this->_data["merchantId"] = Config::$MerchantId;
$this->_data["password"] = Config::$Password;
return $this->_token_request->execute(null, $this->_data);
}
public function __debugInfo()
{
$data = [];
$data["request"] = $this->_data;
if ($this->_token_request instanceof Request) {
$data["token_request"] = $this->_token_request->_data;
}
if ($this->_action_request instanceof Request) {
$data["action_request"] = $this->_action_request->_data;
}
return $data;
}
}

View File

@@ -0,0 +1,28 @@
<?php
namespace Eservice;
class RequestAction extends Request
{
public function execute($callback = null, $result_from_prev = [])
{
try {
foreach ($result_from_prev as $k => $v) {
$this->_data[$k] = $v;
}
$data = $this->validate();
return $this->_exec_post(Config::$PaymentOperationActionUrl, $data, $callback);
} catch (\Exception $e) {
throw $e;
}
}
public function _get_data_from_prev($result_from_prev)
{
$this->_data["merchantId"] = $result_from_prev["merchantId"];
$this->_data["token"] = $result_from_prev["token"];
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace Eservice;
class RequestActionAuth extends RequestAction
{
protected $_params = [
"merchantId" => ["type" => "mandatory"],
"token" => ["type" => "mandatory"],
"specinCreditCardCVV" => [
"type" => "conditional",
"mandatory" => [
"paymentMethod" => "CreditCard",
"channel" => "ECOM"
],
],
"freeText" => ["type" => "optional"],
];
}

View File

@@ -0,0 +1,14 @@
<?php
namespace Eservice;
class RequestActionCapture extends RequestActionRefund
{
public function __construct()
{
parent::__construct();
$this->_data["action"] = Payments::ACTION_CAPTURE;
}
}

View File

@@ -0,0 +1,14 @@
<?php
namespace Eservice;
class RequestActionPurchase extends RequestActionAuth
{
public function __construct()
{
parent::__construct();
$this->_data["action"] = Payments::ACTION_PURCHASE;
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace Eservice;
class RequestActionRefund extends RequestAction
{
protected $_params = [
"merchantId" => ["type" => "mandatory"],
"token" => ["type" => "mandatory"],
];
public function __construct()
{
parent::__construct();
$this->_data["action"] = Payments::ACTION_REFUND;
}
}

View File

@@ -0,0 +1,25 @@
<?php
namespace Eservice;
class RequestActionStatusCheck extends RequestAction
{
protected $_params = [
"merchantId" => ["type" => "mandatory"],
"token" => ["type" => "mandatory"],
"action" => [
"type" => "mandatory",
"values" => [Payments::ACTION_STATUS_CHECK],
],
"txId" => ["type" => "optional"],
"merchantTxId" => ["type" => "optional"],
];
public function __construct()
{
parent::__construct();
$this->_data["action"] = Payments::ACTION_STATUS_CHECK;
}
}

View File

@@ -0,0 +1,20 @@
<?php
namespace Eservice;
class RequestActionTokenize extends RequestAction
{
protected $_params = [
"merchantId" => ["type" => "mandatory"],
"token" => ["type" => "mandatory"],
"number" => ["type" => "mandatory"],
"nameOnCard" => ["type" => "mandatory"],
"expiryMonth" => ["type" => "mandatory"],
"expiryYear" => ["type" => "mandatory"],
"startMonth" => ["type" => "optional"],
"startYear" => ["type" => "optional"],
"issueNumber" => ["type" => "optional"],
"cardDescription" => ["type" => "optional"],
];
}

View File

@@ -0,0 +1,7 @@
<?php
namespace Eservice;
class RequestActionVoid extends RequestActionRefund
{
}

View File

@@ -0,0 +1,15 @@
<?php
namespace Eservice;
class RequestAuth extends Request
{
public function __construct($values = [])
{
parent::__construct();
$this->_token_request = new RequestTokenAuth($values);
$this->_action_request = new RequestActionAuth($values);
}
}

View File

@@ -0,0 +1,15 @@
<?php
namespace Eservice;
class RequestCapture extends RequestRefund
{
public function __construct($values = [])
{
parent::__construct();
$this->_token_request = new RequestTokenCapture($values);
$this->_action_request = new RequestActionCapture($values);
}
}

View File

@@ -0,0 +1,15 @@
<?php
namespace Eservice;
class RequestPurchase extends RequestAuth
{
public function __construct($values = [])
{
parent::__construct();
$this->_token_request = new RequestTokenPurchase($values);
$this->_action_request = new RequestActionPurchase($values);
}
}

View File

@@ -0,0 +1,15 @@
<?php
namespace Eservice;
class RequestRefund extends Request
{
public function __construct($values = [])
{
parent::__construct();
$this->_token_request = new RequestTokenRefund($values);
$this->_action_request = new RequestActionRefund($values);
}
}

View File

@@ -0,0 +1,15 @@
<?php
namespace Eservice;
class RequestStatusCheck extends Request
{
public function __construct($values = [])
{
parent::__construct();
$this->_token_request = new RequestTokenStatusCheck($values);
$this->_action_request = new RequestActionStatusCheck($values);
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace Eservice;
class RequestToken extends Request
{
public function execute($callback = null, $result_from_prev = [])
{
try {
foreach ($result_from_prev as $k => $v) {
$this->_data[$k] = $v;
}
$data = $this->validate();
return $this->_exec_post(Config::$SessionTokenRequestUrl, $data, $callback);
} catch (\Exception $e) {
throw $e;
}
}
}

View File

@@ -0,0 +1,126 @@
<?php
namespace Eservice;
class RequestTokenAuth extends RequestToken
{
protected $_params = [
"action" => [
"type" => "mandatory",
"values" => [Payments::ACTION_AUTH, Payments::ACTION_PURCHASE],
],
"merchantId" => ["type" => "mandatory"],
"password" => ["type" => "mandatory"],
"timestamp" => ["type" => "mandatory"],
"allowOriginUrl" => ["type" => "mandatory"],
"channel" => ["type" => "mandatory"],
"amount" => ["type" => "mandatory"],
"currency" => ["type" => "mandatory"],
"country" => ["type" => "mandatory"],
"paymentSolutionId" => ["type" => "mandatory"],
"merchantNotificationUrl" => ["type" => "mandatory"],
"customerId" => [
"type" => "conditional",
"mandatory" => ["paymentMethod" => "CreditCard"],
],
"customerDocumentNumber" => [
"type" => "conditional",
"mandatory" => ["customerDocumentType" => "isset"],
],
"payerDocumentNumber" => [
"type" => "conditional",
"mandatory" => ["payerDocumentType" => "isset"],
],
"merchantTxId" => ["type" => "optional"],
"brandId" => ["type" => "optional"],
"userDevice" => ["type" => "optional"],
"userAgent" => ["type" => "optional"],
"taxAmount" => ["type" => "optional"],
"shippingAmount" => ["type" => "optional"],
"chargeAmount" => ["type" => "optional"],
"discountAmount" => ["type" => "optional"],
"language" => ["type" => "optional"],
"s_text1" => ["type" => "optional"],
"s_text2" => ["type" => "optional"],
"s_text3" => ["type" => "optional"],
"s_text4" => ["type" => "optional"],
"s_text5" => ["type" => "optional"],
"d_date1" => ["type" => "optional"],
"d_date2" => ["type" => "optional"],
"d_date3" => ["type" => "optional"],
"d_date4" => ["type" => "optional"],
"d_date5" => ["type" => "optional"],
"b_bool1" => ["type" => "optional"],
"b_bool2" => ["type" => "optional"],
"b_bool3" => ["type" => "optional"],
"b_bool4" => ["type" => "optional"],
"b_bool5" => ["type" => "optional"],
"n_num1" => ["type" => "optional"],
"n_num2" => ["type" => "optional"],
"n_num3" => ["type" => "optional"],
"n_num4" => ["type" => "optional"],
"n_num5" => ["type" => "optional"],
"merchantLandingPageUrl" => ["type" => "optional"],
"firstTimeTransaction" => ["type" => "optional"],
"customerDocumentType" => ["type" => "optional"],
"customerFirstName" => ["type" => "optional"],
"customerLastName" => ["type" => "optional"],
"customerSex" => ["type" => "optional"],
"customerDateOfBirth" => ["type" => "optional"],
"customerRegistrationDate" => ["type" => "optional"],
"customerEmail" => ["type" => "optional"],
"customerPhone" => ["type" => "optional"],
"customerIPAddress" => ["type" => "optional"],
"customerCountry" => ["type" => "optional"],
"customerAddressHouseName" => ["type" => "optional"],
"customerAddressHouseNumber" => ["type" => "optional"],
"customerAddressFlat" => ["type" => "optional"],
"customerAddressStreet" => ["type" => "optional"],
"customerAddressCity" => ["type" => "optional"],
"customerAddressDistrict" => ["type" => "optional"],
"customerAddressPostalCode" => ["type" => "optional"],
"customerAddressCountry" => ["type" => "optional"],
"customerAddressState" => ["type" => "optional"],
"customerAddressPhone" => ["type" => "optional"],
"customerShippingAddressHouseName" => ["type" => "optional"],
"customerShippingAddressHouseNumber" => ["type" => "optional"],
"customerShippingAddressFlat" => ["type" => "optional"],
"customerShippingAddressStreet" => ["type" => "optional"],
"customerShippingAddressCity" => ["type" => "optional"],
"customerShippingAddressDistrict" => ["type" => "optional"],
"customerShippingAddressPostalCode" => ["type" => "optional"],
"customerShippingAddressCountry" => ["type" => "optional"],
"customerShippingAddressState" => ["type" => "optional"],
"customerShippingAddressPhone" => ["type" => "optional"],
"customerBillingAddressHouseName" => ["type" => "optional"],
"customerBillingAddressHouseNumber" => ["type" => "optional"],
"customerBillingAddressFlat" => ["type" => "optional"],
"customerBillingAddressStreet" => ["type" => "optional"],
"customerBillingAddressCity" => ["type" => "optional"],
"customerBillingAddressDistrict" => ["type" => "optional"],
"customerBillingAddressPostalCode" => ["type" => "optional"],
"customerBillingAddressCountry" => ["type" => "optional"],
"customerBillingAddressState" => ["type" => "optional"],
"customerBillingAddressPhone" => ["type" => "optional"],
"payerFirstName" => ["type" => "optional"],
"payerLastName" => ["type" => "optional"],
"payerEmail" => ["type" => "optional"],
"payerDateOfBirth" => ["type" => "optional"],
"payerPhone" => ["type" => "optional"],
"payerDocumentType" => ["type" => "optional"],
"payerCustomerId" => ["type" => "optional"],
"forceSecurePayment" => ["type" => "optional"],
"processUnknownSecurePayment" => ["type" => "optional"],
"specinCreditCardToken" => ["type" => "optional"],
"specinProcessWithoutCvv2" => ["type" => "optional"],
"bankMid" => ["type" => "optional"],
];
public function __construct()
{
parent::__construct();
$this->_data["action"] = Payments::ACTION_AUTH;
}
}

View File

@@ -0,0 +1,14 @@
<?php
namespace Eservice;
class RequestTokenCapture extends RequestTokenRefund
{
public function __construct()
{
parent::__construct();
$this->_data["action"] = Payments::ACTION_CAPTURE;
}
}

View File

@@ -0,0 +1,14 @@
<?php
namespace Eservice;
class RequestTokenPurchase extends RequestTokenAuth
{
public function __construct()
{
parent::__construct();
$this->_data["action"] = Payments::ACTION_PURCHASE;
}
}

View File

@@ -0,0 +1,29 @@
<?php
namespace Eservice;
class RequestTokenRefund extends RequestToken
{
protected $_params = [
"merchantId" => ["type" => "mandatory"],
"originalMerchantTxId" => ["type" => "mandatory"],
"password" => ["type" => "mandatory"],
"action" => [
"type" => "mandatory",
"values" => [Payments::ACTION_REFUND, Payments::ACTION_CAPTURE],
],
"timestamp" => ["type" => "mandatory"],
"allowOriginUrl" => ["type" => "mandatory"],
"amount" => ["type" => "mandatory"],
"originalTxId" => ["type" => "optional"],
"agentId" => ["type" => "optional"],
];
public function __construct()
{
parent::__construct();
$this->_data["action"] = Payments::ACTION_REFUND;
}
}

View File

@@ -0,0 +1,25 @@
<?php
namespace Eservice;
class RequestTokenStatusCheck extends RequestToken
{
protected $_params = [
"merchantId" => ["type" => "mandatory"],
"password" => ["type" => "mandatory"],
"action" => [
"type" => "mandatory",
"values" => [Payments::ACTION_STATUS_CHECK],
],
"timestamp" => ["type" => "mandatory"],
"allowOriginUrl" => ["type" => "mandatory"],
];
public function __construct()
{
parent::__construct();
$this->_data["action"] = Payments::ACTION_STATUS_CHECK;
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace Eservice;
class RequestTokenTokenize extends RequestToken
{
protected $_params = [
"action" => [
"type" => "mandatory",
"values" => [Payments::ACTION_TOKENIZE],
],
"merchantId" => ["type" => "mandatory"],
"password" => ["type" => "mandatory"],
"timestamp" => ["type" => "mandatory"],
"allowOriginUrl" => ["type" => "mandatory"],
"customerId" => ["type" => "optional"],
];
public function __construct()
{
parent::__construct();
$this->_data["action"] = Payments::ACTION_TOKENIZE;
}
}

View File

@@ -0,0 +1,28 @@
<?php
namespace Eservice;
class RequestTokenVoid extends RequestTokenRefund
{
protected $_params = [
"merchantId" => ["type" => "mandatory"],
"originalMerchantTxId" => ["type" => "mandatory"],
"password" => ["type" => "mandatory"],
"action" => [
"type" => "mandatory",
"values" => [Payments::ACTION_VOID],
],
"timestamp" => ["type" => "mandatory"],
"allowOriginUrl" => ["type" => "mandatory"],
"originalTxId" => ["type" => "optional"],
"agentId" => ["type" => "optional"],
];
public function __construct()
{
parent::__construct();
$this->_data["action"] = Payments::ACTION_VOID;
}
}

View File

@@ -0,0 +1,15 @@
<?php
namespace Eservice;
class RequestTokenize extends Request
{
public function __construct($values = [])
{
parent::__construct();
$this->_token_request = new RequestTokenTokenize($values);
$this->_action_request = new RequestActionTokenize($values);
}
}

View File

@@ -0,0 +1,15 @@
<?php
namespace Eservice;
class RequestVoid extends RequestRefund
{
public function __construct($values = [])
{
parent::__construct();
$this->_token_request = new RequestTokenVoid($values);
$this->_action_request = new RequestActionVoid($values);
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace Eservice;
class Response extends Configurable
{
protected $_info;
protected $_request = [];
public function __construct($response, $info = [])
{
$this->_data = $response;
$this->_info = new ResponseInfo($info);
}
public function get_info($name = null)
{
if (!is_null($name)) {
if (isset($this->info->{$name})) {
return $this->info->{$name};
}
return null;
}
return $this->info;
}
public function __debugInfo()
{
$data = [];
if ((is_array($this->_request)) && (count($this->_request) > 0)) {
$data["request"] = $this->_request;
}
$data["response"] = $this->_data;
$data["additionalInfo"] = $this->_info;
return $data;
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace Eservice;
class ResponseError extends Response
{
protected $_errors = [];
public function __construct($response, $request, $info = [])
{
parent::__construct($response, $info);
$this->_errors = new ResponseErrorErrors($this->data["errors"]);
$this->_request = $request;
}
public function get_error($name = null)
{
if (!is_null($name)) {
if (isset($this->errors->{$name})) {
return $this->errors->{$name};
}
return null;
}
return $this->errors;
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace Eservice;
class ResponseErrorErrors extends Response
{
public function __construct($errors = [])
{
if (is_array($errors)) {
foreach ($errors as $error) {
$this->_data[$error] = $error;
}
} else {
$this->_data[$errors] = $errors;
}
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace Eservice;
class ResponseInfo extends Response
{
public function __construct($info = [])
{
$this->_params = array_keys($info);
$this->_data = $info;
}
public function __debugInfo()
{
return $this->_data;
}
}

View File

@@ -0,0 +1,8 @@
<?php
namespace Eservice;
class ResponseSuccess extends Response
{
}

View File

@@ -0,0 +1,46 @@
<?php
include_once('lib/Config.php');
include_once('lib/Configurable.php');
include_once('lib/Executable.php');
include_once('lib/Request.php');
include_once('lib/Response.php');
include_once('lib/Payments.php');
include_once('lib/Exception/ConfigurationEndpointNotSet.php');
include_once('lib/Exception/ExecuteNetworkError.php');
include_once('lib/Exception/MethodNotFound.php');
include_once('lib/Exception/ParamNotExisting.php');
include_once('lib/Exception/ParamNotSet.php');
include_once('lib/Exception/ParamValueNotExisting.php');
include_once('lib/Exception/ProcessDataNotSet.php');
include_once('lib/Request/Action.php');
include_once('lib/Request/Auth.php');
include_once('lib/Request/Refund.php');
include_once('lib/Request/Capture.php');
include_once('lib/Request/Purchase.php');
include_once('lib/Request/StatusCheck.php');
include_once('lib/Request/Token.php');
include_once('lib/Request/Tokenize.php');
include_once('lib/Request/Void.php');
include_once('lib/Request/Action/Auth.php');
include_once('lib/Request/Action/Refund.php');
include_once('lib/Request/Action/Capture.php');
include_once('lib/Request/Action/Purchase.php');
include_once('lib/Request/Action/StatusCheck.php');
include_once('lib/Request/Action/Tokenize.php');
include_once('lib/Request/Action/Void.php');
include_once('lib/Request/Token/Auth.php');
include_once('lib/Request/Token/Refund.php');
include_once('lib/Request/Token/Capture.php');
include_once('lib/Request/Token/Purchase.php');
include_once('lib/Request/Token/StatusCheck.php');
include_once('lib/Request/Token/Tokenize.php');
include_once('lib/Request/Token/Void.php');
include_once('lib/Response/Error/Errors.php');
include_once('lib/Response/Error.php');
include_once('lib/Response/Info.php');
include_once('lib/Response/Success.php');