private function _buildTransaction($action, HpsCheck $check, $amount, $clientTransactionId = null)
 {
     $amount = HpsInputValidation::checkAmount($amount);
     if ($check->secCode == HpsSECCode::CCD && ($check->checkHolder == null || $check->checkHolder->checkName == null)) {
         throw new HpsInvalidRequestException(HpsExceptionCodes::MISSING_CHECK_NAME, 'For SEC code CCD, the check name is required', 'check_name');
     }
     $xml = new DOMDocument();
     $hpsTransaction = $xml->createElement('hps:Transaction');
     $hpsCheckSale = $xml->createElement('hps:CheckSale');
     $hpsBlock1 = $xml->createElement('hps:Block1');
     $hpsBlock1->appendChild($xml->createElement('hps:Amt', sprintf("%0.2f", round($amount, 3))));
     $hpsBlock1->appendChild($this->_hydrateCheckData($check, $xml));
     $hpsBlock1->appendChild($xml->createElement('hps:CheckAction', $action));
     $hpsBlock1->appendChild($xml->createElement('hps:SECCode', $check->secCode));
     if ($check->checkType != null) {
         $hpsBlock1->appendChild($xml->createElement('hps:CheckType', $check->checkType));
     }
     $hpsBlock1->appendChild($xml->createElement('hps:DataEntryMode', $check->dataEntryMode));
     if ($check->checkHolder != null) {
         $hpsBlock1->appendChild($this->_hydrateConsumerInfo($check, $xml));
     }
     $hpsCheckSale->appendChild($hpsBlock1);
     $hpsTransaction->appendChild($hpsCheckSale);
     return $this->_submitTransaction($hpsTransaction, 'CheckSale', $clientTransactionId);
 }
 /**
  * Creates a sale transaction through the HpsCheckService
  */
 public function execute()
 {
     parent::execute();
     HpsInputValidation::checkAmount($this->amount);
     $xml = new DOMDocument();
     $hpsTransaction = $xml->createElement('hps:Transaction');
     $hpsCheckSale = $xml->createElement('hps:CheckSale');
     $hpsBlock1 = $xml->createElement('hps:Block1');
     $hpsBlock1->appendChild($xml->createElement('hps:Amt', sprintf("%0.2f", round($this->amount, 3))));
     $hpsBlock1->appendChild($xml->createElement('hps:CheckAction', 'SALE'));
     $hpsBlock1->appendChild($xml->createElement('hps:PaymentMethodKey', $this->paymentMethodKey));
     $recurringData = $xml->createElement('hps:RecurringData');
     if ($this->schedule != null) {
         $scheduleKey = $this->schedule;
         if ($this->schedule instanceof HpsPayPlanSchedule) {
             $scheduleKey = $this->schedule->scheduleKey;
         }
         $recurringData->appendChild($xml->createElement('hps:ScheduleID', $scheduleKey));
     }
     $recurringData->appendChild($xml->createElement('hps:OneTime', $this->oneTime ? 'Y' : 'N'));
     $hpsBlock1->appendChild($recurringData);
     $hpsCheckSale->appendChild($hpsBlock1);
     $hpsTransaction->appendChild($hpsCheckSale);
     return $this->_submitTransaction($hpsTransaction, 'CheckSale', $clientTransactionId);
 }
 /**
  * Creates a reverse transaction through the HpsCreditService
  */
 public function execute()
 {
     parent::execute();
     HpsInputValidation::checkCurrency($this->currency);
     HpsInputValidation::checkAmount($this->amount);
     $xml = new DOMDocument();
     $hpsTransaction = $xml->createElement('hps:Transaction');
     $hpsCreditReversal = $xml->createElement('hps:CreditReversal');
     $hpsBlock1 = $xml->createElement('hps:Block1');
     $hpsBlock1->appendChild($xml->createElement('hps:Amt', $this->amount));
     if ($this->authAmount != null) {
         $hpsBlock1->appendChild($xml->createElement('hps:AuthAmt', $this->authAmount));
     }
     if ($this->card != null) {
         $cardData = $xml->createElement('hps:CardData');
         $cardData->appendChild($this->service->_hydrateManualEntry($this->card, $xml));
         $hpsBlock1->appendChild($cardData);
     } else {
         if ($this->token != null) {
             $cardData = $xml->createElement('hps:CardData');
             $cardData->appendChild($this->service->_hydrateTokenData($this->token, $xml));
             $hpsBlock1->appendChild($cardData);
         } else {
             $hpsBlock1->appendChild($xml->createElement('hps:GatewayTxnId', $this->transactionId));
         }
     }
     if ($this->details != null) {
         $hpsBlock1->appendChild($this->service->_hydrateAdditionalTxnFields($this->details, $xml));
     }
     $hpsCreditReversal->appendChild($hpsBlock1);
     $hpsTransaction->appendChild($hpsCreditReversal);
     return $this->service->_submitTransaction($hpsTransaction, 'CreditReversal', isset($this->details->clientTransactionId) ? $this->details->clientTransationId : null);
 }
 /**
  * Creates a recurring billing transaction through the HpsCreditService
  */
 public function execute()
 {
     parent::execute();
     HpsInputValidation::checkAmount($this->amount);
     $xml = new DOMDocument();
     $hpsTransaction = $xml->createElement('hps:Transaction');
     $hpsRecurringBilling = $xml->createElement('hps:RecurringBilling');
     $hpsBlock1 = $xml->createElement('hps:Block1');
     $hpsBlock1->appendChild($xml->createElement('hps:AllowDup', 'Y'));
     $hpsBlock1->appendChild($xml->createElement('hps:Amt', $this->amount));
     if ($this->cardHolder != null) {
         $hpsBlock1->appendChild($this->_hydrateCardHolderData($this->cardHolder, $xml));
     }
     if ($this->details != null) {
         $hpsBlock1->appendChild($this->_hydrateAdditionalTxnFields($this->details, $xml));
     }
     if ($this->card != null) {
         $cardData = $xml->createElement('hps:CardData');
         $cardData->appendChild($this->_hydrateManualEntry($this->card, $xml));
         $hpsBlock1->appendChild($cardData);
     } else {
         if ($this->token != null) {
             $cardData = $xml->createElement('hps:CardData');
             $tokenData = $xml->createElement('hps:TokenData');
             $tokenData->appendChild($xml->createElement('hps:TokenValue', $this->token->tokenValue));
             $cardData->appendChild($tokenData);
             $hpsBlock1->appendChild($cardData);
         } else {
             if ($this->paymentMethodKey != null) {
                 $hpsBlock1->appendChild($xml->createElement('hps:PaymentMethodKey', $this->paymentMethodKey));
             }
         }
     }
     $recurringData = $xml->createElement('hps:RecurringData');
     if ($this->schedule != null) {
         $id = $this->schedule;
         if ($this->schedule instanceof HpsPayPlanSchedule) {
             $id = $this->schedule->scheduleIdentifier;
         }
         $recurringData->appendChild($xml->createElement('hps:ScheduleID', $id));
     }
     $recurringData->appendChild($xml->createElement('hps:OneTime', $this->oneTime ? 'Y' : 'N'));
     $hpsBlock1->appendChild($recurringData);
     $hpsRecurringBilling->appendChild($hpsBlock1);
     $hpsTransaction->appendChild($hpsRecurringBilling);
     return $this->service->_submitTransaction($hpsTransaction, 'RecurringBilling', isset($this->details->clientTransactionId) ? $this->details->clientTransactionId : null);
 }
 /**
  * Creates a listTransactions transaction through the HpsCreditService
  */
 public function execute()
 {
     parent::execute();
     date_default_timezone_set("UTC");
     $dateFormat = 'Y-m-d\\TH:i:s.00\\Z';
     $current = new DateTime();
     $currentTime = $current->format($dateFormat);
     HpsInputValidation::checkDateNotFuture($this->startDate);
     HpsInputValidation::checkDateNotFuture($this->endDate);
     $xml = new DOMDocument();
     $hpsTransaction = $xml->createElement('hps:Transaction');
     $hpsReportActivity = $xml->createElement('hps:ReportActivity');
     $hpsReportActivity->appendChild($xml->createElement('hps:RptStartUtcDT', $this->startDate));
     $hpsReportActivity->appendChild($xml->createElement('hps:RptEndUtcDT', $this->endDate));
     $hpsTransaction->appendChild($hpsReportActivity);
     return $this->service->_submitTransaction($hpsTransaction, 'ReportActivity');
 }
 /**
  * Creates a sale transaction through the HpsGiftCardService
  */
 public function execute()
 {
     parent::execute();
     HpsInputValidation::checkAmount($this->amount);
     $this->currency = strtolower($this->currency);
     $xml = new DOMDocument();
     $hpsTransaction = $xml->createElement('hps:Transaction');
     $hpsGiftSale = $xml->createElement('hps:GiftCardSale');
     $hpsBlock1 = $xml->createElement('hps:Block1');
     $hpsBlock1->appendChild($xml->createElement('hps:Amt', $this->amount));
     $hpsBlock1->appendChild($this->service->_hydrateGiftCardData($this->card, $xml));
     if (in_array($this->currency, array('points', 'usd'))) {
         $hpsBlock1->appendChild($xml->createElement('hps:Currency', strtoupper($this->currency)));
     }
     if ($this->gratuity != null) {
         $hpsBlock1->appendChild($xml->createElement('hps:GratuityAmtInfo', $this->gratuity));
     }
     if ($this->tax != null) {
         $hpsBlock1->appendChild($xml->createElement('hps:TaxAmtInfo', $this->tax));
     }
     $hpsGiftSale->appendChild($hpsBlock1);
     $hpsTransaction->appendChild($hpsGiftSale);
     return $this->service->_submitTransaction($hpsTransaction, 'GiftCardSale');
 }
 public function sale($giftCard, $amount, $currency = 'usd', $gratuity = null, $tax = null)
 {
     $txnType = 'GiftCardSale';
     HpsInputValidation::checkCurrency($currency);
     $amount = HpsInputValidation::checkAmount($amount);
     $xml = new DOMDocument();
     $hpsTransaction = $xml->createElement('hps:Transaction');
     $hpsGiftCard = $xml->createElement('hps:' . $txnType);
     $hpsBlock1 = $xml->createElement('hps:Block1');
     $hpsBlock1->appendChild($xml->createElement('hps:Amt', $amount));
     $hpsBlock1->appendChild($this->_hydrateGiftCardData($giftCard, $xml));
     if (strtolower($currency) == 'usd' || $currency == 'points') {
         $hpsBlock1->appendChild($xml->createElement('hps:Currency', strtolower($currency) == 'usd' ? 'USD' : 'POINTS'));
     }
     if ($gratuity != null) {
         $hpsBlock1->appendChild($xml->createElement('hps:GratuityAmtInfo', $gratuity));
     }
     if ($tax != null) {
         $hpsBlock1->appendChild($xml->createElement('hps:TaxAmtInfo', $tax));
     }
     $hpsGiftCard->appendChild($hpsBlock1);
     $hpsTransaction->appendChild($hpsGiftCard);
     return $this->_submitTransaction($hpsTransaction, $txnType);
 }
