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: IPCReversal.
 7  * Collect, validate and send API params
 8  */
 9 class Reversal extends Base
10 {
11     private $trnref;
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      * Transaction reference - transaction unique identifier
24      * @param string $trnref
25      * @return Reversal
26      */
27     public function setTrnref($trnref)
28     {
29         $this->trnref = $trnref;
30         return $this;
31     }
32 
33     /**
34      * Transaction reference - transaction unique identifier
35      * @return string
36      */
37     public function getTrnref()
38     {
39         return $this->trnref;
40     }
41 
42     /**
43      * Initiate API request
44      * @return Response
45      */
46     public function process()
47     {
48         $this->validate();
49 
50         $this->_addPostParam('IPCmethod', 'IPCReversal');
51         $this->_addPostParam('IPCVersion', $this->getCnf()->getVersion());
52         $this->_addPostParam('IPCLanguage', $this->getCnf()->getLang());
53         $this->_addPostParam('SID', $this->getCnf()->getSid());
54         $this->_addPostParam('WalletNumber', $this->getCnf()->getWallet());
55         $this->_addPostParam('KeyIndex', $this->getCnf()->getKeyIndex());
56         $this->_addPostParam('Source', Defines::SOURCE_PARAM);
57         $this->_addPostParam('IPC_Trnref', $this->getTrnref());
58         $this->_addPostParam('OutputFormat', $this->getOutputFormat());
59 
60         return $this->_processPost();
61     }
62 
63     /**
64      * Validate all set refund details
65      * @return boolean
66      * @throws IPC_Exception
67      */
68     public function validate()
69     {
70         try {
71             $this->getCnf()->validate();
72         } catch (\Exception $ex) {
73             throw new IPC_Exception('Invalid Config details: ' . $ex->getMessage());
74         }
75 
76         if ($this->getTrnref() == null || !Helper::isValidTrnRef($this->getTrnref())) {
77             throw new IPC_Exception('Invalid TrnRef');
78         }
79 
80         if ($this->getOutputFormat() == null || !Helper::isValidOutputFormat($this->getOutputFormat())) {
81             throw new IPC_Exception('Invalid Output format');
82         }
83 
84         return true;
85     }
86 }
API documentation generated by ApiGen