Skip to content

Commit

Permalink
Merge pull request #75 from globalpayments/20210105-deployment
Browse files Browse the repository at this point in the history
20210105 deployment
  • Loading branch information
securesubmit-buildmaster authored Jan 5, 2021
2 parents 5cf1b51 + ea39c07 commit c8b108c
Show file tree
Hide file tree
Showing 32 changed files with 12,585 additions and 12,626 deletions.
96 changes: 48 additions & 48 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="./test/setup.php"
colors="true"
processIsolation="false"
stopOnFailure="true"
>
<php>
<ini name="zend.enable_gc" value="0"/>
<ini name="memory_limit" value="-1"/>
<!-- error_reporting(E_ALL); -->
<ini name="error_reporting" value="32767"/>
</php>

<testsuites>
<testsuite name="all">
<directory>./test/</directory>
</testsuite>
<testsuite name="unit">
<directory>./test/Unit/</directory>
</testsuite>
<testsuite name="integration">
<directory>./test/Integration/</directory>
</testsuite>
<testsuite name="certification">
<directory>./test/Integration/Gateways/PorticoConnector/Certifications/</directory>
<directory>./test/Integration/Gateways/RealexConnector/Certifications/</directory>
</testsuite>
<testsuite name="portico">
<directory>./test/Integration/Gateways/PorticoConnector/</directory>
</testsuite>
<testsuite name="realex">
<directory>./test/Integration/Gateways/RealexConnector/</directory>
</testsuite>

</testsuites>

<filter>
<whitelist>
<directory>./src/</directory>
<exclude>
<directory>./test/</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
<!-- vim: set ft=xml -->
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="./test/setup.php"
colors="true"
processIsolation="false"
stopOnFailure="false"
>
<php>
<ini name="zend.enable_gc" value="0"/>
<ini name="memory_limit" value="-1"/>
<!-- error_reporting(E_ALL); -->
<ini name="error_reporting" value="32767"/>
</php>

<testsuites>
<testsuite name="all">
<directory>./test/</directory>
</testsuite>
<testsuite name="unit">
<directory>./test/Unit/</directory>
</testsuite>
<testsuite name="integration">
<directory>./test/Integration/</directory>
</testsuite>
<testsuite name="certification">
<directory>./test/Integration/Gateways/PorticoConnector/Certifications/</directory>
<directory>./test/Integration/Gateways/RealexConnector/Certifications/</directory>
</testsuite>
<testsuite name="portico">
<directory>./test/Integration/Gateways/PorticoConnector/</directory>
</testsuite>
<testsuite name="realex">
<directory>./test/Integration/Gateways/RealexConnector/</directory>
</testsuite>

</testsuites>

<filter>
<whitelist>
<directory>./src/</directory>
<exclude>
<directory>./test/</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
<!-- vim: set ft=xml -->
Binary file removed sami.phar
Binary file not shown.
221 changes: 111 additions & 110 deletions src/Entities/RecurringEntity.php
Original file line number Diff line number Diff line change
@@ -1,110 +1,111 @@
<?php

namespace GlobalPayments\Api\Entities;

use GlobalPayments\Api\ServicesContainer;
use GlobalPayments\Api\Entities\Exceptions\ApiException;
use GlobalPayments\Api\Entities\Exceptions\UnsupportedTransactionException;
use GlobalPayments\Api\PaymentMethods\RecurringPaymentMethod;
use GlobalPayments\Api\Services\RecurringService;

