diff --git a/assets/js/securesubmit.js b/assets/js/securesubmit.js index 3b6a3ae..4d26133 100755 --- a/assets/js/securesubmit.js +++ b/assets/js/securesubmit.js @@ -39,7 +39,7 @@ // Initialize spinner if (!this.isAjax) { - gformInitSpinner(this.formId); + //gformInitSpinner(this.formId); } if (this.isSecure) { @@ -281,7 +281,6 @@ // Handles tokenization response this.secureSubmitResponseHandler = function (response) { - // Preevent any wierdness if ($('#securesubmit_response').length) { return false; diff --git a/classes/class-gf-securesubmit.php b/classes/class-gf-securesubmit.php index 800f5d4..fdd78cb 100755 --- a/classes/class-gf-securesubmit.php +++ b/classes/class-gf-securesubmit.php @@ -1,6 +1,32 @@ includeSecureSubmitSDK(); $config = $this->getHpsServicesConfig(rgpost('key')); - $service = new HpsCreditService($config); + $service = new ReportingService(); $is_valid = true; try { - $service->get('1'); - } catch (HpsAuthenticationException $e) { + $service->transactionDetail("1")->execute(); + } catch (ApiException $e) { $is_valid = false; - } catch (HpsException $e) { - // Transaction was authenticated, but failed for another reason } $response = $is_valid @@ -648,7 +672,6 @@ public function feed_settings_fields() $default_settings = $this->add_field_after('recurringAmount', $public_api_key_field, $default_settings); $default_settings = $this->add_field_after('recurringAmount', $secret_api_key_field, $default_settings); } - if ($this->getAllowLevelII() == 'yes') { $tax_type_field = array( 'name' => 'mappedFields', @@ -1068,7 +1091,7 @@ public function validation($validation_result) * ] */ public function authorize($feed, $submission_data, $form, $entry) - { + { $auth = array( 'is_authorized' => false, 'captured_payment' => array('is_success' => false), @@ -1076,7 +1099,7 @@ public function authorize($feed, $submission_data, $form, $entry) $this->includeSecureSubmitSDK(); $submission_data = array_merge($submission_data, $this->get_submission_dataACH($feed, $form, $entry)); - $isCCData = $this->getSecureSubmitJsResponse(); + $isCCData = $this->getSecureSubmitJsResponse(); if (empty($isCCData->token_value) && false !== $this->isACH && !empty($submission_data['ach_number'])) { $auth = $this->authorizeACH($feed, $submission_data, $form, $entry); @@ -1150,20 +1173,19 @@ private function authorizeACH($feed, $submission_data, $form, $entry) /** @var HpsCheck $check */ /** @var string $note displayed message for consumer */ - $check = new HpsCheck(); + $check = new ECheck(); $check->accountNumber = $submission_data['ach_number']; // from form $account_number_field_input $check->routingNumber = $submission_data['ach_route']; // from form $routing_number_field_input - - $check->checkHolder = $this->buildCheckHolder($feed, $submission_data, $entry);//$account_name_field_input - $check->secCode = HpsSECCode::WEB; - $check->dataEntryMode = HpsDataEntryMode::MANUAL; + + $check->checkHolder = $this->checkHolderData($feed, $submission_data, $entry); + $check->secCode = SecCode::WEB; + $check->entryMode = EntryMethod::MANUAL; //HpsCheckType::BUSINESS; // drop down choice PERSONAL or BUSINESS $check_type_input $check->checkType = $submission_data['ach_check_type']; //HpsAccountType::CHECKING; // drop down choice CHECKING or SAVINGS $account_type_input $check->accountType = $submission_data['ach_account_type']; $config = $this->getHpsServicesConfig($this->getSecretApiKey($feed)); - - $service = new HpsFluentCheckService($config); + $address = $this->buildAddress($feed, $submission_data, $entry); /** * if fraud_velocity_attempts is less than the $HeartlandHPS_FailCount then we know @@ -1176,9 +1198,10 @@ private function authorizeACH($feed, $submission_data, $form, $entry) //throw new HpsException(wp_sprintf('%s %s', $fraud_message, $issuerResponse)); } - $response = $service->sale($submission_data['payment_amount']) - ->withCheck($check)/**@throws HpsCheckException on error */ - ->execute(); + $response = $check->charge($submission_data['payment_amount']) + ->withCurrency('USD') + ->withAddress($address) + ->execute(); do_action('heartland_gravityforms_transaction_success', $form, $entry, $response, null); $type = 'Payment'; @@ -1201,7 +1224,7 @@ private function authorizeACH($feed, $submission_data, $form, $entry) 'note' => $note, ), ); - } catch (HpsCheckException $e) { + } catch (GatewayException $e) { do_action('heartland_gravityforms_transaction_failure', $form, $entry, $e); $err = null; if (is_array($e->details)) { @@ -1236,7 +1259,7 @@ private function authorizeACH($feed, $submission_data, $form, $entry) $auth = $this->authorization_error($err); $auth['transaction_id'] = (string)$e->transactionId; - } catch (HpsException $e) { + } catch (Exception $e) { do_action('heartland_gravityforms_transaction_failure', $form, $entry, $e); // if advanced fraud is enabled, increment the error count if ($enable_fraud) { @@ -1259,9 +1282,6 @@ private function authorizeACH($feed, $submission_data, $form, $entry) } } - $auth = $this->authorization_error($e->getMessage()); - } catch (Exception $e) { - do_action('heartland_gravityforms_transaction_failure', $form, $entry, $e); $auth = $this->authorization_error($e->getMessage()); } return $auth; @@ -1323,12 +1343,12 @@ public function get_submission_dataACH($feed, $form, $entry) $accountType = rgpost(GF_Field_HPSach::HPS_ACH_TYPE_FIELD_NAME); $checkType = rgpost(GF_Field_HPSach::HPS_ACH_CHECK_FIELD_NAME); $accountTypeOptions = array( - 1 => HpsAccountType::CHECKING, - 2 => HpsAccountType::SAVINGS, + 1 => AccountType::CHECKING, + 2 => AccountType::SAVINGS, ); $checkTypeOptions = array( - 1 => HpsCheckType::PERSONAL, - 2 => HpsCheckType::BUSINESS, + 1 => CheckType::PERSONAL, + 2 => CheckType::BUSINESS, ); if (key_exists($accountType, $accountTypeOptions) && key_exists($checkType, $checkTypeOptions)) { @@ -1415,10 +1435,9 @@ private function authorizeCC($feed, $submission_data, $form, $entry) try { $config = $this->getHpsServicesConfig($this->getSecretApiKey($feed)); - $service = new HpsCreditService($config); - - $cardHolder = $this->buildCardHolder($feed, $submission_data, $entry); - + $cardHolder = $this->cardHolderData($feed, $submission_data, $entry); + $address = $this->buildAddress($feed, $submission_data, $entry); + /** * if fraud_velocity_attempts is less than the $HeartlandHPS_FailCount then we know * far too many failures have been tried @@ -1429,17 +1448,15 @@ private function authorizeCC($feed, $submission_data, $form, $entry) return $this->authorization_error(wp_sprintf('%s %s', $fraud_message, $issuerResponse)); //throw new HpsException(wp_sprintf('%s %s', $fraud_message, $issuerResponse)); } - $response = $this->getSecureSubmitJsResponse(); - $token = new HpsTokenData(); - $token->tokenValue = ($response != null - ? $response->token_value - : ''); - + $tokenValue = $this->getSecureSubmitJsResponse(); + $cardHolder->token = ($tokenValue != null + ? $tokenValue->token_value + : ''); /** * CardHolder Authentication (3D Secure) * */ - $secureEcommerce = null; + $secureEcommerce = ''; if ($this->getEnable3DSecure() === 'yes' && false !== ($data = json_decode(stripslashes($submission_data['securesubmit_cca_data']))) && isset($data) && isset($data->ActionCode) @@ -1471,54 +1488,44 @@ private function authorizeCC($feed, $submission_data, $form, $entry) ? $data->Payment->ExtendedData->XID : ''; - $secureEcommerce = new HpsSecureEcommerce(); + $secureEcommerce = new EcommerceInfo(); $secureEcommerce->type = '3DSecure'; - $secureEcommerce->dataSource = $dataSource; - $secureEcommerce->data = $cavv; - $secureEcommerce->eciFlag = $eciFlag; + $secureEcommerce->paymentDataSource = $dataSource; + $secureEcommerce->cavv = $cavv; + $secureEcommerce->eci = $eciFlag; $secureEcommerce->xid = $xid; } - + + $cpcReq = false; - if ($this->getAllowLevelII()) { + if ($this->getAllowLevelII() === 'yes') { $cpcReq = true; } $currency = GFCommon::get_currency(); $transaction = null; if ($isAuth) { - $transaction = $service->authorize( - $submission_data['payment_amount'], - $currency, - $token, - $cardHolder, - false, - null, - null, - false, - $cpcReq, - null, - null, - $secureEcommerce - ); + $auth_transaction = $cardHolder->authorize($submission_data['payment_amount']) + ->withCurrency($currency) + ->withAddress($address) + ->withAllowDuplicates(true) + ->withCommercialRequest($cpcReq); + if($secureEcommerce){ + $transaction = $auth_transaction->withEcommerceInfo($secureEcommerce); + } + $transaction = $auth_transaction->execute(); } else { - $transaction = $service->charge( - $submission_data['payment_amount'], - $currency, - $token, - $cardHolder, - false, - null, - null, - false, - $cpcReq, - null, - null, - null, - $secureEcommerce - ); + $capt_transaction = $cardHolder->charge($submission_data['payment_amount']) + ->withCurrency($currency) + ->withAddress($address) + ->withAllowDuplicates(true) + ->withCommercialRequest($cpcReq); + if($secureEcommerce){ + $transaction = $capt_transaction->withEcommerceInfo($secureEcommerce); + } + $transaction = $capt_transaction->execute(); } - do_action('heartland_gravityforms_transaction_success', $form, $entry, $transaction, $response); + do_action('heartland_gravityforms_transaction_success', $form, $entry, $transaction, null); self::get_instance()->transaction_response = $transaction; if ($this->getSendEmail() == 'yes') { @@ -1535,27 +1542,29 @@ private function authorizeCC($feed, $submission_data, $form, $entry) $amount_formatted, $transaction->transactionId ); - - if ($cpcReq - && ($transaction->cpcIndicator == 'B' - || $transaction->cpcIndicator == 'R' - || $transaction->cpcIndicator == 'S') + if ($cpcReq && $transaction->commercialIndicator == 'B' + || $transaction->commercialIndicator == 'R' + || $transaction->commercialIndicator == 'S' ) { - $cpcData = new HpsCPCData(); - $cpcData->CardHolderPONbr = $this->getLevelIICustomerPO($feed); + $CardHolderPONbr = $this->getLevelIICustomerPO($feed); if ($this->getLevelIITaxType($feed) == "SALES_TAX") { - $cpcData->TaxType = HpsTaxType::SALES_TAX; + $TaxType = HpsTaxType::SALES_TAX; } elseif ($this->getLevelIITaxType($feed) == "NOTUSED") { - $cpcData->TaxType = HpsTaxType::NOTUSED; + $TaxType = HpsTaxType::NOTUSED; } elseif ($this->getLevelIITaxType($feed) == "TAXEXEMPT") { - $cpcData->TaxType = HpsTaxType::TAXEXEMPT; + $TaxType = HpsTaxType::TAXEXEMPT; } - $cpcData->TaxAmt = $this->getLevelIICustomerTaxAmount($feed); + $TaxAmt = $this->getLevelIICustomerTaxAmount($feed); - if (!empty($cpcData->CardHolderPONbr) && !empty($cpcData->TaxType) && !empty($cpcData->TaxAmt)) { + if (!empty($CardHolderPONbr) && !empty($TaxType) && !empty($TaxAmt)) { $cpcResponse = $service->cpcEdit($transaction->transactionId, $cpcData); + $cpcResponse = $response->edit() + ->withPoNumber($CardHolderPONbr) + ->withTaxType($TaxType) + ->withTaxAmount($TaxAmt) + ->execute(); $note .= sprintf(__(' CPC Response Code: %s', $this->_slug), $cpcResponse->responseCode); } } @@ -1570,12 +1579,12 @@ private function authorizeCC($feed, $submission_data, $form, $entry) 'is_success' => true, 'transaction_id' => $transaction->transactionId, 'amount' => $submission_data['payment_amount'], - 'payment_method' => $response->card_type, + 'payment_method' => $transaction->cardType, 'securesubmit_payment_action' => $this->getAuthorizeOrCharge($feed), 'note' => $note, ), - ); - } catch (HpsException $e) { + ); + } catch (GatewayException $e) { do_action('heartland_gravityforms_transaction_failure', $form, $entry, $e); // if advanced fraud is enabled, increment the error count if ($enable_fraud) { @@ -1660,8 +1669,9 @@ protected function sendEmail($form, $entry, $transaction, $cardHolder = null) * * @return HpsCardHolder|HpsAddress */ - private function buildCardHolder($feed, $submission_data, $entry) + private function cardHolderData($feed, $submission_data, $entry) { + $cardHolder = new CreditCardData(); $firstName = ''; $lastName = ''; if ('' === rgar($submission_data, 'card_name')) { @@ -1676,12 +1686,8 @@ private function buildCardHolder($feed, $submission_data, $entry) } catch (Exception $ex) { $firstName = rgar($submission_data, 'card_name'); } - - $cardHolder = new HpsCardHolder(); $cardHolder->firstName = $firstName; $cardHolder->lastName = $lastName; - $cardHolder->address = $this->buildAddress($feed, $submission_data, $entry); - return $cardHolder; } @@ -1692,10 +1698,9 @@ private function buildCardHolder($feed, $submission_data, $entry) * * @return HpsCheckHolder|HpsAddress */ - private function buildCheckHolder($feed, $submission_data, $entry) + private function checkHolderData($feed, $submission_data, $entry) { - $checkHolder = new HpsCheckHolder(); - $checkHolder->address = $this->buildAddress($feed, $submission_data, $entry); + $checkHolder = new ECheck(); $checkHolder->checkName = htmlspecialchars(rgar($submission_data, 'ach_check_holder')); //'check holder'; $firstName = ''; @@ -1724,7 +1729,7 @@ private function buildCheckHolder($feed, $submission_data, $entry) private function buildAddress($feed, $submission_data, $entry) { $isRecurring = isset($feed['meta']['transactionType']) && $feed['meta']['transactionType'] == 'subscription'; - $address = new HpsAddress(); + $address = new Address(); $address->address = rgar($submission_data, 'address') . rgar($submission_data, 'address2'); @@ -1794,7 +1799,7 @@ public function populateCreditCardLastFour($form) public function includeSecureSubmitSDK() { - require_once plugin_dir_path(__FILE__) . 'includes/Hps.php'; + require_once plugin_dir_path(__FILE__) . 'includes/vendor/autoload.php'; do_action('gform_securesubmit_post_include_api'); } @@ -2166,13 +2171,11 @@ public function get_validation_result($validationResult, $authorizationResult) * @uses GFSecureSubmit::getSecureSubmitJsError() * @uses GFPaymentAddOn::authorization_error() * @uses GFAddOn::log_debug() - * @uses HpsInputValidation::checkAmount * @uses \rgars - * @uses \GFSecureSubmit::getPayPlanService * @uses \GFSecureSubmit::create_customer - * @uses \HpsPayPlanService::addCustomer + * @uses \Customer::addCustomer * @uses \GFSecureSubmit::createPaymentMethod - * @uses \HpsPayPlanService::addPaymentMethod + * @uses \RecurringPaymentMethod::addPaymentMethod * @uses \GFSecureSubmit::create_plan * @uses \HpsPayPlanService::addSchedule * @uses \GFSecureSubmit::processRecurring @@ -2186,6 +2189,7 @@ public function get_validation_result($validationResult, $authorizationResult) */ public function subscribe($feed, $submission_data, $form, $entry) { + /** @var array $subscribResult */ // Include HPS API library. $this->includeSecureSubmitSDK(); @@ -2205,51 +2209,76 @@ public function subscribe($feed, $submission_data, $form, $entry) return $this->authorization_error($userError . 'Currently ACH is not supported for subscriptions'); } - // Prepare payment amount and trial period data. - $payment_amount = HpsInputValidation::checkAmount(rgar($submission_data, 'payment_amount')); + //check amount + $payment_amount = rgar($submission_data, 'payment_amount'); + if ($payment_amount < 0 || $payment_amount === null) { + $this->log_debug(__METHOD__ . '(): Amount error: ' . $this->getSecureSubmitJsError()); + + return $this->authorization_error($userError . 'Invalid amount value.'); + } else { + $payment_amount = preg_replace('/[^0-9\.]/', '', $payment_amount); + $payment_amount = sprintf("%0.2f", round($payment_amount, 3)); + } + + //check setup fee + $setupFeePaymentAmount = rgar($submission_data, 'setup_fee'); + if ($setupFeePaymentAmount < 0 || $setupFeePaymentAmount === null) { + $this->log_debug(__METHOD__ . '(): Set up Fee error: ' . $this->getSecureSubmitJsError()); + + return $this->authorization_error($userError . 'Invalid Set up fee.'); + } else { + $setupFeePaymentAmount = preg_replace('/[^0-9\.]/', '', $setupFeePaymentAmount); + $setupFeePaymentAmount = sprintf("%0.2f", round($setupFeePaymentAmount, 3)); + } + + // Prepare payment amount and trial period data. $setupFeeEnabled = rgar($feed['meta'], 'setupFee_enabled'); $setupFeeField = rgar($feed['meta'], 'setupFee_product'); - $setupFeePaymentAmount = HpsInputValidation::checkAmount(rgar($submission_data, 'setup_fee')); $trialEnabled = rgars($feed, 'meta/trial_enabled'); $trial_period_days = $trialEnabled ? rgars($feed, 'meta/trial_product') : null; $currency = rgar($entry, 'currency'); - + $payPlanCustomer = null; $payPlanPaymentMethod = null; $planSchedule = null; try { - $payPlanService = $this->getPayPlanService($this->getSecretApiKey($feed)); + + $this->getHpsServicesConfig($this->getSecretApiKey($feed)); // while it could be ACH here for the Payplan Customer record it is the same difference // Prepare customer metadata. - $customer = $this->create_customer($feed, $submission_data, $entry); - $this->log_debug(__METHOD__ . '(): Create customer.'); - /** @var HpsPayPlanCustomer $payPlanCustomer */ - $payPlanCustomer = $payPlanService->addCustomer($customer); - - if (null === $payPlanCustomer->customerKey) { + $customer = $this->create_customer($feed, $submission_data, $entry); + $payPlanCustomer = $customer->create(); + + if (null === $payPlanCustomer->key) { $this->log_debug(__METHOD__ . '(): Could not create Pay Plan Customer'); return $this->authorization_error($userError); } $this->log_debug(__METHOD__ . '(): Create payment method.'); - $paymentMethod = $this->createPaymentMethod($payPlanCustomer); - /** @var HpsPayPlanPaymentMethod $payPlanPaymentMethod */ - $payPlanPaymentMethod = $payPlanService->addPaymentMethod($paymentMethod); - - if (null === $payPlanPaymentMethod->paymentMethodKey) { + + $card = new CreditCardData(); + $card->token = $this->getSecureSubmitJsResponse()->token_value; + + /** @var RecurringPaymentMethod $payPlanPaymentMethod */ + $payPlanPaymentMethod = $payPlanCustomer->addPaymentMethod( + $this->getIdentifier('Credit' . $card->token), + $card + )->create(); + + if (null === $payPlanPaymentMethod->key) { $this->log_debug(__METHOD__ . '(): Could not create Pay Plan payment method'); return $this->authorization_error($userError); } // Get HPS plan for feed. - $this->log_debug(__METHOD__ . '(): Create Schedule.'); - /** @var HpsPayPlanSchedule $plan */ - $plan = $this->create_plan( + $this->log_debug(__METHOD__ . '(): Add Schedule.'); + /** @var \RecurringPaymentMethod $plan */ + $planSchedule = $this->create_plan( $payPlanPaymentMethod, $feed, $payment_amount, @@ -2257,14 +2286,8 @@ public function subscribe($feed, $submission_data, $form, $entry) $currency ); - // If error was returned when retrieving plan, return plan. - - /** @var HpsPayPlanSchedule $planSchedule */ - $this->log_debug(__METHOD__ . '(): Add Schedule.'); - $planSchedule = $payPlanService->addSchedule($plan); - // Create the plan unless there is no key. - if (null === $planSchedule->scheduleKey) { + if (null === $planSchedule->key) { $this->log_debug(__METHOD__ . '(): Could not create Pay Plan Schedule'); return $this->authorization_error($userError); @@ -2290,19 +2313,19 @@ public function subscribe($feed, $submission_data, $form, $entry) $subscribResult = array( 'is_success' => true, - 'subscription_id' => $planSchedule->scheduleKey, - 'customer_id' => $customer->customerKey, + 'subscription_id' => $planSchedule->key, + 'customer_id' => $customer->key, 'amount' => $payment_amount, ); // array } catch (Exception $e) { do_action('heartland_gravityforms_transaction_failure', $form, $entry, $e); - $this->rollbackPayPlanResources($payPlanService, $payPlanCustomer, $payPlanPaymentMethod, $planSchedule); + $this->rollbackPayPlanResources($payPlanCustomer, $payPlanPaymentMethod, $planSchedule); // Return authorization error. return $this->authorization_error($userError . $e->getMessage()); } if (!isset($subscribResult)) { - $this->rollbackPayPlanResources($payPlanService, $payPlanCustomer, $payPlanPaymentMethod, $planSchedule); + $this->rollbackPayPlanResources($payPlanCustomer, $payPlanPaymentMethod, $planSchedule); $this->log_debug(__METHOD__ . '(): Unknown error '); return $this->authorization_error($userError); } // if @@ -2353,33 +2376,35 @@ public function cancel($entry, $feed) try { $scheduleKey = gform_get_meta($entry['id'], 'hps_payplan_subscription_id'); - $service = $this->getPayPlanService($this->getSecretApiKey($feed)); - $subscription = $service->getSchedule($scheduleKey); + $this->getHpsServicesConfig($this->getSecretApiKey($feed)); + + $schedule = new Schedule(); + $schedule->key = $scheduleKey; + + $subscription = RecurringService::get($schedule); + // set schedule to inactive - $subscription->scheduleStatus = HpsPayPlanScheduleStatus::INACTIVE; - $service->editSchedule($subscription); + $subscription->status = 'Inactive'; + $subscription->saveChanges(); + return true; - } catch (HpsException $e) { + } catch (\Exception $e) { return false; } } - protected function rollbackPayPlanResources($service, $customer, $paymentMethod, $schedule) + protected function rollbackPayPlanResources($customer, $paymentMethod, $schedule) { - if ($service === null) { - return; - } - if ($schedule !== null) { - $service->deleteSchedule($schedule); + $schedule->delete(); } if ($paymentMethod !== null) { - $service->deletePaymentMethod($paymentMethod); + $paymentMethod->delete(); } if ($customer !== null) { - $service->deleteCustomer($customer); + $customer->delete(); } } @@ -2391,26 +2416,16 @@ protected function rollbackPayPlanResources($service, $customer, $paymentMethod, * @param $payPlanPaymentMethod * @param $planSchedule * - * @return array|\HpsBuilderAbstract|\HpsReportTransactionDetails|\HpsReportTransactionSummary|\HpsTransaction|mixed|null + * @return array|\Transaction|mixed|null */ private function processRecurring($payment_amount, $feed, $payPlanPaymentMethod, $planSchedule) { - static $creditService = null; - - if (null === $creditService) { - $creditService = new HpsFluentCreditService($this->getHpsServicesConfig($this->getSecretApiKey($feed))); - } - - $details = new HpsTransactionDetails(); - $details->customerId = $payPlanPaymentMethod->customerIdentifier; - return $creditService - ->recurring() - ->withAmount($payment_amount) - ->withPaymentMethodKey($payPlanPaymentMethod->paymentMethodKey) - ->withSchedule($planSchedule->scheduleKey) - ->withDetails($details) - ->execute(); + return $payPlanPaymentMethod->charge($payment_amount) + ->withCurrency(GFCommon::get_currency()) + ->withScheduleId($planSchedule->key) + ->withOneTimePayment(false) + ->execute(); } /** @@ -2421,92 +2436,39 @@ private function processRecurring($payment_amount, $feed, $payPlanPaymentMethod, * * @used-by GFSecureSubmit::subscribe() * @uses GFAddOn::log_debug() - * @uses \GFSecureSubmit::buildCardHolder + * @uses \GFSecureSubmit::CardHolderData * @uses \GFSecureSubmit::getIdentifier * * @param array $feed The feed currently being processed. * @param array $submission_data * @param array $entry The entry currently being processed. * - * @return \HpsPayPlanCustomer The HPS customer object. + * @return Customer The Customer object. * @internal param array $customer_meta The customer properties. * @internal param array $form The form which created the current entry. * */ private function create_customer($feed, $submission_data, $entry) { - $acctHolder = $this->buildCardHolder($feed, $submission_data, $entry); - $meta = $this->get_address_card_field($feed); - //'United States' 'Canada' - - /** @noinspection PhpUndefinedFieldInspection */ - $acctHolder->address->country = $this->normalizeCountry($acctHolder->address->country, true); - - // Convert states names to abbreviations - $acctHolder->address->state = $this->normalizeState($acctHolder->address->state); - - // Log the customer to be created. - $this->log_debug(__METHOD__ . '(): Customer meta to be created => ' . print_r($acctHolder, 1)); - + $acctHolder = $this->cardHolderData($feed, $submission_data, $entry); + $address = $this->buildAddress($feed, $submission_data, $entry); + /** @var string $modifier This value helps semi uniqely identify the customer */ $modifier = $this->getSecureSubmitJsResponse()->last_four . $this->getSecureSubmitJsResponse()->card_type; - - $customer = new HpsPayPlanCustomer(); - $customer->customerIdentifier = $this->getIdentifier($modifier . $acctHolder->firstName . $acctHolder->lastName); + + $customer = new Customer(); + $customer->id = $this->getIdentifier($modifier . $acctHolder->firstName . $acctHolder->lastName); $customer->firstName = $acctHolder->firstName; $customer->lastName = $acctHolder->lastName; - $customer->primaryEmail = rgar($submission_data, 'email'); - $customer->customerStatus = HpsPayPlanCustomerStatus::ACTIVE; - $customer->addressLine1 = $acctHolder->address->address; - $customer->city = $acctHolder->address->city; - $customer->stateProvince = $acctHolder->address->state; - $customer->zipPostalCode = $acctHolder->address->zip; - /** @noinspection PhpUndefinedFieldInspection */ - $customer->country = $acctHolder->address->country; - + $customer->status = 'Active'; + $customer->email = rgar($submission_data, 'email'); + $customer->address = $address; + + // Log the customer to be created. + $this->log_debug(__METHOD__ . '(): Customer meta to be created => ' . print_r($customer, 1)); + return $customer; - } - - /** - * Retrieve a specific customer from HPS. - * - * @since Unknown - * @access protected - * - * @used-by GFSecureSubmit::subscribe() - * @uses GFAddOn::log_debug() - * @uses HpsPayPlanService::getCustomer() - * @uses \GFSecureSubmit::getSecureSubmitJsResponse - * @uses \GFSecureSubmit::getIdentifier - * - * @param array $submission_data - * @param HpsPayPlanCustomer $customer - * - * @return bool|\HpsPayPlanPaymentMethod Contains customer data if available. Otherwise, false. - * - * @internal param \HpsPayPlanService $payPlanService - */ - private function createPaymentMethod($customer) - { - $paymentMethod = null; - $acct = $this->getSecureSubmitJsResponse()->token_value; - - if (!empty($acct)) { - $paymentMethod = new HpsPayPlanPaymentMethod(); - $paymentMethod->paymentMethodIdentifier = $this->getIdentifier('Credit' . $acct); - $paymentMethod->nameOnAccount = $customer->firstName . ' ' . $customer->lastName; - /** @noinspection PhpUndefinedFieldInspection */ - $paymentMethod->firstName = $customer->firstName; - $paymentMethod->lastName = $customer->lastName; - $paymentMethod->country = $customer->country; - $paymentMethod->zipPostalCode = $customer->zipPostalCode; - $paymentMethod->customerKey = $customer->customerKey; - $paymentMethod->paymentMethodType = HpsPayPlanPaymentMethodType::CREDIT_CARD; - $paymentMethod->paymentToken = $acct; - } - - return $paymentMethod; - } + } /** * Create and return a HPS plan with the specified properties. @@ -2516,15 +2478,12 @@ private function createPaymentMethod($customer) * * @used-by GFSecureSubmit::subscribe() * @uses \GFSecureSubmit::getIdentifier - * @uses \GFSecureSubmit::getPayPlanService * @uses \GFSecureSubmit::getSecretApiKey - * @uses HpsInputValidation::checkAmount * @uses \GFSecureSubmit::validPayPlanCycle - * @uses HpsPayPlanSchedule - * @uses HpsPayPlanAmount + * @uses Schedule * @uses GFAddOn::log_debug() * - * @param HpsPayPlanPaymentMethod $plan The plan ID. + * @param RecurringPaymentMethod $plan The plan ID. * @param array $feed The feed currently being processed. * @param float|int $payment_amount The recurring amount. * @param string $customerKey The Custyomer ID used by HPS. @@ -2537,77 +2496,51 @@ private function create_plan( $plan, $feed, $payment_amount, - $trial_period_days = 0 + $trial_period_days = 0, + $currency ) { - // Log the plan to be created. - $this->log_debug(__METHOD__ . '(): Plan to be created => ' . print_r(func_get_args(), 1)); - //(HpsPayPlanService $service, $customerKey, $paymentMethodKey, $amount) - $schedule = new HpsPayPlanSchedule(); - $schedule->scheduleIdentifier = $this->getIdentifier($feed['meta']['feedName'] . $plan->paymentMethodKey); - $schedule->customerKey = $plan->customerKey; - $schedule->scheduleStatus = HpsPayPlanScheduleStatus::ACTIVE; - $schedule->paymentMethodKey = $plan->paymentMethodKey; - $schedule->subtotalAmount = new HpsPayPlanAmount(HpsInputValidation::checkAmount($payment_amount) * 100); - $schedule->totalAmount = new HpsPayPlanAmount(HpsInputValidation::checkAmount($payment_amount)); - $schedule->frequency = $this->validPayPlanCycle($feed); - - /*Conditional; Required if Frequency is Monthly, Bi-Monthly, Quarterly, Semi-Annually.*/ - if (!in_array($schedule->frequency, array( - HpsPayPlanScheduleFrequency::WEEKLY, - HpsPayPlanScheduleFrequency::BIWEEKLY, - HpsPayPlanScheduleFrequency::SEMIMONTHLY, - HpsPayPlanScheduleFrequency::ANNUALLY - ))) { - $schedule->processingDateInfo = date("d", strtotime(date('d-m-Y'))); - } - - $schedule->startDate = $this->getStartDateInfo($schedule->frequency, $trial_period_days); - - if (HpsPayPlanScheduleFrequency::SEMIMONTHLY === $schedule->frequency) { - $schedule->processingDateInfo = "Last"; - } - - $numberOfPayments = $feed['meta']['recurringTimes'] === '0' - ? HpsPayPlanScheduleDuration::ONGOING - : HpsPayPlanScheduleDuration::LIMITED_NUMBER; - $schedule->duration = $numberOfPayments; - $schedule->reprocessingCount = 1; - - if ($numberOfPayments !== HpsPayPlanScheduleDuration::ONGOING) { - $schedule->numberOfPayments = intval($feed['meta']['recurringTimes']); - - if ($trial_period_days != null && $trial_period_days != 0) { - $schedule->numberOfPayments = $schedule->numberOfPayments - 1; - } - } + $frequency = $this->validPayPlanCycle($feed); + $startDate = $this->getStartDateInfo($frequency, $trial_period_days); + $startDate = \DateTime::createFromFormat('Ymd', $startDate); + + $scheduleResponse = $plan->addSchedule( + $this->getIdentifier($feed['meta']['feedName'] . $plan->key) + ) + ->withStatus('Active') + ->withCurrency($currency) + ->withAmount($payment_amount) + ->withStartDate($startDate) + ->withFrequency($frequency) + ->withReprocessingCount(1) + ->create(); - return $schedule; + return $scheduleResponse; } /** Takes subscription billing cycle and returns a valid payplan cycle * * @used-by \GFSecureSubmit::create_plan - * @uses HpsPayPlanScheduleFrequency + * @uses ScheduleFrequency * @uses GFAddOn::log_debug() * * @param array $feed * * @return null|string - * @throws \HpsArgumentException + * @throws \ArgumentException */ private function validPayPlanCycle($feed) { $this->log_debug(__METHOD__ . '(): Plan to be created => ' . print_r($feed, 1)); $this->includeSecureSubmitSDK(); - $oClass = new ReflectionClass('HpsPayPlanScheduleFrequency'); + $oClass = new ReflectionClass('GlobalPayments\Api\Entities\Enums\ScheduleFrequency'); $array = $oClass->getConstants(); $cycle = rgar($array, $feed['meta']['billingCycle']); if (null == $cycle) { $this->log_debug(__METHOD__ . '(): Billing Cycle Error => ' . print_r($feed, 1)); - throw new HpsArgumentException( + throw new ArgumentException( 'Invalid period for subscription. Please check settings and try again', - HpsExceptionCodes::INVALID_CONFIGURATION + ExceptionCodes::INVALID_CONFIGURATION ); } $this->log_debug(__METHOD__ . '(): Billing Cycle Calculated => ' . $cycle); @@ -2620,44 +2553,44 @@ private function validPayPlanCycle($feed) * @param int $trial_period_days * * @return bool|string - * @throws \HpsArgumentException + * @throws \ArgumentException */ private function getStartDateInfo($frequency, $trial_period_days) { if ($trial_period_days*1 !== 0) { - $period = date('mdY', strtotime('+' . ($trial_period_days * 1) . ' days')); + $period = date('Ymd', strtotime('+' . ($trial_period_days * 1) . ' days')); } else { switch ($frequency) { - case HpsPayPlanScheduleFrequency::WEEKLY: - $period = date('mdY', strtotime('+1 week')); + case ScheduleFrequency::WEEKLY: + $period = date('Ymd', strtotime('+1 week')); break; - case HpsPayPlanScheduleFrequency::BIWEEKLY: + case ScheduleFrequency::BI_WEEKLY: $period = date('mdY', strtotime('+2 week')); break; - case HpsPayPlanScheduleFrequency::SEMIMONTHLY: + case ScheduleFrequency::SEMI_MONTHLY: if (intval(date('d', strtotime('+15 day'))) < 15) { $period = date('m15Y', strtotime('+15 day')); } else { $period = date('mtY', strtotime('+15 day')); } break; - case HpsPayPlanScheduleFrequency::MONTHLY: - $period = date('mdY', strtotime('+1 month')); + case ScheduleFrequency::MONTHLY: + $period = date('Ymd', strtotime('+1 month')); break; - case HpsPayPlanScheduleFrequency::QUARTERLY: - $period = date('mdY', strtotime('+3 month')); + case ScheduleFrequency::QUARTERLY: + $period = date('Ymd', strtotime('+3 month')); break; - case HpsPayPlanScheduleFrequency::SEMIANNUALLY: - $period = date('mdY', strtotime('+6 month')); + case ScheduleFrequency::SEMI_ANNUALLY: + $period = date('Ymd', strtotime('+6 month')); break; - case HpsPayPlanScheduleFrequency::ANNUALLY: - $period = date('mdY', strtotime('+1 year')); + case ScheduleFrequency::ANNUALLY: + $period = date('Ymd', strtotime('+1 year')); break; default: $this->log_debug(__METHOD__ . '(): Billing Cycle Error => ' . print_r($frequency, 1)); - throw new HpsArgumentException( + throw new ArgumentException( 'Invalid period for subscription. Please check settings and try again', - HpsExceptionCodes::INVALID_CONFIGURATION + ExceptionCodes::INVALID_CONFIGURATION ); } } @@ -2686,25 +2619,13 @@ private function getHpsServicesConfig($key) { static $config = null; if (empty($config)) { - $config = new HpsServicesConfig(); + $config = new ServicesConfig(); $config->secretApiKey = $key; - $config->developerId = '002914'; - $config->versionNumber = '1916'; - } - - return $config; - } - - /** - * @param string $key - * - * @return \HpsPayPlanService|null - */ - private function getPayPlanService($key) - { - static $service = null; - if (empty($service)) { - $service = new HpsPayPlanService($this->getHpsServicesConfig($key)); + $env = $config->environment; + $config->serviceUrl = ($env != "TEST")? + 'https://api2.heartlandportico.com': + 'https://cert.api2.heartlandportico.com'; + $service = ServicesContainer::configure($config); } return $service; @@ -2719,7 +2640,7 @@ public function supported_billing_intervals() //authorize.net does not use years or weeks, override framework function $this->includeSecureSubmitSDK(); - $oClass = new ReflectionClass('HpsPayPlanScheduleFrequency'); + $oClass = new ReflectionClass('ScheduleFrequency'); $array = $oClass->getConstants(); $billing_cycles = array(); foreach ($array as $const => $value) { diff --git a/classes/includes/Hps.php b/classes/includes/Hps.php deleted file mode 100644 index 9be1e5f..0000000 --- a/classes/includes/Hps.php +++ /dev/null @@ -1,211 +0,0 @@ -= 5.5.9" + }, + "require-dev": { + "brianium/paratest": "dev-master", + "phpstan/phpstan-shim": "^0.8.4", + "phpunit/phpunit": "~5.0", + "squizlabs/php_codesniffer": "2.*" + }, + "type": "library", + "autoload": { + "psr-4": { + "GlobalPayments\\Api\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "Heartland Payment Systems" + } + ], + "description": "PHP SDK for processing payments with Global Payments, including Heartland Payment Systems and Realex Payments", + "homepage": "https://developer.heartlandpaymentsystems.com/documentation", + "time": "2019-10-03T15:15:47+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "1.1.0" +} diff --git a/classes/includes/src/Abstractions/HpsAltPaymentServiceInterface.php b/classes/includes/src/Abstractions/HpsAltPaymentServiceInterface.php deleted file mode 100644 index f4d754e..0000000 --- a/classes/includes/src/Abstractions/HpsAltPaymentServiceInterface.php +++ /dev/null @@ -1,158 +0,0 @@ - - * @license https://github.com/hps/heartland-php/blob/master/LICENSE.txt Custom - * @link https://github.com/hps/heartland-php - */ - -/** - * AltPayment Service Interface - * - * @category PHP - * @package HPS - * @author Heartland Payment Systems - * @license https://github.com/hps/heartland-php/blob/master/LICENSE.txt Custom - * @link https://github.com/hps/heartland-php - */ -interface HpsAltPaymentServiceInterface -{ - /** - * Creates an authorization - * - * @param string $orderId order id from gateway - * @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 $lineItems line items from order - * @param HpsOrderData $orderData gateway/processor specific - * data - * - * @return object - */ - public function authorize( - $orderId, - $amount, - $currency, - HpsBuyerData $buyer = null, - HpsPaymentData $payment = null, - HpsShippingInfo $shippingAddress = null, - $lineItems = null, - HpsOrderData $orderData = null - ); - - /** - * Captures an authorization - * - * @param string $orderId order id from gateway - * @param mixed $amount amount to be authorized - * @param HpsOrderData $orderData gateway/processor specific data - * - * @return object - */ - public function capture( - $orderId, - $amount, - HpsOrderData $orderData = null - ); - - /** - * Creates a new AltPayment session - * - * @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 $lineItems line items from order - * @param HpsOrderData $orderData gateway/processor specific - * data - * - * @return object - */ - public function createSession( - $amount, - $currency, - HpsBuyerData $buyer = null, - HpsPaymentData $payment = null, - HpsShippingInfo $shippingAddress = null, - $lineItems = null, - HpsOrderData $orderData = null - ); - - /** - * Refunds a transaction - * - * @param string $orderId order id from gateway - * @param boolean $isPartial flag for partial refund - * @param string $partialAmount partial amount to be refunded - * @param HpsOrderData $orderData gateway/processor specific data - * - * @return object - */ - public function refund( - $orderId, - $isPartial = false, - $partialAmount = null, - HpsOrderData $orderData = null - ); - - /** - * Creates an authorization - * - * @param string $orderId order id from gateway - * @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 $lineItems line items from order - * @param HpsOrderData $orderData gateway/processor specific - * data - * - * @return object - */ - public function sale( - $orderId, - $amount, - $currency, - HpsBuyerData $buyer = null, - HpsPaymentData $payment = null, - HpsShippingInfo $shippingAddress = null, - $lineItems = null, - HpsOrderData $orderData = null - ); - - /** - * Voids a transaction - * - * @param string $orderId order id from gateway - * @param HpsOrderData $orderData gateway/processor specific data - * - * @return object - */ - public function void( - $orderId, - HpsOrderData $orderData = null - ); - - /** - * Gets information about a session - * - * @param string $orderId order id from gateway - * @param HpsOrderData $orderData gateway/processor specific data - * - * @return object - */ - public function sessionInfo( - $orderId, - HpsOrderData $orderData = null - ); -} diff --git a/classes/includes/src/Abstractions/HpsBuilderAbstract.php b/classes/includes/src/Abstractions/HpsBuilderAbstract.php deleted file mode 100644 index 7e2c74f..0000000 --- a/classes/includes/src/Abstractions/HpsBuilderAbstract.php +++ /dev/null @@ -1,173 +0,0 @@ -service = $service; - } - - /** - * @return HpsBuilderAbstract - */ - public function execute() - { - foreach ($this->builderActions as $action) { - call_user_func_array($action->action, $action->arguments); - } - $this->validate(); - $this->executed = true; - return $this; - } - /** - * @param $action - * - * @return \HpsBuilderAbstract - */ - public function addAction($action) - { - $this->builderActions[] = $action; - return $this; - } - - /** - * @throws HpsException - */ - public function checkStatus() - { - if (!$this->executed) { - throw new HpsException('Builder actions not executed'); - } - } - - /** - * Allows for automatic setter functions - * in child classes. - * - * @param string $name - * @param array $args - * - * @throws HpsUnknownPropertyException - * - * @return HpsBuilderAbstract - */ - public function __call($name, array $args) - { - switch (true) { - case substr($name, 0, 4) == 'with': - $property = substr($name, 4); - $property = strtolower(substr($property, 0, 1)) . substr($property, 1); - $this->setPropertyIfExists($property, $args[0]); - break; - default: - return false; - break; - } - return $this; - } - - /** - * @throws Exception - */ - protected function validate() - { - $actions = $this->compileActionCounts(); - foreach ($this->validations as $validation) { - $result = call_user_func_array($validation['callback'], array($actions)); - if (!$result) { - $class = $validation['exceptionType']; - throw new $class($validation['exceptionMessage'], 0); - } - } - } - - /** - * @return array - */ - protected function compileActionCounts() - { - $counts = array(); - - foreach ($this->builderActions as $action) { - $counts[$action->name] = isset($counts[$action->name]) ? $counts[$action->name]+1 : 1; - } - - return $counts; - } - - /** - * @param callable $callback - * @param string $exceptionType - * @param string $exceptionMessage - * - * @return HpsBuilderAbstract - */ - protected function addValidation($callback, $exceptionType, $exceptionMessage = '') - { - $this->validations[] = array( - 'callback' => $callback, - 'exceptionType' => $exceptionType, - 'exceptionMessage' => $exceptionMessage, - ); - return $this; - } - - /** - * Sets a property if it exists on the current object. - * - * @param string $property - * @param mixed $value - * - * @throws HpsUnknownPropertyException - * - * @return null - */ - private function setPropertyIfExists($property, $value) - { - if (property_exists($this, $property)) { - if ($value == null) { - return $this; - } - - $action = new HpsBuilderAction($property, array($this, 'setProperty')); - $action->arguments = array($property, $value); - $this->addAction($action); - } else { - throw new HpsUnknownPropertyException($this, $property); - } - return $this; - } - - /** - * Sets a property on the current object. - * - * @param string $property - * @param mixed $value - * - * @return null - */ - protected function setProperty($property, $value) - { - $this->{$property} = $value; - } -} diff --git a/classes/includes/src/Abstractions/HpsConfigInterface.php b/classes/includes/src/Abstractions/HpsConfigInterface.php deleted file mode 100644 index 8d7ff5d..0000000 --- a/classes/includes/src/Abstractions/HpsConfigInterface.php +++ /dev/null @@ -1,24 +0,0 @@ -_config = $config; - } - } - /** - * @return \HpsConfigInterface|null - */ - public function servicesConfig() - { - return $this->_config; - } - /** - * @param $value - */ - public function setServicesConfig($value) - { - $this->_config = $value; - } - /** - * @param $url - * @param $headers - * @param null $data - * @param string $httpVerb - * @param string $keyType - * @param null $options - * - * @return mixed - * @throws \HpsAuthenticationException - * @throws \HpsGatewayException - */ - 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 - ); - } - } - /** - * @return bool - */ - protected function _isConfigInvalid() - { - if ($this->_config == null && ( - $this->_config->secretApiKey == null || - $this->_config->userName == null || - $this->_config->password == null || - $this->_config->licenseId == -1 || - $this->_config->deviceId == -1 || - $this->_config->siteId == -1) - ) { - return true; - } - return false; - } -} diff --git a/classes/includes/src/Abstractions/HpsGatewayServiceInterface.php b/classes/includes/src/Abstractions/HpsGatewayServiceInterface.php deleted file mode 100644 index aad3b3a..0000000 --- a/classes/includes/src/Abstractions/HpsGatewayServiceInterface.php +++ /dev/null @@ -1,23 +0,0 @@ -Transaction->$txnType; - - $auth = parent::fromDict($rsp, $txnType, $returnType); - - $auth->status = isset($authorize->Status) ? (string)$authorize->Status : null; - $auth->statusMessage = isset($authorize->StatusMessage) ? (string)$authorize->StatusMessage : null; - - return $auth; - } -} diff --git a/classes/includes/src/Entities/AltPayment/HpsAltPaymentCapture.php b/classes/includes/src/Entities/AltPayment/HpsAltPaymentCapture.php deleted file mode 100644 index ab04568..0000000 --- a/classes/includes/src/Entities/AltPayment/HpsAltPaymentCapture.php +++ /dev/null @@ -1,28 +0,0 @@ -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; - } -} diff --git a/classes/includes/src/Entities/AltPayment/HpsAltPaymentCreateSession.php b/classes/includes/src/Entities/AltPayment/HpsAltPaymentCreateSession.php deleted file mode 100644 index c5b1bd9..0000000 --- a/classes/includes/src/Entities/AltPayment/HpsAltPaymentCreateSession.php +++ /dev/null @@ -1,31 +0,0 @@ -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; - } -} diff --git a/classes/includes/src/Entities/AltPayment/HpsAltPaymentResponse.php b/classes/includes/src/Entities/AltPayment/HpsAltPaymentResponse.php deleted file mode 100644 index fb26d9c..0000000 --- a/classes/includes/src/Entities/AltPayment/HpsAltPaymentResponse.php +++ /dev/null @@ -1,45 +0,0 @@ -Transaction->$txnType; - - $altPayment = parent::fromDict($rsp, $txnType, $returnType); - - if ($response->RspCode != 0) { - $error = self::nvpToArray($response->Processor->Response); - $altPayment->error = new HpsProcessorError(); - $altPayment->error->code = isset($error['Code']) ? $error['Code'] : null; - $altPayment->error->message = isset($error['Message']) ? $error['Message'] : null; - $altPayment->error->type = isset($error['Type']) ? $error['Type'] : null; - } - - return $altPayment; - } - /** - * @param $pairs - * - * @return array - */ - public static function nvpToArray($pairs) - { - $array = array(); - foreach ($pairs->NameValuePair as $pair) { - $array[(string)$pair->Name] = (string)$pair->Value; - } - return $array; - } -} diff --git a/classes/includes/src/Entities/AltPayment/HpsAltPaymentReturn.php b/classes/includes/src/Entities/AltPayment/HpsAltPaymentReturn.php deleted file mode 100644 index 0ceb506..0000000 --- a/classes/includes/src/Entities/AltPayment/HpsAltPaymentReturn.php +++ /dev/null @@ -1,8 +0,0 @@ -Transaction->$txnType; - - $sale = parent::fromDict($rsp, $txnType, $returnType); - - $sale->status = isset($charge->Status) ? (string)$charge->Status : null; - $sale->statusMessage = isset($charge->StatusMessage) ? (string)$charge->StatusMessage : null; - - return $sale; - } -} diff --git a/classes/includes/src/Entities/AltPayment/HpsAltPaymentSessionInfo.php b/classes/includes/src/Entities/AltPayment/HpsAltPaymentSessionInfo.php deleted file mode 100644 index 7ed8415..0000000 --- a/classes/includes/src/Entities/AltPayment/HpsAltPaymentSessionInfo.php +++ /dev/null @@ -1,72 +0,0 @@ -Transaction->$txnType; - $buyer = self::nvpToArray($sessionInfo->Buyer); - $payment = self::nvpToArray($sessionInfo->Payment); - $shipping = self::nvpToArray($sessionInfo->Shipping->Address); - $lineItems = self::nvpToArray($sessionInfo->LineItem->Detail); - - $session = parent::fromDict($rsp, $txnType, $returnType); - $session->status = isset($sessionInfo->Status) ? (string)$sessionInfo->Status : null; - - $session->buyer = new HpsBuyerData(); - $session->buyer->emailAddress = isset($buyer['EmailAddress']) ? $buyer['EmailAddress'] : null; - $session->buyer->payerId = isset($buyer['BuyerId']) ? $buyer['BuyerId'] : null; - $session->buyer->status = isset($buyer['Status']) ? $buyer['Status'] : null; - $session->buyer->countryCode = isset($buyer['CountryCode']) ? $buyer['CountryCode'] : null; - $session->buyer->firstName = isset($buyer['FirstName']) ? $buyer['FirstName'] : null; - $session->buyer->lastName = isset($buyer['LastName']) ? $buyer['LastName'] : null; - - $session->shipping = new HpsShippingInfo(); - $session->shipping->name = isset($shipping['ShipName']) ? $shipping['ShipName'] : null; - $session->shipping->address = new HpsAddress(); - $session->shipping->address->address = isset($shipping['ShipAddress']) ? $shipping['ShipAddress'] : null; - $session->shipping->address->city = isset($shipping['ShipCity']) ? $shipping['ShipCity'] : null; - $session->shipping->address->state = isset($shipping['ShipState']) ? $shipping['ShipState'] : null; - $session->shipping->address->zip = isset($shipping['ShipZip']) ? $shipping['ShipZip'] : null; - $session->shipping->address->country = isset($shipping['ShipCountryCode']) ? $shipping['ShipCountryCode'] : null; - - $session->payment = new HpsPaymentData(); - $session->payment->subtotal = isset($payment['ItemAmount']) ? $payment['ItemAmount'] : null; - $session->payment->shippingAmount = isset($payment['ShippingAmount']) ? $payment['ShippingAmount'] : null; - $session->payment->taxAmount = isset($payment['TaxAmount']) ? $payment['TaxAmount'] : null; - - $session->lineItems = array(); - $lineItem = new HpsLineitem(); - $lineItem->name = isset($lineItems['Name']) ? $lineItems['Name'] : null; - $lineItem->amount = isset($lineItems['Amount']) ? $lineItems['Amount'] : null; - $lineItem->number = isset($lineItems['Number']) ? $lineItems['Number'] : null; - $lineItem->quantity = isset($lineItems['Quantity']) ? $lineItems['Quantity'] : null; - $lineItem->taxAmount = isset($lineItems['TaxAmount']) ? $lineItems['TaxAmount'] : null; - - return $session; - } -} diff --git a/classes/includes/src/Entities/AltPayment/HpsAltPaymentVoid.php b/classes/includes/src/Entities/AltPayment/HpsAltPaymentVoid.php deleted file mode 100644 index e111583..0000000 --- a/classes/includes/src/Entities/AltPayment/HpsAltPaymentVoid.php +++ /dev/null @@ -1,8 +0,0 @@ -authenticateMethod = self::readDataKey($data, 'AuthenticateMethod'); - $response->authorizationCode = self::readDataKey($data, 'AuthorizationCode'); - $response->cardBin = self::readDataKey($data, 'CardBin'); - $response->cardEnrollmentMethod = self::readDataKey($data, 'CardEnrollmentMethod'); - $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->cardTypeName = self::readDataKey($data, 'CardTypeName'); - $response->longAccessToken = self::readDataKey($data, 'LongAccessToken'); - $response->mastercardAssignedId = self::readDataKey($data, 'MasterCardAssignedId'); - $response->nameOnCard = self::readDataKey($data, 'NameOnCard'); - $response->paResStatus = self::readDataKey($data, 'PaResStatus'); - $response->payPassWalletIndicator = self::readDataKey($data, 'PayPassWalletIndicator'); - $response->paymentProcessorOrderNumber = self::readDataKey($data, 'PaymentProcessorOrderNumber'); - $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'); - $response->processorSignatureVerification = self::readDataKey($data, 'ProcessorSignatureVerification'); - $response->processorXid = self::readDataKey($data, 'ProcessorXid'); - $response->rewardExpMonth = self::readDataKey($data, 'RewardExpMonth'); - $response->rewardExpYear = self::readDataKey($data, 'RewardExpYear'); - $response->rewardId = self::readDataKey($data, 'RewardId'); - $response->rewardName = self::readDataKey($data, 'RewardName'); - $response->rewardNumber = self::readDataKey($data, 'RewardNumber'); - $response->scEnrollmentStatus = self::readDataKey($data, 'ScEnrollmentStatus'); - $response->signatureVerification = self::readDataKey($data, 'SignatureVerification'); - return $response; - } -} \ No newline at end of file diff --git a/classes/includes/src/Entities/AltPayment/HpsCardinalMPIAuthorizeResponse.php b/classes/includes/src/Entities/AltPayment/HpsCardinalMPIAuthorizeResponse.php deleted file mode 100644 index e99f987..0000000 --- a/classes/includes/src/Entities/AltPayment/HpsCardinalMPIAuthorizeResponse.php +++ /dev/null @@ -1,82 +0,0 @@ -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; - } -} \ No newline at end of file diff --git a/classes/includes/src/Entities/AltPayment/HpsCardinalMPIAuthresponseResponse.php b/classes/includes/src/Entities/AltPayment/HpsCardinalMPIAuthresponseResponse.php deleted file mode 100644 index 1d519ab..0000000 --- a/classes/includes/src/Entities/AltPayment/HpsCardinalMPIAuthresponseResponse.php +++ /dev/null @@ -1,18 +0,0 @@ -acsUrl = self::readDataKey($data, 'ACSUrl'); - $response->enrolled = self::readDataKey($data, 'Enrolled'); - $response->payload = self::readDataKey($data, 'Payload'); - $response->processorTransactionIdPairing = self::readDataKey($data, 'ProcessorTransactionIdPairing'); - return $response; - } -} \ No newline at end of file diff --git a/classes/includes/src/Entities/AltPayment/HpsCardinalMPIPreapprovalResponse.php b/classes/includes/src/Entities/AltPayment/HpsCardinalMPIPreapprovalResponse.php deleted file mode 100644 index 86a4fc0..0000000 --- a/classes/includes/src/Entities/AltPayment/HpsCardinalMPIPreapprovalResponse.php +++ /dev/null @@ -1,25 +0,0 @@ -longAccessToken = self::readDataKey($data, 'LongAccessToken'); - $response->preCheckoutData = isset($data->PrecheckoutData) ? simplexml_load_string($data->PrecheckoutData)->PrecheckoutData : null; - $response->preCheckoutTransactionId = self::readDataKey($data, 'PrecheckoutTransactionId'); - return $response; - } -} \ No newline at end of file diff --git a/classes/includes/src/Entities/AltPayment/HpsCardinalMPIRefundResponse.php b/classes/includes/src/Entities/AltPayment/HpsCardinalMPIRefundResponse.php deleted file mode 100644 index 5b51803..0000000 --- a/classes/includes/src/Entities/AltPayment/HpsCardinalMPIRefundResponse.php +++ /dev/null @@ -1,18 +0,0 @@ -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 $key - * - * @return null|string - */ - public static function readDataKey($data, $key) - { - return isset($data->{$key}) ? (string)$data->{$key} : null; - } -} \ No newline at end of file diff --git a/classes/includes/src/Entities/AltPayment/HpsCardinalMPIVoidResponse.php b/classes/includes/src/Entities/AltPayment/HpsCardinalMPIVoidResponse.php deleted file mode 100644 index 18a8d66..0000000 --- a/classes/includes/src/Entities/AltPayment/HpsCardinalMPIVoidResponse.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @license https://github.com/hps/heartland-php/blob/master/LICENSE.txt Custom - * @link https://github.com/hps/heartland-php - */ - -/** - * Order Data - * - * @category PHP - * @package HPS - * @author Heartland Payment Systems - * @license https://github.com/hps/heartland-php/blob/master/LICENSE.txt Custom - * @link https://github.com/hps/heartland-php - */ -class HpsOrderData -{ - public $transactionStatus = null; - public $currencyCode = null; - public $orderId = null; - public $orderNumber = null; - public $transactionMode = 'S'; - public $ipAddress = null; - public $browserHeader = null; - public $userAgent = null; - public $originUrl = null; - public $termUrl = null; - public $checkoutType = null; - public $pairingToken = null; - public $pairingVerifier = null; -} \ No newline at end of file diff --git a/classes/includes/src/Entities/AltPayment/HpsPaymentData.php b/classes/includes/src/Entities/AltPayment/HpsPaymentData.php deleted file mode 100644 index 249a821..0000000 --- a/classes/includes/src/Entities/AltPayment/HpsPaymentData.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @license https://github.com/hps/heartland-php/blob/master/LICENSE.txt Custom - * @link https://github.com/hps/heartland-php - */ - -/** - * Order Data - * - * @category PHP - * @package HPS - * @author Heartland Payment Systems - * @license https://github.com/hps/heartland-php/blob/master/LICENSE.txt Custom - * @link https://github.com/hps/heartland-php - */ -class HpsPaymentData -{ - /** @var double|null */ - public $subtotal = null; - - /** @var double|null */ - public $shippingAmount = null; - - /** @var double|null */ - public $taxAmount = null; - - /** @var string|null */ - public $paymentType = null; - - /** @var string|null */ - public $invoiceNumber = null; -} diff --git a/classes/includes/src/Entities/AltPayment/HpsShippingInfo.php b/classes/includes/src/Entities/AltPayment/HpsShippingInfo.php deleted file mode 100644 index d5da7e3..0000000 --- a/classes/includes/src/Entities/AltPayment/HpsShippingInfo.php +++ /dev/null @@ -1,28 +0,0 @@ -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 string $name - * @param float|string|int $value Never a Bool - * @throws HpsArgumentException - */ - public function __set($name, $value) - { - if (!$value instanceof stdClass) { - if (!property_exists(__CLASS__, $name)) { - $value = null; - } - switch ($name) { - case 'height': - case 'width': - case 'attachmentDataId': - $validator = FILTER_SANITIZE_NUMBER_INT; - break; - default: - $validator = FILTER_SANITIZE_STRING; - } - $value = filter_var($value, $validator); - - if ($name === 'attachmentFormat' && preg_match(HpsAttachmentType::VALID_ATTACHMENT_FORMAT, $value) !== 1) { - throw new \HpsArgumentException('attachmentFormat not a valid enum', 1); - } - - if ($value === false) { - throw new \HpsArgumentException('invalid parameter for {' . __CLASS__ . '}', 1); - } // - $this->{$name} = $value; - } - - } - - /** - * @param string $name - * @return float|string|int null - */ - public function __get($name) - { - $value = null; - if (property_exists(__CLASS__, $name)) { - $value = $this->{$name}; - } - return $value; - } -} \ No newline at end of file diff --git a/classes/includes/src/Entities/Batch/HpsBatch.php b/classes/includes/src/Entities/Batch/HpsBatch.php deleted file mode 100644 index a2e49ba..0000000 --- a/classes/includes/src/Entities/Batch/HpsBatch.php +++ /dev/null @@ -1,12 +0,0 @@ -NOTE: If processing with Colonnade, Account Type must be specified. - * - * @var null - */ - public $accountType = null; - - /** - * Data Entry Mode indicating whether the check data was manually entered or obtained from a check reader. - * Default value is HpsDataEntryMode::MANUAL. - * - * @var string|null - */ - public $dataEntryMode = HpsDataEntryMode::MANUAL; - - /** - * Indicates Check Verify. Requires processor setup to utilise. Contact your HPS representative for more information - * on the GETI eBronze program. - * - * @var null - */ - public $checkVerify = null; - - /** - * NACHA Standard Entry Class Code. - * - * NOTE: If processing with Colonnade, SECCode is required for CHeck Sale transactions. - * - * @var null - */ - public $secCode = null; -} diff --git a/classes/includes/src/Entities/Check/HpsCheckHolder.php b/classes/includes/src/Entities/Check/HpsCheckHolder.php deleted file mode 100644 index e22de59..0000000 --- a/classes/includes/src/Entities/Check/HpsCheckHolder.php +++ /dev/null @@ -1,14 +0,0 @@ -Transaction->$txnType; - - $sale = parent::fromDict($rsp, $txnType, $returnType); - $sale->responseCode = (isset($response->RspCode) ? (string)$response->RspCode : null); - $sale->responseText = (isset($response->RspMessage) ? (string)$response->RspMessage : null); - $sale->authorizationCode = (isset($response->AuthCode) ? (string)$response->AuthCode : null); - - if ($response->CheckRspInfo) { - $sale->details = array(); - - $checkInfo = $response->CheckRspInfo; - if (count($checkInfo) > 1) { - foreach ($checkInfo as $details) { - $sale->details[] = self::_hydrateRspDetails($details); - } - } else { - $sale->details = self::_hydrateRspDetails($checkInfo); - } - } - - return $sale; - } - /** - * @param $checkInfo - * - * @return \HpsCheckResponseDetails - */ - private static function _hydrateRspDetails($checkInfo) - { - $details = new HpsCheckResponseDetails(); - $details->messageType = (isset($checkInfo->Type) ? (string)$checkInfo->Type : null); - $details->code = (isset($checkInfo->Code) ? (string)$checkInfo->Code : null); - $details->message = (isset($checkInfo->Message) ? (string)$checkInfo->Message : null); - $details->fieldNumber = (isset($checkInfo->FieldNumber) ? (string)$checkInfo->FieldNumber : null); - $details->fieldName = (isset($checkInfo->FieldName) ? (string)$checkInfo->FieldName : null); - return $details; - } -} diff --git a/classes/includes/src/Entities/Check/HpsCheckResponseDetails.php b/classes/includes/src/Entities/Check/HpsCheckResponseDetails.php deleted file mode 100644 index 80567c5..0000000 --- a/classes/includes/src/Entities/Check/HpsCheckResponseDetails.php +++ /dev/null @@ -1,13 +0,0 @@ -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; - } -} diff --git a/classes/includes/src/Entities/Credit/HpsCPCData.php b/classes/includes/src/Entities/Credit/HpsCPCData.php deleted file mode 100644 index 36c83df..0000000 --- a/classes/includes/src/Entities/Credit/HpsCPCData.php +++ /dev/null @@ -1,37 +0,0 @@ - 17) { - throw new HpsArgumentException('Card holder PO number must be less than 17 characters',HpsExceptionCodes::INVALID_CPC_DATA); - } - $this->cardHolderPONbr = $poNbr; - } - - if ($taxType != null) { - $this->taxType = $taxType; - } - - if ($taxAmt != null) { - $this->taxAmt = $taxAmt; - } - } -} diff --git a/classes/includes/src/Entities/Credit/HpsCPCEdit.php b/classes/includes/src/Entities/Credit/HpsCPCEdit.php deleted file mode 100644 index c74b02b..0000000 --- a/classes/includes/src/Entities/Credit/HpsCPCEdit.php +++ /dev/null @@ -1,22 +0,0 @@ -responseCode = '00'; - $cpcEdit->responseText = ''; - return $cpcEdit; - } -} diff --git a/classes/includes/src/Entities/Credit/HpsCardHolder.php b/classes/includes/src/Entities/Credit/HpsCardHolder.php deleted file mode 100644 index d022a6a..0000000 --- a/classes/includes/src/Entities/Credit/HpsCardHolder.php +++ /dev/null @@ -1,8 +0,0 @@ - '/^3[47][0-9]{13}$/', - 'MasterCard' => '/^5[1-5][0-9]{14}$/', - 'Visa' => '/^4[0-9]{12}(?:[0-9]{3})?$/', - 'DinersClub' => '/^3(?:0[0-5]|[68][0-9])[0-9]{11}$/', - 'EnRoute' => '/^(2014|2149)/', - 'Discover' => '/^6(?:011|5[0-9]{2})[0-9]{12}$/', - 'Jcb' => '/^(?:2131|1800|35\d{3})\d{11}$/', - ); - foreach ($regexMap as $card => $rx) { - if (preg_match($rx, $this->number)) { - return $card; - } - } - return "Unknown"; - } -} diff --git a/classes/includes/src/Entities/Credit/HpsManageTokensResponse.php b/classes/includes/src/Entities/Credit/HpsManageTokensResponse.php deleted file mode 100644 index 3915aec..0000000 --- a/classes/includes/src/Entities/Credit/HpsManageTokensResponse.php +++ /dev/null @@ -1,22 +0,0 @@ -responseCode = '00'; - $transaction->responseText = ''; - return $transaction; - } -} \ No newline at end of file diff --git a/classes/includes/src/Entities/Credit/HpsOfflineAuthorization.php b/classes/includes/src/Entities/Credit/HpsOfflineAuthorization.php deleted file mode 100644 index e221e7d..0000000 --- a/classes/includes/src/Entities/Credit/HpsOfflineAuthorization.php +++ /dev/null @@ -1,22 +0,0 @@ -responseCode = '00'; - $offlineAuth->responseText = ''; - return $offlineAuth; - } -} diff --git a/classes/includes/src/Entities/Credit/HpsRecurringBilling.php b/classes/includes/src/Entities/Credit/HpsRecurringBilling.php deleted file mode 100644 index 89606ad..0000000 --- a/classes/includes/src/Entities/Credit/HpsRecurringBilling.php +++ /dev/null @@ -1,8 +0,0 @@ -responseCode = '00'; - $refund->responseText = ''; - return $refund; - } -} diff --git a/classes/includes/src/Entities/Credit/HpsReportTransactionDetails.php b/classes/includes/src/Entities/Credit/HpsReportTransactionDetails.php deleted file mode 100644 index 0c0f352..0000000 --- a/classes/includes/src/Entities/Credit/HpsReportTransactionDetails.php +++ /dev/null @@ -1,84 +0,0 @@ -Transaction->$txnType; - - $details = parent::fromDict($rsp, $txnType, $returnType); - $details->originalTransactionId = (isset($reportResponse->OriginalGatewayTxnId) ? (string)$reportResponse->OriginalGatewayTxnId : null); - $details->authorizedAmount = (isset($reportResponse->Data->AuthAmt) ? (string)$reportResponse->Data->AuthAmt : null); - $details->maskedCardNumber = (isset($reportResponse->Data->MaskedCardNbr) ? (string)$reportResponse->Data->MaskedCardNbr : null); - $details->authorizationCode = (isset($reportResponse->Data->AuthCode) ? (string)$reportResponse->Data->AuthCode : null); - $details->avsResultCode = (isset($reportResponse->Data->AVSRsltCode) ? (string)$reportResponse->Data->AVSRsltCode : null); - $details->avsResultText = (isset($reportResponse->Data->AVSRsltText) ? (string)$reportResponse->Data->AVSRsltText : null); - $details->cardType = (isset($reportResponse->Data->CardType) ? (string)$reportResponse->Data->CardType : null); - $details->descriptor = (isset($reportResponse->Data->TxnDescriptor) ? (string)$reportResponse->Data->TxnDescriptor : null); - $details->transactionType = (isset($reportResponse->ServiceName) ? HpsTransaction::serviceNameToTransactionType((string)$reportResponse->ServiceName) : null); - $details->transactionUTCDate = (isset($reportResponse->RspUtcDT) ? (string)$reportResponse->RspUtcDT : null); - $details->cpcIndicator = (isset($reportResponse->Data->CPCInd) ? (string)$reportResponse->Data->CPCInd : null); - $details->cvvResultCode = (isset($reportResponse->Data->CVVRsltCode) ? (string)$reportResponse->Data->CVVRsltCode : null); - $details->cvvResultText = (isset($reportResponse->Data->CVVRsltText) ? (string)$reportResponse->Data->CVVRsltText : null); - $details->referenceNumber = (isset($reportResponse->Data->RefNbr) ? (string)$reportResponse->Data->RefNbr : null); - $details->responseCode = (isset($reportResponse->Data->RspCode) ? (string)$reportResponse->Data->RspCode : null); - $details->responseText = (isset($reportResponse->Data->RspText) ? (string)$reportResponse->Data->RspText : null); - $details->transactionStatus = (isset($reportResponse->Data->TxnStatus) ? (string)$reportResponse->Data->TxnStatus : null); - $details->gratuityAmount = (isset($reportResponse->Data->GratuityAmtInfo) ? (string)$reportResponse->Data->GratuityAmtInfo : null); - $details->settlementAmount = (isset($reportResponse->Data->SettlementAmt) ? (string)$reportResponse->Data->SettlementAmt : null); - $details->convenienceAmount = (isset($reportResponse->Data->ConvenienceAmtInfo) ? (string)$reportResponse->Data->ConvenienceAmtInfo : null); - $details->shippingAmount = (isset($reportResponse->Data->ShippingAmtInfo) ? (string)$reportResponse->Data->ShippingAmtInfo : null); - - if (isset($reportResponse->Data->TokenizationMsg)) { - $details->tokenData = new HpsTokenData(); - $details->tokenData->responseMessage = (string)$reportResponse->Data->TokenizationMsg; - } - - if (isset($reportResponse->Data->AdditionalTxnFields)) { - $additionalTxnFields = $reportResponse->Data->AdditionalTxnFields; - $details->memo = (isset($additionalTxnFields->Description) ? (string)$additionalTxnFields->Description : null); - $details->invoiceNumber = (isset($additionalTxnFields->InvoiceNbr) ? (string)$additionalTxnFields->InvoiceNbr : null); - $details->customerId = (isset($additionalTxnFields->CustomerID) ? (string)$additionalTxnFields->CustomerID : null); - } - - if ((string)$reportResponse->GatewayRspCode != '0' && (string)$reportResponse->Data->RspCode != '00') { - if ($details->exceptions == null) { - $details->exceptions = new HpsChargeExceptions(); - } - - $details->exceptions->issuerException = HpsIssuerResponseValidation::getException( - (string)$rsp->Header->GatewayTxnId, - (string)$reportResponse->Data->RspCode, - (string)$reportResponse->Data->RspText, - 'credit' - ); - } - - return $details; - } -} diff --git a/classes/includes/src/Entities/Credit/HpsReportTransactionSummary.php b/classes/includes/src/Entities/Credit/HpsReportTransactionSummary.php deleted file mode 100644 index 339b091..0000000 --- a/classes/includes/src/Entities/Credit/HpsReportTransactionSummary.php +++ /dev/null @@ -1,81 +0,0 @@ -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; - } -} diff --git a/classes/includes/src/Entities/Credit/HpsReversal.php b/classes/includes/src/Entities/Credit/HpsReversal.php deleted file mode 100644 index b2043e1..0000000 --- a/classes/includes/src/Entities/Credit/HpsReversal.php +++ /dev/null @@ -1,33 +0,0 @@ -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; - } -} diff --git a/classes/includes/src/Entities/Credit/HpsSecureEcommerce.php b/classes/includes/src/Entities/Credit/HpsSecureEcommerce.php deleted file mode 100644 index 00fdfb4..0000000 --- a/classes/includes/src/Entities/Credit/HpsSecureEcommerce.php +++ /dev/null @@ -1,13 +0,0 @@ -responseCode = '00'; - $void->responseText = ''; - return $void; - } -} diff --git a/classes/includes/src/Entities/Debit/HpsDebitAddValue.php b/classes/includes/src/Entities/Debit/HpsDebitAddValue.php deleted file mode 100644 index f768643..0000000 --- a/classes/includes/src/Entities/Debit/HpsDebitAddValue.php +++ /dev/null @@ -1,8 +0,0 @@ -name = $name; - $this->action = $action; - } -} diff --git a/classes/includes/src/Entities/Fluent/HpsUnknownPropertyException.php b/classes/includes/src/Entities/Fluent/HpsUnknownPropertyException.php deleted file mode 100644 index 5e08470..0000000 --- a/classes/includes/src/Entities/Fluent/HpsUnknownPropertyException.php +++ /dev/null @@ -1,27 +0,0 @@ -number = $number; - } -} diff --git a/classes/includes/src/Entities/Gift/HpsGiftCardActivate.php b/classes/includes/src/Entities/Gift/HpsGiftCardActivate.php deleted file mode 100644 index 31d9350..0000000 --- a/classes/includes/src/Entities/Gift/HpsGiftCardActivate.php +++ /dev/null @@ -1,56 +0,0 @@ -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; - } -} diff --git a/classes/includes/src/Entities/Gift/HpsGiftCardAddValue.php b/classes/includes/src/Entities/Gift/HpsGiftCardAddValue.php deleted file mode 100644 index e3d9f77..0000000 --- a/classes/includes/src/Entities/Gift/HpsGiftCardAddValue.php +++ /dev/null @@ -1,8 +0,0 @@ -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; - } -} diff --git a/classes/includes/src/Entities/Gift/HpsGiftCardBalance.php b/classes/includes/src/Entities/Gift/HpsGiftCardBalance.php deleted file mode 100644 index 789d0f2..0000000 --- a/classes/includes/src/Entities/Gift/HpsGiftCardBalance.php +++ /dev/null @@ -1,8 +0,0 @@ -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; - } -} diff --git a/classes/includes/src/Entities/Gift/HpsGiftCardVoid.php b/classes/includes/src/Entities/Gift/HpsGiftCardVoid.php deleted file mode 100644 index 1890340..0000000 --- a/classes/includes/src/Entities/Gift/HpsGiftCardVoid.php +++ /dev/null @@ -1,8 +0,0 @@ -invoiceNumber = $invoiceNumber; - - if ($shipMonth == null) { - $shipMonth = date('m'); - } - $this->shipMonth = $shipMonth; - - if ($shipDay == null) { - $shipDay = date('d'); - } - $this->shipDay = $shipDay; - } -} diff --git a/classes/includes/src/Entities/HpsEncryptionData.php b/classes/includes/src/Entities/HpsEncryptionData.php deleted file mode 100644 index 2d766bb..0000000 --- a/classes/includes/src/Entities/HpsEncryptionData.php +++ /dev/null @@ -1,34 +0,0 @@ -responseMessage = $responseMessage; - } -} diff --git a/classes/includes/src/Entities/HpsTrackData.php b/classes/includes/src/Entities/HpsTrackData.php deleted file mode 100644 index 85fee46..0000000 --- a/classes/includes/src/Entities/HpsTrackData.php +++ /dev/null @@ -1,16 +0,0 @@ -_header = new HpsTransactionHeader(); - $transaction->_header->gatewayResponseCode = (string)$rsp->Header->GatewayRspCode; - $transaction->_header->gatewayResponseMessage = (string)$rsp->Header->GatewayRspMsg; - $transaction->_header->responseDt = (string)$rsp->Header->RspDT; - $transaction->_header->clientTxnId = (isset($rsp->Header->ClientTxnId) ? (string)$rsp->Header->ClientTxnId : null); - - $transaction->transactionId = (string)$rsp->Header->GatewayTxnId; - if (isset($rsp->Header->ClientTxnId)) { - $transaction->clientTransactionId = (string)$rsp->Header->ClientTxnId; - } - - // Hydrate the body - if (!isset($rsp->Transaction) || !isset($rsp->Transaction->{$txnType})) { - return $transaction; - } - // Hydrate the body - $item = $rsp->Transaction->{$txnType}; - if ($item != null) { - $transaction->responseCode = (isset($item->RspCode) ? (string)$item->RspCode : null); - $transaction->responseText = (isset($item->RspText) ? (string)$item->RspText : null); - $transaction->referenceNumber = (isset($item->RefNbr) ? (string)$item->RefNbr : null); - } - - return $transaction; - } - /** - * @return object - */ - public function gatewayResponse() - { - return (object)array( - 'code' => $this->_header->gatewayResponseCode, - 'message' => $this->_header->gatewayResponseMessage, - ); - } - /** - * @param $transactionType - * - * @return string - */ - public static function transactionTypeToServiceName($transactionType) - { - switch ($transactionType) { - case HpsTransactionType::AUTHORIZE: - return HpsItemChoiceTypePosResponseVer10Transaction::CREDIT_AUTH; - break; - case HpsTransactionType::CAPTURE: - return HpsItemChoiceTypePosResponseVer10Transaction::CREDIT_ADD_TO_BATCH; - break; - case HpsTransactionType::CHARGE: - return HpsItemChoiceTypePosResponseVer10Transaction::CREDIT_SALE; - break; - case HpsTransactionType::REFUND: - return HpsItemChoiceTypePosResponseVer10Transaction::CREDIT_RETURN; - break; - case HpsTransactionType::REVERSE: - return HpsItemChoiceTypePosResponseVer10Transaction::CREDIT_REVERSAL; - break; - case HpsTransactionType::VERIFY: - return HpsItemChoiceTypePosResponseVer10Transaction::CREDIT_ACCOUNT_VERIFY; - break; - case HpsTransactionType::LIST_TRANSACTION: - return HpsItemChoiceTypePosResponseVer10Transaction::REPORT_ACTIVITY; - break; - case HpsTransactionType::GET: - return HpsItemChoiceTypePosResponseVer10Transaction::REPORT_TXN_DETAIL; - break; - case HpsTransactionType::VOID: - return HpsItemChoiceTypePosResponseVer10Transaction::CREDIT_VOID; - break; - case HpsTransactionType::BATCH_CLOSE: - return HpsItemChoiceTypePosResponseVer10Transaction::BATCH_CLOSE; - break; - case HpsTransactionType::SECURITY_ERROR: - return "SecurityError"; - break; - default: - return ""; - } - } - /** - * @param $serviceName - * - * @return int|null - */ - public static function serviceNameToTransactionType($serviceName) - { - switch ($serviceName) { - case HpsItemChoiceTypePosResponseVer10Transaction::CREDIT_AUTH: - return HpsTransactionType::AUTHORIZE; - break; - case HpsItemChoiceTypePosResponseVer10Transaction::CREDIT_ADD_TO_BATCH: - return HpsTransactionType::CAPTURE; - break; - case HpsItemChoiceTypePosResponseVer10Transaction::CREDIT_SALE: - return HpsTransactionType::CHARGE; - break; - case HpsItemChoiceTypePosResponseVer10Transaction::CREDIT_RETURN: - return HpsTransactionType::REFUND; - break; - case HpsItemChoiceTypePosResponseVer10Transaction::CREDIT_REVERSAL: - return HpsTransactionType::REVERSE; - break; - case HpsItemChoiceTypePosResponseVer10Transaction::CREDIT_ACCOUNT_VERIFY: - return HpsTransactionType::VERIFY; - break; - case HpsItemChoiceTypePosResponseVer10Transaction::REPORT_ACTIVITY: - return HpsTransactionType::LIST_TRANSACTION; - break; - case HpsItemChoiceTypePosResponseVer10Transaction::REPORT_TXN_DETAIL: - return HpsTransactionType::GET; - break; - case HpsItemChoiceTypePosResponseVer10Transaction::CREDIT_VOID: - return HpsTransactionType::VOID; - break; - case HpsItemChoiceTypePosResponseVer10Transaction::BATCH_CLOSE: - return HpsTransactionType::BATCH_CLOSE; - break; - default: - return null; - } - } -} diff --git a/classes/includes/src/Entities/HpsTransactionDetails.php b/classes/includes/src/Entities/HpsTransactionDetails.php deleted file mode 100644 index 3a3c014..0000000 --- a/classes/includes/src/Entities/HpsTransactionDetails.php +++ /dev/null @@ -1,12 +0,0 @@ -Transaction->$txnType; - - $status = parent::fromDict($rsp, $txnType, $returnType); - $status->authorizationCode = (isset($statusResponse->TransactionStatus->AuthCode) ? (string)$statusResponse->TransactionStatus->AuthCode : null); - $status->originalGatewayResponseCode = (isset($statusResponse->TransactionStatus->GatewayRspCode) ? (string)$statusResponse->TransactionStatus->GatewayRspCode : null); - $status->originalGatewayResponseText = (isset($statusResponse->TransactionStatus->GatewayRspMsg) ? (string)$statusResponse->TransactionStatus->GatewayRspMsg : null); - $status->originalResponseCode = (isset($statusResponse->TransactionStatus->RspCode) ? (string)$statusResponse->TransactionStatus->RspCode : null); - $status->originalResponseText = (isset($statusResponse->TransactionStatus->RspText) ? (string)$statusResponse->TransactionStatus->RspText : null); - $status->transactionStatus = (isset($statusResponse->TransactionStatus->TxnStatus) ? (string)$statusResponse->TransactionStatus->TxnStatus : null); - $status->originalTransactionId = (isset($statusResponse->TransactionStatus->GatewayTxnId) ? (string)$statusResponse->TransactionStatus->GatewayTxnId : null); - $status->altPayment = (isset($statusResponse->TransactionStatus->AltPayment) ? $statusResponse->TransactionStatus->AltPayment : null); - $status->timezoneConversion = (isset($statusResponse->TzConversion) ? (string)$statusResponse->TzConversion : null); - - return $status; - } -} diff --git a/classes/includes/src/Entities/PayPlan/HpsPayPlanAmount.php b/classes/includes/src/Entities/PayPlan/HpsPayPlanAmount.php deleted file mode 100644 index b0cb39d..0000000 --- a/classes/includes/src/Entities/PayPlan/HpsPayPlanAmount.php +++ /dev/null @@ -1,23 +0,0 @@ -value = $value; - if ($currency != null) { - $this->currency = $currency; - } - } -} diff --git a/classes/includes/src/Entities/PayPlan/HpsPayPlanCustomer.php b/classes/includes/src/Entities/PayPlan/HpsPayPlanCustomer.php deleted file mode 100644 index 5528055..0000000 --- a/classes/includes/src/Entities/PayPlan/HpsPayPlanCustomer.php +++ /dev/null @@ -1,181 +0,0 @@ -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; - } - - // Needs to be implemented to get name of child class - /** - * @param string $class - * @param array $params - * - * @return array - */ - public function getEditableFieldsWithValues($class = '', $params = array()) - { - return parent::getEditableFieldsWithValues(get_class(), $params); - } -} diff --git a/classes/includes/src/Entities/PayPlan/HpsPayPlanPaymentMethod.php b/classes/includes/src/Entities/PayPlan/HpsPayPlanPaymentMethod.php deleted file mode 100644 index a2bae11..0000000 --- a/classes/includes/src/Entities/PayPlan/HpsPayPlanPaymentMethod.php +++ /dev/null @@ -1,239 +0,0 @@ -paymentMethodKey = property_exists($obj, 'paymentMethodKey') ? $obj->paymentMethodKey : null; - $ret->paymentMethodType = property_exists($obj, 'paymentMethodType') ? $obj->paymentMethodType : null; - $ret->preferredPayment = property_exists($obj, 'preferredPayment') ? $obj->preferredPayment : null; - $ret->paymentStatus = property_exists($obj, 'paymentStatus') ? $obj->paymentStatus : null; - $ret->paymentMethodIdentifier = property_exists($obj, 'paymentMethodIdentifier') ? $obj->paymentMethodIdentifier : null; - $ret->customerKey = property_exists($obj, 'customerKey') ? $obj->customerKey : null; - $ret->customerIdentifier = property_exists($obj, 'customerIdentifier') ? $obj->customerIdentifier : null; - $ret->customerStatus = property_exists($obj, 'customerStatus') ? $obj->customerStatus : 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->nameOnAccount = property_exists($obj, 'nameOnAccount') ? $obj->nameOnAccount : null; - $ret->accountNumberLast4 = property_exists($obj, 'accountNumberLast4') ? $obj->accountNumberLast4 : null; - $ret->paymentMethod = property_exists($obj, 'paymentMethod') ? $obj->paymentMethod : null; - $ret->cardBrand = property_exists($obj, 'cardBrand') ? $obj->cardBrand : null; - $ret->expirationDate = property_exists($obj, 'expirationDate') ? $obj->expirationDate : null; - $ret->cvvResponseCode = property_exists($obj, 'cvvResponseCode') ? $obj->cvvResponseCode : null; - $ret->avsResponseCode = property_exists($obj, 'avsResponseCode') ? $obj->avsResponseCode : null; - $ret->achType = property_exists($obj, 'achType') ? $obj->achType : null; - $ret->accountType = property_exists($obj, 'accountType') ? $obj->accountType : null; - $ret->routingNumber = property_exists($obj, 'routingNumber') ? $obj->routingNumber : null; - $ret->telephoneIndicator = property_exists($obj, 'telephoneIndicator') ? $obj->telephoneIndicator : 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->stateProvince = property_exists($obj, 'stateProvince') ? $obj->stateProvince : null; - $ret->zipPostalCode = property_exists($obj, 'zipPostalCode') ? $obj->zipPostalCode : null; - $ret->country = property_exists($obj, 'country') ? $obj->country : null; - $ret->accountHolderYob = property_exists($obj, 'accountHolderYob') ? $obj->accountHolderYob : null; - $ret->driversLicenseState = property_exists($obj, 'driversLicenseState') ? $obj->driversLicenseState : null; - $ret->driversLicenseNumber = property_exists($obj, 'driversLicenseNumber') ? $obj->driversLicenseNumber : null; - $ret->socialSecurityNumberLast4 = property_exists($obj, 'socialSecurityNumberLast4') ? $obj->socialSecurityNumberLast4 : null; - $ret->hasSchedules = property_exists($obj, 'hasSchedules') ? $obj->hasSchedules : null; - $ret->hasActiveSchedules = property_exists($obj, 'hasActiveSchedules') ? $obj->hasActiveSchedules : 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; - } - - // Needs to be implemented to get name of child class - /** - * @param string $class - * @param array $params - * - * @return array - */ - public function getEditableFieldsWithValues($class = '', $params = array()) - { - return parent::getEditableFieldsWithValues(get_class(), array($this->paymentMethodType)); - } -} diff --git a/classes/includes/src/Entities/PayPlan/HpsPayPlanSchedule.php b/classes/includes/src/Entities/PayPlan/HpsPayPlanSchedule.php deleted file mode 100644 index 258ff4a..0000000 --- a/classes/includes/src/Entities/PayPlan/HpsPayPlanSchedule.php +++ /dev/null @@ -1,220 +0,0 @@ -emailReceipt = 'Never'; - $this->emailAdvanceNotice = 'No'; - } - /** - * @param \HpsPayPlanSchedule|null $schedule - * - * @return array - */ - public static function getEditableFields( HpsPayPlanSchedule $schedule = null ) - { - $editableFields = array( - 'scheduleName', - 'scheduleStatus', - 'deviceId', - 'paymentMethodKey', - 'subtotalAmount', - 'taxAmount', - 'numberOfPaymentsRemaining', - 'endDate', - 'reprocessingCount', - 'emailReceipt', - 'emailAdvanceNotice', - 'processingDateInfo', - 'invoiceNbr', - 'description', - ); - if ($schedule->scheduleStarted === true){ - $editableFields[] = 'cancellationDate'; - $editableFields[] = 'nextProcessingDate'; - } - // Only editable when scheduleStarted = false - else{ - $editableFields[] = 'scheduleIdentifier'; - $editableFields[] = 'startDate'; - $editableFields[] = 'frequency'; - $editableFields[] = 'duration'; - } - return $editableFields; - } - /** - * @return array - */ - public static function getSearchableFields() - { - return array( - 'scheduleIdentifier', - 'scheduleName', - 'deviceIdFilter', - 'deviceName', - 'customerIdentifier', - 'customerKey', - 'lastname', - 'company', - 'paymentMethodType', - 'paymentMethodKey', - 'achType', - 'accountType', - 'cardBrand', - 'totalAmount', - 'startDate', - 'previousProcessingDate', - 'nextProcessingDate', - 'frequency', - 'duration', - 'scheduleStatus', - ); - } - /** - * @param $obj - * - * @return \HpsPayPlanSchedule - */ - public static function fromStdClass($obj) - { - $ret = new HpsPayPlanSchedule(); - $ret->scheduleKey = property_exists($obj, 'scheduleKey') ? $obj->scheduleKey : null; - $ret->scheduleIdentifier = property_exists($obj, 'scheduleIdentifier') ? $obj->scheduleIdentifier : null; - $ret->customerKey = property_exists($obj, 'customerKey') ? $obj->customerKey : null; - $ret->scheduleName = property_exists($obj, 'scheduleName') ? $obj->scheduleName : null; - $ret->scheduleStatus = property_exists($obj, 'scheduleStatus') ? $obj->scheduleStatus : null; - $ret->paymentMethodKey = property_exists($obj, 'paymentMethodKey') ? $obj->paymentMethodKey : null; - $ret->subtotalAmount = property_exists($obj, 'subtotalAmount') ? $obj->subtotalAmount : null; - $ret->taxAmount = property_exists($obj, 'taxAmount') ? $obj->taxAmount : null; - $ret->totalAmount = property_exists($obj, 'totalAmount') ? $obj->totalAmount : null; - $ret->deviceId = property_exists($obj, 'deviceId') ? $obj->deviceId : null; - $ret->startDate = property_exists($obj, 'startDate') ? $obj->startDate : null; - $ret->processingDateInfo = property_exists($obj, 'processingDateInfo') ? $obj->processingDateInfo : null; - $ret->frequency = property_exists($obj, 'frequency') ? $obj->frequency : null; - $ret->duration = property_exists($obj, 'duration') ? $obj->duration : null; - $ret->endDate = property_exists($obj, 'endDate') ? $obj->endDate : null; - $ret->reprocessingCount = property_exists($obj, 'reprocessingCount') ? $obj->reprocessingCount : null; - $ret->emailReceipt = property_exists($obj, 'emailReceipt') ? $obj->emailReceipt : null; - $ret->emailAdvanceNotice = property_exists($obj, 'emailAdvanceNotice') ? $obj->emailAdvanceNotice : null; - $ret->nextProcessingDate = property_exists($obj, 'nextProcessingDate') ? $obj->nextProcessingDate : null; - $ret->previousProcessingDate = property_exists($obj, 'previousProcessingDate') ? $obj->previousProcessingDate : null; - $ret->approvedTransactionCount = property_exists($obj, 'approvedTransactionCount') ? $obj->approvedTransactionCount : null; - $ret->failureCount = property_exists($obj, 'failureCount') ? $obj->failureCount : null; - $ret->totalApprovedAmountToDate = property_exists($obj, 'totalApprovedAmountToDate') ? $obj->totalApprovedAmountToDate : null; - $ret->numberOfPaymentsRemaining = property_exists($obj, 'numberOfPaymentsRemaining') ? $obj->numberOfPaymentsRemaining : null; - $ret->cancellationDate = property_exists($obj, 'cancellationDate') ? $obj->cancellationDate : null; - $ret->scheduleStarted = property_exists($obj, 'scheduleStarted') ? $obj->scheduleStarted : 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; - $ret->description = property_exists($obj, 'description') ? $obj->description : null; - $ret->invoiceNbr = property_exists($obj, 'invoiceNbr') ? $obj->invoiceNbr : null; - return $ret; - } - - // Needs to be implemented to get name of child class - /** - * @param null $params - * @param string $class - * - * @return array - */ - public function getEditableFieldsWithValues($params = null,$class = 'HpsPayPlanSchedule'){ - if ($params===null){ - $params=$this; - } - return parent::getEditableFieldsWithValues($class, $params); - } -} diff --git a/classes/includes/src/Entities/index.php b/classes/includes/src/Entities/index.php deleted file mode 100644 index b3d9bbc..0000000 --- a/classes/includes/src/Entities/index.php +++ /dev/null @@ -1 +0,0 @@ -code = $code; - $this->message = (string) $message; - } -} diff --git a/classes/includes/src/Infrastructure/HpsCheckException.php b/classes/includes/src/Infrastructure/HpsCheckException.php deleted file mode 100644 index de88f17..0000000 --- a/classes/includes/src/Infrastructure/HpsCheckException.php +++ /dev/null @@ -1,26 +0,0 @@ -transactionId = $transactionId; - $this->details = $details; - $this->code = $code; - $this->message = (string) $message; - } -} diff --git a/classes/includes/src/Infrastructure/HpsConfiguration.php b/classes/includes/src/Infrastructure/HpsConfiguration.php deleted file mode 100644 index d2b8dc6..0000000 --- a/classes/includes/src/Infrastructure/HpsConfiguration.php +++ /dev/null @@ -1,21 +0,0 @@ -transactionId = $transactionId; - $this->code = $code; - - if ($issuerCode != null || $issuerMessage != null) { - $this->details = new HpsCreditExceptionDetails(); - $this->details->issuerResponseCode = $issuerCode; - $this->details->issuerResponseText = $issuerMessage; - parent::__construct($message, $code, $innerException); - } - } -} diff --git a/classes/includes/src/Infrastructure/HpsCreditExceptionDetails.php b/classes/includes/src/Infrastructure/HpsCreditExceptionDetails.php deleted file mode 100644 index cee4fa2..0000000 --- a/classes/includes/src/Infrastructure/HpsCreditExceptionDetails.php +++ /dev/null @@ -1,10 +0,0 @@ -message = (string) $message; - if ($code != null) { - $this->code = $code; - } - if ($innerException != null) { - $this->innerException = $innerException; - } - } -} diff --git a/classes/includes/src/Infrastructure/HpsGatewayException.php b/classes/includes/src/Infrastructure/HpsGatewayException.php deleted file mode 100644 index 2d85059..0000000 --- a/classes/includes/src/Infrastructure/HpsGatewayException.php +++ /dev/null @@ -1,37 +0,0 @@ -code = $code; - $this->message = (string) $message; - - if ($gatewayResponseCode != null || $gatewayResponseMessage != null) { - $this->details = new HpsGatewayExceptionDetails(); - $this->details->gatewayResponseCode = $gatewayResponseCode; - $this->details->gatewayResponseMessage = $gatewayResponseMessage; - - $this->innerException = $innerException; - } - - $this->transactionId = $transactionId; - } -} diff --git a/classes/includes/src/Infrastructure/HpsGatewayExceptionDetails.php b/classes/includes/src/Infrastructure/HpsGatewayExceptionDetails.php deleted file mode 100644 index e622554..0000000 --- a/classes/includes/src/Infrastructure/HpsGatewayExceptionDetails.php +++ /dev/null @@ -1,10 +0,0 @@ -param = $paramName; - $this->message = (string) $message; - $this->code = $code; - parent::__construct($message); - } -} diff --git a/classes/includes/src/Infrastructure/HpsLogger.php b/classes/includes/src/Infrastructure/HpsLogger.php deleted file mode 100644 index 252937c..0000000 --- a/classes/includes/src/Infrastructure/HpsLogger.php +++ /dev/null @@ -1,42 +0,0 @@ -_logger = new HpsEmptyLogger(); - } - /** - * @return \HpsLogger|null - */ - public static function getInstance() - { - if (null === self::$_instance) { - self::$_instance = new HpsLogger(); - } - return self::$_instance; - } - /** - * @param \HpsLoggerInterface $logger - */ - public function useLogger(HpsLoggerInterface $logger) - { - $this->_logger = $logger; - } - /** - * @param $message - * @param null $object - */ - public function log($message, $object = null) - { - $this->_logger->log($message, $object); - } -} diff --git a/classes/includes/src/Infrastructure/HpsProcessorError.php b/classes/includes/src/Infrastructure/HpsProcessorError.php deleted file mode 100644 index 2637eba..0000000 --- a/classes/includes/src/Infrastructure/HpsProcessorError.php +++ /dev/null @@ -1,11 +0,0 @@ -transactionId = $transactionId; - $this->code = $code; - - if ($processorCode != null || $processorMessage != null) { - $this->details = new HpsProcessorExceptionDetails(); - $this->details->processorResponseCode = $processorCode; - $this->details->processorResponseText = $processorMessage; - parent::__construct($message, $code, $innerException); - } - } -} diff --git a/classes/includes/src/Infrastructure/HpsProcessorExceptionDetails.php b/classes/includes/src/Infrastructure/HpsProcessorExceptionDetails.php deleted file mode 100644 index 9bde5de..0000000 --- a/classes/includes/src/Infrastructure/HpsProcessorExceptionDetails.php +++ /dev/null @@ -1,10 +0,0 @@ -Header->GatewayRspCode; - $rspText = $response->Header->GatewayRspMsg; - $transactionId = (isset($response->Header->GatewayTxnId) ? $response->Header->GatewayTxnId : null); - $e = HpsGatewayResponseValidation::getException($rspCode, $rspText, $response); - - if ($e != null) { - if ($e instanceof HpsGatewayException) { - $e->transactionId = $transactionId; - } - throw $e; - } - if (!isset($response->Transaction) || !isset($response->Transaction->$expectedType)) { - throw new HpsGatewayException( - HpsExceptionCodes::UNEXPECTED_GATEWAY_ERROR, - 'Unexpected response from HPS gateway', - null, - null, - null, - $transactionId - ); - } - } - /** - * @param $responseCode - * @param $responseText - * @param $response - * - * @return \HpsAuthenticationException|\HpsGatewayException|null - */ - public static function getException($responseCode, $responseText, $response) - { - $e = null; - - switch ($responseCode) { - case '0': - break; - case '-2': - $e = new HpsAuthenticationException( - HpsExceptionCodes::AUTHENTICATION_ERROR, - 'Authentication Error. Please double check your service configuration' - ); - break; - case '3': - $e = new HpsGatewayException( - HpsExceptionCodes::INVALID_ORIGINAL_TRANSACTION, - $responseText, - $responseCode, - $responseText - ); - break; - case '5': - $e = new HpsGatewayException( - HpsExceptionCodes::NO_OPEN_BATCH, - $responseText, - $responseCode, - $responseText - ); - break; - case '12': - $e = new HpsGatewayException( - HpsExceptionCodes::INVALID_CPC_DATA, - 'Invalid CPC data', - $responseCode, - $responseText - ); - break; - case '27': - case '34': - case '26': - case '13': - $e = new HpsGatewayException( - HpsExceptionCodes::INVALID_CARD_DATA, - 'Invalid card data', - $responseCode, - $responseText - ); - break; - case '14': - $e = new HpsGatewayException( - HpsExceptionCodes::INVALID_NUMBER, - 'The card number is not valid', - $responseCode, - $responseText - ); - break; - case '30': - $e = new HpsGatewayException( - HpsExceptionCodes::GATEWAY_ERROR, - 'Gateway timed out', - $responseCode, - $responseText - ); - break; - case '1': - default: - $e = new HpsGatewayException( - HpsExceptionCodes::UNKNOWN_GATEWAY_ERROR, - $responseText, - $responseCode, - $responseText - ); - } - - return $e; - } -} diff --git a/classes/includes/src/Infrastructure/Validation/HpsInputValidation.php b/classes/includes/src/Infrastructure/Validation/HpsInputValidation.php deleted file mode 100644 index f6cac37..0000000 --- a/classes/includes/src/Infrastructure/Validation/HpsInputValidation.php +++ /dev/null @@ -1,197 +0,0 @@ - 20, - 'ZipCode' => 9, - 'FirstName' => 26, - 'LastName' => 26, - 'City' => 20, - 'Email' => 100, - 'State' => 20 - ); - /** - * @param $amount - * - * @return string - * @throws \HpsInvalidRequestException - */ - 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 $currency - * @param null $allowedCurrencies - * - * @throws \HpsInvalidRequestException - */ - 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 $number - * - * @return mixed - */ - public static function cleanPhoneNumber($number) - { - return preg_replace('/\D+/', '', trim($number)); - } - /** - * @param $zip - * - * @return mixed - */ - public static function cleanZipCode($zip) - { - return preg_replace('/[^0-9A-Za-z]/', '', trim($zip)); - } - /** - * @param $date - * - * @throws \HpsInvalidRequestException - */ - 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 $text - * - * @return mixed - */ - public static function cleanAscii($text) - { - return preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $text); - } - - /** - * 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 - */ - 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 Zip code in correct format or throw an exception - * - * @param string $zipCode this is user entered zip code - * @return string - * @throws HpsInvalidRequestException - */ - 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 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 - */ - 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 email in correct format or throw an exception - * - * @param string $value this is user entered email address - * @return string - * @throws HpsInvalidRequestException - */ - 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; - } - - - -} diff --git a/classes/includes/src/Infrastructure/Validation/HpsIssuerResponseValidation.php b/classes/includes/src/Infrastructure/Validation/HpsIssuerResponseValidation.php deleted file mode 100644 index 5430be9..0000000 --- a/classes/includes/src/Infrastructure/Validation/HpsIssuerResponseValidation.php +++ /dev/null @@ -1,158 +0,0 @@ - HpsExceptionCodes::CARD_DECLINED, - '03' => HpsExceptionCodes::CARD_DECLINED, - '04' => HpsExceptionCodes::CARD_DECLINED, - '05' => HpsExceptionCodes::CARD_DECLINED, - '41' => HpsExceptionCodes::CARD_DECLINED, - '43' => HpsExceptionCodes::CARD_DECLINED, - '44' => HpsExceptionCodes::CARD_DECLINED, - '51' => HpsExceptionCodes::CARD_DECLINED, - '56' => HpsExceptionCodes::CARD_DECLINED, - '61' => HpsExceptionCodes::CARD_DECLINED, - '62' => HpsExceptionCodes::CARD_DECLINED, - '63' => HpsExceptionCodes::CARD_DECLINED, - '65' => HpsExceptionCodes::CARD_DECLINED, - '78' => HpsExceptionCodes::CARD_DECLINED, - '06' => HpsExceptionCodes::PROCESSING_ERROR, - '07' => HpsExceptionCodes::PROCESSING_ERROR, - '12' => HpsExceptionCodes::PROCESSING_ERROR, - '15' => HpsExceptionCodes::PROCESSING_ERROR, - '19' => HpsExceptionCodes::PROCESSING_ERROR, - '52' => HpsExceptionCodes::PROCESSING_ERROR, - '53' => HpsExceptionCodes::PROCESSING_ERROR, - '57' => HpsExceptionCodes::PROCESSING_ERROR, - '58' => HpsExceptionCodes::PROCESSING_ERROR, - '76' => HpsExceptionCodes::PROCESSING_ERROR, - '77' => HpsExceptionCodes::PROCESSING_ERROR, - '96' => HpsExceptionCodes::PROCESSING_ERROR, - 'EC' => HpsExceptionCodes::PROCESSING_ERROR, - '13' => HpsExceptionCodes::INVALID_AMOUNT, - '14' => HpsExceptionCodes::INCORRECT_NUMBER, - '54' => HpsExceptionCodes::EXPIRED_CARD, - '55' => HpsExceptionCodes::INVALID_PIN, - '75' => HpsExceptionCodes::PIN_ENTRIES_EXCEEDED, - '80' => HpsExceptionCodes::INVALID_EXPIRY, - '86' => HpsExceptionCodes::PIN_VERIFICATION, - '91' => HpsExceptionCodes::ISSUER_TIMEOUT, - 'EB' => HpsExceptionCodes::INCORRECT_CVC, - 'N7' => HpsExceptionCodes::INCORRECT_CVC, - 'FR' => HpsExceptionCodes::POSSIBLE_FRAUD_DETECTED, - ); - - public static $_issuerCodeToGiftExceptionCode = array( - '1' => HpsExceptionCodes::UNKNOWN_GIFT_ERROR, - '2' => HpsExceptionCodes::UNKNOWN_GIFT_ERROR, - '11' => HpsExceptionCodes::UNKNOWN_GIFT_ERROR, - '3' => HpsExceptionCodes::INVALID_CARD_DATA, - '8' => HpsExceptionCodes::INVALID_CARD_DATA, - '4' => HpsExceptionCodes::EXPIRED_CARD, - '5' => HpsExceptionCodes::CARD_DECLINED, - '12' => HpsExceptionCodes::CARD_DECLINED, - '6' => HpsExceptionCodes::PROCESSING_ERROR, - '7' => HpsExceptionCodes::PROCESSING_ERROR, - '10' => HpsExceptionCodes::PROCESSING_ERROR, - '9' => HpsExceptionCodes::INVALID_AMOUNT, - '13' => HpsExceptionCodes::PARTIAL_APPROVAL, - '14' => HpsExceptionCodes::INVALID_PIN, - ); - - public static $_creditExceptionCodeToMessage = array( - HpsExceptionCodes::CARD_DECLINED => "The card was declined.", - HpsExceptionCodes::PROCESSING_ERROR => "An error occurred while processing the card.", - HpsExceptionCodes::INVALID_AMOUNT => "Must be greater than or equal 0.", - HpsExceptionCodes::EXPIRED_CARD => "The card has expired.", - HpsExceptionCodes::INVALID_PIN => "The pin is invalid.", - HpsExceptionCodes::PIN_ENTRIES_EXCEEDED => "Maximum number of pin retries exceeded.", - HpsExceptionCodes::INVALID_EXPIRY => "Card expiration date is invalid.", - HpsExceptionCodes::PIN_VERIFICATION => "Can't verify card pin number.", - HpsExceptionCodes::INCORRECT_CVC => "The card's security code is incorrect.", - HpsExceptionCodes::ISSUER_TIMEOUT => "The card issuer timed-out.", - HpsExceptionCodes::UNKNOWN_CREDIT_ERROR => "An unknown issuer error has occurred.", - HpsExceptionCodes::INCORRECT_NUMBER => "The card number is incorrect.", - HpsExceptionCodes::POSSIBLE_FRAUD_DETECTED => "Possible fraud detected", - HpsExceptionCodes::UNKNOWN_GIFT_ERROR => "An unknown gift error has occurred.", - HpsExceptionCodes::PARTIAL_APPROVAL => "The amount was partially approved.", - HpsExceptionCodes::INVALID_CARD_DATA => "The card data is invalid.", - ); - /** - * @param $transactionId - * @param $responseCode - * @param $responseText - * @param string $type - * - * @throws \HpsCreditException - * @throws null - */ - public static function checkResponse($transactionId, $responseCode, $responseText, $type = 'credit') - { - $e = HpsIssuerResponseValidation::getException( - (string)$transactionId, - (string)$responseCode, - (string)$responseText, - $type - ); - - if ($e != null) { - throw $e; - } - } - /** - * @param $transactionId - * @param $responseCode - * @param $responseText - * @param $type - * - * @return \HpsCreditException|null - */ - public static function getException($transactionId, $responseCode, $responseText, $type) - { - $acceptedCodes = array('00', '0'); - $map = array(); - - switch ($type) { - case 'credit': - $acceptedCodes = array_merge($acceptedCodes, array('85', '10')); - $map = self::$_issuerCodeToCreditExceptionCode; - break; - case 'gift': - $acceptedCodes = array_merge($acceptedCodes, array('13')); - $map = self::$_issuerCodeToGiftExceptionCode; - break; - } - - if (in_array($responseCode, $acceptedCodes)) { - return null; - } - - $code = null; - if (array_key_exists($responseCode, $map)) { - $code = $map[$responseCode]; - } - - if ($code == null) { - return new HpsCreditException( - $transactionId, - HpsExceptionCodes::UNKNOWN_CREDIT_ERROR, - self::$_creditExceptionCodeToMessage[HpsExceptionCodes::UNKNOWN_CREDIT_ERROR], - $responseCode, - $responseText - ); - } - - $message = null; - if (array_key_exists($code, self::$_creditExceptionCodeToMessage)) { - $message = self::$_creditExceptionCodeToMessage[$code]; - } else { - $message = 'Unknown issuer error'; - } - - return new HpsCreditException($transactionId, $code, $message, $responseCode, $responseText); - } -} diff --git a/classes/includes/src/Infrastructure/Validation/HpsProcessorResponseValidation.php b/classes/includes/src/Infrastructure/Validation/HpsProcessorResponseValidation.php deleted file mode 100644 index d340eea..0000000 --- a/classes/includes/src/Infrastructure/Validation/HpsProcessorResponseValidation.php +++ /dev/null @@ -1,64 +0,0 @@ -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 $pairs - * - * @return array - */ - protected static function nvpToArray($pairs) - { - $array = array(); - foreach ($pairs->NameValuePair as $pair) { - $array[(string)$pair->Name] = (string)$pair->Value; - } - return $array; - } -} diff --git a/classes/includes/src/Infrastructure/index.php b/classes/includes/src/Infrastructure/index.php deleted file mode 100644 index b3d9bbc..0000000 --- a/classes/includes/src/Infrastructure/index.php +++ /dev/null @@ -1 +0,0 @@ -setUpValidations(); - } - - /** - * Creates an override transaction through the HpsCheckService - */ - public function execute() - { - parent::execute(); - - return $this->service->_buildTransaction( - 'OVERRIDE', - $this->check, - $this->amount, - $this->clientTransactionId - ); - } - - /** - * Setups up validations for building sales. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'checkNotNull'), 'HpsArgumentException', 'Override needs an check') - ->addValidation(array($this, 'amountNotNull'), 'HpsArgumentException', 'Override needs an amount'); - } - - /** - * Ensures an amount has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function amountNotNull($actionCounts) - { - return isset($actionCounts['amount']); - } - - /** - * Ensures a check has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function checkNotNull($actionCounts) - { - return isset($actionCounts['check']); - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/Check/HpsCheckServiceRecurringBuilder.php b/classes/includes/src/Services/Fluent/Gateway/Check/HpsCheckServiceRecurringBuilder.php deleted file mode 100644 index 0509b8f..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/Check/HpsCheckServiceRecurringBuilder.php +++ /dev/null @@ -1,107 +0,0 @@ -setUpValidations(); - } - - /** - * 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->service->_submitTransaction($hpsTransaction, 'CheckSale'); - } - - /** - * Setups up validations for building sales. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'paymentMethodKeyNotNull'), 'HpsArgumentException', 'Sale needs a payment method key') - ->addValidation(array($this, 'amountNotNull'), 'HpsArgumentException', 'Sale needs an amount'); - } - - /** - * Ensures an amount has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function amountNotNull($actionCounts) - { - return isset($actionCounts['amount']); - } - - /** - * Ensures a paymentMethodKey has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function paymentMethodKeyNotNull($actionCounts) - { - return isset($actionCounts['paymentMethodKey']) && $actionCounts['paymentMethodKey'] == 1; - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/Check/HpsCheckServiceReturnBuilder.php b/classes/includes/src/Services/Fluent/Gateway/Check/HpsCheckServiceReturnBuilder.php deleted file mode 100644 index ce67eef..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/Check/HpsCheckServiceReturnBuilder.php +++ /dev/null @@ -1,83 +0,0 @@ -setUpValidations(); - } - - /** - * Creates a return transaction through the HpsCheckService - */ - public function execute() - { - parent::execute(); - - return $this->service->_buildTransaction( - 'RETURN', - $this->check, - $this->amount, - $this->clientTransactionId - ); - } - - /** - * Setups up validations for building returns. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'checkNotNull'), 'HpsArgumentException', 'Return needs an check') - ->addValidation(array($this, 'amountNotNull'), 'HpsArgumentException', 'Return needs an amount'); - } - - /** - * Ensures an amount has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function amountNotNull($actionCounts) - { - return isset($actionCounts['amount']); - } - - /** - * Ensures a check has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function checkNotNull($actionCounts) - { - return isset($actionCounts['check']); - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/Check/HpsCheckServiceSaleBuilder.php b/classes/includes/src/Services/Fluent/Gateway/Check/HpsCheckServiceSaleBuilder.php deleted file mode 100644 index c4c1e09..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/Check/HpsCheckServiceSaleBuilder.php +++ /dev/null @@ -1,96 +0,0 @@ -setUpValidations(); - } - - /** - * Creates a sale transaction through the HpsCheckService - */ - public function execute() - { - parent::execute(); - - return $this->service->_buildTransaction( - 'SALE', - $this->check, - $this->amount, - $this->clientTransactionId, - $this->checkVerify, - $this->achVerify - ); - } - - /** - * Setups up validations for building sales. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'checkNotNull'), 'HpsArgumentException', 'Sale needs a check') - ->addValidation(array($this, 'amountNotNull'), 'HpsArgumentException', 'Sale needs an amount'); - } - - /** - * Ensures an amount has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function amountNotNull($actionCounts) - { - if ($this->checkVerify || $this->achVerify) { - return true; - } - return isset($actionCounts['amount']); - } - - /** - * Ensures a check has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function checkNotNull($actionCounts) - { - return isset($actionCounts['check']); - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/Check/HpsCheckServiceVoidBuilder.php b/classes/includes/src/Services/Fluent/Gateway/Check/HpsCheckServiceVoidBuilder.php deleted file mode 100644 index 9dd966d..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/Check/HpsCheckServiceVoidBuilder.php +++ /dev/null @@ -1,81 +0,0 @@ -setUpValidations(); - } - - /** - * Creates a void transaction through the HpsCheckService - */ - 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'); - } - - /** - * Setups up validations for building voids. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'onlyOneTransactionId'), 'HpsArgumentException', 'Void can only use one transaction id'); - } - - /** - * 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 - */ - 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)); - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/Check/HpsCreditServiceRecurringBuilder.php b/classes/includes/src/Services/Fluent/Gateway/Check/HpsCreditServiceRecurringBuilder.php deleted file mode 100644 index 8176d6a..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/Check/HpsCreditServiceRecurringBuilder.php +++ /dev/null @@ -1,107 +0,0 @@ -setUpValidations(); - } - - /** - * 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); - } - - /** - * Setups up validations for building sales. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'paymentMethodKeyNotNull'), 'HpsArgumentException', 'Sale needs a payment method key') - ->addValidation(array($this, 'amountNotNull'), 'HpsArgumentException', 'Sale needs an amount'); - } - - /** - * Ensures an amount has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function amountNotNull($actionCounts) - { - return isset($actionCounts['amount']); - } - - /** - * Ensures a paymentMethodKey has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function paymentMethodKeyNotNull($actionCounts) - { - return isset($actionCounts['paymentMethodKey']); - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceAuthorizeBuilder.php b/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceAuthorizeBuilder.php deleted file mode 100644 index 46a445f..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceAuthorizeBuilder.php +++ /dev/null @@ -1,271 +0,0 @@ -setUpValidations(); - } - - /** - * 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)); - - //update convenienceAmtInfo if passed - if ($this->convenienceAmtInfo != null && $this->convenienceAmtInfo != '') { - $hpsBlock1->appendChild($xml->createElement('hps:ConvenienceAmtInfo', HpsInputValidation::checkAmount($this->convenienceAmtInfo))); - } - - //update shippingAmtInfo if passed - if ($this->shippingAmtInfo != null && $this->shippingAmtInfo != '') { - $hpsBlock1->appendChild($xml->createElement('hps:ShippingAmtInfo', HpsInputValidation::checkAmount($this->shippingAmtInfo))); - } - - 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); - } - - if ($this->secureEcommerce != null) { - $hpsBlock1->appendChild($this->service->_hydrateSecureEcommerce($this->secureEcommerce, $xml)); - } - - $hpsCreditAuth->appendChild($hpsBlock1); - $hpsTransaction->appendChild($hpsCreditAuth); - - return $this->service->_submitTransaction($hpsTransaction, 'CreditAuth', (isset($this->details->clientTransactionId) ? $this->details->clientTransactionId : null)); - } - - /** - * Setups up validations for building authorizations. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'onlyOnePaymentMethod'), 'HpsArgumentException', 'Authorize can only use one payment method') - ->addValidation(array($this, 'amountNotNull'), 'HpsArgumentException', 'Authorize needs an amount') - ->addValidation(array($this, 'currencyNotNull'), 'HpsArgumentException', 'Authorize needs a currency'); - } - - /** - * Ensures there is only one payment method, and checks that - * there is only one card or one token in use. Both cannot be - * used. - * - * @param array $actionCounts - * - * @return bool - */ - public function onlyOnePaymentMethod($actionCounts) - { - $count = 0; - if (isset($actionCounts['card'])) { $count++; } - if (isset($actionCounts['token'])) { $count++; } - if (isset($actionCounts['trackData'])) { $count++; } - return 1 === $count; - } - - /** - * Ensures an amount has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function amountNotNull($actionCounts) - { - return isset($actionCounts['amount']); - } - - /** - * Ensures a currency has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function currencyNotNull($actionCounts) - { - return isset($actionCounts['currency']); - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceCaptureBuilder.php b/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceCaptureBuilder.php deleted file mode 100644 index 11b1936..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceCaptureBuilder.php +++ /dev/null @@ -1,95 +0,0 @@ -setUpValidations(); - } - - /** - * Creates a capture transaction through the HpsCreditService - */ - 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(); - } - - /** - * Setups up validations for building captures. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'transactionIdNotNull'), 'HpsArgumentException', 'Capture needs a transactionId'); - } - - /** - * Ensures a transactionId has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function transactionIdNotNull($actionCounts) - { - return isset($actionCounts['transactionId']); - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceChargeBuilder.php b/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceChargeBuilder.php deleted file mode 100644 index 77acca1..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceChargeBuilder.php +++ /dev/null @@ -1,264 +0,0 @@ -setUpValidations(); - } - - /** - * Creates a charge 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'); - $hpsCreditSale = $xml->createElement('hps:CreditSale'); - $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)); - - //update convenienceAmtInfo if passed - if ($this->convenienceAmtInfo != null && $this->convenienceAmtInfo != '') { - $hpsBlock1->appendChild($xml->createElement('hps:ConvenienceAmtInfo', HpsInputValidation::checkAmount($this->convenienceAmtInfo))); - } - - //update shippingAmtInfo if passed - if ($this->shippingAmtInfo != null && $this->shippingAmtInfo != '') { - $hpsBlock1->appendChild($xml->createElement('hps:ShippingAmtInfo', HpsInputValidation::checkAmount($this->shippingAmtInfo))); - } - - 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 = $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); - } - - if ($this->cpcReq) { - $hpsBlock1->appendChild($xml->createElement('hps:CPCReq', 'Y')); - } - - $cardData->appendChild($xml->createElement('hps:TokenRequest', ($this->requestMultiUseToken ? 'Y' : 'N'))); - - if ($this->details != null) { - $hpsBlock1->appendChild($this->service->_hydrateAdditionalTxnFields($this->details, $xml)); - } - - if ($this->txnDescriptor != null && $this->txnDescriptor != '') { - $hpsBlock1->appendChild($xml->createElement('hps:TxnDescriptor', $this->txnDescriptor)); - } - - if ($this->directMarketData != null && $this->directMarketData->invoiceNumber != null) { - $hpsBlock1->appendChild($this->service->_hydrateDirectMarketData($this->directMarketData, $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($cardData); - - if ($this->secureEcommerce != null) { - $hpsBlock1->appendChild($this->service->_hydrateSecureEcommerce($this->secureEcommerce, $xml)); - } - - $hpsCreditSale->appendChild($hpsBlock1); - $hpsTransaction->appendChild($hpsCreditSale); - - return $this->service->_submitTransaction($hpsTransaction, 'CreditSale', (isset($this->details->clientTransactionId) ? $this->details->clientTransactionId : null)); - } - - /** - * Setups up validations for building charges. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'amountNotNull'), 'HpsArgumentException', 'Charge needs an amount') - ->addValidation(array($this, 'onlyOnePaymentMethod'), 'HpsArgumentException', 'Charge can only use one payment method') - ->addValidation(array($this, 'currencyNotNull'), 'HpsArgumentException', 'Charge needs a currency'); - } - - /** - * Ensures there is only one payment method, and checks that - * there is only one card or one token in use. Both cannot be - * used. - * - * @param array $actionCounts - * - * @return bool - */ - public function onlyOnePaymentMethod($actionCounts) - { - $methods = 0; - if (isset($actionCounts['card']) && $actionCounts['card'] == 1) { - $methods++; - } - if (isset($actionCounts['token']) && $actionCounts['token'] == 1) { - $methods++; - } - if (isset($actionCounts['trackData']) && $actionCounts['trackData'] == 1) { - $methods++; - } - return $methods == 1; - } - - /** - * Ensures an amount has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function amountNotNull($actionCounts) - { - return isset($actionCounts['amount']); - } - - /** - * Ensures a currency has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function currencyNotNull($actionCounts) - { - return isset($actionCounts['currency']); - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceCpcEditBuilder.php b/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceCpcEditBuilder.php deleted file mode 100644 index c03d3fe..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceCpcEditBuilder.php +++ /dev/null @@ -1,81 +0,0 @@ -setUpValidations(); - } - - /** - * Creates a cpcEdit transaction through the HpsCreditService - */ - 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'); - } - - /** - * Setups up validations for building cpcEdits. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'transactionIdNotNull'), 'HpsArgumentException', 'CpcEdit needs a transactionId') - ->addValidation(array($this, 'cpcDataNotNull'), 'HpsArgumentException', 'CpcEdit needs cpcData'); - } - - /** - * Ensures a transactionId has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function transactionIdNotNull($actionCounts) - { - return isset($actionCounts['transactionId']); - } - - /** - * Ensures cpcData has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function cpcDataNotNull($actionCounts) - { - return isset($actionCounts['cpcData']); - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceEditBuilder.php b/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceEditBuilder.php deleted file mode 100644 index 93d0ace..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceEditBuilder.php +++ /dev/null @@ -1,88 +0,0 @@ -setUpValidations(); - } - - /** - * Creates an edit transaction through the HpsCreditService - */ - public function execute() - { - parent::execute(); - - $xml = new DOMDocument(); - $hpsTransaction = $xml->createElement('hps:Transaction'); - $hpsCreditTxnEdit = $xml->createElement('hps:CreditTxnEdit'); - - $hpsCreditTxnEdit->appendChild($xml->createElement('hps:GatewayTxnId', $this->transactionId)); - if ($this->amount != null) { - $amount = sprintf('%0.2f', round($this->amount, 3)); - $hpsCreditTxnEdit->appendChild($xml->createElement('hps:Amt', $amount)); - } - if ($this->gratuity != null) { - $hpsCreditTxnEdit->appendChild($xml->createElement('hps:GratuityAmtInfo', $this->gratuity)); - } - - $hpsTransaction->appendChild($hpsCreditTxnEdit); - $trans = $this->service->_submitTransaction($hpsTransaction, 'CreditTxnEdit', $this->clientTransactionId); - - $trans->responseCode = '00'; - $trans->responseText = ''; - - return $trans; - } - - /** - * Setups up validations for building edits. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'transactionIdNotNull'), 'HpsArgumentException', 'Edit needs a transactionId'); - } - - /** - * Ensures a transactionId has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function transactionIdNotNull($actionCounts) - { - return isset($actionCounts['transactionId']); - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceGetBuilder.php b/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceGetBuilder.php deleted file mode 100644 index ca6dbbd..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceGetBuilder.php +++ /dev/null @@ -1,67 +0,0 @@ -setUpValidations(); - } - - /** - * Creates a get transaction through the HpsCreditService - */ - 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'); - } - - /** - * Setups up validations for building edits. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'transactionIdNotNull'), 'HpsArgumentException', 'Get needs a transactionId'); - } - - /** - * Ensures a transactionId has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function transactionIdNotNull($actionCounts) - { - return isset($actionCounts['transactionId']); - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceListTransactionsBuilder.php b/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceListTransactionsBuilder.php deleted file mode 100644 index 409ea5a..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceListTransactionsBuilder.php +++ /dev/null @@ -1,94 +0,0 @@ -setUpValidations(); - } - - /** - * 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'); - } - - /** - * Setups up validations for building edits. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'startDateNotNull'), 'HpsArgumentException', 'ListTransactions needs a startDate') - ->addValidation(array($this, 'endDateNotNull'), 'HpsArgumentException', 'ListTransactions needs an endDate'); - } - - /** - * Ensures a startDate has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function startDateNotNull($actionCounts) - { - return isset($actionCounts['startDate']); - } - - /** - * Ensures an endDate has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function endDateNotNull($actionCounts) - { - return isset($actionCounts['endDate']); - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceOfflineAuthBuilder.php b/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceOfflineAuthBuilder.php deleted file mode 100644 index 48b8f01..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceOfflineAuthBuilder.php +++ /dev/null @@ -1,227 +0,0 @@ -setUpValidations(); - } - - /** - * Creates a offline auth transaction through the HpsCreditService - */ - public function execute() - { - parent::execute(); - - $xml = new DOMDocument(); - $hpsTransaction = $xml->createElement('hps:Transaction'); - $hpsCreditOfflineAuth = $xml->createElement('hps:CreditOfflineAuth'); - $hpsBlock1 = $xml->createElement('hps:Block1'); - - $hpsBlock1->appendChild($xml->createElement('hps:AllowDup', ($this->allowDuplicates ? 'Y' : 'N'))); - $hpsBlock1->appendChild($xml->createElement('hps:Amt', $this->amount)); - - //update convenienceAmtInfo if passed - if ($this->convenienceAmtInfo != null && $this->convenienceAmtInfo != '') { - $hpsBlock1->appendChild($xml->createElement('hps:ConvenienceAmtInfo', HpsInputValidation::checkAmount($this->convenienceAmtInfo))); - } - - //update shippingAmtInfo if passed - if ($this->shippingAmtInfo != null && $this->shippingAmtInfo != '') { - $hpsBlock1->appendChild($xml->createElement('hps:ShippingAmtInfo', HpsInputValidation::checkAmount($this->shippingAmtInfo))); - } - - 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 - )); - } 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)); - } - } 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', 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)); - } - - if ($this->cpcReq == true) { - $hpsBlock1->appendChild($xml->createElement('hps:CPCReq', 'Y')); - } - - if ($this->txnDescriptor != null) { - $hpsBlock1->appendChild($xml->createElement('hps:TxnDescriptor', $this->txnDescriptor)); - } - - if ($this->autoSubstantiation != null) { - $hpsBlock1->appendChild($this->service->_hydrateAutoSubstantiation($this->autoSubstantiation)); - } - - if ($this->offlineAuthCode != null) { - $hpsBlock1->appendChild($xml->createElement('hps:OfflineAuthCode', $this->offlineAuthCode)); - } - - $hpsCreditOfflineAuth->appendChild($hpsBlock1); - $hpsTransaction->appendChild($hpsCreditOfflineAuth); - - return $this->service->_submitTransaction($hpsTransaction, 'CreditOfflineAuth', (isset($this->details->clientTransactionId) ? $this->details->clientTransactionId : null)); - } - - /** - * Setups up validations for building offline auths. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'onlyOnePaymentMethod'), 'HpsArgumentException', 'Offline Auth can only use one payment method'); - } - - /** - * Ensures there is only one payment method, and checks that - * there is only one card or one token in use. Both cannot be - * used. - * - * @param array $actionCounts - * - * @return bool - */ - public function onlyOnePaymentMethod($actionCounts) - { - $methods = 0; - if (isset($actionCounts['card']) && $actionCounts['card'] == 1) { - $methods++; - } - if (isset($actionCounts['token']) && $actionCounts['token'] == 1) { - $methods++; - } - if (isset($actionCounts['trackData']) && $actionCounts['trackData'] == 1) { - $methods++; - } - return $methods == 1; - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceOfflineChargeBuilder.php b/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceOfflineChargeBuilder.php deleted file mode 100644 index 2d45299..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceOfflineChargeBuilder.php +++ /dev/null @@ -1,184 +0,0 @@ -createElement('hps:Transaction'); - $hpsCreditOfflineAuth = $xml->createElement('hps:CreditOfflineAuth'); - $hpsBlock1 = $xml->createElement('hps:Block1'); - - $hpsBlock1->appendChild($xml->createElement('hps:AllowDup', ($this->allowDuplicates ? 'Y' : 'N'))); - $hpsBlock1->appendChild($xml->createElement('hps:Amt', $this->amount)); - - //update convenienceAmtInfo if passed - if ($this->convenienceAmtInfo != null && $this->convenienceAmtInfo != '') { - $hpsBlock1->appendChild($xml->createElement('hps:ConvenienceAmtInfo', HpsInputValidation::checkAmount($this->convenienceAmtInfo))); - } - - //update shippingAmtInfo if passed - if ($this->shippingAmtInfo != null && $this->shippingAmtInfo != '') { - $hpsBlock1->appendChild($xml->createElement('hps:ShippingAmtInfo', HpsInputValidation::checkAmount($this->shippingAmtInfo))); - } - - 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)); - } - } 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)); - } - } 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)); - } - - if ($this->cpcReq == true) { - $hpsBlock1->appendChild($xml->createElement('hps:CPCReq', 'Y')); - } - - if ($this->txnDescriptor != null) { - $hpsBlock1->appendChild($xml->createElement('hps:TxnDescriptor', $this->txnDescriptor)); - } - - if ($this->autoSubstantiation != null) { - $hpsBlock1->appendChild($this->service->_hydrateAutoSubstantiation($this->autoSubstantiation)); - } - - if ($this->offlineAuthCode != null) { - $hpsBlock1->appendChild($xml->createElement('hps:OfflineAuthCode', $this->offlineAuthCode)); - } - - $hpsCreditOfflineAuth->appendChild($hpsBlock1); - $hpsTransaction->appendChild($hpsCreditOfflineAuth); - - return $this->service->_submitTransaction($hpsTransaction, 'CreditOfflineAuth', (isset($this->details->clientTransactionId) ? $this->details->clientTransactionId : null)); - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServicePrepaidAddValueBuilder.php b/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServicePrepaidAddValueBuilder.php deleted file mode 100644 index 2edb1bf..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServicePrepaidAddValueBuilder.php +++ /dev/null @@ -1,110 +0,0 @@ -setUpValidations(); - } - - /** - * Creates an add value transaction through the HpsCreditService - */ - public function execute() - { - parent::execute(); - - $xml = new DOMDocument(); - $hpsTransaction = $xml->createElement('hps:Transaction'); - $hpsCreditAuth = $xml->createElement('hps:PrePaidAddValue'); - $hpsBlock1 = $xml->createElement('hps:Block1'); - - $hpsBlock1->appendChild($xml->createElement('hps:Amt', $this->amount)); - $hpsBlock1->appendChild($xml->createElement('hps:AllowDup', ($this->allowDuplicates ? 'Y' : 'N'))); - - $cardData = $xml->createElement('hps:CardData'); - if ($this->card != null) { - $cardData->appendChild($this->service->_hydrateManualEntry($this->card, $xml)); - } else if ($this->trackData != null) { - $cardData->appendChild($this->service->_hydrateTrackData($this->trackData, $xml)); - } else if ($this->token != null) { - $cardData->appendChild($this->service->_hydrateTokenData($this->token, $xml)); - } - - $hpsBlock1->appendChild($cardData); - $hpsCreditAuth->appendChild($hpsBlock1); - $hpsTransaction->appendChild($hpsCreditAuth); - - return $this->service->_submitTransaction($hpsTransaction, 'PrePaidAddValue'); - } - - /** - * Setups up validations for building balance inquiries. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'onlyOnePaymentMethod'), 'HpsArgumentException', 'Add Value can only use one payment method'); - } - - /** - * Ensures there is only one payment method, and checks that - * there is only one card or one token in use. Both cannot be - * used. - * - * @param array $actionCounts - * - * @return bool - */ - public function onlyOnePaymentMethod($actionCounts) - { - $methods = 0; - if (isset($actionCounts['card']) && $actionCounts['card'] == 1) { - $methods++; - } - if (isset($actionCounts['token']) && $actionCounts['token'] == 1) { - $methods++; - } - if (isset($actionCounts['trackData']) && $actionCounts['trackData'] == 1) { - $methods++; - } - return $methods == 1; - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServicePrepaidBalanceInquiryBuilder.php b/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServicePrepaidBalanceInquiryBuilder.php deleted file mode 100644 index c22ea82..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServicePrepaidBalanceInquiryBuilder.php +++ /dev/null @@ -1,103 +0,0 @@ -setUpValidations(); - } - - /** - * Creates a balance inquiry transaction through the HpsCreditService - */ - public function execute() - { - parent::execute(); - - $xml = new DOMDocument(); - $hpsTransaction = $xml->createElement('hps:Transaction'); - $hpsCreditAuth = $xml->createElement('hps:PrePaidBalanceInquiry'); - $hpsBlock1 = $xml->createElement('hps:Block1'); - - $cardData = $xml->createElement('hps:CardData'); - if ($this->card != null) { - $cardData->appendChild($this->service->_hydrateManualEntry($this->card, $xml)); - } else if ($this->trackData != null) { - $cardData->appendChild($this->service->_hydrateTrackData($this->trackData, $xml)); - } else if ($this->token != null) { - $cardData->appendChild($this->service->_hydrateTokenData($this->token, $xml)); - } - $hpsBlock1->appendChild($cardData); - - if ($this->cardHolder != null) { - $hpsBlock1->appendChild($this->service->_hydrateCardHolderData($this->cardHolder, $xml)); - } - - $hpsCreditAuth->appendChild($hpsBlock1); - $hpsTransaction->appendChild($hpsCreditAuth); - - return $this->service->_submitTransaction($hpsTransaction, 'PrePaidBalanceInquiry'); - } - - /** - * Setups up validations for building balance inquiries. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'onlyOnePaymentMethod'), 'HpsArgumentException', 'Balance Inquiry can only use one payment method'); - } - - /** - * Ensures there is only one payment method, and checks that - * there is only one card or one token in use. Both cannot be - * used. - * - * @param array $actionCounts - * - * @return bool - */ - public function onlyOnePaymentMethod($actionCounts) - { - $methods = 0; - if (isset($actionCounts['card']) && $actionCounts['card'] == 1) { - $methods++; - } - if (isset($actionCounts['token']) && $actionCounts['token'] == 1) { - $methods++; - } - if (isset($actionCounts['trackData']) && $actionCounts['trackData'] == 1) { - $methods++; - } - return $methods == 1; - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceRecurringBuilder.php b/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceRecurringBuilder.php deleted file mode 100644 index 517c1dd..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceRecurringBuilder.php +++ /dev/null @@ -1,160 +0,0 @@ -setUpValidations(); - } - - /** - * 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->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)); - } - - /** - * Setups up validations for building recurring billings. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'onlyOnePaymentMethod'), 'HpsArgumentException', 'Recurring Billing can only use one payment method') - ->addValidation(array($this, 'amountNotNull'), 'HpsArgumentException', 'Recurring Billing needs an amount'); - } - - /** - * Ensures there is only one payment method, and checks that - * there is only one card or one token in use. Both cannot be - * used. - * - * @param array $actionCounts - * - * @return bool - */ - public function onlyOnePaymentMethod($actionCounts) - { - $methods = 0; - - if (isset($actionCounts['card']) && $actionCounts['card'] == 1) { - $methods++; - } - - if (isset($actionCounts['token']) && $actionCounts['token'] == 1) { - $methods++; - } - - if (isset($actionCounts['paymentMethodKey']) && $actionCounts['paymentMethodKey'] == 1) { - $methods++; - } - - return $methods == 1; - } - - /** - * Ensures an amount has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function amountNotNull($actionCounts) - { - return isset($actionCounts['amount']); - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceRefundBuilder.php b/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceRefundBuilder.php deleted file mode 100644 index 9722388..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceRefundBuilder.php +++ /dev/null @@ -1,171 +0,0 @@ -setUpValidations(); - } - - /** - * Creates a refund 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'); - $hpsCreditReturn = $xml->createElement('hps:CreditReturn'); - $hpsBlock1 = $xml->createElement('hps:Block1'); - - $hpsBlock1->appendChild($xml->createElement('hps:AllowDup', ($this->allowDuplicates ? 'Y' : 'N'))); - $hpsBlock1->appendChild($xml->createElement('hps:Amt', $this->amount)); - - if ($this->cardHolder != null) { - $hpsBlock1->appendChild($this->service->_hydrateCardHolderData($this->cardHolder, $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 { - $hpsBlock1->appendChild($xml->createElement('hps:GatewayTxnId', $this->transactionId)); - } - - if ($this->details != null) { - $hpsBlock1->appendChild($this->service->_hydrateAdditionalTxnFields($this->details, $xml)); - } - - $hpsCreditReturn->appendChild($hpsBlock1); - $hpsTransaction->appendChild($hpsCreditReturn); - - return $this->service->_submitTransaction($hpsTransaction, 'CreditReturn', (isset($this->details->clientTransactionId) ? $this->details->clientTransationId : null)); - } - - /** - * Setups up validations for building refunds. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'onlyOnePaymentMethod'), 'HpsArgumentException', 'Refund can only use one payment method') - ->addValidation(array($this, 'amountNotNull'), 'HpsArgumentException', 'Refund needs an amount') - ->addValidation(array($this, 'currencyNotNull'), 'HpsArgumentException', 'Refund needs an currency'); - } - - /** - * 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 - */ - 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 an amount has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function amountNotNull($actionCounts) - { - return isset($actionCounts['amount']); - } - - /** - * Ensures a currency has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function currencyNotNull($actionCounts) - { - return isset($actionCounts['currency']); - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceReverseBuilder.php b/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceReverseBuilder.php deleted file mode 100644 index b9271a2..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceReverseBuilder.php +++ /dev/null @@ -1,162 +0,0 @@ -setUpValidations(); - } - - /** - * 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)); - } - - /** - * Setups up validations for building reverses. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'onlyOnePaymentMethod'), 'HpsArgumentException', 'Reverse can only use one payment method') - ->addValidation(array($this, 'amountNotNull'), 'HpsArgumentException', 'Reverse needs an amount') - ->addValidation(array($this, 'currencyNotNull'), 'HpsArgumentException', 'Reverse needs an currency'); - } - - /** - * 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 - */ - 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 an amount has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function amountNotNull($actionCounts) - { - return isset($actionCounts['amount']); - } - - /** - * Ensures a currency has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function currencyNotNull($actionCounts) - { - return isset($actionCounts['currency']); - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceUpdateTokenExpirationBuilder.php b/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceUpdateTokenExpirationBuilder.php deleted file mode 100644 index ebed1e8..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceUpdateTokenExpirationBuilder.php +++ /dev/null @@ -1,100 +0,0 @@ -setUpValidations(); - } - - /** - * Creates an edit transaction through the HpsCreditService - */ - public function execute() - { - parent::execute(); - $xml = new DOMDocument(); - $hpsTransaction = $xml->createElement('hps:Transaction'); - $hpsManageTokens = $xml->createElement('hps:ManageTokens'); - - $hpsManageTokens->appendChild($xml->createElement('hps:TokenValue', trim((string)$this->token))); - - $hpsTokenActions = $xml->createElement('hps:TokenActions'); - $hpsSet = $xml->createElement('hps:Set'); - $hpsAttribute = $xml->createElement('hps:Attribute'); - - $hpsAttribute->appendChild($xml->createElement('hps:Name', 'ExpMonth')); - $hpsAttribute->appendChild($xml->createElement('hps:Value', (string)sprintf("%'.02d", (int)$this->expMonth))); - - $hpsSet->appendChild($hpsAttribute); - - $hpsAttribute = $xml->createElement('hps:Attribute'); - - $hpsAttribute->appendChild($xml->createElement('hps:Name', 'ExpYear')); - $hpsAttribute->appendChild($xml->createElement('hps:Value', (string)$this->expYear)); - - $hpsSet->appendChild($hpsAttribute); - - $hpsTokenActions->appendChild($hpsSet); - - $hpsManageTokens->appendChild($hpsTokenActions); - - $hpsTransaction->appendChild($hpsManageTokens); - $trans = $this->service->_submitTransaction($hpsTransaction, 'ManageTokens', null); - - $trans->responseCode = '00'; - $trans->responseText = ''; - - return $trans; - } - - /** - * Setups up validations for building edits. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'tokenNotNull'), 'HpsArgumentException', 'Edit needs a multi use token value'); - } - - /** - * Ensures a token has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function tokenNotNull($actionCounts) - { - return isset($actionCounts['token']); - } -} \ No newline at end of file diff --git a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceVerifyBuilder.php b/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceVerifyBuilder.php deleted file mode 100644 index 677578e..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceVerifyBuilder.php +++ /dev/null @@ -1,136 +0,0 @@ -setUpValidations(); - } - - /** - * Creates a verify transaction through the HpsCreditService - */ - public function execute() - { - parent::execute(); - - $xml = new DOMDocument(); - $hpsTransaction = $xml->createElement('hps:Transaction'); - $hpsCreditAccountVerify = $xml->createElement('hps:CreditAccountVerify'); - $hpsBlock1 = $xml->createElement('hps:Block1'); - - 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 - )); - } - } - $cardData->appendChild($xml->createElement('hps:TokenRequest', ($this->requestMultiUseToken) ? 'Y' : 'N')); - - $hpsBlock1->appendChild($cardData); - $hpsCreditAccountVerify->appendChild($hpsBlock1); - $hpsTransaction->appendChild($hpsCreditAccountVerify); - - return $this->service->_submitTransaction($hpsTransaction, 'CreditAccountVerify', $this->clientTransactionId); - } - - /** - * Setups up validations for building verifys. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'onlyOnePaymentMethod'), 'HpsArgumentException', 'Verify can only use one payment method'); - } - - /** - * Ensures there is only one payment method, and checks that - * there is only one card or one token in use. Both cannot be - * used. - * - * @param array $actionCounts - * - * @return bool - */ - public function onlyOnePaymentMethod($actionCounts) - { - $count = 0; - if (isset($actionCounts['card'])) { $count++; } - if (isset($actionCounts['token'])) { $count++; } - if (isset($actionCounts['trackData'])) { $count++; } - return 1 === $count; - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceVoidBuilder.php b/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceVoidBuilder.php deleted file mode 100644 index 82e0e52..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/Credit/HpsCreditServiceVoidBuilder.php +++ /dev/null @@ -1,67 +0,0 @@ -setUpValidations(); - } - - /** - * Creates a void transaction through the HpsCreditService - */ - public function execute() - { - parent::execute(); - - $xml = new DOMDocument(); - $hpsTransaction = $xml->createElement('hps:Transaction'); - $hpsCreditVoid = $xml->createElement('hps:CreditVoid'); - $hpsCreditVoid->appendChild($xml->createElement('hps:GatewayTxnId', $this->transactionId)); - $hpsTransaction->appendChild($hpsCreditVoid); - - return $this->service->_submitTransaction($hpsTransaction, 'CreditVoid', $this->clientTransactionId); - } - - /** - * Setups up validations for building edits. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'transactionIdNotNull'), 'HpsArgumentException', 'Void needs a transactionId'); - } - - /** - * Ensures a transactionId has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function transactionIdNotNull($actionCounts) - { - return isset($actionCounts['transactionId']); - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/Debit/HpsDebitServiceAddValueBuilder.php b/classes/includes/src/Services/Fluent/Gateway/Debit/HpsDebitServiceAddValueBuilder.php deleted file mode 100644 index 50c29a2..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/Debit/HpsDebitServiceAddValueBuilder.php +++ /dev/null @@ -1,139 +0,0 @@ -setUpValidations(); - } - - /** - * Creates a addValue transaction through the HpsDebitService - */ - public function execute() - { - parent::execute(); - - $addValueSvc = new HpsDebitService($this->service->servicesConfig()); - return $addValueSvc->addValue( - $this->amount, - $this->currency, - $this->trackData, - $this->pinBlock, - $this->encryptionData, - $this->allowDuplicates, - $this->cardHolder, - $this->details, - $this->clientTransactionId - ); - } - - /** - * Setups up validations for building addValues. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'amountNotNull'), 'HpsArgumentException', 'AddValue needs an amount') - ->addValidation(array($this, 'currencyNotNull'), 'HpsArgumentException', 'AddValue needs an currency') - ->addValidation(array($this, 'trackDataNotNull'), 'HpsArgumentException', 'AddValue needs an trackData') - ->addValidation(array($this, 'pinBlockNotNull'), 'HpsArgumentException', 'AddValue needs an pinBlock'); - } - - /** - * Ensures an amount has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function amountNotNull($actionCounts) - { - return isset($actionCounts['amount']); - } - - /** - * Ensures a currency has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function currencyNotNull($actionCounts) - { - return isset($actionCounts['currency']); - } - - /** - * Ensures a trackData has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function trackDataNotNull($actionCounts) - { - return isset($actionCounts['trackData']); - } - - /** - * Ensures a pinBlock has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function pinBlockNotNull($actionCounts) - { - return isset($actionCounts['pinBlock']); - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/Debit/HpsDebitServiceChargeBuilder.php b/classes/includes/src/Services/Fluent/Gateway/Debit/HpsDebitServiceChargeBuilder.php deleted file mode 100644 index 1c59892..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/Debit/HpsDebitServiceChargeBuilder.php +++ /dev/null @@ -1,149 +0,0 @@ -setUpValidations(); - } - - /** - * Creates a charge transaction through the HpsDebitService - */ - 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 - ); - } - - /** - * Setups up validations for building charges. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'amountNotNull'), 'HpsArgumentException', 'Charge needs an amount') - ->addValidation(array($this, 'currencyNotNull'), 'HpsArgumentException', 'Charge needs an currency') - ->addValidation(array($this, 'trackDataNotNull'), 'HpsArgumentException', 'Charge needs an trackData') - ->addValidation(array($this, 'pinBlockNotNull'), 'HpsArgumentException', 'Charge needs an pinBlock'); - } - - /** - * Ensures an amount has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function amountNotNull($actionCounts) - { - return isset($actionCounts['amount']); - } - - /** - * Ensures a currency has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function currencyNotNull($actionCounts) - { - return isset($actionCounts['currency']); - } - - /** - * Ensures a trackData has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function trackDataNotNull($actionCounts) - { - return isset($actionCounts['trackData']); - } - - /** - * Ensures a pinBlock has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function pinBlockNotNull($actionCounts) - { - return isset($actionCounts['pinBlock']); - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/Debit/HpsDebitServiceReturnBuilder.php b/classes/includes/src/Services/Fluent/Gateway/Debit/HpsDebitServiceReturnBuilder.php deleted file mode 100644 index 17a794d..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/Debit/HpsDebitServiceReturnBuilder.php +++ /dev/null @@ -1,139 +0,0 @@ -setUpValidations(); - } - - /** - * Creates a return transaction through the HpsDebitService - */ - public function execute() - { - parent::execute(); - - $returnSvc = new HpsDebitService($this->service->servicesConfig()); - return $returnSvc->returnDebit( - $this->transactionId, - $this->amount, - $this->trackData, - $this->pinBlock, - $this->allowDuplicates, - $this->cardHolder, - $this->encryptionData, - $this->details, - $this->clientTransactionId - ); - } - - /** - * Setups up validations for building returns. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'transactionIdNotNull'), 'HpsArgumentException', 'Return needs an transactionId') - ->addValidation(array($this, 'amountNotNull'), 'HpsArgumentException', 'Return needs an amount') - ->addValidation(array($this, 'trackDataNotNull'), 'HpsArgumentException', 'Return needs an trackData') - ->addValidation(array($this, 'pinBlockNotNull'), 'HpsArgumentException', 'Return needs an pinBlock'); - } - - /** - * Ensures a transactionId has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function transactionIdNotNull($actionCounts) - { - return isset($actionCounts['transactionId']); - } - - /** - * Ensures an amount has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function amountNotNull($actionCounts) - { - return isset($actionCounts['amount']); - } - - /** - * Ensures a trackData has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function trackDataNotNull($actionCounts) - { - return isset($actionCounts['trackData']); - } - - /** - * Ensures a pinBlock has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function pinBlockNotNull($actionCounts) - { - return isset($actionCounts['pinBlock']); - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/Debit/HpsDebitServiceReverseBuilder.php b/classes/includes/src/Services/Fluent/Gateway/Debit/HpsDebitServiceReverseBuilder.php deleted file mode 100644 index c16a68c..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/Debit/HpsDebitServiceReverseBuilder.php +++ /dev/null @@ -1,116 +0,0 @@ -setUpValidations(); - } - - /** - * Creates a reverse transaction through the HpsDebitService - */ - 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 - ); - } - - /** - * Setups up validations for building reverses. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'transactionIdNotNull'), 'HpsArgumentException', 'Reverse needs an transactionId') - ->addValidation(array($this, 'amountNotNull'), 'HpsArgumentException', 'Reverse needs an amount') - ->addValidation(array($this, 'trackDataNotNull'), 'HpsArgumentException', 'Reverse needs an trackData'); - } - - /** - * Ensures a transactionId has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function transactionIdNotNull($actionCounts) - { - return isset($actionCounts['transactionId']); - } - - /** - * Ensures an amount has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function amountNotNull($actionCounts) - { - return isset($actionCounts['amount']); - } - - /** - * Ensures a trackData has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function trackDataNotNull($actionCounts) - { - return isset($actionCounts['trackData']); - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceActivateBuilder.php b/classes/includes/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceActivateBuilder.php deleted file mode 100644 index a43458e..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceActivateBuilder.php +++ /dev/null @@ -1,127 +0,0 @@ -setUpValidations(); - } - - /** - * Creates an activate transaction through the HpsGiftCardService - */ - 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 - ); - } - - /** - * Setups up validations for building activates. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'onlyOnePaymentMethod'), 'HpsArgumentException', 'Activate can only use one payment method') - ->addValidation(array($this, 'amountNotNull'), 'HpsArgumentException', 'Activate needs an amount') - ->addValidation(array($this, 'currencyNotNull'), 'HpsArgumentException', 'Activate needs a currency'); - } - - /** - * Ensures there is only one payment method, and checks that - * there is only one card or one token in use. Both cannot be - * used. - * - * @param array $actionCounts - * - * @return bool - */ - public function onlyOnePaymentMethod($actionCounts) - { - $methods = 0; - if (isset($actionCounts['card']) && $actionCounts['card'] == 1) { - $methods++; - } - if (isset($actionCounts['token']) && $actionCounts['token'] == 1) { - $methods++; - } - return $methods == 1; - } - - /** - * Ensures a card has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function cardNotNull($actionCounts) - { - return isset($actionCounts['card']); - } - - /** - * Ensures an amount has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function amountNotNull($actionCounts) - { - return isset($actionCounts['amount']); - } - - /** - * Ensures a currency has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function currencyNotNull($actionCounts) - { - return isset($actionCounts['currency']); - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceAddValueBuilder.php b/classes/includes/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceAddValueBuilder.php deleted file mode 100644 index 073751c..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceAddValueBuilder.php +++ /dev/null @@ -1,127 +0,0 @@ -setUpValidations(); - } - - /** - * Creates an addValue transaction through the HpsGiftCardService - */ - public function execute() - { - parent::execute(); - - $addValueSvc = 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 $addValueSvc->addValue( - $this->amount, - $this->currency, - $this->card - ); - } - - /** - * Setups up validations for building addValues. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'onlyOnePaymentMethod'), 'HpsArgumentException', 'AddValue can only use one payment method') - ->addValidation(array($this, 'amountNotNull'), 'HpsArgumentException', 'AddValue needs an amount') - ->addValidation(array($this, 'currencyNotNull'), 'HpsArgumentException', 'AddValue needs a currency'); - } - - /** - * Ensures there is only one payment method, and checks that - * there is only one card or one token in use. Both cannot be - * used. - * - * @param array $actionCounts - * - * @return bool - */ - public function onlyOnePaymentMethod($actionCounts) - { - $methods = 0; - if (isset($actionCounts['card']) && $actionCounts['card'] == 1) { - $methods++; - } - if (isset($actionCounts['token']) && $actionCounts['token'] == 1) { - $methods++; - } - return $methods == 1; - } - - /** - * Ensures a card has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function cardNotNull($actionCounts) - { - return isset($actionCounts['card']); - } - - /** - * Ensures an amount has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function amountNotNull($actionCounts) - { - return isset($actionCounts['amount']); - } - - /** - * Ensures a currency has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function currencyNotNull($actionCounts) - { - return isset($actionCounts['currency']); - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceAliasBuilder.php b/classes/includes/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceAliasBuilder.php deleted file mode 100644 index c665ed2..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceAliasBuilder.php +++ /dev/null @@ -1,140 +0,0 @@ -setUpValidations(); - } - - /** - * Creates an alias transaction through the HpsGiftCardService - */ - 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'); - } - - /** - * Setups up validations for building aliases. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'onlyOnePaymentMethod'), 'HpsArgumentException', 'Alias can only use one payment method') - ->addValidation(array($this, 'aliasNotNull'), 'HpsArgumentException', 'Alias needs an alias') - ->addValidation(array($this, 'actionNotNull'), 'HpsArgumentException', 'Alias needs an action'); - } - - /** - * Ensures there is only one payment method, and checks that - * there is only one card or one token in use. Both cannot be - * used. - * - * @param array $actionCounts - * - * @return bool - */ - public function onlyOnePaymentMethod($actionCounts) - { - $methods = 0; - if (isset($actionCounts['card']) && $actionCounts['card'] == 1) { - $methods++; - } - if (isset($actionCounts['token']) && $actionCounts['token'] == 1) { - $methods++; - } - return $methods == 1; - } - - /** - * Ensures a card has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function cardNotNull($actionCounts) - { - if ($this->action == 'CREATE') { - return $this->card == null; - } - - return isset($actionCounts['card']); - } - - /** - * Ensures an alias has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function aliasNotNull($actionCounts) - { - return isset($actionCounts['alias']); - } - - /** - * Ensures a action has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function actionNotNull($actionCounts) - { - return isset($actionCounts['action']); - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceBalanceBuilder.php b/classes/includes/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceBalanceBuilder.php deleted file mode 100644 index 1a860de..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceBalanceBuilder.php +++ /dev/null @@ -1,91 +0,0 @@ -setUpValidations(); - } - - /** - * Creates a balance transaction through the HpsGiftCardService - */ - 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 - ); - } - - /** - * Setups up validations for building balances. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'onlyOnePaymentMethod'), 'HpsArgumentException', 'Balance can only use one payment method'); - } - - /** - * Ensures there is only one payment method, and checks that - * there is only one card or one token in use. Both cannot be - * used. - * - * @param array $actionCounts - * - * @return bool - */ - public function onlyOnePaymentMethod($actionCounts) - { - $methods = 0; - if (isset($actionCounts['card']) && $actionCounts['card'] == 1) { - $methods++; - } - if (isset($actionCounts['token']) && $actionCounts['token'] == 1) { - $methods++; - } - return $methods == 1; - } - - /** - * Ensures a card has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function cardNotNull($actionCounts) - { - return isset($actionCounts['card']); - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceDeactivateBuilder.php b/classes/includes/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceDeactivateBuilder.php deleted file mode 100644 index 559373c..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceDeactivateBuilder.php +++ /dev/null @@ -1,91 +0,0 @@ -setUpValidations(); - } - - /** - * Creates a deactivate transaction through the HpsGiftCardService - */ - 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 - ); - } - - /** - * Setups up validations for building deactivates. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'onlyOnePaymentMethod'), 'HpsArgumentException', 'Deactivate can only use one payment method'); - } - - /** - * Ensures there is only one payment method, and checks that - * there is only one card or one token in use. Both cannot be - * used. - * - * @param array $actionCounts - * - * @return bool - */ - public function onlyOnePaymentMethod($actionCounts) - { - $methods = 0; - if (isset($actionCounts['card']) && $actionCounts['card'] == 1) { - $methods++; - } - if (isset($actionCounts['token']) && $actionCounts['token'] == 1) { - $methods++; - } - return $methods == 1; - } - - /** - * Ensures a card has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function cardNotNull($actionCounts) - { - return isset($actionCounts['card']); - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceReplaceBuilder.php b/classes/includes/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceReplaceBuilder.php deleted file mode 100644 index 26a0310..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceReplaceBuilder.php +++ /dev/null @@ -1,78 +0,0 @@ -setUpValidations(); - } - - /** - * Creates a replace transaction through the HpsGiftCardService - */ - public function execute() - { - parent::execute(); - - $replaceSvc = new HpsGiftCardService($this->service->servicesConfig()); - return $replaceSvc->replace( - $this->oldCard, - $this->newCard - ); - } - - /** - * Setups up validations for building replaces. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'oldCardNotNull'), 'HpsArgumentException', 'Replace needs an oldCard') - ->addValidation(array($this, 'newCardNotNull'), 'HpsArgumentException', 'Replace needs a newCard'); - } - - /** - * Ensures an oldCard has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function oldCardNotNull($actionCounts) - { - return isset($actionCounts['oldCard']); - } - - /** - * Ensures a newCard has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function newCardNotNull($actionCounts) - { - return isset($actionCounts['newCard']); - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceReverseBuilder.php b/classes/includes/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceReverseBuilder.php deleted file mode 100644 index 2e22756..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceReverseBuilder.php +++ /dev/null @@ -1,102 +0,0 @@ -setUpValidations(); - } - - /** - * Creates a reverse transaction through the HpsGiftCardService - */ - 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 - ); - } - - /** - * Setups up validations for building reverses. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'cardOrTransactionId'), 'HpsArgumentException', 'Reverse can only use one payment method or a transactionId') - ->addValidation(array($this, 'amountNotNull'), 'HpsArgumentException', 'Reverse needs an amount'); - } - - /** - * Ensures a card has been set. - * - * @param array $actionCounts - * - * @return bool - */ - 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 an amount has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function amountNotNull($actionCounts) - { - return isset($actionCounts['amount']); - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceRewardBuilder.php b/classes/includes/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceRewardBuilder.php deleted file mode 100644 index 84dd289..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceRewardBuilder.php +++ /dev/null @@ -1,124 +0,0 @@ -setUpValidations(); - } - - /** - * Creates a reward transaction through the HpsGiftCardService - */ - 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 - ); - } - - /** - * Setups up validations for building rewards. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'onlyOnePaymentMethod'), 'HpsArgumentException', 'Reward can only use one payment method') - ->addValidation(array($this, 'amountNotNull'), 'HpsArgumentException', 'Reward needs an amount'); - } - - /** - * Ensures there is only one payment method, and checks that - * there is only one card or one token in use. Both cannot be - * used. - * - * @param array $actionCounts - * - * @return bool - */ - public function onlyOnePaymentMethod($actionCounts) - { - $methods = 0; - if (isset($actionCounts['card']) && $actionCounts['card'] == 1) { - $methods++; - } - if (isset($actionCounts['token']) && $actionCounts['token'] == 1) { - $methods++; - } - return $methods == 1; - } - - /** - * Ensures a card has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function cardNotNull($actionCounts) - { - return isset($actionCounts['card']); - } - - /** - * Ensures an amount has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function amountNotNull($actionCounts) - { - return isset($actionCounts['amount']); - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceSaleBuilder.php b/classes/includes/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceSaleBuilder.php deleted file mode 100644 index 9dad6d9..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceSaleBuilder.php +++ /dev/null @@ -1,157 +0,0 @@ -setUpValidations(); - } - - /** - * 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)); - 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'); - } - - /** - * Setups up validations for building sales. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'onlyOnePaymentMethod'), 'HpsArgumentException', 'Sale can only use one payment method') - ->addValidation(array($this, 'amountNotNull'), 'HpsArgumentException', 'Sale needs an amount') - ->addValidation(array($this, 'currencyNotNull'), 'HpsArgumentException', 'Sale needs a currency'); - } - - /** - * Ensures there is only one payment method, and checks that - * there is only one card or one token in use. Both cannot be - * used. - * - * @param array $actionCounts - * - * @return bool - */ - public function onlyOnePaymentMethod($actionCounts) - { - $methods = 0; - if (isset($actionCounts['card']) && $actionCounts['card'] == 1) { - $methods++; - } - if (isset($actionCounts['token']) && $actionCounts['token'] == 1) { - $methods++; - } - return $methods == 1; - } - - /** - * Ensures a card has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function cardNotNull($actionCounts) - { - return isset($actionCounts['card']); - } - - /** - * Ensures an amount has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function amountNotNull($actionCounts) - { - return isset($actionCounts['amount']); - } - - /** - * Ensures a currency has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function currencyNotNull($actionCounts) - { - return isset($actionCounts['currency']); - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceVoidBuilder.php b/classes/includes/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceVoidBuilder.php deleted file mode 100644 index 8626097..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceVoidBuilder.php +++ /dev/null @@ -1,60 +0,0 @@ -setUpValidations(); - } - - /** - * Creates a void transaction through the HpsGiftCardService - */ - public function execute() - { - parent::execute(); - - $voidSvc = new HpsGiftCardService($this->service->servicesConfig()); - return $voidSvc->void( - $this->transactionId - ); - } - - /** - * Setups up validations for building voids. - * - * @return null - */ - private function setUpValidations() - { - $this - ->addValidation(array($this, 'transactionIdNotNull'), 'HpsArgumentException', 'Void needs a transactionId'); - } - - /** - * Ensures a transactionId has been set. - * - * @param array $actionCounts - * - * @return bool - */ - protected function transactionIdNotNull($actionCounts) - { - return isset($actionCounts['transactionId']); - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/HpsFluentCheckService.php b/classes/includes/src/Services/Fluent/Gateway/HpsFluentCheckService.php deleted file mode 100644 index b271d23..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/HpsFluentCheckService.php +++ /dev/null @@ -1,167 +0,0 @@ -_config = $config; - return $this; - } - /** - * @return \HpsCheckServiceOverrideBuilder - */ - public function override() - { - return new HpsCheckServiceOverrideBuilder($this); - } - /** - * @param null $amount - * - * @return \HpsCheckServiceRecurringBuilder - */ - public function recurring($amount = null) - { - $builder = new HpsCheckServiceRecurringBuilder($this); - return $builder->withAmount($amount); - } - /** - * @return \HpsCheckServiceReturnBuilder - */ - public function returnCheck() - { - return new HpsCheckServiceReturnBuilder($this); - } - /** - * @param null $amount - * - * @return \HpsCheckServiceSaleBuilder - */ - public function sale($amount = null) - { - $builder = new HpsCheckServiceSaleBuilder($this); - return $builder - ->withAmount($amount); - } - /** - * @return \HpsCheckServiceVoidBuilder - */ - public function void() - { - return new HpsCheckServiceVoidBuilder($this); - } - /** - * @param $action - * @param \HpsCheck $check - * @param $amount - * @param null $clientTransactionId - * @param bool $checkVerify - * @param bool $achVerify - * - * @return mixed - * @throws \HpsCheckException - * @throws \HpsInvalidRequestException - */ - public function _buildTransaction($action, HpsCheck $check, $amount, $clientTransactionId = null, $checkVerify = false, $achVerify = false) - { - if ($amount != null) { - 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 ($checkVerify || $achVerify) { - $verifyElement = $xml->createElement('hps:VerifyInfo'); - if ($checkVerify) { - $verifyElement->appendChild($xml->createElement('hps:CheckVerify', ($checkVerify ? 'Y' : 'N'))); - } - if ($achVerify) { - $verifyElement->appendChild($xml->createElement('hps:ACHVerify', ($achVerify ? 'Y' : 'N'))); - } - $hpsBlock1->appendChild($verifyElement); - } - - if ($check->checkType != null) { - $hpsBlock1->appendChild($xml->createElement('hps:CheckType', $check->checkType)); - } - if ($check->dataEntryMode != null) { - $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 $transaction - * @param $txnType - * @param null $clientTransactionId - * - * @return mixed - * @throws \HpsAuthenticationException - * @throws \HpsCheckException - * @throws \HpsGatewayException - * @throws null - */ - public function _submitTransaction($transaction, $txnType, $clientTransactionId = null) - { - $rsp = $this->doRequest($transaction, $clientTransactionId); - HpsGatewayResponseValidation::checkResponse($rsp, $txnType); - $response = HpsCheckResponse::fromDict($rsp, $txnType); - - if ($response->responseCode != 0) { - // do a void if timeout response occurs - if ($response->responseCode == 30) { - $this->void() - ->withTransactionId($rsp->Header->GatewayTxnId) - ->execute(); - } - - throw new HpsCheckException( - $rsp->Header->GatewayTxnId, - $response->details, - $response->responseCode, - $response->responseText - ); - } - - return $response; - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/HpsFluentCreditService.php b/classes/includes/src/Services/Fluent/Gateway/HpsFluentCreditService.php deleted file mode 100644 index 1f331ce..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/HpsFluentCreditService.php +++ /dev/null @@ -1,365 +0,0 @@ -_config = $config; - return $this; - } - /** - * @param null $amount - * - * @return \HpsCreditServiceAuthorizeBuilder - */ - public function authorize($amount = null) - { - $builder = new HpsCreditServiceAuthorizeBuilder($this); - return $builder - ->withAmount($amount) - ->withCurrency('usd'); - } - /** - * @param null $transactionId - * - * @return \HpsCreditServiceCaptureBuilder - */ - public function capture($transactionId = null) - { - $builder = new HpsCreditServiceCaptureBuilder($this); - return $builder - ->withTransactionId($transactionId); - } - /** - * @param null $amount - * - * @return \HpsCreditServiceChargeBuilder - */ - public function charge($amount = null) - { - $builder = new HpsCreditServiceChargeBuilder($this); - return $builder - ->withAmount($amount) - ->withCurrency('usd'); - } - /** - * @param null $transactionId - * - * @return \HpsCreditServiceCpcEditBuilder - */ - public function cpcEdit($transactionId = null) - { - $builder = new HpsCreditServiceCpcEditBuilder($this); - return $builder - ->withTransactionId($transactionId); - } - /** - * @return \HpsCreditServiceEditBuilder - */ - public function edit() - { - return new HpsCreditServiceEditBuilder($this); - } - /** - * @return \HpsCreditServiceUpdateTokenExpirationBuilder - */ - public function updateTokenExpiration() - { - $builder = new HpsCreditServiceUpdateTokenExpirationBuilder($this); - //print_r($builder); - return $builder; - } - /** - * @param null $transactionId - * - * @return \HpsCreditServiceGetBuilder - */ - public function get($transactionId = null) - { - $builder = new HpsCreditServiceGetBuilder($this); - return $builder - ->withTransactionId($transactionId); - } - /** - * @return \HpsCreditServiceListTransactionsBuilder - */ - public function listTransactions() - { - return new HpsCreditServiceListTransactionsBuilder($this); - } - /** - * @param null $amount - * - * @return \HpsCreditServiceOfflineAuthBuilder - */ - public function offlineAuth($amount = null) - { - $builder = new HpsCreditServiceOfflineAuthBuilder($this); - return $builder - ->withAmount($amount) - ->withCurrency('usd'); - } - /** - * @param null $amount - * - * @return \HpsCreditServiceOfflineChargeBuilder - */ - public function offlineCharge($amount = null) - { - $builder = new HpsCreditServiceOfflineChargeBuilder($this); - return $builder - ->withAmount($amount) - ->withCurrency('usd'); - } - /** - * @return \HpsCreditServicePrepaidBalanceInquiryBuilder - */ - public function prepaidBalanceInquiry() - { - return new HpsCreditServicePrepaidBalanceInquiryBuilder($this); - } - /** - * @param null $amount - * - * @return \HpsCreditServicePrepaidAddValueBuilder - */ - public function prepaidAddValue($amount = null) - { - $builder = new HpsCreditServicePrepaidAddValueBuilder($this); - return $builder - ->withAmount($amount) - ->withCurrency('usd'); - } - /** - * @param null $amount - * - * @return \HpsCreditServiceRecurringBuilder - */ - public function recurring($amount = null) - { - $builder = new HpsCreditServiceRecurringBuilder($this); - return $builder->withAmount($amount); - } - /** - * @param null $amount - * - * @return \HpsCreditServiceRefundBuilder - */ - public function refund($amount = null) - { - $builder = new HpsCreditServiceRefundBuilder($this); - return $builder - ->withAmount($amount) - ->withCurrency('usd'); - } - /** - * @param null $amount - * - * @return \HpsCreditServiceReverseBuilder - */ - public function reverse($amount = null) - { - $builder = new HpsCreditServiceReverseBuilder($this); - return $builder - ->withAmount($amount) - ->withCurrency('usd'); - } - /** - * @return \HpsAccountVerify - */ - public function verify() - { - return new HpsCreditServiceVerifyBuilder($this); - } - /** - * @param null $transactionId - * - * @return \HpsCreditServiceVoidBuilder - */ - public function void($transactionId = null) - { - $builder = new HpsCreditServiceVoidBuilder($this); - return $builder - ->withTransactionId($transactionId); - } - /** - * @param $response - * @param $expectedType - * - * @throws \HpsAuthenticationException - * @throws \HpsGatewayException - * @throws null - */ - private function _processChargeGatewayResponse($response, $expectedType) - { - $gatewayRspCode = (isset($response->Header->GatewayRspCode) ? $response->Header->GatewayRspCode : null); - $transactionId = (isset($response->Header->GatewayTxnId) ? $response->Header->GatewayTxnId : null); - - if ($gatewayRspCode == '0') { - return; - } - - if ($gatewayRspCode == '30') { - try { - $this->reverse($this->_amount)->withTransactionId($transactionId)->execute(); - } catch (Exception $e) { - throw new HpsGatewayException( - HpsExceptionCodes::GATEWAY_TIMEOUT_REVERSAL_ERROR, - 'Error occurred while reversing a charge due to HPS gateway timeout', - $e - ); - } - } - - HpsGatewayResponseValidation::checkResponse($response, $expectedType); - } - /** - * @param $response - * @param $expectedType - * - * @throws \HpsCreditException - * @throws null - */ - private function _processChargeIssuerResponse($response, $expectedType) - { - $transactionId = (isset($response->Header->GatewayTxnId) ? $response->Header->GatewayTxnId : null); - $item = $response->Transaction->$expectedType; - - if ($item != null) { - $responseCode = (isset($item->RspCode) ? $item->RspCode : null); - $responseText = (isset($item->RspText) ? $item->RspText : null); - - if ($responseCode != null) { - // check if we need to do a reversal - if ($responseCode == '91') { - try { - $this->reverse($this->_amount)->withTransactionId($transactionId)->execute(); - } catch (HpsGatewayException $e) { - // if the transaction wasn't found; throw the original timeout exception - if ($e->details->gatewayResponseCode == 3) { - HpsIssuerResponseValidation::checkResponse($transactionId, $responseCode, $responseText); - } - throw new HpsCreditException( - $transactionId, - HpsExceptionCodes::ISSUER_TIMEOUT_REVERSAL_ERROR, - 'Error occurred while reversing a charge due to HPS issuer timeout', - $e - ); - } catch (HpsException $e) { - throw new HpsCreditException( - $transactionId, - HpsExceptionCodes::ISSUER_TIMEOUT_REVERSAL_ERROR, - 'Error occurred while reversing a charge due to HPS issuer timeout', - $e - ); - } - } - HpsIssuerResponseValidation::checkResponse($transactionId, $responseCode, $responseText); - } - } - } - /** - * @param $transaction - * @param $txnType - * @param null $clientTxnId - * @param null $cardData - * - * @return array|null - * @throws \HpsCreditException - * @throws \HpsException - * @throws \HpsGatewayException - */ - public function _submitTransaction($transaction, $txnType, $clientTxnId = null, $cardData = null) - { - try { - $response = $this->doRequest($transaction, $clientTxnId); - } catch (HpsException $e) { - if ($e->innerException != null && $e->innerException->getMessage() == 'gateway_time-out') { - if (in_array($txnType, array('CreditSale', 'CreditAuth'))) { - try { - $this->reverse($this->_amount)->withCard($cardData)->execute(); - } 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 'ReportTxnDetail': - $rvalue = HpsReportTransactionDetails::fromDict($response, $txnType); - break; - case 'ReportActivity': - $rvalue = HpsReportTransactionSummary::fromDict($response, $txnType, $this->_filterBy); - break; - case 'CreditSale': - $rvalue = HpsCharge::fromDict($response, $txnType); - break; - case 'CreditAccountVerify': - $rvalue = HpsAccountVerify::fromDict($response, $txnType); - break; - case 'CreditAuth': - $rvalue = HpsAuthorization::fromDict($response, $txnType); - break; - case 'CreditReturn': - $rvalue = HpsRefund::fromDict($response, $txnType); - break; - case 'CreditReversal': - $rvalue = HpsReversal::fromDict($response, $txnType); - break; - case 'CreditVoid': - $rvalue = HpsVoid::fromDict($response, $txnType); - break; - case 'CreditCPCEdit': - $rvalue = HpsCPCEdit::fromDict($response, $txnType); - break; - case 'CreditTxnEdit': - $rvalue = HpsTransaction::fromDict($response, $txnType); - break; - case 'RecurringBilling': - $rvalue = HpsRecurringBilling::fromDict($response, $txnType); - break; - case 'CreditAdditionalAuth': - $rvalue = HpsAuthorization::fromDict($response, $txnType); - break; - case 'PrePaidBalanceInquiry': - $rvalue = HpsAuthorization::fromDict($response, $txnType); - break; - case 'PrePaidAddValue': - $rvalue = HpsAuthorization::fromDict($response, $txnType); - break; - case 'CreditOfflineAuth': - $rvalue = HpsOfflineAuthorization::fromDict($response, $txnType); - break; - case 'ManageTokens': - $rvalue = HpsManageTokensResponse::fromDict($response, $txnType); - break; - default: - break; - } - - return $rvalue; - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/HpsFluentDebitService.php b/classes/includes/src/Services/Fluent/Gateway/HpsFluentDebitService.php deleted file mode 100644 index e68ce6b..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/HpsFluentDebitService.php +++ /dev/null @@ -1,71 +0,0 @@ -_config = $config; - return $this; - } - /** - * @param null $amount - * - * @return \HpsDebitServiceAddValueBuilder - */ - public function addValue($amount = null) - { - $builder = new HpsDebitServiceAddValueBuilder($this); - return $builder - ->withAmount($amount); - } - /** - * @param null $amount - * - * @return \HpsDebitServiceChargeBuilder - */ - public function charge($amount = null) - { - $builder = new HpsDebitServiceChargeBuilder($this); - return $builder - ->withAmount($amount); - } - /** - * @param null $transactionId - * - * @return \HpsDebitServiceReturnBuilder - */ - public function returnDebit($transactionId = null) - { - $builder = new HpsDebitServiceReturnBuilder($this); - return $builder - ->withTransactionId($transactionId); - } - /** - * @param null $transactionId - * - * @return \HpsDebitServiceReverseBuilder - */ - public function reverse($transactionId = null) - { - $builder = new HpsDebitServiceReverseBuilder($this); - return $builder - ->withTransactionId($transactionId); - } -} diff --git a/classes/includes/src/Services/Fluent/Gateway/HpsFluentGiftCardService.php b/classes/includes/src/Services/Fluent/Gateway/HpsFluentGiftCardService.php deleted file mode 100644 index 849eb6e..0000000 --- a/classes/includes/src/Services/Fluent/Gateway/HpsFluentGiftCardService.php +++ /dev/null @@ -1,186 +0,0 @@ -_config = $config; - return $this; - } - /** - * @param null $amount - * - * @return \HpsGiftCardServiceActivateBuilder - */ - public function activate($amount = null) - { - $builder = new HpsGiftCardServiceActivateBuilder($this); - return $builder - ->withAmount($amount) - ->withCurrency('usd'); - } - /** - * @param null $amount - * - * @return \HpsGiftCardServiceAddValueBuilder - */ - public function addValue($amount = null) - { - $builder = new HpsGiftCardServiceAddValueBuilder($this); - return $builder - ->withAmount($amount); - } - /** - * @return \HpsGiftCardServiceAliasBuilder - */ - public function alias() - { - return new HpsGiftCardServiceAliasBuilder($this); - } - /** - * @return \HpsGiftCardServiceBalanceBuilder - */ - public function balance() - { - return new HpsGiftCardServiceBalanceBuilder($this); - } - /** - * @return \HpsGiftCardServiceDeactivateBuilder - */ - public function deactivate() - { - return new HpsGiftCardServiceDeactivateBuilder($this); - } - /** - * @return \HpsGiftCardServiceReplaceBuilder - */ - public function replace() - { - return new HpsGiftCardServiceReplaceBuilder($this); - } - /** - * @param null $amount - * - * @return \HpsGiftCardServiceReverseBuilder - */ - public function reverse($amount = null) - { - $builder = new HpsGiftCardServiceReverseBuilder($this); - return $builder - ->withAmount($amount) - ->withCurrency('usd'); - } - /** - * @param null $amount - * - * @return \HpsGiftCardServiceRewardBuilder - */ - public function reward($amount = null) - { - $builder = new HpsGiftCardServiceRewardBuilder($this); - return $builder - ->withAmount($amount) - ->withCurrency('usd'); - } - /** - * @param null $amount - * - * @return \HpsGiftCardServiceSaleBuilder - */ - public function sale($amount = null) - { - $builder = new HpsGiftCardServiceSaleBuilder($this); - return $builder - ->withAmount($amount) - ->withCurrency('usd'); - } - /** - * @param null $transactionId - * - * @return \HpsGiftCardServiceVoidBuilder - */ - public function void($transactionId = null) - { - $builder = new HpsGiftCardServiceVoidBuilder($this); - return $builder - ->withTransactionId($transactionId); - } - /** - * @param $transaction - * @param $txnType - * @param null $clientTxnId - * - * @return \HpsGiftCardAlias|string - * @throws \HpsAuthenticationException - * @throws \HpsCreditException - * @throws \HpsGatewayException - * @throws null - */ - public function _submitTransaction($transaction, $txnType, $clientTxnId = null) - { - $response = $this->doRequest($transaction, $clientTxnId); - - HpsGatewayResponseValidation::checkResponse($response, $txnType); - HpsIssuerResponseValidation::checkResponse( - $response->Header->GatewayTxnId, - $response->Transaction->$txnType->RspCode, - $response->Transaction->$txnType->RspText, - 'gift' - ); - - $rvalue = ''; - switch ($txnType) { - case 'GiftCardActivate': - $rvalue = HpsGiftCardActivate::fromDict($response, $txnType, 'HpsGiftCardActivate'); - break; - case 'GiftCardAddValue': - $rvalue = HpsGiftCardAddValue::fromDict($response, $txnType, 'HpsGiftCardAddValue'); - break; - case 'GiftCardAlias': - $rvalue = HpsGiftCardAlias::fromDict($response, $txnType, 'HpsGiftCardAlias'); - break; - case 'GiftCardBalance': - $rvalue = HpsGiftCardBalance::fromDict($response, $txnType, 'HpsGiftCardBalance'); - break; - case 'GiftCardDeactivate': - $rvalue = HpsGiftCardDeactivate::fromDict($response, $txnType, 'HpsGiftCardDeactivate'); - break; - case 'GiftCardReplace': - $rvalue = HpsGiftCardReplace::fromDict($response, $txnType, 'HpsGiftCardReplace'); - break; - case 'GiftCardReward': - $rvalue = HpsGiftCardReward::fromDict($response, $txnType, 'HpsGiftCardReward'); - break; - case 'GiftCardSale': - $rvalue = HpsGiftCardSale::fromDict($response, $txnType, 'HpsGiftCardSale'); - break; - case 'GiftCardVoid': - $rvalue = HpsGiftCardVoid::fromDict($response, $txnType, 'HpsGiftCardVoid'); - break; - case 'GiftCardReversal': - $rvalue = HpsGiftCardReversal::fromDict($response, $txnType, 'HpsGiftCardReversal'); - break; - default: - break; - } - - return $rvalue; - } -} diff --git a/classes/includes/src/Services/Gateway/AltPayment/HpsAltPaymentService.php b/classes/includes/src/Services/Gateway/AltPayment/HpsAltPaymentService.php deleted file mode 100644 index 9c83fe3..0000000 --- a/classes/includes/src/Services/Gateway/AltPayment/HpsAltPaymentService.php +++ /dev/null @@ -1,484 +0,0 @@ -createElement('hps:Transaction'); - $auth = $xml->createElement('hps:AltPaymentAuth'); - - $auth->appendChild($xml->createElement('hps:TransactionType', $this->_transactionType)); - $auth->appendChild($xml->createElement('hps:SessionId', $sessionId)); - $auth->appendChild($this->hydrateBuyerData($buyer, $xml)); - $auth->appendChild($xml->createElement('hps:Amt', $amount)); - $auth->appendChild($this->hydratePaymentData($payment, $xml)); - if ($shippingAddress != null) { - $auth->appendChild($this->hydrateShippingData($shippingAddress, $xml)); - } - if ($lineItems != null) { - $auth->appendChild($this->hydrateLineItems($lineItems, $xml)); - } - - $transaction->appendChild($auth); - return $this->_submitTransaction($transaction, 'AltPaymentAuth'); - } - /** - * @param $transactionId - * @param $amount - * - * @return null - * @throws \HpsException - * @throws \HpsInvalidRequestException - */ - public function capture($transactionId, $amount) - { - HpsInputValidation::checkAmount($amount); - - $xml = new DOMDocument(); - $transaction = $xml->createElement('hps:Transaction'); - $capture = $xml->createElement('hps:AltPaymentCapture'); - - $capture->appendChild($xml->createElement('hps:TransactionType', $this->_transactionType)); - $capture->appendChild($xml->createElement('hps:GatewayTxnId', $transactionId)); - $capture->appendChild($xml->createElement('hps:Amt', $amount)); - - $payment = $xml->createElement('hps:Payment'); - $nvp = $xml->createElement('hps:NameValuePair'); - $nvp->appendChild($xml->createElement('hps:Name', 'FullyCapturedFlag')); - $nvp->appendChild($xml->createElement('hps:Value', 'true')); - $payment->appendChild($nvp); - - $capture->appendChild($payment); - $transaction->appendChild($capture); - return $this->_submitTransaction($transaction, 'AltPaymentCapture'); - } - /** - * @param $amount - * @param $currency - * @param \HpsBuyerData|null $buyer - * @param \HpsPaymentData|null $payment - * @param \HpsShippingInfo|null $shippingAddress - * @param null $lineItems - * - * @return null - * @throws \HpsException - * @throws \HpsInvalidRequestException - */ - public function createSession($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'); - $createSession = $xml->createElement('hps:AltPaymentCreateSession'); - - $createSession->appendChild($xml->createElement('hps:TransactionType', $this->_transactionType)); - $createSession->appendChild($this->hydrateBuyerData($buyer, $xml)); - $createSession->appendChild($xml->createElement('hps:Amt', $amount)); - $createSession->appendChild($this->hydratePaymentData($payment, $xml)); - if ($shippingAddress != null) { - $createSession->appendChild($this->hydrateShippingData($shippingAddress, $xml)); - } - if ($lineItems != null) { - $createSession->appendChild($this->hydrateLineItems($lineItems, $xml)); - } - - $transaction->appendChild($createSession); - return $this->_submitTransaction($transaction, 'AltPaymentCreateSession'); - } - /** - * @param $transactionId - * @param bool $isPartial - * @param null $partialAmount - * - * @return null - * @throws \HpsException - */ - public function refund($transactionId, $isPartial = false, $partialAmount = null) - { - $xml = new DOMDocument(); - $transaction = $xml->createElement('hps:Transaction'); - $return = $xml->createElement('hps:AltPaymentReturn'); - - $return->appendChild($xml->createElement('hps:TransactionType', $this->_transactionType)); - $return->appendChild($xml->createElement('hps:GatewayTxnId', $transactionId)); - - if ($isPartial) { - $return->appendChild($xml->createElement('hps:Amt', $partialAmount)); - } - - $payment = $xml->createElement('hps:Return'); - $nvp = $xml->createElement('hps:NameValuePair'); - $nvp->appendChild($xml->createElement('hps:Name', 'ReturnType')); - $nvp->appendChild($xml->createElement('hps:Value', $isPartial ? 'partial' : 'full')); - $payment->appendChild($nvp); - - $return->appendChild($payment); - $transaction->appendChild($return); - return $this->_submitTransaction($transaction, 'AltPaymentReturn'); - } - /** - * @param $sessionId - * @param $amount - * @param $currency - * @param \HpsBuyerData|null $buyer - * @param \HpsPaymentData|null $payment - * @param \HpsShippingInfo|null $shippingAddress - * @param null $lineItems - * - * @return null - * @throws \HpsException - * @throws \HpsInvalidRequestException - */ - 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'); - } - /** - * @param $transactionId - * - * @return null - * @throws \HpsException - */ - public function void($transactionId) - { - $xml = new DOMDocument(); - $transaction = $xml->createElement('hps:Transaction'); - $void = $xml->createElement('hps:AltPaymentVoid'); - - $void->appendChild($xml->createElement('hps:TransactionType', $this->_transactionType)); - $void->appendChild($xml->createElement('hps:GatewayTxnId', $transactionId)); - - $transaction->appendChild($void); - return $this->_submitTransaction($transaction, 'AltPaymentVoid'); - } - /** - * @param $sessionId - * - * @return null - * @throws \HpsException - */ - public function sessionInfo($sessionId) - { - $xml = new DOMDocument(); - $transaction = $xml->createElement('hps:Transaction'); - $info = $xml->createElement('hps:AltPaymentSessionInfo'); - - $info->appendChild($xml->createElement('hps:TransactionType', $this->_transactionType)); - $info->appendChild($xml->createElement('hps:SessionId', $sessionId)); - - $transaction->appendChild($info); - return $this->_submitTransaction($transaction, 'AltPaymentSessionInfo'); - } - /** - * @param $type - */ - public function setTransactionType($type) - { - $this->_transactionType = $type; - } - /** - * @param $transactionId - * - * @return null - * @throws \HpsException - */ - public function status($transactionId) - { - $xml = new DOMDocument(); - $transaction = $xml->createElement('hps:Transaction'); - $status = $xml->createElement('hps:GetTransactionStatus'); - - $status->appendChild($xml->createElement('hps:GatewayTxnId', $transactionId)); - - $transaction->appendChild($status); - return $this->_submitTransaction($transaction, 'GetTransactionStatus'); - } - /** - * @param \HpsBuyerData $buyer - * @param \DOMDocument $xml - * - * @return \DOMElement - */ - protected function hydrateBuyerData(HpsBuyerData $buyer, DOMDocument $xml) - { - $data = $xml->createElement('hps:Buyer'); - if (isset($buyer->returnUrl)) { - $data->appendChild($this->hydrateNameValuePair('ReturnUrl', $buyer->returnUrl, $xml)); - } - if (isset($buyer->cancelUrl)) { - $data->appendChild($this->hydrateNameValuePair('CancelUrl', $buyer->cancelUrl, $xml)); - } - if (isset($buyer->emailAddress)) { - $data->appendChild($this->hydrateNameValuePair('EmailAddress', $buyer->emailAddress, $xml)); - } - if (isset($buyer->payerId)) { - $data->appendChild($this->hydrateNameValuePair('BuyerId', $buyer->payerId, $xml)); - } - if (isset($buyer->credit) && $buyer->credit != false) { - $data->appendChild($this->hydrateNameValuePair('FundingSource', 'credit', $xml)); - } - return $data; - } - /** - * @param $items - * @param \DOMDocument $xml - * - * @return \DOMElement - */ - protected function hydrateLineItems($items, DOMDocument $xml) - { - $lineItems = $xml->createElement('hps:LineItem'); - - foreach ($items as $item) { - if (!$item instanceof HpsLineItem) { - continue; - } - $detail = $xml->createElement('hps:Detail'); - if (isset($item->name)) { - $detail->appendChild($this->hydrateNameValuePair('Name', $item->name, $xml)); - } - if (isset($item->description)) { - $detail->appendChild($this->hydrateNameValuePair('Description', $item->description, $xml)); - } - if (isset($item->number)) { - $detail->appendChild($this->hydrateNameValuePair('Number', $item->number, $xml)); - } - if (isset($item->amount)) { - $detail->appendChild($this->hydrateNameValuePair('Amount', $item->amount, $xml)); - } - if (isset($item->quantity)) { - $detail->appendChild($this->hydrateNameValuePair('Quantity', $item->quantity, $xml)); - } - if (isset($item->taxAmount)) { - $detail->appendChild($this->hydrateNameValuePair('TaxAmount', $item->taxAmount, $xml)); - } - $lineItems->appendChild($detail); - } - return $lineItems; - } - /** - * @param $name - * @param $value - * @param \DOMDocument $xml - * - * @return \DOMElement - */ - protected function hydrateNameValuePair($name, $value, DOMDocument $xml) - { - $nvp = $xml->createElement('hps:NameValuePair'); - $nvp->appendChild($xml->createElement('hps:Name', $name)); - $nvp->appendChild($xml->createElement('hps:Value', HpsInputValidation::cleanAscii($value))); - return $nvp; - } - /** - * @param \HpsPaymentData $payment - * @param \DOMDocument $xml - * - * @return \DOMElement - */ - protected function hydratePaymentData(HpsPaymentData $payment, DOMDocument $xml) - { - $data = $xml->createElement('hps:Payment'); - $data->appendChild($this->hydrateNameValuePair('ItemAmount', $payment->subtotal, $xml)); - if (isset($payment->shippingAmount)) { - $data->appendChild($this->hydrateNameValuePair('ShippingAmount', $payment->shippingAmount, $xml)); - } - if (isset($payment->taxAmount)) { - $data->appendChild($this->hydrateNameValuePair('TaxAmount', $payment->taxAmount, $xml)); - } - if (isset($payment->paymentType)) { - $data->appendChild($this->hydrateNameValuePair('PaymentType', $payment->paymentType, $xml)); - } - if (isset($payment->invoiceNumber)) { - $data->appendChild($this->hydrateNameValuePair('InvoiceNbr', $payment->invoiceNumber, $xml)); - } - return $data; - } - /** - * @param \HpsShippingInfo $info - * @param \DOMDocument $xml - * - * @return \DOMElement - */ - protected function hydrateShippingData(HpsShippingInfo $info, DOMDocument $xml) - { - $shipping = $xml->createElement('hps:Shipping'); - $address = $xml->createElement('hps:Address'); - $address->appendChild($this->hydrateNameValuePair('AllowAddressOverride', 'false', $xml)); - $address->appendChild($this->hydrateNameValuePair('ShipName', $info->name, $xml)); - $address->appendChild($this->hydrateNameValuePair('ShipAddress', $info->address->address, $xml)); - $address->appendChild($this->hydrateNameValuePair('ShipCity', $info->address->city, $xml)); - $address->appendChild($this->hydrateNameValuePair('ShipState', $info->address->state, $xml)); - $address->appendChild($this->hydrateNameValuePair('ShipZip', $info->address->zip, $xml)); - $address->appendChild($this->hydrateNameValuePair('ShipCountryCode', $info->address->country, $xml)); - $shipping->appendChild($address); - return $shipping; - } - /** - * @param $response - * @param $expectedType - * - * @throws \HpsAuthenticationException - * @throws \HpsGatewayException - * @throws null - */ - private function _processGatewayResponse($response, $expectedType) - { - $gatewayRspCode = (isset($response->Header->GatewayRspCode) ? $response->Header->GatewayRspCode : null); - $transactionId = (isset($response->Header->GatewayTxnId) ? $response->Header->GatewayTxnId : null); - - if ($gatewayRspCode == '0') { - return; - } - - if ($gatewayRspCode == '30') { - try { - $this->void($transactionId); - } catch (Exception $e) { - throw new HpsGatewayException( - HpsExceptionCodes::GATEWAY_TIMEOUT_REVERSAL_ERROR, - 'Error occurred while reversing a charge due to HPS gateway timeout', - $e, - null, - null, - $transactionId - ); - } - } - - HpsGatewayResponseValidation::checkResponse($response, $expectedType); - } - /** - * @param $response - * @param $expectedType - * - * @throws \HpsProcessorException - * @throws null - */ - private function _processProcessorResponse($response, $expectedType) - { - $transactionId = (isset($response->Header->GatewayTxnId) ? $response->Header->GatewayTxnId : null); - $item = $response->Transaction->$expectedType; - - if ($item != null) { - $responseCode = (isset($item->RspCode) ? $item->RspCode : null); - $responseMessage = (isset($item->RspMessage) ? $item->RspMessage : null); - - if ($responseCode == null && isset($item->TransactionStatus->RspCode)) { - $responseCode = $item->TransactionStatus->RspCode; - } - if ($responseMessage == null && isset($item->TransactionStatus->RspText)) { - $responseMessage = $item->TransactionStatus->RspText; - } - - HpsProcessorResponseValidation::checkResponse($transactionId, $responseCode, $responseMessage, $item); - } - } - /** - * @param $transaction - * @param $txnType - * @param null $clientTxnId - * @param null $cardData - * - * @return null - * @throws \HpsException - * @throws \HpsGatewayException - */ - private function _submitTransaction($transaction, $txnType, $clientTxnId = null, $cardData = null) - { - try { - $response = $this->doRequest($transaction, $clientTxnId); - } catch (HpsException $e) { - if ($e->innerException != null && $e->innerException->getMessage() == 'gateway_time-out') { - // if (in_array($txnType, array('CreditSale', 'CreditAuth'))) { - // 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->_processGatewayResponse($response, $txnType); - $this->_processProcessorResponse($response, $txnType); - - $rvalue = null; - switch ($txnType) { - case 'AltPaymentCreateSession': - $rvalue = HpsAltPaymentCreateSession::fromDict($response, $txnType); - break; - case 'AltPaymentSessionInfo': - $rvalue = HpsAltPaymentSessionInfo::fromDict($response, $txnType); - break; - case 'AltPaymentSale': - $rvalue = HpsAltPaymentSale::fromDict($response, $txnType); - break; - case 'AltPaymentAuth': - $rvalue = HpsAltPaymentAuth::fromDict($response, $txnType); - break; - case 'AltPaymentCapture': - $rvalue = HpsAltPaymentCapture::fromDict($response, $txnType); - break; - case 'AltPaymentReturn': - $rvalue = HpsAltPaymentReturn::fromDict($response, $txnType); - break; - case 'AltPaymentVoid': - $rvalue = HpsAltPaymentVoid::fromDict($response, $txnType); - break; - case 'GetTransactionStatus': - $rvalue = HpsTransactionStatus::fromDict($response, $txnType); - break; - default: - break; - } - - return $rvalue; - } -} diff --git a/classes/includes/src/Services/Gateway/AltPayment/HpsMasterPassService.php b/classes/includes/src/Services/Gateway/AltPayment/HpsMasterPassService.php deleted file mode 100644 index 6a065ff..0000000 --- a/classes/includes/src/Services/Gateway/AltPayment/HpsMasterPassService.php +++ /dev/null @@ -1,622 +0,0 @@ - - * @license https://github.com/hps/heartland-php/blob/master/LICENSE.txt Custom - * @link https://github.com/hps/heartland-php - */ - -/** - * MasterPass using Cardinal Commerce - * - * @category PHP - * @package HPS - * @author Heartland Payment Systems - * @license https://github.com/hps/heartland-php/blob/master/LICENSE.txt Custom - * @link https://github.com/hps/heartland-php - */ -class HpsMasterPassService - extends HpsCentinelGatewayService - implements HpsAltPaymentServiceInterface -{ - protected static $currencyCodes = array( - 'usd' => '840', - ); - - /** - * Updates the Merchant’s front-end order number with their back-end order - * number in the Centinel system. The Merchant’s original order number is - * persisted and searchable. The transaction expects the OrderId and - * OrderNumber values to correspond to the original Lookup response message. - * - * @param string $orderId order id from Cardinal - * @param HpsOrderData $orderData Cardinal/MasterPass specific data - * - * @return object - */ - public function addOrderNumber( - $orderId, - HpsOrderData $orderData - ) { - $payload = array( - 'OrderId' => $orderId, - 'OrderNumber' => $orderData->orderNumber, - 'TransactionType' => 'WT', - ); - return $this->submitTransaction($payload, 'cmpi_add_order_number'); - } - - /** - * Responsible for returning the status of the MasterPass transaction to the - * Merchant. The message will return the status of the transaction, enabling - * the Merchant to handle the order according to the outcome. In the event - * that the ErrorNo element is 0 (zero) then the PAResStatus value will define - * how the transaction should be processed. Based on the transaction outcome - * the Merchant's order management system should be updated and the appropriate - * message should be displayed to the consumer. In the event that a nonzero - * ErrorNo value is returned or PAResStatus value is not Y, the consumer should - * be prompted for an alternate form of payment. - * - * @param string $orderId order id from Cardinal - * @param string $oauthToken oauth token from MasterPass - * @param string $oauthVerifier oauth verifier from MasterPass - * @param string $payload payload data from Cardinal - * @param string $resourceUrl resource URL from MasterPass - * @param HpsOrderData $orderData Cardinal/MasterPass specific data - * - * @return object - */ - public function authenticate( - $orderId, - $oauthToken, - $oauthVerifier, - $payload, - $resourceUrl, - HpsOrderData $orderData = null - ) { - $data = array( - 'OrderId' => $orderId, - 'PAResPayload' => $payload, - 'Status' => $orderData->transactionStatus, - 'TransactionType' => 'WT', - ); - - if ($orderData->checkoutType === HpsCentinelCheckoutType::PAIRING - || $orderData->checkoutType === HpsCentinelCheckoutType::PAIRING_CHECKOUT - ) { - $data['PairingToken'] = $orderData->pairingToken; - $data['PairingVerifier'] = $orderData->pairingVerifier; - } - - if ($orderData->checkoutType === null - || $orderData->checkoutType === HpsCentinelCheckoutType::LIGHTBOX - || $orderData->checkoutType === HpsCentinelCheckoutType::PAIRING_CHECKOUT - ) { - $data['CheckoutResourceUrl'] = $resourceUrl; - $data['OAuthToken'] = $oauthToken; - $data['OAuthVerifier'] = $oauthVerifier; - } - - return $this->submitTransaction($data, 'cmpi_authenticate'); - } - - /** - * 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 $lineItems line items from order - * @param HpsOrderData $orderData Cardinal/MasterPass specific - * data - * - * @return object - */ - public function authorize( - $orderId, - $amount, - $currency, - HpsBuyerData $buyer = null, - HpsPaymentData $payment = null, - HpsShippingInfo $shippingAddress = null, - $lineItems = null, - HpsOrderData $orderData = null - ) { - $payload = array( - 'TransactionType' => 'WT', - 'Amount' => $this->formatAmount($amount), - 'OrderId' => $orderId, - 'CurrencyCode' => $this->currencyStringToNumeric($currency), - ); - 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_authorize'); - } - - /** - * 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 - */ - 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 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 $lineItems line items from order - * @param HpsOrderData $orderData Cardinal/MasterPass specific - * data - * - * @return object - */ - 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'); - } - - /** - * 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 - */ - public function preApproval( - $longAccessToken, - HpsOrderData $orderData = null - ) { - $payload = array( - 'LongAccessToken' => $longAccessToken, - 'SubMsgType' => 'cmpi_preapproval', - 'TransactionType' => 'WT', - ); - return $this->submitTransaction($payload, 'cmpi_baseserver_api'); - } - - /** - * 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 - */ - 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 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 $lineItems line items from order - * @param HpsOrderData $orderData Cardinal/MasterPass specific - * data - * - * @return object - */ - 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, - ); - } - - /** - * 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 - */ - public function void( - $orderId, - HpsOrderData $orderData = null - ) { - $payload = array( - 'OrderId' => $orderId, - ); - return $this->submitTransaction($payload, 'cmpi_void'); - } - - /** - * Gets information about a MasterPass session - * - * @param string $orderId order id from Cardinal - * @param HpsOrderData $orderData Cardinal/MasterPass specific data - * - * @return object - */ - public function sessionInfo( - $orderId, - HpsOrderData $orderData = null - ) { - } - - /** - * Gets checkout type from `$orderData` or `lightbox` if not set - * - * @param HpsOrderData $orderData the order data - * - * @return string - */ - protected function getCheckoutType(HpsOrderData $orderData) - { - return isset($orderData->checkoutType) - ? $orderData->checkoutType - : 'lightbox'; - } - /** - * Converts a 3-letter currency code to 3-digit ISO 4217 version - * - * @param string $currency currency code - * - * @return string - * @throws \HpsArgumentException - * @raises HpsArgumentException - */ - 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 HpsBuyerData into expected format for Cardinal - * - * @param HpsBuyerData $buyer buyer information - * - * @return array - */ - 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 HpsLineItem's into expected format for Cardinal - * - * @param array $items line items from order - * - * @return array - */ - 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 HpsShippingInfo into expected format for Cardinal - * - * @param HpsPaymentData $payment payment information - * - * @return array - */ - 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 HpsShippingInfo $shipping shipping information - * - * @return array - */ - 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, - ); - } - - /** - * Formats the amount in form of cents - * - * @param mixed $amount amount to be formatted - * - * @return string - */ - protected function formatAmount($amount) - { - return sprintf('%s', ceil(intval($amount) * 100)); - // return $amount; - } - /** - * Processes the response from Cardinal - * - * @param object $response response from Cardinal - * - * @return null - * @throws \HpsException - */ - 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 MasterPass - * - * @param object $response response from Cardinal - * - * @return null - * @throws \HpsException - */ - protected function processProcessorResponse($response) - { - $statusCode = isset($response->StatusCode) - ? (string)$response->StatusCode - : null; - - if ($statusCode == null || $statusCode == 'Y') { - return; - } - - throw new HpsException((string)$response->ErrorDesc); - } - - /** - * Submits a transaction to the gateway - * - * @param array $request request payload - * @param string $txnType type of transaction to be ran - * - * @return object - */ - 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; - } -} diff --git a/classes/includes/src/Services/Gateway/AltPayment/HpsPayPalService.php b/classes/includes/src/Services/Gateway/AltPayment/HpsPayPalService.php deleted file mode 100644 index f7d1b95..0000000 --- a/classes/includes/src/Services/Gateway/AltPayment/HpsPayPalService.php +++ /dev/null @@ -1,9 +0,0 @@ -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 \DOMElement $transaction - * @param string $txnType - * - * @return array|null - * @throws \HpsException - * @throws \HpsGatewayException - */ - 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 SimpleXMLElement $response raw XML response - * @param string $expectedType - * @throws HpsAuthenticationException - * @throws HpsGatewayException - * @throws null - */ - private function _processGatewayResponse($response, $expectedType) - { - $gatewayRspCode = (isset($response->Header->GatewayRspCode) ? $response->Header->GatewayRspCode : null); - $transactionId = (isset($response->Header->GatewayTxnId) ? (float)$response->Header->GatewayTxnId : null); - - if ($gatewayRspCode == '0') { - return; - } - - if ($gatewayRspCode == '3') { - throw new HpsGatewayException( - HpsExceptionCodes::GATEWAY_ERROR, - 'Image could not be retrieved for ' . $transactionId, - null, - null, - null, - $transactionId - ); - } - - HpsGatewayResponseValidation::checkResponse($response, $expectedType); - } -} \ No newline at end of file diff --git a/classes/includes/src/Services/Gateway/HpsBatchService.php b/classes/includes/src/Services/Gateway/HpsBatchService.php deleted file mode 100644 index 6a2e1bd..0000000 --- a/classes/includes/src/Services/Gateway/HpsBatchService.php +++ /dev/null @@ -1,43 +0,0 @@ -createElement('hps:Transaction'); - $hpsBatchClose = $xml->createElement('hps:BatchClose'); - $hpsTransaction->appendChild($hpsBatchClose); - - $response = $this->doRequest($hpsTransaction); - HpsGatewayResponseValidation::checkResponse($response, 'BatchClose'); - - //Process the response - $batchClose = $response->Transaction->BatchClose; - $result = new HpsBatch(); - $result->id = (isset($batchClose->BatchId) ? $batchClose->BatchId : null); - $result->sequenceNumber = (isset($batchClose->BatchSeqNbr) ? $batchClose->BatchSeqNbr : null); - $result->totalAmount = (isset($batchClose->TotalAmt) ? $batchClose->TotalAmt : null); - $result->transactionCount = (isset($batchClose->TxnCnt) ? $batchClose->TxnCnt : null); - - return $result; - } -} diff --git a/classes/includes/src/Services/Gateway/HpsCentinelGatewayService.php b/classes/includes/src/Services/Gateway/HpsCentinelGatewayService.php deleted file mode 100644 index a1409c9..0000000 --- a/classes/includes/src/Services/Gateway/HpsCentinelGatewayService.php +++ /dev/null @@ -1,70 +0,0 @@ - $this->_config->version, - 'ProcessorId' => $this->_config->processorId, - 'MerchantId' => $this->_config->merchantId, - 'TransactionPwd' => $this->_config->transactionPwd, - )); - - $xml = new DOMDocument('1.0', 'utf-8'); - $envelope = $xml->createElement('CardinalMPI'); - foreach ($request as $k => $v) { - $envelope->appendChild($xml->createElement($k, $v)); - } - $xml->appendChild($envelope); - - $url = $this->_config->serviceUri(); - $xmlData = $xml->saveXML(); - $data = 'cmpi_msg=' . urlencode($xmlData); - $header = array( - 'Content-type: application/x-www-form-urlencoded;charset="utf-8"', - 'Accept: text/xml', - 'Content-length: '.strlen($data), - ); - // error_log($xmlData); - - return $this->submitRequest($url, $header, $data); - } - /** - * @param $curlResponse - * @param $curlInfo - * @param $curlError - * - * @return \SimpleXMLElement - * @throws \HpsException - */ - public function processResponse($curlResponse, $curlInfo, $curlError) - { - // error_log($curlResponse); - switch ($curlInfo['http_code']) { - case '200': - return simplexml_load_string($curlResponse); - break; - case '500': - $faultString = ''; - throw new HpsException($faultString); - break; - default: - throw new HpsException('Unexpected response'); - break; - } - } -} diff --git a/classes/includes/src/Services/Gateway/HpsCheckService.php b/classes/includes/src/Services/Gateway/HpsCheckService.php deleted file mode 100644 index dba9535..0000000 --- a/classes/includes/src/Services/Gateway/HpsCheckService.php +++ /dev/null @@ -1,179 +0,0 @@ -NOTE: 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) - */ - public function sale(HpsCheck $check, $amount, $clientTransactionId = null) - { - return $this->_buildTransaction('SALE', $check, $amount, $clientTransactionId); - } - /** - * @param \HpsCheck $check - * @param $amount - * @param null $clientTransactionId - * - * @return mixed - * @throws \HpsException - * @throws \HpsInvalidRequestException - */ - 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 - */ - public function override(HpsCheck $check, $amount, $clientTransactionId = null) - { - //TODO: implement replacemen - throw new HpsException('Check action OVERRIDE not currently supported'); - return $this->_buildTransaction('OVERRIDE', $check, $amount, $clientTransactionId); - } - /** - * A Void 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 - */ - 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'); - } - /** - * @param $action - * @param \HpsCheck $check - * @param $amount - * @param null $clientTransactionId - * - * @return mixed - * @throws \HpsCheckException - * @throws \HpsInvalidRequestException - */ - 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 $transaction - * @param $txnType - * @param null $clientTransactionId - * - * @return mixed - * @throws \HpsAuthenticationException - * @throws \HpsCheckException - * @throws \HpsGatewayException - * @throws null - */ - 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; - } -} diff --git a/classes/includes/src/Services/Gateway/HpsCreditService.php b/classes/includes/src/Services/Gateway/HpsCreditService.php deleted file mode 100644 index a63ce3b..0000000 --- a/classes/includes/src/Services/Gateway/HpsCreditService.php +++ /dev/null @@ -1,710 +0,0 @@ -_currency = $currency; - $this->_amount = HpsInputValidation::checkAmount($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', 'Y')); - $hpsBlock1->appendChild($xml->createElement('hps:AllowPartialAuth', ($allowPartialAuth ? 'Y' : 'N'))); - $hpsBlock1->appendChild($xml->createElement('hps:Amt', $amount)); - //update convenienceAmtInfo if passed - if ($convenienceAmtInfo != null && $convenienceAmtInfo != '') { - $hpsBlock1->appendChild($xml->createElement('hps:ConvenienceAmtInfo', $convenienceAmtInfo)); - } - - //update shippingAmtInfo if passed - if ($shippingAmtInfo != null && $shippingAmtInfo != '') { - $hpsBlock1->appendChild($xml->createElement('hps:ShippingAmtInfo', $shippingAmtInfo)); - } - - if ($cardHolder != null) { - $hpsBlock1->appendChild($this->_hydrateCardHolderData($cardHolder, $xml)); - } - if ($details != null) { - $hpsBlock1->appendChild($this->_hydrateAdditionalTxnFields($details, $xml)); - } - if ($txnDescriptor != null && $txnDescriptor != '') { - $hpsBlock1->appendChild($xml->createElement('hps:TxnDescriptor', $txnDescriptor)); - } - - $cardData = $xml->createElement('hps:CardData'); - if ($cardOrToken instanceof HpsCreditCard) { - $cardData->appendChild($this->_hydrateManualEntry($cardOrToken, $xml)); - } else { - $cardData->appendChild($this->_hydrateTokenData($cardOrToken, $xml)); - } - $cardData->appendChild($xml->createElement('hps:TokenRequest', ($requestMultiUseToken) ? 'Y' : 'N')); - if ($cpcReq) { - $hpsBlock1->appendChild($xml->createElement('hps:CPCReq', 'Y')); - } - - $hpsBlock1->appendChild($cardData); - $hpsCreditAuth->appendChild($hpsBlock1); - $hpsTransaction->appendChild($hpsCreditAuth); - - return $this->_submitTransaction($hpsTransaction, 'CreditAuth', (isset($details->clientTransactionId) ? $details->clientTransactionId : null), $cardOrToken); - } - /** - * @param $transactionId - * @param null $amount - * @param null $gratuity - * @param null $clientTransactionId - * @param null $directMarketData - * - * @return array|null - * @throws \HpsArgumentException - * @throws \HpsGatewayException - */ - public function capture($transactionId, $amount = null, $gratuity = null, $clientTransactionId = null, $directMarketData = null) - { - $xml = new DOMDocument(); - $hpsTransaction = $xml->createElement('hps:Transaction'); - $hpsCreditAddToBatch = $xml->createElement('hps:CreditAddToBatch'); - - $hpsCreditAddToBatch->appendChild($xml->createElement('hps:GatewayTxnId', $transactionId)); - if ($amount != null) { - $amount = sprintf("%0.2f", round($amount, 3)); - $hpsCreditAddToBatch->appendChild($xml->createElement('hps:Amt', $amount)); - } - if ($gratuity != null) { - $hpsCreditAddToBatch->appendChild($xml->createElement('hps:GratuityAmtInfo', $gratuity)); - } - - if ($directMarketData != null && $directMarketData->invoiceNumber != null) { - $hpsCreditAddToBatch->appendChild($this->_hydrateDirectMarketData($directMarketData, $xml)); - } - - $hpsTransaction->appendChild($hpsCreditAddToBatch); - $options = array(); - if ($clientTransactionId != null) { - $options['clientTransactionId'] = $clientTransactionId; - } - $response = $this->doRequest($hpsTransaction, $options); - $this->_processChargeGatewayResponse($response, 'CreditAddToBatch'); - - return $this->get($transactionId); - } - /** - * @param $amount - * @param $currency - * @param $cardOrToken - * @param null $cardHolder - * @param bool $requestMultiUseToken - * @param null $details - * @param null $txnDescriptor - * @param bool $allowPartialAuth - * @param bool $cpcReq - * @param null $directMarketData - * @param null $convenienceAmtInfo - * @param null $shippingAmtInfo - * - * @return array|null - * @throws \HpsException - * @throws \HpsGatewayException - * @throws \HpsInvalidRequestException - */ - public function charge($amount, $currency, $cardOrToken, $cardHolder = null, $requestMultiUseToken = false, $details = null, $txnDescriptor = null, $allowPartialAuth = false, $cpcReq = false, $directMarketData = null, $convenienceAmtInfo = null, $shippingAmtInfo = null) - { - HpsInputValidation::checkCurrency($currency); - $this->_currency = $currency; - $this->_amount = HpsInputValidation::checkAmount($amount); - - $xml = new DOMDocument(); - $hpsTransaction = $xml->createElement('hps:Transaction'); - $hpsCreditSale = $xml->createElement('hps:CreditSale'); - $hpsBlock1 = $xml->createElement('hps:Block1'); - - $hpsBlock1->appendChild($xml->createElement('hps:AllowDup', 'Y')); - $hpsBlock1->appendChild($xml->createElement('hps:AllowPartialAuth', ($allowPartialAuth ? 'Y' : 'N'))); - $hpsBlock1->appendChild($xml->createElement('hps:Amt', $amount)); - //update convenienceAmtInfo if passed - if ($convenienceAmtInfo != null && $convenienceAmtInfo != '') { - $hpsBlock1->appendChild($xml->createElement('hps:ConvenienceAmtInfo', $convenienceAmtInfo)); - } - - //update shippingAmtInfo if passed - if ($shippingAmtInfo != null && $shippingAmtInfo != '') { - $hpsBlock1->appendChild($xml->createElement('hps:ShippingAmtInfo', $shippingAmtInfo)); - } - if ($cardHolder != null) { - $hpsBlock1->appendChild($this->_hydrateCardHolderData($cardHolder, $xml)); - } - if ($details != null) { - $hpsBlock1->appendChild($this->_hydrateAdditionalTxnFields($details, $xml)); - } - if ($txnDescriptor != null && $txnDescriptor != '') { - $hpsBlock1->appendChild($xml->createElement('hps:TxnDescriptor', $txnDescriptor)); - } - - $cardData = $xml->createElement('hps:CardData'); - if ($cardOrToken instanceof HpsCreditCard) { - $cardData->appendChild($this->_hydrateManualEntry($cardOrToken, $xml)); - } else { - $cardData->appendChild($this->_hydrateTokenData($cardOrToken, $xml)); - } - if ($cpcReq) { - $hpsBlock1->appendChild($xml->createElement('hps:CPCReq', 'Y')); - } - $cardData->appendChild($xml->createElement('hps:TokenRequest', ($requestMultiUseToken) ? 'Y' : 'N')); - - if ($directMarketData != null && $directMarketData->invoiceNumber != null) { - $hpsBlock1->appendChild($this->_hydrateDirectMarketData($directMarketData, $xml)); - } - - $hpsBlock1->appendChild($cardData); - $hpsCreditSale->appendChild($hpsBlock1); - $hpsTransaction->appendChild($hpsCreditSale); - - return $this->_submitTransaction($hpsTransaction, 'CreditSale', (isset($details->clientTransactionId) ? $details->clientTransactionId : null), $cardOrToken); - } - /** - * @param $schedule - * @param $amount - * @param $cardOrTokenOrPMKey - * @param null $cardHolder - * @param bool $oneTime - * @param null $details - * - * @return array|null - * @throws \HpsException - * @throws \HpsGatewayException - * @throws \HpsInvalidRequestException - */ - public function recurring($schedule, $amount, $cardOrTokenOrPMKey, $cardHolder = null, $oneTime = false, $details = null) - { - $this->_amount = HpsInputValidation::checkAmount($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', $amount)); - if ($cardHolder != null) { - $hpsBlock1->appendChild($this->_hydrateCardHolderData($cardHolder, $xml)); - } - if ($details != null) { - $hpsBlock1->appendChild($this->_hydrateAdditionalTxnFields($details, $xml)); - } - - if ($cardOrTokenOrPMKey instanceof HpsCreditCard) { - $cardData = $xml->createElement('hps:CardData'); - $cardData->appendChild($this->_hydrateManualEntry($cardOrTokenOrPMKey, $xml)); - $hpsBlock1->appendChild($cardData); - } else if ($cardOrTokenOrPMKey instanceof HpsTokenData) { - $cardData = $xml->createElement('hps:CardData'); - $cardData->appendChild($this->_hydrateTokenData($cardOrTokenOrPMKey, $xml)); - $hpsBlock1->appendChild($cardData); - } else { - $hpsBlock1->appendChild($xml->createElement('hps:PaymentMethodKey', $cardOrTokenOrPMKey)); - } - - $id = $schedule; - if ($schedule instanceof HpsPayPlanSchedule) { - $id = $schedule->scheduleIdentifier; - } - $recurringData = $xml->createElement('hps:RecurringData'); - $recurringData->appendChild($xml->createElement('hps:ScheduleID', $id)); - $recurringData->appendChild($xml->createElement('hps:OneTime', ($oneTime ? 'Y' : 'N'))); - - $hpsBlock1->appendChild($recurringData); - $hpsRecurringBilling->appendChild($hpsBlock1); - $hpsTransaction->appendChild($hpsRecurringBilling); - - return $this->_submitTransaction($hpsTransaction, 'RecurringBilling', (isset($details->clientTransactionId) ? $details->clientTransactionId : null), $cardOrTokenOrPMKey); - } - /** - * @param $transactionId - * @param $cpcData - * - * @return array|null - * @throws \HpsException - * @throws \HpsGatewayException - */ - public function cpcEdit($transactionId, $cpcData) - { - $xml = new DOMDocument(); - $hpsTransaction = $xml->createElement('hps:Transaction'); - $hpsPosCreditCPCEdit = $xml->createElement('hps:CreditCPCEdit'); - $hpsPosCreditCPCEdit->appendChild($xml->createElement('hps:GatewayTxnId', $transactionId)); - $hpsPosCreditCPCEdit->appendChild($this->_hydrateCPCData($cpcData, $xml)); - $hpsTransaction->appendChild($hpsPosCreditCPCEdit); - - return $this->_submitTransaction($hpsTransaction, 'CreditCPCEdit'); - } - /** - * @param $transactionId - * @param null $amount - * @param null $gratuity - * @param null $clientTransactionId - * - * @return array|null - * @throws \HpsException - * @throws \HpsGatewayException - */ - public function edit($transactionId, $amount = null, $gratuity = null, $clientTransactionId = null) - { - $xml = new DOMDocument(); - $hpsTransaction = $xml->createElement('hps:Transaction'); - $hpsCreditTxnEdit = $xml->createElement('hps:CreditTxnEdit'); - - $hpsCreditTxnEdit->appendChild($xml->createElement('hps:GatewayTxnId', $transactionId)); - if ($amount != null) { - $amount = sprintf('%0.2f', round($amount, 3)); - $hpsCreditTxnEdit->appendChild($xml->createElement('hps:Amt', $amount)); - } - if ($gratuity != null) { - $hpsCreditTxnEdit->appendChild($xml->createElement('hps:GratuityAmtInfo', $gratuity)); - } - - $hpsTransaction->appendChild($hpsCreditTxnEdit); - $trans = $this->_submitTransaction($hpsTransaction, 'CreditTxnEdit', $clientTransactionId); - - $trans->responseCode = '00'; - $trans->responseText = ''; - - return $trans; - } - - /** builds soap transaction for Portico so that expiration dates can be updated for expired cards with a new current issuance - * @param string $tokenValue - * @param int $expMonth 1-12 padding will be handled automatically - * @param int $expYear must be 4 digits. - * - * @return \HpsManageTokensResponse - * @throws \HpsException - * @throws \HpsGatewayException - */ - public function updateTokenExpiration($tokenValue, $expMonth, $expYear) { - // new DOM - $xml = new DOMDocument(); - $hpsTransaction = $xml->createElement('hps:Transaction'); - $hpsManageTokens = $xml->createElement('hps:ManageTokens'); - - $hpsManageTokens->appendChild($xml->createElement('hps:TokenValue', trim((string)$tokenValue))); - - $hpsTokenActions = $xml->createElement('hps:TokenActions'); - $hpsSet = $xml->createElement('hps:Set'); - $hpsAttribute = $xml->createElement('hps:Attribute'); - - $hpsAttribute->appendChild($xml->createElement('hps:Name', 'ExpMonth')); - $hpsAttribute->appendChild($xml->createElement('hps:Value', (string)sprintf("%'.02d", (int)$expMonth))); - - $hpsSet->appendChild($hpsAttribute); - - $hpsAttribute = $xml->createElement('hps:Attribute'); - - $hpsAttribute->appendChild($xml->createElement('hps:Name', 'ExpYear')); - $hpsAttribute->appendChild($xml->createElement('hps:Value', (string)$expYear)); - - $hpsSet->appendChild($hpsAttribute); - - $hpsTokenActions->appendChild($hpsSet); - - $hpsManageTokens->appendChild($hpsTokenActions); - - $hpsTransaction->appendChild($hpsManageTokens); - - return $this->_submitTransaction($hpsTransaction, 'ManageTokens'); - } - /** - * @param $transactionId - * - * @return array|null - * @throws \HpsArgumentException - * @throws \HpsException - * @throws \HpsGatewayException - */ - public function get($transactionId) - { - if ($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', $transactionId)); - $hpsTransaction->appendChild($hpsReportTxnDetail); - - return $this->_submitTransaction($hpsTransaction, 'ReportTxnDetail'); - } - /** - * @param $startDate - * @param $endDate - * @param null $filterBy - * - * @return array|null - * @throws \HpsException - * @throws \HpsGatewayException - * @throws \HpsInvalidRequestException - */ - public function listTransactions($startDate, $endDate, $filterBy = null) - { - $this->_filterBy = $filterBy; - date_default_timezone_set("UTC"); - $dateFormat = 'Y-m-d\TH:i:s.00\Z'; - $current = new DateTime(); - $currentTime = $current->format($dateFormat); - - HpsInputValidation::checkDateNotFuture($startDate); - HpsInputValidation::checkDateNotFuture($endDate); - - $xml = new DOMDocument(); - $hpsTransaction = $xml->createElement('hps:Transaction'); - $hpsReportActivity = $xml->createElement('hps:ReportActivity'); - $hpsReportActivity->appendChild($xml->createElement('hps:RptStartUtcDT', $startDate)); - $hpsReportActivity->appendChild($xml->createElement('hps:RptEndUtcDT', $endDate)); - $hpsTransaction->appendChild($hpsReportActivity); - - return $this->_submitTransaction($hpsTransaction, 'ReportActivity'); - } - /** - * @param $amount - * @param $currency - * @param $cardData - * @param null $cardHolder - * @param null $details - * - * @return array|null - * @throws \HpsException - * @throws \HpsGatewayException - * @throws \HpsInvalidRequestException - */ - public function refund($amount, $currency, $cardData, $cardHolder = null, $details = null) - { - HpsInputValidation::checkCurrency($currency); - $this->_currency = $currency; - $this->_amount = HpsInputValidation::checkAmount($amount); - - $xml = new DOMDocument(); - $hpsTransaction = $xml->createElement('hps:Transaction'); - $hpsCreditReturn = $xml->createElement('hps:CreditReturn'); - $hpsBlock1 = $xml->createElement('hps:Block1'); - - $hpsBlock1->appendChild($xml->createElement('hps:AllowDup', 'Y')); - $hpsBlock1->appendChild($xml->createElement('hps:Amt', $amount)); - 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'); - $cardDataElement->appendChild($this->_hydrateTokenData($cardData, $xml)); - $hpsBlock1->appendChild($cardDataElement); - } else { - $hpsBlock1->appendChild($xml->createElement('hps:GatewayTxnId', $cardData)); - } - if ($cardHolder != null) { - $hpsBlock1->appendChild($this->_hydrateCardHolderData($cardHolder, $xml)); - } - if ($details != null) { - $hpsBlock1->appendChild($this->_hydrateAdditionalTxnFields($details, $xml)); - } - - $hpsCreditReturn->appendChild($hpsBlock1); - $hpsTransaction->appendChild($hpsCreditReturn); - - return $this->_submitTransaction($hpsTransaction, 'CreditReturn', (isset($details->clientTransactionId) ? $details->clientTransationId : null)); - } - /** - * @param HpsCreditCard|HpsTokenData|int $cardData GatewayTxnId - * @param float $amount - * @param string $currency - * @param null|HpsTransactionDetails $details - * @param null|float $authAmount - * @return HpsReversal - * @throws HpsException - * @throws HpsGatewayException - * @throws HpsInvalidRequestException - */ - public function reverse($cardData, $amount, $currency, $details = null, $authAmount = 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 ($authAmount !== null){ - $hpsBlock1->appendChild($xml->createElement('hps:AuthAmt', HpsInputValidation::checkAmount($authAmount))); - } - $cardDataElement = null; - if ($cardData instanceof HpsCreditCard) { - $cardDataElement = $xml->createElement('hps:CardData'); - $cardDataElement->appendChild($this->_hydrateManualEntry($cardData, $xml)); - } else if ($cardData instanceof HpsTokenData) { - $cardDataElement = $xml->createElement('hps:CardData'); - $cardDataElement->appendChild($this->_hydrateTokenData($cardData, $xml)); - } else { - $cardDataElement = $xml->createElement('hps:GatewayTxnId', $cardData); - } - $hpsBlock1->appendChild($cardDataElement); - if ($details != null) { - $hpsBlock1->appendChild($this->_hydrateAdditionalTxnFields($details, $xml)); - } - - $hpsCreditReversal->appendChild($hpsBlock1); - $hpsTransaction->appendChild($hpsCreditReversal); - - return $this->_submitTransaction($hpsTransaction, 'CreditReversal', (isset($details->clientTransactionId) ? $details->clientTransactionId : null)); - } - /** - * @param $cardOrToken - * @param null $cardHolder - * @param bool $requestMultiUseToken - * @param null $clientTransactionId - * - * @return array|null - * @throws \HpsException - * @throws \HpsGatewayException - */ - public function verify($cardOrToken, $cardHolder = null, $requestMultiUseToken = false, $clientTransactionId = null) - { - $xml = new DOMDocument(); - $hpsTransaction = $xml->createElement('hps:Transaction'); - $hpsCreditAccountVerify = $xml->createElement('hps:CreditAccountVerify'); - $hpsBlock1 = $xml->createElement('hps:Block1'); - - if ($cardHolder != null) { - $hpsBlock1->appendChild($this->_hydrateCardHolderData($cardHolder, $xml)); - } - - $cardData = $xml->createElement('hps:CardData'); - if ($cardOrToken instanceof HpsCreditCard) { - $cardData->appendChild($this->_hydrateManualEntry($cardOrToken, $xml)); - } else { - $cardData->appendChild($this->_hydrateTokenData($cardOrToken, $xml)); - } - $cardData->appendChild($xml->createElement('hps:TokenRequest', ($requestMultiUseToken) ? 'Y' : 'N')); - - $hpsBlock1->appendChild($cardData); - $hpsCreditAccountVerify->appendChild($hpsBlock1); - $hpsTransaction->appendChild($hpsCreditAccountVerify); - - return $this->_submitTransaction($hpsTransaction, 'CreditAccountVerify', $clientTransactionId); - } - /** - * @param $transactionId - * @param null $clientTransactionId - * - * @return array|null - * @throws \HpsException - * @throws \HpsGatewayException - */ - public function void($transactionId, $clientTransactionId = null) - { - $xml = new DOMDocument(); - $hpsTransaction = $xml->createElement('hps:Transaction'); - $hpsCreditVoid = $xml->createElement('hps:CreditVoid'); - $hpsCreditVoid->appendChild($xml->createElement('hps:GatewayTxnId', $transactionId)); - $hpsTransaction->appendChild($hpsCreditVoid); - - return $this->_submitTransaction($hpsTransaction, 'CreditVoid', $clientTransactionId); - } - /** - * @param $response - * @param $expectedType - * - * @throws \HpsAuthenticationException - * @throws \HpsGatewayException - * @throws null - */ - private function _processChargeGatewayResponse($response, $expectedType) - { - $gatewayRspCode = (isset($response->Header->GatewayRspCode) ? $response->Header->GatewayRspCode : null); - $transactionId = (isset($response->Header->GatewayTxnId) ? $response->Header->GatewayTxnId : null); - - if ($gatewayRspCode == '0') { - return; - } - - if ($gatewayRspCode == '30') { - try { - $this->reverse($transactionId, $this->_amount, $this->_currency); - } catch (Exception $e) { - throw new HpsGatewayException( - HpsExceptionCodes::GATEWAY_TIMEOUT_REVERSAL_ERROR, - 'Error occurred while reversing a charge due to HPS gateway timeout', - $e, - null, - null, - $transactionId - ); - } - } - - HpsGatewayResponseValidation::checkResponse($response, $expectedType); - } - /** - * @param $response - * @param $expectedType - * - * @throws \HpsCreditException - * @throws null - */ - private function _processChargeIssuerResponse($response, $expectedType) - { - $transactionId = (isset($response->Header->GatewayTxnId) ? $response->Header->GatewayTxnId : null); - $item = $response->Transaction->$expectedType; - - if ($item != null) { - $responseCode = (isset($item->RspCode) ? $item->RspCode : null); - $responseText = (isset($item->RspText) ? $item->RspText : null); - - if ($responseCode != null) { - // check if we need to do a reversal - if ($responseCode == '91') { - try { - $this->reverse($transactionId, $this->_amount, $this->_currency); - } catch (HpsGatewayException $e) { - // if the transaction wasn't found; throw the original timeout exception - if ($e->details->gatewayResponseCode == 3) { - HpsIssuerResponseValidation::checkResponse($transactionId, $responseCode, $responseText); - } - throw new HpsCreditException( - $transactionId, - HpsExceptionCodes::ISSUER_TIMEOUT_REVERSAL_ERROR, - 'Error occurred while reversing a charge due to HPS issuer timeout', - $e - ); - } catch (HpsException $e) { - throw new HpsCreditException( - $transactionId, - HpsExceptionCodes::ISSUER_TIMEOUT_REVERSAL_ERROR, - 'Error occurred while reversing a charge due to HPS issuer timeout', - $e - ); - } - } - HpsIssuerResponseValidation::checkResponse($transactionId, $responseCode, $responseText); - } - } - } - - /** - * @param $transaction - * @param $txnType - * @param null $clientTxnId - * @param null $cardData - * - * @return array|null - * @throws \HpsCreditException - * @throws \HpsException - * @throws \HpsGatewayException - */ - 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 (in_array($txnType, array('CreditSale', 'CreditAuth'))) { - 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 'ReportTxnDetail': - $rvalue = HpsReportTransactionDetails::fromDict($response, $txnType); - break; - case 'ReportActivity': - $rvalue = HpsReportTransactionSummary::fromDict($response, $txnType, $this->_filterBy); - break; - case 'CreditSale': - $rvalue = HpsCharge::fromDict($response, $txnType); - break; - case 'CreditAccountVerify': - $rvalue = HpsAccountVerify::fromDict($response, $txnType); - break; - case 'CreditAuth': - $rvalue = HpsAuthorization::fromDict($response, $txnType); - break; - case 'CreditReturn': - $rvalue = HpsRefund::fromDict($response, $txnType); - break; - case 'CreditReversal': - $rvalue = HpsReversal::fromDict($response, $txnType); - break; - case 'CreditVoid': - $rvalue = HpsVoid::fromDict($response, $txnType); - break; - case 'CreditCPCEdit': - $rvalue = HpsCPCEdit::fromDict($response, $txnType); - break; - case 'CreditTxnEdit': - $rvalue = HpsTransaction::fromDict($response, $txnType); - break; - case 'RecurringBilling': - $rvalue = HpsRecurringBilling::fromDict($response, $txnType); - break; - case 'ManageTokens': - $rvalue = HpsManageTokensResponse::fromDict($response); - break; - default: - break; - } - - return $rvalue; - } -} diff --git a/classes/includes/src/Services/Gateway/HpsDebitService.php b/classes/includes/src/Services/Gateway/HpsDebitService.php deleted file mode 100644 index 800b622..0000000 --- a/classes/includes/src/Services/Gateway/HpsDebitService.php +++ /dev/null @@ -1,346 +0,0 @@ -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); - } - - /** - * A Debit Return transaction returns funds to the cardholder. The transaction is generally used as a - * counterpart to a Debit Charge transaction that needs to be reversed. The Debit Return transaction is - * placed in the current open batch. If a batch is not open, this transaction create an open batch. - * - * @param string $transactionId The gateway transaciton ID of the charge to be returned. - * @param double $amount Authorization amount. - * @param string $trackData Track data read from the card by the card reader. - * @param string $pinBlock PIN block. - * @param bool $allowDuplicates Indicates whether to allow duplicate transactions. - * @param HpsCardHolder $cardHolder Card holder information. - * @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 HpsDebitReturn The Return (Authorization) results. - */ - public function returnDebit($transactionId, $amount, $trackData, $pinBlock, $allowDuplicates = false, HpsCardHolder $cardHolder = 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:DebitReturn'); - $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, 'DebitReturn', $clientTransactionId); - } - - /** - * 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. - */ - 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 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 HpsDebitSale 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); - } - /** - * @param $response - * @param $expectedType - * - * @throws \HpsAuthenticationException - * @throws \HpsGatewayException - * @throws null - */ - private function _processChargeGatewayResponse($response, $expectedType) - { - $gatewayRspCode = (isset($response->Header->GatewayRspCode) ? $response->Header->GatewayRspCode : null); - $transactionId = (isset($response->Header->GatewayTxnId) ? $response->Header->GatewayTxnId : null); - - if ($gatewayRspCode == '0') { - return; - } - - if ($gatewayRspCode == '30') { - try { - $this->reverse($transactionId, $this->_amount, $this->_currency); - } catch (Exception $e) { - throw new HpsGatewayException( - HpsExceptionCodes::GATEWAY_TIMEOUT_REVERSAL_ERROR, - 'Error occurred while reversing a charge due to HPS gateway timeout', - $e, - null, - null, - $transactionId - ); - } - } - - HpsGatewayResponseValidation::checkResponse($response, $expectedType); - } - /** - * @param $response - * @param $expectedType - * - * @throws \HpsCreditException - * @throws null - */ - private function _processChargeIssuerResponse($response, $expectedType) - { - $transactionId = (isset($response->Header->GatewayTxnId) ? $response->Header->GatewayTxnId : null); - $item = $response->Transaction->$expectedType; - - if ($item != null) { - $responseCode = (isset($item->RspCode) ? $item->RspCode : null); - $responseText = (isset($item->RspText) ? $item->RspText : null); - - if ($responseCode != null) { - // check if we need to do a reversal - if ($responseCode == '91') { - try { - $this->reverse($transactionId, $this->_amount, $this->_currency); - } catch (HpsGatewayException $e) { - // if the transaction wasn't found; throw the original timeout exception - if ($e->details->gatewayResponseCode == 3) { - HpsIssuerResponseValidation::checkResponse($transactionId, $responseCode, $responseText); - } - throw new HpsCreditException( - $transactionId, - HpsExceptionCodes::ISSUER_TIMEOUT_REVERSAL_ERROR, - 'Error occurred while reversing a charge due to HPS issuer timeout', - $e - ); - } catch (HpsException $e) { - throw new HpsCreditException( - $transactionId, - HpsExceptionCodes::ISSUER_TIMEOUT_REVERSAL_ERROR, - 'Error occurred while reversing a charge due to HPS issuer timeout', - $e - ); - } - } - HpsIssuerResponseValidation::checkResponse($transactionId, $responseCode, $responseText); - } - } - } - /** - * @param $transaction - * @param $txnType - * @param null $clientTxnId - * @param null $cardData - * - * @return null - * @throws \HpsCreditException - * @throws \HpsException - * @throws \HpsGatewayException - */ - 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; - } -} diff --git a/classes/includes/src/Services/Gateway/HpsGiftCardService.php b/classes/includes/src/Services/Gateway/HpsGiftCardService.php deleted file mode 100644 index 87e89c2..0000000 --- a/classes/includes/src/Services/Gateway/HpsGiftCardService.php +++ /dev/null @@ -1,408 +0,0 @@ -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)); - - $hpsGiftCard->appendChild($hpsBlock1); - $hpsTransaction->appendChild($hpsGiftCard); - - return $this->_submitTransaction($hpsTransaction, $txnType); - } - /** - * @param $amount - * @param $currency - * @param $giftCard - * - * @return \HpsGiftCardAlias|string - * @throws \HpsInvalidRequestException - */ - public function addValue($amount, $currency, $giftCard) - { - HpsInputValidation::checkCurrency($currency); - $amount = HpsInputValidation::checkAmount($amount); - $txnType = 'GiftCardAddValue'; - - $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)); - - $hpsGiftCard->appendChild($hpsBlock1); - $hpsTransaction->appendChild($hpsGiftCard); - - return $this->_submitTransaction($hpsTransaction, $txnType); - } - /** - * @param $action - * @param $giftCard - * @param $aliasStr - * - * @return \HpsGiftCardAlias|string - */ - 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 $giftCard - * - * @return \HpsGiftCardAlias|string - */ - 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 - */ - public function deactivate($giftCard) - { - $txnType = 'GiftCardDeactivate'; - - $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 $oldGiftCard - * @param $newGiftCard - * - * @return \HpsGiftCardAlias|string - */ - 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 $giftCard - * @param $amount - * @param string $currency - * - * @return \HpsGiftCardAlias|string - * @throws \HpsInvalidRequestException - */ - 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 - * @param null $gratuity - * @param null $tax - * - * @return \HpsGiftCardAlias|string - * @throws \HpsInvalidRequestException - */ - 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 - */ - 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)); - - 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 $transactionId - * - * @return \HpsGiftCardAlias|string - */ - 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 $transaction - * @param $txnType - * @param null $clientTxnId - * - * @return \HpsGiftCardAlias|string - * @throws \HpsAuthenticationException - * @throws \HpsCreditException - * @throws \HpsGatewayException - * @throws null - */ - private function _submitTransaction($transaction, $txnType, $clientTxnId = null) - { - $options = array(); - if ($clientTxnId != null) { - $options['clientTransactionId'] = $clientTxnId; - } - $response = $this->doRequest($transaction, $options); - - HpsGatewayResponseValidation::checkResponse($response, $txnType); - HpsIssuerResponseValidation::checkResponse( - $response->Header->GatewayTxnId, - $response->Transaction->$txnType->RspCode, - $response->Transaction->$txnType->RspText, - 'gift' - ); - - $rvalue = ''; - switch ($txnType) { - case 'GiftCardActivate': - $rvalue = HpsGiftCardActivate::fromDict($response, $txnType, 'HpsGiftCardActivate'); - break; - case 'GiftCardAddValue': - $rvalue = HpsGiftCardAddValue::fromDict($response, $txnType, 'HpsGiftCardAddValue'); - break; - case 'GiftCardAlias': - $rvalue = HpsGiftCardAlias::fromDict($response, $txnType, 'HpsGiftCardAlias'); - break; - case 'GiftCardBalance': - $rvalue = HpsGiftCardBalance::fromDict($response, $txnType, 'HpsGiftCardBalance'); - break; - case 'GiftCardDeactivate': - $rvalue = HpsGiftCardDeactivate::fromDict($response, $txnType, 'HpsGiftCardDeactivate'); - break; - case 'GiftCardReplace': - $rvalue = HpsGiftCardReplace::fromDict($response, $txnType, 'HpsGiftCardReplace'); - break; - case 'GiftCardReward': - $rvalue = HpsGiftCardReward::fromDict($response, $txnType, 'HpsGiftCardReward'); - break; - case 'GiftCardSale': - $rvalue = HpsGiftCardSale::fromDict($response, $txnType, 'HpsGiftCardSale'); - break; - case 'GiftCardVoid': - $rvalue = HpsGiftCardVoid::fromDict($response, $txnType, 'HpsGiftCardVoid'); - break; - case 'GiftCardReversal': - $rvalue = HpsGiftCardReversal::fromDict($response, $txnType, 'HpsGiftCardReversal'); - break; - default: - break; - } - - return $rvalue; - } -} diff --git a/classes/includes/src/Services/Gateway/HpsPayPlanService.php b/classes/includes/src/Services/Gateway/HpsPayPlanService.php deleted file mode 100644 index cd1d81b..0000000 --- a/classes/includes/src/Services/Gateway/HpsPayPlanService.php +++ /dev/null @@ -1,178 +0,0 @@ -customer = new HpsPayPlanCustomerService($config); - $this->paymentMethod = new HpsPayPlanPaymentMethodService($config); - $this->schedule = new HpsPayPlanScheduleService($config); - } - /** - * @param \HpsServicesConfig $config - */ - public function setServicesConfig(HpsServicesConfig $config) - { - $this->customer->setServicesConfig($config); - $this->paymentMethod->setServicesConfig($config); - $this->schedule->setServicesConfig($config); - } - - /// Customer methods - - /** - * @param \HpsPayPlanCustomer $customer - * - * @return mixed - */ - public function addCustomer(HpsPayPlanCustomer $customer) - { - return $this->customer->add($customer); - } - /** - * @param \HpsPayPlanCustomer $customer - * - * @return mixed - */ - public function editCustomer(HpsPayPlanCustomer $customer) - { - return $this->customer->edit($customer); - } - /** - * @param array $searchFields - * - * @return object - */ - public function findAllCustomers($searchFields = array()) - { - return $this->customer->findAll($searchFields); - } - /** - * @param $customer - * - * @return mixed - */ - public function getCustomer($customer) - { - return $this->customer->get($customer); - } - /** - * @param $customer - * @param bool $forceDelete - * - * @return mixed - */ - public function deleteCustomer($customer, $forceDelete = false) - { - return $this->customer->delete($customer, $forceDelete); - } - - /// PaymentMethod methods - - /** - * @param \HpsPayPlanPaymentMethod $paymentMethod - * - * @return mixed - */ - public function addPaymentMethod(HpsPayPlanPaymentMethod $paymentMethod) - { - return $this->paymentMethod->add($paymentMethod); - } - /** - * @param \HpsPayPlanPaymentMethod $paymentMethod - * - * @return mixed - */ - public function editPaymentMethod(HpsPayPlanPaymentMethod $paymentMethod) - { - return $this->paymentMethod->edit($paymentMethod); - } - /** - * @param array $searchFields - * - * @return object - */ - public function findAllPaymentMethods($searchFields = array()) - { - return $this->paymentMethod->findAll($searchFields); - } - /** - * @param $paymentMethod - * - * @return mixed - */ - public function getPaymentMethod($paymentMethod) - { - return $this->paymentMethod->get($paymentMethod); - } - /** - * @param $paymentMethod - * @param bool $forceDelete - * - * @return mixed - */ - public function deletePaymentMethod($paymentMethod, $forceDelete = false) - { - return $this->paymentMethod->delete($paymentMethod, $forceDelete); - } - - /// Schedule methods - - /** - * @param \HpsPayPlanSchedule $schedule - * - * @return mixed - */ - public function addSchedule(HpsPayPlanSchedule $schedule) - { - return $this->schedule->add($schedule); - } - /** - * @param \HpsPayPlanSchedule $schedule - * - * @return mixed - */ - public function editSchedule(HpsPayPlanSchedule $schedule) - { - return $this->schedule->edit($schedule); - } - /** - * @param array $searchFields - * - * @return object - */ - public function findAllSchedules($searchFields = array()) - { - return $this->schedule->findAll($searchFields); - } - /** - * @param $schedule - * - * @return mixed - */ - public function getSchedule($schedule) - { - return $this->schedule->get($schedule); - } - /** - * @param $schedule - * @param bool $forceDelete - * - * @return mixed - */ - public function deleteSchedule($schedule, $forceDelete = false) - { - return $this->schedule->delete($schedule, $forceDelete); - } -} diff --git a/classes/includes/src/Services/Gateway/HpsRestGatewayService.php b/classes/includes/src/Services/Gateway/HpsRestGatewayService.php deleted file mode 100644 index a7c866a..0000000 --- a/classes/includes/src/Services/Gateway/HpsRestGatewayService.php +++ /dev/null @@ -1,165 +0,0 @@ -limit = $limit; - $this->offset = $offset; - return $this; - } - /** - * @param $searchFields - * - * @return $this - */ - public function search($searchFields) - { - $this->searchFields = $searchFields; - return $this; - } - /** - * @param null $data - * @param array $options - * - * @return mixed - * @throws \HpsAuthenticationException - * @throws \HpsGatewayException - */ - 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 $curlResponse - * @param $curlInfo - * @param $curlError - * - * @return mixed - * @throws \HpsException - */ - 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 $result - * @param $type - * - * @return mixed - */ - protected function hydrateObject($result, $type) - { - return call_user_func(array($type, 'fromStdClass'), $result); - } - /** - * @param $resultSet - * @param $type - * - * @return object - */ - 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, - ); - } - /** - * @return string - */ - private function _gatewayUrlForKey() - { - if ($this->_config->secretApiKey != null && $this->_config->secretApiKey != "") { - if (strpos($this->_config->secretApiKey, '_cert_') !== false) { - return self::CERT_URL; - } else if (strpos($this->_config->secretApiKey, '_uat_') !== false) { - return self::UAT_URL; - } else { - return self::PROD_URL; - } - } else { - return $this->_config->soapServiceUri; - } - } -} diff --git a/classes/includes/src/Services/Gateway/HpsSoapGatewayService.php b/classes/includes/src/Services/Gateway/HpsSoapGatewayService.php deleted file mode 100644 index 81dfe22..0000000 --- a/classes/includes/src/Services/Gateway/HpsSoapGatewayService.php +++ /dev/null @@ -1,484 +0,0 @@ -createElement('soapenv:Envelope'); - $soapEnvelope->setAttribute('xmlns:soapenv', 'http://schemas.xmlsoap.org/soap/envelope/'); - $soapEnvelope->setAttribute('xmlns:hps', 'http://Hps.Exchange.PosGateway'); - - $soapBody = $xml->createElement('soapenv:Body'); - $hpsRequest = $xml->createElement('hps:PosRequest'); - - $hpsVersion = $xml->createElement('hps:Ver1.0'); - $hpsHeader = $xml->createElement('hps:Header'); - - if ($this->_config->secretApiKey != null && $this->_config->secretApiKey != "") { - $hpsHeader->appendChild($xml->createElement('hps:SecretAPIKey', trim($this->_config->secretApiKey))); - } else { - $hpsHeader->appendChild($xml->createElement('hps:SiteId', $this->_config->siteId)); - $hpsHeader->appendChild($xml->createElement('hps:DeviceId', $this->_config->deviceId)); - $hpsHeader->appendChild($xml->createElement('hps:LicenseId', $this->_config->licenseId)); - $hpsHeader->appendChild($xml->createElement('hps:UserName', $this->_config->username)); - $hpsHeader->appendChild($xml->createElement('hps:Password', $this->_config->password)); - } - if ($this->_config->developerId != null && $this->_config->developerId != "") { - $hpsHeader->appendChild($xml->createElement('hps:DeveloperID', $this->_config->developerId)); - $hpsHeader->appendChild($xml->createElement('hps:VersionNbr', $this->_config->versionNumber)); - $hpsHeader->appendChild($xml->createElement('hps:SiteTrace', $this->_config->siteTrace)); - } - if (isset($options['clientTransactionId'])) { - $hpsHeader->appendChild($xml->createElement('hps:ClientTxnId', $options['clientTransactionId'])); - } - - $hpsVersion->appendChild($hpsHeader); - $transaction = $xml->importNode($transaction, true); - $hpsVersion->appendChild($transaction); - - $hpsRequest->appendChild($hpsVersion); - $soapBody->appendChild($hpsRequest); - $soapEnvelope->appendChild($soapBody); - $xml->appendChild($soapEnvelope); - - $url = $this->_gatewayUrlForKey(); - $header = array( - 'Content-type: text/xml;charset="utf-8"', - 'Accept: text/xml', - 'SOAPAction: ""', - 'Content-length: '.strlen($xml->saveXML()), - ); - $data = $xml->saveXML(); - // print "\n" . $data; - - return $this->submitRequest($url, $header, $data); - } - /** - * @param $curlResponse - * @param $curlInfo - * @param $curlError - * - * @return mixed - * @throws \HpsException - */ - public function processResponse($curlResponse, $curlInfo, $curlError) - { - // print "\n" . $curlResponse; - switch ($curlInfo['http_code']) { - case '200': - $responseObject = $this->_XML2Array($curlResponse); - $ver = "Ver1.0"; - return $responseObject->$ver; - break; - case '500': - $faultString = $this->_XMLFault2String($curlResponse); - throw new HpsException($faultString); - break; - default: - throw new HpsException('Unexpected response'); - break; - } - } - /** - * @param $details - * @param \DOMDocument $xml - * - * @return \DOMElement - */ - public function _hydrateAdditionalTxnFields($details, DOMDocument $xml) - { - $additionalTxnFields = $xml->createElement('hps:AdditionalTxnFields'); - - if ($details->memo != null && $details->memo != "") { - $additionalTxnFields->appendChild($xml->createElement('hps:Description', $details->memo)); - } - - if ($details->invoiceNumber != null && $details->invoiceNumber != "") { - $additionalTxnFields->appendChild($xml->createElement('hps:InvoiceNbr', $details->invoiceNumber)); - } - - if ($details->customerId != null && $details->customerId != "") { - $additionalTxnFields->appendChild($xml->createElement('hps:CustomerID', $details->customerId)); - } - - return $additionalTxnFields; - } - /** - * @param \HpsCardHolder $cardHolder - * @param \DOMDocument $xml - * - * @return \DOMElement - * @throws \HpsInvalidRequestException - */ - public function _hydrateCardHolderData(HpsCardHolder $cardHolder, DOMDocument $xml) - { - //handle both phone and phoneNumber properties as a valid phone - if($cardHolder->phone === null && !empty($cardHolder->phoneNumber) === true){ - $cardHolder->phone = $cardHolder->phoneNumber; - } - //handle both email and emailAddress properties as a valid email - if($cardHolder->email === null && !empty($cardHolder->emailAddress) === true){ - $cardHolder->email = $cardHolder->emailAddress; - } - - $cardHolderData = $xml->createElement('hps:CardHolderData'); - $cardHolderData->appendChild($xml->createElement('hps:CardHolderFirstName', HpsInputValidation::checkCardHolderData($cardHolder->firstName, 'FirstName'))); - $cardHolderData->appendChild($xml->createElement('hps:CardHolderLastName', HpsInputValidation::checkCardHolderData($cardHolder->lastName,'LastName'))); - $cardHolderData->appendChild($xml->createElement('hps:CardHolderEmail', HpsInputValidation::checkEmailAddress($cardHolder->email))); - $cardHolderData->appendChild($xml->createElement('hps:CardHolderPhone', HpsInputValidation::checkPhoneNumber($cardHolder->phone))); - $cardHolderData->appendChild($xml->createElement('hps:CardHolderAddr', HpsInputValidation::checkCardHolderData($cardHolder->address->address))); - $cardHolderData->appendChild($xml->createElement('hps:CardHolderCity', HpsInputValidation::checkCardHolderData($cardHolder->address->city, 'City'))); - $cardHolderData->appendChild($xml->createElement('hps:CardHolderState', HpsInputValidation::checkCardHolderData($cardHolder->address->state, 'State'))); - $cardHolderData->appendChild($xml->createElement('hps:CardHolderZip', HpsInputValidation::checkZipCode($cardHolder->address->zip))); - - return $cardHolderData; - } - /** - * @param \HpsCheck $check - * @param \DOMDocument $xml - * - * @return \DOMElement - */ - public function _hydrateCheckData(HpsCheck $check, DOMDocument $xml) - { - $checkData = $xml->createElement('hps:AccountInfo'); - - if ($check->accountNumber != null) { - $checkData->appendChild($xml->createElement('hps:AccountNumber', $check->accountNumber)); - } - - if ($check->checkNumber != null) { - $checkData->appendChild($xml->createElement('hps:CheckNumber', $check->checkNumber)); - } - - if ($check->micrNumber != null) { - $checkData->appendChild($xml->createElement('hps:MICRData', $check->micrNumber)); - } - - if ($check->routingNumber != null) { - $checkData->appendChild($xml->createElement('hps:RoutingNumber', $check->routingNumber)); - } - - if ($check->accountType != null) { - $checkData->appendChild($xml->createElement('hps:AccountType', strtoupper($check->accountType))); - } - - return $checkData; - } - /** - * @param \HpsCheck $check - * @param \DOMDocument $xml - * - * @return \DOMElement - */ - public function _hydrateConsumerInfo(HpsCheck $check, DOMDocument $xml) - { - $consumerInfo = $xml->createElement('hps:ConsumerInfo'); - - if ($check->checkHolder->address != null) { - $consumerInfo->appendChild($xml->createElement('hps:Address1', $check->checkHolder->address->address)); - $consumerInfo->appendChild($xml->createElement('hps:City', $check->checkHolder->address->city)); - $consumerInfo->appendChild($xml->createElement('hps:State', $check->checkHolder->address->state)); - $consumerInfo->appendChild($xml->createElement('hps:Zip', $check->checkHolder->address->zip)); - } - - if ($check->checkHolder->checkName != null) { - $consumerInfo->appendChild($xml->createElement('hps:CheckName', $check->checkHolder->checkName)); - } - - if ($check->checkHolder->courtesyCard != null) { - $consumerInfo->appendChild($xml->createElement('hps:CourtesyCard', $check->checkHolder->courtesyCard)); - } - - if ($check->checkHolder->dlNumber != null) { - $consumerInfo->appendChild($xml->createElement('hps:DLNumber', $check->checkHolder->dlNumber)); - } - - if ($check->checkHolder->dlState != null) { - $consumerInfo->appendChild($xml->createElement('hps:DLState', $check->checkHolder->dlState)); - } - - if ($check->checkHolder->email != null) { - $consumerInfo->appendChild($xml->createElement('hps:EmailAddress', $check->checkHolder->email)); - } - - if ($check->checkHolder->firstName != null) { - $consumerInfo->appendChild($xml->createElement('hps:FirstName', $check->checkHolder->firstName)); - } - - if ($check->checkHolder->lastName != null) { - $consumerInfo->appendChild($xml->createElement('hps:LastName', $check->checkHolder->lastName)); - } - - if ($check->checkHolder->phone != null) { - $consumerInfo->appendChild($xml->createElement('hps:PhoneNumber', $check->checkHolder->phone)); - } - - if ($check->checkHolder->ssl4 != null || $check->checkHolder->dobYear != null) { - $identityInfo = $xml->createElement('hps:IdentityInfo'); - if ($check->checkHolder->ssl4 != null) { - $identityInfo->appendChild($xml->createElement('hps:SSNL4', $check->checkHolder->ssl4)); - } - if ($check->checkHolder->dobYear != null) { - $identityInfo->appendChild($xml->createElement('hps:DOBYear', $check->checkHolder->dobYear)); - } - $consumerInfo->appendChild($identityInfo); - } - - return $consumerInfo; - } - /** - * @param \HpsCPCData $cpcData - * @param \DOMDocument $xml - * - * @return \DOMElement - */ - public function _hydrateCPCData(HpsCPCData $cpcData, DOMDocument $xml) - { - $cpcDataElement = $xml->createElement('hps:CPCData'); - if (isset($cpcData->cardHolderPONbr)) { - $cpcDataElement->appendChild($xml->createElement('hps:CardHolderPONbr', $cpcData->cardHolderPONbr)); - } - if (isset($cpcData->taxAmt)) { - $cpcDataElement->appendChild($xml->createElement('hps:TaxAmt', $cpcData->taxAmt)); - } - if (isset($cpcData->taxType)) { - $cpcDataElement->appendChild($xml->createElement('hps:TaxType', $cpcData->taxType)); - } - - return $cpcDataElement; - } - /** - * @param \HpsDirectMarketData $data - * @param \DOMDocument $xml - * - * @return \DOMElement - */ - public function _hydrateDirectMarketData(HpsDirectMarketData $data, DOMDocument $xml) - { - $directMktDataElement = $xml->createElement('hps:DirectMktData'); - $directMktDataElement->appendChild($xml->createElement('hps:DirectMktInvoiceNbr', $data->invoiceNumber)); - $directMktDataElement->appendChild($xml->createElement('hps:DirectMktShipMonth', $data->shipMonth)); - $directMktDataElement->appendChild($xml->createElement('hps:DirectMktShipDay', $data->shipDay)); - - return $directMktDataElement; - } - /** - * @param \HpsEncryptionData $encryptionData - * @param \DOMDocument $xml - * - * @return \DOMElement - */ - public function _hydrateEncryptionData(HpsEncryptionData $encryptionData, DOMDocument $xml) - { - $encData = $xml->createElement('hps:EncryptionData'); - if ($encryptionData->encryptedTrackNumber != null) { - $encData->appendChild($xml->createElement('hps:EncryptedTrackNumber', $encryptionData->encryptedTrackNumber)); - } - $encData->appendChild($xml->createElement('hps:KSN', $encryptionData->ksn)); - $encData->appendChild($xml->createElement('hps:KTB', $encryptionData->ktb)); - $encData->appendChild($xml->createElement('hps:Version', $encryptionData->version)); - return $encData; - } - /** - * @param \HpsGiftCard $giftCard - * @param \DOMDocument $xml - * @param string $elementName - * - * @return \DOMElement - */ - public function _hydrateGiftCardData(HpsGiftCard $giftCard, DOMDocument $xml, $elementName = 'CardData') - { - $giftCardData = $xml->createElement('hps:'.$elementName); - if ($giftCard->number != null) { - $giftCardData->appendChild($xml->createElement('hps:CardNbr', $giftCard->number)); - } else if ($giftCard->trackData != null) { - $giftCardData->appendChild($xml->createElement('hps:TrackData', $giftCard->trackData)); - } else if ($giftCard->alias != null) { - $giftCardData->appendChild($xml->createElement('hps:Alias', $giftCard->alias)); - } else if ($giftCard->tokenValue != null) { - $giftCardData->appendChild($xml->createElement('hps:TokenValue', $giftCard->tokenValue)); - } - - if ($giftCard->encryptionData != null) { - $giftCardData->appendChild($this->_hydrateEncryptionData($giftCard->encryptionData, $xml)); - } - - if ($giftCard->pin != null) { - $giftCardData->appendChild($xml->createElement('hps:PIN', $giftCard->pin)); - } - - return $giftCardData; - } - /** - * @param \HpsCreditCard $card - * @param \DOMDocument $xml - * @param bool $cardPresent - * @param bool $readerPresent - * - * @return \DOMElement - */ - public function _hydrateManualEntry(HpsCreditCard $card, DOMDocument $xml, $cardPresent = false, $readerPresent = false) - { - $manualEntry = $xml->createElement('hps:ManualEntry'); - - if (isset($card->number)) { - $manualEntry->appendChild($xml->createElement('hps:CardNbr', $card->number)); - } - - if (isset($card->expMonth)) { - $manualEntry->appendChild($xml->createElement('hps:ExpMonth', $card->expMonth)); - } - - if (isset($card->expYear)) { - $manualEntry->appendChild($xml->createElement('hps:ExpYear', $card->expYear)); - } - - if (isset($card->cvv)) { - $manualEntry->appendChild($xml->createElement('hps:CVV2', $card->cvv)); - } - - $manualEntry->appendChild($xml->createElement('hps:CardPresent', ($cardPresent ? 'Y' : 'N'))); - $manualEntry->appendChild($xml->createElement('hps:ReaderPresent', ($readerPresent ? 'Y' : 'N'))); - - return $manualEntry; - } - /** - * @param $data - * @param $xml - * - * @return mixed - */ - public function _hydrateSecureEcommerce($data, $xml) - { - $secureEcommerce = $xml->createElement('hps:SecureECommerce'); - $secureEcommerce->appendChild($xml->createElement('hps:PaymentDataSource', $data->dataSource)); - $secureEcommerce->appendChild($xml->createElement('hps:TypeOfPaymentData', $data->type)); - - $paymentDataElement = $xml->createElement('hps:PaymentData', $data->data); - $paymentDataElementEncoding = $xml->createAttribute('encoding'); - $paymentDataElementEncoding->value = 'base64'; - $paymentDataElement->appendChild($paymentDataElementEncoding); - $secureEcommerce->appendChild($paymentDataElement); - - if ($data->eciFlag != null && $data->eciFlag != '') { - $secureEcommerce->appendChild($xml->createElement('hps:ECommerceIndicator', $data->eciFlag)); - } - - $xidElement = $xml->createElement('hps:XID', $data->xid); - $xidElementEncoding = $xml->createAttribute('encoding'); - $xidElementEncoding->value = 'base64'; - $xidElement->appendChild($xidElementEncoding); - $secureEcommerce->appendChild($xidElement); - - return $secureEcommerce; - } - /* - * @link https://github.com/hps/heartland-php/pull/21 - * @description resolves a recursion issue identified in the link above - */ - /** - * @param $token - * @param \DOMDocument $xml - * @param bool $cardPresent - * @param bool $readerPresent - * - * @return \DOMElement - */ - public function _hydrateTokenData($token, DOMDocument $xml, $cardPresent = false, $readerPresent = false) - { - if (!$token instanceof HpsTokenData) { - $tokenValue = $token; - $token = new HpsTokenData(); - $token->tokenValue = $tokenValue; - } - - $tokenData = $xml->createElement('hps:TokenData'); - $tokenData->appendChild($xml->createElement('hps:TokenValue', $token->tokenValue)); - - if (isset($token->expMonth)) { - $tokenData->appendChild($xml->createElement('hps:ExpMonth', $token->expMonth)); - } - - if (isset($token->expYear)) { - $tokenData->appendChild($xml->createElement('hps:ExpYear', $token->expYear)); - } - - if (isset($token->cvv)) { - $tokenData->appendChild($xml->createElement('hps:CVV2', $token->cvv)); - } - - $tokenData->appendChild($xml->createElement('hps:CardPresent', ($cardPresent ? 'Y' : 'N'))); - $tokenData->appendChild($xml->createElement('hps:ReaderPresent', ($readerPresent ? 'Y' : 'N'))); - return $tokenData; - } - /** - * @param \HpsTrackData $trackData - * @param $xml - * - * @return mixed - */ - public function _hydrateTrackData(HpsTrackData $trackData, $xml) - { - $trackDataElement = $xml->createElement('hps:TrackData', $trackData->value); - $trackDataElementMethod = $xml->createAttribute('method'); - $trackDataElementMethod->value = $trackData->method; - $trackDataElement->appendChild($trackDataElementMethod); - return $trackDataElement; - } - /** - * @return string - */ - private function _gatewayUrlForKey() - { - if ($this->_config->secretApiKey != null && $this->_config->secretApiKey != "") { - if (strpos($this->_config->secretApiKey, '_cert_') !== false) { - return "https://cert.api2.heartlandportico.com/Hps.Exchange.PosGateway/PosGatewayService.asmx"; - } else if (strpos($this->_config->secretApiKey, '_uat_') !== false) { - return "https://posgateway.uat.secureexchange.net/Hps.Exchange.PosGateway/PosGatewayService.asmx"; - } else { - return "https://api2.heartlandportico.com/Hps.Exchange.PosGateway/PosGatewayService.asmx"; - } - } else { - return $this->_config->soapServiceUri; - } - } - /** - * @param $xml - * - * @return mixed - */ - private function _XML2Array($xml) - { - $envelope = simplexml_load_string($xml, "SimpleXMLElement", 0, 'http://schemas.xmlsoap.org/soap/envelope/'); - foreach ($envelope->Body as $response) { - foreach ($response->children('http://Hps.Exchange.PosGateway') as $item) { - return $item; - } - } - return null; - } - /** - * @param $xml - * - * @return string - */ - private function _XMLFault2String($xml) - { - $dom = new DOMDocument(); - $dom->loadXML($xml); - return $dom->getElementsByTagName('faultstring')->item(0)->nodeValue; - } -} diff --git a/classes/includes/src/Services/Gateway/HpsTokenService.php b/classes/includes/src/Services/Gateway/HpsTokenService.php deleted file mode 100644 index 73c506d..0000000 --- a/classes/includes/src/Services/Gateway/HpsTokenService.php +++ /dev/null @@ -1,97 +0,0 @@ -_config = new HpsServicesConfig(); - $this->_config->publicApiKey = $publicAPIKey; - - $components = explode("_", $publicAPIKey); - if (count($components) == 3 && strtolower($components[1]) == "prod") { - $this->_url = "https://api2.heartlandportico.com/SecureSubmit.v1/api/token"; - } else { - $this->_url = "https://cert.api2.heartlandportico.com/Hps.Exchange.PosGateway.Hpf.v1/api/token"; - } - } - /** - * @param \HpsCreditCard $cardData - * - * @return mixed - * @throws \HpsAuthenticationException - * @throws \HpsGatewayException - */ - public function getToken(HpsCreditCard $cardData) - { - $data = array(); - $data['api_key'] = $this->_config->publicApiKey; - $data['object'] = 'token'; - $data['token_type'] = 'supt'; - $data['_method'] = 'post'; - $data['card[number]'] = $cardData->number; - $data['card[cvc]'] = $cardData->cvv; - $data['card[exp_month]'] = $cardData->expMonth; - $data['card[exp_year]'] = $cardData->expYear; - - $url = $this->_url ."?". http_build_query($data); - $header = array('Content-type: application/json'); - - return $this->submitRequest($url, $header, null, 'GET', HpsServicesConfig::KEY_TYPE_PUBLIC); - } - /** - * @param \HpsGiftCard $cardData - * - * @return mixed - * @throws \HpsAuthenticationException - * @throws \HpsGatewayException - */ - public function getGiftCardToken(HpsGiftCard $cardData) - { - $data = array(); - $data['api_key'] = $this->_config->publicApiKey; - $data['object'] = 'token'; - $data['token_type'] = 'supt'; - $data['_method'] = 'post'; - $data['card[number]'] = $cardData->number; - - $url = $this->_url ."?". http_build_query($data); - $header = array('Content-type: application/json'); - - return $this->submitRequest($url, $header, null, 'GET', HpsServicesConfig::KEY_TYPE_PUBLIC); - } - /** - * @param $curlResponse - * @param $curlInfo - * @param $curlError - * - * @return mixed - * @throws \HpsException - */ - protected function processResponse($curlResponse, $curlInfo, $curlError) - { - $response = json_decode($curlResponse); - - if (isset($response->error) && is_object($response->error)) { - throw new HpsException($response->error->message, $response->error->code); - } - - return $response; - } - /** - * @return bool - */ - protected function _isConfigInvalid() - { - return $this->_config->publicApiKey == null || $this->_url == null; - } -} diff --git a/classes/includes/src/Services/Gateway/PayPlan/HpsPayPlanCustomerService.php b/classes/includes/src/Services/Gateway/PayPlan/HpsPayPlanCustomerService.php deleted file mode 100644 index 6d7618f..0000000 --- a/classes/includes/src/Services/Gateway/PayPlan/HpsPayPlanCustomerService.php +++ /dev/null @@ -1,96 +0,0 @@ -getEditableFieldsWithValues(); - $result = $this->doRequest($data, array( - 'verb' => 'POST', - 'endpoint' => 'customers', - )); - return $this->hydrateObject($result, 'HpsPayPlanCustomer'); - } - /** - * @param \HpsPayPlanCustomer $customer - * - * @return mixed - */ - public function edit(HpsPayPlanCustomer $customer) - { - $data = $customer->getEditableFieldsWithValues(); - $result = $this->doRequest($data, array( - 'verb' => 'PUT', - 'endpoint' => 'customers/'.$customer->customerKey, - )); - return $this->hydrateObject($result, 'HpsPayPlanCustomer'); - } - /** - * @param array $searchFields - * - * @return object - */ - public function findAll($searchFields = array()) - { - // Cannot have an array as the root object - // in a JSON document - $data = $searchFields === array() ? (object)array() : $searchFields; - $results = $this - ->doRequest($data, array( - 'verb' => 'POST', - 'endpoint' => 'searchCustomers', - )); - - return $this->hydrateSearchResults($results, 'HpsPayPlanCustomer'); - } - /** - * @param $customer - * - * @return mixed - */ - public function get($customer) - { - $id = null; - if ($customer instanceof HpsPayPlanCustomer) { - $id = $customer->customerKey; - } else { - $id = $customer; - } - $result = $this->doRequest(null, array( - 'verb' => 'GET', - 'endpoint' => 'customers/'.$id, - )); - return $this->hydrateObject($result, 'HpsPayPlanCustomer'); - } - /** - * @param $customer - * @param bool $forceDelete - * - * @return mixed - */ - public function delete($customer, $forceDelete = false) - { - $id = null; - if ($customer instanceof HpsPayPlanCustomer) { - $id = $customer->customerKey; - } else { - $id = $customer; - } - - $data = array( - 'forceDelete' => $forceDelete, - ); - return $this->doRequest($data, array( - 'verb' => 'DELETE', - 'endpoint' => 'customers/'.$id, - )); - } -} diff --git a/classes/includes/src/Services/Gateway/PayPlan/HpsPayPlanPaymentMethodService.php b/classes/includes/src/Services/Gateway/PayPlan/HpsPayPlanPaymentMethodService.php deleted file mode 100644 index 2cadf03..0000000 --- a/classes/includes/src/Services/Gateway/PayPlan/HpsPayPlanPaymentMethodService.php +++ /dev/null @@ -1,165 +0,0 @@ -paymentMethodType == HpsPayPlanPaymentMethodType::ACH) { - $result = $this->addACH($paymentMethod); - } else { - $result = $this->addCreditCard($paymentMethod); - } - return $this->hydrateObject($result, 'HpsPayPlanPaymentMethod'); - } - /** - * @param \HpsPayPlanPaymentMethod $paymentMethod - * - * @return mixed - */ - 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 array $searchFields - * - * @return object - */ - public function findAll($searchFields = array()) - { - // Cannot have an array as the root object - // in a JSON document - $data = $searchFields === array() ? (object)array() : $searchFields; - $results = $this - ->doRequest($data, array( - 'verb' => 'POST', - 'endpoint' => 'searchPaymentMethods', - )); - - return $this->hydrateSearchResults($results, 'HpsPayPlanPaymentMethod'); - } - /** - * @param $paymentMethod - * - * @return mixed - */ - 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 - * @param bool $forceDelete - * - * @return mixed - */ - 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 \HpsPayPlanPaymentMethod $paymentMethod - * - * @return mixed - */ - 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 - */ - 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 - */ - 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 - */ - private function editACH(HpsPayPlanPaymentMethod $paymentMethod) - { - $data = $paymentMethod->getEditableFieldsWithValues(); - $result = $this->doRequest($data, array( - 'verb' => 'PUT', - 'endpoint' => 'paymentMethodsACH/'.$paymentMethod->paymentMethodKey, - )); - return $this->hydrateObject($result, 'HpsPayPlanPaymentMethod'); - } -} diff --git a/classes/includes/src/Services/Gateway/PayPlan/HpsPayPlanScheduleService.php b/classes/includes/src/Services/Gateway/PayPlan/HpsPayPlanScheduleService.php deleted file mode 100644 index cb05c0e..0000000 --- a/classes/includes/src/Services/Gateway/PayPlan/HpsPayPlanScheduleService.php +++ /dev/null @@ -1,96 +0,0 @@ -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 - */ - 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 array $searchFields - * - * @return object - */ - public function findAll($searchFields = array()) - { - // Cannot have an array as the root object - // in a JSON document - $data = $searchFields === array() ? (object)array() : $searchFields; - $results = $this - ->doRequest($data, array( - 'verb' => 'POST', - 'endpoint' => 'searchSchedules', - )); - return $this->hydrateSearchResults($results, 'HpsPayPlanSchedule'); - } - /** - * @param $schedule - * - * @return mixed - */ - 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 - * @param bool $forceDelete - * - * @return mixed - */ - 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, - )); - } -} \ No newline at end of file diff --git a/classes/includes/src/Services/HpsCentinelConfig.php b/classes/includes/src/Services/HpsCentinelConfig.php deleted file mode 100644 index 6fbdc2f..0000000 --- a/classes/includes/src/Services/HpsCentinelConfig.php +++ /dev/null @@ -1,41 +0,0 @@ -serviceUri; - } - /** - * @param $value - * - * @return mixed|void - */ - public function setServiceUri($value) - { - $this->serviceUri = $value; - } - /** - * @param $keyType - * - * @return bool - */ - public function validate($keyType) - { - return true; - } -} diff --git a/classes/includes/src/Services/HpsServicesConfig.php b/classes/includes/src/Services/HpsServicesConfig.php deleted file mode 100644 index 212b2c6..0000000 --- a/classes/includes/src/Services/HpsServicesConfig.php +++ /dev/null @@ -1,88 +0,0 @@ -soapServiceUri; - } - /** - * @param $value - * - * @return mixed|void - */ - public function setServiceUri($value) - { - $this->soapServiceUri = $value; - } - /** - * @param $keyType - * - * @return bool - */ - public function validate($keyType) - { - return ($keyType == self::KEY_TYPE_PUBLIC && $this->validatePublicApiKey()) - || ($keyType == self::KEY_TYPE_SECRET && $this->validateSecretApiKey()); - } - /** - * @param $keyType - * - * @return string - */ - public function getKeyType($keyType) - { - $key = trim($keyType == self::KEY_TYPE_SECRET ? $this->secretApiKey : $this->publicApiKey); - switch (true) { - case substr($key, 0, 6) == 'skapi_': - return self::KEY_TYPE_SECRET; - break; - case substr($key, 0, 6) == 'pkapi_': - return self::KEY_TYPE_PUBLIC; - break; - default: - return self::KEY_TYPE_UNKNOWN; - break; - } - } - /** - * @return bool - */ - protected function validateSecretApiKey() - { - return is_string($this->secretApiKey) - && $this->getKeyType(self::KEY_TYPE_SECRET) == self::KEY_TYPE_SECRET - && strlen($this->secretApiKey) >= 48; - } - /** - * @return bool - */ - protected function validatePublicApiKey() - { - return is_string($this->publicApiKey) - && $this->getKeyType(self::KEY_TYPE_PUBLIC) == self::KEY_TYPE_PUBLIC - && strlen($this->publicApiKey) >= 28; - } -} diff --git a/classes/includes/src/Services/index.php b/classes/includes/src/Services/index.php deleted file mode 100644 index b3d9bbc..0000000 --- a/classes/includes/src/Services/index.php +++ /dev/null @@ -1 +0,0 @@ -