Overview
  • Namespace
  • Class

Namespaces

  • Mypos
    • IPC

Classes

  • Mypos\IPC\Base
  • Mypos\IPC\Card
  • Mypos\IPC\CardStore
  • Mypos\IPC\Cart
  • Mypos\IPC\Config
  • Mypos\IPC\Customer
  • Mypos\IPC\Defines
  • Mypos\IPC\GetTxnStatus
  • Mypos\IPC\Helper
  • Mypos\IPC\IAPurchase
  • Mypos\IPC\IAStoreCard
  • Mypos\IPC\IAStoredCardUpdate
  • Mypos\IPC\IPCGetTxnLog
  • Mypos\IPC\Loader
  • Mypos\IPC\MandateManagement
  • Mypos\IPC\Purchase
  • 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: IPCRequestMoney.
  7  * Collect, validate and send API params
  8  */
  9 class RequestMoney extends Base
 10 {
 11     private $currency = 'EUR', $amount, $orderID, $mandateReferece, $customerWalletNumber, $reversalIndicator, $reason;
 12 
 13     /**
 14      * Return Refund object
 15      * @param Config $cnf
 16      */
 17     public function __construct(Config $cnf)
 18     {
 19         $this->setCnf($cnf);
 20     }
 21 
 22     /**
 23      * Refund amount
 24      * @param float $amount
 25      */
 26     public function setAmount($amount)
 27     {
 28         $this->amount = $amount;
 29     }
 30 
 31     /**
 32      * Refund amount
 33      * @return float
 34      */
 35     public function getAmount()
 36     {
 37         return $this->amount;
 38     }
 39 
 40     /**
 41      * ISO-4217 Three letter currency code
 42      * @param string $currency
 43      * @return RequestMoney
 44      */
 45     public function setCurrency($currency)
 46     {
 47         $this->currency = $currency;
 48         return $this;
 49     }
 50 
 51     /**
 52      * ISO-4217 Three letter currency code
 53      * @return string
 54      */
 55     public function getCurrency()
 56     {
 57         return $this->currency;
 58     }
 59 
 60 
 61     /**
 62      * Request identifier - must be unique
 63      * @param string $orderID
 64      * @return RequestMoney
 65      */
 66     public function setOrderID($orderID)
 67     {
 68         $this->orderID = $orderID;
 69         return $this;
 70     }
 71 
 72     /**
 73      * Request identifier - must be unique
 74      * @return string
 75      */
 76     public function getOrderID()
 77     {
 78         return $this->orderID;
 79     }
 80 
 81     /**
 82      * Unique identifier of the agreement (mandate) between the merchant and the client (debtor). Up to 127 characters.
 83      * @return string
 84      */
 85     public function getMandateReferece()
 86     {
 87         return $this->mandateReferece;
 88     }
 89 
 90     /**
 91      * Unique identifier of the agreement (mandate) between the merchant and the client (debtor). Up to 127 characters.
 92      * @param string $mandateReferece
 93      */
 94     public function setMandateReferece($mandateReferece)
 95     {
 96         $this->mandateReferece = $mandateReferece;
 97     }
 98 
 99     /**
100      * Identifier of the client’s (debtor’s) myPOS account
101      * @return string
102      */
103     public function getCustomerWalletNumber()
104     {
105         return $this->customerWalletNumber;
106     }
107 
108     /**
109      * Identifier of the client’s (debtor’s) myPOS account
110      * @param string $customerWalletNumber
111      */
112     public function setCustomerWalletNumber($customerWalletNumber)
113     {
114         $this->customerWalletNumber = $customerWalletNumber;
115     }
116 
117     /**
118      * Reversal of the previously executed Request money transaction.
119      * @return bool
120      */
121     public function getReversalIndicator()
122     {
123         return $this->reversalIndicator;
124     }
125 
126     /**
127      * Reversal of the previously executed Request money transaction.
128      * @param bool $reversalIndicator
129      */
130     public function setReversalIndicator($reversalIndicator)
131     {
132         $this->reversalIndicator = $reversalIndicator;
133     }
134 
135     /**
136      * The reason for the transfer.
137      * @return string
138      */
139     public function getReason()
140     {
141         return $this->reason;
142     }
143 
144     /**
145      * The reason for the transfer.
146      * @param string $reason
147      */
148     public function setReason($reason)
149     {
150         $this->reason = $reason;
151     }
152 
153 
154     /**
155      * Initiate API request
156      * @return Response
157      */
158     public function process()
159     {
160         $this->validate();
161 
162         $this->_addPostParam('IPCmethod', 'IPCRequestMoney');
163         $this->_addPostParam('IPCVersion', $this->getCnf()->getVersion());
164         $this->_addPostParam('IPCLanguage', $this->getCnf()->getLang());
165         $this->_addPostParam('SID', $this->getCnf()->getSid());
166         $this->_addPostParam('WalletNumber', $this->getCnf()->getWallet());
167         $this->_addPostParam('KeyIndex', $this->getCnf()->getKeyIndex());
168         $this->_addPostParam('Source', Defines::SOURCE_PARAM);
169 
170         $this->_addPostParam('Currency', $this->getCurrency());
171         $this->_addPostParam('Amount', $this->getAmount());
172 
173         $this->_addPostParam('OrderID', $this->getOrderID());
174         $this->_addPostParam('MandateReference', $this->getMandateReferece());
175 
176         $this->_addPostParam('CustomerWalletNumber', $this->getCustomerWalletNumber());
177         $this->_addPostParam('ReversalIndicator', (int)$this->getReversalIndicator());
178         $this->_addPostParam('Reason', $this->getReason());
179         $this->_addPostParam('OutputFormat', $this->getOutputFormat());
180         return $this->_processPost();
181     }
182 
183     /**
184      * Validate all set refund details
185      * @return boolean
186      * @throws IPC_Exception
187      */
188     public function validate()
189     {
190         try {
191             $this->getCnf()->validate();
192         } catch (\Exception $ex) {
193             throw new IPC_Exception('Invalid Config details: ' . $ex->getMessage());
194         }
195 
196         if ($this->getAmount() == null || !Helper::isValidAmount($this->getAmount())) {
197             throw new IPC_Exception('Invalid Amount');
198         }
199 
200         if ($this->getCurrency() == null || !Helper::isValidCurrency($this->getCurrency())) {
201             throw new IPC_Exception('Invalid Currency');
202         }
203 
204         if ($this->getOrderID() == null || !Helper::isValidOrderId($this->getOrderID())) {
205             throw new IPC_Exception('Invalid OrderId');
206         }
207 
208         if ($this->getOutputFormat() == null || !Helper::isValidOutputFormat($this->getOutputFormat())) {
209             throw new IPC_Exception('Invalid Output format');
210         }
211 
212         return true;
213     }
214 }
API documentation generated by ApiGen