コード例 #1
0
 /**
  * {@inheritDoc}
  * @see \Omnipay\Common\Message\MessageInterface::getData()
  * @throws \Omnipay\Common\Exception\InvalidRequestException - when the credit card information is missing
  * @throws \Omnipay\Common\Exception\InvalidCreditCardException - when the credit card information is invalid
  */
 public function getData()
 {
     //Checks if a card parameter is provided.
     //May throw \Omnipay\Common\Exception\InvalidRequestException
     $this->validate('card');
     // @codeCoverageIgnoreStart
     //Omnipay already makes sure that the card is either NULL or a valid \Omnipay\Common\CreditCard object.
     //This is just an extra defensive check.
     if (!$this->getCard() instanceof \Omnipay\Common\CreditCard) {
         throw new \Omnipay\Common\Exception\InvalidRequestException('Invalid credit card object.');
     }
     // @codeCoverageIgnoreEnd
     if (!$this->getTestMode()) {
         //May throw \Omnipay\Common\Exception\InvalidCreditCardException
         $this->getCard()->validate();
     }
     $data = array();
     $data['paymtCode'] = 'C20';
     $data['fncCode'] = '01';
     $data['cduserID'] = $this->generatedCardReference;
     $data = array_merge($data, \Omnipay\Econtext\Util\Helper::cardToApiParameters($this->getCard()));
     return $data;
 }
コード例 #2
0
 /**
  * {@inheritDoc}
  * @see \Omnipay\Common\Message\MessageInterface::getData()
  * @throws \Omnipay\Common\Exception\InvalidRequestException - when either the cardReference or card parameter is missing
  */
 public function getData()
 {
     $this->validate('amount');
     $this->validate('transactionReference');
     $data = array();
     $data['paymtCode'] = 'C20';
     $data['orderID'] = $this->getTransactionReference();
     $data['ordAmount'] = $this->getParameter('amount');
     $data['ordAmountTax'] = $this->getParameter('amountTax') ?: 0;
     $data['itemName'] = $this->getDescription();
     if ($this->getCardReference()) {
         //Purchase using an already server-persisted card
         $data['fncCode'] = '10';
         $data['cduserID'] = $this->getCardReference();
         return $data;
     }
     if ($this->getCard() instanceof \Omnipay\Common\CreditCard) {
         //Purchase using an as-of-yet non-server-persisted card
         //Effectively, behind the scenes, the server will persist the card (whose `cardReference` we have prepared)
         //and would also execute the purchase.
         $data['fncCode'] = '22';
         //This is equivalent to code 01 (CreateCardMerchantRequest) + 10 (charge existing card, like above)
         $data['cduserID'] = $this->getGeneratedCardReference();
         $data = array_merge($data, \Omnipay\Econtext\Util\Helper::cardToApiParameters($this->getCard()));
         //No idea why this is a required argument in this case and not for fncCode=10 (CreateCardMerchantRequest).
         $data['cd3secFlg'] = 0;
         return $data;
     }
     throw new \Omnipay\Common\Exception\InvalidRequestException('A `cardReference` or a `card` key needs to be provided.');
 }