public function setTransactionReference($value)
 {
     if (substr($value, 0, 1) === '{') {
         // Value is a complex key containing the transaction ID and other properties
         $transactionRef = new TransactionReference($value);
     } else {
         // Value just contains the transaction ID
         $transactionRef = new TransactionReference();
         $transactionRef->setTransId($value);
     }
     return $this->setParameter('transactionReference', $transactionRef);
 }
Example #2
0
 /**
  * A composite key containing the gateway provided transaction reference as well as other data points that may be
  * required for subsequent transactions that may need to modify this one.
  *
  * @param bool $serialize Determines whether a string or object is returned
  * @return TransactionReference|string
  */
 public function getTransactionReference($serialize = true)
 {
     $body = $this->data->transactionResponse[0];
     $transactionRef = new TransactionReference();
     $transactionRef->setApprovalCode((string) $body->authCode);
     $transactionRef->setTransId((string) $body->transId);
     try {
         // Need to store card details in the transaction reference since it is required when doing a refund
         if ($card = $this->request->getCard()) {
             $transactionRef->setCard(array('number' => $card->getNumberLastFour(), 'expiry' => $card->getExpiryDate('mY')));
         } elseif ($cardReference = $this->request->getCardReference()) {
             $transactionRef->setCardReference(new CardReference($cardReference));
         }
     } catch (\Exception $e) {
     }
     return $serialize ? (string) $transactionRef : $transactionRef;
 }