IAStoredCardUpdate Class
The IAStoredCardUpdate class is used to update an already stored card using the direct server-to-server method IPCIAStoreCard. It supports updating the card details (like expiry or CVC) associated with a stored card token.
This is a non-redirect flow. Your server must be PCI-compliant to handle raw card data securely.
Class Info
- Namespace:
Mypos\IPC - Located at:
IAStoredCardUpdate.php - Extends:
CardStoreBase
- Purpose: Update a stored card using a secure backend request.
Method Summary
| Method | Return Type | Description |
|---|---|---|
__construct(Mypos\IPC\Config $cnf) | - | Initializes the update object with a configuration instance. |
process() | Mypos\IPC\Response | Sends the API request and returns the response. |
validate() | bool | Validates that all necessary parameters are set. |
getCard() | Mypos\IPC\Card | Returns the Card object containing the updated data. |
setCard(Mypos\IPC\Card $card) | void | Sets the new card details (token must be present). |
Inherited from CardStore
| Method | Description |
|---|---|
setCurrency(string $currency) | Set currency used during optional verification. |
setAmount(float $amount) | Set verification amount (optional). |
setCardVerification(int $flag) | Enable or disable card verification. |
getCurrency() | Get the currently set currency. |
getAmount() | Get the currently set verification amount. |
getCardVerification() | Get the current card verification flag. |
Constants:
CARD_VERIFICATION_NO = 1CARD_VERIFICATION_YES = 2
Inherited from Base
You also gain access to:
_addPostParam()_processPost()_processHtmlPost()getCnf(), setCnf()getOutputFormat(), setOutputFormat()isValidSignature()
Example Usage
<?php
namespace Mypos\IPC;
/**
* Process IPC method: IPCIAStoreCard.
* Collect, validate and send API params
*/
class IAStoredCardUpdate extends CardStore
{
/**
* @var Card
*/
private $card;
/**
* Return purchase object
*
* @param Config $cnf
*/
public function __construct(Config $cnf)
{
$this->setCnf($cnf);
}
/**
* Initiate API request
*
* @return Response
*/
public function process()
{
$this->validate();
$this->_addPostParam('IPCmethod', 'IPCIAStoredCardUpdate');
$this->_addPostParam('IPCVersion', $this->getCnf()->getVersion());
$this->_addPostParam('IPCLanguage', $this->getCnf()->getLang());
$this->_addPostParam('SID', $this->getCnf()->getSid());
$this->_addPostParam('WalletNumber', $this->getCnf()->getWallet());
$this->_addPostParam('KeyIndex', $this->getCnf()->getKeyIndex());
$this->_addPostParam('Source', $this->getCnf()->getSource());
$this->_addPostParam('CardVerification', $this->getCardVerification());
if ($this->getCardVerification() == self::CARD_VERIFICATION_YES) {
$this->_addPostParam('Amount', $this->getAmount());
$this->_addPostParam('Currency', $this->getCurrency());
}
$this->_addPostParam('CardType', $this->getCard()->getCardType());
$this->_addPostParam('CardToken', $this->getCard()->getCardToken());
$this->_addPostParam('CardholderName', $this->getCard()->getCardHolder());
$this->_addPostParam('ExpDate', $this->getCard()->getExpDate(), true);
$this->_addPostParam('CVC', $this->getCard()->getCvc(), true);
$this->_addPostParam('ECI', $this->getCard()->getEci());
$this->_addPostParam('AVV', $this->getCard()->getAvv());
$this->_addPostParam('XID', $this->getCard()->getXid());
$this->_addPostParam('OutputFormat', $this->getOutputFormat());
return $this->_processPost();
}
/**
* Validate all set purchase details
*
* @return boolean
* @throws IPC_Exception
*/
public function validate()
{
parent::validate();
try {
$this->getCnf()->validate();
} catch (\Exception $ex) {
throw new IPC_Exception('Invalid Config details: '.$ex->getMessage());
}
try {
$this->getCard()->validate();
} catch (\Exception $ex) {
throw new IPC_Exception('Invalid Card details: '.$ex->getMessage());
}
return true;
}
/**
* Card object
*
* @return Card
*/
public function getCard()
{
return $this->card;
}
/**
* Card object
*
* @param Card $card
*/
public function setCard($card)
{
$this->card = $card;
}
}
Use Cases
Use the IAStoredCardUpdate class when:
- You need to refresh an expiring card (e.g., new expiry or CVC)
- You want to re-verify a card that has already been stored
- You are building a card update UI in a PCI-compliant backend system