Exemplo n.º 8
0
 /**
  * A Debit Charge transaction performs a sale purchased with a Debit Card. The Debit Charge is placed
  * in the current open batch. If a batch is not open, this transaction creates an open batch.
  *
  * @param double                $amount              Authorization amount.
  * @param string                $currency            Currency ("usd")
  * @param string                $trackData           Track data read from the card by the card reader.
  * @param string                $pinBlock            PIN block.
  * @param HpsEncryptionData     $encryptionData      E3 encryption data group.
  * @param bool                  $allowDuplicates     Indicates whether to allow duplicate transactions.
  * @param double                $cashBackAmount      Contains the portion of the amount that is cash back.
  * @param bool                  $allowPartialAuth    Indicate whether to allow partial authorization.
  * @param HpsCardHolder         $cardHolder          Card holder information.
  * @param HpsTransactionDetails $details             Group containing additional transaction fields to be included in detail reporting.
  * @param string                $clientTransactionId Optional client transaction ID.
  *
  * @return HpsDebit The Debit Charge result.
  */
 public function charge($amount, $currency, $trackData, $pinBlock, HpsEncryptionData $encryptionData = null, $allowDuplicates = false, $cashBackAmount = null, $allowPartialAuth = false, HpsCardHolder $cardHolder = null, HpsTransactionDetails $details = null, $clientTransactionId = null)
 {
     HpsInputValidation::checkAmount($amount);
     HpsInputValidation::checkCurrency($currency);
     $xml = new DOMDocument();
     $hpsTransaction = $xml->createElement('hps:Transaction');
     $hpsGiftCard = $xml->createElement('hps:DebitSale');
     $hpsBlock1 = $xml->createElement('hps:Block1');
     $hpsBlock1->appendChild($xml->createElement('hps:TrackData', $trackData));
     $hpsBlock1->appendChild($xml->createElement('hps:AllowDup', $allowDuplicates ? 'Y' : 'N'));
     if ($cardHolder != null) {
         $hpsBlock1->appendChild($this->_hydrateCardHolderData($cardHolder, $xml));
     }
     $hpsBlock1->appendChild($xml->createElement('hps:Amt', $amount));
     $hpsBlock1->appendChild($xml->createElement('hps:CashbackAmtInfo', isset($cashBackAmount) ? $cashBackAmount : 0));
     $hpsBlock1->appendChild($xml->createElement('hps:AllowPartialAuth', $allowPartialAuth ? 'Y' : 'N'));
     $hpsBlock1->appendChild($xml->createElement('hps:PinBlock', $pinBlock));
     if ($encryptionData != null) {
         $hpsBlock1->appendChild($this->_hydrateEncryptionData($encryptionData, $xml));
     }
     if ($details != null) {
         $hpsBlock1->appendChild($this->_hydrateAdditionalTxnFields($details, $xml));
     }
     $hpsGiftCard->appendChild($hpsBlock1);
     $hpsTransaction->appendChild($hpsGiftCard);
     return $this->_submitTransaction($hpsTransaction, 'DebitSale', $clientTransactionId);
 }
 /**
  * Creates an authorization transaction through the HpsCreditService
  */
 public function execute()
 {
     parent::execute();
     HpsInputValidation::checkCurrency($this->currency);
     HpsInputValidation::checkAmount($this->amount);
     $xml = new DOMDocument();
     $hpsTransaction = $xml->createElement('hps:Transaction');
     $hpsCreditAuth = $xml->createElement('hps:CreditAuth');
     $hpsBlock1 = $xml->createElement('hps:Block1');
     $hpsBlock1->appendChild($xml->createElement('hps:AllowDup', $this->allowDuplicates ? 'Y' : 'N'));
     $hpsBlock1->appendChild($xml->createElement('hps:AllowPartialAuth', $this->allowPartialAuth ? 'Y' : 'N'));
     $hpsBlock1->appendChild($xml->createElement('hps:Amt', $this->amount));
     if ($this->gratuity != null) {
         $hpsBlock1->appendChild($xml->createElement('hps:GratuityAmtInfo', $this->gratuity));
     }
     if ($this->cardHolder != null) {
         $hpsBlock1->appendChild($this->service->_hydrateCardHolderData($this->cardHolder, $xml));
     }
     $cardData = $xml->createElement('hps:CardData');
     if ($this->card != null) {
         $cardData->appendChild($this->service->_hydrateManualEntry($this->card, $xml, $this->cardPresent, $this->readerPresent));
         if ($this->card->encryptionData != null) {
             $cardData->appendChild($this->service->_hydrateEncryptionData($this->card->encryptionData, $xml));
         }
     } else {
         if ($this->token != null) {
             $cardData->appendChild($this->service->_hydrateTokenData($this->token, $xml, $this->cardPresent, $this->readerPresent));
         } else {
             if ($this->trackData != null) {
                 $cardData->appendChild($this->service->_hydrateTrackData($this->trackData, $xml));
                 if ($this->trackData->encryptionData != null) {
                     $cardData->appendChild($this->service->_hydrateEncryptionData($this->trackData->encryptionData, $xml));
                 }
             } else {
                 if ($this->paymentData != null) {
                     $manualEntry = $xml->createElement('hps:ManualEntry');
                     $manualEntry->appendChild($xml->createElement('hps:CardNbr', $this->paymentData->applicationPrimaryAccountNumber));
                     $expDate = (string) $this->paymentData->applicationExpirationDate;
                     $manualEntry->appendChild($xml->createElement('hps:ExpMonth', substr($expDate, 2, 2)));
                     $manualEntry->appendChild($xml->createElement('hps:ExpYear', '20' . substr($expDate, 0, 2)));
                     $cardData->appendChild($manualEntry);
                 }
             }
         }
     }
     $cardData->appendChild($xml->createElement('hps:TokenRequest', $this->requestMultiUseToken ? 'Y' : 'N'));
     $hpsBlock1->appendChild($cardData);
     if ($this->paymentData != null) {
         $hpsBlock1->appendChild($this->service->_hydrateSecureEcommerce($this->paymentData->paymentData, $xml));
     }
     if ($this->cpcReq == true) {
         $hpsBlock1->appendChild($xml->createElement('hps:CPCReq', 'Y'));
     }
     if ($this->details != null) {
         $hpsBlock1->appendChild($this->service->_hydrateAdditionalTxnFields($this->details, $xml));
     }
     if ($this->txnDescriptor != null) {
         $hpsBlock1->appendChild($xml->createElement('hps:TxnDescriptor', $this->txnDescriptor));
     }
     if ($this->autoSubstantiation != null) {
         $hpsBlock1->appendChild($this->service->_hydrateAutoSubstantiation($this->autoSubstantiation, $xml));
     }
     if ($this->originalTxnReferenceData != null) {
         $refElement = $xml->createElement('hps:OrigTxnRefData');
         $refElement->appendChild($xml->createElement('hps:AuthCode', $this->originalTxnReferenceData->authorizationCode));
         $refElement->appendChild($xml->createElement('hps:CardNbrLastFour', $this->originalTxnReferenceData->cardNumberLast4));
         $hpsBlock1->appendChild($refElement);
     }
     $hpsCreditAuth->appendChild($hpsBlock1);
     $hpsTransaction->appendChild($hpsCreditAuth);
     return $this->service->_submitTransaction($hpsTransaction, 'CreditAuth', isset($this->details->clientTransactionId) ? $this->details->clientTransactionId : null);
 }
 public function reverse($cardData, $amount, $currency, $details = null)
 {
     HpsInputValidation::checkCurrency($currency);
     $this->_currency = $currency;
     $this->_amount = HpsInputValidation::checkAmount($amount);
     $xml = new DOMDocument();
     $hpsTransaction = $xml->createElement('hps:Transaction');
     $hpsCreditReversal = $xml->createElement('hps:CreditReversal');
     $hpsBlock1 = $xml->createElement('hps:Block1');
     $hpsBlock1->appendChild($xml->createElement('hps:Amt', $amount));
     if ($details != null) {
         $hpsBlock1->appendChild($this->_hydrateAdditionalTxnFields($details, $xml));
     }
     if ($cardData instanceof HpsCreditCard) {
         $cardDataElement = $xml->createElement('hps:CardData');
         $cardDataElement->appendChild($this->_hydrateManualEntry($cardData, $xml));
         $hpsBlock1->appendChild($cardDataElement);
     } else {
         if ($cardData instanceof HpsTokenData) {
             $cardDataElement = $xml->createElement('hps:CardData');
             $tokenData = $xml->createElement('hps:TokenData');
             $tokenData->appendChild($xml->createElement('hps:TokenValue', $cardData->tokenValue));
             $cardDataElement->appendChild($tokenData);
             $hpsBlock1->appendChild($cardDataElement);
         } else {
             $hpsBlock1->appendChild($xml->createElement('hps:GatewayTxnId', $cardData));
         }
     }
     if ($details != null) {
         $hpsBlock1->appendChild($this->_hydrateAdditionalTxnFields($details, $xml));
     }
     $hpsCreditReversal->appendChild($hpsBlock1);
     $hpsTransaction->appendChild($hpsCreditReversal);
     return $this->_submitTransaction($hpsTransaction, 'CreditReversal', isset($details->clientTxnId) ? $details->clientTxnId : null);
 }
