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 abstract class CardStore extends Base
 7 {
 8     const CARD_VERIFICATION_NO = 1;
 9     const CARD_VERIFICATION_YES = 2;
10 
11     private $currency = 'EUR', $amount, $cardVerification;
12 
13     /**
14      * Amount of the transaction
15      * Used in the request if CardVerification = CARD_VERIFICATION_YES.
16      * @return float
17      */
18     public function getAmount()
19     {
20         return $this->amount;
21     }
22 
23     /**
24      * Amount of the transaction.
25      * Used in the request if CardVerification = CARD_VERIFICATION_YES.
26      * @param float $amount
27      */
28     public function setAmount($amount)
29     {
30         $this->amount = $amount;
31     }
32 
33     /**
34      * ISO-4217 Three letter currency code
35      * Used in the request if CardVerification = CARD_VERIFICATION_YES.
36      * @param string $currency
37      * @return Purchase
38      */
39     public function setCurrency($currency)
40     {
41         $this->currency = $currency;
42         return $this;
43     }
44 
45     /**
46      * ISO-4217 Three letter currency code
47      * Used in the request if CardVerification = CARD_VERIFICATION_YES.
48      * @return string
49      */
50     public function getCurrency()
51     {
52         return $this->currency;
53     }
54 
55     /**
56      * Specify whether the inputted card data to be verified or not before storing
57      * @return int
58      */
59     public function getCardVerification()
60     {
61         return $this->cardVerification;
62     }
63 
64     /**
65      * Specify whether the inputted card data to be verified or not before storing
66      * @param int $cardVerification
67      */
68     public function setCardVerification($cardVerification)
69     {
70         $this->cardVerification = $cardVerification;
71     }
72 
73 
74     /**
75      * Validate all set purchase details
76      * @return boolean
77      * @throws IPC_Exception
78      */
79     public function validate()
80     {
81         if ($this->getCardVerification() == null || !in_array($this->getCardVerification(), [self::CARD_VERIFICATION_NO, self::CARD_VERIFICATION_YES])) {
82             throw new IPC_Exception('Invalid card verification');
83         }
84 
85         if ($this->getCardVerification() == self::CARD_VERIFICATION_YES) {
86             if ($this->getCurrency() === null || strpos(Defines::AVL_CURRENCIES, $this->getCurrency()) === false) {
87                 throw new IPC_Exception('Invalid currency');
88             }
89         }
90         return true;
91     }
92 
93 
94 }
API documentation generated by ApiGen