MandateManagement Class

The MandateManagement class allows you to manage recurring payment mandates between a merchant and a customer. It processes the IPC method IPCMandateManagement, supporting both registration and cancellation of mandates tied to a customer’s myPOS wallet.

A mandate is a recurring billing agreement where the customer authorizes the merchant to initiate future payments on their behalf.

Class Info

  • Namespace: Mypos\IPC
  • Located at: MandateManagement.php
  • Extends: Mypos\IPC\Base
  • Purpose: Register or cancel a recurring billing mandate using the customer’s myPOS wallet.

Method Summary

MethodReturn TypeDescription
__construct(Mypos\IPC\Config $cnf)-Initializes the class using your configuration object.
setCustomerWalletNumber(string $wallet)voidSets the wallet number of the customer (debtor).
getCustomerWalletNumber()stringGets the customer's wallet number.
setAction(int $action)voidSets the action: register or cancel a mandate.
getAction()intGets the current action type.
setMandateText(string $text)voidSets a descriptive text to identify the mandate.
getMandateText()stringGets the mandate’s display text.
setMandateReference(string $ref)voidSets a unique identifier (max 127 chars) for the mandate.
getMandateReference()stringGets the mandate reference ID.
validate()boolValidates all required mandate fields.
process()Mypos\IPC\ResponseExecutes the API request and returns a response.

Mandate Action Constants

ConstantValueDescription
MANDATE_MANAGEMENT_ACTION_REGISTER1Register a new mandate.
MANDATE_MANAGEMENT_ACTION_CANCEL2Cancel an existing mandate.

Inherited from Base

Also inherits low-level methods like:

  • _addPostParam()
  • _processPost(), _processHtmlPost()
  • getCnf(), setCnf()
  • getOutputFormat(), setOutputFormat()
  • isValidSignature()

Example Usage

<?php
namespace Mypos\IPC;
/**
 * Process IPC method: IPCMandateManagement.
 * Collect, validate and send API params
 */
class MandateManagement extends Base
{
    const MANDATE_MANAGEMENT_ACTION_REGISTER = 1;
    const MANDATE_MANAGEMENT_ACTION_CANCEL = 2;
    private $mandateReference, $customerWalletNumber, $action, $mandateText;
    /**
     * Return Refund object
     *
     * @param Config $cnf
     */
    public function __construct(Config $cnf)
    {
        $this->setCnf($cnf);
    }
    /**
     * Identifier of the client’s (debtor’s) myPOS account
     *
     * @param string $customerWalletNumber
     */
    public function setCustomerWalletNumber($customerWalletNumber)
    {
        $this->customerWalletNumber = $customerWalletNumber;
    }
    /**
     * Registration / Cancellation of a MandateReference
     *
     * @param int $action
     */
    public function setAction($action)
    {
        $this->action = $action;
    }
    /**
     * Text supplied from the merchant, so the client can easily identify the Mandate.
     *
     * @param string $mandateText
     */
    public function setMandateText($mandateText)
    {
        $this->mandateText = $mandateText;
    }
    /**
     * Initiate API request
     *
     * @return Response
     */
    public function process()
    {
        $this->validate();
        $this->_addPostParam('IPCmethod', 'IPCMandateManagement');
        $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('MandateReference', $this->getMandateReference());
        $this->_addPostParam('CustomerWalletNumber', $this->getCustomerWalletNumber());
        $this->_addPostParam('Action', $this->getAction());
        $this->_addPostParam('MandateText', $this->getMandateText());
        $this->_addPostParam('OutputFormat', $this->getOutputFormat());
        return $this->_processPost();
    }
    /**
     * Validate all set refund 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->getOutputFormat() == null || !Helper::isValidOutputFormat($this->getOutputFormat())) {
            throw new IPC_Exception('Invalid Output format');
        }
        return true;
    }
    /**
     * Unique identifier of the agreement (mandate) between the merchant and the client (debtor). Up to 127 characters.
     *
     * @return string
     */
    public function getMandateReference()
    {
        return $this->mandateReference;
    }
    /**
     * Unique identifier of the agreement (mandate) between the merchant and the client (debtor). Up to 127 characters.
     *
     * @param string $mandateReference
     */
    public function setMandateReference($mandateReference)
    {
        $this->mandateReference = $mandateReference;
    }
    /**
     * Identifier of the client’s (debtor’s) myPOS account
     *
     * @return string
     */
    public function getCustomerWalletNumber()
    {
        return $this->customerWalletNumber;
    }
    /**
     * Registration / Cancellation of a MandateReference
     *
     * @return int
     */
    public function getAction()
    {
        return $this->action;
    }
    /**
     * Text supplied from the merchant, so the client can easily identify the Mandate.
     *
     * @return string
     */
    public function getMandateText()
    {
        return $this->mandateText;
    }
}

Use Cases

Use the MandateManagement class when:

  • You want to set up a recurring billing agreement with a customer
  • You need to cancel an existing mandate for recurring charges
  • You're managing subscriptions, memberships, or installment payments