Exemplo n.º 11
0
 private function _buildTransaction($action, HpsCheck $check, $amount, $clientTransactionId = null)
 {
     $amount = HpsInputValidation::checkAmount($amount);
     if ($check->secCode == 'CCD' && ($check->checkHolder == null || $check->checkHolder->checkName == null)) {
         throw new HpsInvalidRequestException(HpsExceptionCodes::MissingCheckName, "For sec code CCD the Check name is required.", "check_name");
     }
     $xml = new DOMDocument();
     $hpsTransaction = $xml->createElement('hps:Transaction');
     $hpsCheckSale = $xml->createElement('hps:CheckSale');
     $hpsBlock1 = $xml->createElement('hps:Block1');
     $hpsBlock1->appendChild($xml->createElement('hps:Amt', $amount));
     $hpsBlock1->appendChild($this->_hydrateCheckData($check, $xml));
     $hpsBlock1->appendChild($xml->createElement('hps:CheckAction', $action));
     $hpsBlock1->appendChild($xml->createElement('hps:SECCode', $check->secCode));
     if ($check->checkType != null) {
         $hpsBlock1->appendChild($xml->createElement('hps:CheckType', $check->checkType));
     }
     $hpsBlock1->appendChild($xml->createElement('hps:DataEntryMode', $check->dataEntryMode));
     if ($check->checkHolder != null) {
         $hpsBlock1->appendChild($this->_hydrateConsumerInfo($check, $xml));
     }
     $hpsCheckSale->appendChild($hpsBlock1);
     $hpsTransaction->appendChild($hpsCheckSale);
     return $this->_submitTransaction($hpsTransaction, 'CheckSale', $clientTransactionId);
 }
Exemplo n.º 12
0
 public function sale($sessionId, $amount, $currency, HpsBuyerData $buyer = null, HpsPaymentData $payment = null, HpsShippingInfo $shippingAddress = null, $lineItems = null)
 {
     HpsInputValidation::checkAmount($amount);
     HpsInputValidation::checkCurrency($currency);
     $xml = new DOMDocument();
     $transaction = $xml->createElement('hps:Transaction');
     $sale = $xml->createElement('hps:AltPaymentSale');
     $sale->appendChild($xml->createElement('hps:TransactionType', $this->_transactionType));
     $sale->appendChild($xml->createElement('hps:SessionId', $sessionId));
     $sale->appendChild($this->hydrateBuyerData($buyer, $xml));
     $sale->appendChild($xml->createElement('hps:Amt', $amount));
     $sale->appendChild($this->hydratePaymentData($payment, $xml));
     if ($shippingAddress != null) {
         $sale->appendChild($this->hydrateShippingData($shippingAddress, $xml));
     }
     if ($lineItems != null) {
         $sale->appendChild($this->hydrateLineItems($lineItems, $xml));
     }
     $transaction->appendChild($sale);
     return $this->_submitTransaction($transaction, 'AltPaymentSale');
 }