Source of file PaymentTestPaymentExtensionHooks.php
Size: 3,457 Bytes - Last Modified: 2021-12-24T06:34:53+00:00
/var/www/docs.ssmods.com/process/src/tests/Extensions/PaymentTestPaymentExtensionHooks.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 | <?php namespace SilverStripe\Omnipay\Tests\Extensions; use SilverStripe\ORM\DataExtension; use SilverStripe\Dev\TestOnly; /** * Extension that can be used to test payment hooks * @codeCoverageIgnore */ class PaymentTestPaymentExtensionHooks extends DataExtension implements TestOnly { protected static $instances = []; /** * Fint the PaymentTestPaymentExtensionHooks instance for a given payment ID * @param $id * @return PaymentTestPaymentExtensionHooks|null */ public static function findExtensionForID($id) { if (empty(self::$instances[$id])) { return null; } return self::$instances[$id]; } public static function ResetAll() { foreach (self::$instances as $instance) { $instance->Reset(); } self::$instances = []; } protected $callStack = []; public function setOwner($owner, $ownerBaseClass = null) { parent::setOwner($owner, $ownerBaseClass); if ($owner) { self::$instances[$owner->ID] = $this; } } public function Reset() { $this->callStack = []; } /** * Get an array of the extension methods that were called and their arguments * @return array */ public function getCallStack() { return $this->callStack; } /** * Get an array of the extension methods that were called * @return array */ public function getCalledMethods() { $result = []; array_walk($this->callStack, function ($value, $key) use (&$result) { $result[] = $value['method']; }); return $result; } public function onAuthorized($serviceResponse) { $this->callStack[] = array( 'method' => 'onAuthorized', 'args' => array($serviceResponse) ); } public function onAwaitingAuthorized($serviceResponse) { $this->callStack[] = array( 'method' => 'onAwaitingAuthorized', 'args' => array($serviceResponse) ); } public function onCaptured($serviceResponse) { $this->callStack[] = array( 'method' => 'onCaptured', 'args' => array($serviceResponse) ); } public function onAwaitingCaptured($serviceResponse) { $this->callStack[] = array( 'method' => 'onAwaitingCaptured', 'args' => array($serviceResponse) ); } public function onRefunded($serviceResponse) { $this->callStack[] = array( 'method' => 'onRefunded', 'args' => array($serviceResponse) ); } public function onVoid($serviceResponse) { $this->callStack[] = array( 'method' => 'onVoid', 'args' => array($serviceResponse) ); } public function onCancelled() { $this->callStack[] = array( 'method' => 'onCancelled', 'args' => [] ); } public function onCardCreated($serviceResponse) { $this->callStack[] = array( 'method' => 'onCardCreated', 'args' => array($serviceResponse) ); } public function onAwaitingCreateCard($serviceResponse) { $this->callStack[] = array( 'method' => 'onAwaitingCreateCard', 'args' => array($serviceResponse) ); } } |