/**
* Base implementation for recurring resource types.
* </summary>
*/
abstract class RecurringEntity implements IRecurringEntity
{
/**
* All resource should be supplied a merchant-/application-defined ID.
*
* @var string
*/
public $id;

/**
* All resources should be supplied a gateway-defined ID.
*
* @var string
*/
public $key;

/**
* {@inheritDoc}
*/
public function create()
{
return RecurringService::create($this);
}

/**
* {@inheritDoc}
*/
public function delete($force = false)
{
try {
return RecurringService::delete($this, $force);
} catch (ApiException $exc) {
throw new ApiException('Failed to delete record, see inner exception for more details', $exc);
}
}

/**
* {@inheritDoc}
*/
public static function find($id, $configName = 'default')
{
$client = ServicesContainer::instance()->getRecurringClient($configName);
if (!$client->supportsRetrieval) {
throw new UnsupportedTransactionException();
}

$identifier = static::getIdentifierName();
$response = RecurringService::search(static::class)
->addSearchCriteria($identifier, $id)
->execute();
$entity = isset($response[0]) ? $response[0] : null;

if ($entity !== null) {
return RecurringService::get($entity);
}

return null;
}

/**
* {@inheritDoc}
*/
public static function findAll($configName = 'default')
{
$client = ServicesContainer::instance()->getRecurringClient($configName);
if (!$client->supportsRetrieval) {
throw new UnsupportedTransactionException();
}

return RecurringService::search(static::class)->execute();
}

/**
* {@inheritDoc}
*/
public function saveChanges($configName = 'default')
{
try {
return RecurringService::edit($this);
} catch (ApiException $exc) {
throw new ApiException('Update failed, see inner exception for more details', $exc);
}
}

protected static function getIdentifierName()
{
if (static::class === Customer::class) {
return 'customerIdentifier';
} elseif (static::class === RecurringPaymentMethod::class) {
return 'paymentMethodIdentifier';
} elseif (static::class === Schedule::class) {
return 'scheduleIdentifier';
}
return '';
}
}
<?php

namespace GlobalPayments\Api\Entities;

use GlobalPayments\Api\ServicesContainer;
use GlobalPayments\Api\Entities\Exceptions\ApiException;
use GlobalPayments\Api\Entities\Exceptions\UnsupportedTransactionException;
use GlobalPayments\Api\PaymentMethods\RecurringPaymentMethod;
use GlobalPayments\Api\Services\RecurringService;

/**
* Base implementation for recurring resource types.
* </summary>
*/
abstract class RecurringEntity implements IRecurringEntity
{
/**
* All resource should be supplied a merchant-/application-defined ID.
*
* @var string
*/
public $id;

/**
* All resources should be supplied a gateway-defined ID.
*
* @var string
*/
public $key;

/**
* {@inheritDoc}
*/
public function create()
{
return RecurringService::create($this);
}

/**
* {@inheritDoc}
*/
public function delete($force = false)
{
try {
return RecurringService::delete($this, $force);
} catch (ApiException $exc) {
throw new ApiException('Failed to delete record, see inner exception for more details', $exc);
}
}

/**
* {@inheritDoc}
*/
public static function find($id, $configName = 'default')
{
$client = ServicesContainer::instance()->getRecurringClient($configName);
if (!$client->supportsRetrieval) {
throw new UnsupportedTransactionException();
}

$identifier = static::getIdentifierName();
$response = RecurringService::search(static::class)
->addSearchCriteria($identifier, $id)
->execute();

foreach ($response as $entity) {
if ($entity->id === $id) {
return RecurringService::get($entity);
}
}

return null;
}

/**
* {@inheritDoc}
*/
public static function findAll($configName = 'default')
{
$client = ServicesContainer::instance()->getRecurringClient($configName);
if (!$client->supportsRetrieval) {
throw new UnsupportedTransactionException();
}

return RecurringService::search(static::class)->execute();
}

/**
* {@inheritDoc}
*/
public function saveChanges($configName = 'default')
{
try {
return RecurringService::edit($this);
} catch (ApiException $exc) {
throw new ApiException('Update failed, see inner exception for more details', $exc);
}
}

protected static function getIdentifierName()
{
if (static::class === Customer::class) {
return 'customerIdentifier';
} elseif (static::class === RecurringPaymentMethod::class) {
return 'paymentMethodIdentifier';
} elseif (static::class === Schedule::class) {
return 'scheduleIdentifier';
}
return '';
}
}
Loading

0 comments on commit c8b108c

Please sign in to comment.