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: IPCIAStoreCard.
  7  * Collect, validate and send API params
  8  */
  9 class IAStoreCard extends CardStore
 10 {
 11 
 12     const CARD_VERIFICATION_NO = 1;
 13     const CARD_VERIFICATION_YES = 2;
 14 
 15     /**
 16      * @var Card
 17      */
 18     private $card;
 19 
 20     /**
 21      * Return purchase object
 22      * @param Config $cnf
 23      */
 24     public function __construct(Config $cnf)
 25     {
 26         $this->setCnf($cnf);
 27     }
 28 
 29     /**
 30      * Card object
 31      * @return Card
 32      */
 33     public function getCard()
 34     {
 35         return $this->card;
 36     }
 37 
 38     /**
 39      * Card object
 40      * @param Card $card
 41      */
 42     public function setCard($card)
 43     {
 44         $this->card = $card;
 45     }
 46 
 47 
 48     /**
 49      * Initiate API request
 50      * @return Response
 51      */
 52     public function process()
 53     {
 54         $this->validate();
 55 
 56         $this->_addPostParam('IPCmethod', 'IPCIAStoreCard');
 57         $this->_addPostParam('IPCVersion', $this->getCnf()->getVersion());
 58         $this->_addPostParam('IPCLanguage', $this->getCnf()->getLang());
 59         $this->_addPostParam('SID', $this->getCnf()->getSid());
 60         $this->_addPostParam('WalletNumber', $this->getCnf()->getWallet());
 61         $this->_addPostParam('KeyIndex', $this->getCnf()->getKeyIndex());
 62         $this->_addPostParam('Source', Defines::SOURCE_PARAM);
 63 
 64         $this->_addPostParam('CardVerification', $this->getCardVerification());
 65         if ($this->getCardVerification() == self::CARD_VERIFICATION_YES) {
 66             $this->_addPostParam('Amount', $this->getAmount());
 67             $this->_addPostParam('Currency', $this->getCurrency());
 68         }
 69 
 70         $this->_addPostParam('CardType', $this->getCard()->getCardType());
 71         $this->_addPostParam('PAN', $this->getCard()->getCardNumber(), true);
 72         $this->_addPostParam('CardholderName', $this->getCard()->getCardHolder());
 73         $this->_addPostParam('ExpDate', $this->getCard()->getExpDate(), true);
 74         $this->_addPostParam('CVC', $this->getCard()->getCvc(), true);
 75         $this->_addPostParam('ECI', $this->getCard()->getEci());
 76         $this->_addPostParam('AVV', $this->getCard()->getAvv());
 77         $this->_addPostParam('XID', $this->getCard()->getXid());
 78 
 79         $this->_addPostParam('OutputFormat', $this->getOutputFormat());
 80         return $this->_processPost();
 81     }
 82 
 83     /**
 84      * Validate all set purchase details
 85      * @return boolean
 86      * @throws IPC_Exception
 87      */
 88     public function validate()
 89     {
 90         parent::validate();
 91         try {
 92             $this->getCnf()->validate();
 93         } catch (Exception $ex) {
 94             throw new IPC_Exception('Invalid Config details: ' . $ex->getMessage());
 95         }
 96 
 97         try {
 98             $this->getCard()->validate();
 99         } catch (Exception $ex) {
100             throw new IPC_Exception('Invalid Card details: ' . $ex->getMessage());
101         }
102         return true;
103     }
104 
105 }
106 
API documentation generated by ApiGen