Process IPC method: GetPaymentStatus. Collect, validate and send API params

Mypos\IPC\Base
Extended byMypos\IPC\GetPaymentStatus
Namespace: Mypos\IPC
Located at GetPaymentStatus.php 

Methods summary

public
public Mypos\IPC\Response
#process( )

Initiate API request

public boolean
#validate( )

Validate all set details

public string
#getOrderID( )

Original request order id

public Mypos\IPC\GetPaymentStatus
#setOrderID( string $orderID )

Original request order id

Properties summary

Properties inherited from Mypos\IPC\Base

$outputFormat

 

Example

<?php
namespace Mypos\IPC;
/**
 * Process IPC method: GetPaymentStatus.
 * Collect, validate and send API params
 */
class GetPaymentStatus extends Base
{
    private $orderID;
    public function __construct(Config $cnf)
    {
        $this->setCnf($cnf);
    }
    /**
     * Initiate API request
     *
     * @return Response
     */
    public function process()
    {
        $this->validate();
        $this->_addPostParam('IPCmethod', 'GetPaymentStatus');
        $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('OrderID', $this->getOrderID());
        $this->_addPostParam('OutputFormat', $this->getOutputFormat());
        return $this->_processPost();
    }
    /**
     * Validate all set details
     *
     * @return boolean
     * @throws IPC_Exception
     */
    public function validate()
    {
        try {
            $this->getCnf()->validate();
        } catch (\Exception $ex) {
            throw new IPC_Exception('Invalid Config details: '.$ex->getMessage());
        }
        if ($this->getOrderID() == null || !Helper::isValidOrderId($this->getOrderID())) {
            throw new IPC_Exception('Invalid OrderId');
        }
        if ($this->getOutputFormat() == null || !Helper::isValidOutputFormat($this->getOutputFormat())) {
            throw new IPC_Exception('Invalid Output format');
        }
        return true;
    }
    /**
     * Original request order id
     *
     * @return string
     */
    public function getOrderID()
    {
        return $this->orderID;
    }
    /**
     * Original request order id
     *
     * @param string $orderID
     *
     * @return GetPaymentStatus
     */
    public function setOrderID($orderID)
    {
        $this->orderID = $orderID;
        return $this;
    }
}