diff --git a/.phpcs.xml b/.phpcs.xml index 865ce7d..8583745 100644 --- a/.phpcs.xml +++ b/.phpcs.xml @@ -5,4 +5,6 @@ */genesis/* + *.min.js + *.min.css diff --git a/.phpmd.xml b/.phpmd.xml index b264445..3568018 100644 --- a/.phpmd.xml +++ b/.phpmd.xml @@ -15,6 +15,12 @@ + + + + + + diff --git a/Gemfile b/Gemfile deleted file mode 100644 index 5f29bc2..0000000 --- a/Gemfile +++ /dev/null @@ -1,6 +0,0 @@ -source 'http://rubygems.org' - -# code analysis -gem 'pronto', '~> 0.9.5' -gem 'pronto-phpcs', '~> 0.4.0', require: false -gem 'pronto-phpmd', '~> 0.4.0', require: false diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index 0cbcb6b..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1,53 +0,0 @@ -GEM - remote: http://rubygems.org/ - specs: - addressable (2.8.4) - public_suffix (>= 2.0.2, < 6.0) - faraday (1.0.1) - multipart-post (>= 1.2, < 3) - gitlab (4.14.0) - httparty (~> 0.14, >= 0.14.0) - terminal-table (~> 1.5, >= 1.5.1) - httparty (0.21.0) - mini_mime (>= 1.0.0) - multi_xml (>= 0.5.2) - mini_mime (1.1.2) - multi_xml (0.6.0) - multipart-post (2.3.0) - octokit (4.25.1) - faraday (>= 1, < 3) - sawyer (~> 0.9) - pronto (0.9.5) - gitlab (~> 4.0, >= 4.0.0) - httparty (>= 0.13.7) - octokit (~> 4.7, >= 4.7.0) - rainbow (~> 2.1) - rugged (~> 0.24, >= 0.23.0) - thor (~> 0.19.0) - pronto-phpcs (0.4.0) - pronto (~> 0.9.0) - pronto-phpmd (0.4.0) - pronto (~> 0.9.0) - public_suffix (4.0.7) - rainbow (2.2.2) - rake - rake (13.0.6) - rugged (0.99.0) - sawyer (0.9.2) - addressable (>= 2.3.5) - faraday (>= 0.17.3, < 3) - terminal-table (1.8.0) - unicode-display_width (~> 1.1, >= 1.1.1) - thor (0.19.4) - unicode-display_width (1.8.0) - -PLATFORMS - ruby - -DEPENDENCIES - pronto (~> 0.9.5) - pronto-phpcs (~> 0.4.0) - pronto-phpmd (~> 0.4.0) - -BUNDLED WITH - 1.17.3 diff --git a/README.md b/README.md index 5340e5f..b907e79 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Requirements ------------ * OpenCart 3.0.X - 3.0.3.X (due to architectural changes, this module is __incompatible__ with OpenCart 1.X and 2.0.X) -* [GenesisPHP v1.24.0](https://github.com/GenesisGateway/genesis_php/tree/1.24.0) - (Integrated in Module) +* [GenesisPHP v2.0.2](https://github.com/GenesisGateway/genesis_php/tree/2.0.2) - (Integrated in Module) GenesisPHP Requirements ------------ @@ -79,12 +79,10 @@ Supported Transactions & Payment Methods * __eps__ * __eZeeWallet__ * __Fashioncheque__ - * __GiroPay__ * __Google Pay__ * __iDeal__ * __iDebit__ * __InstaDebit__ - * __InstantTransfer__ * __InitRecurringSale__ * __InitRecurringSale (3D-Secure)__ * __Intersolve__ @@ -99,7 +97,9 @@ Supported Transactions & Payment Methods * __Online Banking__ * __Interac Combined Pay-in (CPI)__ * __Bancontact__ - * __Blik One Click (BLK)__ + * __BLIK__ + * __SPEI__ + * __LatiPay__ * __OXXO__ * __P24__ * __Pago Facil__ @@ -109,15 +109,6 @@ Supported Transactions & Payment Methods * __Pix__ * __POLi__ * __Post Finance__ - * __PPRO__ - * __eps__ - * __GiroPay__ - * __Ideal__ - * __Przelewy24__ - * __SafetyPay__ - * __TrustPay__ - * __BCMC__ - * __MyBank__ * __PSE__ * __RapiPago__ * __Redpagos__ @@ -140,4 +131,4 @@ _Note_: If you have trouble with your credentials or terminal configuration, get You're now ready to process payments through our gateway. -[support]: mailto:tech-support@e-comprocessing.com +[support]: mailto:tech-support@e-comprocessing.net diff --git a/admin/controller/extension/payment/ecomprocessing/base_controller.php b/admin/controller/extension/payment/ecomprocessing/base_controller.php index 2e3ff68..dc8da37 100644 --- a/admin/controller/extension/payment/ecomprocessing/base_controller.php +++ b/admin/controller/extension/payment/ecomprocessing/base_controller.php @@ -17,8 +17,9 @@ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License, version 2 (GPL-2.0) */ -use Genesis\API\Constants\Transaction\Parameters\ScaExemptions; -use Genesis\API\Constants\Transaction\Parameters\Threeds\V2\Control\ChallengeIndicators; +use Genesis\Api\Constants\Transaction\Parameters\ScaExemptions; +use Genesis\Api\Constants\Transaction\Parameters\Threeds\V2\Control\ChallengeIndicators; +use Genesis\Api\Constants\Transaction\States; if (!class_exists('\Genesis\Genesis', false)) { include DIR_APPLICATION . '/../admin/model/extension/payment/ecomprocessing/genesis/vendor/autoload.php'; @@ -32,6 +33,13 @@ * Base Abstract Class for Method Admin Controllers * * Class ControllerExtensionPaymentEcomprocessingBase + * + * @SuppressWarnings(PHPMD.ExcessiveClassLength) + * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) + * @SuppressWarnings(PHPMD.TooManyMethods) + * @SuppressWarnings(PHPMD.LongClassName) */ abstract class ControllerExtensionPaymentEcomprocessingBase extends Controller { @@ -294,6 +302,7 @@ protected function processPostIndexAction() * Processes HTTP GET Index action * * @return void + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ protected function processGetIndexAction() { @@ -534,6 +543,7 @@ public function order() * Get transactions list * * @return mixed + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function orderAction() { @@ -559,7 +569,7 @@ public function orderAction() // Process individual fields foreach ($transactions as &$transaction) { /* OpenCart 2.2.x Fix (Cart\Currency does not check if the given currency code exists */ - if (($has_currency_method && $this->currency->has($transaction['currency'])) || (!$has_currency_method && !@empty($transaction['currency']))) + if (($has_currency_method && $this->currency->has($transaction['currency'])) || (!$has_currency_method && !empty($transaction['currency']))) $transaction['amount'] = $this->currency->format($transaction['amount'], $transaction['currency']); else /* No Currency Code is stored on Void Transaction */ $transaction['amount'] = ""; @@ -579,10 +589,13 @@ public function orderAction() // Ascending Date/Timestamp sorting uasort($transactions, function ($element1, $element2) { // sort by timestamp (date) first - if (@$element1["timestamp"] == @$element2["timestamp"]) { - return 0; + if (isset($element1['timestamp']) && isset($element2['timestamp'])) { + if ($element1['timestamp'] == $element2['timestamp']) { + return 0; + } + return ($element1["timestamp"] > $element2["timestamp"]) ? 1 : -1; } - return (@$element1["timestamp"] > @$element2["timestamp"]) ? 1 : -1; + return -1; }); // Create the parent/child relations from a flat array @@ -672,13 +685,13 @@ public function getModalForm() $order_id, $transaction['reference_id'], array( - \Genesis\API\Constants\Transaction\Types::AUTHORIZE, - \Genesis\API\Constants\Transaction\Types::AUTHORIZE_3D, - \Genesis\API\Constants\Transaction\Types::GOOGLE_PAY, - \Genesis\API\Constants\Transaction\Types::PAY_PAL, - \Genesis\API\Constants\Transaction\Types::APPLE_PAY, + \Genesis\Api\Constants\Transaction\Types::AUTHORIZE, + \Genesis\Api\Constants\Transaction\Types::AUTHORIZE_3D, + \Genesis\Api\Constants\Transaction\Types::GOOGLE_PAY, + \Genesis\Api\Constants\Transaction\Types::PAY_PAL, + \Genesis\Api\Constants\Transaction\Types::APPLE_PAY, ), - \Genesis\API\Constants\Transaction\States::APPROVED + \Genesis\Api\Constants\Transaction\States::APPROVED ); $total_captured_amount = $this->getModelInstance()->getTransactionsSumAmount($order_id, $transaction['unique_id'], 'capture', 'approved'); $transaction['available_amount'] = $total_authorized_amount - $total_captured_amount; @@ -829,6 +842,7 @@ public function capture() * Perform a Refund transaction * * @return void + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function refund() { @@ -1107,15 +1121,15 @@ protected function validate() $this->error['warning'] = $this->language->get('error_permission'); } - if (@empty($this->request->post["{$this->module_name}_username"])) { + if (empty($this->request->post["{$this->module_name}_username"])) { $this->error['username'] = $this->language->get('error_username'); } - if (@empty($this->request->post["{$this->module_name}_password"])) { + if (empty($this->request->post["{$this->module_name}_password"])) { $this->error['password'] = $this->language->get('error_password'); } - if (@empty($this->request->post["{$this->module_name}_transaction_type"])) { + if (empty($this->request->post["{$this->module_name}_transaction_type"])) { $this->error['transaction_type'] = $this->language->get('error_transaction_type'); } @@ -1362,8 +1376,8 @@ public function getOrderRecurringId($order_id) public function isInitialRecurringTransaction($transaction_type) { return in_array($transaction_type, array( - \Genesis\API\Constants\Transaction\Types::INIT_RECURRING_SALE, - \Genesis\API\Constants\Transaction\Types::INIT_RECURRING_SALE_3D + \Genesis\Api\Constants\Transaction\Types::INIT_RECURRING_SALE, + \Genesis\Api\Constants\Transaction\Types::INIT_RECURRING_SALE_3D )); } @@ -1424,7 +1438,7 @@ public function canCaptureTransaction($transaction) ); } - return \Genesis\API\Constants\Transaction\Types::canCapture($transaction['type']); + return \Genesis\Api\Constants\Transaction\Types::canCapture($transaction['type']); } /** @@ -1446,7 +1460,7 @@ public function canRefundTransaction($transaction) ); } - return \Genesis\API\Constants\Transaction\Types::canRefund($transaction['type']); + return \Genesis\Api\Constants\Transaction\Types::canRefund($transaction['type']); } /** @@ -1457,7 +1471,7 @@ public function canRefundTransaction($transaction) */ public function canVoidTransaction($transaction) { - return \Genesis\API\Constants\Transaction\Types::canVoid($transaction['type']) && + return \Genesis\Api\Constants\Transaction\Types::canVoid($transaction['type']) && $this->hasApprovedState($transaction['status']); } @@ -1473,8 +1487,8 @@ public function isVoidTransactionExist($order_id, $transaction) return $this->getModelInstance()->getTransactionsByTypeAndStatus( $order_id, $transaction['unique_id'], - \Genesis\API\Constants\Transaction\Types::VOID, - \Genesis\API\Constants\Transaction\States::APPROVED + \Genesis\Api\Constants\Transaction\Types::VOID, + \Genesis\Api\Constants\Transaction\States::APPROVED ) !== false; } @@ -1798,9 +1812,9 @@ protected function getServerAddress() protected function isTransactionWithCustomAttribute($transaction_type) { $transaction_types = [ - \Genesis\API\Constants\Transaction\Types::GOOGLE_PAY, - \Genesis\API\Constants\Transaction\Types::PAY_PAL, - \Genesis\API\Constants\Transaction\Types::APPLE_PAY, + \Genesis\Api\Constants\Transaction\Types::GOOGLE_PAY, + \Genesis\Api\Constants\Transaction\Types::PAY_PAL, + \Genesis\Api\Constants\Transaction\Types::APPLE_PAY, ]; return in_array($transaction_type, $transaction_types); @@ -1822,7 +1836,7 @@ protected function checkReferenceActionByCustomAttr($action, $transaction_type) } switch ($transaction_type) { - case \Genesis\API\Constants\Transaction\Types::GOOGLE_PAY: + case \Genesis\Api\Constants\Transaction\Types::GOOGLE_PAY: if (EcomprocessingHelper::REFERENCE_ACTION_CAPTURE === $action) { return in_array( EcomprocessingHelper::GOOGLE_PAY_TRANSACTION_PREFIX . @@ -1839,7 +1853,7 @@ protected function checkReferenceActionByCustomAttr($action, $transaction_type) ); } break; - case \Genesis\API\Constants\Transaction\Types::PAY_PAL: + case \Genesis\Api\Constants\Transaction\Types::PAY_PAL: if (EcomprocessingHelper::REFERENCE_ACTION_CAPTURE === $action) { return in_array( EcomprocessingHelper::PAYPAL_TRANSACTION_PREFIX . @@ -1859,7 +1873,7 @@ protected function checkReferenceActionByCustomAttr($action, $transaction_type) return (count(array_intersect($refundable_types, $selected_types)) > 0); } break; - case \Genesis\API\Constants\Transaction\Types::APPLE_PAY: + case \Genesis\Api\Constants\Transaction\Types::APPLE_PAY: if (EcomprocessingHelper::REFERENCE_ACTION_CAPTURE === $action) { return in_array( EcomprocessingHelper::APPLE_PAY_TRANSACTION_PREFIX . @@ -1895,7 +1909,7 @@ protected function hasApprovedState($transaction_type) return false; } - $state = new \Genesis\API\Constants\Transaction\States($transaction_type); + $state = new States($transaction_type); return $state->isApproved(); } diff --git a/admin/controller/extension/payment/ecomprocessing_checkout.php b/admin/controller/extension/payment/ecomprocessing_checkout.php index a694ac1..97bcda8 100644 --- a/admin/controller/extension/payment/ecomprocessing_checkout.php +++ b/admin/controller/extension/payment/ecomprocessing_checkout.php @@ -25,6 +25,7 @@ * Backend controller for the "ecomprocessing Checkout" module * * @package EcomprocessingCheckout + * @SuppressWarnings(PHPMD.LongClassName) */ class ControllerExtensionPaymentEcomprocessingCheckout extends ControllerExtensionPaymentEcomprocessingBase { diff --git a/admin/model/extension/payment/ecomprocessing/EcomprocessingHelper.php b/admin/model/extension/payment/ecomprocessing/EcomprocessingHelper.php index 1f303ea..9a71d18 100644 --- a/admin/model/extension/payment/ecomprocessing/EcomprocessingHelper.php +++ b/admin/model/extension/payment/ecomprocessing/EcomprocessingHelper.php @@ -17,6 +17,9 @@ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License, version 2 (GPL-2.0) */ +use Genesis\Api\Request\Financial\Alternatives\Klarna\Item; +use Genesis\Api\Request\Financial\Alternatives\Klarna\Items; + if (!class_exists('\Genesis\Genesis', false)) { if (strpos(DIR_APPLICATION, 'admin') === false) { $path = DIR_APPLICATION . '/../admin/model/extension/payment/ecomprocessing/genesis/vendor/autoload.php'; @@ -43,28 +46,27 @@ */ class EcomprocessingHelper { - const PPRO_TRANSACTION_SUFFIX = '_ppro'; const TRANSACTION_LANGUAGE_PREFIX = 'text_transaction_'; - const GOOGLE_PAY_TRANSACTION_PREFIX = \Genesis\API\Constants\Transaction\Types::GOOGLE_PAY . '_'; + const GOOGLE_PAY_TRANSACTION_PREFIX = \Genesis\Api\Constants\Transaction\Types::GOOGLE_PAY . '_'; const GOOGLE_PAY_PAYMENT_TYPE_AUTHORIZE = - \Genesis\API\Constants\Transaction\Parameters\Mobile\GooglePay\PaymentTypes::AUTHORIZE; + \Genesis\Api\Constants\Transaction\Parameters\Mobile\GooglePay\PaymentTypes::AUTHORIZE; const GOOGLE_PAY_PAYMENT_TYPE_SALE = - \Genesis\API\Constants\Transaction\Parameters\Mobile\GooglePay\PaymentTypes::SALE; + \Genesis\Api\Constants\Transaction\Parameters\Mobile\GooglePay\PaymentTypes::SALE; - const PAYPAL_TRANSACTION_PREFIX = \Genesis\API\Constants\Transaction\Types::PAY_PAL . '_'; + const PAYPAL_TRANSACTION_PREFIX = \Genesis\Api\Constants\Transaction\Types::PAY_PAL . '_'; const PAYPAL_PAYMENT_TYPE_AUTHORIZE = - \Genesis\API\Constants\Transaction\Parameters\Wallets\PayPal\PaymentTypes::AUTHORIZE; + \Genesis\Api\Constants\Transaction\Parameters\Wallets\PayPal\PaymentTypes::AUTHORIZE; const PAYPAL_PAYMENT_TYPE_SALE = - \Genesis\API\Constants\Transaction\Parameters\Wallets\PayPal\PaymentTypes::SALE; + \Genesis\Api\Constants\Transaction\Parameters\Wallets\PayPal\PaymentTypes::SALE; const PAYPAL_PAYMENT_TYPE_EXPRESS = - \Genesis\API\Constants\Transaction\Parameters\Wallets\PayPal\PaymentTypes::EXPRESS; + \Genesis\Api\Constants\Transaction\Parameters\Wallets\PayPal\PaymentTypes::EXPRESS; - const APPLE_PAY_TRANSACTION_PREFIX = \Genesis\API\Constants\Transaction\Types::APPLE_PAY . '_'; + const APPLE_PAY_TRANSACTION_PREFIX = \Genesis\Api\Constants\Transaction\Types::APPLE_PAY . '_'; const APPLE_PAY_PAYMENT_TYPE_AUTHORIZE = - \Genesis\API\Constants\Transaction\Parameters\Mobile\ApplePay\PaymentTypes::AUTHORIZE; + \Genesis\Api\Constants\Transaction\Parameters\Mobile\ApplePay\PaymentTypes::AUTHORIZE; const APPLE_PAY_PAYMENT_TYPE_SALE = - \Genesis\API\Constants\Transaction\Parameters\Mobile\ApplePay\PaymentTypes::SALE; + \Genesis\Api\Constants\Transaction\Parameters\Mobile\ApplePay\PaymentTypes::SALE; const REFERENCE_ACTION_CAPTURE = 'capture'; const REFERENCE_ACTION_REFUND = 'refund'; @@ -77,8 +79,8 @@ class EcomprocessingHelper public static function getRecurringTransactionTypes() { return array( - \Genesis\API\Constants\Transaction\Types::INIT_RECURRING_SALE, - \Genesis\API\Constants\Transaction\Types::INIT_RECURRING_SALE_3D + \Genesis\Api\Constants\Transaction\Types::INIT_RECURRING_SALE, + \Genesis\Api\Constants\Transaction\Types::INIT_RECURRING_SALE_3D ); } @@ -91,9 +93,9 @@ public static function getTransactionTypeNames() { $data = array(); - foreach (\Genesis\API\Constants\Transaction\Types::getWPFTransactionTypes() as $type) { + foreach (\Genesis\Api\Constants\Transaction\Types::getWPFTransactionTypes() as $type) { $key = EcomprocessingHelper::TRANSACTION_LANGUAGE_PREFIX . $type; - $data[$key] = \Genesis\API\Constants\Transaction\Names::getName($type); + $data[$key] = \Genesis\Api\Constants\Transaction\Names::getName($type); } return $data; @@ -111,21 +113,21 @@ public static function getTransactionTypeNames() * ) * ) * - * @return \Genesis\API\Request\Financial\Alternatives\Klarna\Items + * @return \Genesis\Api\Request\Financial\Alternatives\Klarna\Items * @throws \Genesis\Exceptions\ErrorParameter */ public static function getKlarnaCustomParamItems($order) { $tax_class_ids = self::getTaxClassIdFromProductInfo($order['additional']['product_info']); - $items = new \Genesis\API\Request\Financial\Alternatives\Klarna\Items($order['currency']); + $items = new Items($order['currency']); foreach ($order['additional']['product_order_info'] as $product) { - $tax_class_id = \Genesis\API\Request\Financial\Alternatives\Klarna\Item::ITEM_TYPE_PHYSICAL; + $tax_class_id = \Genesis\Api\Request\Financial\Alternatives\Klarna\Item::ITEM_TYPE_PHYSICAL; if ($tax_class_ids[$product['product_id']] == ModelPaymentEcomprocessingBase::OC_TAX_CLASS_VIRTUAL_PRODUCT) { - $tax_class_id = \Genesis\API\Request\Financial\Alternatives\Klarna\Item::ITEM_TYPE_DIGITAL; + $tax_class_id = \Genesis\Api\Request\Financial\Alternatives\Klarna\Item::ITEM_TYPE_DIGITAL; } - $klarna_item = new \Genesis\API\Request\Financial\Alternatives\Klarna\Item( + $klarna_item = new Item( $product['name'], $tax_class_id, $product['quantity'], @@ -138,9 +140,9 @@ public static function getKlarnaCustomParamItems($order) $taxes = floatval(self::getTaxFromOrderTotals($order['additional']['order_totals'])); if ($taxes) { $items->addItem( - new \Genesis\API\Request\Financial\Alternatives\Klarna\Item( + new Item( 'Taxes', - \Genesis\API\Request\Financial\Alternatives\Klarna\Item::ITEM_TYPE_SURCHARGE, + \Genesis\Api\Request\Financial\Alternatives\Klarna\Item::ITEM_TYPE_SURCHARGE, 1, $taxes ) @@ -150,9 +152,9 @@ public static function getKlarnaCustomParamItems($order) $shipping = floatval(self::getShippingFromOrderTotals($order['additional']['order_totals'])); if ($shipping) { $items->addItem( - new \Genesis\API\Request\Financial\Alternatives\Klarna\Item( + new Item( 'Shipping Costs', - \Genesis\API\Request\Financial\Alternatives\Klarna\Item::ITEM_TYPE_SHIPPING_FEE, + \Genesis\Api\Request\Financial\Alternatives\Klarna\Item::ITEM_TYPE_SHIPPING_FEE, 1, $shipping ) @@ -220,9 +222,11 @@ public static function getTaxFromOrderTotals($order_totals) { */ public static function getAvailableBankCodes() { return [ - \Genesis\API\Constants\Banks::CPI => 'Interac Combined Pay-in', - \Genesis\API\Constants\Banks::BCT => 'Bancontact', - \Genesis\API\Constants\Banks::BLK => 'Blik One Click' + \Genesis\Api\Constants\Banks::CPI => 'Interac Combined Pay-in', + \Genesis\Api\Constants\Banks::BCT => 'Bancontact', + \Genesis\Api\Constants\Banks::BLK => 'BLIK', + \Genesis\Api\Constants\Banks::SE => 'SPEI', + \Genesis\Api\Constants\Banks::PID => 'LatiPay' ]; } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Alternatives/ABNiDEAL.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Alternatives/ABNiDEAL.php deleted file mode 100644 index 7a8c3e2..0000000 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Alternatives/ABNiDEAL.php +++ /dev/null @@ -1,110 +0,0 @@ -requiredFields = \Genesis\Utils\Common::createArrayObject($requiredFields); - - $requiredFieldValues = [ - 'billing_country' => \Genesis\Utils\Country::getList(), - 'currency' => \Genesis\Utils\Currency::getList() - ]; - - $this->requiredFieldValues = \Genesis\Utils\Common::createArrayObject($requiredFieldValues); - } - - /** - * Return additional request attributes - * @return array - */ - protected function getPaymentTransactionStructure() - { - return [ - 'return_success_url' => $this->return_success_url, - 'return_failure_url' => $this->return_failure_url, - 'amount' => $this->transformAmount($this->amount, $this->currency), - 'currency' => $this->currency, - 'customer_email' => $this->customer_email, - 'customer_phone' => $this->customer_phone, - 'customer_bank_id' => $this->customer_bank_id, - 'billing_address' => $this->getBillingAddressParamsStructure(), - 'shipping_address' => $this->getShippingAddressParamsStructure() - ]; - } -} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Alternatives/Earthport.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Alternatives/Earthport.php deleted file mode 100644 index bcc8a84..0000000 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Alternatives/Earthport.php +++ /dev/null @@ -1,325 +0,0 @@ -requiredFields = \Genesis\Utils\Common::createArrayObject($requiredFields); - - $requiredFieldValues = [ - 'billing_country' => [ - 'AD', 'AU', 'AT', 'BH', 'BS', 'BE', 'BG', 'CA', 'CY', 'CZ', 'DK', 'EG', 'EE', - 'FI', 'FR', 'DE', 'GR', 'HK', 'HU', 'ID', 'IE', 'IL', 'IT', 'JP', 'KE', 'LV', - 'LI', 'LT', 'LU', 'MY', 'MT', 'MA', 'NL', 'NZ', 'NO', 'PK', 'PH', 'PL', 'PT', - 'RO', 'SG', 'SK', 'SI', 'ES', 'SE', 'CH', 'GB', 'US', 'VN' - ], - 'currency' => \Genesis\Utils\Currency::getList() - ]; - - $this->requiredFieldValues = \Genesis\Utils\Common::createArrayObject($requiredFieldValues); - - $this->setRequiredFieldValuesConditional(); - } - - /** - * Set the required fields - conditionally depending on other fields - * - * @return void - * - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - protected function setRequiredFieldValuesConditional() - { - $commonIbanFields = [ - 'iban', - 'bic' - ]; - $commonAccountFields = [ - 'account_number', - 'bank_code', - 'branch_code' - ]; - - $requiredFieldsConditional = [ - 'billing_country' => [ - 'AD' => $commonIbanFields, - 'AU' => $commonAccountFields, - 'AT' => $commonIbanFields, - 'BH' => $commonIbanFields, - 'BS' => $commonIbanFields, - 'BE' => $commonIbanFields, - 'BG' => $commonIbanFields, - 'CA' => $commonAccountFields, - 'CY' => $commonIbanFields, - 'CZ' => $commonIbanFields, - 'DK' => $commonIbanFields, - 'EG' => [ - 'account_number', - 'bic' - ], - 'EE' => $commonIbanFields, - 'FI' => $commonIbanFields, - 'FR' => $commonIbanFields, - 'DE' => $commonIbanFields, - 'GR' => $commonIbanFields, - 'HK' => [ - 'bank_code', - 'branch_code', - 'account_number', - 'account_number_suffix' - ], - 'HU' => $commonIbanFields, - 'ID' => $commonAccountFields, - 'IE' => $commonIbanFields, - 'IL' => $commonIbanFields, - 'IT' => $commonIbanFields, - 'JP' => $commonIbanFields, - 'KE' => $commonIbanFields, - 'LV' => $commonIbanFields, - 'LI' => $commonIbanFields, - 'LT' => $commonIbanFields, - 'LU' => $commonIbanFields, - 'MY' => [ - 'account_number', - 'bic' - ], - 'MT' => $commonIbanFields, - 'MA' => [ - 'account_number' - ], - 'NL' => $commonIbanFields, - 'NZ' => [ - 'bank_code', - 'branch_code', - 'account_number', - 'account_number_suffix' - ], - 'NO' => $commonIbanFields, - 'PK' => $commonIbanFields, - 'PH' => [ - 'bank_code', - 'account_number' - ], - 'PL' => $commonIbanFields, - 'PT' => $commonIbanFields, - 'RO' => $commonIbanFields, - 'SG' => $commonAccountFields, - 'SK' => $commonIbanFields, - 'SI' => $commonIbanFields, - 'ES' => $commonIbanFields, - 'SE' => [ - 'bank_code', - 'account_number', - 'bic' - ], - 'CH' => $commonIbanFields, - 'GB' => [ - 'account_number', - 'sort_code' - ], - 'US' => [ - 'billing_state', - 'account_number', - 'aba_routing_number' - ], - 'VN' => [ - 'account_number', - 'bic' - ] - ] - ]; - - $this->requiredFieldsConditional = \Genesis\Utils\Common::createArrayObject($requiredFieldsConditional); - } - - /** - * Return additional request attributes - * @return array - */ - protected function getPaymentTransactionStructure() - { - return [ - 'amount' => $this->transformAmount($this->amount, $this->currency), - 'currency' => $this->currency, - 'customer_email' => $this->customer_email, - 'customer_phone' => $this->customer_phone, - 'account_name' => $this->account_name, - 'bank_name' => $this->bank_name, - 'iban' => $this->iban, - 'bic' => $this->bic, - 'account_number' => $this->account_number, - 'bank_code' => $this->bank_code, - 'branch_code' => $this->branch_code, - 'account_number_suffix' => $this->account_number_suffix, - 'sort_code' => $this->sort_code, - 'aba_routing_number' => $this->aba_routing_number, - 'billing_address' => $this->getBillingAddressParamsStructure(), - ]; - } -} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Alternatives/INPay.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Alternatives/INPay.php deleted file mode 100644 index 40c8e23..0000000 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Alternatives/INPay.php +++ /dev/null @@ -1,230 +0,0 @@ -setIsPayout(false); - } - - /** - * Returns the Request transaction type - * @return string - */ - protected function getTransactionType() - { - return \Genesis\API\Constants\Transaction\Types::INPAY; - } - - /** - * Set Flag for payout transaction - * @param bool|int|string $value - * @return $this - */ - public function setIsPayout($value) - { - $this->is_payout = filter_var($value, FILTER_VALIDATE_BOOLEAN); - - return $this; - } - - /** - * Set the required fields - * - * @return void - */ - protected function setRequiredFields() - { - $requiredFields = [ - 'transaction_id', - 'remote_ip', - 'amount', - 'currency', - 'return_success_url', - 'return_failure_url', - 'customer_email', - 'billing_country' - ]; - - $this->requiredFields = \Genesis\Utils\Common::createArrayObject($requiredFields); - - $requiredFieldValues = [ - 'billing_country' => \Genesis\Utils\Country::getList(), - 'currency' => \Genesis\Utils\Currency::getList() - ]; - - $this->requiredFieldValues = \Genesis\Utils\Common::createArrayObject($requiredFieldValues); - - $requiredFieldsConditional = [ - 'is_payout' => [ - false => [ - 'customer_bank_id', - 'order_description' - ], - true => [ - 'payout_order_id', - 'payout_bank_country', - 'payout_bank_name', - 'payout_swift', - 'payout_acc_number', - 'payout_bank_address', - 'payout_owner_name', - 'payout_owner_address' - ] - ] - ]; - - $this->requiredFieldsConditional = \Genesis\Utils\Common::createArrayObject($requiredFieldsConditional); - } - - /** - * Return additional request attributes - * @return array - */ - protected function getPaymentTransactionStructure() - { - return [ - 'return_success_url' => $this->return_success_url, - 'return_failure_url' => $this->return_failure_url, - 'amount' => $this->transformAmount($this->amount, $this->currency), - 'currency' => $this->currency, - 'is_payout' => var_export($this->is_payout, true), - 'customer_bank_id' => $this->customer_bank_id, - 'order_description' => $this->order_description, - 'payout_order_id' => $this->payout_order_id, - 'payout_bank_country' => $this->payout_bank_country, - 'payout_bank_name' => $this->payout_bank_name, - 'payout_swift' => $this->payout_swift, - 'payout_acc_number' => $this->payout_acc_number, - 'payout_bank_address' => $this->payout_bank_address, - 'payout_owner_name' => $this->payout_owner_name, - 'payout_owner_address' => $this->payout_owner_address, - 'customer_email' => $this->customer_email, - 'customer_phone' => $this->customer_phone, - 'billing_address' => $this->getBillingAddressParamsStructure(), - 'shipping_address' => $this->getShippingAddressParamsStructure() - ]; - } -} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Alternatives/PaypalExpress.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Alternatives/PaypalExpress.php deleted file mode 100644 index 0d210a9..0000000 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Alternatives/PaypalExpress.php +++ /dev/null @@ -1,68 +0,0 @@ -requiredFields = \Genesis\Utils\Common::createArrayObject($requiredFields); - } -} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Alternatives/Trustly/Withdrawal.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Alternatives/Trustly/Withdrawal.php deleted file mode 100644 index 98e99ac..0000000 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Alternatives/Trustly/Withdrawal.php +++ /dev/null @@ -1,104 +0,0 @@ -requiredFields = \Genesis\Utils\Common::createArrayObject($requiredFields); - - $requiredFieldValues = [ - 'billing_country' => [ - 'AT', 'BG', 'BE', 'HR', 'CZ', 'CY', 'DK', 'EE', 'FI', 'FR', 'DE', 'GR', 'HU', 'IT', 'IE', 'LT', 'LV', - 'LU', 'MT', 'NO', 'NL', 'PT', 'PL', 'RO', 'SK', 'SI', 'SE', 'ES', 'GB' - ], - 'currency' => \Genesis\Utils\Currency::getList() - ]; - - $this->requiredFieldValues = \Genesis\Utils\Common::createArrayObject($requiredFieldValues); - } - - protected function getPaymentTransactionStructure() - { - return array_merge( - $this->getPaymentAttributesStructure(), - [ - 'return_success_url' => $this->return_success_url, - 'return_failure_url' => $this->return_failure_url, - 'amount' => $this->transformAmount($this->amount, $this->currency), - 'currency' => $this->currency, - 'customer_email' => $this->customer_email, - 'customer_phone' => $this->customer_phone, - 'birth_date' => $this->getBirthDate(), - 'billing_address' => $this->getBillingAddressParamsStructure(), - 'shipping_address' => $this->getShippingAddressParamsStructure() - ] - ); - } -} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Cards/Credit.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Cards/Credit.php deleted file mode 100644 index 0f973da..0000000 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Cards/Credit.php +++ /dev/null @@ -1,66 +0,0 @@ -getSourceOfFundsStructure(), - [ - 'customer_identification' => $this->getCustomerIdentificationDataStructure() - ] - ); - } -} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/CashPayments/Banamex.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/CashPayments/Banamex.php deleted file mode 100644 index 25cdfff..0000000 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/CashPayments/Banamex.php +++ /dev/null @@ -1,57 +0,0 @@ -requiredFields = CommonUtils::createArrayObject($requiredFields); - - $requiredFieldValues = [ - 'billing_country' => $this->getAllowedBillingCountries() - ]; - - $this->requiredFieldValues = CommonUtils::createArrayObject($requiredFieldValues); - - $this->requiredFieldValuesConditional = CommonUtils::createArrayObject( - $this->getDocumentIdConditions() - ); - } - - /** - * Return additional request attributes - * - * @return array - */ - protected function getPaymentTransactionStructure() - { - return [ - 'return_success_url' => $this->return_success_url, - 'return_failure_url' => $this->return_failure_url, - 'amount' => $this->transformAmount($this->amount, $this->currency), - 'currency' => $this->currency, - 'customer_email' => $this->customer_email, - 'document_id' => $this->document_id, - 'billing_address' => $this->getBillingAddressParamsStructure(), - 'shipping_address' => $this->getShippingAddressParamsStructure(), - ]; - } -} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/CashPayments/SantanderCash.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/CashPayments/SantanderCash.php deleted file mode 100644 index a6054b9..0000000 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/CashPayments/SantanderCash.php +++ /dev/null @@ -1,50 +0,0 @@ -requiredFields = \Genesis\Utils\Common::createArrayObject($requiredFields); - - $requiredFieldValues = [ - 'currency' => [ 'CNY' ] - ]; - - $this->requiredFieldValues = \Genesis\Utils\Common::createArrayObject($requiredFieldValues); - } - - /** - * Return additional request attributes - * @return array - */ - protected function getPaymentTransactionStructure() - { - return [ - 'usage' => $this->usage, - 'remote_ip' => $this->remote_ip, - 'return_success_url' => $this->return_success_url, - 'return_failure_url' => $this->return_failure_url, - 'amount' => $this->transformAmount($this->amount, $this->currency), - 'currency' => $this->currency, - 'customer_email' => $this->customer_email, - 'customer_phone' => $this->customer_phone, - 'birth_date' => $this->getBirthDate(), - 'billing_address' => $this->getBillingAddressParamsStructure(), - 'shipping_address' => $this->getShippingAddressParamsStructure() - ]; - } -} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/OnlineBankingPayments/AstropayDirect.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/OnlineBankingPayments/AstropayDirect.php deleted file mode 100644 index 55297c8..0000000 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/OnlineBankingPayments/AstropayDirect.php +++ /dev/null @@ -1,99 +0,0 @@ -requiredFields = \Genesis\Utils\Common::createArrayObject($requiredFields); - - $requiredFieldValues = [ - 'billing_country' => ['AR', 'BR', 'CL', 'CN', 'CO', 'MX', 'PE', 'UY'] - ]; - - $this->requiredFieldValues = \Genesis\Utils\Common::createArrayObject($requiredFieldValues); - } - - /** - * Return additional request attributes - * @return array - */ - protected function getPaymentTransactionStructure() - { - return [ - 'usage' => $this->usage, - 'remote_ip' => $this->remote_ip, - 'return_success_url' => $this->return_success_url, - 'return_failure_url' => $this->return_failure_url, - 'amount' => $this->transformAmount($this->amount, $this->currency), - 'currency' => $this->currency, - 'consumer_reference' => $this->consumer_reference, - 'billing_address' => $this->getBillingAddressParamsStructure(), - 'shipping_address' => $this->getShippingAddressParamsStructure() - ]; - } -} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/OnlineBankingPayments/Citadel/Payin.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/OnlineBankingPayments/Citadel/Payin.php deleted file mode 100644 index 986f70a..0000000 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/OnlineBankingPayments/Citadel/Payin.php +++ /dev/null @@ -1,117 +0,0 @@ -requiredFields = \Genesis\Utils\Common::createArrayObject($requiredFields); - - $requiredFieldValues = [ - 'billing_country' => [ - 'AT', 'AU', 'BE', 'CA', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', - 'GR', 'HU', 'IE', 'IT', 'JP', 'LT', 'LV', 'PL', 'PT', 'SE', 'SK' - ], - 'currency' => \Genesis\Utils\Currency::getList() - ]; - - $this->requiredFieldValues = \Genesis\Utils\Common::createArrayObject($requiredFieldValues); - } - - /** - * Return additional request attributes - * @return array - */ - protected function getPaymentTransactionStructure() - { - return [ - 'amount' => $this->transformAmount($this->amount, $this->currency), - 'currency' => $this->currency, - 'return_success_url' => $this->return_success_url, - 'return_failure_url' => $this->return_failure_url, - 'notification_url' => $this->notification_url, - 'customer_email' => $this->customer_email, - 'customer_phone' => $this->customer_phone, - 'merchant_customer_id' => $this->merchant_customer_id, - 'billing_address' => $this->getBillingAddressParamsStructure(), - 'shipping_address' => $this->getShippingAddressParamsStructure() - ]; - } -} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/OnlineBankingPayments/Citadel/Payout.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/OnlineBankingPayments/Citadel/Payout.php deleted file mode 100644 index b297204..0000000 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/OnlineBankingPayments/Citadel/Payout.php +++ /dev/null @@ -1,256 +0,0 @@ -requiredFields = \Genesis\Utils\Common::createArrayObject($requiredFields); - - $requiredFieldValues = [ - 'billing_country' => [ - 'АЕ', 'AT', 'AU', 'BE', 'BG', 'CA', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', - 'FI', 'FR', 'GB', 'GF', 'GP', 'GR', 'HU', 'IE', 'IT', 'LT', 'LU', 'LV', - 'MC', 'MQ', 'MT', 'MX', 'NL', 'PL', 'PT', 'RE', 'SE', 'SI', 'SK' - ], - 'currency' => \Genesis\Utils\Currency::getList() - ]; - - $this->requiredFieldValues = \Genesis\Utils\Common::createArrayObject($requiredFieldValues); - - $this->setRequiredFieldsConditional(); - } - - /** - * Set the required fields conditional - * - * @return void - */ - protected function setRequiredFieldsConditional() - { - $requiredParamsIbanSwiftCode = ['iban', 'swift_code']; - - $requiredFieldsConditional = [ - 'billing_country' => [ - 'AE' => $requiredParamsIbanSwiftCode, - 'AT' => $requiredParamsIbanSwiftCode, - 'AU' => ['account_number', 'branch_code'], - 'BE' => $requiredParamsIbanSwiftCode, - 'BG' => ['iban'], - 'CA' => ['account_number', 'branch_code', 'bank_code', 'bank_name'], - 'CY' => $requiredParamsIbanSwiftCode, - 'CZ' => ['iban'], - 'DE' => $requiredParamsIbanSwiftCode, - 'DK' => ['account_number', 'bank_code'], - 'EE' => $requiredParamsIbanSwiftCode, - 'ES' => $requiredParamsIbanSwiftCode, - 'FI' => $requiredParamsIbanSwiftCode, - 'FR' => $requiredParamsIbanSwiftCode, - 'GB' => ['account_number', 'bank_code'], - 'GF' => $requiredParamsIbanSwiftCode, - 'GP' => $requiredParamsIbanSwiftCode, - 'GR' => $requiredParamsIbanSwiftCode, - 'HU' => ['account_number'], - 'IE' => $requiredParamsIbanSwiftCode, - 'IT' => $requiredParamsIbanSwiftCode, - 'LT' => $requiredParamsIbanSwiftCode, - 'LU' => $requiredParamsIbanSwiftCode, - 'LV' => $requiredParamsIbanSwiftCode, - 'MC' => $requiredParamsIbanSwiftCode, - 'MQ' => $requiredParamsIbanSwiftCode, - 'MT' => $requiredParamsIbanSwiftCode, - 'MX' => ['iban', 'bank_name'], - 'NL' => $requiredParamsIbanSwiftCode, - 'PL' => ['iban'], - 'PT' => $requiredParamsIbanSwiftCode, - 'RE' => $requiredParamsIbanSwiftCode, - 'SE' => ['iban'], - 'SI' => $requiredParamsIbanSwiftCode, - 'SK' => $requiredParamsIbanSwiftCode - ] - ]; - - $this->requiredFieldsConditional = \Genesis\Utils\Common::createArrayObject($requiredFieldsConditional); - } - - /** - * Return additional request attributes - * @return array - */ - protected function getPaymentTransactionStructure() - { - return [ - 'amount' => $this->transformAmount($this->amount, $this->currency), - 'currency' => $this->currency, - 'customer_email' => $this->customer_email, - 'customer_phone' => $this->customer_phone, - 'holder_name' => $this->holder_name, - 'iban' => $this->iban, - 'swift_code' => $this->swift_code, - 'account_number' => $this->account_number, - 'bank_name' => $this->bank_name, - 'bank_city' => $this->bank_city, - 'bank_code' => $this->bank_code, - 'branch_code' => $this->branch_code, - 'branch_check_digit' => $this->branch_check_digit, - 'billing_address' => $this->getBillingAddressParamsStructure(), - 'shipping_address' => $this->getShippingAddressParamsStructure() - ]; - } -} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/OnlineBankingPayments/Entercash.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/OnlineBankingPayments/Entercash.php deleted file mode 100644 index d36e59c..0000000 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/OnlineBankingPayments/Entercash.php +++ /dev/null @@ -1,203 +0,0 @@ -iban) === false) { - $this->setIban($this->iban); - } - break; - case 'SE': - case 'FI': - $this->setIban(''); - $this->setBic(''); - break; - } - - return parent::setBillingCountry($value); - } - - /** - * @param $value - * - * @return Entercash - * @throws ErrorParameter - */ - public function setBic($value) - { - switch ($this->billing_country) { - case 'SE': - case 'FI': - $this->throwBankAttributesNotSupported(); - break; - } - - return parent::setBic($value); - } - - /** - * @param $value - * - * @return Entercash - * @throws ErrorParameter - */ - public function setIban($value) - { - switch ($this->billing_country) { - case 'DE': - $this->validateIban(self::PATTERN_DE_IBAN, $value); - break; - case 'AT': - $this->validateIban(self::PATTERN_AT_IBAN, $value); - break; - case 'SE': - case 'FI': - $this->throwBankAttributesNotSupported(); - break; - } - - return parent::setIban($value); - } - - /** - * @param string $pattern Regex pattern for IBAN validation - * @param string $value - * - * @throws ErrorParameter - */ - protected function validateIban($pattern, $value) - { - if (!preg_match($pattern, $value)) { - throw new ErrorParameter('Invalid IBAN. Please check the documenatition for more information.'); - } - } - - /** - * @throws ErrorParameter - */ - protected function throwBankAttributesNotSupported() - { - throw new ErrorParameter('The selected country doesn\'t support IBAN and Bic params.' . - 'Please check the documenatition for more information.'); - } - - /** - * Returns the Request transaction type - * @return string - */ - protected function getTransactionType() - { - return \Genesis\API\Constants\Transaction\Types::ENTERCASH; - } - - /** - * Set the required fields - * - * @return void - */ - protected function setRequiredFields() - { - $requiredFields = [ - 'transaction_id', - 'usage', - 'remote_ip', - 'return_success_url', - 'return_failure_url', - 'amount', - 'currency', - 'consumer_reference', - 'customer_email', - 'billing_country' - ]; - - $this->requiredFields = \Genesis\Utils\Common::createArrayObject($requiredFields); - - $requiredFieldValues = [ - 'billing_country' => [ 'AT', 'DE', 'FI', 'SE' ], - 'currency' => [ 'EUR', 'SEK' ] - ]; - - $this->requiredFieldValues = \Genesis\Utils\Common::createArrayObject($requiredFieldValues); - } - - /** - * Return additional request attributes - * @return array - */ - protected function getPaymentTransactionStructure() - { - return [ - 'usage' => $this->usage, - 'remote_ip' => $this->remote_ip, - 'return_success_url' => $this->return_success_url, - 'return_failure_url' => $this->return_failure_url, - 'amount' => $this->transformAmount($this->amount, $this->currency), - 'currency' => $this->currency, - 'consumer_reference' => $this->consumer_reference, - 'customer_email' => $this->customer_email, - 'iban' => $this->iban, - 'bic' => $this->bic, - 'billing_address' => $this->getBillingAddressParamsStructure(), - 'shipping_address' => $this->getShippingAddressParamsStructure() - ]; - } -} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/OnlineBankingPayments/GiroPay.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/OnlineBankingPayments/GiroPay.php deleted file mode 100644 index a1c4839..0000000 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/OnlineBankingPayments/GiroPay.php +++ /dev/null @@ -1,124 +0,0 @@ -requiredFields = CommonUtils::createArrayObject($requiredFields); - - $requiredFieldValues = [ - 'billing_country' => ['DE'], - 'currency' => ['EUR'] - ]; - - $this->requiredFieldValues = CommonUtils::createArrayObject($requiredFieldValues); - } - - /** - * Add iban conditional validation if it is present - * - * @return void - * - * @throws InvalidArgument - * @throws \Genesis\Exceptions\ErrorParameter - * @throws \Genesis\Exceptions\InvalidClassMethod - */ - protected function checkRequirements() - { - $this->requiredFieldValuesConditional = CommonUtils::createArrayObject( - array_merge( - (array)$this->requiredFieldValuesConditional, - $this->getIbanConditions() - ) - ); - - parent::checkRequirements(); - } - - /** - * Return additional request attributes - * @return array - */ - protected function getPaymentTransactionStructure() - { - return [ - 'usage' => $this->usage, - 'remote_ip' => $this->remote_ip, - 'return_success_url' => $this->return_success_url, - 'return_failure_url' => $this->return_failure_url, - 'return_pending_url' => $this->getReturnPendingUrl(), - 'amount' => $this->transformAmount($this->amount, $this->currency), - 'currency' => $this->currency, - 'customer_email' => $this->customer_email, - 'bic' => $this->bic, - 'iban' => $this->iban, - 'billing_address' => $this->getBillingAddressParamsStructure(), - 'shipping_address' => $this->getShippingAddressParamsStructure() - ]; - } -} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/OnlineBankingPayments/InstantTransfer.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/OnlineBankingPayments/InstantTransfer.php deleted file mode 100644 index 189de94..0000000 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/OnlineBankingPayments/InstantTransfer.php +++ /dev/null @@ -1,152 +0,0 @@ -iban) === false) { - $this->setIban($this->iban); - } - break; - } - - return parent::setBillingCountry($value); - } - - /** - * @param $value - * - * @return InstantTransfer - * @throws ErrorParameter - */ - public function setIban($value) - { - if ($this->billing_country === 'DE') { - $this->validateIban(self::PATTERN_DE_IBAN, $value); - } - - return parent::setIban($value); - } - - /** - * @param string $pattern Regex pattern for IBAN validation - * @param string $value - * - * @throws ErrorParameter - */ - protected function validateIban($pattern, $value) - { - if (!preg_match($pattern, $value)) { - throw new ErrorParameter('Invalid IBAN. Please check the documenatition for more information.'); - } - } - - /** - * Returns the Request transaction type - * @return string - */ - protected function getTransactionType() - { - return \Genesis\API\Constants\Transaction\Types::INSTANT_TRANSFER; - } - - /** - * Set the required fields - * - * @return void - */ - protected function setRequiredFields() - { - $requiredFields = [ - 'transaction_id', - 'return_success_url', - 'return_failure_url', - 'amount', - 'currency', - 'billing_country' - ]; - - $this->requiredFields = \Genesis\Utils\Common::createArrayObject($requiredFields); - - $requiredFieldValues = [ - 'billing_country' => [ 'DE' ] - ]; - - $this->requiredFieldValues = \Genesis\Utils\Common::createArrayObject($requiredFieldValues); - } - - /** - * Return additional request attributes - * @return array - */ - protected function getPaymentTransactionStructure() - { - return [ - 'usage' => $this->usage, - 'remote_ip' => $this->remote_ip, - 'return_success_url' => $this->return_success_url, - 'return_failure_url' => $this->return_failure_url, - 'amount' => $this->transformAmount($this->amount, $this->currency), - 'currency' => $this->currency, - 'customer_email' => $this->customer_email, - 'iban' => $this->iban, - 'bic' => $this->bic, - 'billing_address' => $this->getBillingAddressParamsStructure(), - 'shipping_address' => $this->getShippingAddressParamsStructure() - ]; - } -} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/OnlineBankingPayments/TrustPay.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/OnlineBankingPayments/TrustPay.php deleted file mode 100644 index 012ed16..0000000 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/OnlineBankingPayments/TrustPay.php +++ /dev/null @@ -1,98 +0,0 @@ -requiredFields = \Genesis\Utils\Common::createArrayObject($requiredFields); - - $requiredFieldValues = [ - 'billing_country' => ['CZ', 'SK'], - 'currency' => ['EUR', 'CZK'] - ]; - - $this->requiredFieldValues = \Genesis\Utils\Common::createArrayObject($requiredFieldValues); - } - - /** - * Return additional request attributes - * @return array - */ - protected function getPaymentTransactionStructure() - { - return [ - 'usage' => $this->usage, - 'remote_ip' => $this->remote_ip, - 'return_success_url' => $this->return_success_url, - 'return_failure_url' => $this->return_failure_url, - 'return_pending_url' => $this->getReturnPendingUrl(), - 'amount' => $this->transformAmount($this->amount, $this->currency), - 'currency' => $this->currency, - 'customer_email' => $this->customer_email, - 'billing_address' => $this->getBillingAddressParamsStructure(), - 'shipping_address' => $this->getShippingAddressParamsStructure() - ]; - } -} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/PayByVouchers/Sale.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/PayByVouchers/Sale.php deleted file mode 100644 index b73f790..0000000 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/PayByVouchers/Sale.php +++ /dev/null @@ -1,127 +0,0 @@ -requiredFields = \Genesis\Utils\Common::createArrayObject($requiredFields); - - $requiredFieldValues = array_merge( - [ - 'card_type' => CardTypes::getCardTypes(), - 'redeem_type' => RedeemTypes::getRedeemTypes(), - 'currency' => Currency::getList() - ], - $this->getCCFieldValueFormatValidators() - ); - - $this->requiredFieldValues = \Genesis\Utils\Common::createArrayObject($requiredFieldValues); - } - - /** - * Return additional request attributes - * @return array - */ - protected function getPaymentTransactionStructure() - { - return [ - 'card_type' => $this->card_type, - 'redeem_type' => $this->redeem_type, - 'amount' => $this->transformAmount($this->amount, $this->currency), - 'currency' => $this->currency, - 'card_holder' => $this->card_holder, - 'card_number' => $this->card_number, - 'cvv' => $this->cvv, - 'expiration_month' => $this->expiration_month, - 'expiration_year' => $this->expiration_year, - 'customer_email' => $this->customer_email, - 'customer_phone' => $this->customer_phone, - 'birth_date' => $this->getBirthDate(), - 'billing_address' => $this->getBillingAddressParamsStructure(), - 'shipping_address' => $this->getShippingAddressParamsStructure(), - 'dynamic_descriptor_params' => $this->getDynamicDescriptorParamsStructure() - ]; - } - - /** - * Skip Credit Card validation if Client-Side Encryption is set - * - * @return void - */ - protected function checkRequirements() - { - $this->removeCreditCardValidations(); - - parent::checkRequirements(); - } -} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/PayByVouchers/oBeP.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/PayByVouchers/oBeP.php deleted file mode 100644 index 874f1b0..0000000 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/PayByVouchers/oBeP.php +++ /dev/null @@ -1,216 +0,0 @@ -initXmlConfiguration(); - - $this->initApiGatewayConfiguration(); - } - - /** - * Set the required fields - * - * @return void - */ - protected function setRequiredFields() - { - $requiredFields = [ - 'transaction_id', - 'card_type', - 'redeem_type', - 'amount', - 'currency', - 'product_name', - 'product_category', - 'customer_name', - 'customer_email', - 'customer_phone', - 'customer_id_number', - 'customer_bank_id', - 'bank_account_number' - ]; - - $this->requiredFields = \Genesis\Utils\Common::createArrayObject($requiredFields); - } - - /** - * Create the request's Tree structure - * - * @return void - */ - protected function populateStructure() - { - $treeStructure = [ - 'payment_transaction' => [ - 'transaction_type' => \Genesis\API\Constants\Transaction\Types::PAYBYVOUCHER_YEEPAY, - 'transaction_id' => $this->transaction_id, - 'card_type' => $this->card_type, - 'redeem_type' => $this->redeem_type, - 'remote_ip' => $this->remote_ip, - 'amount' => $this->transform( - 'amount', - [ - $this->amount, - $this->currency - ] - ), - 'currency' => $this->currency, - 'product_name' => $this->product_name, - 'product_category' => $this->product_category, - 'customer_name' => $this->customer_name, - 'customer_email' => $this->customer_email, - 'customer_phone' => $this->customer_phone, - 'customer_id_number' => $this->customer_id_number, - 'customer_bank_id' => $this->customer_bank_id, - 'bank_account_number' => $this->bank_account_number - ] - ]; - - $this->treeStructure = \Genesis\Utils\Common::createArrayObject($treeStructure); - } -} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Vouchers/AstropayCard.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Vouchers/AstropayCard.php deleted file mode 100644 index 06336b1..0000000 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Vouchers/AstropayCard.php +++ /dev/null @@ -1,102 +0,0 @@ -requiredFields = \Genesis\Utils\Common::createArrayObject($requiredFields); - - $requiredFieldValues = [ - 'billing_country' => ['AR', 'BR', 'CL', 'CO', 'CR', 'MX', 'PE', 'UY', 'VE'] - ]; - - $this->requiredFieldValues = \Genesis\Utils\Common::createArrayObject($requiredFieldValues); - } - - /** - * Return additional request attributes - * @return array - */ - protected function getPaymentTransactionStructure() - { - return [ - 'usage' => $this->usage, - 'remote_ip' => $this->remote_ip, - 'return_success_url' => $this->return_success_url, - 'return_failure_url' => $this->return_failure_url, - 'return_pending_url' => $this->getReturnPendingUrl(), - 'amount' => $this->transformAmount($this->amount, $this->currency), - 'currency' => $this->currency, - 'consumer_reference' => $this->consumer_reference, - 'billing_address' => $this->getBillingAddressParamsStructure(), - 'shipping_address' => $this->getShippingAddressParamsStructure() - ]; - } -} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Wallets/Qiwi.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Wallets/Qiwi.php deleted file mode 100644 index b30a545..0000000 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Wallets/Qiwi.php +++ /dev/null @@ -1,122 +0,0 @@ -requiredFields = \Genesis\Utils\Common::createArrayObject($requiredFields); - - $requiredFieldValues = [ - 'billing_country' => ['RU', 'KZ', 'UA'], - 'customer_phone' => new RegexValidator(RegexValidator::PATTERN_QIWI_PHONE_NUMBER) - ]; - - $this->requiredFieldValues = \Genesis\Utils\Common::createArrayObject($requiredFieldValues); - - $requiredFieldValuesConditional = [ - 'billing_country' => [ - 'RU' => [ - [ - 'currency' => ['EUR', 'RUB'] - ] - ], - 'KZ' => [ - [ - 'currency' => ['EUR', 'KZT'] - ] - ], - 'UA' => [ - [ - 'currency' => ['USD'] - ] - ] - ] - ]; - - $this->requiredFieldValuesConditional = - \Genesis\Utils\Common::createArrayObject($requiredFieldValuesConditional); - } - - /** - * Return additional request attributes - * @return array - */ - protected function getPaymentTransactionStructure() - { - return [ - 'usage' => $this->usage, - 'remote_ip' => $this->remote_ip, - 'return_success_url' => $this->return_success_url, - 'return_failure_url' => $this->return_failure_url, - 'amount' => $this->transformAmount($this->amount, $this->currency), - 'currency' => $this->currency, - 'customer_email' => $this->customer_email, - 'customer_phone' => $this->customer_phone, - 'billing_address' => $this->getBillingAddressParamsStructure(), - 'shipping_address' => $this->getShippingAddressParamsStructure() - ]; - } -} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Wallets/Zimpler.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Wallets/Zimpler.php deleted file mode 100644 index a320594..0000000 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Wallets/Zimpler.php +++ /dev/null @@ -1,99 +0,0 @@ -requiredFields = \Genesis\Utils\Common::createArrayObject($requiredFields); - - $requiredFieldValues = [ - 'billing_country' => [ 'FI', 'SE' ], - 'currency' => [ 'EUR', 'SEK' ] - ]; - - $this->requiredFieldValues = \Genesis\Utils\Common::createArrayObject($requiredFieldValues); - } - - /** - * Return additional request attributes - * @return array - */ - protected function getPaymentTransactionStructure() - { - return [ - 'usage' => $this->usage, - 'remote_ip' => $this->remote_ip, - 'return_success_url' => $this->return_success_url, - 'return_failure_url' => $this->return_failure_url, - 'amount' => $this->transformAmount($this->amount, $this->currency), - 'currency' => $this->currency, - 'customer_phone' => $this->customer_phone, - 'customer_email' => $this->customer_email, - 'billing_address' => $this->getBillingAddressParamsStructure(), - 'shipping_address' => $this->getShippingAddressParamsStructure() - ]; - } -} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/NonFinancial/AVS.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/NonFinancial/AVS.php deleted file mode 100644 index bf0f2a6..0000000 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/NonFinancial/AVS.php +++ /dev/null @@ -1,125 +0,0 @@ -initXmlConfiguration(); - - $this->initApiGatewayConfiguration(); - } - - /** - * Set the required fields - * - * @return void - */ - protected function setRequiredFields() - { - $requiredFields = [ - 'transaction_id', - 'card_holder', - 'card_number', - 'expiration_month', - 'expiration_year', - 'billing_address1', - 'billing_zip_code', - 'billing_city' - ]; - - $this->requiredFields = \Genesis\Utils\Common::createArrayObject($requiredFields); - - $requiredFieldValues = $this->getCCFieldValueFormatValidators(); - - $this->requiredFieldValues = \Genesis\Utils\Common::createArrayObject($requiredFieldValues); - } - - /** - * Create the request's Tree structure - * - * @return void - */ - protected function populateStructure() - { - $treeStructure = [ - 'payment_transaction' => [ - 'transaction_type' => Services::AVS, - 'transaction_id' => $this->transaction_id, - 'usage' => $this->usage, - 'moto' => $this->moto, - 'remote_ip' => $this->remote_ip, - 'card_holder' => $this->card_holder, - 'card_number' => $this->card_number, - 'cvv' => $this->cvv, - 'expiration_month' => $this->expiration_month, - 'expiration_year' => $this->expiration_year, - 'customer_email' => $this->customer_email, - 'customer_phone' => $this->customer_phone, - 'birth_date' => $this->getBirthDate(), - 'billing_address' => $this->getBillingAddressParamsStructure(), - 'shipping_address' => $this->getShippingAddressParamsStructure(), - 'risk_params' => $this->getRiskParamsStructure() - ] - ]; - - $this->treeStructure = \Genesis\Utils\Common::createArrayObject($treeStructure); - } - - /** - * Skip Credit Card validation if Client-Side Encryption is set - * - * @return void - */ - protected function checkRequirements() - { - $this->removeCreditCardValidations(); - - parent::checkRequirements(); - } -} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/NonFinancial/AccountVerification.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/NonFinancial/AccountVerification.php deleted file mode 100644 index dff6dbe..0000000 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/NonFinancial/AccountVerification.php +++ /dev/null @@ -1,144 +0,0 @@ -initXmlConfiguration(); - - $this->initApiGatewayConfiguration(); - } - - /** - * Set the required fields - * - * @return void - */ - protected function setRequiredFields() - { - $requiredFields = [ - 'transaction_id', - 'card_holder', - 'card_number', - 'expiration_month', - 'expiration_year', - 'billing_address1', - 'billing_zip_code', - 'billing_city' - ]; - - $this->requiredFields = CommonUtils::createArrayObject($requiredFields); - - $requiredFieldValues = $this->getCCFieldValueFormatValidators(); - - $this->requiredFieldValues = CommonUtils::createArrayObject($requiredFieldValues); - } - - /** - * Create the request's Tree structure - * - * @return void - */ - protected function populateStructure() - { - $treeStructure = [ - 'payment_transaction' => array_merge( - [ - 'transaction_type' => \Genesis\API\Constants\Transaction\Types::ACCOUNT_VERIFICATION, - 'transaction_id' => $this->transaction_id, - 'usage' => $this->usage, - 'moto' => $this->moto, - 'remote_ip' => $this->remote_ip, - 'card_holder' => $this->card_holder, - 'card_number' => $this->card_number, - 'cvv' => $this->cvv, - 'expiration_month' => $this->expiration_month, - 'expiration_year' => $this->expiration_year, - 'customer_email' => $this->customer_email, - 'customer_phone' => $this->customer_phone, - 'document_id' => $this->document_id, - 'birth_date' => $this->getBirthDate(), - 'billing_address' => $this->getBillingAddressParamsStructure(), - 'shipping_address' => $this->getShippingAddressParamsStructure(), - 'risk_params' => $this->getRiskParamsStructure() - ], - $this->getCredentialOnFileAttributesStructure() - ) - ]; - - $this->treeStructure = CommonUtils::createArrayObject($treeStructure); - } - - /** - * Skip Credit Card validation if Client-Side Encryption is set - * Add document_id conditional validation if it is present - * - * @return void - * @throws InvalidArgument - * @throws \Genesis\Exceptions\ErrorParameter - * @throws \Genesis\Exceptions\InvalidClassMethod - */ - protected function checkRequirements() - { - $this->removeCreditCardValidations(); - - if ($this->document_id) { - $this->requiredFieldValuesConditional = CommonUtils::createArrayObject( - $this->getDocumentIdConditions() - ); - } - - parent::checkRequirements(); - } -} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Financial/VoucherAttributes.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Financial/VoucherAttributes.php deleted file mode 100644 index f736c24..0000000 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Financial/VoucherAttributes.php +++ /dev/null @@ -1,50 +0,0 @@ - \Genesis\API\Constants\Payment\Methods::getMethods() + 'payment_method' => \Genesis\Api\Constants\Payment\Methods::getMethods() ]; } /** * @return array */ - public static function forPayByVoucherSale() - { - return [ - 'card_type' => - \Genesis\API\Constants\Transaction\Parameters\PayByVouchers\CardTypes::getCardTypes(), - 'redeem_type' => - \Genesis\API\Constants\Transaction\Parameters\PayByVouchers\RedeemTypes::getRedeemTypes() - ]; - } - - /** - * @return array - * @deprecated PayByVoucherYeepay payment method is deprecated and will be removed - */ - public static function forPayByVoucherYeepay() - { - return array_merge( - static::forPayByVoucherSale(), - [ - 'product_name' => null, - 'product_category' => null - ] - ); - } - - /** - * @return array - */ - public static function forCitadelPayIn() + public static function forInstaDebitPayIn() { return [ - 'merchant_customer_id' => null + 'customer_account_id' => null ]; } /** * @return array */ - public static function forInstaDebitPayIn() + public static function forIDebitPayIn() { return [ 'customer_account_id' => null @@ -94,20 +67,22 @@ public static function forInstaDebitPayIn() /** * @return array */ - public static function forIDebitPayIn() + public static function forKlarnaAuthorize() { return [ - 'customer_account_id' => null + 'billing_country' => Authorize::getAllowedCountries() ]; } /** + * Required custom attribute for Paysafecard + * * @return array */ - public static function forKlarnaAuthorize() + public static function forPaysafecard() { return [ - 'billing_country' => Authorize::getAllowedCountries() + 'customer_id' => null ]; } } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Constants/Transaction/Names.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Constants/Transaction/Names.php similarity index 80% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Constants/Transaction/Names.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Constants/Transaction/Names.php index ad94541..0aaa3cd 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Constants/Transaction/Names.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Constants/Transaction/Names.php @@ -1,4 +1,5 @@ 'AVS', - Types::ABNIDEAL => 'ABN iDeal', - Types::ACCOUNT_VERIFICATION => 'Account Verification', Types::AFRICAN_MOBILE_PAYOUT => 'African Mobile Payout', Types::AFRICAN_MOBILE_SALE => 'African Mobile Sale', - Types::ALIPAY => 'Alipay', Types::APPLE_PAY => 'Apple pay', Types::ARGENCARD => 'Argencard', - Types::ASTROPAY_CARD => 'Astropay Card', - Types::ASTROPAY_DIRECT => 'Astropay Direct', Types::AURA => 'Aura', Types::AUTHORIZE => 'Authorize', Types::AUTHORIZE_3D => 'Authorize (3D-Secure)', Types::BALOTO => 'Baloto', - Types::BANAMEX => 'Banamex', Types::BANCOMER => 'Bancomer', Types::BANCONTACT => 'Bancontact', Types::BANCO_DE_OCCIDENTE => 'Banco de Occidente', @@ -68,33 +62,23 @@ class Names Types::BRADESCO => 'Bradesco', Types::CABAL => 'Cabal', Types::CAPTURE => 'Capture', - Types::CARULLA => 'Carulla', Types::CASHU => 'CashU', Types::CENCOSUD => 'Cencosud', - Types::CITADEL_PAYIN => 'Citadel PayIn', - Types::CITADEL_PAYOUT => 'Citadel PayOut', Types::CREDIT => 'Credit', Types::DAVIVIENDA => 'Davivienda', - Types::EARTHPORT => 'Earthport', Types::EFECTY => 'Efecty', Types::ELO => 'Elo', - Types::EMPRESE_DE_ENERGIA => 'Emprese de Energia', - Types::ENTERCASH => 'Entercash', Types::EPS => 'EPS', Types::EZEECARD_PAYOUT => 'eZeeCard Payout', Types::EZEEWALLET => 'eZeeWallet', Types::FASHIONCHEQUE => 'Fashioncheque', - Types::GIROPAY => 'GiroPay', Types::GOOGLE_PAY => 'Google Pay', - Types::HIPERCARD => 'Hipercard', Types::IDEAL => 'iDeal', Types::IDEBIT_PAYIN => 'iDebit PayIn', Types::IDEBIT_PAYOUT => 'iDebit PayOut', Types::INCREMENTAL_AUTHORIZE => 'Incremental Authorize', Types::INIT_RECURRING_SALE => 'Init Recurring Sale', Types::INIT_RECURRING_SALE_3D => 'Init Recurring Sale (3D-Secure)', - Types::INPAY => 'INPay', - Types::INSTANT_TRANSFER => 'InstantTransfer', Types::INSTA_DEBIT_PAYIN => 'InstaDebit PayIn', Types::INSTA_DEBIT_PAYOUT => 'InstaDebit PayOut', Types::INTERSOLVE => 'Intersolve', @@ -114,11 +98,8 @@ class Names Types::P24 => 'P24', Types::PAGO_FACIL => 'Pago Facil', Types::PARTIAL_REVERSAL => 'Partial Reversal', - Types::PAYBYVOUCHER_SALE => 'PayByVoucher Sale', - Types::PAYBYVOUCHER_YEEPAY => 'PayByVoucher Yeepay', Types::PAYOUT => 'Payout', Types::PAY_PAL => 'PayPal', - Types::PAYPAL_EXPRESS => 'PayPal Express Checkout', Types::PAYSAFECARD => 'Paysafecard', Types::PAYU => 'PayU', Types::PIX => 'PIX', @@ -126,7 +107,6 @@ class Names Types::POST_FINANCE => 'PostFinance', Types::PPRO => 'PPRO', Types::PSE => 'Pagos Seguros en Linea', - Types::QIWI => 'QIWI', Types::RAPI_PAGO => 'RapiPago', Types::RECURRING_SALE => 'Recurring Sale', Types::RUSSIAN_MOBILE_SALE => 'Russian Mobile Sale', @@ -137,26 +117,21 @@ class Names Types::SALE => 'Sale', Types::SALE_3D => 'Sale (3D-Secure)', Types::SANTANDER => 'Santander', - Types::SANTANDER_CASH => 'Santander Cash', Types::SCT_PAYOUT => 'SCT Payout', Types::SDD_INIT_RECURRING_SALE => 'SDD Init Recurring Sale', Types::SDD_RECURRING_SALE => 'SDD Recurring Sale', Types::SDD_REFUND => 'SDD Refund', Types::SDD_SALE => 'SDD Sale', Types::SOFORT => 'Sofort', - Types::SURTIMAX => 'Surtimax', Types::TARJETA_SHOPPING => 'Tarjeta Shopping', Types::TCS => 'The Container Store', Types::TRANSFER_TO_PAYOUT => 'TransferTo Payout', Types::TRUSTLY_SALE => 'Trustly Sale', - Types::TRUSTLY_WITHDRAWAL => 'Trustly Withdrawal', - Types::TRUSTPAY => 'TrustPay', Types::UPI => 'Upi', Types::VOID => 'Void', Types::WEBMONEY => 'WebMoney', Types::WEBPAY => 'Webpay', - Types::WECHAT => 'Wechat', - Types::ZIMPLER => 'Zimpler' + Types::WECHAT => 'Wechat' ]; /** diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Constants/Transaction/Parameters/AfricanMobileOperators.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Constants/Transaction/Parameters/AfricanMobileOperators.php similarity index 92% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Constants/Transaction/Parameters/AfricanMobileOperators.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Constants/Transaction/Parameters/AfricanMobileOperators.php index 42f1d0d..854001d 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Constants/Transaction/Parameters/AfricanMobileOperators.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Constants/Transaction/Parameters/AfricanMobileOperators.php @@ -1,4 +1,5 @@ [ + Banks::PID + ], 'BRL' => [ Banks::CA ], @@ -60,7 +64,7 @@ class BankCodeParameters Banks::SP ], 'EUR' => [ - Banks::PF, Banks::BCT + Banks::PF, Banks::BCT, Banks::TRL ], 'THB' => [ Banks::BBL_IB_U, Banks::KBANK_PAYPLUS, Banks::BAY_IB_U, Banks::KTB_IB_U, @@ -119,6 +123,9 @@ class BankCodeParameters ], 'PLN' => [ Banks::BLK + ], + 'GBP' => [ + Banks::TRL ] ]; diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Constants/Transaction/Parameters/OnlineBanking/Ideal/AllowedBanks.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Constants/Transaction/Parameters/OnlineBanking/Ideal/AllowedBanks.php similarity index 93% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Constants/Transaction/Parameters/OnlineBanking/Ideal/AllowedBanks.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Constants/Transaction/Parameters/OnlineBanking/Ideal/AllowedBanks.php index 59aaec4..fd8d356 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Constants/Transaction/Parameters/OnlineBanking/Ideal/AllowedBanks.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Constants/Transaction/Parameters/OnlineBanking/Ideal/AllowedBanks.php @@ -1,4 +1,5 @@ status)) { - return $this->compare($target); - } + if ( + $action === 'is' && + in_array( + $target, + array_merge(CommonUtils::getClassConstants(__CLASS__), $this->getAllStateAliases()) + ) + ) { + return $this->compare($target); } throw new InvalidMethod( sprintf( - 'You\'re trying to call a non-existent method %s of class %s!', + 'You\'re trying to call a non-existent method %s of class %s! The transaction states are: %s', $method, - __CLASS__ + __CLASS__, + implode(', ', CommonUtils::getClassConstants(__CLASS__)) ) ); } @@ -316,7 +329,7 @@ public function compare($subject) */ public function isValid() { - $statusList = \Genesis\Utils\Common::getClassConstants(__CLASS__); + $statusList = CommonUtils::getClassConstants(__CLASS__); return in_array(strtolower($this->status), $statusList); } @@ -330,9 +343,7 @@ public function isValid() private function getStateAliasConstantName($state) { $subject = $state; - $alias = [ - self::NEW_STATUS => 'new_status' - ]; + $alias = $this->getAllStateAliases(); if (array_key_exists($state, $alias)) { $subject = $alias[$state]; @@ -340,4 +351,15 @@ private function getStateAliasConstantName($state) return $subject; } + + /** + * The list of state aliases + * @return string[] + */ + private function getAllStateAliases() + { + return [ + self::NEW_STATUS => 'new_status' + ]; + } } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Constants/Transaction/Types.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Constants/Transaction/Types.php similarity index 76% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Constants/Transaction/Types.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Constants/Transaction/Types.php index 31ae668..4b05c3a 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Constants/Transaction/Types.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Constants/Transaction/Types.php @@ -1,4 +1,5 @@ 'Cancel', self::CAPTURE => 'Capture', self::REFUND => 'Refund', - self::ABNIDEAL => 'Alternatives\ABNiDEAL', - self::EARTHPORT => 'Alternatives\Earthport', - self::INPAY => 'Alternatives\INPay', self::KLARNA_AUTHORIZE => 'Alternatives\Klarna\Authorize', self::KLARNA_CAPTURE => 'Alternatives\Klarna\Capture', self::KLARNA_REFUND => 'Alternatives\Klarna\Refund', self::P24 => 'Alternatives\P24', - self::PAYPAL_EXPRESS => 'Alternatives\PaypalExpress', - self::POLI => 'Alternatives\POLi', - self::PPRO => 'Alternatives\PPRO', + self::POLI => 'Alternatives\Poli', + self::PPRO => 'Alternatives\Ppro', self::SOFORT => 'Alternatives\Sofort', self::TRANSFER_TO_PAYOUT => 'Alternatives\TransferTo\Payout', self::TRUSTLY_SALE => 'Alternatives\Trustly\Sale', - self::TRUSTLY_WITHDRAWAL => 'Alternatives\Trustly\Withdrawal', self::INIT_RECURRING_SALE => 'Cards\Recurring\InitRecurringSale', self::INIT_RECURRING_SALE_3D => 'Cards\Recurring\InitRecurringSale3D', self::RECURRING_SALE => 'Cards\Recurring\RecurringSale', @@ -810,7 +614,6 @@ public static function getFinancialRequestClassForTrxType($type) self::CREDIT => 'Cards\Credit', self::ELO => 'Cards\Elo', self::EZEECARD_PAYOUT => 'Cards\EzeeCardPayout', - self::HIPERCARD => 'Cards\Hipercard', self::NARANJA => 'Cards\Naranja', self::NATIVA => 'Cards\Nativa', self::PAYOUT => 'Cards\Payout', @@ -818,18 +621,13 @@ public static function getFinancialRequestClassForTrxType($type) self::SALE_3D => 'Cards\Sale3D', self::TARJETA_SHOPPING => 'Cards\TarjetaShopping', self::BALOTO => 'CashPayments\Baloto', - self::BANAMEX => 'CashPayments\Banamex', self::BANCO_DE_OCCIDENTE => 'CashPayments\BancoDeOccidente', self::BOLETO => 'CashPayments\Boleto', - self::CARULLA => 'CashPayments\Carulla', self::EFECTY => 'CashPayments\Efecty', - self::EMPRESE_DE_ENERGIA => 'CashPayments\EmpreseDeEnergia', self::OXXO => 'CashPayments\Oxxo', self::PAGO_FACIL => 'CashPayments\PagoFacil', self::PIX => 'CashPayments\Pix', self::REDPAGOS => 'CashPayments\Redpagos', - self::SANTANDER_CASH => 'CashPayments\SantanderCash', - self::SURTIMAX => 'CashPayments\Surtimax', self::BITPAY_PAYOUT => 'Crypto\BitPay\Payout', self::BITPAY_REFUND => 'Crypto\BitPay\Refund', self::BITPAY_SALE => 'Crypto\BitPay\Sale', @@ -840,23 +638,16 @@ public static function getFinancialRequestClassForTrxType($type) self::GOOGLE_PAY => 'Mobile\GooglePay', self::RUSSIAN_MOBILE_SALE => 'Mobile\RussianMobileSale', self::AFRICAN_MOBILE_SALE => 'Mobile\AfricanMobileSale.php', - self::ALIPAY => 'OnlineBankingPayments\Alipay', - self::ASTROPAY_DIRECT => 'OnlineBankingPayments\AstropayDirect', self::BANCO_DO_BRASIL => 'OnlineBankingPayments\BancoDoBrasil', self::BANCOMER => 'OnlineBankingPayments\Bancomer', self::BRADESCO => 'OnlineBankingPayments\Bradesco', - self::CITADEL_PAYIN => 'OnlineBankingPayments\Citadel\Payin', - self::CITADEL_PAYOUT => 'OnlineBankingPayments\Citadel\Payout', self::DAVIVIENDA => 'OnlineBankingPayments\Davivienda', - self::ENTERCASH => 'OnlineBankingPayments\Entercash', self::EPS => 'OnlineBankingPayments\Eps', - self::GIROPAY => 'OnlineBankingPayments\Giropay', self::IDEAL => 'OnlineBankingPayments\Ideal', - self::IDEBIT_PAYIN => 'OnlineBankingPayments\iDebit\Payin', - self::IDEBIT_PAYOUT => 'OnlineBankingPayments\iDebit\Payout', + self::IDEBIT_PAYIN => 'OnlineBankingPayments\Idebit\Payin', + self::IDEBIT_PAYOUT => 'OnlineBankingPayments\Idebit\Payout', self::INSTA_DEBIT_PAYIN => 'OnlineBankingPayments\InstaDebit\PayIn', self::INSTA_DEBIT_PAYOUT => 'OnlineBankingPayments\InstaDebit\Payout', - self::INSTANT_TRANSFER => 'OnlineBankingPayments\InstantTransfer', self::ITAU => 'OnlineBankingPayments\Itau', self::MULTIBANCO => 'OnlineBankingPayments\Multibanco', self::MY_BANK => 'OnlineBankingPayments\MyBank', @@ -868,31 +659,25 @@ public static function getFinancialRequestClassForTrxType($type) self::RAPI_PAGO => 'OnlineBankingPayments\RapiPago', self::SAFETYPAY => 'OnlineBankingPayments\SafetyPay', self::SANTANDER => 'OnlineBankingPayments\Santander', - self::TRUSTPAY => 'OnlineBankingPayments\TrustPay', self::UPI => 'OnlineBankingPayments\Upi', self::WEBPAY => 'OnlineBankingPayments\Webpay', self::WECHAT => 'OnlineBankingPayments\WeChat', - self::PAYBYVOUCHER_YEEPAY => 'PayByVouchers\oBeP', - self::PAYBYVOUCHER_SALE => 'PayByVouchers\Sale', self::AFRICAN_MOBILE_PAYOUT => 'Payout\AfricanMobilePayout', self::RUSSIAN_MOBILE_PAYOUT => 'Payout\RussianMobilePayout', self::INCREMENTAL_AUTHORIZE => 'Preauthorization\IncrementalAuthorize', self::PARTIAL_REVERSAL => 'Preauthorization\PartialReversal', - self::SCT_PAYOUT => 'SCT\Payout', - self::SDD_INIT_RECURRING_SALE => 'SDD\Recurring\InitRecurringSale', - self::SDD_RECURRING_SALE => 'SDD\Recurring\RecurringSale', - self::SDD_REFUND => 'SDD\Refund', - self::SDD_SALE => 'SDD\Sale', - self::ASTROPAY_CARD => 'Vouchers\AstropayCard', + self::SCT_PAYOUT => 'Sct\Payout', + self::SDD_INIT_RECURRING_SALE => 'Sdd\Recurring\InitRecurringSale', + self::SDD_RECURRING_SALE => 'Sdd\Recurring\RecurringSale', + self::SDD_REFUND => 'Sdd\Refund', + self::SDD_SALE => 'Sdd\Sale', self::CASHU => 'Vouchers\CashU', self::NEOSURF => 'Vouchers\Neosurf', self::PAYSAFECARD => 'Vouchers\Paysafecard', - self::EZEEWALLET => 'Wallets\eZeeWallet', + self::EZEEWALLET => 'Wallets\EzeeWallet', self::NETELLER => 'Wallets\Neteller', - self::QIWI => 'Wallets\Qiwi', self::PAY_PAL => 'Wallets\PayPal', - self::WEBMONEY => 'Wallets\WebMoney', - self::ZIMPLER => 'Wallets\Zimpler', + self::WEBMONEY => 'Wallets\WebMoney' ]; return isset($map[$type]) ? 'Financial\\' . $map[$type] : false; @@ -943,7 +728,6 @@ public static function getWPFTransactionTypes() self::EPS, self::EZEEWALLET, self::FASHIONCHEQUE, - self::GIROPAY, self::GOOGLE_PAY, self::IDEAL, self::IDEBIT_PAYIN, @@ -1031,23 +815,6 @@ public static function isValidSplitPaymentTrxType($type) return in_array(strtolower($type), self::getSplitPaymentsTrxTypes()); } - /** - * Check whether this is a valid (known) transaction type - * - * @param string $type - * - * @return bool - */ - public static function isPayByVoucher($type) - { - $transactionTypesList = [ - self::PAYBYVOUCHER_YEEPAY, - self::PAYBYVOUCHER_SALE - ]; - - return in_array(strtolower($type), $transactionTypesList); - } - /** * @param string $type * @@ -1092,7 +859,6 @@ public static function canRefund($type) self::EFECTY, self::EPS, self::FASHIONCHEQUE, - self::GIROPAY, self::IDEAL, self::IDEBIT_PAYIN, self::INIT_RECURRING_SALE, @@ -1128,7 +894,6 @@ public static function canRefund($type) self::UPI, self::WEBPAY, self::WECHAT, - self::ZIMPLER, self::GOOGLE_PAY, ]; @@ -1287,31 +1052,7 @@ public static function getFinancialDeprecatedRequests() { $data = array(); - $transactions = [ - self::ABNIDEAL, - self::ALIPAY, - self::ASTROPAY_CARD, - self::ASTROPAY_DIRECT, - self::BANAMEX, - self::CARULLA, - self::CITADEL_PAYIN, - self::CITADEL_PAYOUT, - self::EARTHPORT, - self::EMPRESE_DE_ENERGIA, - self::ENTERCASH, - self::HIPERCARD, - self::INSTANT_TRANSFER, - self::INPAY, - self::PAYBYVOUCHER_SALE, - self::PAYBYVOUCHER_YEEPAY, - self::PAYPAL_EXPRESS, - self::QIWI, - self::SANTANDER_CASH, - self::SURTIMAX, - self::TRUSTLY_WITHDRAWAL, - self::TRUSTPAY, - self::ZIMPLER - ]; + $transactions = []; foreach ($transactions as $transaction) { $data[$transaction] = self::getFinancialRequestClassForTrxType($transaction); diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Constants/i18n.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Constants/i18n.php similarity index 94% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Constants/i18n.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Constants/i18n.php index 6a0c5b7..18a17a8 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Constants/i18n.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Constants/i18n.php @@ -1,4 +1,5 @@ isAuthentic()) { - throw new \Genesis\Exceptions\InvalidArgument('Invalid Genesis Notification!'); + throw new InvalidArgument('Invalid Genesis Notification!'); } } @@ -111,7 +123,12 @@ public function parseNotification($notification = [], $authenticate = true) * Reconcile with the Payment Gateway to get the latest * status on the transaction * - * @throws \Genesis\Exceptions\InvalidResponse + * @throws ErrorParameter + * @throws InvalidClassMethod + * @throws InvalidResponse + * @throws InvalidArgument + * @throws InvalidMethod + * @throws DeprecatedMethod */ public function initReconciliation() { @@ -120,18 +137,14 @@ public function initReconciliation() if ($this->isAPINotification()) { $type = 'NonFinancial\Reconcile\Transaction'; } elseif ($this->isWPFNotification()) { - $type = 'WPF\Reconcile'; + $type = 'Wpf\Reconcile'; } - $request = new \Genesis\Genesis($type); + $request = new Genesis($type); - try { - $request->request()->setUniqueId($this->unique_id); + $request->request()->setUniqueId($this->unique_id); - $request->execute(); - } catch (\Genesis\Exceptions\ErrorAPI $api) { - // This is reconciliation, don't throw on ErrorAPI - } + $request->execute(); return $this->reconciliationObj = $request->response()->getResponseObject(); } @@ -140,12 +153,12 @@ public function initReconciliation() * Verify the signature on the parsed Notification * * @return bool - * @throws \Genesis\Exceptions\InvalidArgument + * @throws InvalidArgument */ public function isAuthentic() { if (!isset($this->unique_id) || !isset($this->notificationObj->signature)) { - throw new \Genesis\Exceptions\InvalidArgument( + throw new InvalidArgument( 'Missing field(s), required for validation!' ); } @@ -237,7 +250,7 @@ public function generateResponse() ] ]; - $builder = new \Genesis\Builder('xml'); + $builder = new Builder('xml'); $builder->parseStructure($structure); return $builder->getDocument(); @@ -256,7 +269,7 @@ public function getResponseIdField() case $this->isKYCNotification(): return 'reference_id'; default: - throw new \LogicException('Unknown notification type'); + throw new LogicException('Unknown notification type'); } } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request.php similarity index 82% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request.php index ab2032d..265a8e6 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request.php @@ -1,4 +1,5 @@ processRequestParameters(); if ($this->treeStructure instanceof \ArrayObject) { - $this->builderContext = new \Genesis\Builder($this->builderInterface); + $this->builderContext = new Builder($this->builderInterface); $this->builderContext->parseStructure($this->treeStructure->getArrayCopy()); return $this->builderContext->getDocument(); @@ -295,10 +300,11 @@ protected function initXmlConfiguration() { $this->config = CommonUtils::createArrayObject( [ - 'protocol' => Request::PROTOCOL_HTTPS, - 'port' => Request::PORT_HTTPS, - 'type' => Request::METHOD_POST, - 'format' => Builder::XML + 'protocol' => Request::PROTOCOL_HTTPS, + 'port' => Request::PORT_HTTPS, + 'type' => Request::METHOD_POST, + 'format' => Builder::XML, + 'authorization' => Request::AUTH_TYPE_BASIC ] ); } @@ -312,10 +318,11 @@ protected function initJsonConfiguration() { $this->config = CommonUtils::createArrayObject( [ - 'protocol' => Request::PROTOCOL_HTTPS, - 'port' => Request::PORT_HTTPS, - 'type' => Request::METHOD_POST, - 'format' => Builder::JSON + 'protocol' => Request::PROTOCOL_HTTPS, + 'port' => Request::PORT_HTTPS, + 'type' => Request::METHOD_POST, + 'format' => Builder::JSON, + 'authorization' => Request::AUTH_TYPE_BASIC ] ); } @@ -329,10 +336,30 @@ protected function initFormConfiguration() { $this->config = CommonUtils::createArrayObject( [ - 'protocol' => Request::PROTOCOL_HTTPS, - 'port' => Request::PORT_HTTPS, - 'type' => Request::METHOD_POST, - 'format' => Builder::FORM + 'protocol' => Request::PROTOCOL_HTTPS, + 'port' => Request::PORT_HTTPS, + 'type' => Request::METHOD_POST, + 'format' => Builder::FORM, + 'authorization' => Request::AUTH_TYPE_BASIC + ] + ); + } + + /** + * Configures a Secure Post Request with GraphQL body + * + * @return void + */ + protected function initGraphqlConfiguration() + { + $this->config = CommonUtils::createArrayObject( + [ + 'protocol' => Request::PROTOCOL_HTTPS, + 'port' => Request::PORT_HTTPS, + 'type' => Request::METHOD_POST, + 'format' => Builder::JSON, + 'authorization' => Request::AUTH_TYPE_TOKEN, + 'bearer_token' => null ] ); } @@ -349,8 +376,7 @@ protected function initApiGatewayConfiguration( $requestPath = 'process', $includeToken = true, $subdomain = 'gateway' - ) - { + ) { $this->setApiConfig( 'url', $this->buildRequestURL( diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Base/BaseVersionedRequest.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Base/BaseVersionedRequest.php similarity index 92% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Base/BaseVersionedRequest.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Base/BaseVersionedRequest.php index a76a7a4..965005e 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Base/BaseVersionedRequest.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Base/BaseVersionedRequest.php @@ -1,4 +1,5 @@ requestType) { case Builder::XML: @@ -147,7 +149,7 @@ protected function initConfiguration($subdomain = 'gateway') break; } - $this->initApiGatewayConfiguration($this->version . '/' . $this->requestPath, false, $subdomain); + $this->initApiGatewayConfiguration("$this->version/$this->requestPath", false); } /** diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Base/Financial.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Base/Financial.php similarity index 63% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Base/Financial.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Base/Financial.php index 95e91f0..366cd88 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Base/Financial.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Base/Financial.php @@ -1,4 +1,5 @@ use_smart_router = CommonUtils::toBoolean($value); + + return $this; + } + /** * Returns the Request transaction type * @return string @@ -54,27 +78,37 @@ abstract protected function getPaymentTransactionStructure(); /** * Initialize per-request configuration + * + * @throws EnvironmentNotSet */ protected function initConfiguration() { $this->initXmlConfiguration(); $this->initApiGatewayConfiguration(); + + if (Config::getForceSmartRouting()) { + $this->initializeSmartRouter(); + } } /** - * Perform field validation + * Process Request Params * * @return void - * @throws \Genesis\Exceptions\InvalidArgument + * + * @throws EnvironmentNotSet * @throws \Genesis\Exceptions\ErrorParameter + * @throws \Genesis\Exceptions\InvalidArgument * @throws \Genesis\Exceptions\InvalidClassMethod */ - protected function checkRequirements() + protected function processRequestParameters() { - parent::checkRequirements(); + if ($this->getUseSmartRouter()) { + $this->initializeSmartRouter(); + } - $this->validateConditionalValuesRequirements(); + parent::processRequestParameters(); } /** @@ -97,4 +131,15 @@ protected function populateStructure() $this->treeStructure = \Genesis\Utils\Common::createArrayObject($treeStructure); } + + /** + * Initialize Smart Router endpoint + * + * @return void + * @throws \Genesis\Exceptions\EnvironmentNotSet + */ + protected function initializeSmartRouter() + { + $this->initApiGatewayConfiguration('transactions', false, 'api_service'); + } } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Base/Financial/Alternative.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Base/Financial/Alternative.php similarity index 85% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Base/Financial/Alternative.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Base/Financial/Alternative.php index 2699e6d..cc1f2e8 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Base/Financial/Alternative.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Base/Financial/Alternative.php @@ -1,4 +1,5 @@ items) || $this->items->count() === 0) { - throw new \Genesis\Exceptions\ErrorParameter('Empty (null) required parameter: items'); + throw new ErrorParameter('Empty (null) required parameter: items'); } } } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Base/Financial/Cards/CreditCard.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Base/Financial/Cards/CreditCard.php similarity index 88% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Base/Financial/Cards/CreditCard.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Base/Financial/Cards/CreditCard.php index fddd94a..c45f1f6 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Base/Financial/Cards/CreditCard.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Base/Financial/Cards/CreditCard.php @@ -1,4 +1,5 @@ request_path = $requestPath; + $this->request_name = $requestName; + + parent::__construct($this->request_path, Builder::JSON, $allowedVersions); + } + + /** + * Add single value to response field list + * + * @param $value + * @return $this + * @throws InvalidArgument + */ + public function addResponseField($value) + { + if (!in_array($value, $this->getResponseFieldsAllowedValues())) { + throw new InvalidArgument( + 'Invalid value given for response fields. Allowed values: ' . + implode(', ', $this->getResponseFieldsAllowedValues()) + ); + } + + array_push($this->response_fields, $value); + + $this->response_fields = array_unique($this->response_fields); + + return $this; + } + + /** + * Set the fields in the response + * + * @param array $value + * @return $this + * @throws InvalidArgument + */ + public function setResponseFields($value) + { + if ( + CommonUtils::isValidArray($value) + && empty(array_diff($value, $this->getResponseFieldsAllowedValues())) + ) { + $this->response_fields = $value; + $this->response_fields = array_unique($this->response_fields); + + return $this; + } + + throw new InvalidArgument( + 'Invalid value/s given for the response fields array. Allowed values: ' . + implode(', ', $this->getResponseFieldsAllowedValues()) + ); + } + + /** + * Return a formatted string with response fields + * + * @return string + */ + public function getResponseFields() + { + return sprintf('%s', implode(' ', $this->response_fields)); + } + + /** + * Initialize the appropriate token for the request + * + * @return string + */ + abstract protected function initGraphqlToken(); + + /** + * Filters that are used in the request + * + * @return string + */ + abstract protected function getRequestFilters(); + + /** + * List of allowed response fields + * + * @return string[] + */ + abstract protected function getResponseFieldsAllowedValues(); + + /** + * Set the per-request configuration + * + * @return void + * @throws EnvironmentNotSet + */ + protected function initConfiguration() + { + $this->initGraphqlConfiguration(); + + $this->initGraphqlToken(); + + $this->initializeServiceApiRouter($this->request_path); + } + + /** + * Initialize GraphQL endpoint + * + * @param $request_path + * @return void + * @throws \Genesis\Exceptions\EnvironmentNotSet + */ + protected function initializeServiceApiRouter($request_path) + { + $this->initApiGatewayConfiguration( + $request_path . '/' . $this->getVersion() . '/graphql', + false, + 'api_service' + ); + } + + /** + * Additional query data + * + * @return string + */ + protected function getAdditionalData() + { + return ''; + } + + /** + * Create the request's structure + * + * @return void + */ + protected function populateStructure() + { + $treeStructure = [ + 'query' => sprintf( + 'query { + %s( + %s + ) { + items { %s } + %s + } + }', + $this->request_name, + $this->getRequestFilters(), + $this->getRequestStructure(), + $this->getAdditionalData() + ) + ]; + + $this->treeStructure = \Genesis\Utils\Common::createArrayObject($treeStructure); + } + + /** + * Helper to form parts of GraphQL query + * + * @param array $elements - GraphQL group of elements in the format + * ['name1' => 'value1', + * 'name2' => 'value2'] + * @param string $element_name - the name of the group of elements in GraphQL + * element_name: { name1: value1, name2: value2 } + * @param string $glue - a separator, example: ', ' in name1: value1, name2: value2 + * @param string $format - the used format, example: '%s: %s' for name1: value1 + * @return string + */ + protected function generateGraphQLCode($elements, $element_name, $glue = ', ', $format = '%s: %s') + { + $elements = array_filter($elements); + + if (empty($elements)) { + return ''; + } + + return sprintf( + $element_name . ': { %s }', + implode( + $glue, + array_map( + function ($key, $value) use ($format) { + return sprintf($format, $key, $value); + }, + array_keys($elements), + $elements + ) + ) + ); + } +} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Base/NonFinancial/Alternatives/Klarna/BaseRequest.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Base/NonFinancial/Alternatives/Klarna/BaseRequest.php new file mode 100644 index 0000000..880b7f2 --- /dev/null +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Base/NonFinancial/Alternatives/Klarna/BaseRequest.php @@ -0,0 +1,104 @@ +setRequestRequiredFields() + ); + + $this->requiredFields = Common::createArrayObject($requiredFields); + } + + protected function initBaseConfiguration($requestPath) + { + $this->initXmlConfiguration(); + + $this->initApiGatewayConfiguration($requestPath, false); + } + + protected function populateStructure() + { + $treeStructure = [ + $this->getParentNode() => array_merge( + [ + 'transaction_id' => $this->transaction_id + ], + $this->getRequestStructure() + ) + ]; + + $this->treeStructure = Common::createArrayObject($treeStructure); + } + + /** + * Get additional attributes + * + * @return array + */ + abstract protected function getRequestStructure(); + + /** + * Set additional required fields + * + * @return array + */ + abstract protected function setRequestRequiredFields(); + + /** + * Get the root node of the Populated XML structure + * + * @return string + */ + abstract protected function getParentNode(); +} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Base/NonFinancial/Alternatives/Trustly/BaseRequest.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Base/NonFinancial/Alternatives/Trustly/BaseRequest.php new file mode 100644 index 0000000..28e71eb --- /dev/null +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Base/NonFinancial/Alternatives/Trustly/BaseRequest.php @@ -0,0 +1,174 @@ +request_path = $requestPath; + + parent::__construct($this->request_path, Builder::JSON, ['v1']); + } + + /** + * @param string $value + * + * @return $this + * @throws InvalidArgument + */ + public function setEmail($value) + { + if (empty($value)) { + $this->email = null; + + return $this; + } + + if (!filter_var($value, FILTER_VALIDATE_EMAIL)) { + throw new InvalidArgument('Invalid email given'); + } + + $this->email = $value; + + return $this; + } + + /** + * Generate the proper date format + * + * @return string|null + */ + public function getBirthDate() + { + return (empty($this->birth_date)) ? null : + $this->birth_date->format(DateTimeFormat::YYYY_MM_DD_ISO_8601); + } + + /** + * Set the per-request configuration + * + * @return void + * @throws EnvironmentNotSet + */ + protected function initConfiguration() + { + parent::initConfiguration(); + $this->initApiGatewayConfiguration("{$this->getVersion()}/trustly/$this->request_path", true); + } + + /** + * Create the request's Tree structure + * + * @return void + */ + protected function populateStructure() + { + $this->treeStructure = CommonUtils::createArrayObject( + $this->getRequestStructure() + ); + } +} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Base/NonFinancial/Consumers/BaseRequest.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Base/NonFinancial/Consumers/BaseRequest.php similarity index 90% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Base/NonFinancial/Consumers/BaseRequest.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Base/NonFinancial/Consumers/BaseRequest.php index e69dac5..d099964 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Base/NonFinancial/Consumers/BaseRequest.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Base/NonFinancial/Consumers/BaseRequest.php @@ -1,4 +1,5 @@ page = (int) $value; - - return $this; - } - - /** - * Number of entities on page, default to 100 - * - * @param $value - * @return $this - */ - public function setPerPage($value) - { - $this->per_page = (int) $value; - - return $this; - } - /** * Get formatted Start Date as string * diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Base/NonFinancial/Fx/BaseRequest.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Base/NonFinancial/Fx/BaseRequest.php similarity index 90% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Base/NonFinancial/Fx/BaseRequest.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Base/NonFinancial/Fx/BaseRequest.php index c4e9aa9..df1002f 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Base/NonFinancial/Fx/BaseRequest.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Base/NonFinancial/Fx/BaseRequest.php @@ -1,4 +1,5 @@ request_path = $requestPath; - $this->kyc_subdomain = 'kyc'; parent::__construct($this->request_path, Builder::JSON, ['v1']); } @@ -71,12 +64,11 @@ public function __construct($requestPath) * * @return void * @throws EnvironmentNotSet - * @SuppressWarnings("unused") */ - protected function initConfiguration($subdomain = 'kyc') + protected function initConfiguration() { - parent::initConfiguration($this->kyc_subdomain); - $this->initApiGatewayConfiguration('api/' . $this->getVersion() . '/' . $this->request_path,false, $this->kyc_subdomain); // @codingStandardsIgnoreLine + parent::initConfiguration(); + $this->initApiGatewayConfiguration("api/{$this->getVersion()}/$this->request_path", false, 'kyc'); } /** @@ -86,7 +78,7 @@ protected function initConfiguration($subdomain = 'kyc') */ protected function populateStructure() { - $this->treeStructure = \Genesis\Utils\Common::createArrayObject( + $this->treeStructure = CommonUtils::createArrayObject( $this->getRequestStructure() ); } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Base/NonFinancial/TokenizationApi/BaseRequest.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Base/NonFinancial/TokenizationApi/BaseRequest.php similarity index 92% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Base/NonFinancial/TokenizationApi/BaseRequest.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Base/NonFinancial/TokenizationApi/BaseRequest.php index a55dd2f..40186c0 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Base/NonFinancial/TokenizationApi/BaseRequest.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Base/NonFinancial/TokenizationApi/BaseRequest.php @@ -1,4 +1,5 @@ setQuantityUnit($quantity_unit); } - /** - * Verify required field - * - * @param $field - * @param $value - * @throws \Genesis\Exceptions\ErrorParameter - */ - protected function verifyRequiredField($field, $value) - { - if (empty($value)) { - throw new \Genesis\Exceptions\ErrorParameter( - sprintf( - 'Empty (null) item required parameter: %s', - $field - ) - ); - } - } - - /** - * Verify non-negative filed - * - * @param $field - * @param $value - * @throws \Genesis\Exceptions\ErrorParameter - */ - protected function verifyNonNegativeField($field, $value) - { - if (!empty($value) && $value <= 0) { - throw new \Genesis\Exceptions\ErrorParameter( - sprintf( - 'Item parameter %s is set to %s, but expected to be positive number', - $field, - $value - ) - ); - } - } - - /** - * Verify negative filed - * - * @param $field - * @param $value - * @throws \Genesis\Exceptions\ErrorParameter - */ - protected function verifyNegativeField($field, $value) - { - if (!empty($value) && $value > 0) { - throw new \Genesis\Exceptions\ErrorParameter( - sprintf( - 'Item parameter %s is set to %s, but expected to be negative number', - $field, - $value - ) - ); - } - } - - /** - * Verify unit_price filed - * - * @param $value - * @throws \Genesis\Exceptions\ErrorParameter - */ - protected function verifyUnitPriceField($value) - { - $this->verifyRequiredField('unit_price', $value); - - if (in_array($this->item_type, [self::ITEM_TYPE_DISCOUNT, self::ITEM_TYPE_STORE_CREDIT])) { - $this->verifyNegativeField('unit_price', $value); - return; - } - - $this->verifyNonNegativeField('unit_price', $value); - } - /** * Set name * * @param $value * @return $this - * @throws \Genesis\Exceptions\ErrorParameter + * @throws ErrorParameter */ public function setName($value) { @@ -301,7 +227,7 @@ public function setName($value) * * @param $value * @return $this - * @throws \Genesis\Exceptions\ErrorParameter + * @throws ErrorParameter */ public function setUnitPrice($value) { @@ -316,7 +242,7 @@ public function setUnitPrice($value) * * @param $value * @return $this - * @throws \Genesis\Exceptions\ErrorParameter + * @throws ErrorParameter */ public function setQuantity($value) { @@ -332,7 +258,7 @@ public function setQuantity($value) * * @param $value * @return $this - * @throws \Genesis\Exceptions\ErrorParameter + * @throws ErrorParameter */ public function setTaxRate($value) { @@ -346,7 +272,7 @@ public function setTaxRate($value) * Set total discount amount * @param $value * @return $this - * @throws \Genesis\Exceptions\ErrorParameter + * @throws ErrorParameter */ public function setTotalDiscountAmount($value) { @@ -361,24 +287,17 @@ public function setTotalDiscountAmount($value) * * @param $value * @return $this - * @throws \Genesis\Exceptions\ErrorParameter + * @throws ErrorParameter */ public function setItemType($value) { $this->verifyRequiredField('item_type', $value); // check if it is valid type - $item_types = array( - self::ITEM_TYPE_PHYSICAL, - self::ITEM_TYPE_DISCOUNT, - self::ITEM_TYPE_SHIPPING_FEE, - self::ITEM_TYPE_DIGITAL, - self::ITEM_TYPE_GIFT_CARD, - self::ITEM_TYPE_STORE_CREDIT, - self::ITEM_TYPE_SURCHARGE - ); + $item_types = CommonUtils::getClassConstants(__CLASS__); + if (!in_array($value, $item_types)) { - throw new \Genesis\Exceptions\ErrorParameter( + throw new ErrorParameter( sprintf( 'Required item parameter item_type is set to %s, but expected to be one of (%s)', $value, @@ -399,12 +318,12 @@ public function setItemType($value) * * @param $value * @return $this - * @throws \Genesis\Exceptions\ErrorParameter + * @throws ErrorParameter */ public function setQuantityUnit($value) { if (!empty($value) && strlen($value) > 8) { - throw new \Genesis\Exceptions\ErrorParameter( + throw new ErrorParameter( sprintf( 'Item parameter quantity_unit is set to %s, but expected to be string with max length 8 characters', $value @@ -440,14 +359,18 @@ public function getTotalAmount() public function getTotalTaxAmount() { // Convert to minor units for more accurate calculations - $total_amount = CurrencyUtils::amountToExponent($this->getTotalAmount(), $this->currency); - $tax_rate = CurrencyUtils::amountToExponent($this->tax_rate, $this->currency); + $total_amount = $this->getAmountInProperUnit($this->getTotalAmount()); + $tax_rate = $this->getAmountInProperUnit($this->tax_rate); $total_tax_amount = ceil( $total_amount - ( ($total_amount * 10000) / (10000 + $tax_rate) ) ); - return CurrencyUtils::exponentToAmount($total_tax_amount, $this->currency); + if (!empty($this->currency)) { + return CurrencyUtils::exponentToAmount($total_tax_amount, $this->currency); + } + + return $total_tax_amount; } /** @@ -461,11 +384,11 @@ public function toArray() 'name' => $this->name, 'item_type' => $this->item_type, 'quantity' => $this->quantity, - 'unit_price' => CurrencyUtils::amountToExponent($this->unit_price, $this->currency), - 'tax_rate' => CurrencyUtils::amountToExponent($this->tax_rate, $this->currency), - 'total_discount_amount' => CurrencyUtils::amountToExponent($this->total_discount_amount, $this->currency), - 'total_amount' => CurrencyUtils::amountToExponent($this->getTotalAmount(), $this->currency), - 'total_tax_amount' => CurrencyUtils::amountToExponent($this->getTotalTaxAmount(), $this->currency), + 'unit_price' => $this->getAmountInProperUnit($this->unit_price), + 'tax_rate' => $this->getAmountInProperUnit($this->tax_rate), + 'total_discount_amount' => $this->getAmountInProperUnit($this->total_discount_amount), + 'total_amount' => $this->getAmountInProperUnit($this->getTotalAmount()), + 'total_tax_amount' => $this->getAmountInProperUnit($this->getTotalTaxAmount()), 'reference' => $this->reference, 'image_url' => $this->image_url, 'product_url' => $this->product_url, @@ -488,28 +411,108 @@ public function setProductIdentifiers(ProductIdentifiers $value) } /** - * Builds an array list with all product identifiers params + * Add merchant data: marketplace seller info * - * @return array + * @param $value + * @return $this */ - protected function getProductIdentifiersParamsStructure() + public function addMerchantMarketplaceSellerInfo($value) { - if ($this->product_identifiers instanceof ProductIdentifiers) { - return $this->product_identifiers->toArray(); + array_push($this->marketplace_seller_info, $value); + + return $this; + } + + /** + * Verify required field + * + * @param $field + * @param $value + * @throws ErrorParameter + */ + protected function verifyRequiredField($field, $value) + { + if (empty($value)) { + throw new ErrorParameter( + sprintf( + 'Empty (null) item required parameter: %s', + $field + ) + ); } - return []; } /** - * Add merchant data: marketplace seller info + * Verify non-negative filed * + * @param $field * @param $value - * @return $this + * @throws ErrorParameter */ - public function addMerchantMarketplaceSellerInfo($value) + protected function verifyNonNegativeField($field, $value) { - array_push($this->marketplace_seller_info, $value); - return $this; + if (!empty($value) && $value <= 0) { + throw new ErrorParameter( + sprintf( + 'Item parameter %s is set to %s, but expected to be positive number', + $field, + $value + ) + ); + } + } + + /** + * Verify negative filed + * + * @param $field + * @param $value + * @throws ErrorParameter + */ + protected function verifyNegativeField($field, $value) + { + if (!empty($value) && $value > 0) { + throw new ErrorParameter( + sprintf( + 'Item parameter %s is set to %s, but expected to be negative number', + $field, + $value + ) + ); + } + } + + /** + * Verify unit_price filed + * + * @param $value + * @throws ErrorParameter + */ + protected function verifyUnitPriceField($value) + { + $this->verifyRequiredField('unit_price', $value); + + if (in_array($this->item_type, [self::ITEM_TYPE_DISCOUNT, self::ITEM_TYPE_STORE_CREDIT])) { + $this->verifyNegativeField('unit_price', $value); + + return; + } + + $this->verifyNonNegativeField('unit_price', $value); + } + + /** + * Builds an array list with all product identifiers params + * + * @return array + */ + protected function getProductIdentifiersParamsStructure() + { + if ($this->product_identifiers instanceof ProductIdentifiers) { + return $this->product_identifiers->toArray(); + } + + return []; } /** @@ -526,4 +529,20 @@ function ($marketplace_seller_info) { $this->marketplace_seller_info ); } + + /** + * If the currency is set and the amount is in major unit convert it to minor + * + * @param mixed $value + * @return mixed + * @throws \Genesis\Exceptions\InvalidArgument + */ + private function getAmountInProperUnit($value) + { + if (!empty($this->currency)) { + return CurrencyUtils::amountToExponent($value, $this->currency); + } + + return $value; + } } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Alternatives/Klarna/Items.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Alternatives/Klarna/Items.php similarity index 81% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Alternatives/Klarna/Items.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Alternatives/Klarna/Items.php index 88f6880..2c94fc0 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Alternatives/Klarna/Items.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Alternatives/Klarna/Items.php @@ -1,4 +1,5 @@ currency = $currency; + if (!empty($currency)) { + $this->currency = $currency; + } } /** @@ -68,8 +71,10 @@ public function __construct($currency) */ public function addItem(Item $item) { - // set currency, so amounts transformations can be done - $item->setCurrency($this->currency); + if (!empty($this->currency)) { + // set currency, so amounts transformations can be done + $item->setCurrency($this->currency); + } array_push($this->items, $item); return $this; @@ -115,7 +120,9 @@ public function count() public function toArray() { return [ - 'order_tax_amount' => CurrencyUtils::amountToExponent($this->getOrderTaxAmount(), $this->currency), + 'order_tax_amount' => (!empty($this->currency)) ? + CurrencyUtils::amountToExponent($this->getOrderTaxAmount(), $this->currency) : + $this->getOrderTaxAmount(), 'items' => array_map( function ($item) { return ['item' => $item->toArray()]; diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Alternatives/Klarna/ProductIdentifiers.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Alternatives/Klarna/ProductIdentifiers.php similarity index 93% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Alternatives/Klarna/ProductIdentifiers.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Alternatives/Klarna/ProductIdentifiers.php index 7d6ca26..556fd05 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Alternatives/Klarna/ProductIdentifiers.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Alternatives/Klarna/ProductIdentifiers.php @@ -1,4 +1,5 @@ 'EUR' ] ], - PaymentMethods::GIRO_PAY => [ - [ - 'billing_country' => 'DE', - 'currency' => 'EUR' - ] - ], PaymentMethods::BCMC => [ [ 'billing_country' => 'BE', @@ -205,29 +203,6 @@ protected function setRequiredFieldValuesConditional() $this->requiredFieldValuesConditional = CommonUtils::createArrayObject($requiredFieldValuesConditional); } - /** - * Add iban conditional validation if it is present - * - * @return void - * - * @throws InvalidArgument - * @throws \Genesis\Exceptions\ErrorParameter - * @throws \Genesis\Exceptions\InvalidClassMethod - */ - protected function checkRequirements() - { - if ($this->payment_type === PaymentMethods::GIRO_PAY) { - $this->requiredFieldValuesConditional = CommonUtils::createArrayObject( - array_merge( - (array)$this->requiredFieldValuesConditional, - $this->getIbanConditions() - ) - ); - } - - parent::checkRequirements(); - } - /** * Return additional request attributes * @return array diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Alternatives/Sofort.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Alternatives/Sofort.php similarity index 88% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Alternatives/Sofort.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Alternatives/Sofort.php index 26360ee..238c0e2 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Alternatives/Sofort.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Alternatives/Sofort.php @@ -1,4 +1,5 @@ requiredTokenizationFieldsConditional(), $this->requiredCCFieldsConditional(), $this->requiredManagedRecurringFieldsConditional(), - $this->requiredRecurringManagedTypeFieldConditional(), - $this->requiredRecurringSubsequentTypeFieldConditional() + $this->requiredRecurringManagedTypeFieldConditional() ); $this->requiredFieldsConditional = CommonUtils::createArrayObject($requiredFieldsConditional); @@ -113,6 +131,12 @@ protected function setRequiredFields() */ protected function checkRequirements() { + if ($this->recurring_type == Types::SUBSEQUENT) { + $this->checkRequirementsSubsequent(); + + return; + } + $requiredFieldValuesConditional = $this->requiredRecurringAllTypesFieldValuesConditional(); $this->requiredFieldValuesConditional = CommonUtils::createArrayObject( @@ -148,7 +172,8 @@ protected function getTransactionAttributes() 'managed_recurring' => $this->getManagedRecurringAttributesStructure(), 'recurring_category' => $this->recurring_category, 'reference_id' => $this->reference_id, - 'funding' => $this->getFundingAttributesStructure() + 'funding' => $this->getFundingAttributesStructure(), + 'account_owner' => $this->getAccountOwnerAttributesStructure() ], $this->getScaAttributesStructure(), $this->getUcofAttributesStructure() diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Cards/Authorize3D.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Cards/Authorize3D.php similarity index 74% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Cards/Authorize3D.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Cards/Authorize3D.php index 7b41837..9efc4e7 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Cards/Authorize3D.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Cards/Authorize3D.php @@ -1,4 +1,5 @@ $this->getRecurringType(), 'managed_recurring' => $this->getManagedRecurringAttributesStructure(), 'recurring_category' => $this->recurring_category, - 'funding' => $this->getFundingAttributesStructure() + 'funding' => $this->getFundingAttributesStructure(), + 'account_owner' => $this->getAccountOwnerAttributesStructure() ], $this->getScaAttributesStructure(), $this->get3DSTransactionAttributes() diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Cards/Bancontact.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Cards/Bancontact.php similarity index 84% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Cards/Bancontact.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Cards/Bancontact.php index dc66aa9..5184667 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Cards/Bancontact.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Cards/Bancontact.php @@ -1,4 +1,5 @@ requiredFields = \Genesis\Utils\Common::createArrayObject($requiredFields); + } + + /** + * Apply transformation: Convert to Minor currency unit + * When there is no currency the amount will not be modified + * + * @param string $amount + * @param string $currency + * + * @return string + */ + protected function transformAmount($amount = '', $currency = '') + { + if (empty($currency)) { + return $amount; + } + + return parent::transformAmount($amount, $currency); + } + + /** + * Returns the Request transaction type + * @return string + */ + protected function getTransactionType() + { + return \Genesis\Api\Constants\Transaction\Types::CREDIT; + } + + /** + * Return additional request attributes + * + * @return array + */ + protected function getPaymentTransactionStructure() + { + return array_merge( + $this->getSourceOfFundsStructure(), + [ + 'reference_id' => $this->reference_id, + 'amount' => $this->transformAmount($this->amount, $this->currency), + 'customer_identification' => $this->getCustomerIdentificationDataStructure(), + 'account_owner' => $this->getAccountOwnerAttributesStructure(), + 'purpose_of_payment' => $this->purpose_of_payment + ] + ); + } +} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Cards/Elo.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Cards/Elo.php similarity index 84% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Cards/Elo.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Cards/Elo.php index 951c088..ef8dd0a 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Cards/Elo.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Cards/Elo.php @@ -1,4 +1,5 @@ $this->getDynamicDescriptorParamsStructure(), 'money_transfer' => $this->getMoneyTransferPayoutStructure(), 'customer_identification' => $this->getCustomerIdentificationDataStructure(), + 'account_owner' => $this->getAccountOwnerAttributesStructure(), + 'purpose_of_payment' => $this->purpose_of_payment ], $this->getSourceOfFundsStructure() ); diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Cards/Recurring/InitRecurringSale.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Cards/Recurring/InitRecurringSale.php similarity index 72% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Cards/Recurring/InitRecurringSale.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Cards/Recurring/InitRecurringSale.php index ddd5713..107f06b 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Cards/Recurring/InitRecurringSale.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Cards/Recurring/InitRecurringSale.php @@ -1,4 +1,5 @@ $this->getBusinessAttributesStructure(), 'managed_recurring' => $this->getManagedRecurringAttributesStructure(), 'recurring_category' => $this->recurring_category, - 'funding' => $this->getFundingAttributesStructure() + 'funding' => $this->getFundingAttributesStructure(), + 'account_owner' => $this->getAccountOwnerAttributesStructure() ]; } } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Cards/Recurring/InitRecurringSale3D.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Cards/Recurring/InitRecurringSale3D.php similarity index 76% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Cards/Recurring/InitRecurringSale3D.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Cards/Recurring/InitRecurringSale3D.php index 282c845..1eecc77 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Cards/Recurring/InitRecurringSale3D.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Cards/Recurring/InitRecurringSale3D.php @@ -1,4 +1,5 @@ $this->getBusinessAttributesStructure(), 'managed_recurring' => $this->getManagedRecurringAttributesStructure(), 'recurring_category' => $this->recurring_category, - 'funding' => $this->getFundingAttributesStructure() + 'funding' => $this->getFundingAttributesStructure(), + 'account_owner' => $this->getAccountOwnerAttributesStructure() ], $this->getScaAttributesStructure(), $this->get3DSTransactionAttributes() diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Cards/Recurring/RecurringSale.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Cards/Recurring/RecurringSale.php similarity index 80% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Cards/Recurring/RecurringSale.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Cards/Recurring/RecurringSale.php index adf0fb1..32658f0 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Cards/Recurring/RecurringSale.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Cards/Recurring/RecurringSale.php @@ -1,4 +1,5 @@ requiredTokenizationFieldsConditional(), $this->requiredCCFieldsConditional(), - $this->requiredRecurringSubsequentTypeFieldConditional(), $this->requiredManagedRecurringFieldsConditional(), $this->requiredRecurringManagedTypeFieldConditional() ); @@ -113,6 +130,12 @@ protected function setRequiredFields() */ protected function checkRequirements() { + if ($this->recurring_type == Types::SUBSEQUENT) { + $this->checkRequirementsSubsequent(); + + return; + } + $requiredFieldValuesConditional = $this->requiredRecurringAllTypesFieldValuesConditional(); $this->requiredFieldValuesConditional = CommonUtils::createArrayObject( @@ -147,7 +170,8 @@ protected function getTransactionAttributes() 'recurring_type' => $this->getRecurringType(), 'managed_recurring' => $this->getManagedRecurringAttributesStructure(), 'recurring_category' => $this->recurring_category, - 'funding' => $this->getFundingAttributesStructure() + 'funding' => $this->getFundingAttributesStructure(), + 'account_owner' => $this->getAccountOwnerAttributesStructure() ], $this->getScaAttributesStructure(), $this->getUcofAttributesStructure() diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Cards/Sale3D.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Cards/Sale3D.php similarity index 74% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Cards/Sale3D.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Cards/Sale3D.php index b676c3a..6ee20d8 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Cards/Sale3D.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Cards/Sale3D.php @@ -1,4 +1,5 @@ $this->getRecurringType(), 'managed_recurring' => $this->getManagedRecurringAttributesStructure(), 'recurring_category' => $this->recurring_category, - 'funding' => $this->getFundingAttributesStructure() + 'funding' => $this->getFundingAttributesStructure(), + 'account_owner' => $this->getAccountOwnerAttributesStructure() ], $this->getScaAttributesStructure(), $this->get3DSTransactionAttributes() diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Cards/TarjetaShopping.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Cards/TarjetaShopping.php similarity index 84% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Cards/TarjetaShopping.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Cards/TarjetaShopping.php index dac2205..66bc442 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Cards/TarjetaShopping.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Cards/TarjetaShopping.php @@ -1,4 +1,5 @@ getTransactionUniqueId(), $this->getApiConfig('url')); + return str_replace(':unique_id', (string)$this->getTransactionUniqueId(), $this->getApiConfig('url')); } /** @@ -343,7 +343,8 @@ private function configureEndpointUrl($endpointUrl) */ public static function buildFromResponseObject(\stdClass $responseObject) { - if (!isset($responseObject->threeds_method_continue_url) + if ( + !isset($responseObject->threeds_method_continue_url) || !isset($responseObject->unique_id) || !isset($responseObject->amount) || !isset($responseObject->currency) || !isset($responseObject->timestamp) || !($responseObject->timestamp instanceof \DateTime) diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/CashPayments/Baloto.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/CashPayments/Baloto.php similarity index 83% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/CashPayments/Baloto.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/CashPayments/Baloto.php index 51120b1..3518155 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/CashPayments/Baloto.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/CashPayments/Baloto.php @@ -1,4 +1,5 @@ allowedOptionsSetter( + 'gender', + Gender::getAll(), + $value, + 'Invalid value for parameter gender provided.' + ); + } + + /** + * @param $value + * @return Pix + * @throws \Genesis\Exceptions\InvalidArgument + */ + public function setMaritalStatus($value) + { + return $this->allowedOptionsSetter( + 'marital_status', + MaritalStatuses::getAll(), + $value, + 'Invalid value for marital status parameter provided.' + ); + } + + public function setCompanyType($value) + { + return $this->allowedOptionsSetter( + 'company_type', + CompanyTypes::getAll(), + $value, + 'Invalid value for company type parameter provided.' + ); + } + + /** + * Set the required fields + * + * @return void + */ + protected function setRequiredFields() + { + $requiredFields = [ + 'transaction_id', + 'amount', + 'currency', + 'document_id' + ]; + + $this->requiredFields = CommonUtils::createArrayObject($requiredFields); + + $requiredFieldValues = [ + 'billing_country' => $this->getAllowedBillingCountries() + ]; + + $this->requiredFieldValues = CommonUtils::createArrayObject($requiredFieldValues); + + $this->requiredFieldValuesConditional = CommonUtils::createArrayObject( + $this->getDocumentIdConditions() + ); + } + + /** + * Return additional request attributes + * + * @return array + */ + protected function getPaymentTransactionStructure() + { + return array_merge( + [ + 'return_success_url' => $this->return_success_url, + 'return_failure_url' => $this->return_failure_url, + 'return_pending_url' => $this->getReturnPendingUrl(), + 'amount' => $this->transformAmount($this->amount, $this->currency), + 'currency' => $this->currency, + 'customer_email' => $this->customer_email, + 'document_id' => $this->document_id, + 'billing_address' => $this->getBillingAddressParamsStructure(), + 'shipping_address' => $this->getShippingAddressParamsStructure(), + 'birth_date' => $this->getBirthDate(), + 'birth_city' => $this->birth_city, + 'birth_state' => $this->birth_state, + 'gender' => $this->gender, + 'marital_status' => $this->marital_status, + 'sender_occupation' => $this->sender_occupation, + 'nationality' => $this->nationality, + 'country_of_origin' => $this->country_of_origin + + ], + $this->getCustomerParamsStructure() + ); + } +} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/CashPayments/Redpagos.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/CashPayments/Redpagos.php similarity index 83% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/CashPayments/Redpagos.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/CashPayments/Redpagos.php index 3f64164..dcd2605 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/CashPayments/Redpagos.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/CashPayments/Redpagos.php @@ -1,4 +1,5 @@ [ ['bank_code' => BankCodeParameters::getBankCodesPerCurrency('PLN')] ], + 'AUD' => [ + ['bank_code' => BankCodeParameters::getBankCodesPerCurrency('AUD')] + ] ] ]; diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/OnlineBankingPayments/OnlineBanking/Payout.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/OnlineBankingPayments/OnlineBanking/Payout.php similarity index 88% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/OnlineBankingPayments/OnlineBanking/Payout.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/OnlineBankingPayments/OnlineBanking/Payout.php index 8a3a411..e80bbc3 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/OnlineBankingPayments/OnlineBanking/Payout.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/OnlineBankingPayments/OnlineBanking/Payout.php @@ -1,4 +1,5 @@ $this->getBirthDate(), 'payment_type' => $this->payment_type, 'billing_address' => $this->getBillingAddressParamsStructure(), - 'shipping_address' => $this->getShippingAddressParamsStructure() + 'shipping_address' => $this->getShippingAddressParamsStructure(), + 'pix_key' => $this->pix_key ], $this->getCustomerParamsStructure() ); @@ -456,16 +469,13 @@ protected function validateBRLCurrency() } $requiredFieldsGroups = [ - 'currency' => ['bank_code', 'bank_name'], + 'BRL Currency' => ['bank_code', 'bank_name'] ]; $this->requiredFieldsGroups = Common::createArrayObject($requiredFieldsGroups); - // Allow empty bank_name with non-empty bank_code - if (!empty($this->bank_code)) { - $requiredFieldValuesConditional = (array)$this->requiredFieldValuesConditional; - $requiredFieldValuesConditional['currency']['BRL'][] = ['bank_code' => $this->bank_code]; - - $this->requiredFieldValuesConditional = Common::createArrayObject($requiredFieldValuesConditional); + // Allow empty bank_name, only with Group bank_code and bank_name requirement + if (empty($this->bank_name)) { + unset($this->requiredFieldValuesConditional['currency']['BRL']); } } } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/OnlineBankingPayments/PayU.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/OnlineBankingPayments/PayU.php similarity index 81% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/OnlineBankingPayments/PayU.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/OnlineBankingPayments/PayU.php index eb4fd93..edee64f 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/OnlineBankingPayments/PayU.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/OnlineBankingPayments/PayU.php @@ -1,4 +1,5 @@ $this->getBillingAddressParamsStructure(), 'shipping_address' => $this->getShippingAddressParamsStructure(), 'return_success_url' => $this->return_success_url, - 'return_failure_url' => $this->return_failure_url + 'return_failure_url' => $this->return_failure_url, + 'return_pending_url' => $this->getReturnPendingUrl() ]; } } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/TravelData/AirlineItineraryLegData.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/TravelData/AirlineItineraryLegData.php similarity index 96% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/TravelData/AirlineItineraryLegData.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/TravelData/AirlineItineraryLegData.php index fcd4032..b2e8530 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/TravelData/AirlineItineraryLegData.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/TravelData/AirlineItineraryLegData.php @@ -1,4 +1,5 @@ merchant_website = null; + + return $this; + } + + if (!CommonUtils::isValidUrl($value)) { + throw new InvalidArgument('Invalid merchant_website URL is given.'); + } + + $this->merchant_website = $value; + + return $this; + } + /** * Returns the Request transaction type * @return string */ protected function getTransactionType() { - return \Genesis\API\Constants\Transaction\Types::EZEEWALLET; + return \Genesis\Api\Constants\Transaction\Types::EZEEWALLET; } /** @@ -102,11 +139,11 @@ protected function getPaymentTransactionStructure() 'return_failure_url' => $this->return_failure_url, 'notification_url' => $this->notification_url, 'source_wallet_id' => $this->source_wallet_id, - 'source_wallet_pwd' => $this->transformWalletPassword($this->source_wallet_pwd) + 'source_wallet_pwd' => $this->transformWalletPassword($this->source_wallet_pwd), + 'merchant_website' => $this->merchant_website ]; } - /** * Apply transformation: * diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Wallets/Neteller.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Wallets/Neteller.php similarity index 86% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Wallets/Neteller.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Wallets/Neteller.php index 1bae700..556164d 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/Wallets/Neteller.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Financial/Wallets/Neteller.php @@ -1,4 +1,5 @@ requiredFieldValues = \Genesis\Utils\Common::createArrayObject($requiredFieldValues); - + $requiredFieldsConditional = [ 'is_payout' => [ true => [ diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/CashPayments/Carulla.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Alternatives/Klarna/ReleaseAuthorization.php similarity index 62% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/CashPayments/Carulla.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Alternatives/Klarna/ReleaseAuthorization.php index 506be82..5e01f30 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/Financial/CashPayments/Carulla.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Alternatives/Klarna/ReleaseAuthorization.php @@ -1,4 +1,5 @@ config = \Genesis\Utils\Common::createArrayObject( - [ - 'protocol' => Request::PROTOCOL_HTTPS, - 'port' => Request::PORT_HTTPS, - 'type' => Request::METHOD_GET, - 'format' => 'xml' - ] - ); - - $this->initApiGatewayConfiguration('retrieve_abn_ideal_banks', false); + parent::initBaseConfiguration('klarna/update_order_address'); + } + + protected function getRequestStructure() + { + return [ + 'billing_address' => $this->getBillingAddressParamsStructure(), + 'shipping_address' => $this->getShippingAddressParamsStructure() + ]; + } + + protected function getParentNode() + { + return 'update_order_address_request'; + } + + protected function setRequestRequiredFields() + { + return [ + 'billing_country', + 'shipping_country' + ]; } } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Alternatives/Klarna/UpdateItems.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Alternatives/Klarna/UpdateItems.php new file mode 100644 index 0000000..c9bde68 --- /dev/null +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Alternatives/Klarna/UpdateItems.php @@ -0,0 +1,102 @@ +items = $items; + + return $this; + } + + protected function initConfiguration() + { + parent::initBaseConfiguration('klarna/update_order_items'); + } + + protected function getRequestStructure() + { + return array_merge( + [ + 'amount' => \Genesis\Utils\Currency::amountToExponent($this->amount, $this->currency) + ], + $this->items instanceof Items ? $this->items->toArray() : [] + ); + } + + protected function getParentNode() + { + return 'update_order_items_request'; + } + + protected function setRequestRequiredFields() + { + return [ + 'amount' + ]; + } + + protected function checkRequirements() + { + parent::checkRequirements(); + + // verify there is at least one item added + if (empty($this->items) || $this->items->count() === 0) { + throw new ErrorParameter('Empty (null) required parameter: items'); + } + } +} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/NonFinancial/Alternatives/TransferTo/Payers.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Alternatives/TransferTo/Payers.php similarity index 90% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/NonFinancial/Alternatives/TransferTo/Payers.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Alternatives/TransferTo/Payers.php index 8e76c60..1917b05 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/NonFinancial/Alternatives/TransferTo/Payers.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Alternatives/TransferTo/Payers.php @@ -1,4 +1,5 @@ 'bank_number' + ]; + } + + /** + * Set the required fields + * + * @return void + */ + protected function setRequiredFields() + { + $requiredFields = [ + 'first_name', + 'last_name', + 'birth_date', + 'user_id', + 'clearing_house', + 'account_number', + 'bank_number' + ]; + + $this->requiredFields = CommonUtils::createArrayObject($requiredFields); + + $requiredFieldValues = [ + 'clearing_house' => ClearingHouses::getAll() + ]; + + $this->requiredFieldValues = CommonUtils::createArrayObject($requiredFieldValues); + } + + /** + * @return array + */ + protected function getRequestStructure() + { + return [ + 'first_name' => $this->first_name, + 'last_name' => $this->last_name, + 'email' => $this->email, + 'mobile_phone' => $this->mobile_phone, + 'national_id' => $this->national_id, + 'birth_date' => $this->getBirthDate(), + 'user_id' => $this->user_id, + 'account_number' => $this->account_number, + 'clearing_house' => $this->clearing_house, + 'bank_number' => $this->bank_number + ]; + } +} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Alternatives/Trustly/SelectAccount.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Alternatives/Trustly/SelectAccount.php new file mode 100644 index 0000000..7a365d7 --- /dev/null +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Alternatives/Trustly/SelectAccount.php @@ -0,0 +1,154 @@ +requiredFields = CommonUtils::createArrayObject($requiredFields); + + $requiredFieldValues = [ + 'country' => Country::getList() + ]; + + $this->requiredFieldValues = CommonUtils::createArrayObject($requiredFieldValues); + } + + /** + * @return array + */ + protected function getRequestStructure() + { + return [ + 'country' => $this->country, + 'first_name' => $this->first_name, + 'last_name' => $this->last_name, + 'ip_address' => $this->ip_address, + 'email' => $this->email, + 'mobile_phone' => $this->mobile_phone, + 'national_id' => $this->national_id, + 'birth_date' => $this->getBirthDate(), + 'success_url' => $this->success_url, + 'failure_url' => $this->failure_url, + 'user_id' => $this->user_id, + 'unique_id' => $this->unique_id, + 'locale' => $this->locale + ]; + } +} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/BillingApi/Transaction.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/BillingApi/Transaction.php new file mode 100644 index 0000000..3c45a81 --- /dev/null +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/BillingApi/Transaction.php @@ -0,0 +1,536 @@ +setStringArray($value, 'unique_id', 'UniqueId'); + } + + /** + * Return a formatted string with the Unique IDs + * + * @return string + */ + public function getUniqueId() + { + if (empty($this->unique_id)) { + return ''; + } + + return sprintf('[%s]', implode(',', $this->unique_id)); + } + + /** + * Set the list of Billing statement IDs in the filter + * + * @param array $value + * @return $this + * @throws InvalidArgument + */ + public function setBillingStatementId($value) + { + return $this->setStringArray($value, 'billing_statement_id', 'BillingStatementId'); + } + + /** + * Return a formatted string with the Billing statement IDs + * + * @return string + */ + public function getBillingStatementId() + { + if (empty($this->billing_statement_id)) { + return ''; + } + + return sprintf('[%s]', implode(',', $this->billing_statement_id)); + } + + /** + * Set the list of Merchant transaction IDs in the filter + * + * @param array $value + * @return $this + * @throws InvalidArgument + */ + public function setMerchantTransactionId($value) + { + return $this->setStringArray($value, 'merchant_transaction_id', 'MerchantTransactionId'); + } + + /** + * Return a formatted string with the Merchant IDs + * + * @return string + */ + public function getMerchantTransactionId() + { + if (empty($this->merchant_transaction_id)) { + return ''; + } + + return sprintf('[%s]', implode(',', $this->merchant_transaction_id)); + } + + /** + * Set the list of Master Account Names in the filter + * + * @param array $value + * @return $this + * @throws InvalidArgument + */ + public function setMasterAccountName($value) + { + return $this->setStringArray($value, 'master_account_name', 'MasterAccountName'); + } + + /** + * Return a formatted string with the Master Account Names + * + * @return string + */ + public function getMasterAccountName() + { + if (empty($this->master_account_name)) { + return ''; + } + + return sprintf('[%s]', implode(',', $this->master_account_name)); + } + + /** + * Set transaction type parameter + * + * @param string $value + * @return $this + * @throws InvalidArgument + */ + public function setTransactionType($value) + { + return $this->allowedOptionsSetter( + 'transaction_type', + $this->getTransactionTypeAllowedValues(), + $value, + 'Invalid value given for transactionType. Allowed values: ' . + implode(', ', $this->getTransactionTypeAllowedValues()) + ); + } + + /** + * Set order by field parameter + * + * @param string $value + * @return $this + * @throws InvalidArgument + */ + public function setOrderByField($value) + { + return $this->allowedOptionsSetter( + 'order_by_field', + $this->getOrderByFieldAllowedValues(), + $value, + 'Invalid value given for orderByField. Allowed values: ' . + implode(', ', $this->getOrderByFieldAllowedValues()) + ); + } + + /** + * Set Service API token + * + * @return void + */ + protected function initGraphqlToken() + { + $this->setApiConfig('bearer_token', \Genesis\Config::getBillingApiToken()); + } + + /** + * Additional optional filter arguments + * + * @return string + */ + protected function getAdditionalArguments() + { + return sprintf( + '%s %s', + $this->getRequestOrder(), + $this->getRequestPaging() + ); + } + + /** + * Add paging information to the request + * + * @return string + */ + protected function getAdditionalData() + { + return $this->pagingGraphQlFields(); + } + + /** + * @return void + */ + protected function setRequiredFields() + { + $requiredFields = [ + 'response_fields' + ]; + $this->requiredFields = \Genesis\Utils\Common::createArrayObject($requiredFields); + + $requiredFieldsGroups = [ + 'filter' => [ + 'start_date', + 'end_date', + 'unique_id', + 'billing_statement_id', + 'merchant_transaction_id', + 'master_account_name', + 'transaction_type' + ] + ]; + $this->requiredFieldsGroups = \Genesis\Utils\Common::createArrayObject($requiredFieldsGroups); + } + + /** + * @return void + * @throws ErrorParameter + * @throws InvalidArgument + */ + protected function checkRequirements() + { + parent::checkRequirements(); + + $this->validateConditionallyRequiredDates(); + $this->validateStatementsMaxCount(); + } + + /** + * Validate dates + * If startDate is provided, then endDate should also be provided and vice versa. + * + * @return void + * @throws ErrorParameter + */ + protected function validateConditionallyRequiredDates() + { + if ( + (!empty($this->start_date) && empty($this->end_date)) + || (!empty($this->end_date) && empty($this->start_date)) + ) { + throw new ErrorParameter( + 'If filter startDate is provided, then endDate should also be provided and vice versa.' + ); + } + } + + /** + * Validate max number of filter elements + * + * @return void + * @throws ErrorParameter + */ + protected function validateStatementsMaxCount() + { + $this->checkArrayMaxSize( + $this->billing_statement_id, + self::MAX_COUNT_BILLING_STATEMENT_ID, + 'billingStatementId' + ); + + $this->checkArrayMaxSize( + $this->unique_id, + self::MAX_COUNT_UNIQUE_ID, + 'uniqueId' + ); + + $this->checkArrayMaxSize( + $this->merchant_transaction_id, + self::MAX_COUNT_MERCHANT_TRANSACTION_ID, + 'merchantTransactionId' + ); + + $this->checkArrayMaxSize( + $this->master_account_name, + self::MAX_COUNT_MASTER_ACCOUNT_NAME, + 'masterAccountName' + ); + } + + /** + * Validate max number of elements in array + * + * @param array $var - the array variable + * @param int $maxSize - max size of the array + * @param string $message - text for the error message + * + * @return void + * @throws ErrorParameter + */ + protected function checkArrayMaxSize($var, $maxSize, $message) + { + if (!empty($var) && count($var) > $maxSize) { + throw new ErrorParameter( + sprintf( + 'Max number of %s elements allowed is %s.', + $message, + $maxSize + ) + ); + } + } + + /** + * Set parameter of type array of strings + * + * @param array $value - value to be set + * @param string $name - name of the array variable + * @param string $message - the message of the exception + * + * @return $this + * @throws InvalidArgument + */ + protected function setStringArray($value, $name, $message) + { + if (CommonUtils::isValidArray($value)) { + $this->{$name} = array_map('strval', $value); + + return $this; + } + + throw new InvalidArgument( + "$message should be an array of strings" + ); + } + + /** + * List of allowed response fields + * + * @return string[] + */ + protected function getResponseFieldsAllowedValues() + { + return ['uniqueId', 'billingStatementId', 'billingStatementDisplayId', 'transactionType', + 'transactionDate', 'transactionCurrency', 'transactionAmount', 'exchangeRate', 'billingCurrency', + 'billingAmount', 'transactionFeeCurrency', 'transactionFeeAmount', 'commissionAmount', 'commissionRuleId', + 'transactionFeeChargedOnBillingStatementId', 'commissionPercent', 'interchangeFee', 'interchangeCurrency', + 'isInterchangeplusplus', 'interchangeplusplusChargedOnBillingStatementId', 'schemeFee', 'vatAmount', + 'vatRate', 'schemeFeeCurrency', 'standardDebitCardRate', 'gstAmount', 'gstRate', 'terminalId', 'region', + 'settlementStatements', 'settlementDates', 'settlementStatus', 'merchantId', 'merchantName', 'valueDate']; + } + + /** + * List of allowed fields for response sorting + * + * @return string[] + */ + protected function getOrderByFieldAllowedValues() + { + return ['billingStatementId', 'transactionDate', 'transactionCurrency', 'transactionAmount', 'exchangeRate', + 'billingAmount', 'transactionFeeAmount', 'commissionPercent', 'commissionAmount', 'interchangeFee', + 'region', 'settlementStatus']; + } + + /** + * List of allowed values for transaction_type parameter + * + * @return string[] + */ + protected function getTransactionTypeAllowedValues() + { + return ['Authorisation Approved', 'Authorisation Declined', 'Settlement Approved', 'Settlement Declined', + 'Sale Approved', 'Sale Declined', 'Refund Approved', 'Refund Declined', 'Payout Approved', + 'Payout Declined', 'CFT Other Approved', 'CFT Declined', 'Chargeback', 'Chargeback Reversal', + 'Chargeback Representment', 'Retrieval Request', 'Void', 'Visa EU Intraregional Fraud Chargeback', + 'MasterCard EU Region Chargeback', 'Second Chargeback', 'CFT Visa Approved', 'CFT MasterCard Approved', + 'Visa RDR', 'RDR Reversal', 'Gateway Transaction Fee', 'Risk Management Transaction Fee', + 'Fraud Engine Transaction Fee']; + } + + /** + * Return a formatted string with request filters + * + * @return string + */ + protected function getRequestFilters() + { + $filters = [ + 'uniqueId' => $this->getUniqueId(), + 'startDate' => $this->getStartDate(), + 'endDate' => $this->getEndDate(), + 'billingStatementId' => $this->getBillingStatementId(), + 'merchantTransactionId' => $this->getMerchantTransactionId(), + 'masterAccountName' => $this->getMasterAccountName(), + 'transactionType' => $this->getTransactionType() + ]; + + $filters = array_filter($filters); + + $filterData = implode( + ', ', + array_map( + function ($key, $value) { + $format = ($key == 'billingStatementId') ? '%s: %s' : '%s: "%s"'; + + return sprintf($format, $key, $value); + }, + array_keys($filters), + $filters + ) + ); + + return sprintf( + 'filter: { %s } %s', + $filterData, + $this->getAdditionalArguments() + ); + } + + /** + * Return a formatted string with paging parameters + * + * @return string + */ + protected function getRequestPaging() + { + $paging = [ + 'page' => $this->getPage(), + 'perPage' => $this->getPerPage() + ]; + + return $this->generateGraphQLCode($paging, 'paging'); + } + + /** + * Return a formatted string with ordering parameters + * + * @return string + */ + protected function getRequestOrder() + { + $elements = [ + 'byDirection' => $this->getOrderByDirection(), + 'byField' => $this->getOrderByField() + ]; + + return $this->generateGraphQLCode($elements, 'sort'); + } + + protected function getRequestStructure() + { + return $this->getResponseFields(); + } +} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/NonFinancial/Blacklist.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Blacklist.php similarity index 94% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/NonFinancial/Blacklist.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Blacklist.php index f7891ff..7e94f38 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/NonFinancial/Blacklist.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Blacklist.php @@ -1,4 +1,5 @@ requiredFields = \Genesis\Utils\Common::createArrayObject($requiredFields); + } + + /** + * @return array + */ + protected function getRequestStructure() + { + return [ + 'email' => $this->email, + 'consumer_id' => $this->consumer_id + ]; + } +} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/NonFinancial/Consumers/Retrieve.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Consumers/Retrieve.php similarity index 90% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/NonFinancial/Consumers/Retrieve.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Consumers/Retrieve.php index 689ad1d..c470f64 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/NonFinancial/Consumers/Retrieve.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Consumers/Retrieve.php @@ -1,4 +1,5 @@ page = (int) $value; - - return $this; - } - - /** - * Number of entities on page, default to 100 - * - * @param $value - * @return $this - */ - public function setPerPage($value) - { - $this->per_page = (int) $value; - - return $this; - } - /** * Filters chargebacks by being externally processed or being native to Genesis. * diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/NonFinancial/Fraud/Chargeback/Transaction.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Fraud/Chargeback/Transaction.php similarity index 93% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/NonFinancial/Fraud/Chargeback/Transaction.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Fraud/Chargeback/Transaction.php index 5e1ff50..6cf5eee 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/NonFinancial/Fraud/Chargeback/Transaction.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Fraud/Chargeback/Transaction.php @@ -1,4 +1,5 @@ reference_id = null; + + return $this; + } + + return $this->setLimitedString( + 'reference_id', + $value, + self::REFERENCE_ID_MIN_LENGTH, + self::REFERENCE_ID_MAX_LENGTH + ); + } + /** * Get the request structure * diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Kyc/Cnpj/Check.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Kyc/Cnpj/Check.php new file mode 100644 index 0000000..b5b8e7a --- /dev/null +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Kyc/Cnpj/Check.php @@ -0,0 +1,94 @@ +document_id = $value; + + $this->setApiConfig( + 'url', + $this->buildRequestURL('kyc', "api/{$this->getVersion()}/{$this->getRequestPath()}/$this->document_id") + ); + + return $this; + } + + /** + * @return void + */ + protected function setRequiredFields() + { + $requiredFields = [ + 'document_id' + ]; + + $this->requiredFields = CommonUtils::createArrayObject($requiredFields); + } + + /** + * @return array + */ + protected function getRequestStructure() + { + return []; + } +} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/NonFinancial/KYC/ConsumerRegistration/Create.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Kyc/ConsumerRegistration/Create.php similarity index 93% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/NonFinancial/KYC/ConsumerRegistration/Create.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Kyc/ConsumerRegistration/Create.php index 1fb85fd..0ba1eae 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/NonFinancial/KYC/ConsumerRegistration/Create.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Kyc/ConsumerRegistration/Create.php @@ -1,4 +1,5 @@ document_id = $value; + + $this->setApiConfig( + 'url', + $this->buildRequestURL('kyc', "api/{$this->getVersion()}/{$this->getRequestPath()}/$this->document_id") + ); + + return $this; + } + + /** + * @return void + */ + protected function setRequiredFields() + { + $requiredFields = [ + 'document_id' + ]; + + $this->requiredFields = CommonUtils::createArrayObject($requiredFields); + } + + /** + * @return array + */ + protected function getRequestStructure() + { + return []; + } +} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/NonFinancial/KYC/IdentityDocument/Download.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Kyc/IdentityDocument/Download.php similarity index 90% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/NonFinancial/KYC/IdentityDocument/Download.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Kyc/IdentityDocument/Download.php index f8f5f5a..f12f96c 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/NonFinancial/KYC/IdentityDocument/Download.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Kyc/IdentityDocument/Download.php @@ -1,4 +1,5 @@ batch_slip_number = (string) $value; + + return $this; + } + + protected function initConfiguration() + { + parent::initBaseConfiguration('processed_batches/by_post_date'); + } + + protected function getRequestStructure() + { + return [ + 'batch_slip_number' => $this->batch_slip_number + ]; + } + + protected function getParentNode() + { + return 'processed_batch_request'; + } +} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/NonFinancial/ProcessedTransactions/DateRange.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/ProcessedTransactions/DateRange.php similarity index 82% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/NonFinancial/ProcessedTransactions/DateRange.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/ProcessedTransactions/DateRange.php index fc0e2c8..d016d49 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/NonFinancial/ProcessedTransactions/DateRange.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/ProcessedTransactions/DateRange.php @@ -1,4 +1,5 @@ initXmlConfiguration(); + + $this->initApiGatewayConfiguration('reconcile/by_date'); + } + + /** + * Set the required fields + * + * @return void + */ + protected function setRequiredFields() + { + $requiredFields = [ + 'start_date' + ]; + + $this->requiredFields = \Genesis\Utils\Common::createArrayObject($requiredFields); + } + + /** + * Create the request's Tree structure + * + * @return void + */ + protected function populateStructure() + { + $treeStructure = [ + 'reconcile' => [ + 'start_date' => $this->getStartDate(), + 'end_date' => $this->getEndDate(), + 'page' => $this->page + ] + ]; + + $this->treeStructure = \Genesis\Utils\Common::createArrayObject($treeStructure); + } +} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/NonFinancial/Reconcile/Transaction.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Reconcile/Transaction.php similarity index 94% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/NonFinancial/Reconcile/Transaction.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Reconcile/Transaction.php index 782f186..dae064b 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/NonFinancial/Reconcile/Transaction.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/NonFinancial/Reconcile/Transaction.php @@ -1,4 +1,5 @@ 44640) { - throw new InvalidArgument('Valid value ranges between 1 minute and 31 days given in minutes'); + if ($lifetime < 1 || $lifetime > 131487) { + throw new InvalidArgument( + 'Valid value ranges between 1 minute and 3 months given in minutes (131487)' + ); } $this->lifetime = $lifetime; @@ -386,171 +397,6 @@ public function setScaExemption($value) return $this; } - /** - * Verify that transaction type parameters are populated correctly - * - * @param string $transactionType - * @param array $parameters - * @throws \Genesis\Exceptions\ErrorParameter - */ - protected function verifyTransactionType($transactionType, $parameters = []) - { - if (!Types::isValidWPFTransactionType($transactionType)) { - throw new \Genesis\Exceptions\ErrorParameter( - sprintf( - 'Transaction type (%s) is not valid. Valid WPF transactions are: %s.', - $transactionType, - implode(', ', Types::getWPFTransactionTypes()) - ) - ); - } - - $txnCustomRequiredParams = Types::getCustomRequiredParameters( - $transactionType - ); - - if (!CommonUtils::isValidArray($txnCustomRequiredParams)) { - return; - } - - $txnCustomRequiredParams = static::validateNativeCustomParameters($transactionType, $txnCustomRequiredParams); - - if (CommonUtils::isValidArray($txnCustomRequiredParams) && !CommonUtils::isValidArray($parameters)) { - throw new \Genesis\Exceptions\ErrorParameter( - sprintf( - 'Custom transaction parameters (%s) are required and none are set.', - implode(', ', array_keys($txnCustomRequiredParams)) - ) - ); - } - - foreach ($txnCustomRequiredParams as $customRequiredParam => $customRequiredParamValues) { - $this->validateRequiredParameter( - $transactionType, - $customRequiredParam, - $customRequiredParamValues, - $parameters - ); - } - } - - /** - * @param string $transactionType - * @param array $txnCustomRequiredParams - * - * @return array - */ - protected function validateNativeCustomParameters($transactionType, $txnCustomRequiredParams) - { - foreach ($txnCustomRequiredParams as $customRequiredParam => $customRequiredParamValues) { - if (property_exists($this, $customRequiredParam)) { - $this->validateRequiredParameter( - $transactionType, - $customRequiredParam, - $customRequiredParamValues, - [ $customRequiredParam => $this->{$customRequiredParam} ] - ); - - unset($txnCustomRequiredParams[$customRequiredParam]); - } - } - - return $txnCustomRequiredParams; - } - - protected function validateRequiredParameter( - $transactionType, - $customRequiredParam, - $customRequiredParamValues, - $parameters - ) { - $this->checkEmptyRequiredParamsFor( - $transactionType, - $customRequiredParam, - $parameters - ); - - if (!CommonUtils::isValidArray($customRequiredParamValues)) { - return; - } - - if (!CommonUtils::arrayContainsArrayItems($parameters)) { - $this->checkIsParamSet( - $transactionType, - $parameters[$customRequiredParam], - $customRequiredParamValues - ); - - return; - } - - foreach ($parameters as $parameter) { - $this->checkIsParamSet( - $transactionType, - $parameter[$customRequiredParam], - $customRequiredParamValues - ); - } - } - - /** - * @param string $transactionType - * @param array $parameters - * @param mixed $paramValues - * - * @throws \Genesis\Exceptions\ErrorParameter - */ - private function checkIsParamSet($transactionType, $parameters, $paramValues) - { - if (!in_array($parameters, $paramValues)) { - throw new \Genesis\Exceptions\ErrorParameter( - sprintf( - 'Invalid value (%s) for required parameter: %s (Transaction type: %s)', - $parameters, - $paramValues, - $transactionType - ) - ); - } - } - - /** - * Performs a check there is an empty required param for the passed transaction type - * - * @param string $transactionType - * @param string $customRequiredParam - * @param array $txnParameters - * - * @throws \Genesis\Exceptions\ErrorParameter - */ - protected function checkEmptyRequiredParamsFor( - $transactionType, - $customRequiredParam, - $txnParameters = [] - ) { - if (CommonUtils::isArrayKeyExists($customRequiredParam, $txnParameters) && - !empty($txnParameters[$customRequiredParam]) - ) { - return; - } - - foreach ($txnParameters as $parameter) { - if (CommonUtils::isArrayKeyExists($customRequiredParam, $parameter) && - !empty($parameter[$customRequiredParam]) - ) { - return; - } - } - - throw new \Genesis\Exceptions\ErrorParameter( - sprintf( - 'Empty (null) required parameter: %s for transaction type %s', - $customRequiredParam, - $transactionType - ) - ); - } - /** * Add ISO 639-1 language code to the URL * @@ -560,7 +406,7 @@ protected function checkEmptyRequiredParamsFor( * * @throws \Genesis\Exceptions\InvalidArgument */ - public function setLanguage($language = \Genesis\API\Constants\i18n::EN) + public function setLanguage($language = \Genesis\Api\Constants\i18n::EN) { $language = CommonUtils::filterLanguageCode($language); @@ -702,7 +548,8 @@ protected function populateStructure() 'threeds_v2_params' => $this->getThreedsV2ParamsStructure(), 'web_payment_form_id' => $this->web_payment_form_id, 'recurring_category' => $this->recurring_category, - 'funding' => $this->getFundingAttributesStructure() + 'funding' => $this->getFundingAttributesStructure(), + 'account_owner' => $this->getAccountOwnerAttributesStructure() ] ]; diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/WPF/Reconcile.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Wpf/Reconcile.php similarity index 94% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/WPF/Reconcile.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Wpf/Reconcile.php index 8b0196d..8777711 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Request/WPF/Reconcile.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Request/Wpf/Reconcile.php @@ -1,4 +1,5 @@ responseRaw = $network->getResponseBody(); + $this->responseRaw = $network->getResponseBody(); + $this->responseCode = $network->getStatus(); try { $parser = $this->getParser($network); $this->responseObj = $parser->getObject(); } catch (\Exception $e) { - throw new \Genesis\Exceptions\InvalidResponse( + throw new InvalidResponse( $e->getMessage(), $e->getCode() ); @@ -101,24 +146,6 @@ public function parseResponse(Network $network) // Apply per-field transformations $this->transform([$this->responseObj]); - - if (isset($this->responseObj->status)) { - $state = new Constants\Transaction\States($this->responseObj->status); - - if (!$state->isValid()) { - throw new \Genesis\Exceptions\InvalidArgument( - 'Unknown transaction status', - isset($this->responseObj->code) ? $this->responseObj->code : 0 - ); - } - - if ($state->isError() && !$this->suppressReconciliationException()) { - throw new \Genesis\Exceptions\ErrorAPI( - $this->responseObj->message, - isset($this->responseObj->code) ? $this->responseObj->code : 0 - ); - } - } } protected function getParser(Network $network) @@ -184,31 +211,6 @@ public function isPartiallyApproved() return null; } - /** - * Suppress Reconciliation responses as their statuses - * reflect their transactions - * - * @return bool - */ - public function suppressReconciliationException() - { - $instances = [ - new \Genesis\API\Request\NonFinancial\Reconcile\DateRange(), - new \Genesis\API\Request\NonFinancial\Reconcile\Transaction(), - new \Genesis\API\Request\WPF\Reconcile() - ]; - - if (isset($this->requestCtx) && isset($this->responseObj->unique_id)) { - foreach ($instances as $instance) { - if ($this->requestCtx instanceof $instance) { - return true; - } - } - } - - return false; - } - /** * Try to fetch a description of the received Error Code * @@ -237,6 +239,16 @@ public function getResponseRaw() return $this->responseRaw; } + /** + * Get the HTTP response status + * + * @return int + */ + public function getResponseCode() + { + return $this->responseCode; + } + /** * Get the parsed response * @@ -355,7 +367,7 @@ public static function transformFilterTimestamp($transaction) { if (isset($transaction->timestamp)) { try { - $transaction->timestamp = new \DateTime($transaction->timestamp); + $transaction->timestamp = new DateTime($transaction->timestamp); } catch (\Exception $e) { // Just log the attempt error_log($e->getMessage()); @@ -364,4 +376,26 @@ public static function transformFilterTimestamp($transaction) return $transaction; } + + /** + * Handle "magic" calls for status check + * + * @param $method + * @param $args + * + * @throws InvalidMethod + * @return bool + */ + public function __call($method, $args) + { + $status = new Constants\Transaction\States( + isset($this->responseObj->status) ? $this->responseObj->status : '' + ); + + if ($status->isValid()) { + return $status->$method(); + } + + return false; + } } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/MagicAccessors.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/MagicAccessors.php similarity index 95% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/MagicAccessors.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/MagicAccessors.php index 194cbab..db2bdb8 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/MagicAccessors.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/MagicAccessors.php @@ -1,4 +1,5 @@ $this->billing_first_name, - 'last_name' => $this->billing_last_name, - 'address1' => $this->billing_address1, - 'address2' => $this->billing_address2, - 'zip_code' => $this->billing_zip_code, - 'city' => $this->billing_city, - 'state' => $this->billing_state, - 'country' => $this->billing_country + 'first_name' => $this->billing_first_name, + 'last_name' => $this->billing_last_name, + 'address1' => $this->billing_address1, + 'address2' => $this->billing_address2, + 'zip_code' => $this->billing_zip_code, + 'city' => $this->billing_city, + 'state' => $this->billing_state, + 'neighborhood' => $this->billing_neighborhood, + 'country' => $this->billing_country ]; } } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/CustomerAddress/CustomerInfoAttributes.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/CustomerAddress/CustomerInfoAttributes.php similarity index 92% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/CustomerAddress/CustomerInfoAttributes.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/CustomerAddress/CustomerInfoAttributes.php index 70b0249..3967dc0 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/CustomerAddress/CustomerInfoAttributes.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/CustomerAddress/CustomerInfoAttributes.php @@ -1,4 +1,5 @@ $this->shipping_first_name, - 'last_name' => $this->shipping_last_name, - 'address1' => $this->shipping_address1, - 'address2' => $this->shipping_address2, - 'zip_code' => $this->shipping_zip_code, - 'city' => $this->shipping_city, - 'state' => $this->shipping_state, - 'country' => $this->shipping_country + 'first_name' => $this->shipping_first_name, + 'last_name' => $this->shipping_last_name, + 'address1' => $this->shipping_address1, + 'address2' => $this->shipping_address2, + 'zip_code' => $this->shipping_zip_code, + 'city' => $this->shipping_city, + 'state' => $this->shipping_state, + 'neighborhood' => $this->shipping_neighborhood, + 'country' => $this->shipping_country ]; } } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/DocumentAttributes.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/DocumentAttributes.php similarity index 94% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/DocumentAttributes.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/DocumentAttributes.php index 42ae54f..ec2922d 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/DocumentAttributes.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/DocumentAttributes.php @@ -1,4 +1,5 @@ 'NonFinancial\AVS', - self::ABNI_DEAL_BANKS => 'NonFinancial\Retrieve\AbniDealBanks', - Types::ACCOUNT_VERIFICATION => 'NonFinancial\AccountVerification' + 'first_name' => $this->account_first_name, + 'middle_name' => $this->account_middle_name, + 'last_name' => $this->account_last_name ]; } } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Financial/AsyncAttributes.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Financial/AsyncAttributes.php similarity index 91% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Financial/AsyncAttributes.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Financial/AsyncAttributes.php index 74e3470..0bc2f4f 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Financial/AsyncAttributes.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Financial/AsyncAttributes.php @@ -1,4 +1,5 @@ [ - $this->iban => [ - ['iban' => new RegexValidator(RegexValidator::PATTERN_DE_IBAN)] - ] - ], - ]; - } } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Financial/BeneficiaryAttributes.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Financial/BeneficiaryAttributes.php similarity index 93% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Financial/BeneficiaryAttributes.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Financial/BeneficiaryAttributes.php index 9397cde..0c4a317 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Financial/BeneficiaryAttributes.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Financial/BeneficiaryAttributes.php @@ -1,4 +1,5 @@ [ - Types::SUBSEQUENT => [ - 'reference_id' - ] - ] - ]; - } - /** * Returns Conditional Fields validation applicable for Managed Recurring Type. Managed Recurring attributes are * required in this case. diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Financial/Cards/Recurring/SubsequentRecurringTypeAttributes.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Financial/Cards/Recurring/SubsequentRecurringTypeAttributes.php new file mode 100644 index 0000000..67621c7 --- /dev/null +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Financial/Cards/Recurring/SubsequentRecurringTypeAttributes.php @@ -0,0 +1,87 @@ +recurring_type == Types::SUBSEQUENT && empty($currency)) { + return $amount; + } + + return parent::transformAmount($amount, $currency); + } + + /** + * Extend the Request Validations for Subsequent recurring type + * + * @return void + * @throws \Genesis\Exceptions\ErrorParameter + * @throws \Genesis\Exceptions\InvalidArgument + * @throws \Genesis\Exceptions\InvalidClassMethod + */ + protected function checkRequirementsSubsequent() + { + $requiredFields = [ + 'transaction_id', + 'amount' + ]; + + $this->requiredFields = CommonUtils::createArrayObject($requiredFields); + + unset($this->requiredFieldsOR); + + unset($this->requiredFieldValues); + + $requiredFieldValuesConditional = $this->requiredRecurringAllTypesFieldValuesConditional(); + + $this->requiredFieldValuesConditional = CommonUtils::createArrayObject( + $requiredFieldValuesConditional + ); + + $this->validate(); + } +} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Financial/CredentialOnFileAttributes.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Financial/CredentialOnFileAttributes.php similarity index 92% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Financial/CredentialOnFileAttributes.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Financial/CredentialOnFileAttributes.php index 1cb225c..0815cce 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Financial/CredentialOnFileAttributes.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Financial/CredentialOnFileAttributes.php @@ -1,4 +1,5 @@ $this->company_type, 'company_activity' => $this->company_activity, 'incorporation_date' => $this->getIncorporationDate(), - 'mothers_name' => $this->mothers_name, - 'pix_key' => $this->pix_key + 'mothers_name' => $this->mothers_name ]; } } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Financial/CustomerIdentificationData.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Financial/CustomerIdentificationData.php similarity index 93% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Financial/CustomerIdentificationData.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Financial/CustomerIdentificationData.php index 5f267a5..98b5c67 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Financial/CustomerIdentificationData.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Financial/CustomerIdentificationData.php @@ -1,4 +1,5 @@ allowedOptionsSetter( + 'mpi_protocol_sub_version', + MpiProtocolSubVersions::getAll(), + $value, + "Invalid Protocol sub-version value." + ); + } + /** * Set the value for 3DS challenge indicator. Highly recommended to increase approve ratio. * @param $value @@ -189,6 +214,7 @@ protected function get3DSv2ParamsStructure() 'cavv' => $this->mpi_cavv, 'eci' => $this->mpi_eci, 'protocol_version' => $this->mpi_protocol_version, + 'protocol_sub_version' => $this->mpi_protocol_sub_version, 'directory_server_id' => $this->mpi_directory_server_id, 'asc_transaction_id' => $this->mpi_asc_transaction_id, 'threeds_challenge_indicator' => $this->mpi_threeds_challenge_indicator diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Financial/NotificationAttributes.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Financial/NotificationAttributes.php similarity index 90% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Financial/NotificationAttributes.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Financial/NotificationAttributes.php index f762704..1880e17 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Financial/NotificationAttributes.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Financial/NotificationAttributes.php @@ -1,4 +1,5 @@ $this->getMaxConsumerReferenceLen()) { + if (strlen((string)$value) > $this->getMaxConsumerReferenceLen()) { throw new ErrorParameter("Consumer reference can be max {$this->getMaxConsumerReferenceLen()} characters."); } @@ -99,7 +100,7 @@ public function setConsumerReference($value) */ public function setNationalId($value) { - if (strlen($value) > $this->getNationalIdLen()) { + if (strlen((string)$value) > $this->getNationalIdLen()) { throw new ErrorParameter("National Identifier can be max {$this->getNationalIdLen()} characters."); } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Financial/PreauthorizationAttributes.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Financial/PreauthorizationAttributes.php similarity index 91% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Financial/PreauthorizationAttributes.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Financial/PreauthorizationAttributes.php index da3021e..61a0c4f 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Financial/PreauthorizationAttributes.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Financial/PreauthorizationAttributes.php @@ -1,4 +1,5 @@ threeds_v2_merchant_risk_gift_card_count = (int) $value; - if ($this->threeds_v2_merchant_risk_gift_card_count < 0 || + if ( + $this->threeds_v2_merchant_risk_gift_card_count < 0 || $this->threeds_v2_merchant_risk_gift_card_count > 99 ) { throw new InvalidArgument( diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Financial/Threeds/V2/Method.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Financial/Threeds/V2/Method.php similarity index 92% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Financial/Threeds/V2/Method.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Financial/Threeds/V2/Method.php index 4bed0ed..fc86b1b 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Financial/Threeds/V2/Method.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Financial/Threeds/V2/Method.php @@ -1,4 +1,5 @@ throwMethodError(__METHOD__); } - + protected function getThreedsV2ParamsStructure() { return array_merge( diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Financial/TravelData/AirlineItineraryAttributes.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Financial/TravelData/AirlineItineraryAttributes.php similarity index 93% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Financial/TravelData/AirlineItineraryAttributes.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Financial/TravelData/AirlineItineraryAttributes.php index e679305..e716a1d 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Financial/TravelData/AirlineItineraryAttributes.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Financial/TravelData/AirlineItineraryAttributes.php @@ -1,4 +1,5 @@ getStructureName(); if (count($this->{$structureName}) === $item->getMaxCount()) { - throw new InvalidArgument('Max '. $structureName .' count of ' . $item->getMaxCount() . ' reached.'); + throw new InvalidArgument('Max ' . $structureName . ' count of ' . $item->getMaxCount() . ' reached.'); } $this->{$structureName}[] = $item; diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Financial/TravelData/CarRentalAttributes.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Financial/TravelData/CarRentalAttributes.php similarity index 96% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Financial/TravelData/CarRentalAttributes.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Financial/TravelData/CarRentalAttributes.php index 42b7c77..3919f5e 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Financial/TravelData/CarRentalAttributes.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Financial/TravelData/CarRentalAttributes.php @@ -1,4 +1,5 @@ [ 'version' => $this->token_version, 'data' => $this->token_data, 'signature' => $this->token_signature, 'header' => [ + 'applicationData' => $this->token_application_data, 'ephemeralPublicKey' => $this->token_ephemeral_public_key, + 'wrappedKey' => $this->token_wrapped_key, 'publicKeyHash' => $this->token_public_key_hash, 'transactionId' => $this->token_transaction_id ] @@ -135,6 +167,9 @@ public function getPaymentTokenStructure() 'type' => $this->token_type ], 'transactionIdentifier' => $this->token_transaction_identifier - ], JSON_UNESCAPED_UNICODE); + ] + ); + + return json_encode($structure, JSON_UNESCAPED_UNICODE); } } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Mobile/GooglePayAttributes.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Mobile/GooglePayAttributes.php similarity index 97% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Mobile/GooglePayAttributes.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Mobile/GooglePayAttributes.php index 59af8c5..fbcdbab 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/Mobile/GooglePayAttributes.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/Mobile/GooglePayAttributes.php @@ -1,4 +1,5 @@ allowedOptionsSetter( + 'order_by_direction', + $this->getOrderByDirectionAllowedValues(), + strtolower($value), + 'Invalid value given for orderByDirection. Allowed values: ' . + implode(', ', $this->getOrderByDirectionAllowedValues()) + ); } /** - * Returns all available Card Types - * @return array + * List of allowed response ordering directions + * + * @return string[] */ - public static function getCardTypes() + protected function getOrderByDirectionAllowedValues() { - $methods = \Genesis\Utils\Common::getClassConstants(__CLASS__); - - return array_values($methods); + return ['asc', 'desc']; } } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/NonFinancial/CustomerInformation.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/NonFinancial/CustomerInformation.php similarity index 92% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/NonFinancial/CustomerInformation.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/NonFinancial/CustomerInformation.php index 6a508c6..c103bdd 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/NonFinancial/CustomerInformation.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/NonFinancial/CustomerInformation.php @@ -1,4 +1,5 @@ end_date)) ? null : $this->end_date->format($format); } - - /** - * Set the per-request configuration - * - * @return void - */ - protected function initConfiguration() - { - $this->initXmlConfiguration(); - - $this->initApiGatewayConfiguration('reconcile/by_date'); - } - - /** - * Set the required fields - * - * @return void - */ - protected function setRequiredFields() - { - $requiredFields = [ - 'start_date' - ]; - - $this->requiredFields = \Genesis\Utils\Common::createArrayObject($requiredFields); - } - - /** - * Create the request's Tree structure - * - * @return void - */ - protected function populateStructure() - { - $treeStructure = [ - 'reconcile' => [ - 'start_date' => $this->getStartDate(), - 'end_date' => $this->getEndDate(), - 'page' => $this->page - ] - ]; - - $this->treeStructure = \Genesis\Utils\Common::createArrayObject($treeStructure); - } } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/NonFinancial/DepositLimits.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/NonFinancial/DepositLimits.php similarity index 91% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/NonFinancial/DepositLimits.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/NonFinancial/DepositLimits.php index 555e29d..d60ffab 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/NonFinancial/DepositLimits.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/NonFinancial/DepositLimits.php @@ -1,4 +1,5 @@ allowedOptionsSetter( 'externally_processed', - \Genesis\API\Constants\NonFinancial\Fraud\Chargeback\ExternallyProcessed::getAll(), + \Genesis\Api\Constants\NonFinancial\Fraud\Chargeback\ExternallyProcessed::getAll(), $value, 'Invalid value for externally_processed attribute.' ); diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/NonFinancial/IdentityDocuments.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/NonFinancial/IdentityDocuments.php similarity index 94% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/NonFinancial/IdentityDocuments.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/NonFinancial/IdentityDocuments.php index 1efd774..40140a1 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/NonFinancial/IdentityDocuments.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/NonFinancial/IdentityDocuments.php @@ -1,4 +1,5 @@ expiry_date->format(DateTimeFormat::YYYY_MM_DD_ISO_8601); } - - /** - * Verify Reference ID value - * - * @param $value - * @return $this - * @throws InvalidArgument - */ - public function setReferenceId($value) - { - if (empty($value)) { - $this->reference_id = null; - - return $this; - } - - return $this->setLimitedString( - 'reference_id', - $value, - self::REFERENCE_ID_MIN_LENGTH, - self::REFERENCE_ID_MAX_LENGTH - ); - } } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/NonFinancial/KycBillingInformation.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/NonFinancial/KycBillingInformation.php similarity index 94% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/NonFinancial/KycBillingInformation.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/NonFinancial/KycBillingInformation.php index d4fd7a9..5dd8b63 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/NonFinancial/KycBillingInformation.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/NonFinancial/KycBillingInformation.php @@ -1,4 +1,5 @@ page = (int) $value; - return false; + return $this; } /** - * Returns all available Redeem Types - * @return array + * Set the number of elements per page + * + * @param $value + * @return $this */ - public static function getRedeemTypes() + public function setPerPage($value) { - $methods = \Genesis\Utils\Common::getClassConstants(__CLASS__); + $this->per_page = (int) $value; - return array_values($methods); + return $this; + } + + /** + * GraphQL code to request paging information + * + * @return string + */ + protected function pagingGraphQlFields() + { + return 'paging { + page + perPage + pagesCount + totalCount + }'; } } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/NonFinancial/PaymentDetails.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/NonFinancial/PaymentDetails.php similarity index 94% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/NonFinancial/PaymentDetails.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/NonFinancial/PaymentDetails.php index d9014f6..30abc06 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/NonFinancial/PaymentDetails.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/NonFinancial/PaymentDetails.php @@ -1,4 +1,5 @@ allowedOptionsSetter( 'cvv_present', - CVVPresents::getAll(), + CvvPresents::getAll(), $cvvPresent, 'Invalid cvv present indicator.' ); diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/NonFinancial/ProcessingType.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/NonFinancial/ProcessingType.php similarity index 90% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/NonFinancial/ProcessingType.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/NonFinancial/ProcessingType.php index 7b9846a..dabc4f0 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/Request/NonFinancial/ProcessingType.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/Request/NonFinancial/ProcessingType.php @@ -1,4 +1,5 @@ $customRequiredParamValues) { + $this->validateRequiredParameter( + $transactionType, + $customRequiredParam, + $customRequiredParamValues, + $parameters + ); + } + } + + protected function validateRequiredParameter( + $transactionType, + $customRequiredParam, + $customRequiredParamValues, + $parameters + ) { + $this->checkEmptyRequiredParamsFor( + $transactionType, + $customRequiredParam, + $parameters + ); + + if (!CommonUtils::isValidArray($customRequiredParamValues)) { + return; + } + + if (!CommonUtils::arrayContainsArrayItems($parameters)) { + $this->checkIsParamSet( + $transactionType, + $parameters[$customRequiredParam], + $customRequiredParamValues, + $customRequiredParam + ); + + return; + } + + foreach ($parameters as $parameter) { + $this->checkIsParamSet( + $transactionType, + $parameter, + $customRequiredParamValues, + $customRequiredParam + ); + } + } + + /** + * Performs a check there is an empty required param for the passed transaction type + * + * @param string $transactionType + * @param string $customRequiredParam + * @param array $txnParameters + * + * @throws \Genesis\Exceptions\ErrorParameter + */ + protected function checkEmptyRequiredParamsFor( + $transactionType, + $customRequiredParam, + $txnParameters = [] + ) { + if ( + CommonUtils::isArrayKeyExists($customRequiredParam, $txnParameters) && + !empty($txnParameters[$customRequiredParam]) + ) { + return; + } + + foreach ($txnParameters as $parameter) { + if ( + CommonUtils::isArrayKeyExists($customRequiredParam, $parameter) && + !empty($parameter[$customRequiredParam]) + ) { + return; + } + } + + throw new ErrorParameter( + sprintf( + 'Empty (null) required parameter: %s for transaction type %s', + $customRequiredParam, + $transactionType + ) + ); + } + + /** + * @param string $transactionType + * @param array $parameters + * @param mixed $paramValues + * @param string $paramName + * + * @throws \Genesis\Exceptions\ErrorParameter + */ + private function checkIsParamSet($transactionType, $parameters, $paramValues, $paramName) + { + if (!in_array($parameters, $paramValues)) { + throw new ErrorParameter( + sprintf( + 'Invalid value (%s) for required parameter: %s. Allowed values: %s. (Transaction type: %s)', + is_array($parameters) ? implode(', ', $parameters) : $parameters, + $paramName, + is_array($paramValues) ? implode(', ', $paramValues) : $paramValues, + $transactionType + ) + ); + } + } +} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/RestrictedSetter.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/RestrictedSetter.php similarity index 94% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/RestrictedSetter.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/RestrictedSetter.php index 4019df2..9ba2a67 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Traits/RestrictedSetter.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Traits/RestrictedSetter.php @@ -1,4 +1,5 @@ validations as $property => $method) { if (!empty($this->{$property})) { if (!method_exists($this, $method)) { - throw new \Genesis\Exceptions\InvalidClassMethod(); + throw new InvalidClassMethod(); } $this->{$method}(); } @@ -89,7 +90,7 @@ protected function validateFieldRequirements() { $this->requiredFields->setIteratorClass('RecursiveArrayIterator'); - $iterator = new \RecursiveIteratorIterator($this->requiredFields->getIterator()); + $iterator = new RecursiveIteratorIterator($this->requiredFields->getIterator()); foreach ($iterator as $fieldName) { if ($this->isNotNullAndEmptyValueAllowed($fieldName, $this->$fieldName)) { @@ -98,7 +99,7 @@ protected function validateFieldRequirements() } if (empty($this->$fieldName)) { - throw new \Genesis\Exceptions\ErrorParameter( + throw new ErrorParameter( sprintf('Empty (null) required parameter: %s', $fieldName) ); } @@ -124,7 +125,7 @@ protected function validateFieldValuesRequirements() if (CommonUtils::isValidArray($validator)) { if (!in_array($this->$fieldName, $validator)) { - throw new \Genesis\Exceptions\ErrorParameter( + throw new ErrorParameter( sprintf( 'Required parameter %s is set to %s, but expected to be one of (%s)', $fieldName, @@ -141,7 +142,7 @@ protected function validateFieldValuesRequirements() } if ($this->$fieldName !== $validator) { - throw new \Genesis\Exceptions\ErrorParameter( + throw new ErrorParameter( sprintf( 'Required parameter %s is set to %s, but expected to be %s', $fieldName, @@ -180,7 +181,7 @@ protected function validateGroupRequirements() } if (!$emptyFlag) { - throw new \Genesis\Exceptions\ErrorParameter( + throw new ErrorParameter( sprintf( 'One of the following group/s of field/s must be filled in: %s%s', PHP_EOL, @@ -229,7 +230,7 @@ protected function validateConditionalRequirements() ? var_export($this->$fieldName, true) : $this->$fieldName; - throw new \Genesis\Exceptions\ErrorParameter( + throw new ErrorParameter( sprintf( '%s with value %s is depending on: %s, which is empty (null)!', $fieldName, @@ -240,7 +241,7 @@ protected function validateConditionalRequirements() } } } elseif (empty($this->$fieldDependency)) { - throw new \Genesis\Exceptions\ErrorParameter( + throw new ErrorParameter( sprintf( '%s is depending on: %s, which is empty (null)!', $fieldName, @@ -269,7 +270,7 @@ protected function validateConditionalFieldsOr() } if ($definedFieldsCount > 1) { - throw new \Genesis\Exceptions\ErrorParameter( + throw new ErrorParameter( 'Only one of following parameters: ' . implode(', ', array_values($fields)) . ' is allowed.' @@ -278,7 +279,7 @@ protected function validateConditionalFieldsOr() } if ($definedFieldsCount === 0) { - throw new \Genesis\Exceptions\ErrorParameter(implode(', ', array_values($fields))); + throw new ErrorParameter(implode(', ', array_values($fields))); } } @@ -346,7 +347,7 @@ protected function validateConditionalValuesRequirements() } if (!$childFieldGroupValuesValidated) { - throw new \Genesis\Exceptions\ErrorParameter( + throw new ErrorParameter( sprintf( '%s with value %s is depending on group of params with specific values. ' . 'Please, refer to the official API documentation for %s transaction type.', diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Validators/Request/Base/Validator.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Validators/Request/Base/Validator.php similarity index 86% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Validators/Request/Base/Validator.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Validators/Request/Base/Validator.php index cf30330..98ba9d8 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Validators/Request/Base/Validator.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Validators/Request/Base/Validator.php @@ -1,4 +1,5 @@ message, $this->field) : "Please check input data for errors. '{$this->field}' has invalid format"; - throw new \Genesis\Exceptions\InvalidArgument($exceptionMessage); + throw new InvalidArgument($exceptionMessage); } /** @@ -108,7 +111,7 @@ protected function throwInvalidArgument() protected function getRequestValue() { if (!property_exists($this->request, $this->field)) { - throw new \Genesis\Exceptions\ErrorParameter("Property {$this->field} not found in API Request"); + throw new ErrorParameter("Property {$this->field} not found in API Request"); } $method = CommonUtils::snakeCaseToCamelCase($this->field); diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Validators/Request/RegexValidator.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Validators/Request/RegexValidator.php similarity index 87% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Validators/Request/RegexValidator.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Validators/Request/RegexValidator.php index d2e4697..2f16896 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/API/Validators/Request/RegexValidator.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Api/Validators/Request/RegexValidator.php @@ -1,4 +1,5 @@ context = new Builders\XML(); + $this->context = new Builders\Xml(); break; case self::JSON: - $this->context = new Builders\JSON(); + $this->context = new Builders\Json(); break; case self::FORM: - $this->context = new Builders\FORM(); + $this->context = new Builders\Form(); break; } } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Builders/FORM.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Builders/Form.php similarity index 95% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Builders/FORM.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Builders/Form.php index d600e39..6257e0e 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Builders/FORM.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Builders/Form.php @@ -1,4 +1,5 @@ output = json_encode($structure); } catch (\Exception $e) { - throw new \Genesis\Exceptions\InvalidArgument('Invalid data/tree'); + throw new InvalidArgument('Invalid data/tree'); } } } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Builders/XML.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Builders/Xml.php similarity index 95% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Builders/XML.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Builders/Xml.php index c4b4da9..a954e84 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Builders/XML.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Builders/Xml.php @@ -1,4 +1,5 @@ context = new \XMLWriter(); + $this->context = new XMLWriter(); $this->context->openMemory(); $this->context->startDocument('1.0', 'UTF-8'); @@ -73,7 +78,7 @@ public function __construct() public function populateNodes($data) { if (!\Genesis\Utils\Common::isValidArray($data)) { - throw new \Genesis\Exceptions\InvalidArgument('Invalid data structure'); + throw new InvalidArgument('Invalid data structure'); } // Ensure that the Array position is 0 diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Config.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Config.php index 9ad3688..673e297 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Config.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Config.php @@ -1,4 +1,5 @@ null, - 'username' => null, - 'password' => null, - 'token' => null, - 'environment' => \Genesis\API\Constants\Environments::STAGING + 'endpoint' => null, + 'username' => null, + 'password' => null, + 'token' => null, + 'environment' => \Genesis\Api\Constants\Environments::STAGING, + 'force_smart_routing' => false, + 'billing_api_token' => null ]; /** @@ -77,17 +87,21 @@ final class Config * @var array */ public static $domains = [ - 'gateway' => [ + 'gateway' => [ 'production' => 'gate.', 'sandbox' => 'staging.gate.' ], - 'wpf' => [ + 'wpf' => [ 'production' => 'wpf.', 'sandbox' => 'staging.wpf.' ], - 'kyc' => [ + 'kyc' => [ 'production' => 'kyc.', 'sandbox' => 'staging.kyc.' + ], + 'api_service' => [ + 'production' => 'prod.api.', + 'sandbox' => 'staging.api.' ] ]; @@ -101,9 +115,9 @@ final class Config */ public static function __callStatic($method, $args) { - $keySetting = strtolower(substr($method, 3)); + list($action, $keySetting) = CommonUtils::resolveDynamicMethod($method); - switch (substr($method, 0, 3)) { + switch ($action) { case 'get': if (isset(self::$vault[$keySetting])) { return self::$vault[$keySetting]; @@ -117,26 +131,6 @@ public static function __callStatic($method, $args) return null; } - /** - * Get the CA PEM - * - * @return string - Path to the Genesis CA Bundle; false otherwise - * - * @throws \Genesis\Exceptions\InvalidArgument - */ - public static function getCertificateBundle() - { - $bundle = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Certificates' . DIRECTORY_SEPARATOR . 'ca-bundle.pem'; - - if (!file_exists($bundle)) { - throw new \Genesis\Exceptions\InvalidArgument( - 'CA Bundle file is missing or inaccessible' - ); - } - - return $bundle; - } - /** * Get configuration for an interface * @@ -188,24 +182,24 @@ public static function getEnvironment() * @param string $environmentArg * @return string * - * @throws \Genesis\Exceptions\InvalidArgument + * @throws InvalidArgument */ public static function setEnvironment($environmentArg) { $environmentArg = strtolower(trim($environmentArg)); $aliases = [ - \Genesis\API\Constants\Environments::STAGING => [ + \Genesis\Api\Constants\Environments::STAGING => [ 'test', 'testing', 'staging', - \Genesis\API\Constants\Environments::STAGING + \Genesis\Api\Constants\Environments::STAGING ], - \Genesis\API\Constants\Environments::PRODUCTION => [ + \Genesis\Api\Constants\Environments::PRODUCTION => [ 'live', 'prod', 'production', - \Genesis\API\Constants\Environments::PRODUCTION + \Genesis\Api\Constants\Environments::PRODUCTION ] ]; @@ -217,7 +211,7 @@ public static function setEnvironment($environmentArg) } } - throw new \Genesis\Exceptions\InvalidArgument( + throw new InvalidArgument( 'Invalid Environment' ); } @@ -238,23 +232,23 @@ public static function getEndpoint() * @param string $endpointArg * @return string * - * @throws \Genesis\Exceptions\InvalidArgument + * @throws InvalidArgument */ public static function setEndpoint($endpointArg) { $endpointArg = strtolower(trim($endpointArg)); $aliases = [ - \Genesis\API\Constants\Endpoints::EMERCHANTPAY => [ + \Genesis\Api\Constants\Endpoints::EMERCHANTPAY => [ 'emp', 'emerchantpay', - \Genesis\API\Constants\Endpoints::EMERCHANTPAY + \Genesis\Api\Constants\Endpoints::EMERCHANTPAY ], - \Genesis\API\Constants\Endpoints::ECOMPROCESSING => [ + \Genesis\Api\Constants\Endpoints::ECOMPROCESSING => [ 'ecp', 'ecomprocessing', 'e-comprocessing', - \Genesis\API\Constants\Endpoints::ECOMPROCESSING + \Genesis\Api\Constants\Endpoints::ECOMPROCESSING ] ]; @@ -266,7 +260,7 @@ public static function setEndpoint($endpointArg) } } - throw new \Genesis\Exceptions\InvalidArgument( + throw new InvalidArgument( 'Invalid Endpoint' ); } @@ -312,17 +306,28 @@ public static function getVersion() return self::VERSION; } + /** + * Set Force Smart Routing endpoint for Financial types + * + * @param $value + * @return bool + */ + public static function setForceSmartRouting($value) + { + return self::$vault['force_smart_routing'] = CommonUtils::toBoolean($value); + } + /** * Load settings from an ini File * * @param string $iniFile Path to an ini file containing the settings * - * @throws \Genesis\Exceptions\InvalidArgument() + * @throws InvalidArgument() */ public static function loadSettings($iniFile) { if (!file_exists($iniFile)) { - throw new \Genesis\Exceptions\InvalidArgument( + throw new InvalidArgument( 'The provided configuration file is invalid or inaccessible!' ); } @@ -331,7 +336,9 @@ public static function loadSettings($iniFile) foreach ($settings['Genesis'] as $option => $value) { if (array_key_exists($option, self::$vault)) { - self::$vault[$option] = $value; + $method = 'set' . CommonUtils::snakeCaseToCamelCase($option); + + self::{$method}($value); } } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Exceptions/DeprecatedMethod.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Exceptions/DeprecatedMethod.php index 718ed17..e5426c2 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Exceptions/DeprecatedMethod.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Exceptions/DeprecatedMethod.php @@ -1,4 +1,5 @@ getMessage(); - - return 'Message: ' . (empty($message) ? 'Unknown error' : $message) . PHP_EOL . - 'Details: ' . \Genesis\API\Constants\Errors::getErrorDescription($this->getCode()); - } -} diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Exceptions/ErrorNetwork.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Exceptions/ErrorNetwork.php index fc0799f..0f73a8d 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Exceptions/ErrorNetwork.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Exceptions/ErrorNetwork.php @@ -1,4 +1,5 @@ getMessage()) ? $this->getMessage() : 'Unknown error during network request!'; } } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Exceptions/ErrorParameter.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Exceptions/ErrorParameter.php index 04ffb94..ed0fe05 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Exceptions/ErrorParameter.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Exceptions/ErrorParameter.php @@ -1,4 +1,5 @@ getMessage()) ? + $this->getMessage() : 'You\'re trying to call a non-existent method!' . PHP_EOL . 'For proper usage, please refer to the documentation!'; } } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Exceptions/InvalidResponse.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Exceptions/InvalidResponse.php index f654b0d..a3533b6 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Exceptions/InvalidResponse.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Exceptions/InvalidResponse.php @@ -1,4 +1,5 @@ context = new Network\cURL(); + $this->context = new Network\Curl(); break; case 'stream': $this->context = new Network\Stream(); @@ -92,7 +94,7 @@ public function getResponseHeaders() /** * Set Header/Body of the HTTP request * - * @param \Genesis\API\Request $apiContext + * @param \Genesis\Api\Request $apiContext * @throws Exceptions\ErrorParameter * @throws Exceptions\InvalidArgument * @throws Exceptions\InvalidClassMethod @@ -100,17 +102,20 @@ public function getResponseHeaders() public function setApiCtxData($apiContext) { $this->context->prepareRequestBody( - [ - 'body' => $apiContext->getDocument(), - 'url' => $apiContext->getApiConfig('url'), - 'type' => $apiContext->getApiConfig('type'), - 'port' => $apiContext->getApiConfig('port'), - 'protocol' => $apiContext->getApiConfig('protocol'), - 'format' => $apiContext->getApiConfig('format'), - 'timeout' => \Genesis\Config::getNetworkTimeout(), - 'user_agent' => sprintf('Genesis PHP Client v%s', \Genesis\Config::getVersion()), - 'user_login' => sprintf('%s:%s', \Genesis\Config::getUsername(), \Genesis\Config::getPassword()) - ] + array_merge( + [ + 'body' => $apiContext->getDocument(), + 'url' => $apiContext->getApiConfig('url'), + 'type' => $apiContext->getApiConfig('type'), + 'port' => $apiContext->getApiConfig('port'), + 'protocol' => $apiContext->getApiConfig('protocol'), + 'format' => $apiContext->getApiConfig('format'), + 'timeout' => \Genesis\Config::getNetworkTimeout(), + 'user_agent' => sprintf('Genesis PHP Client v%s', \Genesis\Config::getVersion()), + 'authorization' => $apiContext->getApiConfig('authorization') + ], + $this->setAuthCredentials($apiContext) + ) ); } @@ -121,4 +126,39 @@ public function sendRequest() { $this->context->execute(); } + + /** + * Get HTTP status + * + * @return mixed + */ + public function getStatus() + { + return $this->context->getStatus(); + } + + /** + * Determine the appropriate credentials based on the authorization type + * + * @param \Genesis\Api\Request $apiContext + * @return array + */ + protected function setAuthCredentials($apiContext) + { + switch ($apiContext->getApiConfig('authorization')) { + case \Genesis\Api\Request::AUTH_TYPE_TOKEN: + return [ + 'token' => $apiContext->getApiConfig('bearer_token') + ]; + break; + default: + return [ + 'user_login' => sprintf( + '%s:%s', + \Genesis\Config::getUsername(), + \Genesis\Config::getPassword() + ) + ]; + } + } } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Network/Base.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Network/Base.php index bafeac0..baff528 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Network/Base.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Network/Base.php @@ -1,4 +1,5 @@ $requestData['url'], CURLOPT_TIMEOUT => $requestData['timeout'], CURLOPT_USERAGENT => $requestData['user_agent'], - CURLOPT_USERPWD => $requestData['user_login'], - CURLOPT_HTTPAUTH => CURLAUTH_BASIC, CURLOPT_ENCODING => 'gzip', CURLOPT_HTTPHEADER => [ 'Content-Type: ' . $this->getRequestContentType($requestData['format']), + $this->authorization($requestData), // Workaround to prevent cURL from parsing HTTP 100 as separate request 'Expect:' ], CURLOPT_HEADER => true, - CURLOPT_FAILONERROR => true, CURLOPT_FRESH_CONNECT => true, CURLOPT_RETURNTRANSFER => true, // SSL/TLS Configuration @@ -134,7 +135,7 @@ public function checkForErrors() $errStr = curl_error($this->curlHandle); if ($errNo > 0) { - throw new \Genesis\Exceptions\ErrorNetwork($errStr, $errNo); + throw new ErrorNetwork($errStr, $errNo); } } @@ -160,4 +161,18 @@ public function getMethodOptionByType($type) return []; } } + + /** + * @param $requestData + * @return string + */ + protected function authorization($requestData) + { + switch ($requestData['authorization']) { + case Request::AUTH_TYPE_TOKEN: + return 'Authorization: Bearer ' . $requestData['token']; + default: + return 'Authorization: Basic ' . base64_encode($requestData['user_login']); + } + } } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Network/Stream.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Network/Stream.php index f0880f8..7c03155 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Network/Stream.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Network/Stream.php @@ -1,4 +1,5 @@ getRequestContentType($requestData['format']), - sprintf('Authorization: Basic %s', base64_encode($requestData['user_login'])), + $this->authorization($requestData), sprintf('Content-Length: %s', strlen($requestData['body'])), sprintf('User-Agent: %s', $requestData['user_agent']), ]; @@ -150,7 +155,7 @@ public static function processErrors($errNo, $errStr) // the handler. restore_error_handler(); - throw new \Genesis\Exceptions\ErrorNetwork($errStr, $errNo); + throw new ErrorNetwork($errStr, $errNo); } /** @@ -194,4 +199,19 @@ public static function getCiphers() '!SSLv3' ]; } + + /** + * @param $requestData + * @return string + */ + protected function authorization($requestData) + { + switch ($requestData['authorization']) { + case Request::AUTH_TYPE_TOKEN: + return sprintf('Authorization: Bearer %s', base64_encode($requestData['token'])); + break; + default: + return sprintf('Authorization: Basic %s', base64_encode($requestData['user_login'])); + } + } } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Parser.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Parser.php index 4df1179..df0f621 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Parser.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Parser.php @@ -1,4 +1,5 @@ context = new XML(); + $this->context = new Xml(); break; case self::JSON_INTERFACE: - $this->context = new JSON(); + $this->context = new Json(); break; } } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Parsers/JSON.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Parsers/Json.php similarity index 94% rename from admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Parsers/JSON.php rename to admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Parsers/Json.php index dab83fb..87e0638 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Parsers/JSON.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Parsers/Json.php @@ -1,4 +1,5 @@ stdClassObj = new stdClass(); + + return; + } + $hasAttributes = false; - $reader = new \XMLReader(); + $reader = new XMLReader(); $reader->XML($xmlDocument); if ($this->skipRootNode) { @@ -109,7 +120,7 @@ public function parseDocument($xmlDocument) */ public function readerLoop($reader, $processRootAttributes = false) { - $tree = new \stdClass(); + $tree = new stdClass(); if ($processRootAttributes === true) { $this->processNodeAttributes($reader, $tree); @@ -155,7 +166,7 @@ public function processElement(&$reader, &$tree) if (is_a($tree->$name, 'stdClass')) { $currentEl = $tree->$name; - $tree->$name = new \ArrayObject(); + $tree->$name = new ArrayObject(); $tree->$name->append($currentEl); } @@ -180,9 +191,9 @@ public function processAttributes(&$reader, &$tree) { $name = $reader->name; - $node = new \stdClass(); + $node = new stdClass(); - $node->attr = new \stdClass(); + $node->attr = new stdClass(); while ($reader->moveToNextAttribute()) { $node->attr->{$reader->name} = $reader->value; @@ -209,7 +220,7 @@ public function processAttributes(&$reader, &$tree) */ public function processNodeAttributes(&$reader, &$tree) { - $node = new \stdClass(); + $node = new stdClass(); while ($reader->moveToNextAttribute()) { $node->{$reader->name} = $reader->value; diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Utils/Common.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Utils/Common.php index 0f05df3..bc0ce70 100755 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Utils/Common.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Utils/Common.php @@ -1,4 +1,5 @@ isAbstract(); } @@ -400,7 +410,7 @@ public static function getClassConstants($className) return []; } - $reflection = new \ReflectionClass($className); + $reflection = new ReflectionClass($className); return $reflection->getConstants(); } @@ -471,7 +481,7 @@ public static function toBoolean($string) */ public static function removeMultipleKeys($arrayKeys, $arrayObject) { - if (!self::isValidArray($arrayKeys) || !$arrayObject instanceof \ArrayObject) { + if (!self::isValidArray($arrayKeys) || !$arrayObject instanceof ArrayObject) { throw new Exception(); } diff --git a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Utils/Country.php b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Utils/Country.php index 656bbcd..b55e0ff 100644 --- a/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Utils/Country.php +++ b/admin/model/extension/payment/ecomprocessing/genesis/src/Genesis/Utils/Country.php @@ -1,4 +1,5 @@ bootstrap($token); - $genesis = new \Genesis\Genesis( - \Genesis\API\Constants\Transaction\Types::getCaptureTransactionClass($type) + $genesis = new Genesis( + \Genesis\Api\Constants\Transaction\Types::getCaptureTransactionClass($type) ); $genesis @@ -326,7 +330,7 @@ public function capture($type, $reference_id, $amount, $currency, $usage, $order ->setAmount($amount) ->setCurrency($currency); - if ($type === \Genesis\API\Constants\Transaction\Types::KLARNA_AUTHORIZE) { + if ($type === \Genesis\Api\Constants\Transaction\Types::KLARNA_AUTHORIZE) { $genesis->request()->setItems($this->getKlarnaReferenceAttributes($currency, $order_id)); } @@ -358,8 +362,8 @@ public function refund($type, $reference_id, $amount, $currency, $usage = '', $t try { $this->bootstrap($token); - $genesis = new \Genesis\Genesis( - \Genesis\API\Constants\Transaction\Types::getRefundTransactionClass($type) + $genesis = new Genesis( + \Genesis\Api\Constants\Transaction\Types::getRefundTransactionClass($type) ); $genesis @@ -375,7 +379,7 @@ public function refund($type, $reference_id, $amount, $currency, $usage = '', $t ->setAmount($amount) ->setCurrency($currency); - if ($type === \Genesis\API\Constants\Transaction\Types::KLARNA_CAPTURE) { + if ($type === \Genesis\Api\Constants\Transaction\Types::KLARNA_CAPTURE) { $genesis->request()->setItems($this->getKlarnaReferenceAttributes($currency, $order_id)); } @@ -392,7 +396,7 @@ public function refund($type, $reference_id, $amount, $currency, $usage = '', $t /** * @param $currency * @param $order_id - * @return \Genesis\API\Request\Financial\Alternatives\Klarna\Items + * @return \Genesis\Api\Request\Financial\Alternatives\Klarna\Items * @throws \Genesis\Exceptions\ErrorParameter */ protected function getKlarnaReferenceAttributes($currency, $order_id) @@ -436,7 +440,7 @@ public function void($reference_id, $usage = '', $token = null) try { $this->bootstrap($token); - $genesis = new \Genesis\Genesis('Financial\Void'); + $genesis = new Genesis('Financial\Void'); $genesis ->request() @@ -472,43 +476,35 @@ public function getTransactionTypes() $this->load->language('extension/payment/ecomprocessing_checkout'); - $transaction_types = \Genesis\API\Constants\Transaction\Types::getWPFTransactionTypes(); + $transaction_types = \Genesis\Api\Constants\Transaction\Types::getWPFTransactionTypes(); $excluded_types = EcomprocessingHelper::getRecurringTransactionTypes(); // Exclude SDD Recurring - array_push($excluded_types, \Genesis\API\Constants\Transaction\Types::SDD_INIT_RECURRING_SALE); + array_push($excluded_types, \Genesis\Api\Constants\Transaction\Types::SDD_INIT_RECURRING_SALE); // Exclude PPRO transaction. This is not standalone transaction type - array_push($excluded_types, \Genesis\API\Constants\Transaction\Types::PPRO); + array_push($excluded_types, \Genesis\Api\Constants\Transaction\Types::PPRO); // Exclude GooglePay transaction. In this way Google Pay Payment types will be introduced - array_push($excluded_types, \Genesis\API\Constants\Transaction\Types::GOOGLE_PAY); + array_push($excluded_types, \Genesis\Api\Constants\Transaction\Types::GOOGLE_PAY); // Exclude PayPal transaction. In this way PayPal Payment types will be introduced - array_push($excluded_types, \Genesis\API\Constants\Transaction\Types::PAY_PAL); + array_push($excluded_types, \Genesis\Api\Constants\Transaction\Types::PAY_PAL); // Exclude Apple Pay transaction. This is not standalone transaction type - array_push($excluded_types, \Genesis\API\Constants\Transaction\Types::APPLE_PAY); + array_push($excluded_types, \Genesis\Api\Constants\Transaction\Types::APPLE_PAY); // Exclude Transaction Types $transaction_types = array_diff($transaction_types, $excluded_types); - // Add PPRO types - $ppro_types = array_map( - function ($type) { - return $type . EcomprocessingHelper::PPRO_TRANSACTION_SUFFIX; - }, - \Genesis\API\Constants\Payment\Methods::getMethods() - ); - // Add Google Payment types $google_pay_types = array_map( function ($type) { return EcomprocessingHelper::GOOGLE_PAY_TRANSACTION_PREFIX . $type; }, [ - \Genesis\API\Constants\Transaction\Parameters\Mobile\GooglePay\PaymentTypes::AUTHORIZE, - \Genesis\API\Constants\Transaction\Parameters\Mobile\GooglePay\PaymentTypes::SALE + \Genesis\Api\Constants\Transaction\Parameters\Mobile\GooglePay\PaymentTypes::AUTHORIZE, + \Genesis\Api\Constants\Transaction\Parameters\Mobile\GooglePay\PaymentTypes::SALE ] ); @@ -518,9 +514,9 @@ function ($type) { return EcomprocessingHelper::PAYPAL_TRANSACTION_PREFIX . $type; }, [ - \Genesis\API\Constants\Transaction\Parameters\Wallets\PayPal\PaymentTypes::AUTHORIZE, - \Genesis\API\Constants\Transaction\Parameters\Wallets\PayPal\PaymentTypes::SALE, - \Genesis\API\Constants\Transaction\Parameters\Wallets\PayPal\PaymentTypes::EXPRESS + \Genesis\Api\Constants\Transaction\Parameters\Wallets\PayPal\PaymentTypes::AUTHORIZE, + \Genesis\Api\Constants\Transaction\Parameters\Wallets\PayPal\PaymentTypes::SALE, + \Genesis\Api\Constants\Transaction\Parameters\Wallets\PayPal\PaymentTypes::EXPRESS ] ); @@ -530,14 +526,13 @@ function ($type) { return EcomprocessingHelper::APPLE_PAY_TRANSACTION_PREFIX . $type; }, [ - \Genesis\API\Constants\Transaction\Parameters\Mobile\ApplePay\PaymentTypes::AUTHORIZE, - \Genesis\API\Constants\Transaction\Parameters\Mobile\ApplePay\PaymentTypes::SALE + \Genesis\Api\Constants\Transaction\Parameters\Mobile\ApplePay\PaymentTypes::AUTHORIZE, + \Genesis\Api\Constants\Transaction\Parameters\Mobile\ApplePay\PaymentTypes::SALE ] ); $transaction_types = array_merge( $transaction_types, - $ppro_types, $google_pay_types, $paypal_types, $apple_pay_types @@ -548,8 +543,8 @@ function ($type) { $name = $this->language->get('text_transaction_' . $type); if (strpos($name, 'text_transaction') !== false) { - if (\Genesis\API\Constants\Transaction\Types::isValidTransactionType($type)) { - $name = \Genesis\API\Constants\Transaction\Names::getName($type); + if (\Genesis\Api\Constants\Transaction\Types::isValidTransactionType($type)) { + $name = \Genesis\Api\Constants\Transaction\Names::getName($type); } else { $name = strtoupper($type); } @@ -645,18 +640,18 @@ public function getRecurringTransactionTypes() $this->load->language('extension/payment/ecomprocessing_checkout'); return array( - \Genesis\API\Constants\Transaction\Types::INIT_RECURRING_SALE => array( - 'id' => \Genesis\API\Constants\Transaction\Types::INIT_RECURRING_SALE, + \Genesis\Api\Constants\Transaction\Types::INIT_RECURRING_SALE => array( + 'id' => \Genesis\Api\Constants\Transaction\Types::INIT_RECURRING_SALE, 'name' => $this->language->get( EcomprocessingHelper::TRANSACTION_LANGUAGE_PREFIX . - \Genesis\API\Constants\Transaction\Types::INIT_RECURRING_SALE + \Genesis\Api\Constants\Transaction\Types::INIT_RECURRING_SALE ) ), - \Genesis\API\Constants\Transaction\Types::INIT_RECURRING_SALE_3D => array( - 'id' => \Genesis\API\Constants\Transaction\Types::INIT_RECURRING_SALE_3D, + \Genesis\Api\Constants\Transaction\Types::INIT_RECURRING_SALE_3D => array( + 'id' => \Genesis\Api\Constants\Transaction\Types::INIT_RECURRING_SALE_3D, 'name' => $this->language->get( EcomprocessingHelper::TRANSACTION_LANGUAGE_PREFIX . - \Genesis\API\Constants\Transaction\Types::INIT_RECURRING_SALE_3D + \Genesis\Api\Constants\Transaction\Types::INIT_RECURRING_SALE_3D ) ), ); @@ -690,7 +685,7 @@ public function bootstrap($token = null) include DIR_APPLICATION . '/model/extension/payment/ecomprocessing/genesis/vendor/autoload.php'; \Genesis\Config::setEndpoint( - \Genesis\API\Constants\Endpoints::ECOMPROCESSING + \Genesis\Api\Constants\Endpoints::ECOMPROCESSING ); \Genesis\Config::setUsername( @@ -702,7 +697,7 @@ public function bootstrap($token = null) ); \Genesis\Config::setEnvironment( - $this->config->get('ecomprocessing_checkout_sandbox') ? \Genesis\API\Constants\Environments::STAGING : \Genesis\API\Constants\Environments::PRODUCTION + $this->config->get('ecomprocessing_checkout_sandbox') ? \Genesis\Api\Constants\Environments::STAGING : \Genesis\Api\Constants\Environments::PRODUCTION ); } @@ -730,6 +725,8 @@ public function logEx($exception) * @param $seen - array passed to recursive calls to accumulate trace lines already seen * leave as NULL when calling this function * @return array of strings, one entry per trace line + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) */ private function jTraceEx($exception, $seen = null) { diff --git a/admin/view/javascript/ecomprocessing/treegrid/js/jquery.treegrid.js b/admin/view/javascript/ecomprocessing/treegrid/js/jquery.treegrid.js index 1785e53..600f231 100644 --- a/admin/view/javascript/ecomprocessing/treegrid/js/jquery.treegrid.js +++ b/admin/view/javascript/ecomprocessing/treegrid/js/jquery.treegrid.js @@ -1,619 +1,619 @@ -/* - * jQuery treegrid Plugin 0.2.0 - * https://github.com/maxazan/jquery-treegrid - * - * Copyright 2013, Pomazan Max - * Licensed under the MIT licenses. - */ -(function($) { - - var methods = { - /** - * Initialize tree - * - * @param {Object} options - * @returns {Object[]} - */ - initTree: function(options) { - var settings = $.extend({}, this.treegrid.defaults, options); - return this.each(function() { - var $this = $(this); - $this.treegrid('setTreeContainer', $(this)); - $this.treegrid('setSettings', settings); - settings.getRootNodes.apply(this, [$(this)]).treegrid('initNode', settings); - }); - }, - /** - * Initialize node - * - * @param {Object} settings - * @returns {Object[]} - */ - initNode: function(settings) { - return this.each(function() { - var $this = $(this); - $this.treegrid('setTreeContainer', settings.getTreeGridContainer.apply(this)); - $this.treegrid('getChildNodes').treegrid('initNode', settings); - $this.treegrid('initExpander').treegrid('initIndent').treegrid('initEvents').treegrid('initState').treegrid("initSettingsEvents"); - }); - }, - /** - * Initialize node events - * - * @returns {Node} - */ - initEvents: function() { - var $this = $(this); - //Save state on change - $this.on("change", function() { - var $this = $(this); - $this.treegrid('render'); - if ($this.treegrid('getSetting', 'saveState')) { - $this.treegrid('saveState'); - } - }); - //Default behavior on collapse - $this.on("collapse", function() { - var $this = $(this); - $this.removeClass('treegrid-expanded'); - $this.addClass('treegrid-collapsed'); - }); - //Default behavior on expand - $this.on("expand", function() { - var $this = $(this); - $this.removeClass('treegrid-collapsed'); - $this.addClass('treegrid-expanded'); - }); - - return $this; - }, - /** - * Initialize events from settings - * - * @returns {Node} - */ - initSettingsEvents: function() { - var $this = $(this); - //Save state on change - $this.on("change", function() { - var $this = $(this); - if (typeof ($this.treegrid('getSetting', 'onChange')) === "function") { - $this.treegrid('getSetting', 'onChange').apply($this); - } - }); - //Default behavior on collapse - $this.on("collapse", function() { - var $this = $(this); - if (typeof ($this.treegrid('getSetting', 'onCollapse')) === "function") { - $this.treegrid('getSetting', 'onCollapse').apply($this); - } - }); - //Default behavior on expand - $this.on("expand", function() { - var $this = $(this); - if (typeof ($this.treegrid('getSetting', 'onExpand')) === "function") { - $this.treegrid('getSetting', 'onExpand').apply($this); - } - - }); - - return $this; - }, - /** - * Initialize expander for node - * - * @returns {Node} - */ - initExpander: function() { - var $this = $(this); - var cell = $this.find('td').get($this.treegrid('getSetting', 'treeColumn')); - var tpl = $this.treegrid('getSetting', 'expanderTemplate'); - var expander = $this.treegrid('getSetting', 'getExpander').apply(this); - if (expander) { - expander.remove(); - } - $(tpl).prependTo(cell).click(function() { - $($(this).closest('tr')).treegrid('toggle'); - }); - return $this; - }, - /** - * Initialize indent for node - * - * @returns {Node} - */ - initIndent: function() { - var $this = $(this); - $this.find('.treegrid-indent').remove(); - for (var i = 0; i < $(this).treegrid('getDepth'); i++) { - $($this.treegrid('getSetting', 'indentTemplate')).insertBefore($this.find('.treegrid-expander')); - } - return $this; - }, - /** - * Initialise state of node - * - * @returns {Node} - */ - initState: function() { - var $this = $(this); - if ($this.treegrid('getSetting', 'saveState') && !$this.treegrid('isFirstInit')) { - $this.treegrid('restoreState'); - } else { - if ($this.treegrid('getSetting', 'initialState') === "expanded") { - $this.treegrid('expand'); - } else { - $this.treegrid('collapse'); - } - } - return $this; - }, - /** - * Return true if this tree was never been initialised - * - * @returns {Boolean} - */ - isFirstInit: function() { - var tree = $(this).treegrid('getTreeContainer'); - if (tree.data('first_init') === undefined) { - tree.data('first_init', $.cookie(tree.treegrid('getSetting', 'saveStateName')) === undefined); - } - return tree.data('first_init'); - }, - /** - * Save state of current node - * - * @returns {Node} - */ - saveState: function() { - var $this = $(this); - if ($this.treegrid('getSetting', 'saveStateMethod') === 'cookie') { - - var stateArrayString = $.cookie($this.treegrid('getSetting', 'saveStateName')) || ''; - var stateArray = (stateArrayString === '' ? [] : stateArrayString.split(',')); - var nodeId = $this.treegrid('getNodeId'); - - if ($this.treegrid('isExpanded')) { - if ($.inArray(nodeId, stateArray) === -1) { - stateArray.push(nodeId); - } - } else if ($this.treegrid('isCollapsed')) { - if ($.inArray(nodeId, stateArray) !== -1) { - stateArray.splice($.inArray(nodeId, stateArray), 1); - } - } - $.cookie($this.treegrid('getSetting', 'saveStateName'), stateArray.join(',')); - } - return $this; - }, - /** - * Restore state of current node. - * - * @returns {Node} - */ - restoreState: function() { - var $this = $(this); - if ($this.treegrid('getSetting', 'saveStateMethod') === 'cookie') { - var stateArray = $.cookie($this.treegrid('getSetting', 'saveStateName')).split(','); - if ($.inArray($this.treegrid('getNodeId'), stateArray) !== -1) { - $this.treegrid('expand'); - } else { - $this.treegrid('collapse'); - } - - } - return $this; - }, - /** - * Method return setting by name - * - * @param {type} name - * @returns {unresolved} - */ - getSetting: function(name) { - if (!$(this).treegrid('getTreeContainer')) { - return null; - } - return $(this).treegrid('getTreeContainer').data('settings')[name]; - }, - /** - * Add new settings - * - * @param {Object} settings - */ - setSettings: function(settings) { - $(this).treegrid('getTreeContainer').data('settings', settings); - }, - /** - * Return tree container - * - * @returns {HtmlElement} - */ - getTreeContainer: function() { - return $(this).data('treegrid'); - }, - /** - * Set tree container - * - * @param {HtmlE;ement} container - */ - setTreeContainer: function(container) { - return $(this).data('treegrid', container); - }, - /** - * Method return all root nodes of tree. - * - * Start init all child nodes from it. - * - * @returns {Array} - */ - getRootNodes: function() { - return $(this).treegrid('getSetting', 'getRootNodes').apply(this, [$(this).treegrid('getTreeContainer')]); - }, - /** - * Method return all nodes of tree. - * - * @returns {Array} - */ - getAllNodes: function() { - return $(this).treegrid('getSetting', 'getAllNodes').apply(this, [$(this).treegrid('getTreeContainer')]); - }, - /** - * Mthod return true if element is Node - * - * @returns {String} - */ - isNode: function() { - return $(this).treegrid('getNodeId') !== null; - }, - /** - * Mthod return id of node - * - * @returns {String} - */ - getNodeId: function() { - if ($(this).treegrid('getSetting', 'getNodeId') === null) { - return null; - } else { - return $(this).treegrid('getSetting', 'getNodeId').apply(this); - } - }, - /** - * Method return parent id of node or null if root node - * - * @returns {String} - */ - getParentNodeId: function() { - return $(this).treegrid('getSetting', 'getParentNodeId').apply(this); - }, - /** - * Method return parent node or null if root node - * - * @returns {Object[]} - */ - getParentNode: function() { - if ($(this).treegrid('getParentNodeId') === null) { - return null; - } else { - return $(this).treegrid('getSetting', 'getNodeById').apply(this, [$(this).treegrid('getParentNodeId'), $(this).treegrid('getTreeContainer')]); - } - }, - /** - * Method return array of child nodes or null if node is leaf - * - * @returns {Object[]} - */ - getChildNodes: function() { - return $(this).treegrid('getSetting', 'getChildNodes').apply(this, [$(this).treegrid('getNodeId'), $(this).treegrid('getTreeContainer')]); - }, - /** - * Method return depth of tree. - * - * This method is needs for calculate indent - * - * @returns {Number} - */ - getDepth: function() { - if ($(this).treegrid('getParentNode') === null) { - return 0; - } - return $(this).treegrid('getParentNode').treegrid('getDepth') + 1; - }, - /** - * Method return true if node is root - * - * @returns {Boolean} - */ - isRoot: function() { - return $(this).treegrid('getDepth') === 0; - }, - /** - * Method return true if node has no child nodes - * - * @returns {Boolean} - */ - isLeaf: function() { - return $(this).treegrid('getChildNodes').length === 0; - }, - /** - * Method return true if node last in branch - * - * @returns {Boolean} - */ - isLast: function() { - if ($(this).treegrid('isNode')) { - var parentNode = $(this).treegrid('getParentNode'); - if (parentNode === null) { - if ($(this).treegrid('getNodeId') === $(this).treegrid('getRootNodes').last().treegrid('getNodeId')) { - return true; - } - } else { - if ($(this).treegrid('getNodeId') === parentNode.treegrid('getChildNodes').last().treegrid('getNodeId')) { - return true; - } - } - } - return false; - }, - /** - * Method return true if node first in branch - * - * @returns {Boolean} - */ - isFirst: function() { - if ($(this).treegrid('isNode')) { - var parentNode = $(this).treegrid('getParentNode'); - if (parentNode === null) { - if ($(this).treegrid('getNodeId') === $(this).treegrid('getRootNodes').first().treegrid('getNodeId')) { - return true; - } - } else { - if ($(this).treegrid('getNodeId') === parentNode.treegrid('getChildNodes').first().treegrid('getNodeId')) { - return true; - } - } - } - return false; - }, - /** - * Return true if node expanded - * - * @returns {Boolean} - */ - isExpanded: function() { - return $(this).hasClass('treegrid-expanded'); - }, - /** - * Return true if node collapsed - * - * @returns {Boolean} - */ - isCollapsed: function() { - return $(this).hasClass('treegrid-collapsed'); - }, - /** - * Return true if at least one of parent node is collapsed - * - * @returns {Boolean} - */ - isOneOfParentsCollapsed: function() { - var $this = $(this); - if ($this.treegrid('isRoot')) { - return false; - } else { - if ($this.treegrid('getParentNode').treegrid('isCollapsed')) { - return true; - } else { - return $this.treegrid('getParentNode').treegrid('isOneOfParentsCollapsed'); - } - } - }, - /** - * Expand node - * - * @returns {Node} - */ - expand: function() { - return $(this).each(function() { - var $this = $(this); - if (!$this.treegrid('isLeaf') && !$this.treegrid("isExpanded")) { - $this.trigger("expand"); - $this.trigger("change"); - } - }); - }, - /** - * Expand all nodes - * - * @returns {Node} - */ - expandAll: function() { - var $this = $(this); - $this.treegrid('getRootNodes').treegrid('expandRecursive'); - return $this; - }, - /** - * Expand current node and all child nodes begin from current - * - * @returns {Node} - */ - expandRecursive: function() { - return $(this).each(function() { - var $this = $(this); - $this.treegrid('expand'); - if (!$this.treegrid('isLeaf')) { - $this.treegrid('getChildNodes').treegrid('expandRecursive'); - } - }); - }, - /** - * Collapse node - * - * @returns {Node} - */ - collapse: function() { - return $(this).each(function() { - var $this = $(this); - if (!$this.treegrid('isLeaf') && !$this.treegrid("isCollapsed")) { - $this.trigger("collapse"); - $this.trigger("change"); - } - }); - }, - /** - * Collapse all nodes - * - * @returns {Node} - */ - collapseAll: function() { - var $this = $(this); - $this.treegrid('getRootNodes').treegrid('collapseRecursive'); - return $this; - }, - /** - * Collapse current node and all child nodes begin from current - * - * @returns {Node} - */ - collapseRecursive: function() { - return $(this).each(function() { - var $this = $(this); - $this.treegrid('collapse'); - if (!$this.treegrid('isLeaf')) { - $this.treegrid('getChildNodes').treegrid('collapseRecursive'); - } - }); - }, - /** - * Expand if collapsed, Collapse if expanded - * - * @returns {Node} - */ - toggle: function() { - var $this = $(this); - if ($this.treegrid('isExpanded')) { - $this.treegrid('collapse'); - } else { - $this.treegrid('expand'); - } - return $this; - }, - /** - * Rendering node - * - * @returns {Node} - */ - render: function() { - return $(this).each(function() { - var $this = $(this); - - if ($this.treegrid('isOneOfParentsCollapsed')) { - $this.hide(); - } else { - $this.show(); - } - if (!$this.treegrid('isLeaf')) { - $this.treegrid('renderExpander'); - $this.treegrid('getChildNodes').treegrid('render'); - } - }); - }, - /** - * Rendering expander depends on node state - * - * @returns {Node} - */ - renderExpander: function() { - return $(this).each(function() { - var $this = $(this); - var expander = $this.treegrid('getSetting', 'getExpander').apply(this); - if (expander) { - - if (!$this.treegrid('isCollapsed')) { - expander.removeClass($this.treegrid('getSetting', 'expanderCollapsedClass')); - expander.addClass($this.treegrid('getSetting', 'expanderExpandedClass')); - } else { - expander.removeClass($this.treegrid('getSetting', 'expanderExpandedClass')); - expander.addClass($this.treegrid('getSetting', 'expanderCollapsedClass')); - } - } else { - $this.treegrid('initExpander'); - $this.treegrid('renderExpander'); - } - }); - } - }; - $.fn.treegrid = function(method) { - if (methods[method]) { - return methods[ method ].apply(this, Array.prototype.slice.call(arguments, 1)); - } else if (typeof method === 'object' || !method) { - return methods.initTree.apply(this, arguments); - } else { - $.error('Method with name ' + method + ' does not exists for jQuery.treegrid'); - } - }; - /** - * Plugin's default options - */ - $.fn.treegrid.defaults = { - initialState: 'expanded', - saveState: false, - saveStateMethod: 'cookie', - saveStateName: 'tree-grid-state', - expanderTemplate: '', - indentTemplate: '', - expanderExpandedClass: 'treegrid-expander-expanded', - expanderCollapsedClass: 'treegrid-expander-collapsed', - treeColumn: 0, - getExpander: function() { - return $(this).find('.treegrid-expander'); - }, - getNodeId: function() { - var template = /treegrid-([A-Za-z0-9_-]+)/; - if (template.test($(this).attr('class'))) { - return template.exec($(this).attr('class'))[1]; - } - return null; - }, - getParentNodeId: function() { - var template = /treegrid-parent-([A-Za-z0-9_-]+)/; - if (template.test($(this).attr('class'))) { - return template.exec($(this).attr('class'))[1]; - } - return null; - }, - getNodeById: function(id, treegridContainer) { - var templateClass = "treegrid-" + id; - return treegridContainer.find('tr.' + templateClass); - }, - getChildNodes: function(id, treegridContainer) { - var templateClass = "treegrid-parent-" + id; - return treegridContainer.find('tr.' + templateClass); - }, - getTreeGridContainer: function() { - return $(this).closest('table'); - }, - getRootNodes: function(treegridContainer) { - var result = $.grep(treegridContainer.find('tr'), function(element) { - var classNames = $(element).attr('class'); - var templateClass = /treegrid-([A-Za-z0-9_-]+)/; - var templateParentClass = /treegrid-parent-([A-Za-z0-9_-]+)/; - return templateClass.test(classNames) && !templateParentClass.test(classNames); - }); - return $(result); - }, - getAllNodes: function(treegridContainer) { - var result = $.grep(treegridContainer.find('tr'), function(element) { - var classNames = $(element).attr('class'); - var templateClass = /treegrid-([A-Za-z0-9_-]+)/; - return templateClass.test(classNames); - }); - return $(result); - }, - //Events - onCollapse: null, - onExpand: null, - onChange: null - - }; +/* + * jQuery treegrid Plugin 0.2.0 + * https://github.com/maxazan/jquery-treegrid + * + * Copyright 2013, Pomazan Max + * Licensed under the MIT licenses. + */ +(function($) { + + var methods = { + /** + * Initialize tree + * + * @param {Object} options + * @returns {Object[]} + */ + initTree: function(options) { + var settings = $.extend({}, this.treegrid.defaults, options); + return this.each(function() { + var $this = $(this); + $this.treegrid('setTreeContainer', $(this)); + $this.treegrid('setSettings', settings); + settings.getRootNodes.apply(this, [$(this)]).treegrid('initNode', settings); + }); + }, + /** + * Initialize node + * + * @param {Object} settings + * @returns {Object[]} + */ + initNode: function(settings) { + return this.each(function() { + var $this = $(this); + $this.treegrid('setTreeContainer', settings.getTreeGridContainer.apply(this)); + $this.treegrid('getChildNodes').treegrid('initNode', settings); + $this.treegrid('initExpander').treegrid('initIndent').treegrid('initEvents').treegrid('initState').treegrid("initSettingsEvents"); + }); + }, + /** + * Initialize node events + * + * @returns {Node} + */ + initEvents: function() { + var $this = $(this); + //Save state on change + $this.on("change", function() { + var $this = $(this); + $this.treegrid('render'); + if ($this.treegrid('getSetting', 'saveState')) { + $this.treegrid('saveState'); + } + }); + //Default behavior on collapse + $this.on("collapse", function() { + var $this = $(this); + $this.removeClass('treegrid-expanded'); + $this.addClass('treegrid-collapsed'); + }); + //Default behavior on expand + $this.on("expand", function() { + var $this = $(this); + $this.removeClass('treegrid-collapsed'); + $this.addClass('treegrid-expanded'); + }); + + return $this; + }, + /** + * Initialize events from settings + * + * @returns {Node} + */ + initSettingsEvents: function() { + var $this = $(this); + //Save state on change + $this.on("change", function() { + var $this = $(this); + if (typeof ($this.treegrid('getSetting', 'onChange')) === "function") { + $this.treegrid('getSetting', 'onChange').apply($this); + } + }); + //Default behavior on collapse + $this.on("collapse", function() { + var $this = $(this); + if (typeof ($this.treegrid('getSetting', 'onCollapse')) === "function") { + $this.treegrid('getSetting', 'onCollapse').apply($this); + } + }); + //Default behavior on expand + $this.on("expand", function() { + var $this = $(this); + if (typeof ($this.treegrid('getSetting', 'onExpand')) === "function") { + $this.treegrid('getSetting', 'onExpand').apply($this); + } + + }); + + return $this; + }, + /** + * Initialize expander for node + * + * @returns {Node} + */ + initExpander: function() { + var $this = $(this); + var cell = $this.find('td').get($this.treegrid('getSetting', 'treeColumn')); + var tpl = $this.treegrid('getSetting', 'expanderTemplate'); + var expander = $this.treegrid('getSetting', 'getExpander').apply(this); + if (expander) { + expander.remove(); + } + $(tpl).prependTo(cell).click(function() { + $($(this).closest('tr')).treegrid('toggle'); + }); + return $this; + }, + /** + * Initialize indent for node + * + * @returns {Node} + */ + initIndent: function() { + var $this = $(this); + $this.find('.treegrid-indent').remove(); + for (var i = 0; i < $(this).treegrid('getDepth'); i++) { + $($this.treegrid('getSetting', 'indentTemplate')).insertBefore($this.find('.treegrid-expander')); + } + return $this; + }, + /** + * Initialise state of node + * + * @returns {Node} + */ + initState: function() { + var $this = $(this); + if ($this.treegrid('getSetting', 'saveState') && !$this.treegrid('isFirstInit')) { + $this.treegrid('restoreState'); + } else { + if ($this.treegrid('getSetting', 'initialState') === "expanded") { + $this.treegrid('expand'); + } else { + $this.treegrid('collapse'); + } + } + return $this; + }, + /** + * Return true if this tree was never been initialised + * + * @returns {Boolean} + */ + isFirstInit: function() { + var tree = $(this).treegrid('getTreeContainer'); + if (tree.data('first_init') === undefined) { + tree.data('first_init', $.cookie(tree.treegrid('getSetting', 'saveStateName')) === undefined); + } + return tree.data('first_init'); + }, + /** + * Save state of current node + * + * @returns {Node} + */ + saveState: function() { + var $this = $(this); + if ($this.treegrid('getSetting', 'saveStateMethod') === 'cookie') { + + var stateArrayString = $.cookie($this.treegrid('getSetting', 'saveStateName')) || ''; + var stateArray = (stateArrayString === '' ? [] : stateArrayString.split(',')); + var nodeId = $this.treegrid('getNodeId'); + + if ($this.treegrid('isExpanded')) { + if ($.inArray(nodeId, stateArray) === -1) { + stateArray.push(nodeId); + } + } else if ($this.treegrid('isCollapsed')) { + if ($.inArray(nodeId, stateArray) !== -1) { + stateArray.splice($.inArray(nodeId, stateArray), 1); + } + } + $.cookie($this.treegrid('getSetting', 'saveStateName'), stateArray.join(',')); + } + return $this; + }, + /** + * Restore state of current node. + * + * @returns {Node} + */ + restoreState: function() { + var $this = $(this); + if ($this.treegrid('getSetting', 'saveStateMethod') === 'cookie') { + var stateArray = $.cookie($this.treegrid('getSetting', 'saveStateName')).split(','); + if ($.inArray($this.treegrid('getNodeId'), stateArray) !== -1) { + $this.treegrid('expand'); + } else { + $this.treegrid('collapse'); + } + + } + return $this; + }, + /** + * Method return setting by name + * + * @param {type} name + * @returns {unresolved} + */ + getSetting: function(name) { + if (!$(this).treegrid('getTreeContainer')) { + return null; + } + return $(this).treegrid('getTreeContainer').data('settings')[name]; + }, + /** + * Add new settings + * + * @param {Object} settings + */ + setSettings: function(settings) { + $(this).treegrid('getTreeContainer').data('settings', settings); + }, + /** + * Return tree container + * + * @returns {HtmlElement} + */ + getTreeContainer: function() { + return $(this).data('treegrid'); + }, + /** + * Set tree container + * + * @param {HtmlE;ement} container + */ + setTreeContainer: function(container) { + return $(this).data('treegrid', container); + }, + /** + * Method return all root nodes of tree. + * + * Start init all child nodes from it. + * + * @returns {Array} + */ + getRootNodes: function() { + return $(this).treegrid('getSetting', 'getRootNodes').apply(this, [$(this).treegrid('getTreeContainer')]); + }, + /** + * Method return all nodes of tree. + * + * @returns {Array} + */ + getAllNodes: function() { + return $(this).treegrid('getSetting', 'getAllNodes').apply(this, [$(this).treegrid('getTreeContainer')]); + }, + /** + * Mthod return true if element is Node + * + * @returns {String} + */ + isNode: function() { + return $(this).treegrid('getNodeId') !== null; + }, + /** + * Mthod return id of node + * + * @returns {String} + */ + getNodeId: function() { + if ($(this).treegrid('getSetting', 'getNodeId') === null) { + return null; + } else { + return $(this).treegrid('getSetting', 'getNodeId').apply(this); + } + }, + /** + * Method return parent id of node or null if root node + * + * @returns {String} + */ + getParentNodeId: function() { + return $(this).treegrid('getSetting', 'getParentNodeId').apply(this); + }, + /** + * Method return parent node or null if root node + * + * @returns {Object[]} + */ + getParentNode: function() { + if ($(this).treegrid('getParentNodeId') === null) { + return null; + } else { + return $(this).treegrid('getSetting', 'getNodeById').apply(this, [$(this).treegrid('getParentNodeId'), $(this).treegrid('getTreeContainer')]); + } + }, + /** + * Method return array of child nodes or null if node is leaf + * + * @returns {Object[]} + */ + getChildNodes: function() { + return $(this).treegrid('getSetting', 'getChildNodes').apply(this, [$(this).treegrid('getNodeId'), $(this).treegrid('getTreeContainer')]); + }, + /** + * Method return depth of tree. + * + * This method is needs for calculate indent + * + * @returns {Number} + */ + getDepth: function() { + if ($(this).treegrid('getParentNode') === null) { + return 0; + } + return $(this).treegrid('getParentNode').treegrid('getDepth') + 1; + }, + /** + * Method return true if node is root + * + * @returns {Boolean} + */ + isRoot: function() { + return $(this).treegrid('getDepth') === 0; + }, + /** + * Method return true if node has no child nodes + * + * @returns {Boolean} + */ + isLeaf: function() { + return $(this).treegrid('getChildNodes').length === 0; + }, + /** + * Method return true if node last in branch + * + * @returns {Boolean} + */ + isLast: function() { + if ($(this).treegrid('isNode')) { + var parentNode = $(this).treegrid('getParentNode'); + if (parentNode === null) { + if ($(this).treegrid('getNodeId') === $(this).treegrid('getRootNodes').last().treegrid('getNodeId')) { + return true; + } + } else { + if ($(this).treegrid('getNodeId') === parentNode.treegrid('getChildNodes').last().treegrid('getNodeId')) { + return true; + } + } + } + return false; + }, + /** + * Method return true if node first in branch + * + * @returns {Boolean} + */ + isFirst: function() { + if ($(this).treegrid('isNode')) { + var parentNode = $(this).treegrid('getParentNode'); + if (parentNode === null) { + if ($(this).treegrid('getNodeId') === $(this).treegrid('getRootNodes').first().treegrid('getNodeId')) { + return true; + } + } else { + if ($(this).treegrid('getNodeId') === parentNode.treegrid('getChildNodes').first().treegrid('getNodeId')) { + return true; + } + } + } + return false; + }, + /** + * Return true if node expanded + * + * @returns {Boolean} + */ + isExpanded: function() { + return $(this).hasClass('treegrid-expanded'); + }, + /** + * Return true if node collapsed + * + * @returns {Boolean} + */ + isCollapsed: function() { + return $(this).hasClass('treegrid-collapsed'); + }, + /** + * Return true if at least one of parent node is collapsed + * + * @returns {Boolean} + */ + isOneOfParentsCollapsed: function() { + var $this = $(this); + if ($this.treegrid('isRoot')) { + return false; + } else { + if ($this.treegrid('getParentNode').treegrid('isCollapsed')) { + return true; + } else { + return $this.treegrid('getParentNode').treegrid('isOneOfParentsCollapsed'); + } + } + }, + /** + * Expand node + * + * @returns {Node} + */ + expand: function() { + return $(this).each(function() { + var $this = $(this); + if (!$this.treegrid('isLeaf') && !$this.treegrid("isExpanded")) { + $this.trigger("expand"); + $this.trigger("change"); + } + }); + }, + /** + * Expand all nodes + * + * @returns {Node} + */ + expandAll: function() { + var $this = $(this); + $this.treegrid('getRootNodes').treegrid('expandRecursive'); + return $this; + }, + /** + * Expand current node and all child nodes begin from current + * + * @returns {Node} + */ + expandRecursive: function() { + return $(this).each(function() { + var $this = $(this); + $this.treegrid('expand'); + if (!$this.treegrid('isLeaf')) { + $this.treegrid('getChildNodes').treegrid('expandRecursive'); + } + }); + }, + /** + * Collapse node + * + * @returns {Node} + */ + collapse: function() { + return $(this).each(function() { + var $this = $(this); + if (!$this.treegrid('isLeaf') && !$this.treegrid("isCollapsed")) { + $this.trigger("collapse"); + $this.trigger("change"); + } + }); + }, + /** + * Collapse all nodes + * + * @returns {Node} + */ + collapseAll: function() { + var $this = $(this); + $this.treegrid('getRootNodes').treegrid('collapseRecursive'); + return $this; + }, + /** + * Collapse current node and all child nodes begin from current + * + * @returns {Node} + */ + collapseRecursive: function() { + return $(this).each(function() { + var $this = $(this); + $this.treegrid('collapse'); + if (!$this.treegrid('isLeaf')) { + $this.treegrid('getChildNodes').treegrid('collapseRecursive'); + } + }); + }, + /** + * Expand if collapsed, Collapse if expanded + * + * @returns {Node} + */ + toggle: function() { + var $this = $(this); + if ($this.treegrid('isExpanded')) { + $this.treegrid('collapse'); + } else { + $this.treegrid('expand'); + } + return $this; + }, + /** + * Rendering node + * + * @returns {Node} + */ + render: function() { + return $(this).each(function() { + var $this = $(this); + + if ($this.treegrid('isOneOfParentsCollapsed')) { + $this.hide(); + } else { + $this.show(); + } + if (!$this.treegrid('isLeaf')) { + $this.treegrid('renderExpander'); + $this.treegrid('getChildNodes').treegrid('render'); + } + }); + }, + /** + * Rendering expander depends on node state + * + * @returns {Node} + */ + renderExpander: function() { + return $(this).each(function() { + var $this = $(this); + var expander = $this.treegrid('getSetting', 'getExpander').apply(this); + if (expander) { + + if (!$this.treegrid('isCollapsed')) { + expander.removeClass($this.treegrid('getSetting', 'expanderCollapsedClass')); + expander.addClass($this.treegrid('getSetting', 'expanderExpandedClass')); + } else { + expander.removeClass($this.treegrid('getSetting', 'expanderExpandedClass')); + expander.addClass($this.treegrid('getSetting', 'expanderCollapsedClass')); + } + } else { + $this.treegrid('initExpander'); + $this.treegrid('renderExpander'); + } + }); + } + }; + $.fn.treegrid = function(method) { + if (methods[method]) { + return methods[ method ].apply(this, Array.prototype.slice.call(arguments, 1)); + } else if (typeof method === 'object' || !method) { + return methods.initTree.apply(this, arguments); + } else { + $.error('Method with name ' + method + ' does not exists for jQuery.treegrid'); + } + }; + /** + * Plugin's default options + */ + $.fn.treegrid.defaults = { + initialState: 'expanded', + saveState: false, + saveStateMethod: 'cookie', + saveStateName: 'tree-grid-state', + expanderTemplate: '', + indentTemplate: '', + expanderExpandedClass: 'treegrid-expander-expanded', + expanderCollapsedClass: 'treegrid-expander-collapsed', + treeColumn: 0, + getExpander: function() { + return $(this).find('.treegrid-expander'); + }, + getNodeId: function() { + var template = /treegrid-([A-Za-z0-9_-]+)/; + if (template.test($(this).attr('class'))) { + return template.exec($(this).attr('class'))[1]; + } + return null; + }, + getParentNodeId: function() { + var template = /treegrid-parent-([A-Za-z0-9_-]+)/; + if (template.test($(this).attr('class'))) { + return template.exec($(this).attr('class'))[1]; + } + return null; + }, + getNodeById: function(id, treegridContainer) { + var templateClass = "treegrid-" + id; + return treegridContainer.find('tr.' + templateClass); + }, + getChildNodes: function(id, treegridContainer) { + var templateClass = "treegrid-parent-" + id; + return treegridContainer.find('tr.' + templateClass); + }, + getTreeGridContainer: function() { + return $(this).closest('table'); + }, + getRootNodes: function(treegridContainer) { + var result = $.grep(treegridContainer.find('tr'), function(element) { + var classNames = $(element).attr('class'); + var templateClass = /treegrid-([A-Za-z0-9_-]+)/; + var templateParentClass = /treegrid-parent-([A-Za-z0-9_-]+)/; + return templateClass.test(classNames) && !templateParentClass.test(classNames); + }); + return $(result); + }, + getAllNodes: function(treegridContainer) { + var result = $.grep(treegridContainer.find('tr'), function(element) { + var classNames = $(element).attr('class'); + var templateClass = /treegrid-([A-Za-z0-9_-]+)/; + return templateClass.test(classNames); + }); + return $(result); + }, + //Events + onCollapse: null, + onExpand: null, + onChange: null + + }; })(jQuery); \ No newline at end of file diff --git a/catalog/controller/extension/payment/ecomprocessing/EcomprocessingThreedsHelper.php b/catalog/controller/extension/payment/ecomprocessing/EcomprocessingThreedsHelper.php index 2f1274b..463f30c 100644 --- a/catalog/controller/extension/payment/ecomprocessing/EcomprocessingThreedsHelper.php +++ b/catalog/controller/extension/payment/ecomprocessing/EcomprocessingThreedsHelper.php @@ -21,10 +21,10 @@ require DIR_APPLICATION . '/../admin/model/extension/payment/ecomprocessing/genesis/vendor/autoload.php'; } -use Genesis\API\Constants\Transaction\Parameters\Threeds\V2\CardHolderAccount\ShippingAddressUsageIndicators; -use Genesis\API\Constants\Transaction\Parameters\Threeds\V2\CardHolderAccount\RegistrationIndicators; -use Genesis\API\Constants\Transaction\Parameters\Threeds\V2\MerchantRisk\ReorderItemIndicators; -use Genesis\API\Constants\Transaction\Parameters\Threeds\V2\MerchantRisk\ShippingIndicators; +use Genesis\Api\Constants\Transaction\Parameters\Threeds\V2\CardHolderAccount\ShippingAddressUsageIndicators; +use Genesis\Api\Constants\Transaction\Parameters\Threeds\V2\CardHolderAccount\RegistrationIndicators; +use Genesis\Api\Constants\Transaction\Parameters\Threeds\V2\MerchantRisk\ReorderItemIndicators; +use Genesis\Api\Constants\Transaction\Parameters\Threeds\V2\MerchantRisk\ShippingIndicators; use Genesis\Utils\Common as CommonUtils; /** diff --git a/catalog/controller/extension/payment/ecomprocessing/base_controller.php b/catalog/controller/extension/payment/ecomprocessing/base_controller.php index 6ca7886..17e125c 100644 --- a/catalog/controller/extension/payment/ecomprocessing/base_controller.php +++ b/catalog/controller/extension/payment/ecomprocessing/base_controller.php @@ -21,6 +21,7 @@ * Base Abstract Class for Method Front Controllers * * Class ControllerExtensionPaymentEcomprocessingBase + * @SuppressWarnings(PHPMD.LongClassName) */ abstract class ControllerExtensionPaymentEcomprocessingBase extends Controller { diff --git a/catalog/controller/extension/payment/ecomprocessing_checkout.php b/catalog/controller/extension/payment/ecomprocessing_checkout.php index a8811c2..3aa3a27 100644 --- a/catalog/controller/extension/payment/ecomprocessing_checkout.php +++ b/catalog/controller/extension/payment/ecomprocessing_checkout.php @@ -17,9 +17,10 @@ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License, version 2 (GPL-2.0) */ -use Genesis\API\Constants\Transaction\Parameters\Threeds\V2\CardHolderAccount\RegistrationIndicators; -use Genesis\API\Constants\Transaction\Parameters\Threeds\V2\MerchantRisk\DeliveryTimeframes; -use Genesis\API\Constants\Transaction\Parameters\Threeds\V2\Purchase\Categories; +use Genesis\Api\Constants\Transaction\Parameters\Threeds\V2\CardHolderAccount\RegistrationIndicators; +use Genesis\Api\Constants\Transaction\Parameters\Threeds\V2\MerchantRisk\DeliveryTimeframes; +use Genesis\Api\Constants\Transaction\Parameters\Threeds\V2\Purchase\Categories; +use Genesis\Api\Notification; if (!class_exists('ControllerExtensionPaymentEcomprocessingBase')) { require_once DIR_APPLICATION . "controller/extension/payment/ecomprocessing/base_controller.php"; @@ -31,6 +32,8 @@ * @package EcomprocessingCheckout * * @SuppressWarnings(PHPMD.LongVariable) + * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) + * @SuppressWarnings(PHPMD.LongClassName) */ class ControllerExtensionPaymentEcomprocessingCheckout extends ControllerExtensionPaymentEcomprocessingBase { @@ -125,6 +128,9 @@ public function prepareViewDataMixedCart() * @return void * * @SuppressWarnings(PHPMD.LongVariable) + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function send() { @@ -174,6 +180,7 @@ function ($value) { $customer_orders ); $threeds_registration_indicator = RegistrationIndicators::GUEST_CHECKOUT; + $threeds_registration_date = null; if (!$is_guest) { $threeds_registration_date = EcomprocessingThreedsHelper::findFirstCustomerOrderDate($customer_orders); @@ -257,6 +264,7 @@ function ($value) { 'threeds_shipping_indicator' => $threeds_shipping_indicator, 'threeds_reorder_items_indicator' => $threeds_reorder_items_indicator, 'threeds_registration_indicator' => $threeds_registration_indicator, + 'threeds_registration_date' => $threeds_registration_date, 'sca_exemption_value' => $this->config->get('ecomprocessing_checkout_sca_exemption'), 'sca_exemption_amount' => $this->config->get('ecomprocessing_checkout_sca_exemption_amount'), ); @@ -269,8 +277,13 @@ function ($value) { $data['purchases_count_last_6_months'] = $purchases_count_last_6_months; } - $transaction = $this->model_extension_payment_ecomprocessing_checkout->create($data); + $transaction_response = $this->model_extension_payment_ecomprocessing_checkout->create($data); + if (!$transaction_response->isSuccessful()) { + throw new Exception($transaction_response->getErrorDescription()); + } + + $transaction = $transaction_response->getResponseObject(); if (isset($transaction->unique_id)) { $timestamp = ($transaction->timestamp instanceof \DateTime) ? $transaction->timestamp->format('c') : $transaction->timestamp; @@ -329,6 +342,9 @@ function ($value) { * Process Gateway Notification * * @return void + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function callback() { @@ -340,9 +356,7 @@ public function callback() try { $this->model_extension_payment_ecomprocessing_checkout->bootstrap(); - $notification = new \Genesis\API\Notification( - $this->request->post - ); + $notification = new Notification($this->request->post); if ($notification->isAuthentic()) { $notification->initReconciliation(); @@ -398,7 +412,7 @@ public function callback() } switch ($wpf_reconcile->status) { - case \Genesis\API\Constants\Transaction\States::APPROVED: + case \Genesis\Api\Constants\Transaction\States::APPROVED: $this->model_checkout_order->addOrderHistory( $transaction['order_id'], $this->config->get('ecomprocessing_checkout_order_status_id'), @@ -406,8 +420,8 @@ public function callback() true ); break; - case \Genesis\API\Constants\Transaction\States::DECLINED: - case \Genesis\API\Constants\Transaction\States::ERROR: + case \Genesis\Api\Constants\Transaction\States::DECLINED: + case \Genesis\Api\Constants\Transaction\States::ERROR: $this->model_checkout_order->addOrderHistory( $transaction['order_id'], $this->config->get('ecomprocessing_checkout_order_failure_status_id'), diff --git a/catalog/model/extension/payment/ecomprocessing/base_model.php b/catalog/model/extension/payment/ecomprocessing/base_model.php index 5c8b580..1086061 100644 --- a/catalog/model/extension/payment/ecomprocessing/base_model.php +++ b/catalog/model/extension/payment/ecomprocessing/base_model.php @@ -17,6 +17,8 @@ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License, version 2 (GPL-2.0) */ +use Genesis\Genesis; + if (!class_exists('\Genesis\Genesis', false)) { include DIR_APPLICATION . '/../admin/model/extension/payment/ecomprocessing/genesis/vendor/autoload.php'; } @@ -32,30 +34,29 @@ * Base Abstract Model for Method Models * * Class ModelExtensionPaymentEcomprocessingBase + * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) */ abstract class ModelExtensionPaymentEcomprocessingBase extends Model { - const PPRO_TRANSACTION_SUFFIX = '_ppro'; - - const GOOGLE_PAY_TRANSACTION_PREFIX = \Genesis\API\Constants\Transaction\Types::GOOGLE_PAY . '_'; + const GOOGLE_PAY_TRANSACTION_PREFIX = \Genesis\Api\Constants\Transaction\Types::GOOGLE_PAY . '_'; const GOOGLE_PAY_PAYMENT_TYPE_AUTHORIZE = - \Genesis\API\Constants\Transaction\Parameters\Mobile\GooglePay\PaymentTypes::AUTHORIZE; + \Genesis\Api\Constants\Transaction\Parameters\Mobile\GooglePay\PaymentTypes::AUTHORIZE; const GOOGLE_PAY_PAYMENT_TYPE_SALE = - \Genesis\API\Constants\Transaction\Parameters\Mobile\GooglePay\PaymentTypes::SALE; + \Genesis\Api\Constants\Transaction\Parameters\Mobile\GooglePay\PaymentTypes::SALE; - const PAYPAL_TRANSACTION_PREFIX = \Genesis\API\Constants\Transaction\Types::PAY_PAL . '_'; + const PAYPAL_TRANSACTION_PREFIX = \Genesis\Api\Constants\Transaction\Types::PAY_PAL . '_'; const PAYPAL_PAYMENT_TYPE_AUTHORIZE = - \Genesis\API\Constants\Transaction\Parameters\Wallets\PayPal\PaymentTypes::AUTHORIZE; + \Genesis\Api\Constants\Transaction\Parameters\Wallets\PayPal\PaymentTypes::AUTHORIZE; const PAYPAL_PAYMENT_TYPE_SALE = - \Genesis\API\Constants\Transaction\Parameters\Wallets\PayPal\PaymentTypes::SALE; + \Genesis\Api\Constants\Transaction\Parameters\Wallets\PayPal\PaymentTypes::SALE; const PAYPAL_PAYMENT_TYPE_EXPRESS = - \Genesis\API\Constants\Transaction\Parameters\Wallets\PayPal\PaymentTypes::EXPRESS; + \Genesis\Api\Constants\Transaction\Parameters\Wallets\PayPal\PaymentTypes::EXPRESS; - const APPLE_PAY_TRANSACTION_PREFIX = \Genesis\API\Constants\Transaction\Types::APPLE_PAY . '_'; + const APPLE_PAY_TRANSACTION_PREFIX = \Genesis\Api\Constants\Transaction\Types::APPLE_PAY . '_'; const APPLE_PAY_PAYMENT_TYPE_AUTHORIZE = - \Genesis\API\Constants\Transaction\Parameters\Mobile\ApplePay\PaymentTypes::AUTHORIZE; + \Genesis\Api\Constants\Transaction\Parameters\Mobile\ApplePay\PaymentTypes::AUTHORIZE; const APPLE_PAY_PAYMENT_TYPE_SALE = - \Genesis\API\Constants\Transaction\Parameters\Mobile\ApplePay\PaymentTypes::SALE; + \Genesis\Api\Constants\Transaction\Parameters\Mobile\ApplePay\PaymentTypes::SALE; /** * Max. number of records of the cron log @@ -292,16 +293,16 @@ public function addOrderRecurring($recurring_products, $payment_reference) public function updateOrderRecurring($data, $payment_reference = null) { switch ($data['status']) { - case \Genesis\API\Constants\Transaction\States::APPROVED: + case \Genesis\Api\Constants\Transaction\States::APPROVED: $recurring_status = self::OC_ORD_REC_STATUS_ACTIVE; break; - case \Genesis\API\Constants\Transaction\States::DECLINED: - case \Genesis\API\Constants\Transaction\States::ERROR: + case \Genesis\Api\Constants\Transaction\States::DECLINED: + case \Genesis\Api\Constants\Transaction\States::ERROR: $recurring_status = self::OC_ORD_REC_STATUS_CANCELLED; break; - case \Genesis\API\Constants\Transaction\States::NEW_STATUS: - case \Genesis\API\Constants\Transaction\States::PENDING_ASYNC: - case \Genesis\API\Constants\Transaction\States::IN_PROGRESS: + case \Genesis\Api\Constants\Transaction\States::NEW_STATUS: + case \Genesis\Api\Constants\Transaction\States::PENDING_ASYNC: + case \Genesis\Api\Constants\Transaction\States::IN_PROGRESS: $recurring_status = self::OC_ORD_REC_STATUS_PENDING; break; default: @@ -352,16 +353,16 @@ public function populateRecurringTransaction($data) $ord_rec_transaction_id = null; switch ($data['status']) { - case \Genesis\API\Constants\Transaction\States::APPROVED: + case \Genesis\Api\Constants\Transaction\States::APPROVED: $oc_txn_type = self::OC_REC_TXN_PAYMENT; break; - case \Genesis\API\Constants\Transaction\States::DECLINED: - case \Genesis\API\Constants\Transaction\States::ERROR: + case \Genesis\Api\Constants\Transaction\States::DECLINED: + case \Genesis\Api\Constants\Transaction\States::ERROR: $oc_txn_type = self::OC_REC_TXN_FAILED; break; - case \Genesis\API\Constants\Transaction\States::NEW_STATUS: - case \Genesis\API\Constants\Transaction\States::PENDING_ASYNC: - case \Genesis\API\Constants\Transaction\States::IN_PROGRESS: + case \Genesis\Api\Constants\Transaction\States::NEW_STATUS: + case \Genesis\Api\Constants\Transaction\States::PENDING_ASYNC: + case \Genesis\Api\Constants\Transaction\States::IN_PROGRESS: $oc_txn_type = self::OC_REC_TXN_DATE_ADDED; break; default: @@ -608,7 +609,7 @@ protected function recurringSale($rec_data) $data = array( 'terminal_token' => $this->getTerminalToken($transaction), - 'transaction type' => \Genesis\API\Constants\Transaction\Types::RECURRING_SALE, + 'transaction type' => \Genesis\Api\Constants\Transaction\Types::RECURRING_SALE, 'transaction_id' => $this->genTransactionId(), 'usage' => $this->getUsage(), 'remote_address' => $this->request->server['REMOTE_ADDR'], @@ -617,8 +618,13 @@ protected function recurringSale($rec_data) 'currency' => $rec_data['currency_code'] ); - $response = $this->sendRecurringSale($data); + $response_obj = $this->sendRecurringSale($data); + + if (!$response_obj->isSuccessful()) { + throw new Exception($response_obj->getErrorDescription()); + } + $response = $response_obj->getResponseObject(); if ($response != false) { $timestamp = ($response->timestamp instanceof \DateTime) ? $response->timestamp->format('c') : $response->timestamp; @@ -750,9 +756,7 @@ protected function sendRecurringSale($data) $genesis->execute(); - return $genesis->response()->getResponseObject(); - } catch (\Genesis\Exceptions\ErrorAPI $api) { - throw $api; + return $genesis->response(); } catch (\Exception $exception) { $this->logEx($exception); @@ -772,8 +776,8 @@ protected function sendRecurringSale($data) */ public function createGenesisRequest($transaction_type) { - return new \Genesis\Genesis( - \Genesis\API\Constants\Transaction\Types::getFinancialRequestClassForTrxType($transaction_type) + return new Genesis( + \Genesis\Api\Constants\Transaction\Types::getFinancialRequestClassForTrxType($transaction_type) ); } @@ -786,8 +790,8 @@ public function createGenesisRequest($transaction_type) public function isInitialRecurringTransaction($transaction_type) { return in_array($transaction_type, array( - \Genesis\API\Constants\Transaction\Types::INIT_RECURRING_SALE, - \Genesis\API\Constants\Transaction\Types::INIT_RECURRING_SALE_3D + \Genesis\Api\Constants\Transaction\Types::INIT_RECURRING_SALE, + \Genesis\Api\Constants\Transaction\Types::INIT_RECURRING_SALE_3D )); } diff --git a/catalog/model/extension/payment/ecomprocessing_checkout.php b/catalog/model/extension/payment/ecomprocessing_checkout.php index b7b49ef..ab20024 100644 --- a/catalog/model/extension/payment/ecomprocessing_checkout.php +++ b/catalog/model/extension/payment/ecomprocessing_checkout.php @@ -19,10 +19,17 @@ require_once DIR_APPLICATION . 'model/extension/payment/ecomprocessing/base_model.php'; +use Genesis\Genesis; +use Genesis\Api\Constants\Transaction\States; + /** * Front-end model for the "ecomprocessing Checkout" module * * @package EcomprocessingCheckout + * + * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @SuppressWarnings(PHPMD.LongClassName) */ class ModelExtensionPaymentEcomprocessingCheckout extends ModelExtensionPaymentEcomprocessingBase { @@ -100,7 +107,7 @@ public function getConsumerId($email) protected function retrieveConsumerIdFromGenesisGateway($email) { try { - $genesis = new \Genesis\Genesis('NonFinancial\Consumers\Retrieve'); + $genesis = new Genesis('NonFinancial\Consumers\Retrieve'); $genesis->request()->setEmail($email); $genesis->execute(); @@ -124,7 +131,7 @@ protected function retrieveConsumerIdFromGenesisGateway($email) */ protected function isErrorResponse($response) { - $state = new \Genesis\API\Constants\Transaction\States($response->status); + $state = new States($response->status); return $state->isError(); } @@ -136,6 +143,17 @@ protected function isErrorResponse($response) public function addConsumer($email, $consumer_id) { try { + $query = $this->db->query(" + SELECT * FROM + `" . DB_PREFIX . "ecomprocessing_checkout_consumers` + WHERE + `customer_email` = '" . $this->db->escape($email) . "' LIMIT 1 + "); + + if ($query->num_rows) { + return ; + } + $this->db->query(" INSERT INTO `" . DB_PREFIX . "ecomprocessing_checkout_consumers` (`customer_email`, `consumer_id`) @@ -271,14 +289,13 @@ public function populateTransaction($data = array()) * @param $data array Transaction Data * @return mixed * @throws Exception - * @throws \Genesis\Exceptions\ErrorAPI */ public function create($data) { try { $this->bootstrap(); - $genesis = new \Genesis\Genesis('WPF\Create'); + $genesis = new Genesis('Wpf\Create'); $genesis ->request() @@ -324,13 +341,14 @@ public function create($data) } if ($this->isThreedsAllowed()) { - /** @var \Genesis\API\Request\WPF\Create $request */ + /** @var \Genesis\Api\Request\Wpf\Create $request */ $request = $genesis->request(); $request->setThreedsV2ControlChallengeIndicator($data['threeds_challenge_indicator']) ->setThreedsV2PurchaseCategory($data['threeds_purchase_category']) ->setThreedsV2MerchantRiskDeliveryTimeframe($data['threeds_delivery_timeframe']) ->setThreedsV2MerchantRiskShippingIndicator($data['threeds_shipping_indicator']) ->setThreedsV2MerchantRiskReorderItemsIndicator($data['threeds_reorder_items_indicator']) + ->setThreedsV2CardHolderAccountRegistrationDate($data['threeds_registration_date']) ->setThreedsV2CardHolderAccountRegistrationIndicator($data['threeds_registration_indicator']) ; if (!$data['is_guest']) { @@ -353,9 +371,7 @@ public function create($data) $this->saveWpfTokenizationData($genesis); - return $genesis->response()->getResponseObject(); - } catch (\Genesis\Exceptions\ErrorAPI $api) { - throw $api; + return $genesis->response(); } catch (\Exception $exception) { $this->logEx($exception); @@ -409,22 +425,19 @@ protected function saveWpfTokenizationData($genesis) * @param $unique_id string - Id of a Genesis Transaction * @return mixed * @throws Exception - * @throws \Genesis\Exceptions\ErrorAPI */ public function reconcile($unique_id) { try { $this->bootstrap(); - $genesis = new \Genesis\Genesis('WPF\Reconcile'); + $genesis = new Genesis('Wpf\Reconcile'); $genesis->request()->setUniqueId($unique_id); $genesis->execute(); return $genesis->response()->getResponseObject(); - } catch (\Genesis\Exceptions\ErrorAPI $api) { - throw $api; } catch (\Exception $exception) { $this->logEx($exception); @@ -444,7 +457,7 @@ public function bootstrap() include DIR_APPLICATION . '/../admin/model/extension/payment/ecomprocessing/genesis/vendor/autoload.php'; \Genesis\Config::setEndpoint( - \Genesis\API\Constants\Endpoints::ECOMPROCESSING + \Genesis\Api\Constants\Endpoints::ECOMPROCESSING ); \Genesis\Config::setUsername( @@ -456,7 +469,7 @@ public function bootstrap() ); \Genesis\Config::setEnvironment( - $this->config->get('ecomprocessing_checkout_sandbox') ? \Genesis\API\Constants\Environments::STAGING : \Genesis\API\Constants\Environments::PRODUCTION + $this->config->get('ecomprocessing_checkout_sandbox') ? \Genesis\Api\Constants\Environments::STAGING : \Genesis\Api\Constants\Environments::PRODUCTION ); } } @@ -489,9 +502,7 @@ public function getLanguage() $this->bootstrap(); - $is_available = @constant('\Genesis\API\Constants\i18n::' . strtoupper($language_code)); - - if ($is_available) { + if (defined('\Genesis\Api\Constants\i18n::' . strtoupper($language_code))) { return strtolower($language_code); } else { return 'en'; @@ -599,28 +610,23 @@ public function getTransactionTypes() $selected_types = $this->orderCardTransactionTypes( $this->config->get('ecomprocessing_checkout_transaction_type') ); - $methods = \Genesis\API\Constants\Payment\Methods::getMethods(); - foreach ($methods as $method) { - $alias_map[$method . self::PPRO_TRANSACTION_SUFFIX] = \Genesis\API\Constants\Transaction\Types::PPRO; - } - - $alias_map = array_merge($alias_map, [ + $alias_map = [ self::GOOGLE_PAY_TRANSACTION_PREFIX . self::GOOGLE_PAY_PAYMENT_TYPE_AUTHORIZE => - \Genesis\API\Constants\Transaction\Types::GOOGLE_PAY, + \Genesis\Api\Constants\Transaction\Types::GOOGLE_PAY, self::GOOGLE_PAY_TRANSACTION_PREFIX . self::GOOGLE_PAY_PAYMENT_TYPE_SALE => - \Genesis\API\Constants\Transaction\Types::GOOGLE_PAY, + \Genesis\Api\Constants\Transaction\Types::GOOGLE_PAY, self::PAYPAL_TRANSACTION_PREFIX . self::PAYPAL_PAYMENT_TYPE_AUTHORIZE => - \Genesis\API\Constants\Transaction\Types::PAY_PAL, + \Genesis\Api\Constants\Transaction\Types::PAY_PAL, self::PAYPAL_TRANSACTION_PREFIX . self::PAYPAL_PAYMENT_TYPE_SALE => - \Genesis\API\Constants\Transaction\Types::PAY_PAL, + \Genesis\Api\Constants\Transaction\Types::PAY_PAL, self::PAYPAL_TRANSACTION_PREFIX . self::PAYPAL_PAYMENT_TYPE_EXPRESS => - \Genesis\API\Constants\Transaction\Types::PAY_PAL, + \Genesis\Api\Constants\Transaction\Types::PAY_PAL, self::APPLE_PAY_TRANSACTION_PREFIX . self::APPLE_PAY_PAYMENT_TYPE_AUTHORIZE => - \Genesis\API\Constants\Transaction\Types::APPLE_PAY, + \Genesis\Api\Constants\Transaction\Types::APPLE_PAY, self::APPLE_PAY_TRANSACTION_PREFIX . self::APPLE_PAY_PAYMENT_TYPE_SALE => - \Genesis\API\Constants\Transaction\Types::APPLE_PAY, - ]); + \Genesis\Api\Constants\Transaction\Types::APPLE_PAY, + ]; foreach ($selected_types as $selected_type) { if (array_key_exists($selected_type, $alias_map)) { @@ -634,7 +640,6 @@ public function getTransactionTypes() $processed_list[$transaction_type]['parameters'][] = array( $key => str_replace( [ - self::PPRO_TRANSACTION_SUFFIX, self::GOOGLE_PAY_TRANSACTION_PREFIX, self::PAYPAL_TRANSACTION_PREFIX, self::APPLE_PAY_TRANSACTION_PREFIX @@ -690,28 +695,29 @@ public function addTransactionTypesToGatewayRequest(\Genesis\Genesis $genesis, $ * @param array $order Transformed Order Array * @return array * @throws \Genesis\Exceptions\ErrorParameter + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function getCustomRequiredAttributes($type, $order) { $parameters = array(); switch ($type) { - case \Genesis\API\Constants\Transaction\Types::IDEBIT_PAYIN: - case \Genesis\API\Constants\Transaction\Types::INSTA_DEBIT_PAYIN: + case \Genesis\Api\Constants\Transaction\Types::IDEBIT_PAYIN: + case \Genesis\Api\Constants\Transaction\Types::INSTA_DEBIT_PAYIN: $parameters = array( 'customer_account_id' => $order['additional']['user_hash'] ); break; - case \Genesis\API\Constants\Transaction\Types::KLARNA_AUTHORIZE: + case \Genesis\Api\Constants\Transaction\Types::KLARNA_AUTHORIZE: $parameters = EcomprocessingHelper::getKlarnaCustomParamItems($order)->toArray(); break; - case \Genesis\API\Constants\Transaction\Types::TRUSTLY_SALE: + case \Genesis\Api\Constants\Transaction\Types::TRUSTLY_SALE: $current_user_id = $order['additional']['user_id']; $user_id = ($current_user_id > 0) ? $current_user_id : $order['additional']['user_hash']; $parameters = array( 'user_id' => $user_id ); break; - case \Genesis\API\Constants\Transaction\Types::ONLINE_BANKING_PAYIN: + case \Genesis\Api\Constants\Transaction\Types::ONLINE_BANKING_PAYIN: $selected_bank_codes = $this->config->get('ecomprocessing_checkout_bank_codes'); if (\Genesis\Utils\Common::isValidArray($selected_bank_codes)) { @@ -723,7 +729,7 @@ function ($value) { ); } break; - case \Genesis\API\Constants\Transaction\Types::PAYSAFECARD: + case \Genesis\Api\Constants\Transaction\Types::PAYSAFECARD: $current_user_id = $order['additional']['user_id']; $customer_id = ($current_user_id > 0) ? $current_user_id : $order['additional']['user_hash']; $parameters = array( @@ -773,7 +779,7 @@ public function getCurrentUserId() public function logEx($exception) { if ($this->config->get('ecomprocessing_checkout_debug')) { - $log = new Log('Ecomprocessing_checkout.log'); + $log = new Log('ecomprocessing_checkout.log'); $log->write($this->jTraceEx($exception)); } } @@ -839,14 +845,11 @@ private function jTraceEx($exception, $seen = null) private function getCustomParameterKey($transaction_type) { switch ($transaction_type) { - case \Genesis\API\Constants\Transaction\Types::PPRO: - $result = 'payment_method'; - break; - case \Genesis\API\Constants\Transaction\Types::PAY_PAL: + case \Genesis\Api\Constants\Transaction\Types::PAY_PAL: $result = 'payment_type'; break; - case \Genesis\API\Constants\Transaction\Types::GOOGLE_PAY: - case \Genesis\API\Constants\Transaction\Types::APPLE_PAY: + case \Genesis\Api\Constants\Transaction\Types::GOOGLE_PAY: + case \Genesis\Api\Constants\Transaction\Types::APPLE_PAY: $result = 'payment_subtype'; break; default: @@ -864,7 +867,7 @@ private function getCustomParameterKey($transaction_type) */ private function orderCardTransactionTypes($selected_types) { - $custom_order = \Genesis\API\Constants\Transaction\Types::getCardTransactionTypes(); + $custom_order = \Genesis\Api\Constants\Transaction\Types::getCardTransactionTypes(); asort($selected_types);