sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
public function capture( $orderId, $amount, HpsOrderData $orderData = null ) { $payload = array( 'Amount' => $this->formatAmount($amount), 'CurrencyCode' => $this->currencyStringToNumeric( $orderData->currencyCode ), 'OrderId' => $orderId, 'OrderNumber' => $orderData->orderNumber, 'TransactionType' => 'WT', ); return $this->submitTransaction($payload, 'cmpi_capture'); }
Responsible for settling funds from previous authorization transaction. Payment for the complete or partial amount of the authorization is available. Multiple captures can be processed against a single Authorization up to 100% of the authorization. @param string $orderId order id from Cardinal @param mixed $amount amount to be authorized @param HpsOrderData $orderData Cardinal/MasterPass specific data @return object
entailment
public function createSession( $amount, $currency, HpsBuyerData $buyer = null, HpsPaymentData $payment = null, HpsShippingInfo $shippingAddress = null, $lineItems = null, HpsOrderData $orderData = null ) { $payload = array( 'TransactionType' => 'WT', 'OverridePaymentMethod' => 'MPPWLT', 'Amount' => $this->formatAmount($amount), 'CurrencyCode' => $this->currencyStringToNumeric($currency), 'OverrideCheckoutType' => $this->getCheckoutType($orderData), 'ConnectTimeout' => '10000', 'TransactionMode' => 'S', 'OrderNumber' => $orderData->orderNumber, 'IPAddress' => $orderData->ipAddress, 'BrowserHeader' => $orderData->browserHeader, 'UserAgent' => $orderData->userAgent, 'OriginUrl' => $orderData->originUrl, 'TermUrl' => $orderData->termUrl, ); if ($orderData->orderId !== null) { $payload['OrderId'] = $orderData->orderId; } if ($buyer !== null) { $payload = array_merge($payload, $this->hydrateBuyerData($buyer)); } if ($payment !== null) { $payload = array_merge($payload, $this->hydratePaymentData($payment)); } if ($shippingAddress !== null) { $payload = array_merge( $payload, $this->hydrateShippingInfo($shippingAddress) ); } if ($lineItems !== null) { $payload = array_merge($payload, $this->hydrateLineItems($lineItems)); } return $this->submitTransaction($payload, 'cmpi_lookup'); }
Responsible for initiating the MasterPass transaction. The Lookup Message is constructed and sent to the Centinel platform for processing. The Lookup Message requires transaction specific data elements to be formatted on the request message. Please refer to the Message API section for the complete list of required message elements. The Centinel platform will then redirect the consumer back to the TermUrl representing a web page on the merchant's website. At that point, the merchant will process the Authenticate message to retrieve the status from the MasterPass processing. @param mixed $amount amount to be authorized @param string $currency currency code @param HpsBuyerData $buyer buyer information @param HpsPaymentData $payment payment information @param HpsShippingInfo $shippingAddress shipping information @param array<int, HpsLineItem> $lineItems line items from order @param HpsOrderData $orderData Cardinal/MasterPass specific data @return object
entailment
public function preApproval( $longAccessToken, HpsOrderData $orderData = null ) { $payload = array( 'LongAccessToken' => $longAccessToken, 'SubMsgType' => 'cmpi_preapproval', 'TransactionType' => 'WT', ); return $this->submitTransaction($payload, 'cmpi_baseserver_api'); }
Gives Merchants the ability to provide the consumer the opportunity to pre-select their checkout options before completing checkout. @param string $longAccessToken Access token from Cardinal/MasterPass @param HpsOrderData $orderData Cardinal/MasterPass specific data @return object
entailment
public function refund( $orderId, $isPartial = false, $amount = null, HpsOrderData $orderData = null ) { $payload = array( 'Amount' => $this->formatAmount($amount), 'CurrencyCode' => $this->currencyStringToNumeric( $orderData->currencyCode ), 'OrderId' => $orderId, 'TransactionType' => 'WT', ); return $this->submitTransaction($payload, 'cmpi_refund'); }
Responsible for crediting the consumer some portion or all of the original settlement amount. Multiple refunds can be processed against the original capture transaction. @param string $orderId order id from Cardinal @param boolean $isPartial flag for partial refund @param string $amount amount to be refunded @param HpsOrderData $orderData Cardinal/MasterPass specific data @return object
entailment
public function sale( $orderId, $amount, $currency, HpsBuyerData $buyer = null, HpsPaymentData $payment = null, HpsShippingInfo $shippingAddress = null, $lineItems = null, HpsOrderData $orderData = null ) { $authorization = $this->authorize( $orderId, $amount, $currency, $buyer, $payment, $shippingAddress, $lineItems, $orderData ); if (null === $orderData) { $orderData = new HpsOrderData(); } $orderData->currencyCode = $currency; $capture = $this->capture( $orderId, $this->formatAmount($amount), $orderData ); return (object)array( 'authorization' => $authorization, 'capture' => $capture, ); }
Responsible for authorizing the transaction. Once authorized, the transaction amount can be captured at a later point in time. Once the Merchant is ready to perform the actual Authorization of funds the Authorize message should be processes referencing the original OrderId returned in the Lookup message. This authorization request checks the availability of the Customer’s funds to obtain an honor period for capture/settlement. @param string $orderId order id from Cardinal @param mixed $amount amount to be authorized @param string $currency currency code @param HpsBuyerData $buyer buyer information @param HpsPaymentData $payment payment information @param HpsShippingInfo $shippingAddress shipping information @param array<int, HpsLineItem> $lineItems line items from order @param HpsOrderData $orderData Cardinal/MasterPass specific data @return object
entailment
public function void( $orderId, HpsOrderData $orderData = null ) { $payload = array( 'OrderId' => $orderId, ); return $this->submitTransaction($payload, 'cmpi_void'); }
Cancels an authorized transaction with MasterPass. Any hold on consumer funds will be removed when the transaction is voided. @param string $orderId order id from Cardinal @param HpsOrderData $orderData Cardinal/MasterPass specific data @return object
entailment
protected function currencyStringToNumeric($currency) { if (!in_array(strtolower($currency), array_keys(self::$currencyCodes))) { throw new HpsArgumentException( 'Currency is not supported', HpsExceptionCodes::INVALID_CURRENCY ); } return self::$currencyCodes[strtolower($currency)]; }
Converts a 3-letter currency code to 3-digit ISO 4217 version @param string $currency currency code @return string @throws \HpsArgumentException @raises HpsArgumentException
entailment
protected function hydrateBuyerData(HpsBuyerData $buyer) { return array( 'BillingAddress1' => $buyer->address->address, 'BillingCity' => $buyer->address->city, 'BillingCountryCode' => $buyer->countryCode, 'BillingFirstName' => $buyer->firstName, 'BillingLastName' => $buyer->lastName, 'BillingMiddleName' => $buyer->middleName, 'BillingPhone' => $buyer->phoneNumber, 'BillingPostalCode' => $buyer->address->zip, 'BillingState' => $buyer->address->state, ); }
Converts HpsBuyerData into expected format for Cardinal @param HpsBuyerData $buyer buyer information @return array<string, string>
entailment
protected function hydrateLineItems($items) { $result = array(); if ($items == null) { return $result; } foreach ($items as $i => $item) { $result = array_merge( $result, array( 'Item_Name_' . $i => $item->name, 'Item_Desc_' . $i => $item->description, 'Item_Price_' . $i => $this->formatAmount($item->amount), 'Item_Quantity_' . $i => $item->quantity, 'Item_SKU_' . $i => $item->number, ) ); } return $result; }
Converts HpsLineItem's into expected format for Cardinal @param array<int, HpsLineItem> $items line items from order @return array<string, string>
entailment
protected function hydratePaymentData(HpsPaymentData $payment) { return array( 'TaxAmount' => $this->formatAmount($payment->taxAmount), 'ShippingAmount' => $this->formatAmount($payment->shippingAmount), ); }
Converts HpsShippingInfo into expected format for Cardinal @param HpsPaymentData $payment payment information @return array<string, string>
entailment
protected function hydrateShippingInfo(HpsShippingInfo $shipping) { return array( 'ShippingAddress1' => $shipping->address->address, 'ShippingCity' => $shipping->address->city, 'ShippingCountryCode' => $shipping->countryCode, 'ShippingFirstName' => $shipping->firstName, 'ShippingLastName' => $shipping->lastName, 'ShippingMiddleName' => $shipping->middleName, 'ShippingPhone' => $shipping->phoneNumber, 'ShippingPostalCode' => $shipping->address->zip, 'ShippingState' => $shipping->address->state, ); }
Converts HpsShippingInfo into expected format for Cardinal @param HpsShippingInfo $shipping shipping information @return array<string, string>
entailment
protected function processGatewayResponse($response) { $gatewayRspCode = isset($response->ErrorNo) ? (string)$response->ErrorNo : null; if ($gatewayRspCode == '0') { return; } throw new HpsException((string)$response->ErrorDesc); }
Processes the response from Cardinal @param object $response response from Cardinal @return null @throws \HpsException
entailment
protected function processProcessorResponse($response) { $statusCode = isset($response->StatusCode) ? (string)$response->StatusCode : null; if ($statusCode == null || $statusCode == 'Y') { return; } throw new HpsException((string)$response->ErrorDesc); }
Processes the response from MasterPass @param object $response response from Cardinal @return null @throws \HpsException
entailment
protected function submitTransaction( $request, $txnType ) { $request = array_merge($request, array('MsgType' => $txnType)); $response = $this->doRequest($request); $this->processGatewayResponse($response); $this->processProcessorResponse($response); $result = null; switch ($txnType) { case 'cmpi_lookup': $result = HpsCardinalMPILookupResponse::fromObject($response); break; case 'cmpi_authenticate': $result = HpsCardinalMPIAuthenticateResponse::fromObject($response); break; case 'cmpi_baseserver_api': $result = HpsCardinalMPIPreapprovalResponse::fromObject($response); break; case 'cmpi_authorize': $result = HpsCardinalMPIAuthorizeResponse::fromObject($response); break; case 'cmpi_capture': $result = HpsCardinalMPICaptureResponse::fromObject($response); break; case 'cmpi_refund': $result = HpsCardinalMPIRefundResponse::fromObject($response); break; case 'cmpi_void': $result = HpsCardinalMPIVoidResponse::fromObject($response); break; case 'cmpi_add_order_number': $result = HpsCardinalMPIAddOrderNumberResponse::fromObject($response); break; } return $result; }
Submits a transaction to the gateway @param array<string, string> $request request payload @param string $txnType type of transaction to be ran @return object
entailment
public function execute() { parent::execute(); if ($this->transactionId <= 0) { throw new HpsArgumentException('Invalid Transaction Id',HpsExceptionCodes::INVALID_ORIGINAL_TRANSACTION); } $xml = new DOMDocument(); $hpsTransaction = $xml->createElement('hps:Transaction'); $hpsReportTxnDetail = $xml->createElement('hps:ReportTxnDetail'); $hpsReportTxnDetail->appendChild($xml->createElement('hps:TxnId', $this->transactionId)); $hpsTransaction->appendChild($hpsReportTxnDetail); return $this->service->_submitTransaction($hpsTransaction, 'ReportTxnDetail'); }
Creates a get transaction through the HpsCreditService
entailment
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)); if ($this->token != null && ($this->token instanceof HpsTokenData)) { if ($this->card == null) { $this->card = new HpsGiftCard(); } $this->card->tokenValue = $this->token->tokenValue; } $cardData = $this->service->_hydrateGiftCardData($this->card, $xml); $hpsBlock1->appendChild($cardData); 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'); }
Creates a sale transaction through the HpsGiftCardService
entailment
public static function fromObject($data, $returnType = 'HpsCardinalMPIAuthorizeResponse') { $response = parent::fromObject($data, $returnType); $response->authorizationCode = self::readDataKey($data, 'AuthorizationCode'); $response->avsResult = self::readDataKey($data, 'AvsResult'); $response->cardBin = self::readDataKey($data, 'CardBin'); $response->cardExpMonth = self::readDataKey($data, 'CardExpMonth'); $response->cardExpYear = self::readDataKey($data, 'CardExpYear'); $response->cardLastFour = self::readDataKey($data, 'CardLastFour'); $response->cardType = self::readDataKey($data, 'CardType'); $response->longAccessToken = self::readDataKey($data, 'LongAccessToken'); $response->nameOnCard = self::readDataKey($data, 'NameOnCard'); $response->processorBillingAddress1 = self::readDataKey($data, 'ProcessorBillingAddress1'); $response->processorBillingAddress2 = self::readDataKey($data, 'ProcessorBillingAddress2'); $response->processorBillingCity = self::readDataKey($data, 'ProcessorBillingCity'); $response->processorBillingCountryCode = self::readDataKey($data, 'ProcessorBillingCountryCode'); $response->processorBillingFirstName = self::readDataKey($data, 'ProcessorBillingFirstName'); $response->processorBillingLastName = self::readDataKey($data, 'ProcessorBillingLastName'); $response->processorBillingMiddleName = self::readDataKey($data, 'ProcessorBillingMiddleName'); $response->processorBillingPhone = self::readDataKey($data, 'ProcessorBillingPhone'); $response->processorBillingPostalCode = self::readDataKey($data, 'ProcessorBillingPostalCode'); $response->processorBillingState = self::readDataKey($data, 'ProcessorBillingState'); $response->processorCavv = self::readDataKey($data, 'ProcessorCavv'); $response->processorEciFlag = self::readDataKey($data, 'ProcessorEciFlag'); $response->processorEmail = self::readDataKey($data, 'ProcessorEmail'); $response->processorPayresStatus = self::readDataKey($data, 'ProcessorPayresStatus'); $response->processorShippingAddress1 = self::readDataKey($data, 'ProcessorShippingAddress1'); $response->processorShippingAddress2 = self::readDataKey($data, 'ProcessorShippingAddress2'); $response->processorShippingCity = self::readDataKey($data, 'ProcessorShippingCity'); $response->processorShippingCountryCode = self::readDataKey($data, 'ProcessorShippingCountryCode'); $response->processorShippingFullName = self::readDataKey($data, 'ProcessorShippingFullName'); $response->processorShippingPhone = self::readDataKey($data, 'ProcessorShippingPhone'); $response->processorShippingPostalCode = self::readDataKey($data, 'ProcessorShippingPostalCode'); $response->processorShippingState = self::readDataKey($data, 'ProcessorShippingState'); return $response; }
@param $data @param string $returnType @return mixed
entailment
public function execute() { parent::execute(); $balanceSvc = new HpsGiftCardService($this->service->servicesConfig()); if ($this->token != null && ($this->token instanceof HpsTokenData)) { if ($this->card == null) { $this->card = new HpsGiftCard(); } $this->card->tokenValue = $this->token->tokenValue; } return $balanceSvc->balance( $this->card ); }
Creates a balance transaction through the HpsGiftCardService
entailment
public static function fromDict($rsp, $txnType, $returnType = 'HpsAttachment') { $attResponse = $rsp->Transaction->$txnType->Details; $transaction = parent::fromDict($rsp, $txnType, $returnType); foreach (get_object_vars($attResponse) as $key => $prop) { if (property_exists($transaction, lcfirst($key))) { $transaction->__set(lcfirst($key), $prop); } } return $transaction; }
@param \SimpleXMLElement $rsp @param null $txnType @param string $returnType @return HpsAttachment
entailment
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->service->_hydrateCardHolderData($this->cardHolder, $xml)); } if ($this->details != null) { $hpsBlock1->appendChild($this->service->_hydrateAdditionalTxnFields($this->details, $xml)); } 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 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 recurring billing transaction through the HpsCreditService
entailment
public static function fromDict($rsp, $txnType, $returnType = 'HpsGiftCardActivate') { $activationRsp = $rsp->Transaction->$txnType; $activation = new $returnType(); $activation->transactionId = (string)$rsp->Header->GatewayTxnId; $activation->authorizationCode = (isset($activationRsp->AuthCode) ? (string)$activationRsp->AuthCode : null); $activation->balanceAmount = (isset($activationRsp->BalanceAmt) ? (string)$activationRsp->BalanceAmt : null); $activation->pointsBalanceAmount = (isset($activationRsp->PointsBalanceAmt) ? (string)$activationRsp->PointsBalanceAmt : null); $activation->rewards = (isset($activationRsp->Rewards) ? (string)$activationRsp->Rewards : null); $activation->notes = (isset($activationRsp->Notes) ? (string)$activationRsp->Notes : null); $activation->responseCode = (isset($activationRsp->RspCode) ? (string)$activationRsp->RspCode : null); $activation->responseText = (isset($activationRsp->RspText) ? (string)$activationRsp->RspText : null); return $activation; }
@param $rsp @param $txnType @param string $returnType @return mixed
entailment
public static function fromStdClass($obj) { $ret = new HpsPayPlanCustomer(); $ret->customerKey = property_exists($obj, 'customerKey') ? $obj->customerKey : null; $ret->customerIdentifier = property_exists($obj, 'customerIdentifier') ? $obj->customerIdentifier : null; $ret->firstName = property_exists($obj, 'firstName') ? $obj->firstName : null; $ret->lastName = property_exists($obj, 'lastName') ? $obj->lastName : null; $ret->company = property_exists($obj, 'company') ? $obj->company : null; $ret->customerStatus = property_exists($obj, 'customerStatus') ? $obj->customerStatus : null; $ret->primaryEmail = property_exists($obj, 'primaryEmail') ? $obj->primaryEmail : null; $ret->phoneDay = property_exists($obj, 'phoneDay') ? $obj->phoneDay : null; $ret->phoneDayExt = property_exists($obj, 'phoneDayExt') ? $obj->phoneDayExt : null; $ret->phoneEvening = property_exists($obj, 'phoneEvening') ? $obj->phoneEvening : null; $ret->phoneEveningExt = property_exists($obj, 'phoneEveningExt') ? $obj->phoneEveningExt : null; $ret->phoneMobile = property_exists($obj, 'phoneMobile') ? $obj->phoneMobile : null; $ret->phoneMobileExt = property_exists($obj, 'phoneMobileExt') ? $obj->phoneMobileExt : null; $ret->fax = property_exists($obj, 'fax') ? $obj->fax : null; $ret->title = property_exists($obj, 'title') ? $obj->title : null; $ret->department = property_exists($obj, 'department') ? $obj->department : null; $ret->addressLine1 = property_exists($obj, 'addressLine1') ? $obj->addressLine1 : null; $ret->addressLine2 = property_exists($obj, 'addressLine2') ? $obj->addressLine2 : null; $ret->city = property_exists($obj, 'city') ? $obj->city : null; $ret->country = property_exists($obj, 'country') ? $obj->country : null; $ret->stateProvince = property_exists($obj, 'stateProvince') ? $obj->stateProvince : null; $ret->zipPostalCode = property_exists($obj, 'zipPostalCode') ? $obj->zipPostalCode : null; $ret->paymentMethods = property_exists($obj, 'paymentMethods') ? array_map('HpsPayPlanPaymentMethod::fromStdClass', $obj->paymentMethods) : null; $ret->schedules = property_exists($obj, 'schedules') ? array_map('HpsPayPlanSchedule::fromStdClass', $obj->schedules) : null; $ret->creationDate = property_exists($obj, 'creationDate') ? $obj->creationDate : null; $ret->lastChangeDate = property_exists($obj, 'lastChangeDate') ? $obj->lastChangeDate : null; $ret->statusSetDate = property_exists($obj, 'statusSetDate') ? $obj->statusSetDate : null; return $ret; }
@param $obj @return \HpsPayPlanCustomer
entailment
public function execute() { parent::execute(); $rewardSvc = new HpsGiftCardService($this->service->servicesConfig()); if ($this->token != null && ($this->token instanceof HpsTokenData)) { if ($this->card == null) { $this->card = new HpsGiftCard(); } $this->card->tokenValue = $this->token->tokenValue; } return $rewardSvc->reward( $this->card, $this->amount, $this->currency, $this->gratuity, $this->tax ); }
Creates a reward transaction through the HpsGiftCardService
entailment
private function prepareOptions($body, array $query, array $headers, array $options) { $options = array_merge($options, [ RequestOptions::QUERY => $query, RequestOptions::HEADERS => $headers, ]); if (!empty($body) && (is_array($body) || $body instanceof \JsonSerializable)) { $options[RequestOptions::JSON] = $body; } else { $options[RequestOptions::BODY] = $body; } return $options; }
@param mixed $body @param array $query @param array $headers @param array $options @return array
entailment
protected function submitRequest($url, $headers, $data = null, $httpVerb = 'POST', $keyType = HpsServicesConfig::KEY_TYPE_SECRET, $options = null) { if ($this->_isConfigInvalid()) { throw new HpsAuthenticationException( HpsExceptionCodes::INVALID_CONFIGURATION, "The HPS SDK has not been properly configured. " ."Please make sure to initialize the config " ."in a service constructor." ); } if (!$this->_config->validate($keyType) && ($this->_config->username == null && $this->_config->password == null)) { $type = $this->_config->getKeyType($keyType); $message = "The HPS SDK requires a valid {$keyType} API key to be used"; if ($type == $keyType) { $message .= "."; } else { $message .= ", but a(n) {$type} key is currently configured."; } throw new HpsAuthenticationException( HpsExceptionCodes::INVALID_CONFIGURATION, $message ); } $logger = HpsLogger::getInstance(); try { $request = curl_init(); curl_setopt($request, CURLOPT_URL, $url); curl_setopt($request, CURLOPT_CONNECTTIMEOUT, 100); curl_setopt($request, CURLOPT_TIMEOUT, 100); curl_setopt($request, CURLOPT_RETURNTRANSFER, true); curl_setopt($request, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($request, CURLOPT_SSL_VERIFYHOST, false); if ($data != null) { $logger->log('Request data', $data); curl_setopt($request, CURLOPT_CUSTOMREQUEST, $httpVerb); curl_setopt($request, CURLOPT_POSTFIELDS, $data); } $logger->log('Request headers', $headers); curl_setopt($request, CURLOPT_HTTPHEADER, $headers); curl_setopt($request, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS); if ($this->_config->useProxy) { curl_setopt($request, CURLOPT_PROXY, $this->_config->proxyOptions['proxy_host']); curl_setopt($request, CURLOPT_PROXYPORT, $this->_config->proxyOptions['proxy_port']); } if ( $this->_config->curlOptions != null && !empty($this->_config->curlOptions) ) { curl_setopt_array($request, $this->_config->curlOptions); } $curlResponse = curl_exec($request); $curlInfo = curl_getinfo($request); $curlError = curl_errno($request); $logger->log('Response data', $curlResponse); $logger->log('Curl info', $curlInfo); $logger->log('Curl error', $curlError); if ($curlError == 28) { //CURLE_OPERATION_TIMEOUTED throw new HpsException("gateway_time-out"); } if ($curlError == 35) { //CURLE_SSL_CONNECT_ERROR $err_msg = 'PHP-SDK cURL TLS 1.2 handshake failed. If you have any questions, please contact Specialty Products Team at 866.802.9753.'; if ( extension_loaded('openssl') && OPENSSL_VERSION_NUMBER < self::MIN_OPENSSL_VER ) { // then you don't have openSSL 1.0.1c or greater $err_msg .= 'Your current version of OpenSSL is ' . OPENSSL_VERSION_TEXT . 'You do not have the minimum version of OpenSSL 1.0.1c which is required for curl to use TLS 1.2 handshake.'; } throw new HpsGatewayException($curlError,$err_msg); } return $this->processResponse($curlResponse, $curlInfo, $curlError); } catch (Exception $e) { throw new HpsGatewayException( $e->getCode() != null ? $e->getCode() : HpsExceptionCodes::UNKNOWN_GATEWAY_ERROR, $e->getMessage() != null ? $e->getMessage() : 'Unable to process transaction', null, null, $e ); } }
@param $url @param $headers @param null $data @param string $httpVerb @param string $keyType @param null $options @return mixed @throws \HpsAuthenticationException @throws \HpsGatewayException
entailment
public function send($method, $uri, $body = null, array $query = [], array $headers = [], array $options = []) { $this->validateMethod($method); $query = array_merge($this->getDefaultQuery(), $query); $headers = array_merge($this->getDefaultHeaders(), $headers); $this->lastResponse = $this->client->send($method, $uri, $body, $query, $headers, $options); $this->validateResponse($this->lastResponse); return $this->lastResponse; }
@param string $method @param string $uri @param mixed $body @param array $query @param array $headers @param array $options @return ResponseInterface
entailment
public function sendAsync($method, $uri, $body = null, array $query = [], array $headers = [], array $options = []) { try { $this->validateMethod($method); } catch (\InvalidArgumentException $e) { return rejection_for($e); } $query = array_merge($this->getDefaultQuery(), $query); $headers = array_merge($this->getDefaultHeaders(), $headers); return $this->client->sendAsync($method, $uri, $body, $query, $headers, $options)->then( function (ResponseInterface $response) { $this->lastResponse = $response; $this->validateResponse($this->lastResponse); return $this->lastResponse; } ); }
@param string $method @param string $uri @param mixed $body @param array $query @param array $headers @param array $options @return PromiseInterface
entailment
public function addContext(Context $context) { $contexts = $this->get('contextOut'); $contexts[] = $context; $this->add('contextOut', $contexts); }
Add a context to the response. @param \ApiAi\Model\Context $context The Context to be added.
entailment
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->service->_submitTransaction($hpsTransaction, 'CheckSale'); }
Creates a sale transaction through the HpsCheckService
entailment
public function execute() { parent::execute(); $voidSvc = new HpsGiftCardService($this->service->servicesConfig()); return $voidSvc->void( $this->transactionId ); }
Creates a void transaction through the HpsGiftCardService
entailment
public static function fromDict($rsp, $txnType, $returnType = 'HpsReversal') { $reverseResponse = $rsp->Transaction->$txnType; $reverse = parent::fromDict($rsp, $txnType, $returnType); $reverse->avsResultCode = (isset($reverseResponse->AVSRsltCode) ? (string)$reverseResponse->AVSRsltCode : null); $reverse->avsResultText = (isset($reverseResponse->AVSRsltText) ? (string)$reverseResponse->AVSRsltText : null); $reverse->cpcIndicator = (isset($reverseResponse->CPCInd) ? (string)$reverseResponse->CPCInd : null); $reverse->cvvResultCode = (isset($reverseResponse->CVVRsltCode) ? (string)$reverseResponse->CVVRsltCode : null); $reverse->cvvResultText = (isset($reverseResponse->CVVRsltText) ? (string)$reverseResponse->CVVRsltText : null); return $reverse; }
@param $rsp @param $txnType @param string $returnType @return mixed
entailment
public function execute() { parent::execute(); $reverseSvc = new HpsDebitService($this->service->servicesConfig()); return $reverseSvc->reverse( $this->transactionId, $this->amount, $this->trackData, $this->authorizedAmount, $this->encryptionData, $this->details, $this->clientTransactionId ); }
Creates a reverse transaction through the HpsDebitService
entailment
public static function fromDict($rsp, $txnType, $returnType = 'HpsGiftCardSale') { $item = $rsp->Transaction; $sale = parent::fromDict($rsp, $txnType, $returnType); $sale->splitTenderCardAmount = (isset($item->SplitTenderCardAmt) ? (string)$item->SplitTenderCardAmt : null); $sale->splitTenderBalanceDue = (isset($item->SplitTenderBalanceDueAmt) ? (string)$item->SplitTenderBalanceDueAmt : null); return $sale; }
@param $rsp @param $txnType @param string $returnType @return mixed
entailment
public function getAttachments($GatewayTxnId, $AttachmentType = 'all', $ReturnAttachmentTypesOnly = false, $AttachmentDataId = null) { $GatewayTxnId = filter_var($GatewayTxnId, FILTER_SANITIZE_NUMBER_FLOAT); if (!$GatewayTxnId) { throw new HpsArgumentException('Gateway Transaction ID required', HpsExceptionCodes::INVALID_NUMBER); } $AttachmentTypeProvided = preg_match(HpsAttachmentType::VALID_ATTACHMENT_TYPE, $AttachmentType) === 1; $AttachmentDataId = filter_var($AttachmentDataId, FILTER_SANITIZE_NUMBER_INT); // this is a limitation of the gateway and we want to inform the user if ($AttachmentTypeProvided && $AttachmentDataId) { throw new HpsGatewayException(HpsExceptionCodes::GATEWAY_ERROR, "Since the AttachmentDataId was provided the AttachmentType was ignored by the server"); //trigger_error("Since the AttachmentDataId was provided the AttachmentType was ignored by the server", E_USER_NOTICE); } $xml = new DOMDocument(); $hpsTransaction = $xml->createElement('hps:Transaction'); $hpsGetAttachments = $hpsTransaction ->appendChild($xml->createElement('hps:GetAttachments')); $hpsGetAttachments->appendChild($xml->createElement('hps:GatewayTxnId', $GatewayTxnId)); if ($AttachmentTypeProvided) { $hpsGetAttachments->appendChild($xml->createElement('hps:AttachmentType', $AttachmentType)); } if ($ReturnAttachmentTypesOnly === true) { $hpsGetAttachments->appendChild($xml->createElement('hps:ReturnAttachmentTypesOnly', 'true')); } if ($AttachmentDataId) { $hpsGetAttachments->appendChild($xml->createElement('hps:AttachmentDataId', $AttachmentDataId)); } return $this->_submitTransaction($hpsTransaction, 'GetAttachments'); }
@param float $GatewayTxnId this is actually a long but php handles long with float @param \HpsAttachmentType|string $AttachmentType SIGNATURE_IMAGE|RECEIPT_IMAGE|CUSTOMER_IMAGE|PRODUCT_IMAGE|DOCUMENT @param bool $ReturnAttachmentTypesOnly @param null|int $AttachmentDataId @return \HpsAttachment @throws \HpsArgumentException @throws \HpsException @throws \HpsGatewayException
entailment
private function _submitTransaction($transaction, $txnType) { try { $response = $this->doRequest($transaction); } catch (HpsException $e) { if ($e->innerException != null && $e->innerException->getMessage() == 'gateway_time-out') { throw new HpsException('An error occurred and the gateway has timed out', 'gateway_timeout', $e, 'gateway_timeout'); } throw $e; } $this->_processGatewayResponse($response, $txnType); $rvalue = null; switch ($txnType) { case 'GetAttachments': $rvalue = HpsAttachment::fromDict($response, $txnType); break; default: break; } return $rvalue; }
@param \DOMElement $transaction @param string $txnType @return array|null @throws \HpsException @throws \HpsGatewayException
entailment
public static function fromDict($rsp, $txnType, $returnType = 'HpsGiftCardAlias') { $item = $rsp->Transaction->$txnType; $alias = new HpsGiftCardAlias(); $alias->transactionId = (string)$rsp->Header->GatewayTxnId; $alias->giftCard = new HpsGiftCard($item->CardData); $alias->responseCode = (isset($item->RspCode) ? (string)$item->RspCode : null); $alias->responseText = (isset($item->RspText) ? (string)$item->RspText : null); return $alias; }
@param $rsp @param $txnType @param string $returnType @return \HpsGiftCardAlias
entailment
public function alias($action, $giftCard, $aliasStr) { $txnType = 'GiftCardAlias'; $xml = new DOMDocument(); $hpsTransaction = $xml->createElement('hps:Transaction'); $hpsGiftCardAlias = $xml->createElement('hps:'. $txnType); $hpsBlock1 = $xml->createElement('hps:Block1'); $hpsBlock1->appendChild($xml->createElement('hps:Action', strtoupper($action))); $hpsBlock1->appendChild($xml->createElement('hps:Alias', $aliasStr)); if ( $giftCard instanceof HpsTokenData ) { $cardData = new HpsGiftCard(); $cardData->tokenValue = $giftCard->tokenValue; } else { $cardData = $giftCard; } $hpsBlock1->appendChild($this->_hydrateGiftCardData($cardData, $xml)); $hpsGiftCardAlias->appendChild($hpsBlock1); $hpsTransaction->appendChild($hpsGiftCardAlias); return $this->_submitTransaction($hpsTransaction, $txnType); }
@param $action @param $giftCard @param $aliasStr @return \HpsGiftCardAlias|string
entailment
public function balance($giftCard) { $txnType = 'GiftCardBalance'; $xml = new DOMDocument(); $hpsTransaction = $xml->createElement('hps:Transaction'); $hpsGiftCard = $xml->createElement('hps:'. $txnType); $hpsBlock1 = $xml->createElement('hps:Block1'); if ( $giftCard instanceof HpsTokenData ) { $cardData = new HpsGiftCard(); $cardData->tokenValue = $giftCard->tokenValue; } else { $cardData = $giftCard; } $hpsBlock1->appendChild($this->_hydrateGiftCardData($cardData, $xml)); $hpsGiftCard->appendChild($hpsBlock1); $hpsTransaction->appendChild($hpsGiftCard); return $this->_submitTransaction($hpsTransaction, $txnType); }
@param $giftCard @return \HpsGiftCardAlias|string
entailment
public function replace($oldGiftCard, $newGiftCard) { $txnType = 'GiftCardReplace'; $xml = new DOMDocument(); $hpsTransaction = $xml->createElement('hps:Transaction'); $hpsGiftCard = $xml->createElement('hps:'. $txnType); $hpsBlock1 = $xml->createElement('hps:Block1'); $hpsBlock1->appendChild($this->_hydrateGiftCardData($oldGiftCard, $xml, 'OldCardData')); $hpsBlock1->appendChild($this->_hydrateGiftCardData($newGiftCard, $xml, 'NewCardData')); $hpsGiftCard->appendChild($hpsBlock1); $hpsTransaction->appendChild($hpsGiftCard); return $this->_submitTransaction($hpsTransaction, $txnType); }
@param $oldGiftCard @param $newGiftCard @return \HpsGiftCardAlias|string
entailment
public function reverse($giftCard, $amount, $currency = 'usd') { $txnType = 'GiftCardReversal'; 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)); if ($giftCard instanceof HpsGiftCard) { $hpsBlock1->appendChild($this->_hydrateGiftCardData($giftCard, $xml)); } else if ( $giftCard instanceof HpsTokenData ) { $cardData = new HpsGiftCard(); $cardData->tokenValue = $giftCard->tokenValue; } else { $hpsBlock1->appendChild($xml->createElement('hps:GatewayTxnId', $giftCard)); } $hpsGiftCard->appendChild($hpsBlock1); $hpsTransaction->appendChild($hpsGiftCard); return $this->_submitTransaction($hpsTransaction, $txnType); }
@param $giftCard @param $amount @param string $currency @return \HpsGiftCardAlias|string @throws \HpsInvalidRequestException
entailment
public function reward($giftCard, $amount, $currency = 'usd', $gratuity = null, $tax = null) { $txnType = 'GiftCardReward'; 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)); if ( $giftCard instanceof HpsTokenData ) { $cardData = new HpsGiftCard(); $cardData->tokenValue = $giftCard->tokenValue; } else { $cardData = $giftCard; } $hpsBlock1->appendChild($this->_hydrateGiftCardData($cardData, $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); }
@param $giftCard @param $amount @param string $currency @param null $gratuity @param null $tax @return \HpsGiftCardAlias|string @throws \HpsInvalidRequestException
entailment
public function void($transactionId) { $txnType = 'GiftCardVoid'; $xml = new DOMDocument(); $hpsTransaction = $xml->createElement('hps:Transaction'); $hpsGiftCard = $xml->createElement('hps:'. $txnType); $hpsBlock1 = $xml->createElement('hps:Block1'); $hpsBlock1->appendChild($xml->createElement('hps:GatewayTxnId', $transactionId)); $hpsGiftCard->appendChild($hpsBlock1); $hpsTransaction->appendChild($hpsGiftCard); return $this->_submitTransaction($hpsTransaction, $txnType); }
@param $transactionId @return \HpsGiftCardAlias|string
entailment
public static function fromObject($data, $returnType = 'HpsCardinalMPIResponse') { $response = new $returnType(); $response->errorDescription = self::readDataKey($data, 'ErrorDesc'); $response->errorNumber = self::readDataKey($data, 'ErrorNo'); $response->merchantData = self::readDataKey($data, 'MerchantData'); $response->merchantReferenceNumber = self::readDataKey($data, 'MerchantReferenceNumber'); $response->orderId = self::readDataKey($data, 'OrderId'); $response->orderNumber = self::readDataKey($data, 'OrderNumber'); $response->processorOrderNumber = self::readDataKey($data, 'ProcessorOrderNumber'); $response->processorStatusCode = self::readDataKey($data, 'ProcessorStatusCode'); $response->processorTransactionId = self::readDataKey($data, 'ProcessorTransactionId'); $response->reasonCode = self::readDataKey($data, 'ReasonCode'); $response->reasonDescription = self::readDataKey($data, 'ReasonDesc'); $response->statusCode = self::readDataKey($data, 'StatusCode'); $response->transactionId = self::readDataKey($data, 'TransactionId'); return $response; }
@param $data @param string $returnType @return mixed
entailment
public static function readDataKey($data, $key) { return isset($data->{$key}) ? (string)$data->{$key} : null; }
@param $data @param $key @return null|string
entailment
public static function create(Query $query) { $type = null; if ($result = $query->getResult()) { if (!$result->getActionIncomplete()) { if (strlen(trim($result->getAction())) > 0) { $type = Step::TYPE_ACTION; } } if ($result->getFulfillment()->getSpeech()) { $type = Step::TYPE_SPEECH; } } switch ($type) { case Step::TYPE_ACTION: return self::createActionStep($query); case Step::TYPE_SPEECH: return self::createSpeechStep($query); default: throw new InvalidStepException('Invalid Step', $query); } }
@param Query $query @return Action|Speech
entailment
public static function createActionStep(Query $query) { return new Action( $query->getResult()->getAction(), $query->getResult()->getParameters(), $query->getResult()->getContexts() ); }
@param Query $query @return Action
entailment
public static function createSpeechStep(Query $query) { return new Speech( $query->getResult()->getFulfillment()->getSpeech(), $query->getResult()->getContexts() ); }
@param Query $query @return Speech
entailment
public function sale(HpsCheck $check, $amount, $clientTransactionId = null) { return $this->_buildTransaction('SALE', $check, $amount, $clientTransactionId); }
A Sale transaction is used to process transactions using bank account information as the payment method. The transaction service can be used to perform a Sale or Return transaction by indicating the Check Action. <b>NOTE:</b> The Portico Gateway supports both GETI and HPS Colonnade for processing check transactions. While the available services are the same regardless of the check processor, the services may have different behaviors. For example, GETI-processed Check Sale transactions support the ability to override a Check Sale transaction already presented as well as the ability to verify a check. @param \HpsCheck|string $check The Check information. @param string $amount The amount of the sale. @param null $clientTransactionId @return \HpsCheckResponse @throws \HpsInvalidRequestException @internal param string $action Type of Check Action (Sale, Return, Override)
entailment
public function returnCheck(HpsCheck $check, $amount, $clientTransactionId = null) { //TODO: implement replacement throw new HpsException('Check action RETURN not currently supported'); return $this->_buildTransaction('RETURN', $check, $amount, $clientTransactionId); }
@param \HpsCheck $check @param $amount @param null $clientTransactionId @return mixed @throws \HpsException @throws \HpsInvalidRequestException
entailment
public function void($transactionId = null, $clientTransactionId = null) { if (($transactionId == null && $clientTransactionId == null) || ($transactionId != null && $clientTransactionId != null)) { throw new HpsException('Please provide either a transaction id or a client transaction id'); } $xml = new DOMDocument(); $hpsTransaction = $xml->createElement('hps:Transaction'); $hpsCheckVoid = $xml->createElement('hps:CheckVoid'); $hpsBlock1 = $xml->createElement('hps:Block1'); if ($transactionId != null) { $hpsBlock1->appendChild($xml->createElement('hps:GatewayTxnId', $transactionId)); } else { $hpsBlock1->appendChild($xml->createElement('hps:ClientTxnId', $clientTransactionId)); } $hpsCheckVoid->appendChild($hpsBlock1); $hpsTransaction->appendChild($hpsCheckVoid); return $this->_submitTransaction($hpsTransaction, 'CheckVoid'); }
A <b>Void</b> transaction is used to cancel a previously successful sale transaction. The original sale transaction can be identified by the GatewayTxnid of the original or by the ClientTxnId of the original if provided on the original Sale Transaction. @param null $transactionId @param null $clientTransactionId @return mixed @throws \HpsCheckException @throws \HpsException
entailment
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); }
@param $action @param \HpsCheck $check @param $amount @param null $clientTransactionId @return mixed @throws \HpsCheckException @throws \HpsInvalidRequestException
entailment
private function _submitTransaction($transaction, $txnType, $clientTransactionId = null) { $options = array(); if ($clientTransactionId !== null) { $options['clientTransactionId'] = $clientTransactionId; } $rsp = $this->doRequest($transaction, $options); HpsGatewayResponseValidation::checkResponse($rsp, $txnType); $response = HpsCheckResponse::fromDict($rsp, $txnType); if ($response->responseCode != 0) { throw new HpsCheckException( $rsp->Header->GatewayTxnId, $response->details, $response->responseCode, $response->responseText ); } return $response; }
@param $transaction @param $txnType @param null $clientTransactionId @return mixed @throws \HpsAuthenticationException @throws \HpsCheckException @throws \HpsGatewayException @throws null
entailment
public static function fromDict($rsp, $txnType = null, $returnType = 'HpsManageTokensResponse') { $transaction = parent::fromDict($rsp, $txnType, $returnType); $transaction->responseCode = '00'; $transaction->responseText = ''; return $transaction; }
@param \SimpleXMLElement $rsp @param null $txnType @param string $returnType @return HpsManageTokensResponse
entailment
public function execute() { parent::execute(); $xml = new DOMDocument(); $hpsTransaction = $xml->createElement('hps:Transaction'); $hpsCreditAddToBatch = $xml->createElement('hps:CreditAddToBatch'); $hpsCreditAddToBatch->appendChild($xml->createElement('hps:GatewayTxnId', $this->transactionId)); if ($this->amount != null) { $amount = sprintf("%0.2f", round($this->amount, 3)); $hpsCreditAddToBatch->appendChild($xml->createElement('hps:Amt', $amount)); } if ($this->gratuity != null) { $hpsCreditAddToBatch->appendChild($xml->createElement('hps:GratuityAmtInfo', $this->gratuity)); } if ($this->directMarketData != null && $this->directMarketData->invoiceNumber != null) { $hpsCreditAddToBatch->appendChild($this->_hydrateDirectMarketData($this->directMarketData, $xml)); } $hpsTransaction->appendChild($hpsCreditAddToBatch); $response = $this->service->doRequest($hpsTransaction); $this->_processChargeGatewayResponse($response, 'CreditAddToBatch'); return $this->service ->get($this->transactionId) ->execute(); }
Creates a capture transaction through the HpsCreditService
entailment
public function execute() { parent::execute(); $reverseSvc = new HpsGiftCardService($this->service->servicesConfig()); if ($this->token != null && ($this->token instanceof HpsTokenData)) { if ($this->card == null) { $this->card = new HpsGiftCard(); } $this->card->tokenValue = $this->token->tokenValue; } return $reverseSvc->reverse( isset($this->card) ? $this->card : $this->transactionId, $this->amount, $this->currency ); }
Creates a reverse transaction through the HpsGiftCardService
entailment
protected function cardOrTransactionId($actionCounts) { return (isset($actionCounts['card']) && $actionCounts['card'] == 1 && (!isset($actionCounts['transactionId']) || isset($actionCounts['transactionId']) && $actionCounts['transactionId'] == 0)) || (isset($actionCounts['transactionId']) && $actionCounts['transactionId'] == 1 && (!isset($actionCounts['card']) || isset($actionCounts['card']) && $actionCounts['card'] == 0)); }
Ensures a card has been set. @param array $actionCounts @return bool
entailment
public function execute() { parent::execute(); $activateSvc = new HpsGiftCardService($this->service->servicesConfig()); if ($this->token != null && ($this->token instanceof HpsTokenData)) { if ($this->card == null) { $this->card = new HpsGiftCard(); } $this->card->tokenValue = $this->token->tokenValue; } return $activateSvc->activate( $this->amount, $this->currency, $this->card ); }
Creates an activate transaction through the HpsGiftCardService
entailment
public function addValue($amount, $currency, $trackData, $pinBlock, HpsEncryptionData $encryptionData = null, $allowDuplicates = false, HpsCardHolder $cardHolder = null, HpsTransactionDetails $details = null, $clientTransactionId = null) { HpsInputValidation::checkAmount($amount); HpsInputValidation::checkCurrency($currency); /* Build the transaction request. */ $xml = new DOMDocument(); $hpsTransaction = $xml->createElement('hps:Transaction'); $hpsGiftCard = $xml->createElement('hps:DebitAddValue'); $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: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, 'DebitAddValue', $clientTransactionId); }
The Debit Add Value transaction adds value to a stored value card. The transaction 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 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 HpsDebitAddValue The AddValue (Authorization) response.
entailment
public function reverse($transactionId, $amount, $trackData, $authorizedAmount = null, HpsEncryptionData $encryptionData = null, HpsTransactionDetails $details = null, $clientTransactionId = null) { HpsInputValidation::checkAmount($amount); /* Build the transaction request. */ $xml = new DOMDocument(); $hpsTransaction = $xml->createElement('hps:Transaction'); $hpsGiftCard = $xml->createElement('hps:DebitReversal'); $hpsBlock1 = $xml->createElement('hps:Block1'); $hpsBlock1->appendChild($xml->createElement('hps:GatewayTxnId', $transactionId)); $hpsBlock1->appendChild($xml->createElement('hps:TrackData', $trackData)); $hpsBlock1->appendChild($xml->createElement('hps:Amt', $amount)); if ($encryptionData != null) { $hpsBlock1->appendChild($this->_hydrateEncryptionData($encryptionData, $xml)); } if ($details != null) { $hpsBlock1->appendChild($this->_hydrateAdditionalTxnFields($details, $xml)); } if (isset($authorizedAmount)) { $hpsBlock1->appendChild($xml->createElement('hps:authAmt', $authorizedAmount)); $hpsBlock1->appendChild($xml->createElement('hps:authAmtSpecified', true)); } $hpsGiftCard->appendChild($hpsBlock1); $hpsTransaction->appendChild($hpsGiftCard); $rsp = $this->_submitTransaction($hpsTransaction, 'DebitReversal', $clientTransactionId); $rsp->responseCode = '00'; $rsp->responseText = ''; return $rsp; }
A Debit Reversal transaction reverses a Debit Charge or Debit Return transaction. @param string $transactionId The gateway transaciton ID of the charge to be reversed. @param double $amount Authorization amount. @param string $trackData Track data read from the card by the card reader. @param double $authorizedAmount Settlement amount or New Authorization amount after reversal occures. @param HpsEncryptionData $encryptionData E3 encryption data group. @param HpsTransactionDetails $details Group containing additional transaction fields to be included in detail reporting. @param string $clientTransactionId Optional client transaction ID. @return HpsDebitReversal The reversal result.
entailment
private function _submitTransaction($transaction, $txnType, $clientTxnId = null, $cardData = null) { $options = array(); if ($clientTxnId !== null) { $options['clientTransactionId'] = $clientTxnId; } try { $response = $this->doRequest($transaction, $options); } catch (HpsException $e) { if ($e->innerException != null && $e->innerException->getMessage() == 'gateway_time-out') { if ($txnType == 'DebitSale') { try { $this->reverse($cardData, $this->_amount, $this->_currency); } catch (Exception $e) { throw new HpsGatewayException('0', HpsExceptionCodes::GATEWAY_TIMEOUT_REVERSAL_ERROR); } } throw new HpsException('An error occurred and the gateway has timed out', 'gateway_timeout', $e, 'gateway_timeout'); } throw $e; } $this->_processChargeGatewayResponse($response, $txnType); $this->_processChargeIssuerResponse($response, $txnType); $rvalue = null; switch ($txnType) { case 'DebitSale': $rvalue = HpsDebitSale::fromDict($response, $txnType); break; case 'DebitAddValue': $rvalue = HpsDebitAddValue::fromDict($response, $txnType); break; case 'DebitReturn': $rvalue = HpsDebitReturn::fromDict($response, $txnType); break; case 'DebitReversal': $rvalue = HpsDebitReversal::fromDict($response, $txnType); break; default: break; } return $rvalue; }
@param $transaction @param $txnType @param null $clientTxnId @param null $cardData @return null @throws \HpsCreditException @throws \HpsException @throws \HpsGatewayException
entailment
public function onlyOnePaymentMethod($actionCounts) { return (isset($actionCounts['card']) && $actionCounts['card'] == 1 && (!isset($actionCounts['token']) || isset($actionCounts['token']) && $actionCounts['token'] == 0) && (!isset($actionCounts['transactionId']) || isset($actionCounts['transactionId']) == 0)) || (isset($actionCounts['token']) && $actionCounts['token'] == 1 && (!isset($actionCounts['card']) || isset($actionCounts['card']) && $actionCounts['card'] == 0) && (!isset($actionCounts['transactionId']) || isset($actionCounts['transactionId']) == 0)) || (isset($actionCounts['transactionId']) && $actionCounts['transactionId'] == 1 && (!isset($actionCounts['card']) || isset($actionCounts['card']) && $actionCounts['card'] == 0) && (!isset($actionCounts['token']) || isset($actionCounts['token']) == 0)); }
Ensures there is only one payment method, and checks that there is only one card, one token, or one transactionId in use. @param array $actionCounts @return bool
entailment
public function execute() { parent::execute(); $xml = new DOMDocument(); $hpsTransaction = $xml->createElement('hps:Transaction'); $hpsGiftAlias = $xml->createElement('hps:GiftCardAlias'); $hpsBlock1 = $xml->createElement('hps:Block1'); $hpsBlock1->appendChild($xml->createElement('hps:Action', $this->action)); $hpsBlock1->appendChild($xml->createElement('hps:Alias', $this->alias)); if ($this->token != null && ($this->token instanceof HpsTokenData)) { if ($this->card == null) { $this->card = new HpsGiftCard(); } $this->card->tokenValue = $this->token->tokenValue; } $cardData = $this->service->_hydrateGiftCardData($this->card, $xml); $hpsBlock1->appendChild($cardData); $hpsGiftAlias->appendChild($hpsBlock1); $hpsTransaction->appendChild($hpsGiftAlias); return $this->service->_submitTransaction($hpsTransaction, 'GiftCardAlias'); }
Creates an alias transaction through the HpsGiftCardService
entailment
public static function fromDict($rsp, $txnType, $returnType = 'HpsAltPaymentCreateSession') { $createSession = $rsp->Transaction->$txnType; $session = parent::fromDict($rsp, $txnType, $returnType); if (isset($createSession->Session)) { $pairs = self::nvpToArray($createSession->Session); } $session->sessionId = isset($pairs['SessionId']) ? $pairs['SessionId'] : null; $session->redirectUrl = isset($pairs['RedirectUrl']) ? $pairs['RedirectUrl'] : null; return $session; }
@param $rsp @param $txnType @param string $returnType @return mixed
entailment
public function run($cmd) { $cmd = "{$this->phpBinaryPath} {$this->file} $cmd"; $cmd = $this->isWindows() === true ? $cmd = "start /b {$cmd}" : $cmd = "{$cmd} > /dev/null 2>&1 &"; pclose(popen($cmd, 'r')); return true; }
Running console command on background. @param string $cmd Argument that will be passed to console application. @return boolean
entailment
public static function checkResponse($transactionId, $responseCode, $responseText, $item) { $e = self::getException($transactionId, $responseCode, $responseText, $item); if ($e != null) { throw $e; } }
@param $transactionId @param $responseCode @param $responseText @param $item @throws \HpsProcessorException @throws null
entailment
public static function getException($transactionId, $responseCode, $responseText, $item) { $responseCode = (string)$responseCode; $code = null; $message = null; if ($responseCode == '00') { return null; } if (isset($item->Processor) && isset($item->Processor->Response)) { $error = self::nvpToArray($item->Processor->Response); $code = $error['Code']; $message = $error['Message']; } return new HpsProcessorException($transactionId, $code, $message, $responseCode, $responseText); }
@param $transactionId @param $responseCode @param $responseText @param $item @return \HpsProcessorException|null
entailment
protected static function nvpToArray($pairs) { $array = array(); foreach ($pairs->NameValuePair as $pair) { $array[(string)$pair->Name] = (string)$pair->Value; } return $array; }
@param $pairs @return array
entailment
public function getEditableFieldsWithValues($class, $params = array()) { $array = array_intersect_key( get_object_vars($this), array_flip(call_user_func($class.'::getEditableFields', $params)) ); return array_filter($array, array($this, 'isNotNullOrEmpty')); }
@param $class @param array $params @return array
entailment
public static function fromDict($rsp, $txnType, $returnType = 'HpsAuthorization') { $authResponse = $rsp->Transaction->$txnType; $auth = parent::fromDict($rsp, $txnType, $returnType); $auth->authorizationCode = (isset($authResponse->AuthCode) ? (string)$authResponse->AuthCode : null); $auth->avsResultCode = (isset($authResponse->AVSRsltCode) ? (string)$authResponse->AVSRsltCode : null); $auth->avsResultText = (isset($authResponse->AVSRsltText) ? (string)$authResponse->AVSRsltText : null); $auth->cvvResultCode = (isset($authResponse->CVVRsltCode) ? (string)$authResponse->CVVRsltCode : null); $auth->cvvResultText = (isset($authResponse->CVVRsltText) ? (string)$authResponse->CVVRsltText : null); $auth->authorizedAmount = (isset($authResponse->AuthAmt) ? (string)$authResponse->AuthAmt : null); $auth->cardType = (isset($authResponse->CardType) ? (string)$authResponse->CardType : null); $auth->descriptor = (isset($authResponse->TxnDescriptor) ? (string)$authResponse->TxnDescriptor : null); $auth->cpcIndicator = (isset($authResponse->CPCInd) ? (string)$authResponse->CPCInd : null); if (isset($rsp->Header->TokenData)) { $auth->tokenData = new HpsTokenData(); $auth->tokenData->responseCode = (isset($rsp->Header->TokenData->TokenRspCode) ? (string)$rsp->Header->TokenData->TokenRspCode : null); $auth->tokenData->responseMessage = (isset($rsp->Header->TokenData->TokenRspMsg) ? (string)$rsp->Header->TokenData->TokenRspMsg : null); $auth->tokenData->tokenValue = (isset($rsp->Header->TokenData->TokenValue) ? (string)$rsp->Header->TokenData->TokenValue : null); } return $auth; }
@param $rsp @param $txnType @param string $returnType @return mixed
entailment
public function execute() { parent::execute(); $xml = new DOMDocument(); $hpsTransaction = $xml->createElement('hps:Transaction'); $hpsPosCreditCPCEdit = $xml->createElement('hps:CreditCPCEdit'); $hpsPosCreditCPCEdit->appendChild($xml->createElement('hps:GatewayTxnId', $this->transactionId)); $hpsPosCreditCPCEdit->appendChild($this->service->_hydrateCPCData($this->cpcData, $xml)); $hpsTransaction->appendChild($hpsPosCreditCPCEdit); return $this->service->_submitTransaction($hpsTransaction, 'CreditCPCEdit'); }
Creates a cpcEdit transaction through the HpsCreditService
entailment
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 reverse transaction through the HpsCreditService
entailment
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 listTransactions transaction through the HpsCreditService
entailment
public function add(HpsPayPlanPaymentMethod $paymentMethod) { $result = null; if ($paymentMethod->paymentMethodType == HpsPayPlanPaymentMethodType::ACH) { $result = $this->addACH($paymentMethod); } else { $result = $this->addCreditCard($paymentMethod); } return $this->hydrateObject($result, 'HpsPayPlanPaymentMethod'); }
@param \HpsPayPlanPaymentMethod $paymentMethod @return mixed
entailment
public function edit(HpsPayPlanPaymentMethod $paymentMethod) { $result = null; if ($paymentMethod->paymentMethodType == HpsPayPlanPaymentMethodType::ACH) { $result = $this->editACH($paymentMethod); } else { $result = $this->editCreditCard($paymentMethod); } return $this->hydrateObject($result, 'HpsPayPlanPaymentMethod'); }
@param \HpsPayPlanPaymentMethod $paymentMethod @return mixed
entailment
public function get($paymentMethod) { $id = null; if ($paymentMethod instanceof HpsPayPlanPaymentMethod) { $id = $paymentMethod->paymentMethodKey; } else { $id = $paymentMethod; } $result = $this->doRequest(null, array( 'verb' => 'GET', 'endpoint' => 'paymentMethods/'.$id )); return $this->hydrateObject($result, 'HpsPayPlanPaymentMethod'); }
@param $paymentMethod @return mixed
entailment
public function delete($paymentMethod, $forceDelete = false) { $id = null; if ($paymentMethod instanceof HpsPayPlanPaymentMethod) { $id = $paymentMethod->paymentMethodKey; } else { $id = $paymentMethod; } $data = array( 'forceDelete' => $forceDelete, ); return $this->doRequest($data, array( 'verb' => 'DELETE', 'endpoint' => 'paymentMethods/'.$id, )); }
@param $paymentMethod @param bool $forceDelete @return mixed
entailment
private function addCreditCard(HpsPayPlanPaymentMethod $paymentMethod) { $data = $paymentMethod->getEditableFieldsWithValues(); $data['customerKey'] = $paymentMethod->customerKey; if (isset($paymentMethod->accountNumber)) { $data['accountNumber'] = $paymentMethod->accountNumber; } else if (isset($paymentMethod->paymentToken)) { $data['paymentToken'] = $paymentMethod->paymentToken; } $result = $this->doRequest($data, array( 'verb' => 'POST', 'endpoint' => 'paymentMethodsCreditCard', )); return $this->hydrateObject($result, 'HpsPayPlanPaymentMethod'); }
@param \HpsPayPlanPaymentMethod $paymentMethod @return mixed
entailment
private function editCreditCard(HpsPayPlanPaymentMethod $paymentMethod) { $data = $paymentMethod->getEditableFieldsWithValues(); $result = $this->doRequest($data, array( 'verb' => 'PUT', 'endpoint' => 'paymentMethodsCreditCard/'.$paymentMethod->paymentMethodKey, )); return $this->hydrateObject($result, 'HpsPayPlanPaymentMethod'); }
@param \HpsPayPlanPaymentMethod $paymentMethod @return mixed
entailment
private function addACH(HpsPayPlanPaymentMethod $paymentMethod) { $data = $paymentMethod->getEditableFieldsWithValues(); $data['customerKey'] = $paymentMethod->customerKey; $data['accountNumber'] = $paymentMethod->accountNumber; $data['accountType'] = $paymentMethod->accountType; $data['achType'] = $paymentMethod->achType; $data['routingNumber'] = $paymentMethod->routingNumber; $result = $this->doRequest($data, array( 'verb' => 'POST', 'endpoint' => 'paymentMethodsACH', )); return $this->hydrateObject($result, 'HpsPayPlanPaymentMethod'); }
@param \HpsPayPlanPaymentMethod $paymentMethod @return mixed
entailment
public function execute() { parent::execute(); $deactivateSvc = new HpsGiftCardService($this->service->servicesConfig()); if ($this->token != null && ($this->token instanceof HpsTokenData)) { if ($this->card == null) { $this->card = new HpsGiftCard(); } $this->card->tokenValue = $this->token->tokenValue; } return $deactivateSvc->deactivate( $this->card ); }
Creates a deactivate transaction through the HpsGiftCardService
entailment
public function add(HpsPayPlanSchedule $schedule) { $data = $schedule->getEditableFieldsWithValues(); $data['customerKey'] = $schedule->customerKey; $data['numberOfPayments'] = $schedule->numberOfPayments; $result = $this->doRequest($data, array( 'verb' => 'POST', 'endpoint' => 'schedules', )); return $this->hydrateObject($result, 'HpsPayPlanSchedule'); }
@param \HpsPayPlanSchedule $schedule @return mixed
entailment
public function edit(HpsPayPlanSchedule $schedule) { $data = $schedule->getEditableFieldsWithValues( $schedule ); $result = $this->doRequest($data, array( 'verb' => 'PUT', 'endpoint' => 'schedules/'.$schedule->scheduleKey, )); return $this->hydrateObject($result, 'HpsPayPlanSchedule'); }
@param \HpsPayPlanSchedule $schedule @return mixed
entailment
public function get($schedule) { $id = null; if ($schedule instanceof HpsPayPlanSchedule) { $id = $schedule->scheduleKey; } else { $id = $schedule; } $result = $this->doRequest(null, array( 'verb' => 'GET', 'endpoint' => 'schedules/'.$id, )); return $this->hydrateObject($result, 'HpsPayPlanSchedule'); }
@param $schedule @return mixed
entailment
public function delete($schedule, $forceDelete = false) { $id = null; if ($schedule instanceof HpsPayPlanSchedule) { $id = $schedule->scheduleKey; } else { $id = $schedule; } $data = array( 'forceDelete' => $forceDelete, ); return $this->doRequest($data, array( 'verb' => 'DELETE', 'endpoint' => 'schedules/'.$id, )); }
@param $schedule @param bool $forceDelete @return mixed
entailment
public function execute() { parent::execute(); $xml = new DOMDocument(); $hpsTransaction = $xml->createElement('hps:Transaction'); $hpsCheckVoid = $xml->createElement('hps:CheckVoid'); $hpsBlock1 = $xml->createElement('hps:Block1'); if ($this->transactionId != null) { $hpsBlock1->appendChild($xml->createElement('hps:GatewayTxnId', $this->transactionId)); } else if ($this->clientTransactionId != null) { $hpsBlock1->appendChild($xml->createElement('hps:ClientTxnId', $this->clientTransactionId)); } $hpsCheckVoid->appendChild($hpsBlock1); $hpsTransaction->appendChild($hpsCheckVoid); return $this->service->_submitTransaction($hpsTransaction, 'CheckVoid'); }
Creates a void transaction through the HpsCheckService
entailment
public function onlyOneTransactionId($actionCounts) { return (isset($actionCounts['transactionId']) && $actionCounts['transactionId'] == 1 && (!isset($actionCounts['clientTransactionId']) || isset($actionCounts['clientTransactionId']) && $actionCounts['clientTransactionId'] == 0)) || (isset($actionCounts['clientTransactionId']) && $actionCounts['clientTransactionId'] == 1 && (!isset($actionCounts['transactionId']) || isset($actionCounts['transactionId']) && $actionCounts['transactionId'] == 0)); }
Ensures there is only one transaction id, and checks that there is only one transactionId or one clientTransactionId in use. Both cannot be used. @param array $actionCounts @return bool
entailment
public static function fromDict($rsp, $txnType, $filterBy = null, $returnType = 'HpsReportTransactionSummary') { $transactions = array(); if ((string)$rsp->Transaction->ReportActivity->Header->TxnCnt == "0") { return $transactions; } if ($filterBy != null && is_string($filterBy)) { $filterBy = HpsTransaction::serviceNameToTransactionType($filterBy); } $summary = null; $serviceName = (isset($filterBy) ? HpsTransaction::transactionTypeToServiceName($filterBy) : null); foreach ($rsp->Transaction->ReportActivity->Details as $charge) { if (isset($serviceName) && $serviceName != (string)$charge->ServiceName) { continue; } $summary = new HpsReportTransactionSummary(); // Hydrate the header $summary->_header = new HpsTransactionHeader(); $summary->_header->gatewayResponseCode = (string)$charge->GatewayRspCode; $summary->_header->gatewayResponseMessage = (string)$charge->GatewayRspMsg; $summary->transactionId = (string)$charge->GatewayTxnId; $summary->originalTransactionId = (isset($charge->OriginalGatewayTxnId) ? (string)$charge->OriginalGatewayTxnId : null); $summary->maskedCardNumber = (isset($charge->MaskedCardNbr) ? (string)$charge->MaskedCardNbr : null); $summary->responseCode = (isset($charge->IssuerRspCode) ? (string)$charge->IssuerRspCode : null); $summary->responseText = (isset($charge->IssuerRspText) ? (string)$charge->IssuerRspText : null); $summary->amount = (isset($charge->Amt) ? (string)$charge->Amt : null); $summary->settlementAmount = (isset($charge->SettlementAmt) ? (string)$charge->SettlementAmt : null); $summary->transactionType = (isset($charge->ServiceName) ? HpsTransaction::serviceNameToTransactionType((string)$charge->ServiceName) : null); $summary->transactionUTCDate = (isset($charge->TxnUtcDT) ? (string)$charge->TxnUtcDT : null); $gwResponseCode = (isset($charge->GatewayRspCode) ? (string)$charge->GatewayRspCode : null); $issuerResponseCode = (isset($charge->IssuerRspCode) ? (string)$charge->IssuerRspCode : null); if ($gwResponseCode != "0" || $issuerResponseCode != "00") { $exceptions = new HpsChargeExceptions(); if ($gwResponseCode != "0") { $message = (string)$charge->GatewayRspMsg; $exceptions->hpsException = HpsGatewayResponseValidation::getException((string)$charge->GatewayTxnId, $gwResponseCode, $message); } if ($issuerResponseCode != "00") { $message = (string)$charge->IssuerRspText; $exceptions->cardException = HpsIssuerResponseValidation::getException((string)$charge->GatewayTxnId, $issuerResponseCode, $message, 'credit'); } $summary->exceptions = $exceptions; } $transactions[] = $summary; } return $transactions; }
@param $rsp @param $txnType @param null $filterBy @param string $returnType @return array
entailment
public function page($limit, $offset) { $this->limit = $limit; $this->offset = $offset; return $this; }
@param $limit @param $offset @return $this
entailment
protected function doRequest($data = null, $options = array()) { $endpoint = isset($options['endpoint']) ? $options['endpoint'] : ''; $verb = isset($options['verb']) ? $options['verb'] : 'GET'; $url = $this->_gatewayUrlForKey() . '/' . $endpoint; if (isset($this->limit) && isset($this->offset)) { $paging = array( 'limit' => $this->limit, 'offset' => $this->offset, ); $url .= '?' . http_build_query($paging); } if ($this->searchFields != null) { $data = $this->searchFields; } $encodedData = json_encode($data); $identity = array(); if (isset($this->_config->siteId)) { $identity[0] = 'SiteID='.$this->_config->siteId; } if (isset($this->_config->deviceId)) { $identity[1] = 'DeviceID='.$this->_config->deviceId; } if (isset($this->_config->licenseId)) { $identity[2] = 'LicenseID='.$this->_config->licenseId; } $auth = isset($this->_config->username) ? $this->_config->username.':'.$this->_config->password : $this->_config->secretApiKey; $header = array( 'Authorization: Basic '.base64_encode($auth), 'Content-Type: application/json; charset=utf-8', 'Content-Length: '.strlen($encodedData), ); if (isset($this->_config->username)) { $header[] = 'HPS-Identity: '.implode(',', $identity); } $keyType = HpsServicesConfig::KEY_TYPE_SECRET; // print "\n" . $encodedData; return $this->submitRequest($url, $header, $encodedData, $verb, $keyType); }
@param null $data @param array $options @return mixed @throws \HpsAuthenticationException @throws \HpsGatewayException
entailment
protected function processResponse($curlResponse, $curlInfo, $curlError) { // print "\n" . $curlResponse; $response = json_decode($curlResponse); switch ($curlInfo['http_code']) { case '200': case '204': return $response; break; case '400': throw new HpsException($response->error->message); break; default: throw new HpsException('Unexpected response'); break; } }
@param $curlResponse @param $curlInfo @param $curlError @return mixed @throws \HpsException
entailment
protected function hydrateSearchResults($resultSet, $type) { $results = array(); foreach ($resultSet->results as $result) { $results[] = $this->hydrateObject($result, $type); } unset($result); return (object)array( 'offset' => $resultSet->offset, 'limit' => $resultSet->limit, 'total' => $resultSet->totalMatchingRecords, 'results' => $results, ); }
@param $resultSet @param $type @return object
entailment
public static function fromDict($rsp, $txnType, $returnType = 'HpsAltPaymentCapture') { $addToBatch = $rsp->Transaction->$txnType; $capture = parent::fromDict($rsp, $txnType, $returnType); $capture->status = isset($addToBatch->Status) ? (string)$addToBatch->Status : null; $capture->statusMessage = isset($addToBatch->StatusMessage) ? (string)$addToBatch->StatusMessage : null; return $capture; }
@param $rsp @param $txnType @param string $returnType @return mixed
entailment
public static function checkAmount($amount) { if ($amount < 0 || $amount === null) { throw new HpsInvalidRequestException( HpsExceptionCodes::INVALID_AMOUNT, 'Must be greater than or equal to 0.', 'amount' ); } $amount = preg_replace('/[^0-9\.]/', '', $amount); return sprintf("%0.2f", round($amount, 3)); }
@param $amount @return string @throws \HpsInvalidRequestException
entailment
public static function checkCurrency($currency, $allowedCurrencies = null) { $currencies = self::$_defaultAllowedCurrencies; if (isset($allowedCurrencies) && is_array($allowedCurrencies)) { $currencies = $allowedCurrencies; } if ($currency == null || $currency == '') { throw new HpsInvalidRequestException( HpsExceptionCodes::MISSING_CURRENCY, 'Currency cannot be none', 'currency' ); } else if (!in_array(strtolower($currency), $currencies)) { throw new HpsInvalidRequestException( HpsExceptionCodes::INVALID_CURRENCY, "'".strtolower($currency)."' is not a supported currency", 'currency' ); } }
@param $currency @param null $allowedCurrencies @throws \HpsInvalidRequestException
entailment
public static function checkDateNotFuture($date) { $current = date('Y-m-d\TH:i:s.00\Z', time()); if ($date != null && $date > $current) { throw new HpsInvalidRequestException( HpsExceptionCodes::INVALID_DATE, 'Date cannot be in the future' ); } }
@param $date @throws \HpsInvalidRequestException
entailment
public static function checkPhoneNumber($phoneNumber) { $phoneNumber = self::cleanPhoneNumber($phoneNumber); if (!empty($phoneNumber) && strlen($phoneNumber) > self::$_inputFldMaxLength['PhoneNumber']) { $errorMessage = 'The value for phone number can be no more than ' . self::$_inputFldMaxLength['PhoneNumber'] . ' characters, Please try again after making corrections'; throw new HpsInvalidRequestException( HpsExceptionCodes::INVALID_PHONE_NUMBER, $errorMessage ); } return $phoneNumber; }
This method clears the user input and return the phone number in correct format or throw an exception @param string $phoneNumber this is user entered phone number @return string @throws HpsInvalidRequestException
entailment
public static function checkZipCode($zipCode) { $zipCode = self::cleanZipCode($zipCode); if (!empty($zipCode) && strlen($zipCode) > self::$_inputFldMaxLength['ZipCode']) { $errorMessage = 'The value for zip code can be no more than ' . self::$_inputFldMaxLength['ZipCode'] . ' characters, Please try again after making corrections'; throw new HpsInvalidRequestException( HpsExceptionCodes::INVALID_ZIP_CODE, $errorMessage ); } return $zipCode; }
This method clears the user input and return the Zip code in correct format or throw an exception @param string $zipCode this is user entered zip code @return string @throws HpsInvalidRequestException
entailment
public static function checkCardHolderData($value, $type = '') { $value = filter_var(trim($value),FILTER_SANITIZE_SPECIAL_CHARS); //validate length of input data and throw exception //if maximum characters is not mentioned in $_inputFldMaxLength the sanitized values will be returned if (!empty(self::$_inputFldMaxLength[$type]) && strlen($value) > self::$_inputFldMaxLength[$type]) { $errorMessage = "The value for $type can be no more than " . self::$_inputFldMaxLength[$type] . ' characters, Please try again after making corrections'; throw new HpsInvalidRequestException( HpsExceptionCodes::INVALID_INPUT_LENGTH, $errorMessage ); } return $value; }
This method clears the user input and return the user input in correct format or throw an exception @param string $value this is user entered value (first name or last name or email or city) @param string $type this is user entered value field name @return string @throws HpsInvalidRequestException
entailment
public static function checkEmailAddress($value) { $value = filter_var(trim($value),FILTER_SANITIZE_EMAIL); //validate the email address format if(!empty($value) && filter_var($value, FILTER_VALIDATE_EMAIL) === false){ throw new HpsInvalidRequestException( HpsExceptionCodes::INVALID_EMAIL_ADDRESS, 'Invalid email address' ); } //validate length of input data and throw exception if (!empty(self::$_inputFldMaxLength['Email']) && strlen($value) > self::$_inputFldMaxLength['Email']) { $errorMessage = "The value for Email can be no more than " . self::$_inputFldMaxLength['Email'] . ' characters, Please try again after making corrections'; throw new HpsInvalidRequestException( HpsExceptionCodes::INVALID_INPUT_LENGTH, $errorMessage ); } return $value; }
This method clears the user input and return the email in correct format or throw an exception @param string $value this is user entered email address @return string @throws HpsInvalidRequestException
entailment
public function execute() { parent::execute(); $chargeSvc = new HpsDebitService($this->service->servicesConfig()); return $chargeSvc->charge( $this->amount, $this->currency, $this->trackData, $this->pinBlock, $this->encryptionData, $this->allowDuplicates, $this->cashBackAmount, $this->allowPartialAuth, $this->cardHolder, $this->details, $this->clientTransactionId ); }
Creates a charge transaction through the HpsDebitService
entailment