IAStoreCard Class

The IAStoreCard class handles server-to-server card storage via the IPC method IPCIAStoreCard. It allows securely storing a customer’s card directly from your backend, typically for later tokenized transactions.

This is a non-redirect flow that requires a PCI-compliant server since the card details are passed directly.

Class Info

  • Namespace: Mypos\IPC
  • Located at: IAStoreCard.php
  • Extends:
    • CardStore
    • Base
  • Purpose: Store a customer's card via API and optionally verify it using a small authorization.

Method Summary

MethodReturn TypeDescription
__construct(Mypos\IPC\Config $cnf)-Initializes the class with the provided configuration.
process()Mypos\IPC\ResponseSends the API request and returns the response.
validate()boolValidates all required fields before the request.
getCard()Mypos\IPC\CardRetrieves the attached Card object.
setCard(Card $card)voidAttaches a Card object to be stored.

Inherited from CardStore

These methods configure optional verification behavior:

  • setAmount(float $amount)
  • getAmount()
  • setCurrency(string $currency)
  • getCurrency()
  • setCardVerification(int $cardVerification)
  • getCardVerification()

Verification Options:

CardStore::CARD_VERIFICATION_NO  // 1 - Store without charge
CardStore::CARD_VERIFICATION_YES // 2 - Verify with a small transaction

Inherited from Base

You can also access these low-level utilities if needed:

  • _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 IAStoreCard extends CardStore
{
    const CARD_VERIFICATION_NO = 1;
    const CARD_VERIFICATION_YES = 2;
    /**
     * @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', 'IPCIAStoreCard');
        $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('PAN', $this->getCard()->getCardNumber(), true);
        $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 IAStoreCard class when:

  • You want to securely store a customer's card for later use (tokenization)
  • You want to verify the card before saving (optional)
  • You're building a PCI-compliant backend payment system
  • You don’t want to redirect the customer to myPOS checkout pages