Overview
  • Namespace
  • Class

Namespaces

  • Mypos
    • IPC

Classes

  • Mypos\IPC\Authorization
  • Mypos\IPC\AuthorizationCapture
  • Mypos\IPC\AuthorizationList
  • Mypos\IPC\AuthorizationReverse
  • Mypos\IPC\Base
  • Mypos\IPC\Card
  • Mypos\IPC\CardStore
  • Mypos\IPC\Cart
  • Mypos\IPC\Config
  • Mypos\IPC\Customer
  • Mypos\IPC\Defines
  • Mypos\IPC\GetPaymentStatus
  • Mypos\IPC\GetTxnStatus
  • Mypos\IPC\Helper
  • Mypos\IPC\IAPreAuthorization
  • Mypos\IPC\IAPurchase
  • Mypos\IPC\IAStoreCard
  • Mypos\IPC\IAStoredCardUpdate
  • Mypos\IPC\IPCGetTxnLog
  • Mypos\IPC\Loader
  • Mypos\IPC\MandateManagement
  • Mypos\IPC\PreAuthorization
  • Mypos\IPC\PreAuthorizationCancellation
  • Mypos\IPC\PreAuthorizationCompletion
  • Mypos\IPC\PreAuthorizationStatus
  • Mypos\IPC\Purchase
  • Mypos\IPC\PurchaseByIcard
  • Mypos\IPC\Refund
  • Mypos\IPC\RequestMoney
  • Mypos\IPC\Response
  • Mypos\IPC\Reversal

Exceptions

  • Mypos\IPC\IPC_Exception
  1 <?php
  2 
  3 namespace Mypos\IPC;
  4 
  5 /**
  6  * Process IPC method: IPCAuthorizationCapture.
  7  * Collect, validate and send API params
  8  */
  9 class AuthorizationCapture extends Base
 10 {
 11     private $currency = 'EUR', $orderID, $amount;
 12 
 13     /**
 14      * Return purchase object
 15      *
 16      * @param Config $cnf
 17      */
 18     public function __construct(Config $cnf)
 19     {
 20         $this->setCnf($cnf);
 21     }
 22 
 23     /**
 24      * Purchase identifier - must be unique
 25      *
 26      * @param string $orderID
 27      *
 28      * @return AuthorizationCapture
 29      */
 30     public function setOrderID($orderID)
 31     {
 32         $this->orderID = $orderID;
 33 
 34         return $this;
 35     }
 36 
 37     /**
 38      * ISO-4217 Three letter currency code
 39      *
 40      * @param string $currency
 41      *
 42      * @return AuthorizationCapture
 43      */
 44     public function setCurrency($currency)
 45     {
 46         $this->currency = $currency;
 47 
 48         return $this;
 49     }
 50 
 51     /**
 52      *  The amount for completion
 53      * 
 54      * @param mixed $amount
 55      *
 56      * @return AuthorizationCapture
 57      */
 58     public function setAmount($amount)
 59     {
 60         $this->amount = $amount;
 61 
 62         return $this;
 63     }
 64 
 65     /**
 66      * Initiate API request
 67      *
 68      * @return Response
 69      * @throws IPC_Exception
 70      */
 71     public function process()
 72     {
 73         $this->validate();
 74 
 75         $this->_addPostParam('IPCmethod', 'IPCAuthorizationCapture');
 76         $this->_addPostParam('IPCVersion', $this->getCnf()->getVersion());
 77         $this->_addPostParam('IPCLanguage', $this->getCnf()->getLang());
 78         $this->_addPostParam('SID', $this->getCnf()->getSid());
 79         $this->_addPostParam('WalletNumber', $this->getCnf()->getWallet());
 80         $this->_addPostParam('KeyIndex', $this->getCnf()->getKeyIndex());
 81         $this->_addPostParam('Source', $this->getCnf()->getSource());
 82 
 83         $this->_addPostParam('OrderID', $this->getOrderID());
 84 
 85         $this->_addPostParam('Amount', $this->getAmount());
 86         $this->_addPostParam('Currency', $this->getCurrency());
 87         
 88         $this->_addPostParam('OutputFormat', $this->getOutputFormat());
 89 
 90         return $this->_processPost();
 91     }
 92 
 93     /**
 94      * Validate all set purchase details
 95      *
 96      * @return boolean
 97      * @throws IPC_Exception
 98      */
 99     public function validate()
100     {
101         try {
102             $this->getCnf()->validate();
103         } catch (\Exception $ex) {
104             throw new IPC_Exception('Invalid Config details: ' . $ex->getMessage());
105         }
106 
107         if (!Helper::versionCheck($this->getCnf()->getVersion(), '1.4')) {
108             throw new IPC_Exception('IPCVersion ' . $this->getCnf()->getVersion() . ' does not support IPCAuthorizationCapture method. Please use 1.4 or above.');
109         }
110 
111         if ($this->getCurrency() === null) {
112             throw new IPC_Exception('Invalid currency');
113         }
114 
115         if ($this->getAmount() === null || !Helper::isValidAmount($this->getAmount())) {
116             throw new IPC_Exception('Empty or invalid amount');
117         }
118         
119         return true;
120     }
121 
122     /**
123      * ISO-4217 Three letter currency code
124      *
125      * @return string
126      */
127     public function getCurrency()
128     {
129         return $this->currency;
130     }
131 
132     /**
133      * Purchase identifier
134      *
135      * @return string
136      */
137     public function getOrderID()
138     {
139         return $this->orderID;
140     }
141     
142     /**
143      *  The amount for completion
144      *
145      * @return mixed
146      */
147     public function getAmount()
148     {
149         return $this->amount;
150     }
151     
152 }
153 
API documentation generated by ApiGen