diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..697c97ac6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/composer.lock +/.vendor \ No newline at end of file diff --git a/.php-cs-fixer.cache b/.php-cs-fixer.cache deleted file mode 100644 index 8073749d5..000000000 --- a/.php-cs-fixer.cache +++ /dev/null @@ -1 +0,0 @@ -{"php":"8.1.11","version":"3.12.0","indent":" ","lineEnding":"\n","rules":{"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"braces":true,"class_definition":{"inline_constructor_arguments":false,"space_before_parenthesis":true},"compact_nullable_typehint":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"imports_order":["class","function","const"],"sort_algorithm":"none"},"return_type_declaration":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_import_per_statement":{"group_to_single_imports":false},"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline"},"no_break_comment":true,"no_closing_tag":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"concat_space":{"spacing":"one"},"binary_operator_spaces":true,"not_operator_with_successor_space":true,"no_superfluous_elseif":true,"single_quote":true,"operator_linebreak":true,"no_unneeded_control_parentheses":true,"phpdoc_annotation_without_dot":true,"increment_style":true,"phpdoc_scalar":true,"phpdoc_no_alias_tag":true,"phpdoc_no_package":true,"single_line_comment_spacing":true,"no_alias_language_construct_call":true,"trailing_comma_in_multiline":true,"unary_operator_spaces":true,"phpdoc_separation":true,"cast_spaces":true,"no_extra_blank_lines":true,"blank_line_before_statement":true},"hashes":{"index.php":130455044,"mails\/index.php":130455044,"mails\/mx\/index.php":3481959956,"mails\/es\/index.php":130455044,"mails\/en\/index.php":130455044,"HelperGateway.php":2758290419,"conekta.php":1946587380,"model\/index.php":130455044,"model\/Database.php":2959336022,"model\/Config.php":3573154001,"lib\/index.php":130455044,"lib\/conekta-php\/index.php":82925202,"lib\/conekta-php\/test\/BaseTest.php":3372616288,"lib\/conekta-php\/test\/index.php":3690555249,"lib\/conekta-php\/test\/Conekta-1.0\/LangTest.php":2396226415,"lib\/conekta-php\/test\/Conekta-1.0\/index.php":2148746709,"lib\/conekta-php\/test\/Conekta-1.0\/PayoutTest.php":3152474310,"lib\/conekta-php\/test\/Conekta-1.0\/EventTest.php":3124390162,"lib\/conekta-php\/test\/Conekta-1.0\/ConektaTest.php":726261223,"lib\/conekta-php\/test\/Conekta-1.0\/LogTest.php":3720469414,"lib\/conekta-php\/test\/Conekta-1.0\/PlanTest.php":1117982175,"lib\/conekta-php\/test\/Conekta-1.0\/CustomerTest.php":557594961,"lib\/conekta-php\/test\/Conekta-1.0\/ChargeTest.php":3241509521,"lib\/conekta-php\/test\/Conekta-1.0\/WebhookTest.php":2302029667,"lib\/conekta-php\/test\/Conekta-1.0\/ErrorTest.php":3529047549,"lib\/conekta-php\/test\/bootstrap.php":544856124,"lib\/conekta-php\/test\/Conekta-2.0\/ShippingLineTest.php":2044095376,"lib\/conekta-php\/test\/Conekta-2.0\/LineItemTest.php":2692149924,"lib\/conekta-php\/test\/Conekta-2.0\/LangTest.php":2396226415,"lib\/conekta-php\/test\/Conekta-2.0\/TaxLineTest.php":3631946629,"lib\/conekta-php\/test\/Conekta-2.0\/index.php":82925202,"lib\/conekta-php\/test\/Conekta-2.0\/OrderTest.php":2349340505,"lib\/conekta-php\/test\/Conekta-2.0\/ConektaListTest.php":4017519011,"lib\/conekta-php\/test\/Conekta-2.0\/SubscriptionTest.php":3780618734,"lib\/conekta-php\/test\/Conekta-2.0\/ConektaTest.php":3379456307,"lib\/conekta-php\/test\/Conekta-2.0\/SourceTest.php":4170791539,"lib\/conekta-php\/test\/Conekta-2.0\/CustomerTest.php":2212663475,"lib\/conekta-php\/test\/Conekta-2.0\/ShippingContactTest.php":3766919444,"lib\/conekta-php\/test\/Conekta-2.0\/ChargeTest.php":3749194431,"lib\/conekta-php\/test\/Conekta-2.0\/ErrorHandlerTest.php":1746935832,"lib\/conekta-php\/test\/Conekta-2.0\/DiscountLineTest.php":2410314996,"lib\/conekta-php\/test\/Conekta-2.0\/WebhookTest.php":4068501960,"lib\/conekta-php\/test\/support\/index.php":82925202,"lib\/conekta-php\/test\/support\/fixtures\/index.php":82925202,"lib\/conekta-php\/lib\/Conekta\/Card.php":1354944246,"lib\/conekta-php\/lib\/Conekta\/PaymentMethod.php":4084411547,"lib\/conekta-php\/lib\/Conekta\/Lang.php":2980356393,"lib\/conekta-php\/lib\/Conekta\/Requestor.php":1396079409,"lib\/conekta-php\/lib\/Conekta\/Subscription.php":1359438555,"lib\/conekta-php\/lib\/Conekta\/Payout.php":2326044598,"lib\/conekta-php\/lib\/Conekta\/Event.php":2182653876,"lib\/conekta-php\/lib\/Conekta\/WebhookLog.php":4094533976,"lib\/conekta-php\/lib\/Conekta\/Token.php":2454910017,"lib\/conekta-php\/lib\/Conekta\/index.php":3690555249,"lib\/conekta-php\/lib\/Conekta\/Order.php":3247749468,"lib\/conekta-php\/lib\/Conekta\/Charge.php":2698714446,"lib\/conekta-php\/lib\/Conekta\/ShippingContact.php":161060383,"lib\/conekta-php\/lib\/Conekta\/PayoutMethod.php":2817554294,"lib\/conekta-php\/lib\/Conekta\/Address.php":497387927,"lib\/conekta-php\/lib\/Conekta\/ConektaResource.php":4260650745,"lib\/conekta-php\/lib\/Conekta\/Method.php":887838396,"lib\/conekta-php\/lib\/Conekta\/Exceptions\/MalformedRequestError.php":1922212478,"lib\/conekta-php\/lib\/Conekta\/Exceptions\/AuthenticationError.php":1804030305,"lib\/conekta-php\/lib\/Conekta\/Exceptions\/NoConnectionError.php":223587963,"lib\/conekta-php\/lib\/Conekta\/Exceptions\/index.php":82925202,"lib\/conekta-php\/lib\/Conekta\/Exceptions\/ParameterValidationError.php":3055775386,"lib\/conekta-php\/lib\/Conekta\/Exceptions\/ProcessingError.php":1757174606,"lib\/conekta-php\/lib\/Conekta\/Exceptions\/Handler.php":295010265,"lib\/conekta-php\/lib\/Conekta\/Exceptions\/ResourceNotFoundError.php":4004274380,"lib\/conekta-php\/lib\/Conekta\/Exceptions\/ApiError.php":2081123601,"lib\/conekta-php\/lib\/Conekta\/DiscountLine.php":374870150,"lib\/conekta-php\/lib\/Conekta\/Conekta.php":1118154006,"lib\/conekta-php\/lib\/Conekta\/Customer.php":2228979438,"lib\/conekta-php\/lib\/Conekta\/Webhook.php":1162785900,"lib\/conekta-php\/lib\/Conekta\/Payee.php":3947239471,"lib\/conekta-php\/lib\/Conekta\/LineItem.php":1927226907,"lib\/conekta-php\/lib\/Conekta\/TaxLine.php":3655687002,"lib\/conekta-php\/lib\/Conekta\/PaymentSource.php":3921594319,"lib\/conekta-php\/lib\/Conekta\/ConektaList.php":1004318925,"lib\/conekta-php\/lib\/Conekta\/ConektaObject.php":3483140663,"lib\/conekta-php\/lib\/Conekta\/ShippingLine.php":4017771119,"lib\/conekta-php\/lib\/Conekta\/Util.php":3165817836,"lib\/conekta-php\/lib\/Conekta\/Log.php":712631510,"lib\/conekta-php\/lib\/Conekta\/Plan.php":1069008106,"lib\/conekta-php\/lib\/locales\/messages\/index.php":82925202,"lib\/conekta-php\/lib\/locales\/messages\/en.php":3308507690,"lib\/conekta-php\/lib\/locales\/messages\/es.php":2483410141,"lib\/conekta-php\/lib\/locales\/index.php":82925202,"lib\/conekta-php\/lib\/index.php":3690555249,"lib\/conekta-php\/lib\/Conekta.php":2412978291,"lib\/conekta-php\/lib\/ssl_data\/index.php":82925202,"controllers\/index.php":922539806,"controllers\/front\/index.php":2419419258,"controllers\/front\/validation.php":2728110505,"notification.php":3639493434,"views\/index.php":4127699798,"views\/css\/index.php":3690555249,"views\/js\/index.php":130455044,"views\/img\/index.php":130455044,"views\/templates\/index.php":130455044,"views\/templates\/front\/index.php":130455044,"views\/templates\/hook\/index.php":130455044}} \ No newline at end of file diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 479075a47..2567fd75e 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -1,34 +1,236 @@ exclude(['storage', 'bootstrap/cache']) ->in(__DIR__); $config = new PhpCsFixer\Config(); return $config->setRules([ - '@PSR12' => true, - 'array_syntax' => ['syntax' => 'short'], - 'concat_space' => ['spacing' => 'one'], - 'binary_operator_spaces' => true, - 'not_operator_with_successor_space' => true, - 'no_superfluous_elseif' => true, - 'single_quote' => true, - 'operator_linebreak' => true, - 'no_unneeded_control_parentheses' => true, - 'braces' => true, - 'phpdoc_annotation_without_dot' => true, - 'increment_style' => true, - 'phpdoc_scalar' => true, - 'phpdoc_no_alias_tag' => true, - 'phpdoc_no_package' => true, - 'no_spaces_inside_parenthesis' => true, - 'single_line_comment_spacing' => true, - 'no_alias_language_construct_call' => true, - 'trailing_comma_in_multiline' => true, - 'unary_operator_spaces' => true, - 'short_scalar_cast' => true, - 'phpdoc_separation' => true, - 'cast_spaces' => true, - 'no_extra_blank_lines' => true, - 'blank_line_before_statement' => true + '@PSR12' => true, + 'array_syntax' => ['syntax' => 'short'], + 'concat_space' => ['spacing' => 'one'], + 'braces' => [ + 'allow_single_line_anonymous_class_with_empty_body' => false, + 'allow_single_line_closure' => true, + 'position_after_functions_and_oop_constructs' => 'next', + 'position_after_control_structures' => 'same', + 'position_after_anonymous_constructs' => 'same' + ], + 'no_unneeded_control_parentheses' => [ + 'statements' => [ + 'break', + 'clone', + 'continue', + 'echo_print', + 'negative_instanceof', + 'others', + 'return', + 'switch_case', + 'yield', + 'yield_from', + ] + ], + 'phpdoc_annotation_without_dot' => true, + 'increment_style' => ['style' => 'pre'], + 'phpdoc_scalar' => [ + 'types' => [ + 'boolean', + 'callback', + 'double', + 'integer', + 'real', + 'str' + ] + ], + 'phpdoc_no_alias_tag' => [ + 'replacements' => [ + 'property-read' => 'property', + 'property-write' => 'property', + 'type' => 'var', + 'link' => 'see' + ] + + ], + 'phpdoc_no_package' => true, + 'single_quote' => ['strings_containing_single_quote_chars' => true], + 'no_spaces_inside_parenthesis' => true, + 'single_line_comment_spacing' => true, + 'no_alias_language_construct_call' => true, + 'trailing_comma_in_multiline' => [ + 'after_heredoc' => true, + 'elements' => ['arrays'] + ], + 'unary_operator_spaces' => true, + 'short_scalar_cast' => true, + 'phpdoc_separation' => [ + 'groups' => [ + ['deprecated', 'link', 'see', 'since'], + ['author', 'copyright', 'license'], + ['category', 'package', 'subpackage'], + ['property', 'property-read', 'property-write'] + ] + ], + 'cast_spaces' => ['space' => 'single'], + 'no_extra_blank_lines' => [ + 'tokens' => [ + 'attribute', + 'break', + 'case', + 'continue', + 'curly_brace_block', + 'default', + 'extra', + 'parenthesis_brace_block', + 'return', + 'square_brace_block', + 'switch', + 'throw', + 'use', + 'use_trait' + ] + ], + 'blank_line_before_statement' => [ + 'statements' => [ + 'break', + 'case', + 'continue', + 'declare', + 'default', + 'do', + 'exit', + 'for', + 'foreach', + 'goto', + 'if', + 'include', + 'include_once', + 'phpdoc', + 'require', + 'require_once', + 'return', + 'switch', + 'throw', + 'try', + 'while', + 'yield', + 'yield_from' + ] + ], + 'binary_operator_spaces' => [ + 'default' => 'single_space' + ], + 'no_blank_lines_after_phpdoc' => true, + 'class_attributes_separation' => [ + 'elements' => [ + 'const' => 'one', + 'method' => 'one', + 'property' => 'one', + 'trait_import' => 'none', + 'case' => 'none' + ] + + ], + 'ternary_operator_spaces' => true, + 'no_whitespace_in_blank_line' => true, + 'phpdoc_align' => [ + 'tags' => ['method', 'param', 'property', 'return', 'throws', 'type', 'var'], + 'align' => 'left' + ], + 'single_space_after_construct' => [ + 'constructs' => [ + 'abstract', + 'as', + 'attribute', + 'break', + 'case', + 'catch', + 'class', + 'clone', + 'comment', + 'const', + 'const_import', + 'continue', + 'do', + 'echo', + 'else', + 'elseif', + 'enum', + 'extends', + 'final', + 'finally', + 'for', + 'foreach', + 'function', + 'function_import', + 'global', + 'goto', + 'if', + 'implements', + 'include', + 'include_once', + 'instanceof', + 'insteadof', + 'interface', + 'match', + 'named_argument', + 'namespace', + 'new', + 'open_tag_with_echo', + 'php_doc', + 'php_open', + 'print', + 'private', + 'protected', + 'public', + 'readonly', + 'require', + 'require_once', + 'return', + 'static', + 'switch', + 'throw', + 'trait', + 'try', + 'type_colon', + 'use', + 'use_lambda', + 'use_trait', + 'var', + 'while', + 'yield', + 'yield_from' + ] + ], + 'phpdoc_indent' => true, + 'no_leading_import_slash' => true, + 'phpdoc_to_comment' => ['ignored_tags' => ['todo']], + 'single_line_comment_style' => ['comment_types' => ['asterisk', 'hash']], + 'no_trailing_comma_in_singleline' => [ + 'elements' => [ + 'arguments', + 'array_destructuring', + 'array', + 'group_import' + ] + ], + 'whitespace_after_comma_in_array' => ['ensure_single_space' => true], + + 'no_unused_imports' => true, + 'no_multiline_whitespace_around_double_arrow' => true, + 'single_line_throw' => true, + 'standardize_increment' => true, + 'native_function_casing' => true, + 'phpdoc_trim' => true, + 'class_definition' => [ + 'multi_line_extends_each_single_line' => false, + 'single_item_single_line' => false, + 'single_line' => true, + 'space_before_parenthesis' => true, + 'inline_constructor_arguments' => true + ] + + //'not_operator_with_successor_space' => false, + //'no_superfluous_elseif' => true, + //'operator_linebreak' => true, ]) ->setFinder($finder); diff --git a/CHANGELOG.md b/CHANGELOG.md index 99d981723..c4ade2ea3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## [v2.3.6] - 2023-03-15 [Full Changelog](https://github.com/conekta/conekta_prestashop/compare/2.3.5...2.3.6) - Add MSI feature by @ElvisHeredia [#115](https://github.com/conekta/conekta_prestashop/pull/115) +- Fix Coding standards to get approval from Prestashop Validator by @ElvisHeredia [#116](https://github.com/conekta/conekta_prestashop/pull/116) ## [v2.3.5] - 2022-11-04 diff --git a/HelperGateway.php b/HelperGateway.php index af273e01f..ce16dac00 100644 --- a/HelperGateway.php +++ b/HelperGateway.php @@ -1,39 +1,37 @@ - * @copyright 2012-2019 Conekta + * @copyright 2012-2023 Conekta * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - * @category HelperGateway - * @package HelperGateway - * @version GIT: @2.3.5@ - * @link https://conekta.com/ + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ */ - require_once dirname(__FILE__) . '/model/Database.php'; /** * HelperGateway Class Doc Comment * * @author Conekta + * * @category Class - * @package HelperGateway + * * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - * @link https://conekta.com/ + * + * @see https://conekta.com/ */ - class HelperGateway { - /** * Add tax lines * @@ -43,18 +41,18 @@ class HelperGateway */ public static function addTaxLines($taxlines = null) { - $tax_lines = array( - 'tax_lines' => array() - ); + $tax_lines = [ + 'tax_lines' => [], + ]; if (isset($taxlines)) { foreach ($taxlines as $tax) { array_push( $tax_lines['tax_lines'], - array( + [ 'description' => HelperGateway::removeSpecialCharacter($tax['description']), - 'amount' => $tax['amount'] - ) + 'amount' => $tax['amount'], + ] ); } } @@ -71,23 +69,24 @@ public static function addTaxLines($taxlines = null) */ public static function addShippingLines($shippingLines = null) { - $shippingLinesArray = array( - 'shipping_lines' => array() - ); - + $shippingLinesArray = [ + 'shipping_lines' => [], + ]; + if (isset($shippingLines)) { foreach ($shippingLines as $shipping) { array_push( $shippingLinesArray['shipping_lines'], - array( + [ 'amount' => $shipping['amount'], 'tracking_number' => HelperGateway::removeSpecialCharacter($shipping['tracking_number']), 'carrier' => HelperGateway::removeSpecialCharacter($shipping['carrier']), - 'method' => HelperGateway::removeSpecialCharacter($shipping['method']) - ) + 'method' => HelperGateway::removeSpecialCharacter($shipping['method']), + ] ); } } + return $shippingLinesArray['shipping_lines']; } @@ -123,6 +122,7 @@ public static function calculateAmountTotal($order_details = null) $amount = $amount - $discount['amount']; } } + return $amount; } @@ -131,7 +131,7 @@ public static function calculateAmountTotal($order_details = null) * * @param array $items items in the order * - * @return boolean + * @return bool */ public static function validateSubscrition($items) { @@ -149,7 +149,7 @@ public static function validateSubscrition($items) * * @param array $items items in the order * - * @return boolean + * @return bool */ public static function validateItems($items) { @@ -170,15 +170,17 @@ public static function validateItems($items) * @param array $items items in the order * @param int $amount of the order * - * @return boolean + * @return bool */ public static function validateAmounts($items, $amount) { if (Database::isProductSubscription($items[0]['id_product'])) { $plan_id = Database::getIdPlan($items[0]['id_product']); $conekta_plan = \Conekta\Plan::find($plan_id); + return $conekta_plan->amount == $amount; } + return true; } @@ -187,7 +189,7 @@ public static function validateAmounts($items, $amount) * * @param array $items items in the order * - * @return boolean + * @return bool */ public static function validateItemsProduct($items) { @@ -198,7 +200,7 @@ public static function validateItemsProduct($items) if (Database::isProductSubscription($items[$i]['id_product'])) { $non_subscription = false; } - $i++; + ++$i; } return $non_subscription; @@ -213,14 +215,15 @@ public static function validateItemsProduct($items) */ public static function removeSpecialCharacter($param) { - $param = str_replace(array('#', '-', '_', '.', '/', '(', ')', '[', ']', '!', '¡', '%'), ' ', $param); + $param = str_replace(['#', '-', '_', '.', '/', '(', ')', '[', ']', '!', '¡', '%'], ' ', $param); + return $param; } /** * Generate Checkout * - * @param array $items Items of the order + * @param array $items Items of the order * @param array $payment_options Payment options * * @return array @@ -230,14 +233,14 @@ public static function generateCheckout($items, $payment_options) $retorno = HelperGateway::validateSubscrition($items); if ($retorno) { - return array( - "allowed_payment_methods" => array('card'), - "plan_id" => Database::getIdPlan($items[0]['id_product']) - ); + return [ + 'allowed_payment_methods' => ['card'], + 'plan_id' => Database::getIdPlan($items[0]['id_product']), + ]; } elseif (HelperGateway::validateItemsProduct($items)) { - return array( - "allowed_payment_methods" => $payment_options, - ); + return [ + 'allowed_payment_methods' => $payment_options, + ]; } } @@ -252,23 +255,34 @@ public static function generateCheckout($items, $payment_options) public static function getInterval($option, $frecuency) { $interval = ''; + switch ($option) { case 'minute': - ($frecuency > 1)? $interval = 'Minutos': $interval = 'Minuto'; + ($frecuency > 1) ? $interval = 'Minutos' : $interval = 'Minuto'; + break; + case 'week': - ($frecuency > 1)? $interval = 'Semanas': $interval = 'Semana'; + ($frecuency > 1) ? $interval = 'Semanas' : $interval = 'Semana'; + break; + case 'half_month': - ($frecuency > 1)? $interval = 'Quincenas': $interval = 'Quincena'; + ($frecuency > 1) ? $interval = 'Quincenas' : $interval = 'Quincena'; + break; + case 'month': - ($frecuency > 1)? $interval = 'Meses': $interval = 'Mes'; + ($frecuency > 1) ? $interval = 'Meses' : $interval = 'Mes'; + break; + case 'year': - ($frecuency > 1)? $interval = 'Años': $interval = 'Año'; + ($frecuency > 1) ? $interval = 'Años' : $interval = 'Año'; + break; } + return $interval; } @@ -277,21 +291,23 @@ public static function getInterval($option, $frecuency) * * @param array $items Products * - * @return boolean + * @return bool */ public static function isDigital($items) { $all_digital = true; + if (empty($items)) { return false; } $i = 0; + do { if (!$items[$i]['is_virtual']) { - $all_digital = false; + $all_digital = false; } - $i++; + ++$i; } while ($i < count($items) && $all_digital); return $all_digital; diff --git a/composer.json b/composer.json index 5a72e2ed3..f16dbf1bd 100644 --- a/composer.json +++ b/composer.json @@ -13,8 +13,12 @@ "php": ">=7.0" }, "config": { - "preferred-install": "dist" + "preferred-install": "dist", + "prepend-autoloader": false }, "type": "prestashop-module", - "version": "2.3.6" + "version": "2.3.6", + "require-dev": { + "prestashop/autoindex": "^2.1" + } } diff --git a/conekta.php b/conekta.php index 88026168a..f9fe2d889 100644 --- a/conekta.php +++ b/conekta.php @@ -1,53 +1,59 @@ - * @copyright 2012-2019 Conekta + * @copyright 2012-2023 Conekta * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * * @category Conekta - * @package Conekta + * * @version GIT: @2.3.6@ - * @link https://conekta.com/ + * + * @see https://conekta.com/ */ use PrestaShop\PrestaShop\Core\Payment\PaymentOption; require_once __DIR__ . '/model/Config.php'; + require_once __DIR__ . '/model/Database.php'; + require_once __DIR__ . '/lib/conekta-php/lib/Conekta.php'; -if (! defined('_PS_VERSION_')) { - die(403); +if (!defined('_PS_VERSION_')) { + exit(403); } -define("METADATA_LIMIT", 12); +define('METADATA_LIMIT', 12); /** * Conekta Class Doc Comment * * @category Class - * @package Conekta + * * @author Conekta * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - * @link https://conekta.com/ + * + * @see https://conekta.com/ */ class Conekta extends PaymentModule { protected $html = ''; - protected $postErrors = array(); + + protected $postErrors = []; public $details; + public $owner; + public $address; + public $extra_mail_vars; /** @@ -58,15 +64,15 @@ public function __construct() $this->name = 'conekta'; $this->tab = 'payments_gateways'; $this->version = '2.3.6'; - $this->ps_versions_compliancy = array( + $this->ps_versions_compliancy = [ 'min' => '1.7', - 'max' => _PS_VERSION_ - ); + 'max' => _PS_VERSION_, + ]; $this->author = 'Conekta'; - $this->module_key = 'db59557d5fe73f63180043679985c8c4'; + $this->module_key = 'ccca95e436e967df0e6021787a3d1948'; $this->displayName = $this->l('Conekta'); $this->description = $this->l('Accept payments by Credit and Debit Card with Conekta (Visa, Mastercard, Amex)'); - $this->controllers = array('validation'); + $this->controllers = ['validation']; $this->is_eu_compatible = 1; $this->currencies = true; $this->currencies_mode = 'checkbox'; @@ -98,10 +104,12 @@ public function __construct() ]; $order_elements = array_keys(get_class_vars('Cart')); + foreach ($order_elements as $element) { $settings[] = 'ORDER_' . Tools::strtoupper($element); } $product_elements = self::CART_PRODUCT_ATTR; + foreach ($product_elements as $element) { $settings[] = 'PRODUCT_' . Tools::strtoupper($element); } @@ -109,11 +117,10 @@ public function __construct() $config = Configuration::getMultiple($settings); $this->setConfiguration($config); - $this->bootstrap = true; parent::__construct(); - if (! count(Currency::checkPaymentCurrencies($this->id))) { + if (!count(Currency::checkPaymentCurrencies($this->id))) { $this->warning = $this->l('No currency has been set for this module.'); } } @@ -121,12 +128,14 @@ public function __construct() private function setConfiguration(array $config) { $mappedConfig = $this->mappedConfig(); + foreach ($config as $key => $value) { - if (! isset($mappedConfig[$key])) { + if (!isset($mappedConfig[$key])) { continue; } $attr = $mappedConfig[$key]; $this->$attr = $value; + if ($key == 'MODE') { $this->conekta_mode = ($this->mode) ? 'live' : 'test'; } @@ -136,86 +145,88 @@ private function setConfiguration(array $config) private function mappedConfig() { return [ - 'PAYEE_NAME' => 'checkName', - 'PAYEE_ADDRESS' => 'address', - 'MODE' => 'mode', - 'WEB_HOOK' => 'web_hook', - 'PAYMENT_METHS_CARD' => 'paymnt_method_card', + 'PAYEE_NAME' => 'checkName', + 'PAYEE_ADDRESS' => 'address', + 'MODE' => 'mode', + 'WEB_HOOK' => 'web_hook', + 'PAYMENT_METHS_CARD' => 'paymnt_method_card', 'PAYMENT_MONTHS_INSTALLMENT' => 'payment_months_installment', - 'PAYMENT_METHS_CASH' => 'payment_method_cash', - 'PAYMENT_METHS_SPEI' => 'payment_method_spei', - 'EXPIRATION_DATE_TYPE' => 'expiration_date_type', - 'EXPIRATION_DATE_LIMIT' => 'expiration_date_limit', - 'TEST_PRIVATE_KEY' => 'test_private_key', - 'TEST_PUBLIC_KEY' => 'test_public_key', - 'LIVE_PRIVATE_KEY' => 'live_private_key', - 'LIVE_PUBLIC_KEY' => 'live_public_key', - 'CHARGE_ON_DEMAND_ENABLE' => 'charge_on_demand', - '3DS_FORCE' => 'charge_on_demand', - 'INSTALLMENTS_3_MONTHS' => 'installments_3_months', - 'INSTALLMENTS_6_MONTHS' => 'installments_6_months', - 'INSTALLMENTS_9_MONTHS' => 'installments_9_months', - 'INSTALLMENTS_12_MONTHS' => 'installments_12_months', - 'INSTALLMENTS_18_MONTHS' => 'installments_18_months' + 'PAYMENT_METHS_CASH' => 'payment_method_cash', + 'PAYMENT_METHS_SPEI' => 'payment_method_spei', + 'EXPIRATION_DATE_TYPE' => 'expiration_date_type', + 'EXPIRATION_DATE_LIMIT' => 'expiration_date_limit', + 'TEST_PRIVATE_KEY' => 'test_private_key', + 'TEST_PUBLIC_KEY' => 'test_public_key', + 'LIVE_PRIVATE_KEY' => 'live_private_key', + 'LIVE_PUBLIC_KEY' => 'live_public_key', + 'CHARGE_ON_DEMAND_ENABLE' => 'charge_on_demand', + '3DS_FORCE' => 'charge_on_demand', + 'INSTALLMENTS_3_MONTHS' => 'installments_3_months', + 'INSTALLMENTS_6_MONTHS' => 'installments_6_months', + 'INSTALLMENTS_9_MONTHS' => 'installments_9_months', + 'INSTALLMENTS_12_MONTHS' => 'installments_12_months', + 'INSTALLMENTS_18_MONTHS' => 'installments_18_months', ]; } /** * Install configuration, create table in database and register hooks * - * @return boolean + * @return bool */ public function install() { - $updateConfig = array( - 'PS_OS_CHEQUE' => 1, - 'PS_OS_PAYMENT' => 2, + $updateConfig = [ + 'PS_OS_CHEQUE' => 1, + 'PS_OS_PAYMENT' => 2, 'PS_OS_PREPARATION' => 3, - 'PS_OS_SHIPPING' => 4, - 'PS_OS_DELIVERED' => 5, - 'PS_OS_CANCELED' => 6, - 'PS_OS_REFUND' => 7, - 'PS_OS_ERROR' => 8, - 'PS_OS_OUTOFSTOCK' => 9, - 'PS_OS_BANKWIRE' => 10, - 'PS_OS_PAYPAL' => 11, - 'PS_OS_WS_PAYMENT' => 12 - ); + 'PS_OS_SHIPPING' => 4, + 'PS_OS_DELIVERED' => 5, + 'PS_OS_CANCELED' => 6, + 'PS_OS_REFUND' => 7, + 'PS_OS_ERROR' => 8, + 'PS_OS_OUTOFSTOCK' => 9, + 'PS_OS_BANKWIRE' => 10, + 'PS_OS_PAYPAL' => 11, + 'PS_OS_WS_PAYMENT' => 12, + ]; foreach ($updateConfig as $u => $v) { - if (! Configuration::get($u) || (int)Configuration::get($u) < 1) { - if (defined('_' . $u . '_') && (int)constant('_' . $u . '_') > 0) { + if (!Configuration::get($u) || (int) Configuration::get($u) < 1) { + if (defined('_' . $u . '_') && (int) constant('_' . $u . '_') > 0) { Configuration::updateValue($u, constant('_' . $u . '_')); } else { Configuration::updateValue($u, $v); } } } - if (! parent::install() || ! $this->createPendingCashState() - || ! $this->createPendingSpeiState() || ! $this->registerHook('header') - || ! $this->registerHook('paymentOptions') - || ! $this->registerHook('paymentReturn') - || ! $this->registerHook('adminOrder') - || ! $this->registerHook('updateOrderStatus') + + if (!parent::install() || !$this->createPendingCashState() + || !$this->createPendingSpeiState() || !$this->registerHook('header') + || !$this->registerHook('paymentOptions') + || !$this->registerHook('paymentReturn') + || !$this->registerHook('adminOrder') + || !$this->registerHook('updateOrderStatus') && Configuration::updateValue('PAYMENT_METHS_CARD', 1) && Configuration::updateValue('PAYMENT_MONTHS_INSTALLMENT', 1) && Configuration::updateValue('PAYMENT_METHS_CASH', 1) && Configuration::updateValue('PAYMENT_METHS_SPEI', 1) - && Configuration::updateValue('MODE', 0) || ! Database::installDb() - || ! Database::createTableConektaOrder() - || ! Database::createTableMetaData() + && Configuration::updateValue('MODE', 0) || !Database::installDb() + || !Database::createTableConektaOrder() + || !Database::createTableMetaData() ) { return false; } Configuration::updateValue('CONEKTA_PRESTASHOP_VERSION', $this->version); + return true; } /** * Delete configuration and drop table in database. * - * @return boolean + * @return bool */ public function uninstall() { @@ -258,41 +269,42 @@ public function uninstall() public function hookPaymentReturn($params) { if ($params['order'] && Validate::isLoadedObject($params['order'])) { - $id_order = (int)$params['order']->id; + $id_order = (int) $params['order']->id; $conekta_tran_details = Database::getOrderById($id_order); + if ($conekta_tran_details['barcode']) { $this->smarty->assign('cash', true); $this->smarty->assign( 'conekta_order', - array( - 'barcode' => $conekta_tran_details['reference'], - 'type' => 'cash', + [ + 'barcode' => $conekta_tran_details['reference'], + 'type' => 'cash', 'barcode_url' => $conekta_tran_details['barcode'], - 'amount' => $conekta_tran_details['amount'], - 'currency' => $conekta_tran_details['currency'] - ) + 'amount' => $conekta_tran_details['amount'], + 'currency' => $conekta_tran_details['currency'], + ] ); - } elseif (isset($conekta_tran_details['reference']) && ! empty($conekta_tran_details['reference'])) { + } elseif (isset($conekta_tran_details['reference']) && !empty($conekta_tran_details['reference'])) { if (strpos($conekta_tran_details['reference'], '6461801118') !== false) { $this->smarty->assign('spei', true); $this->smarty->assign( 'conekta_order', - array( + [ 'receiving_account_number' => $conekta_tran_details['reference'], - 'amount' => $conekta_tran_details['amount'], - 'currency' => $conekta_tran_details['currency'] - ) + 'amount' => $conekta_tran_details['amount'], + 'currency' => $conekta_tran_details['currency'], + ] ); } } else { $this->smarty->assign('card', true); $this->smarty->assign( 'conekta_order', - array( - 'type' => 'card', + [ + 'type' => 'card', 'reference' => $params['order']->reference ?? '#' . sprintf('%06d', $params['order']->id), - 'valid' => $params['order']->valid - ) + 'valid' => $params['order']->valid, + ] ); } } @@ -303,14 +315,14 @@ public function hookPaymentReturn($params) /** * The order is refunded * - * @param array $params Information of order to update it. + * @param array $params information of order to update it * * @return void */ public function hookUpdateOrderStatus($params) { if ($params['newOrderStatus']->id == 7) { - //order refunded + // order refunded $key = Configuration::get('CONEKTA_MODE') ? Configuration::get('CONEKTA_PRIVATE_KEY_LIVE') : Configuration::get('CONEKTA_PRIVATE_KEY_TEST'); @@ -318,18 +330,18 @@ public function hookUpdateOrderStatus($params) $iso_code = $this->context->language->iso_code; \Conekta\Conekta::setApiKey($key); - \Conekta\Conekta::setPlugin("Prestashop1.7"); - \Conekta\Conekta::setApiVersion("2.0.0"); + \Conekta\Conekta::setPlugin('Prestashop1.7'); + \Conekta\Conekta::setApiVersion('2.0.0'); \Conekta\Conekta::setPluginVersion($this->version); \Conekta\Conekta::setLocale($iso_code); - $id_order = (int)$params['id_order']; + $id_order = (int) $params['id_order']; $conekta_tran_details = Database::getOrderById($id_order); - //only credit card refund - if (! $conekta_tran_details['barcode'] - && ! (isset($conekta_tran_details['reference']) - && ! empty($conekta_tran_details['reference'])) + // only credit card refund + if (!$conekta_tran_details['barcode'] + && !(isset($conekta_tran_details['reference']) + && !empty($conekta_tran_details['reference'])) ) { $order = \Conekta\Order::find($conekta_tran_details['id_conekta_order']); $order->refund(['reason' => 'requested_by_client']); @@ -340,13 +352,13 @@ public function hookUpdateOrderStatus($params) /** * Create pending chash state * - * @return boolean + * @return bool */ private function createPendingCashState() { $state = new OrderState(); $languages = Language::getLanguages(); - $names = array(); + $names = []; foreach ($languages as $lang) { $names[$lang['id_lang']] = 'En espera de pago'; @@ -356,7 +368,7 @@ private function createPendingCashState() $state->color = '#4169E1'; $state->send_email = true; $state->module_name = 'conekta'; - $templ = array(); + $templ = []; foreach ($languages as $lang) { $templ[$lang['id_lang']] = 'conektaefectivo'; @@ -367,6 +379,7 @@ private function createPendingCashState() if ($state->save()) { Configuration::updateValue('waiting_cash_payment', $state->id); $directory = _PS_MAIL_DIR_; + if ($dhvalue = opendir($directory)) { while (($file = readdir($dhvalue)) !== false) { if (is_dir($directory . $file) && $file[0] != '.') { @@ -381,6 +394,7 @@ private function createPendingCashState() Tools::copy($new_txt_file, $txt_folder); } catch (\Exception $e) { $error_copy = $e->getMessage() . ' '; + if (class_exists('Logger')) { Logger::addLog(json_encode($error_copy), 1, null, null, null, true); } @@ -392,19 +406,20 @@ private function createPendingCashState() } else { return false; } + return true; } /** * Create pending spei state * - * @return boolean + * @return bool */ private function createPendingSpeiState() { $state = new OrderState(); $languages = Language::getLanguages(); - $names = array(); + $names = []; foreach ($languages as $lang) { $names[$lang['id_lang']] = 'En espera de pago'; @@ -414,16 +429,18 @@ private function createPendingSpeiState() $state->color = '#4169E1'; $state->send_email = true; $state->module_name = 'conekta'; - $templ = array(); + $templ = []; foreach ($languages as $lang) { $templ[$lang['id_lang']] = 'conektaspei'; } $state->template = $templ; + if ($state->save()) { Configuration::updateValue('waiting_spei_payment', $state->id); $directory = _PS_MAIL_DIR_; + if ($dhvalue = opendir($directory)) { while (($file = readdir($dhvalue)) !== false) { if (is_dir($directory . $file) && $file[0] != '.') { @@ -438,6 +455,7 @@ private function createPendingSpeiState() Tools::copy($new_txt_file, $txt_folder); } catch (\Exception $e) { $error_copy = $e->getMessage() . ' '; + if (class_exists('Logger')) { Logger::addLog(json_encode($error_copy), 1, null, null, null, true); } @@ -449,6 +467,7 @@ private function createPendingSpeiState() } else { return false; } + return true; } @@ -464,40 +483,41 @@ public function hookHeader() ); $iso_code = $this->context->language->iso_code; \Conekta\Conekta::setApiKey($key); - \Conekta\Conekta::setPlugin("Prestashop1.7"); - \Conekta\Conekta::setApiVersion("2.0.0"); + \Conekta\Conekta::setPlugin('Prestashop1.7'); + \Conekta\Conekta::setApiVersion('2.0.0'); \Conekta\Conekta::setLocale($iso_code); if (Tools::getValue('controller') != 'order-opc' && ( - ! ($_SERVER['PHP_SELF'] == __PS_BASE_URI__ . 'order.php' - || $_SERVER['PHP_SELF'] == __PS_BASE_URI__ . 'order-opc.php' - || Tools::getValue('controller') == 'order' - || Tools::getValue('controller') == 'orderopc' - || Tools::getValue('step') == 3 - ) + !( + $_SERVER['PHP_SELF'] == __PS_BASE_URI__ . 'order.php' + || $_SERVER['PHP_SELF'] == __PS_BASE_URI__ . 'order-opc.php' + || Tools::getValue('controller') == 'order' + || Tools::getValue('controller') == 'orderopc' + || Tools::getValue('step') == 3 + ) ) ) { return; } Media::addJsDef( - array( - "ajax_link" => $this->_path . 'ajax.php' - ) + [ + 'ajax_link' => $this->_path . 'ajax.php', + ] ); $this->context->controller->addCSS($this->_path . 'views/css/conekta-prestashop.css'); if (Configuration::get('MODE')) { - $this->smarty->assign("api_key", addslashes(Configuration::get('LIVE_PUBLIC_KEY'))); + $this->smarty->assign('api_key', addslashes(Configuration::get('LIVE_PUBLIC_KEY'))); } else { - $this->smarty->assign("api_key", addslashes(Configuration::get('TEST_PUBLIC_KEY'))); + $this->smarty->assign('api_key', addslashes(Configuration::get('TEST_PUBLIC_KEY'))); } - $this->smarty->assign("path", $this->_path); + $this->smarty->assign('path', $this->_path); $cart = $this->context->cart; $customer = $this->context->customer; - $payment_options = array(); + $payment_options = []; if (Configuration::get('PAYMENT_METHS_SPEI')) { array_push($payment_options, 'bank_transfer'); @@ -514,22 +534,22 @@ public function hookHeader() // $msi = false; $force_3ds = false; $on_demand_enabled = false; - $address_delivery = new Address((int)$cart->id_address_delivery); + $address_delivery = new Address((int) $cart->id_address_delivery); $state = State::getNameById($address_delivery->id_state); $country = Country::getIsoById($address_delivery->id_country); - $carrier = new Carrier((int)$cart->id_carrier); + $carrier = new Carrier((int) $cart->id_carrier); $shp_price = $cart->getTotalShippingCost(); - $shp_carrier = "other"; - $shp_service = "other"; + $shp_carrier = 'other'; + $shp_service = 'other'; $discounts = $cart->getCartRules(); $items = $cart->getProducts(); $shippingLines = null; $shippingContact = null; - if (! empty($carrier)) { + if (!empty($carrier)) { if ($carrier->name != null) { $shp_carrier = $carrier->name; - $shp_service = implode(",", $carrier->delay); + $shp_service = implode(',', $carrier->delay); $shippingLines = Config::getShippingLines($shp_service, $shp_carrier, $shp_price); } } @@ -537,13 +557,13 @@ public function hookHeader() $shippingContact = Config::getShippingContact($customer, $address_delivery, $state, $country); $customerInfo = Config::getCustomerInfo($customer, $address_delivery); - $result = Database::getConektaMetadata($customer->id, $this->conekta_mode, "conekta_customer_id"); + $result = Database::getConektaMetadata($customer->id, $this->conekta_mode, 'conekta_customer_id'); if (count($payment_options) > 0 - && ! empty($shippingContact['address']['postal_code']) - && ! empty($shippingLines)) { - $order_details = array(); - $taxlines = array(); + && !empty($shippingContact['address']['postal_code']) + && !empty($shippingLines)) { + $order_details = []; + $taxlines = []; if (empty($result['meta_value'])) { $customer_id = $this->createCustomer($customer, $customerInfo); @@ -553,9 +573,6 @@ public function hookHeader() $customerConekta->update($customerInfo); } - - - if (Configuration::get('CHARGE_ON_DEMAND_ENABLE')) { $on_demand_enabled = true; } @@ -567,54 +584,58 @@ public function hookHeader() $taxlines = Config::getTaxLines($items); $checkout = [ - "type" => 'Integration', - "allowed_payment_methods" => $payment_options, - "on_demand_enabled" => $on_demand_enabled, - "force_3ds_flow" => Configuration::get('CONEKTA_MODE') ? $force_3ds : false + 'type' => 'Integration', + 'allowed_payment_methods' => $payment_options, + 'on_demand_enabled' => $on_demand_enabled, + 'force_3ds_flow' => Configuration::get('CONEKTA_MODE') ? $force_3ds : false, ]; - if ((Configuration::get('PAYMENT_MONTHS_INSTALLMENT'))) { + + if (Configuration::get('PAYMENT_MONTHS_INSTALLMENT') === 'YES') { $checkout['monthly_installments_enabled'] = true; $checkout['monthly_installments_options'] = $this->getMonthlyInstallments(); } if (in_array('cash', $payment_options)) { - $checkout["expires_at"] = time() + (Configuration::get('EXPIRATION_DATE_LIMIT') * (Configuration::get( - 'EXPIRATION_DATE_TYPE' - ) == 0 ? 86400 : 3600)); + $checkout['expires_at'] = time() + (Configuration::get('EXPIRATION_DATE_LIMIT') * (Configuration::get( + 'EXPIRATION_DATE_TYPE' + ) == 0 ? 86400 : 3600)); } $order_details = [ - 'currency' => $this->context->currency->iso_code, - 'line_items' => Config::getLineItems($items), - 'customer_info' => array("customer_id" => $customer_id), - 'discount_lines' => Config::getDiscountLines($discounts), - 'shipping_lines' => array(), + 'currency' => $this->context->currency->iso_code, + 'line_items' => Config::getLineItems($items), + 'customer_info' => ['customer_id' => $customer_id], + 'discount_lines' => Config::getDiscountLines($discounts), + 'shipping_lines' => [], 'shipping_contact' => $shippingContact, - 'tax_lines' => array(), - 'metadata' => [ - "plugin" => "Prestashop", - "plugin_version" => _PS_VERSION_, - "reference_id" => $this->context->cart->id + 'tax_lines' => [], + 'metadata' => [ + 'plugin' => 'Prestashop', + 'plugin_version' => _PS_VERSION_, + 'reference_id' => $this->context->cart->id, ], - 'checkout' => $checkout + 'checkout' => $checkout, ]; $order_elements = array_keys(get_class_vars('Cart')); + foreach ($order_elements as $element) { - if (! empty(Configuration::get('ORDER_' . Tools::strtoupper($element))) && property_exists( - $this->context->cart, - $element - )) { + if (!empty(Configuration::get('ORDER_' . Tools::strtoupper($element))) && property_exists( + $this->context->cart, + $element + )) { $order_details['metadata'][$element] = $this->context->cart->$element; } } $product_elements = self::CART_PRODUCT_ATTR; + foreach ($items as $item) { $index = 'product-' . $item['id_product']; $order_details['metadata'][$index] = ''; + foreach ($product_elements as $element) { - if (! empty(Configuration::get('PRODUCT_' . Tools::strtoupper($element))) + if (!empty(Configuration::get('PRODUCT_' . Tools::strtoupper($element))) && array_key_exists($element, $item) ) { $order_details['metadata'][$index] .= $this->buildRecursiveMetadata($item[$element], $element); @@ -625,24 +646,24 @@ public function hookHeader() $amount = 0; - if (! empty($shippingLines)) { + if (!empty($shippingLines)) { foreach ($shippingLines as $shipping) { - $order_details['shipping_lines'][] = array( - 'amount' => $shipping['amount'], + $order_details['shipping_lines'][] = [ + 'amount' => $shipping['amount'], 'tracking_number' => $this->removeSpecialCharacter($shipping['tracking_number']), - 'carrier' => $this->removeSpecialCharacter($shipping['carrier']), - 'method' => $this->removeSpecialCharacter($shipping['method']) - ); + 'carrier' => $this->removeSpecialCharacter($shipping['carrier']), + 'method' => $this->removeSpecialCharacter($shipping['method']), + ]; $amount = $amount + $shipping['amount']; } } if (isset($taxlines)) { foreach ($taxlines as $tax) { - $order_details['tax_lines'][] = array( + $order_details['tax_lines'][] = [ 'description' => $this->removeSpecialCharacter($tax['description']), - 'amount' => $tax['amount'] - ); + 'amount' => $tax['amount'], + ]; $amount = $amount + $tax['amount']; } } @@ -661,12 +682,13 @@ public function hookHeader() try { if ($order_details['currency'] == 'MXN' && $amount < $this->amount_min) { - $message = "El monto minimo de compra con Conekta tiene que ser mayor a $20.00 "; + $message = 'El monto minimo de compra con Conekta tiene que ser mayor a $20.00 '; $this->context->smarty->assign( - array( + [ 'message' => $message, - ) + ] ); + return false; } @@ -715,35 +737,38 @@ public function hookHeader() 2, null, 'Cart', - (int)$this->context->cart->id, + (int) $this->context->cart->id, true ); } $message = $e->getMessage(); - $this->context->smarty->assign("message", $message); + $this->context->smarty->assign('message', $message); } } + if (isset($order)) { - $this->smarty->assign("orderID", $order->id); - $this->smarty->assign("checkoutRequestId", $order->checkout['id']); - $this->smarty->assign("amount", $amount); + $this->smarty->assign('orderID', $order->id); + $this->smarty->assign('checkoutRequestId', $order->checkout['id']); + $this->smarty->assign('amount', $amount); } else { - $this->smarty->assign("checkoutRequestId", ""); - $this->smarty->assign("orderID", ""); - $this->smarty->assign("amount", ""); + $this->smarty->assign('checkoutRequestId', ''); + $this->smarty->assign('orderID', ''); + $this->smarty->assign('amount', ''); } - return $this->fetchTemplate("hook-header.tpl"); + + return $this->fetchTemplate('hook-header.tpl'); } /** * Generate string with msi for checkout + * * @return array */ private function getMonthlyInstallments() { - $monthlyInstallments =[ + $monthlyInstallments = [ 3 => Configuration::get('INSTALLMENTS_3_MONTHS'), 6 => Configuration::get('INSTALLMENTS_6_MONTHS'), 9 => Configuration::get('INSTALLMENTS_9_MONTHS'), @@ -769,22 +794,25 @@ private function getMonthlyInstallments() public function buildRecursiveMetadata($data_object, $key) { $string = ''; + if (gettype($data_object) == 'array') { foreach (array_keys($data_object) as $data_key) { - $key_concat = (string)($key) . '-' . (string)($data_key); + $key_concat = (string) $key . '-' . (string) $data_key; + if (empty($data_object[$data_key])) { - $string .= (string)($key_concat) . ': NULL | '; + $string .= (string) $key_concat . ': NULL | '; } else { $string .= $this->buildRecursiveMetadata($data_object[$data_key], $key_concat); } } } else { if (empty($data_object)) { - $string .= (string)($key) . ': NULL | '; + $string .= (string) $key . ': NULL | '; } else { - $string .= (string)($key) . ': ' . (string)($data_object) . ' | '; + $string .= (string) $key . ': ' . (string) $data_object . ' | '; } } + return $string; } @@ -797,7 +825,7 @@ public function buildRecursiveMetadata($data_object, $key) */ public function hookAdminOrder($params) { - $id_order = (int)$params['id_order']; + $id_order = (int) $params['id_order']; $status = $this->getTransactionStatus($id_order); return $status; @@ -812,19 +840,19 @@ public function hookAdminOrder($params) */ public function hookPaymentOptions($params) { - if (! $this->active) { + if (!$this->active) { return; } - if (! $this->checkCurrency($params['cart'])) { + if (!$this->checkCurrency($params['cart'])) { return; } $this->smarty->assign( - array( - 'test_private_key' => Configuration::get('TEST_PRIVATE_KEY') - ) + [ + 'test_private_key' => Configuration::get('TEST_PRIVATE_KEY'), + ] ); - $payment_options = array(); + $payment_options = []; if (Configuration::get('PAYMENT_METHS_CARD') || Configuration::get('PAYMENT_METHS_CASH') @@ -832,6 +860,7 @@ public function hookPaymentOptions($params) ) { array_push($payment_options, $this->getConektaPaymentOption()); } + return $payment_options; } @@ -845,6 +874,7 @@ public function hookPaymentOptions($params) public function removeSpecialCharacter($param) { $param = str_replace(['#', '-', '_', '.', '/', '(', ')', '[', ']', '!', '¡', '%'], ' ', $param); + return $param; } @@ -853,7 +883,7 @@ public function removeSpecialCharacter($param) * * @param array $cart payment cart * - * @return boolean + * @return bool */ public function checkCurrency($cart) { @@ -881,7 +911,7 @@ public function getConektaPaymentOption() $embeddedOption = new PaymentOption(); $embeddedOption->setModuleName($this->name)->setCallToActionText( $this->l('Pago por medio de Conekta ') - )->setAction($this->context->link->getModuleLink($this->name, 'validation', array(), true))->setForm( + )->setAction($this->context->link->getModuleLink($this->name, 'validation', [], true))->setForm( $this->generateCardPaymentForm() )->setLogo(Media::getMediaPath(_PS_MODULE_DIR_ . $this->name . '/views/img/cards2.png')); @@ -896,48 +926,50 @@ public function getConektaPaymentOption() private function postValidation() { if (Tools::isSubmit('btnSubmit')) { - if (! Tools::getValue('PAYEE_NAME')) { - $this->postErrors[] = $this->trans('The "Payee" field is required.', array(), 'Modules.Conekta.Admin'); - } elseif (! Tools::getValue('PAYEE_ADDRESS')) { + if (!Tools::getValue('PAYEE_NAME')) { + $this->postErrors[] = $this->trans('The "Payee" field is required.', [], 'Modules.Conekta.Admin'); + } elseif (!Tools::getValue('PAYEE_ADDRESS')) { $this->postErrors[] = $this->trans( 'The "Address" field is required.', - array(), + [], 'Modules.Conekta.Admin' ); } - if (! Tools::getValue('WEB_HOOK')) { + if (!Tools::getValue('WEB_HOOK')) { $this->postErrors[] = $this->trans( 'The "Web Hook" field is required.', - array(), + [], 'Modules.Conekta.Admin' ); } - if (Tools::getValue('PAYMENT_METHS_CASH') && ! Tools::getValue('EXPIRATION_DATE_LIMIT')) { + if (Tools::getValue('PAYMENT_METHS_CASH') && !Tools::getValue('EXPIRATION_DATE_LIMIT')) { $this->postErrors[] = $this->trans( 'The "Expiration date limit" field is required.', - array(), + [], 'Modules.Conekta.Admin' ); } + if (Tools::getValue('PAYMENT_METHS_CASH') && ((Tools::getValue( - 'EXPIRATION_DATE_TYPE' - ) == 0 && (Tools::getValue('EXPIRATION_DATE_LIMIT') < 0 || Tools::getValue( - 'EXPIRATION_DATE_LIMIT' - ) > 31)) || (Tools::getValue('EXPIRATION_DATE_TYPE') == 1 && (Tools::getValue( - 'EXPIRATION_DATE_LIMIT' - ) < 0 || Tools::getValue('EXPIRATION_DATE_LIMIT') > 24)))) { + 'EXPIRATION_DATE_TYPE' + ) == 0 && (Tools::getValue('EXPIRATION_DATE_LIMIT') < 0 || Tools::getValue( + 'EXPIRATION_DATE_LIMIT' + ) > 31)) || (Tools::getValue('EXPIRATION_DATE_TYPE') == 1 && (Tools::getValue( + 'EXPIRATION_DATE_LIMIT' + ) < 0 || Tools::getValue('EXPIRATION_DATE_LIMIT') > 24)))) { $this->postErrors[] = $this->trans( 'The "Expiration date limit" is out of range.', - array(), + [], 'Modules.Conekta.Admin' ); } - if (Tools::getValue('PAYMENT_METHS_CASH') && ! is_numeric(Tools::getValue('EXPIRATION_DATE_LIMIT'))) { + + if (Tools::getValue('PAYMENT_METHS_CASH') && !is_numeric(Tools::getValue('EXPIRATION_DATE_LIMIT'))) { $this->postErrors[] = $this->trans( 'The "Expiration date limit" must be a number.', - array(), + [], 'Modules.Conekta.Admin' ); } @@ -945,72 +977,73 @@ private function postValidation() $order_elements = array_keys(get_class_vars('Cart')); $i = 0; $attributes_count = 0; + while ($i < count($order_elements) && $attributes_count <= METADATA_LIMIT) { - if (! empty(Tools::getValue('ORDER_' . Tools::strtoupper($order_elements[$i])))) { - $attributes_count++; + if (!empty(Tools::getValue('ORDER_' . Tools::strtoupper($order_elements[$i])))) { + ++$attributes_count; } - $i++; + ++$i; } $i = 0; $product_elements = self::CART_PRODUCT_ATTR; + while ($i < count($product_elements) && $attributes_count <= METADATA_LIMIT) { - if (! empty(Tools::getValue('PRODUCT_' . Tools::strtoupper($product_elements[$i])))) { - $attributes_count++; + if (!empty(Tools::getValue('PRODUCT_' . Tools::strtoupper($product_elements[$i])))) { + ++$attributes_count; } - $i++; + ++$i; } + if ($attributes_count > METADATA_LIMIT) { $this->postErrors[] = $this->trans( 'No more than 12 attributes can be sent as metadata', - array(), + [], 'Modules.Conekta.Admin' ); } - if (! Tools::getValue('TEST_PRIVATE_KEY')) { + if (!Tools::getValue('TEST_PRIVATE_KEY')) { $this->postErrors[] = $this->trans( 'The "Test Private Key" field is required.', - array(), + [], 'Modules.Conekta.Admin' ); } - if (! Tools::getValue('TEST_PUBLIC_KEY')) { + if (!Tools::getValue('TEST_PUBLIC_KEY')) { $this->postErrors[] = $this->trans( 'The "Test Public Key" field is required.', - array(), + [], 'Modules.Conekta.Admin' ); } - if (Tools::getValue('LIVE_PRIVATE_KEY') && ! Tools::getValue('LIVE_PUBLIC_KEY')) { + if (Tools::getValue('LIVE_PRIVATE_KEY') && !Tools::getValue('LIVE_PUBLIC_KEY')) { $this->postErrors[] = $this->trans( 'The "Live Public Key" field is required.', - array(), + [], 'Modules.Conekta.Admin' ); } - if (! Tools::getValue('LIVE_PRIVATE_KEY') && Tools::getValue('LIVE_PUBLIC_KEY')) { + if (!Tools::getValue('LIVE_PRIVATE_KEY') && Tools::getValue('LIVE_PUBLIC_KEY')) { $this->postErrors[] = $this->trans( 'The "Live Private Key" field is required.', - array(), + [], 'Modules.Conekta.Admin' ); } - if ( Tools::getValue('PAYMENT_METHS_CARD') && Tools::getValue('PAYMENT_MONTHS_INSTALLMENT') && - - ! Tools::getValue('INSTALLMENTS_3_MONTHS') && - ! Tools::getValue('INSTALLMENTS_6_MONTHS') && - ! Tools::getValue('INSTALLMENTS_9_MONTHS') && - ! Tools::getValue('INSTALLMENTS_12_MONTHS') && - ! Tools::getValue('INSTALLMENTS_18_MONTHS') - + if (Tools::getValue('PAYMENT_METHS_CARD') && Tools::getValue('PAYMENT_MONTHS_INSTALLMENT') && + !Tools::getValue('INSTALLMENTS_3_MONTHS') && + !Tools::getValue('INSTALLMENTS_6_MONTHS') && + !Tools::getValue('INSTALLMENTS_9_MONTHS') && + !Tools::getValue('INSTALLMENTS_12_MONTHS') && + !Tools::getValue('INSTALLMENTS_18_MONTHS') ) { $this->postErrors[] = $this->trans( - 'Almost one installment, must be selected.'.$result, - array(), + 'Almost one installment, must be selected.' . $result, + [], 'Modules.Conekta.Admin' ); } @@ -1049,6 +1082,7 @@ private function postProcess() Configuration::updateValue('INSTALLMENTS_18_MONTHS', Tools::getValue('INSTALLMENTS_18_MONTHS')); $order_elements = array_keys(get_class_vars('Cart')); + foreach ($order_elements as $element) { Configuration::updateValue( 'ORDER_' . Tools::strtoupper($element), @@ -1056,6 +1090,7 @@ private function postProcess() ); } $product_elements = self::CART_PRODUCT_ATTR; + foreach ($product_elements as $element) { Configuration::updateValue( 'PRODUCT_' . Tools::strtoupper($element), @@ -1065,7 +1100,7 @@ private function postProcess() } $this->html .= $this->displayConfirmation( - $this->trans('Settings updated', array(), 'Admin.Notifications.Success') + $this->trans('Settings updated', [], 'Admin.Notifications.Success') ); } @@ -1086,12 +1121,12 @@ private function displayCheck() */ public function getConfigFieldsValues() { - $ret = array( - 'PAYEE_NAME' => Tools::getValue('PAYEE_NAME', Configuration::get('PAYEE_NAME')), - 'PAYEE_ADDRESS' => Tools::getValue('PAYEE_ADDRESS', Configuration::get('PAYEE_ADDRESS')), - 'MODE' => Tools::getValue('MODE', Configuration::get('MODE')), - 'WEB_HOOK' => Tools::getValue('WEB_HOOK', Configuration::get('WEB_HOOK')), - 'PAYMENT_METHS_CARD' => Tools::getValue( + $ret = [ + 'PAYEE_NAME' => Tools::getValue('PAYEE_NAME', Configuration::get('PAYEE_NAME')), + 'PAYEE_ADDRESS' => Tools::getValue('PAYEE_ADDRESS', Configuration::get('PAYEE_ADDRESS')), + 'MODE' => Tools::getValue('MODE', Configuration::get('MODE')), + 'WEB_HOOK' => Tools::getValue('WEB_HOOK', Configuration::get('WEB_HOOK')), + 'PAYMENT_METHS_CARD' => Tools::getValue( 'PAYMENT_METHS_CARD', Configuration::get('PAYMENT_METHS_CARD') ), @@ -1099,61 +1134,63 @@ public function getConfigFieldsValues() 'PAYMENT_MONTHS_INSTALLMENT', Configuration::get('PAYMENT_MONTHS_INSTALLMENT') ), - 'PAYMENT_METHS_CASH' => Tools::getValue( + 'PAYMENT_METHS_CASH' => Tools::getValue( 'PAYMENT_METHS_CASH', Configuration::get('PAYMENT_METHS_CASH') ), - 'PAYMENT_METHS_BANORTE' => Tools::getValue( + 'PAYMENT_METHS_BANORTE' => Tools::getValue( 'PAYMENT_METHS_BANORTE', Configuration::get('PAYMENT_METHS_BANORTE') ), - 'PAYMENT_METHS_SPEI' => Tools::getValue( + 'PAYMENT_METHS_SPEI' => Tools::getValue( 'PAYMENT_METHS_SPEI', Configuration::get('PAYMENT_METHS_SPEI') ), - 'EXPIRATION_DATE_TYPE' => Tools::getValue( + 'EXPIRATION_DATE_TYPE' => Tools::getValue( 'EXPIRATION_DATE_TYPE', Configuration::get('EXPIRATION_DATE_TYPE') ), - 'EXPIRATION_DATE_LIMIT' => Tools::getValue( + 'EXPIRATION_DATE_LIMIT' => Tools::getValue( 'EXPIRATION_DATE_LIMIT', Configuration::get('EXPIRATION_DATE_LIMIT') ), - 'TEST_PRIVATE_KEY' => Tools::getValue('TEST_PRIVATE_KEY', Configuration::get('TEST_PRIVATE_KEY')), - 'TEST_PUBLIC_KEY' => Tools::getValue('TEST_PUBLIC_KEY', Configuration::get('TEST_PUBLIC_KEY')), - 'LIVE_PRIVATE_KEY' => Tools::getValue('LIVE_PRIVATE_KEY', Configuration::get('LIVE_PRIVATE_KEY')), - 'LIVE_PUBLIC_KEY' => Tools::getValue('LIVE_PUBLIC_KEY', Configuration::get('LIVE_PUBLIC_KEY')), - 'CHARGE_ON_DEMAND_ENABLE' => Tools::getValue( + 'TEST_PRIVATE_KEY' => Tools::getValue('TEST_PRIVATE_KEY', Configuration::get('TEST_PRIVATE_KEY')), + 'TEST_PUBLIC_KEY' => Tools::getValue('TEST_PUBLIC_KEY', Configuration::get('TEST_PUBLIC_KEY')), + 'LIVE_PRIVATE_KEY' => Tools::getValue('LIVE_PRIVATE_KEY', Configuration::get('LIVE_PRIVATE_KEY')), + 'LIVE_PUBLIC_KEY' => Tools::getValue('LIVE_PUBLIC_KEY', Configuration::get('LIVE_PUBLIC_KEY')), + 'CHARGE_ON_DEMAND_ENABLE' => Tools::getValue( 'CHARGE_ON_DEMAND_ENABLE', Configuration::get('CHARGE_ON_DEMAND_ENABLE') ), - '3DS_FORCE' => Tools::getValue('3DS_FORCE', Configuration::get('3DS_FORCE')), - 'INSTALLMENTS_3_MONTHS' => Tools::getValue( + '3DS_FORCE' => Tools::getValue('3DS_FORCE', Configuration::get('3DS_FORCE')), + 'INSTALLMENTS_3_MONTHS' => Tools::getValue( 'INSTALLMENTS_3_MONTHS', Configuration::get('INSTALLMENTS_3_MONTHS') ), - 'INSTALLMENTS_6_MONTHS' => Tools::getValue( + 'INSTALLMENTS_6_MONTHS' => Tools::getValue( 'INSTALLMENTS_6_MONTHS', Configuration::get('INSTALLMENTS_6_MONTHS') ), - 'INSTALLMENTS_9_MONTHS' => Tools::getValue( + 'INSTALLMENTS_9_MONTHS' => Tools::getValue( 'INSTALLMENTS_9_MONTHS', Configuration::get('INSTALLMENTS_9_MONTHS') ), - 'INSTALLMENTS_12_MONTHS' => Tools::getValue( + 'INSTALLMENTS_12_MONTHS' => Tools::getValue( 'INSTALLMENTS_12_MONTHS', Configuration::get('INSTALLMENTS_12_MONTHS') ), - 'INSTALLMENTS_18_MONTHS' => Tools::getValue( + 'INSTALLMENTS_18_MONTHS' => Tools::getValue( 'INSTALLMENTS_18_MONTHS', Configuration::get('INSTALLMENTS_18_MONTHS') - ) - ); + ), + ]; $order_elements = array_keys(get_class_vars('Cart')); + foreach ($order_elements as $element) { $ret['ORDER_' . Tools::strtoupper($element)] = Configuration::get('ORDER_' . Tools::strtoupper($element)); } $product_elements = self::CART_PRODUCT_ATTR; + foreach ($product_elements as $element) { $ret['PRODUCT_' . Tools::strtoupper($element)] = Configuration::get( 'PRODUCT_' . Tools::strtoupper($element) @@ -1163,78 +1200,78 @@ public function getConfigFieldsValues() return $ret; } - const CART_PRODUCT_ATTR = array( - "id_product_attribute", - "id_product", - "cart_quantity", - "id_shop", - "id_customization", - "name", - "is_virtual", - "description_short", - "available_now", - "available_later", - "id_category_default", - "id_supplier", - "id_manufacturer", - "manufacturer_name", - "on_sale", - "ecotax", - "additional_shipping_cost", - "available_for_order", - "show_price", - "price", - "active", - "unity", - "unit_price_ratio", - "quantity_available", - "width", - "height", - "depth", - "out_of_stock", - "weight", - "available_date", - "date_add", - "date_upd", - "quantity", - "link_rewrite", - "category", - "unique_id", - "id_address_delivery", - "advanced_stock_management", - "supplier_reference", - "customization_quantity", - "price_attribute", - "ecotax_attr", - "reference", - "weight_attribute", - "ean13", - "isbn", - "upc", - "minimal_quantity", - "wholesale_price", - "id_image", - "legend", - "reduction_type", - "is_gift", - "reduction", - "reduction_without_tax", - "price_without_reduction", - "attributes", - "attributes_small", - "rate", - "tax_name", - "stock_quantity", - "price_without_reduction_without_tax", - "price_with_reduction", - "price_with_reduction_without_tax", - "total", - "total_wt", - "price_wt", - "reduction_applies", - "quantity_discount_applies", - "allow_oosp" - ); + public const CART_PRODUCT_ATTR = [ + 'id_product_attribute', + 'id_product', + 'cart_quantity', + 'id_shop', + 'id_customization', + 'name', + 'is_virtual', + 'description_short', + 'available_now', + 'available_later', + 'id_category_default', + 'id_supplier', + 'id_manufacturer', + 'manufacturer_name', + 'on_sale', + 'ecotax', + 'additional_shipping_cost', + 'available_for_order', + 'show_price', + 'price', + 'active', + 'unity', + 'unit_price_ratio', + 'quantity_available', + 'width', + 'height', + 'depth', + 'out_of_stock', + 'weight', + 'available_date', + 'date_add', + 'date_upd', + 'quantity', + 'link_rewrite', + 'category', + 'unique_id', + 'id_address_delivery', + 'advanced_stock_management', + 'supplier_reference', + 'customization_quantity', + 'price_attribute', + 'ecotax_attr', + 'reference', + 'weight_attribute', + 'ean13', + 'isbn', + 'upc', + 'minimal_quantity', + 'wholesale_price', + 'id_image', + 'legend', + 'reduction_type', + 'is_gift', + 'reduction', + 'reduction_without_tax', + 'price_without_reduction', + 'attributes', + 'attributes_small', + 'rate', + 'tax_name', + 'stock_quantity', + 'price_without_reduction_without_tax', + 'price_with_reduction', + 'price_with_reduction_without_tax', + 'total', + 'total_wt', + 'price_wt', + 'reduction_applies', + 'quantity_discount_applies', + 'allow_oosp', + ]; /** * Build Admin Content @@ -1245,265 +1282,280 @@ public function buildAdminContent() { $this->context->controller->addJS($this->_path . 'views/js/functions.js'); $order_elements = array_keys( - array_diff_key(get_class_vars('Cart'), array('definition' => '', 'htmlFields' => '')) + array_diff_key(get_class_vars('Cart'), ['definition' => '', 'htmlFields' => '']) ); sort($order_elements); - $order_meta = array(); + $order_meta = []; + foreach ($order_elements as $val) { - $order_meta[] = array( - "id" => Tools::strtoupper($val), - "name" => $val, - "val" => $val - ); + $order_meta[] = [ + 'id' => Tools::strtoupper($val), + 'name' => $val, + 'val' => $val, + ]; } $product_elements = self::CART_PRODUCT_ATTR; sort($product_elements); - $product_meta = array(); + $product_meta = []; + foreach ($product_elements as $val) { - $product_meta[] = array( - "id" => Tools::strtoupper($val), - "name" => $val, - "val" => $val - ); + $product_meta[] = [ + 'id' => Tools::strtoupper($val), + 'name' => $val, + 'val' => $val, + ]; } - $fields_form = array( - 'form' => array( - 'legend' => array( - 'title' => $this->trans('Contact details', array(), 'Modules.Conekta.Admin'), - 'icon' => 'icon-envelope' - ), - 'input' => array( - array( - 'type' => 'text', - 'label' => $this->trans('Payee (name)', array(), 'Modules.Conekta.Admin'), - 'name' => 'PAYEE_NAME', - 'required' => true - ), - array( - 'type' => 'textarea', - 'label' => $this->trans('Address', array(), 'Modules.Conekta.Admin'), - 'desc' => $this->trans( + $fields_form = [ + 'form' => [ + 'legend' => [ + 'title' => $this->trans('Contact details', [], 'Modules.Conekta.Admin'), + 'icon' => 'icon-envelope', + ], + 'input' => [ + [ + 'type' => 'text', + 'label' => $this->trans('Payee (name)', [], 'Modules.Conekta.Admin'), + 'name' => 'PAYEE_NAME', + 'required' => true, + ], + [ + 'type' => 'textarea', + 'label' => $this->trans('Address', [], 'Modules.Conekta.Admin'), + 'desc' => $this->trans( 'Address where the check should be sent to.', - array(), + [], 'Modules.Conekta.Admin' ), - 'name' => 'PAYEE_ADDRESS', - 'required' => true - ), - array( - 'type' => 'radio', - 'label' => $this->l('Mode'), - 'name' => 'MODE', + 'name' => 'PAYEE_ADDRESS', 'required' => true, - 'class' => 't', - 'is_bool' => true, - 'values' => array( - array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Production')), - array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Sandbox')) - ) - ), - array( - 'type' => 'text', - 'label' => $this->trans('Webhook', array(), 'Modules.Conekta.Admin'), - 'name' => 'WEB_HOOK', - 'required' => true - ), - array( - 'type' => 'checkbox', - 'label' => $this->l('Payment Method'), - 'desc' => $this->l('Choose options.'), - 'name' => 'PAYMENT_METHS', - 'values' => array( - 'query' => array( - array('id' => 'CARD', 'name' => $this->l('Card'), 'val' => 'card_payment_method'), - array('id' => 'CASH', 'name' => $this->l('Cash'), 'val' => 'cash_payment_method'), - array('id' => 'SPEI', 'name' => $this->l('SPEI'), 'val' => 'spei_payment_method') - ), - 'id' => 'id', - 'name' => 'name' - ), - 'expand' => array( + ], + [ + 'type' => 'radio', + 'label' => $this->l('Mode'), + 'name' => 'MODE', + 'required' => true, + 'class' => 't', + 'is_bool' => true, + 'values' => [ + ['id' => 'active_on', 'value' => 1, 'label' => $this->l('Production')], + ['id' => 'active_off', 'value' => 0, 'label' => $this->l('Sandbox')], + ], + ], + [ + 'type' => 'text', + 'label' => $this->trans('Webhook', [], 'Modules.Conekta.Admin'), + 'name' => 'WEB_HOOK', + 'required' => true, + ], + [ + 'type' => 'checkbox', + 'label' => $this->l('Payment Method'), + 'desc' => $this->l('Choose options.'), + 'name' => 'PAYMENT_METHS', + 'values' => [ + 'query' => [ + ['id' => 'CARD', 'name' => $this->l('Card'), 'val' => 'card_payment_method'], + ['id' => 'CASH', 'name' => $this->l('Cash'), 'val' => 'cash_payment_method'], + ['id' => 'SPEI', 'name' => $this->l('SPEI'), 'val' => 'spei_payment_method'], + ], + 'id' => 'id', + 'name' => 'name', + ], + 'expand' => [ 'print_total' => 3, - 'default' => 'show', - 'show' => array('text' => $this->l('show'), 'icon' => 'plus-sign-alt'), - 'hide' => array('text' => $this->l('hide'), 'icon' => 'minus-sign-alt') - ) - ), + 'default' => 'show', + 'show' => ['text' => $this->l('show'), 'icon' => 'plus-sign-alt'], + 'hide' => ['text' => $this->l('hide'), 'icon' => 'minus-sign-alt'], + ], + ], [ - 'type' => 'select', - 'label' => $this->l('Monthly Installments enable'), - 'desc' => $this->l('Choose options.'), - 'name' => 'PAYMENT_MONTHS_INSTALLMENT', + 'type' => 'select', + 'label' => $this->l('Monthly Installments enable'), + 'desc' => $this->l('Choose options.'), + 'name' => 'PAYMENT_MONTHS_INSTALLMENT', 'options' => [ 'query' => [ [ 'id' => 'NO', 'name' => $this->l('No'), - 'val' => 'No' + 'val' => 'No', ], [ 'id' => 'YES', 'name' => $this->l('Yes'), - 'val' => 'yes' + 'val' => 'yes', ], ], - 'id' => 'id', - 'name' => 'name' + 'id' => 'id', + 'name' => 'name', ], ], [ - 'type' => 'checkbox', - 'label' => $this->l('Monthly Installments'), - 'desc' => $this->l('Choose options.'), - 'name' => 'INSTALLMENTS', + 'type' => 'checkbox', + 'label' => $this->l('Monthly Installments'), + 'desc' => $this->l('Choose options.'), + 'name' => 'INSTALLMENTS', 'values' => [ 'query' => [ - ['id' => '3_MONTHS', 'name' => $this->l('3 Months'), 'val' => 'installments_3_months'], - ['id' => '6_MONTHS', 'name' => $this->l('6 Months'), 'val' => 'installments_6_months'], - ['id' => '9_MONTHS', 'name' => $this->l('9 Months'), 'val' => 'installments_9_months'], [ - 'id' => '12_MONTHS', + 'id' => '3_MONTHS', + 'name' => $this->l('3 Months'), + 'val' => 'installments_3_months', + ], + [ + 'id' => '6_MONTHS', + 'name' => $this->l('6 Months'), + 'val' => 'installments_6_months', + ], + [ + 'id' => '9_MONTHS', + 'name' => $this->l('9 Months'), + 'val' => 'installments_9_months', + ], + [ + 'id' => '12_MONTHS', 'name' => $this->l('12 Months'), - 'val' => 'installments_12_months' + 'val' => 'installments_12_months', ], [ - 'id' => '18_MONTHS', + 'id' => '18_MONTHS', 'name' => $this->l('18 Months'), - 'val' => 'installments_18_months' - ] + 'val' => 'installments_18_months', + ], ], - 'id' => 'id', - 'name' => 'name' + 'id' => 'id', + 'name' => 'name', ], 'expand' => [ 'print_total' => 5, - 'default' => 'show', - 'show' => ['text' => $this->l('show'), 'icon' => 'plus-sign-alt'], - 'hide' => ['text' => $this->l('hide'), 'icon' => 'minus-sign-alt'] - ] + 'default' => 'show', + 'show' => ['text' => $this->l('show'), 'icon' => 'plus-sign-alt'], + 'hide' => ['text' => $this->l('hide'), 'icon' => 'minus-sign-alt'], + ], ], - array( - 'type' => 'radio', - 'label' => $this->l('Expiration date type'), - 'name' => 'EXPIRATION_DATE_TYPE', - 'class' => 't', + [ + 'type' => 'radio', + 'label' => $this->l('Expiration date type'), + 'name' => 'EXPIRATION_DATE_TYPE', + 'class' => 't', 'is_bool' => true, - 'values' => array( - array('id' => 'EXPIRATION_DATE_TYPE_DAYS', 'value' => 0, 'label' => $this->l('Days')), - array('id' => 'EXPIRATION_DATE_TYPE_HOURS', 'value' => 1, 'label' => $this->l('Hours')) - ) - ), - array( - 'type' => 'text', - 'label' => $this->trans('Expiration date limit', array(), 'Modules.Conekta.Admin'), - 'name' => 'EXPIRATION_DATE_LIMIT', - ), - array( - 'type' => 'text', - 'label' => $this->trans('Test Private Key', array(), 'Modules.Conekta.Admin'), - 'name' => 'TEST_PRIVATE_KEY', - 'required' => true - ), - array( - 'type' => 'text', - 'label' => $this->trans('Test Public Key', array(), 'Modules.Conekta.Admin'), - 'name' => 'TEST_PUBLIC_KEY', - 'required' => true - ), - array( - 'type' => 'password', - 'label' => $this->trans('Live Private Key', array(), 'Modules.Conekta.Admin'), - 'name' => 'LIVE_PRIVATE_KEY', - 'required' => true - ), - array( - 'type' => 'password', - 'label' => $this->trans('Live Public Key', array(), 'Modules.Conekta.Admin'), - 'name' => 'LIVE_PUBLIC_KEY', - 'required' => true - ), - array( - 'type' => 'checkbox', - 'label' => $this->l('Additional Order Metadata'), - 'name' => 'ORDER', - 'values' => array( + 'values' => [ + ['id' => 'EXPIRATION_DATE_TYPE_DAYS', 'value' => 0, 'label' => $this->l('Days')], + ['id' => 'EXPIRATION_DATE_TYPE_HOURS', 'value' => 1, 'label' => $this->l('Hours')], + ], + ], + [ + 'type' => 'text', + 'label' => $this->trans('Expiration date limit', [], 'Modules.Conekta.Admin'), + 'name' => 'EXPIRATION_DATE_LIMIT', + ], + [ + 'type' => 'text', + 'label' => $this->trans('Test Private Key', [], 'Modules.Conekta.Admin'), + 'name' => 'TEST_PRIVATE_KEY', + 'required' => true, + ], + [ + 'type' => 'text', + 'label' => $this->trans('Test Public Key', [], 'Modules.Conekta.Admin'), + 'name' => 'TEST_PUBLIC_KEY', + 'required' => true, + ], + [ + 'type' => 'password', + 'label' => $this->trans('Live Private Key', [], 'Modules.Conekta.Admin'), + 'name' => 'LIVE_PRIVATE_KEY', + 'required' => true, + ], + [ + 'type' => 'password', + 'label' => $this->trans('Live Public Key', [], 'Modules.Conekta.Admin'), + 'name' => 'LIVE_PUBLIC_KEY', + 'required' => true, + ], + [ + 'type' => 'checkbox', + 'label' => $this->l('Additional Order Metadata'), + 'name' => 'ORDER', + 'values' => [ 'query' => $order_meta, - 'id' => 'id', - 'name' => 'name' - ), - 'expand' => array( + 'id' => 'id', + 'name' => 'name', + ], + 'expand' => [ 'print_total' => count($order_meta), - 'default' => 'show', - 'show' => array( + 'default' => 'show', + 'show' => [ 'text' => $this->l('show'), - 'icon' => 'plus-sign-alt' - ), - 'hide' => array( + 'icon' => 'plus-sign-alt', + ], + 'hide' => [ 'text' => $this->l('hide'), - 'icon' => 'minus-sign-alt' - ) - ) - ), - array( - 'type' => 'checkbox', - 'label' => $this->l('Additional Product Metadata'), - 'name' => 'PRODUCT', - 'values' => array( + 'icon' => 'minus-sign-alt', + ], + ], + ], + [ + 'type' => 'checkbox', + 'label' => $this->l('Additional Product Metadata'), + 'name' => 'PRODUCT', + 'values' => [ 'query' => $product_meta, - 'id' => 'id', - 'name' => 'name' - ), - 'expand' => array( + 'id' => 'id', + 'name' => 'name', + ], + 'expand' => [ 'print_total' => count($product_meta), - 'default' => 'show', - 'show' => array( + 'default' => 'show', + 'show' => [ 'text' => $this->l('show'), - 'icon' => 'plus-sign-alt' - ), - 'hide' => array( + 'icon' => 'plus-sign-alt', + ], + 'hide' => [ 'text' => $this->l('hide'), - 'icon' => 'minus-sign-alt' - ) - ) - ), - array( - 'type' => 'checkbox', - 'label' => $this->l('Charge on Demand'), - 'name' => 'CHARGE_ON_DEMAND', - 'values' => array( - 'query' => array( - array( - 'id' => 'ENABLE', + 'icon' => 'minus-sign-alt', + ], + ], + ], + [ + 'type' => 'checkbox', + 'label' => $this->l('Charge on Demand'), + 'name' => 'CHARGE_ON_DEMAND', + 'values' => [ + 'query' => [ + [ + 'id' => 'ENABLE', 'name' => $this->l('Enable card save'), - 'val' => 'charge_on_demand_enabled' - ), - ), - 'id' => 'id', - 'name' => 'name', - ) - ), - array( - 'type' => 'checkbox', - 'label' => $this->l('3DS'), - 'name' => '3DS', - 'values' => array( - 'query' => array( - array( - 'id' => 'FORCE', + 'val' => 'charge_on_demand_enabled', + ], + ], + 'id' => 'id', + 'name' => 'name', + ], + ], + [ + 'type' => 'checkbox', + 'label' => $this->l('3DS'), + 'name' => '3DS', + 'values' => [ + 'query' => [ + [ + 'id' => 'FORCE', 'name' => $this->l('Activar 3DS'), - 'val' => 'force_3ds' - ), - ), - 'id' => 'id', - 'name' => 'name', - ) - ) - ), - 'submit' => array( - 'title' => $this->trans('Save', array(), 'Admin.Actions') - ) - ) - ); + 'val' => 'force_3ds', + ], + ], + 'id' => 'id', + 'name' => 'name', + ], + ], + ], + 'submit' => [ + 'title' => $this->trans('Save', [], 'Admin.Actions'), + ], + ], + ]; + return $fields_form; } @@ -1517,17 +1569,18 @@ public function renderForm() $fields_form = $this->buildAdminContent(); $helper = new HelperForm(); $helper->show_toolbar = false; - $helper->id = (int)Tools::getValue('id_carrier'); + $helper->id = (int) Tools::getValue('id_carrier'); $helper->identifier = $this->identifier; $helper->submit_action = 'btnSubmit'; $helper->currentIndex = $this->context->link->getAdminLink( - 'AdminModules', - false - ) . '&configure=' . $this->name . '&tab_module=' . $this->tab . '&module_name=' . $this->name; + 'AdminModules', + false + ) . '&configure=' . $this->name . '&tab_module=' . $this->tab . '&module_name=' . $this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); - $helper->tpl_vars = array('fields_value' => $this->getConfigFieldsValues()); - $this->fields_form = array(); - return $helper->generateForm(array($fields_form)); + $helper->tpl_vars = ['fields_value' => $this->getConfigFieldsValues()]; + $this->fields_form = []; + + return $helper->generateForm([$fields_form]); } /** @@ -1535,7 +1588,7 @@ public function renderForm() * * @param $mode configuration type * - * @return boolean + * @return bool */ public function checkSettings($mode = 'global') { @@ -1547,12 +1600,12 @@ public function checkSettings($mode = 'global') if ($mode) { $valid = Configuration::get('CONEKTA_PUBLIC_KEY_LIVE') != '' && Configuration::get( - 'CONEKTA_PRIVATE_KEY_LIVE' - ) != ''; + 'CONEKTA_PRIVATE_KEY_LIVE' + ) != ''; } else { $valid = Configuration::get('CONEKTA_PUBLIC_KEY_TEST') != '' && Configuration::get( - 'CONEKTA_PRIVATE_KEY_TEST' - ) != ''; + 'CONEKTA_PRIVATE_KEY_TEST' + ) != ''; } return $valid; @@ -1561,51 +1614,51 @@ public function checkSettings($mode = 'global') /** * Check requirements * - * @return boolean + * @return bool */ public function checkRequirements() { - $tests = array( - 'result' => true - ); + $tests = [ + 'result' => true, + ]; - $tests['curl'] = array( - 'name' => $this->l('PHP cURL extension must be enabled on your server'), - 'result' => (integer)function_exists('curl_init') - ); + $tests['curl'] = [ + 'name' => $this->l('PHP cURL extension must be enabled on your server'), + 'result' => (int) function_exists('curl_init'), + ]; if (Configuration::get('CONEKTA_MODE')) { - $tests['ssl'] = array( - 'name' => $this->l('SSL must be enabled on your store (before entering Live mode)'), - 'result' => (integer)Configuration::get('PS_SSL_ENABLED') || (! empty( - filter_input( - INPUT_SERVER, - 'HTTPS' - ) - ) && Tools::strtolower(filter_input(INPUT_SERVER, 'HTTPS')) != 'off') - ); + $tests['ssl'] = [ + 'name' => $this->l('SSL must be enabled on your store (before entering Live mode)'), + 'result' => (int) Configuration::get('PS_SSL_ENABLED') || (!empty( + filter_input( + INPUT_SERVER, + 'HTTPS' + ) + ) && Tools::strtolower(filter_input(INPUT_SERVER, 'HTTPS')) != 'off'), + ]; } - $tests['php52'] = array( - 'name' => $this->l('Your server must run PHP 5.2 or greater'), - 'result' => (integer)version_compare(PHP_VERSION, '5.2.0', '>=') - ); + $tests['php52'] = [ + 'name' => $this->l('Your server must run PHP 5.2 or greater'), + 'result' => (int) version_compare(PHP_VERSION, '5.2.0', '>='), + ]; - $tests['configuration'] = array( - 'name' => $this->l('You must sign-up for CONEKTA and configure your account settings in the module'), - 'result' => (integer)$this->checkSettings() - ); + $tests['configuration'] = [ + 'name' => $this->l('You must sign-up for CONEKTA and configure your account settings in the module'), + 'result' => (int) $this->checkSettings(), + ]; if (version_compare(_PS_VERSION_, '1.5', '<')) { - $tests['backward'] = array( - 'name' => $this->l('You are using the backward compatibility module'), - 'result' => $this->backward, - 'resolution' => $this->backward_error - ); + $tests['backward'] = [ + 'name' => $this->l('You are using the backward compatibility module'), + 'result' => $this->backward, + 'resolution' => $this->backward_error, + ]; } foreach ($tests as $k => $test) { - if ($k != 'result' && ! $test['result']) { + if ($k != 'result' && !$test['result']) { $tests['result'] = false; } } @@ -1620,34 +1673,34 @@ public function checkRequirements() */ public function getContent() { - //CODE FOR WEBHOOK VALIDATION UNTESTED DONT ERASE + // CODE FOR WEBHOOK VALIDATION UNTESTED DONT ERASE - $this->smarty->assign("base_uri", __PS_BASE_URI__); - $this->smarty->assign("mode", Configuration::get('MODE')); + $this->smarty->assign('base_uri', __PS_BASE_URI__); + $this->smarty->assign('mode', Configuration::get('MODE')); $url = Configuration::get('WEB_HOOK'); if (empty($url)) { - $url = _PS_BASE_URL_ . __PS_BASE_URI__ . "modules/conekta/notification.php"; + $url = _PS_BASE_URL_ . __PS_BASE_URI__ . 'modules/conekta/notification.php'; } if (Tools::isSubmit('btnSubmit') && Tools::getValue('TEST_PUBLIC_KEY') && Tools::getValue('TEST_PRIVATE_KEY')) { $configuration_values = [ - 'CONEKTA_MODE' => Tools::getValue('MODE'), - 'CONEKTA_PUBLIC_KEY_TEST' => rtrim(Tools::getValue('TEST_PUBLIC_KEY')), - 'CONEKTA_PUBLIC_KEY_LIVE' => rtrim(Tools::getValue('LIVE_PUBLIC_KEY')), + 'CONEKTA_MODE' => Tools::getValue('MODE'), + 'CONEKTA_PUBLIC_KEY_TEST' => rtrim(Tools::getValue('TEST_PUBLIC_KEY')), + 'CONEKTA_PUBLIC_KEY_LIVE' => rtrim(Tools::getValue('LIVE_PUBLIC_KEY')), 'CONEKTA_PRIVATE_KEY_TEST' => rtrim(Tools::getValue('TEST_PRIVATE_KEY')), 'CONEKTA_PRIVATE_KEY_LIVE' => rtrim(Tools::getValue('LIVE_PRIVATE_KEY')), - 'CONEKTA_CARDS' => rtrim(Tools::getValue('PAYMENT_METHS_CARD')), - 'CONEKTA_MSI' => rtrim(Tools::getValue('PAYMENT_MONTHS_INSTALLMENT')), - 'PAYMENT_METHS_CASH' => rtrim(Tools::getValue('PAYMENT_METHS_CASH')), - 'PAYMENT_METHS_SPEI' => rtrim(Tools::getValue('PAYMENT_METHS_SPEI')), - 'EXPIRATION_DATE_LIMIT' => rtrim(Tools::getValue('EXPIRATION_DATE_LIMIT')), - 'EXPIRATION_DATE_TYPE' => rtrim(Tools::getValue('EXPIRATION_DATE_TYPE')), - 'INSTALLMENTS_3_MONTHS' => rtrim(Tools::getValue('INSTALLMENTS_3_MONTHS')), - 'INSTALLMENTS_6_MONTHS' => rtrim(Tools::getValue('INSTALLMENTS_6_MONTHS')), - 'INSTALLMENTS_9_MONTHS' => rtrim(Tools::getValue('INSTALLMENTS_9_MONTHS')), - 'INSTALLMENTS_12_MONTHS' => rtrim(Tools::getValue('INSTALLMENTS_12_MONTHS')), - 'INSTALLMENTS_18_MONTHS' => rtrim(Tools::getValue('INSTALLMENTS_18_MONTHS')), + 'CONEKTA_CARDS' => rtrim(Tools::getValue('PAYMENT_METHS_CARD')), + 'CONEKTA_MSI' => rtrim(Tools::getValue('PAYMENT_MONTHS_INSTALLMENT')), + 'PAYMENT_METHS_CASH' => rtrim(Tools::getValue('PAYMENT_METHS_CASH')), + 'PAYMENT_METHS_SPEI' => rtrim(Tools::getValue('PAYMENT_METHS_SPEI')), + 'EXPIRATION_DATE_LIMIT' => rtrim(Tools::getValue('EXPIRATION_DATE_LIMIT')), + 'EXPIRATION_DATE_TYPE' => rtrim(Tools::getValue('EXPIRATION_DATE_TYPE')), + 'INSTALLMENTS_3_MONTHS' => rtrim(Tools::getValue('INSTALLMENTS_3_MONTHS')), + 'INSTALLMENTS_6_MONTHS' => rtrim(Tools::getValue('INSTALLMENTS_6_MONTHS')), + 'INSTALLMENTS_9_MONTHS' => rtrim(Tools::getValue('INSTALLMENTS_9_MONTHS')), + 'INSTALLMENTS_12_MONTHS' => rtrim(Tools::getValue('INSTALLMENTS_12_MONTHS')), + 'INSTALLMENTS_18_MONTHS' => rtrim(Tools::getValue('INSTALLMENTS_18_MONTHS')), ]; foreach ($configuration_values as $configuration_key => $configuration_value) { @@ -1661,29 +1714,31 @@ public function getContent() $webhook_message = false; } - $this->smarty->assign("error_webhook_message", Configuration::get('CONEKTA_WEBHOOK_ERROR_MESSAGE')); + $this->smarty->assign('error_webhook_message', Configuration::get('CONEKTA_WEBHOOK_ERROR_MESSAGE')); } else { - $this->smarty->assign("error_webhook_message", false); + $this->smarty->assign('error_webhook_message', false); } $requirements = $this->checkRequirements(); - $this->smarty->assign("_path", $this->_path); - $this->smarty->assign("requirements", $requirements); - $this->smarty->assign("config_check", $requirements['result']); + $this->smarty->assign('_path', $this->_path); + $this->smarty->assign('requirements', $requirements); + $this->smarty->assign('config_check', $requirements['result']); + if ($requirements['result']) { $this->smarty->assign( - "msg_show", + 'msg_show', $this->l('All the checks were successfully performed. You can now start using your module.') ); } else { - $this->smarty->assign("msg_show", $this->l('Please resolve the following errors:')); + $this->smarty->assign('msg_show', $this->l('Please resolve the following errors:')); } $this->html = ''; if (Tools::isSubmit('btnSubmit')) { $this->postValidation(); - if (! count($this->postErrors)) { + + if (!count($this->postErrors)) { $this->postProcess(); } else { foreach ($this->postErrors as $err) { @@ -1714,7 +1769,7 @@ public function createCustomer($customer, $params) Database::updateConektaMetadata( $customer->id, $this->conekta_mode, - "conekta_customer_id", + 'conekta_customer_id', $customerConekta->id ); @@ -1737,17 +1792,17 @@ private function createWebhook() $iso_code = $this->context->language->iso_code; \Conekta\Conekta::setApiKey($key); - \Conekta\Conekta::setPlugin("Prestashop1.7"); - \Conekta\Conekta::setApiVersion("2.0.0"); + \Conekta\Conekta::setPlugin('Prestashop1.7'); + \Conekta\Conekta::setApiVersion('2.0.0'); \Conekta\Conekta::setPluginVersion($this->version); \Conekta\Conekta::setLocale($iso_code); - $events = array( - "events" => array( - "order.paid", - "order.expired", - ) - ); + $events = [ + 'events' => [ + 'order.paid', + 'order.expired', + ], + ]; $url = Tools::safeOutput(Tools::getValue('WEB_HOOK')); @@ -1755,36 +1810,37 @@ private function createWebhook() // Obtain stored value $config_url = Tools::safeOutput(Configuration::get('CONEKTA_WEBHOOK')); - $is_valid_url = ! empty($url) && ! filter_var($url, FILTER_VALIDATE_URL) === false; - $failed_attempts = (integer)Configuration::get('CONEKTA_WEBHOOK_FAILED_ATTEMPTS'); + $is_valid_url = !empty($url) && !filter_var($url, FILTER_VALIDATE_URL) === false; + $failed_attempts = (int) Configuration::get('CONEKTA_WEBHOOK_FAILED_ATTEMPTS'); // If input is valid, has not been stored and has not failed more than 5 times if ($is_valid_url && ($config_url != $url) && ($failed_attempts < 5 && $url != Configuration::get( - 'CONEKTA_WEBHOOK_FAILED_URL' - ))) { + 'CONEKTA_WEBHOOK_FAILED_URL' + ))) { try { $webhooks = \Conekta\Webhook::where(); - $urls = array(); + $urls = []; foreach ($webhooks as $webhook) { array_push($urls, $webhook->webhook_url); } - if (! in_array($url, $urls)) { + + if (!in_array($url, $urls)) { if (Configuration::get('CONEKTA_MODE')) { - $mode = array( - "production_enabled" => 1 - ); + $mode = [ + 'production_enabled' => 1, + ]; } else { - $mode = array( - "development_enabled" => 1 - ); + $mode = [ + 'development_enabled' => 1, + ]; } \Conekta\Webhook::create( array_merge( - array( - "url" => $url - ), + [ + 'url' => $url, + ], $mode, $events ) @@ -1805,22 +1861,23 @@ private function createWebhook() if ($url == Configuration::get('CONEKTA_WEBHOOK_FAILED_URL')) { Configuration::updateValue( 'CONEKTA_WEBHOOK_ERROR_MESSAGE', - "Webhook was already register, try changing webhook!" + 'Webhook was already register, try changing webhook!' ); Configuration::deleteByName('CONEKTA_WEBHOOK_FAILED_ATTEMPTS'); $failed_attempts = 0; } elseif ($failed_attempts >= 5) { - Configuration::updateValue('CONEKTA_WEBHOOK_ERROR_MESSAGE', "Maximum failed attempts reached!"); - } elseif (! $is_valid_url) { - Configuration::updateValue('CONEKTA_WEBHOOK_ERROR_MESSAGE', "Not a valid url!"); + Configuration::updateValue('CONEKTA_WEBHOOK_ERROR_MESSAGE', 'Maximum failed attempts reached!'); + } elseif (!$is_valid_url) { + Configuration::updateValue('CONEKTA_WEBHOOK_ERROR_MESSAGE', 'Not a valid url!'); } else { Configuration::updateValue( 'CONEKTA_WEBHOOK_ERROR_MESSAGE', - "Webhook was already registered in your shop!" + 'Webhook was already registered in your shop!' ); } } - if (! empty(Configuration::get('CONEKTA_WEBHOOK_ERROR_MESSAGE'))) { + + if (!empty(Configuration::get('CONEKTA_WEBHOOK_ERROR_MESSAGE'))) { $failed_attempts = $failed_attempts + 1; Configuration::updateValue('CONEKTA_WEBHOOK_FAILED_ATTEMPTS', $failed_attempts); Configuration::updateValue('CONEKTA_WEBHOOK_FAILED_URL', $url); @@ -1838,14 +1895,15 @@ private function createWebhook() public function getJumps($total, $jumps) { if ($total >= 300 && $total < 600) { - $jumps[0] = array(1, 3); + $jumps[0] = [1, 3]; } elseif ($total >= 600 && $total < 900) { - $jumps[0] = array(1, 3, 6); + $jumps[0] = [1, 3, 6]; } elseif ($total >= 900 && $total < 1200) { - $jumps[0] = array(1, 3, 6, 9); + $jumps[0] = [1, 3, 6, 9]; } elseif ($total >= 1200) { - $jumps[0] = array(1, 3, 6, 9, 12); + $jumps[0] = [1, 3, 6, 9, 12]; } + return $jumps; } @@ -1856,36 +1914,40 @@ public function getJumps($total, $jumps) */ protected function generateCardPaymentForm() { - //value by default + // value by default $msi = 0; - $jumps = array(1); + $jumps = [1]; + if (Configuration::get('PAYMENT_MONTHS_INSTALLMENT')) { $msi = 1; $total = $this->context->cart->getOrderTotal(); $jumps = $this->getJumps($total, $jumps); } - $months = array(); - for ($i = 1; $i <= 12; $i++) { - $months[] = sprintf("%02d", $i); + $months = []; + + for ($i = 1; $i <= 12; ++$i) { + $months[] = sprintf('%02d', $i); } - $years = array(); - for ($i = 0; $i <= 10; $i++) { + $years = []; + + for ($i = 0; $i <= 10; ++$i) { $years[] = date('Y', strtotime('+' . $i . ' years')); } $this->context->smarty->assign( - array( - 'action' => $this->context->link->getModuleLink($this->name, 'validation', array(), true), - 'months' => $months, - 'years' => $years, - 'msi' => $msi, - 'msi_jumps' => $jumps[0], + [ + 'action' => $this->context->link->getModuleLink($this->name, 'validation', [], true), + 'months' => $months, + 'years' => $years, + 'msi' => $msi, + 'msi_jumps' => $jumps[0], 'test_private_key' => Configuration::get('TEST_PRIVATE_KEY'), 'charge_on_demand' => $this->charge_on_demand, - 'path' => $this->_path - ) + 'path' => $this->_path, + ] ); + return $this->context->smarty->fetch('module:conekta/views/templates/front/payment_form.tpl'); } @@ -1904,46 +1966,48 @@ public function processPayment($conektaOrderId) $iso_code = $this->context->language->iso_code; \Conekta\Conekta::setApiKey($key); - \Conekta\Conekta::setPlugin("Prestashop 1.7"); - \Conekta\Conekta::setApiVersion("2.0.0"); + \Conekta\Conekta::setPlugin('Prestashop 1.7'); + \Conekta\Conekta::setApiVersion('2.0.0'); \Conekta\Conekta::setPluginVersion($this->version); \Conekta\Conekta::setLocale($iso_code); // $cart = $this->context->cart; + try { $order = \Conekta\Order::find($conektaOrderId->id); $charge_response = $order->charges[0]; - $order_status = (int)Configuration::get('PS_OS_PAYMENT'); + $order_status = (int) Configuration::get('PS_OS_PAYMENT'); + $createAtDate = new DateTime($charge_response->created_at); $message = $this->l('Conekta Transaction Details:') . "\n\n" . $this->l( - 'Amount:' - ) . ' ' . ($charge_response->amount * 0.01) . "\n" . $this->l( - 'Status:' - ) . ' ' . ($charge_response->status == 'paid' ? $this->l('Paid') : $this->l( - 'Unpaid' - )) . "\n" . $this->l('Processed on:') . ' ' . strftime( - '%Y-%m-%d %H:%M:%S', - $charge_response->created_at - ) . "\n" . $this->l('Currency:') . ' ' . Tools::strtoupper( + 'Amount:' + ) . ' ' . ($charge_response->amount * 0.01) . "\n" . $this->l( + 'Status:' + ) . ' ' . ($charge_response->status == 'paid' ? $this->l('Paid') : $this->l( + 'Unpaid' + )) . "\n" . $this->l('Processed on:') . ' ' . $createAtDate->format('Y-m-d H:M:S') + . "\n" . $this->l('Currency:') . ' ' . Tools::strtoupper( $charge_response->currency ) . "\n" . $this->l('Mode:') . ' ' . ($charge_response->livemode == 'true' ? $this->l( 'Live' ) : $this->l('Test')) . "\n"; $this->validateOrder( - (int)$this->context->cart->id, - (int)$order_status, + (int) $this->context->cart->id, + (int) $order_status, $order->amount / 100, $this->displayName, $message, - array(), + [], null, false, $this->context->customer->secure_key ); if (version_compare(_PS_VERSION_, '1.5', '>=')) { - $new_order = new Order((int)$this->currentOrder); + $new_order = new Order((int) $this->currentOrder); + if (Validate::isLoadedObject($new_order)) { $payment = $new_order->getOrderPaymentCollection(); + if (isset($payment[0])) { $payment[0]->transaction_id = pSQL($charge_response->id); $payment[0]->save(); @@ -1952,7 +2016,8 @@ public function processPayment($conektaOrderId) } $reference = $charge_response->payment_method->reference; - if (isset($charge_response->id) && $charge_response->payment_method->type == "cash") { + + if (isset($charge_response->id) && $charge_response->payment_method->type == 'cash') { Database::insertOxxoPayment( $order, $charge_response, @@ -1960,7 +2025,7 @@ public function processPayment($conektaOrderId) $this->currentOrder, $this->context->cart->id ); - } elseif (isset($charge_response->id) && $charge_response->payment_method->type == "spei") { + } elseif (isset($charge_response->id) && $charge_response->payment_method->type == 'spei') { Database::insertSpeiPayment( $order, $charge_response, @@ -1983,12 +2048,12 @@ public function processPayment($conektaOrderId) 'order-confirmation', true, null, - array( - 'id_order' => (int)$this->currentOrder, - 'id_cart' => (int)$this->context->cart->id, - 'key' => $this->context->customer->secure_key, - 'id_module' => (int)$this->id - ) + [ + 'id_order' => (int) $this->currentOrder, + 'id_cart' => (int) $this->context->cart->id, + 'key' => $this->context->customer->secure_key, + 'id_module' => (int) $this->id, + ] ); Tools::redirect($redirect); } catch (\Exception $e) { @@ -2000,7 +2065,7 @@ public function processPayment($conektaOrderId) 2, null, 'Cart', - (int)$this->context->cart->id, + (int) $this->context->cart->id, true ); } @@ -2009,9 +2074,9 @@ public function processPayment($conektaOrderId) $controller = Configuration::get('PS_ORDER_PROCESS_TYPE') ? 'order-opc.php' : 'order.php'; $location = $this->context->link->getPageLink($controller, true) . (strpos( - $controller, - '?' - ) !== false ? '&' : '?') . 'step=3&conekta_error=1&message=' . $message . '#conekta_error'; + $controller, + '?' + ) !== false ? '&' : '?') . 'step=3&conekta_error=1&message=' . $message . '#conekta_error'; Tools::redirectLink($location); } @@ -2027,6 +2092,7 @@ public function processPayment($conektaOrderId) public function fetchTemplate($name) { $views = 'views/templates/'; + if (@filemtime(dirname(__FILE__) . '/' . $name)) { return $this->display(__FILE__, $name); } elseif (@filemtime(dirname(__FILE__) . '/' . $views . 'hook/' . $name)) { @@ -2055,28 +2121,28 @@ public function getTransactionStatus($order_id) $this->smarty->assign('conekta_tran_details', $conekta_tran_details); if ($conekta_tran_details['status'] === 'paid') { - $this->smarty->assign("color_status", "green"); - $this->smarty->assign("message_status", $this->l("Paid")); + $this->smarty->assign('color_status', 'green'); + $this->smarty->assign('message_status', $this->l('Paid')); } else { - $this->smarty->assign("color_status", "#CC0000"); - $this->smarty->assign("message_status", $this->l("Unpaid")); + $this->smarty->assign('color_status', '#CC0000'); + $this->smarty->assign('message_status', $this->l('Unpaid')); } $this->smarty->assign( - "display_price", + 'display_price', Tools::displayPrice($conekta_tran_details['amount']) ); $this->smarty->assign( - "processed_on", + 'processed_on', Tools::safeOutput($conekta_tran_details['date_add']) ); - if ($conekta_tran_details['mode'] === "live") { - $this->smarty->assign("color_mode", "green"); - $this->smarty->assign("txt_mode", $this->l("Live")); + if ($conekta_tran_details['mode'] === 'live') { + $this->smarty->assign('color_mode', 'green'); + $this->smarty->assign('txt_mode', $this->l('Live')); } else { - $this->smarty->assign("color_mode", "#CC0000"); + $this->smarty->assign('color_mode', '#CC0000'); $this->smarty->assign( - "txt_mode", + 'txt_mode', $this->l( 'Test (No payment has been processed and you will' . ' need to enable the "Live" mode)' @@ -2084,7 +2150,7 @@ public function getTransactionStatus($order_id) ); } - return $this->fetchTemplate("admin-order.tpl"); + return $this->fetchTemplate('admin-order.tpl'); } } } diff --git a/controllers/front/index.php b/controllers/front/index.php index 88701367a..201ad7d8d 100644 --- a/controllers/front/index.php +++ b/controllers/front/index.php @@ -1,35 +1,29 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * - * DISCLAIMER + * @category Conekta * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. + * @version GIT: @2.3.6@ * - * @author PrestaShop SA - * @copyright 2007-2022 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - * International Registered Trademark & Property of PrestaShop SA -*/ - + * @see https://conekta.com/ + */ header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', false); header('Pragma: no-cache'); header('Location: ../../../../'); + exit; diff --git a/controllers/front/validation.php b/controllers/front/validation.php index be4968e5c..cdec2c518 100644 --- a/controllers/front/validation.php +++ b/controllers/front/validation.php @@ -1,34 +1,34 @@ - * @copyright 2012-2022 Conekta + * @copyright 2012-2023 Conekta * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - * @category Validation - * @package Validation - * @version GIT: @2.3.5@ - * @link https://conekta.com/ + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ */ /** * ConektaValidationModuleFrontController Class Doc Comment * * @author Conekta + * * @category Class - * @package ConektaValidationModuleFrontController + * * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - * @link https://conekta.com/ + * + * @see https://conekta.com/ */ - class ConektaValidationModuleFrontController extends ModuleFrontController { /** @@ -46,13 +46,15 @@ public function postProcess() foreach (Module::getPaymentModules() as $module) { if ($module['name'] == 'conekta') { $authorized = true; + break; } } + if (!$authorized) { print_r($this->getTranslator()->trans( 'This payment method is not available.', - array(), + [], 'Modules.Conekta.Shop' )); } else { @@ -62,27 +64,27 @@ public function postProcess() $date = new DateTime(); - $order = (object) array( + $order = (object) [ 'id' => pSQL(Tools::getValue('conektaOrdenID')), 'amount' => pSQL(Tools::getValue('conektAmount')), - 'charges' => (object) array( + 'charges' => (object) [ 'id' => pSQL(Tools::getValue('chargeId')), - 'created_at' => pSQL(Tools::getValue('createAt'))? + 'created_at' => pSQL(Tools::getValue('createAt')) ? pSQL(Tools::getValue('createAt')) : $date->getTimestamp(), 'amount' => pSQL(Tools::getValue('conektAmount')), 'status' => pSQL(Tools::getValue('charge_status')), 'currency' => pSQL(Tools::getValue('charge_currency')), 'livemode' => Configuration::get('CONEKTA_MODE'), - 'payment_method' => (object) array( + 'payment_method' => (object) [ 'type' => pSQL(Tools::getValue('payment_type')), - 'reference' => pSQL(Tools::getValue('reference')) - ), - ), - 'plan_id' => pSQL(Tools::getValue('plan_id')) - ); + 'reference' => pSQL(Tools::getValue('reference')), + ], + ], + 'plan_id' => pSQL(Tools::getValue('plan_id')), + ]; $conekta->processPayment($order); - + $this->setTemplate('module:conekta/views/templates/front/payment_return.tpl'); } } diff --git a/controllers/index.php b/controllers/index.php index 6e8a072aa..7212a89d8 100644 --- a/controllers/index.php +++ b/controllers/index.php @@ -1,7 +1,5 @@ - * @copyright 2007-2022 PrestaShop SA and Contributors + * @copyright 2007-2023 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ - header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', false); header('Pragma: no-cache'); header('Location: ../../../'); + exit; diff --git a/index.php b/index.php index 1ea68f214..db82febd0 100644 --- a/index.php +++ b/index.php @@ -1,33 +1,27 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * - * DISCLAIMER + * @category Conekta * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to http://www.prestashop.com for more information. + * @version GIT: @2.3.6@ * - * @author PrestaShop SA - * @copyright 2007-2022 PrestaShop SA - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA + * @see https://conekta.com/ */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); +header('Location: ../'); -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); -header("Location: ../"); exit; diff --git a/lib/conekta-php/index.php b/lib/conekta-php/index.php index 88fcd5f2d..db82febd0 100644 --- a/lib/conekta-php/index.php +++ b/lib/conekta-php/index.php @@ -1,35 +1,27 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * - * DISCLAIMER + * @category Conekta * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to http://www.prestashop.com for more information. + * @version GIT: @2.3.6@ * - * @author PrestaShop SA - * @copyright 2007-2017 PrestaShop SA - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA + * @see https://conekta.com/ */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); +header('Location: ../'); - /* -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); -header("Location: ../"); exit; -*/ diff --git a/lib/conekta-php/lib/Conekta.php b/lib/conekta-php/lib/Conekta.php index 76a68a924..d6d41370e 100644 --- a/lib/conekta-php/lib/Conekta.php +++ b/lib/conekta-php/lib/Conekta.php @@ -1,52 +1,110 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ if (!function_exists('curl_init')) { throw new Exception('Conekta needs the CURL PHP extension.'); } + if (!function_exists('json_decode')) { throw new Exception('Conekta needs the JSON PHP extension.'); } + if (!function_exists('mb_detect_encoding')) { throw new Exception('Conekta needs the Multibyte String PHP extension.'); } + if (!function_exists('get_called_class')) { throw new Exception('Conekta needs to be run on PHP >= 5.3.0.'); } -require_once dirname(__FILE__).'/Conekta/Lang.php'; -require_once dirname(__FILE__).'/Conekta/Conekta.php'; -require_once dirname(__FILE__).'/Conekta/Util.php'; -require_once dirname(__FILE__).'/Conekta/Requestor.php'; -require_once dirname(__FILE__).'/Conekta/ConektaObject.php'; -require_once dirname(__FILE__).'/Conekta/ConektaResource.php'; -require_once dirname(__FILE__).'/Conekta/Charge.php'; -require_once dirname(__FILE__).'/Conekta/PaymentMethod.php'; -require_once dirname(__FILE__).'/Conekta/Customer.php'; -require_once dirname(__FILE__).'/Conekta/Card.php'; -require_once dirname(__FILE__).'/Conekta/Plan.php'; -require_once dirname(__FILE__).'/Conekta/Subscription.php'; -require_once dirname(__FILE__).'/Conekta/Token.php'; -require_once dirname(__FILE__).'/Conekta/Event.php'; -require_once dirname(__FILE__).'/Conekta/Payout.php'; -require_once dirname(__FILE__).'/Conekta/Payee.php'; -require_once dirname(__FILE__).'/Conekta/PayoutMethod.php'; -require_once dirname(__FILE__).'/Conekta/Method.php'; -require_once dirname(__FILE__).'/Conekta/Address.php'; -require_once dirname(__FILE__).'/Conekta/Webhook.php'; -require_once dirname(__FILE__).'/Conekta/WebhookLog.php'; -require_once dirname(__FILE__).'/Conekta/Log.php'; -require_once dirname(__FILE__).'/Conekta/Order.php'; -require_once dirname(__FILE__).'/Conekta/PaymentSource.php'; -require_once dirname(__FILE__).'/Conekta/TaxLine.php'; -require_once dirname(__FILE__).'/Conekta/DiscountLine.php'; -require_once dirname(__FILE__).'/Conekta/ShippingLine.php'; -require_once dirname(__FILE__).'/Conekta/LineItem.php'; -require_once dirname(__FILE__).'/Conekta/ConektaList.php'; -require_once dirname(__FILE__).'/Conekta/ShippingContact.php'; -require_once dirname(__FILE__).'/Conekta/Exceptions/Handler.php'; -require_once dirname(__FILE__).'/Conekta/Exceptions/ApiError.php'; -require_once dirname(__FILE__).'/Conekta/Exceptions/AuthenticationError.php'; -require_once dirname(__FILE__).'/Conekta/Exceptions/MalformedRequestError.php'; -require_once dirname(__FILE__).'/Conekta/Exceptions/NoConnectionError.php'; -require_once dirname(__FILE__).'/Conekta/Exceptions/ParameterValidationError.php'; -require_once dirname(__FILE__).'/Conekta/Exceptions/ProcessingError.php'; -require_once dirname(__FILE__).'/Conekta/Exceptions/ResourceNotFoundError.php'; + +require_once dirname(__FILE__) . '/Conekta/Lang.php'; + +require_once dirname(__FILE__) . '/Conekta/Conekta.php'; + +require_once dirname(__FILE__) . '/Conekta/Util.php'; + +require_once dirname(__FILE__) . '/Conekta/Requestor.php'; + +require_once dirname(__FILE__) . '/Conekta/ConektaObject.php'; + +require_once dirname(__FILE__) . '/Conekta/ConektaResource.php'; + +require_once dirname(__FILE__) . '/Conekta/Charge.php'; + +require_once dirname(__FILE__) . '/Conekta/PaymentMethod.php'; + +require_once dirname(__FILE__) . '/Conekta/Customer.php'; + +require_once dirname(__FILE__) . '/Conekta/Card.php'; + +require_once dirname(__FILE__) . '/Conekta/Plan.php'; + +require_once dirname(__FILE__) . '/Conekta/Subscription.php'; + +require_once dirname(__FILE__) . '/Conekta/Token.php'; + +require_once dirname(__FILE__) . '/Conekta/Event.php'; + +require_once dirname(__FILE__) . '/Conekta/Payout.php'; + +require_once dirname(__FILE__) . '/Conekta/Payee.php'; + +require_once dirname(__FILE__) . '/Conekta/PayoutMethod.php'; + +require_once dirname(__FILE__) . '/Conekta/Method.php'; + +require_once dirname(__FILE__) . '/Conekta/Address.php'; + +require_once dirname(__FILE__) . '/Conekta/Webhook.php'; + +require_once dirname(__FILE__) . '/Conekta/WebhookLog.php'; + +require_once dirname(__FILE__) . '/Conekta/Log.php'; + +require_once dirname(__FILE__) . '/Conekta/Order.php'; + +require_once dirname(__FILE__) . '/Conekta/PaymentSource.php'; + +require_once dirname(__FILE__) . '/Conekta/TaxLine.php'; + +require_once dirname(__FILE__) . '/Conekta/DiscountLine.php'; + +require_once dirname(__FILE__) . '/Conekta/ShippingLine.php'; + +require_once dirname(__FILE__) . '/Conekta/LineItem.php'; + +require_once dirname(__FILE__) . '/Conekta/ConektaList.php'; + +require_once dirname(__FILE__) . '/Conekta/ShippingContact.php'; + +require_once dirname(__FILE__) . '/Conekta/Exceptions/Handler.php'; + +require_once dirname(__FILE__) . '/Conekta/Exceptions/ApiError.php'; + +require_once dirname(__FILE__) . '/Conekta/Exceptions/AuthenticationError.php'; + +require_once dirname(__FILE__) . '/Conekta/Exceptions/MalformedRequestError.php'; + +require_once dirname(__FILE__) . '/Conekta/Exceptions/NoConnectionError.php'; + +require_once dirname(__FILE__) . '/Conekta/Exceptions/ParameterValidationError.php'; + +require_once dirname(__FILE__) . '/Conekta/Exceptions/ProcessingError.php'; + +require_once dirname(__FILE__) . '/Conekta/Exceptions/ResourceNotFoundError.php'; diff --git a/lib/conekta-php/lib/Conekta/Address.php b/lib/conekta-php/lib/Conekta/Address.php index 66d69df3c..c64535d87 100644 --- a/lib/conekta-php/lib/Conekta/Address.php +++ b/lib/conekta-php/lib/Conekta/Address.php @@ -1,18 +1,40 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \Conekta\ConektaResource; - class Address extends ConektaResource { - public $street1 = ""; - public $street2 = ""; - public $street3 = ""; - public $city = ""; - public $state = ""; - public $zip = ""; - public $country = ""; + public $street1 = ''; + + public $street2 = ''; + + public $street3 = ''; + + public $city = ''; + + public $state = ''; + + public $zip = ''; + + public $country = ''; public function __get($property) { diff --git a/lib/conekta-php/lib/Conekta/Card.php b/lib/conekta-php/lib/Conekta/Card.php index ae94ddc45..a90dbad8b 100644 --- a/lib/conekta-php/lib/Conekta/Card.php +++ b/lib/conekta-php/lib/Conekta/Card.php @@ -1,23 +1,44 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \Conekta\ConektaResource; -use \Conekta\Lang; -use \Conekta\Exceptions; -use \Conekta\Conekta; - class Card extends ConektaResource { - public $createdAt = ""; - public $last4 = ""; - public $bin = ""; - public $name = ""; - public $expMonth = ""; - public $expYear = ""; - public $brand = ""; - public $parentId = ""; - public $default = ""; + public $createdAt = ''; + + public $last4 = ''; + + public $bin = ''; + + public $name = ''; + + public $expMonth = ''; + + public $expYear = ''; + + public $brand = ''; + + public $parentId = ''; + + public $default = ''; public function __get($property) { @@ -31,7 +52,6 @@ public function __isset($property) return isset($this->$property); } - public function instanceUrl() { $this->apiVersion = Conekta::$apiVersion; @@ -41,7 +61,7 @@ public function instanceUrl() $base = $this->classUrl($class); $extn = urlencode($id); $customerUrl = $this->customer->instanceUrl(); - + return $customerUrl . $base . "/{$extn}"; } diff --git a/lib/conekta-php/lib/Conekta/Charge.php b/lib/conekta-php/lib/Conekta/Charge.php index 30caefc47..ad60be38f 100644 --- a/lib/conekta-php/lib/Conekta/Charge.php +++ b/lib/conekta-php/lib/Conekta/Charge.php @@ -1,28 +1,60 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \Conekta\ConektaResource; - class Charge extends ConektaResource { - public $livemode = ""; - public $amount = ""; - public $createdAt = ""; - public $currency = ""; - public $description = ""; - public $referenceId = ""; - public $failureCode = ""; - public $failureMessage = ""; - public $fee = ""; - public $monthlyInstallments = ""; - public $deviceFingerprint = ""; - public $status = ""; - public $exchangeRate = ""; - public $foreignCurrency = ""; - public $amountInForeignCurrency = ""; - public $checkoutId = ""; - public $checkoutOrderCount = ""; + public $livemode = ''; + + public $amount = ''; + + public $createdAt = ''; + + public $currency = ''; + + public $description = ''; + + public $referenceId = ''; + + public $failureCode = ''; + + public $failureMessage = ''; + + public $fee = ''; + + public $monthlyInstallments = ''; + + public $deviceFingerprint = ''; + + public $status = ''; + + public $exchangeRate = ''; + + public $foreignCurrency = ''; + + public $amountInForeignCurrency = ''; + + public $checkoutId = ''; + + public $checkoutOrderCount = ''; public function __get($property) { @@ -65,8 +97,9 @@ public function capture() public function refund($amount = null) { $params = null; + if (isset($amount)) { - $params = array('amount' => $amount); + $params = ['amount' => $amount]; } return parent::_customAction('post', 'refund', $params); diff --git a/lib/conekta-php/lib/Conekta/Conekta.php b/lib/conekta-php/lib/Conekta/Conekta.php index 313595ab4..e29632682 100644 --- a/lib/conekta-php/lib/Conekta/Conekta.php +++ b/lib/conekta-php/lib/Conekta/Conekta.php @@ -1,48 +1,71 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; abstract class Conekta { public static $apiKey; + public static $apiBase = 'https://api.conekta.io'; + public static $apiVersion = '2.0.0'; + public static $locale = 'es'; + public static $plugin = ''; + public static $pluginVersion = ''; - const VERSION = '4.0.2'; - + public const VERSION = '4.0.2'; + public static function setApiKey($apiKey) { self::$apiKey = $apiKey; } - + public static function setApiVersion($version) { self::$apiVersion = $version; } - + public static function setLocale($locale) { self::$locale = $locale; } - + public static function setPlugin($plugin = '') { self::$plugin = $plugin; } - + public static function setPluginVersion($pluginVersion = '') { self::$pluginVersion = $pluginVersion; } - + public static function getPlugin() { return self::$plugin; } - + public static function getPluginVersion() { return self::$pluginVersion; diff --git a/lib/conekta-php/lib/Conekta/ConektaList.php b/lib/conekta-php/lib/Conekta/ConektaList.php index 338191e77..59123e73b 100644 --- a/lib/conekta-php/lib/Conekta/ConektaList.php +++ b/lib/conekta-php/lib/Conekta/ConektaList.php @@ -1,18 +1,30 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \Conekta\ConektaResource; -use \Conekta\Requestor; -use \Conekta\Util; -use \Conekta\Exceptions; -use \Conekta\Conekta; - class ConektaList extends ConektaObject { - const LIMIT = 5; + public const LIMIT = 5; - public function __construct($elements_type, $params = array()) + public function __construct($elements_type, $params = []) { parent::__construct(); $this->elements_type = $elements_type; @@ -34,7 +46,7 @@ public function loadFromArray($values = null) { if (isset($values)) { $this->has_more = $values['has_more']; - $this->total = $values['total']; + $this->total = $values['total']; foreach ($this as $key => $value) { $this->_unsetKey($key); @@ -46,19 +58,20 @@ public function loadFromArray($values = null) } } - public function next($options = array('limit' => self::LIMIT)) + public function next($options = ['limit' => self::LIMIT]) { - if (sizeOf($this) > 0) { + if (sizeof($this) > 0) { $this->params['next'] = end($this)->id; } $this->params['previous'] = null; + return $this->_moveCursor($options['limit']); } - public function previous($options = array('limit' => self::LIMIT)) + public function previous($options = ['limit' => self::LIMIT]) { - if (sizeOf($this) > 0) { + if (sizeof($this) > 0) { $this->params['previous'] = $this[0]->id; } diff --git a/lib/conekta-php/lib/Conekta/ConektaObject.php b/lib/conekta-php/lib/Conekta/ConektaObject.php index 9e58b6217..095089124 100644 --- a/lib/conekta-php/lib/Conekta/ConektaObject.php +++ b/lib/conekta-php/lib/Conekta/ConektaObject.php @@ -1,9 +1,26 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \ArrayObject; -use \Conekta\Util; +use ArrayObject; class ConektaObject extends ArrayObject { @@ -11,7 +28,7 @@ class ConektaObject extends ArrayObject public function __construct($id = null) { - $this->_values = array(); + $this->_values = []; $this->id = $id; } @@ -33,15 +50,18 @@ public function loadFromArray($values) if (is_array($val)) { $val = Util::convertToConektaObject($val); } + if (strpos(get_class($this), 'ConektaObject') !== false) { $this[$object] = $val; } else { if (strpos($object, 'url') !== false && strpos(get_class($this), 'Webhook') !== false) { - $object = "webhook_url"; + $object = 'webhook_url'; } $this->$object = $val; - if ($object == "metadata") { + + if ($object == 'metadata') { $this->metadata = new ConektaObject(); + if (is_array($val) || is_object($val)) { foreach ($val as $object2 => $val2) { $this->metadata->$object2 = $val2; @@ -65,7 +85,8 @@ public function __toJSON() protected function _toArray() { - $array = array(); + $array = []; + foreach ($this->_values as $object => $val) { if (is_object($val) == true && get_class($val) != '') { if (empty($val->_values) != true) { diff --git a/lib/conekta-php/lib/Conekta/ConektaResource.php b/lib/conekta-php/lib/Conekta/ConektaResource.php index 85b0e81cb..2f7a50594 100644 --- a/lib/conekta-php/lib/Conekta/ConektaResource.php +++ b/lib/conekta-php/lib/Conekta/ConektaResource.php @@ -1,14 +1,25 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \Conekta\ConektaObject; -use \Conekta\Requestor; -use \Conekta\NoConnectionError; -use \Conekta\Lang; -use \Conekta\Util; -use \Conekta\Conekta; - abstract class ConektaResource extends ConektaObject { public static function className($class) @@ -17,6 +28,7 @@ public static function className($class) if ($postfix = strrchr($class, '\\')) { $class = substr($postfix, 1); } + if (substr($class, 0, strlen('Conekta')) == 'Conekta') { $class = substr($class, strlen('Conekta')); } @@ -31,24 +43,22 @@ protected static function _getBase($class, $method) { $args = array_slice(func_get_args(), 2); - return call_user_func_array(array($class, $method), $args); + return call_user_func_array([$class, $method], $args); } public static function classUrl($class = null) { if (empty($class)) { - throw new NoConnectionError( - Lang::translate('error.resource.id', Lang::EN, array('RESOURCE' => "NULL")), - Lang::translate('error.resource.id_purchaser', Conekta::$locale) - ); + throw new NoConnectionError(Lang::translate('error.resource.id', Lang::EN, ['RESOURCE' => 'NULL']), Lang::translate('error.resource.id_purchaser', Conekta::$locale)); } $base = self::_getBase($class, 'className', $class); + return "/{$base}s"; } protected static function _scpWhere($class, $params) { - if (Conekta::$apiVersion == "2.0.0") { + if (Conekta::$apiVersion == '2.0.0') { $path = explode('\\', $class); $instance = new ConektaList(array_pop($path)); } else { @@ -99,15 +109,17 @@ protected function idValidator($id) { if (!$id) { $error = new ParameterValidationError( - Lang::translate('error.resource.id', Lang::EN, array('RESOURCE' => get_class())), + Lang::translate('error.resource.id', Lang::EN, ['RESOURCE' => get_class()]), Lang::translate('error.resource.id_purchaser', Conekta::$locale) ); - if (Conekta::$apiVersion == "2.0.0") { + if (Conekta::$apiVersion == '2.0.0') { $handler = new Handler(); $handler = $error; + throw $handler; } + throw $error; } } @@ -115,14 +127,17 @@ protected function idValidator($id) protected function _delete($parent = null, $member = null) { self::_customAction('delete', null, null); + if (isset($parent) && isset($member)) { $obj = $this->$parent->$member; + if (strpos(get_class($obj), 'ConektaObject') !== false) { foreach ($this->$parent->$member as $k => $v) { if (strpos($v->id, $this->id) !== false) { $this->$parent->$member->_values = Util::shiftArray($this->$parent->$member->_values, $k); $this->$parent->$member->loadFromArray($this->$parent->$member->_values); $this->$parent->$member->offsetUnset(count($this->$parent->$member) - 1); + break; } } @@ -145,7 +160,7 @@ protected function _update($params) protected function _createMember($member, $params) { $requestor = new Requestor(); - $url = $this->instanceUrl().'/'.$member; + $url = $this->instanceUrl() . '/' . $member; $response = $requestor->request('post', $url, $params); if (strpos(get_class($this->$member), 'ConektaList') !== false || @@ -165,7 +180,7 @@ protected function _createMember($member, $params) } else { $this->$member->loadFromArray(array_merge( $this->$member->_toArray(), - array($response) + [$response] )); $this->loadFromArray(); @@ -188,8 +203,9 @@ protected function _createMember($member, $params) protected function _customAction($method = 'post', $action = null, $params = null) { $requestor = new Requestor(); + if (isset($action)) { - $url = $this->instanceUrl().'/'.$action; + $url = $this->instanceUrl() . '/' . $action; } else { $url = $this->instanceUrl(); } @@ -205,7 +221,7 @@ protected function _createMemberWithRelation($member, $params, $parent) $parent_class = strtolower((new \ReflectionClass($parent))->getShortName()); $child = self::_createMember($member, $params); $child->$parent_class = $parent; - + return $child; } } diff --git a/lib/conekta-php/lib/Conekta/Customer.php b/lib/conekta-php/lib/Conekta/Customer.php index 5d151cea2..4074a5761 100644 --- a/lib/conekta-php/lib/Conekta/Customer.php +++ b/lib/conekta-php/lib/Conekta/Customer.php @@ -1,22 +1,48 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \Conekta\ConektaResource; - class Customer extends ConektaResource { - public $livemode = ""; - public $name = ""; - public $email = ""; - public $phone = ""; - public $defaultShippingContactId = ""; - public $defaultPaymentSourceId = ""; - public $referrer = ""; - public $accountAge = ""; - public $paidTransactions = ""; - public $firstPaidAt = ""; - public $corporate = ""; + public $livemode = ''; + + public $name = ''; + + public $email = ''; + + public $phone = ''; + + public $defaultShippingContactId = ''; + + public $defaultPaymentSourceId = ''; + + public $referrer = ''; + + public $accountAge = ''; + + public $paidTransactions = ''; + + public $firstPaidAt = ''; + + public $corporate = ''; public function __get($property) { @@ -37,16 +63,17 @@ public function loadFromArray($values = null) } if (Conekta::$apiVersion == '2.0.0') { - $submodels = array( - 'payment_sources', 'shipping_contacts' - ); + $submodels = [ + 'payment_sources', 'shipping_contacts', + ]; + foreach ($submodels as $submodel) { if (isset($values[$submodel])) { $submodel_list = new ConektaList($submodel, $values[$submodel]); $submodel_list->loadFromArray($values[$submodel]); $this->$submodel->_values = $submodel_list; } else { - $submodel_list = new ConektaList($submodel, array()); + $submodel_list = new ConektaList($submodel, []); } $this->$submodel = $submodel_list; @@ -55,7 +82,8 @@ public function loadFromArray($values = null) } } } else { - $submodels = array('cards'); + $submodels = ['cards']; + foreach ($submodels as $submodel) { if (isset($this->$submodel)) { $submodel_list = $this->$submodel; @@ -75,7 +103,6 @@ public function loadFromArray($values = null) } } - public static function find($id) { $class = get_called_class(); @@ -118,11 +145,12 @@ public function deletePaymentSourceById($paymentSourceId) $currentCustomer = $this; $paymentSources = $currentCustomer->payment_sources; $index = 0; + foreach ($paymentSources as $paymentSource) { if ($paymentSource->id == $paymentSourceId) { $currentCustomer->payment_sources[$index]->delete(); } else { - $index += 1; + ++$index; } } } diff --git a/lib/conekta-php/lib/Conekta/DiscountLine.php b/lib/conekta-php/lib/Conekta/DiscountLine.php index 177f658a8..d04fb0605 100644 --- a/lib/conekta-php/lib/Conekta/DiscountLine.php +++ b/lib/conekta-php/lib/Conekta/DiscountLine.php @@ -1,18 +1,34 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \Conekta\ConektaResource; -use \Conekta\Lang; -use \Conekta\Exceptions; -use \Conekta\Conekta; - class DiscountLine extends ConektaResource { - public $code = ""; - public $amount = ""; - public $type = ""; - public $parentId = ""; + public $code = ''; + + public $amount = ''; + + public $type = ''; + + public $parentId = ''; public function __get($property) { @@ -35,7 +51,7 @@ public function instanceUrl() $base = $this->classUrl($class); $extn = urlencode($id); $orderUrl = $this->order->instanceUrl(); - + return $orderUrl . $base . "/{$extn}"; } diff --git a/lib/conekta-php/lib/Conekta/Event.php b/lib/conekta-php/lib/Conekta/Event.php index bcf08f711..ac580e908 100644 --- a/lib/conekta-php/lib/Conekta/Event.php +++ b/lib/conekta-php/lib/Conekta/Event.php @@ -1,16 +1,36 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \Conekta\ConektaResource; - class Event extends ConektaResource { - public $data = ""; - public $livemode = ""; - public $webhookStatus = ""; - public $createdAt = ""; - public $type = ""; + public $data = ''; + + public $livemode = ''; + + public $webhookStatus = ''; + + public $createdAt = ''; + + public $type = ''; public function __get($property) { diff --git a/lib/conekta-php/lib/Conekta/Exceptions/ApiError.php b/lib/conekta-php/lib/Conekta/Exceptions/ApiError.php index f943dcb51..bbc1248d1 100644 --- a/lib/conekta-php/lib/Conekta/Exceptions/ApiError.php +++ b/lib/conekta-php/lib/Conekta/Exceptions/ApiError.php @@ -1,11 +1,25 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \Conekta\Conekta; -use \Conekta\Exceptions; -use \Exception; - class ApiError extends Handler { } diff --git a/lib/conekta-php/lib/Conekta/Exceptions/AuthenticationError.php b/lib/conekta-php/lib/Conekta/Exceptions/AuthenticationError.php index 5cd78f00b..0bcf73f2e 100644 --- a/lib/conekta-php/lib/Conekta/Exceptions/AuthenticationError.php +++ b/lib/conekta-php/lib/Conekta/Exceptions/AuthenticationError.php @@ -1,11 +1,25 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \Conekta\Conekta; -use \Conekta\Exceptions; -use \Exception; - class AuthenticationError extends Handler { } diff --git a/lib/conekta-php/lib/Conekta/Exceptions/Handler.php b/lib/conekta-php/lib/Conekta/Exceptions/Handler.php index 147945142..16f861e9b 100644 --- a/lib/conekta-php/lib/Conekta/Exceptions/Handler.php +++ b/lib/conekta-php/lib/Conekta/Exceptions/Handler.php @@ -1,14 +1,30 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \Conekta\Lang; -use \Conekta\Conekta; -use \Conekta\Exceptions; -use \Exception; +use Exception; /** * @construct __construct(String $message, String $messageToPurchaser, String $type, String $code, String $params, Array $errorStack) + * * @method void object __get() * @method void object __isset() * @method exception build(Object $response, String $httpcode) @@ -28,6 +44,7 @@ public function __construct($message = null, $messageToPurchaser = null, $type = $this->params = $params; $this->errorStack = json_encode($errorStack); } + public function __get($property) { if (property_exists($this, $property)) { @@ -44,49 +61,58 @@ public static function build($resp = null, $httpCode) { if (isset($httpCode) != true || $httpCode == 0) { return new NoConnectionError( - Lang::translate('error.requestor.connection', Lang::EN, array('BASE' => Conekta::$apiBase)), + Lang::translate('error.requestor.connection', Lang::EN, ['BASE' => Conekta::$apiBase]), Lang::translate('error.requestor.connection_purchaser', Conekta::$locale) ); } $type = self::assignIfSet($resp, 'type'); - $errorStack =array(); - if (array_key_exists('details', $resp)) { //API 2.0.0 + $errorStack = []; + + if (array_key_exists('details', $resp)) { // API 2.0.0 foreach ($resp['details'] as $params) { - //parameter validation + // parameter validation $errorStack['details'][] = $params; - $message = self::assignIfSet($params, 'message'); + $message = self::assignIfSet($params, 'message'); $messageToPurchaser = self::assignIfSet($params, 'message_to_purchaser'); - $param = self::assignIfSet($params, 'params'); - $debugMessage = self::assignIfSet($params, 'debug_message'); - $code = self::assignIfSet($params, 'code'); + $param = self::assignIfSet($params, 'params'); + $debugMessage = self::assignIfSet($params, 'debug_message'); + $code = self::assignIfSet($params, 'code'); } - } else {//API 1.0.0 - //parameter validation + } else { // API 1.0.0 + // parameter validation $errorStack = $resp; - $message = self::assignIfSet($resp, 'message'); + $message = self::assignIfSet($resp, 'message'); $messageToPurchaser = self::assignIfSet($resp, 'message_to_purchaser'); - $param = self::assignIfSet($resp, 'params'); - $debugMessage = self::assignIfSet($resp, 'debug_message'); - $code = self::assignIfSet($resp, 'code'); + $param = self::assignIfSet($resp, 'params'); + $debugMessage = self::assignIfSet($resp, 'debug_message'); + $code = self::assignIfSet($resp, 'code'); } - $errorStack['type'] = array("error_type"=>$type,"error_code" => $httpCode); + $errorStack['type'] = ['error_type' => $type, 'error_code' => $httpCode]; + switch ($httpCode) { - case 400: - return new MalformedRequestError($message, $messageToPurchaser, $type, $code, $param, $errorStack); - case 401: - return new AuthenticationError($message, $messageToPurchaser, $type, $code, $param, $errorStack); - case 402: - return new ProcessingError($message, $messageToPurchaser, $type, $code, $param, $errorStack); - case 404: - return new ResourceNotFoundError($message, $messageToPurchaser, $type, $code, $param, $errorStack); - case 422: - return new ParameterValidationError($message, $messageToPurchaser, $type, $code, $param, $errorStack); - case 500: - return new ApiError($message, $messageToPurchaser, $type, $code, $param, $errorStack); - default: - return new self($message, $messageToPurchaser, $type, $code, $param, $errorStack); - } + case 400: + return new MalformedRequestError($message, $messageToPurchaser, $type, $code, $param, $errorStack); + + case 401: + return new AuthenticationError($message, $messageToPurchaser, $type, $code, $param, $errorStack); + + case 402: + return new ProcessingError($message, $messageToPurchaser, $type, $code, $param, $errorStack); + + case 404: + return new ResourceNotFoundError($message, $messageToPurchaser, $type, $code, $param, $errorStack); + + case 422: + return new ParameterValidationError($message, $messageToPurchaser, $type, $code, $param, $errorStack); + + case 500: + return new ApiError($message, $messageToPurchaser, $type, $code, $param, $errorStack); + + default: + return new self($message, $messageToPurchaser, $type, $code, $param, $errorStack); + } } + public function getConektaMessage() { return json_decode($this->errorStack); @@ -96,11 +122,13 @@ public static function errorHandler($resp, $httpCode) { throw Handler::build($resp, $httpCode); } + public static function assignIfSet($parameter, $index) { if (array_key_exists($index, $parameter)) { return isset($parameter[$index]) ? $parameter[$index] : null; } + return null; } } diff --git a/lib/conekta-php/lib/Conekta/Exceptions/MalformedRequestError.php b/lib/conekta-php/lib/Conekta/Exceptions/MalformedRequestError.php index 1009cec31..2eb33a621 100644 --- a/lib/conekta-php/lib/Conekta/Exceptions/MalformedRequestError.php +++ b/lib/conekta-php/lib/Conekta/Exceptions/MalformedRequestError.php @@ -1,9 +1,24 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ -use \Conekta\Conekta; -use \Conekta\Exceptions; -use \Exception; +namespace Conekta; class MalformedRequestError extends Handler { diff --git a/lib/conekta-php/lib/Conekta/Exceptions/NoConnectionError.php b/lib/conekta-php/lib/Conekta/Exceptions/NoConnectionError.php index 33c810717..dd7bcc34b 100644 --- a/lib/conekta-php/lib/Conekta/Exceptions/NoConnectionError.php +++ b/lib/conekta-php/lib/Conekta/Exceptions/NoConnectionError.php @@ -1,11 +1,25 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \Conekta\Conekta; -use \Conekta\Exceptions; -use \Exception; - class NoConnectionError extends Handler { } diff --git a/lib/conekta-php/lib/Conekta/Exceptions/ParameterValidationError.php b/lib/conekta-php/lib/Conekta/Exceptions/ParameterValidationError.php index 11e73bc71..5ef356954 100644 --- a/lib/conekta-php/lib/Conekta/Exceptions/ParameterValidationError.php +++ b/lib/conekta-php/lib/Conekta/Exceptions/ParameterValidationError.php @@ -1,11 +1,25 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \Conekta\Conekta; -use \Conekta\Exceptions; -use \Exception; - class ParameterValidationError extends Handler { } diff --git a/lib/conekta-php/lib/Conekta/Exceptions/ProcessingError.php b/lib/conekta-php/lib/Conekta/Exceptions/ProcessingError.php index 9773d814e..0bc1351a0 100644 --- a/lib/conekta-php/lib/Conekta/Exceptions/ProcessingError.php +++ b/lib/conekta-php/lib/Conekta/Exceptions/ProcessingError.php @@ -1,9 +1,24 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ -use \Conekta\Conekta; -use \Conekta\Exceptions; -use \Exception; +namespace Conekta; class ProcessingError extends Handler { diff --git a/lib/conekta-php/lib/Conekta/Exceptions/ResourceNotFoundError.php b/lib/conekta-php/lib/Conekta/Exceptions/ResourceNotFoundError.php index 59b0e8ee0..dca4e6451 100644 --- a/lib/conekta-php/lib/Conekta/Exceptions/ResourceNotFoundError.php +++ b/lib/conekta-php/lib/Conekta/Exceptions/ResourceNotFoundError.php @@ -1,9 +1,24 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ -use \Conekta\Conekta; -use \Conekta\Exceptions; -use \Exception; +namespace Conekta; class ResourceNotFoundError extends Handler { diff --git a/lib/conekta-php/lib/Conekta/Exceptions/index.php b/lib/conekta-php/lib/Conekta/Exceptions/index.php index 88fcd5f2d..db82febd0 100644 --- a/lib/conekta-php/lib/Conekta/Exceptions/index.php +++ b/lib/conekta-php/lib/Conekta/Exceptions/index.php @@ -1,35 +1,27 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * - * DISCLAIMER + * @category Conekta * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to http://www.prestashop.com for more information. + * @version GIT: @2.3.6@ * - * @author PrestaShop SA - * @copyright 2007-2017 PrestaShop SA - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA + * @see https://conekta.com/ */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); +header('Location: ../'); - /* -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); -header("Location: ../"); exit; -*/ diff --git a/lib/conekta-php/lib/Conekta/Lang.php b/lib/conekta-php/lib/Conekta/Lang.php index 3dc746633..e686b7bee 100644 --- a/lib/conekta-php/lib/Conekta/Lang.php +++ b/lib/conekta-php/lib/Conekta/Lang.php @@ -1,21 +1,40 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; class Lang { - const EN = 'en'; - const ES = 'es'; + public const EN = 'en'; - protected static $cache = array(); + public const ES = 'es'; + + protected static $cache = []; public static function translate($key, $locale, $parameters = null) { - $parameters = str_replace("Conekta\\", "", $parameters); + $parameters = str_replace('Conekta\\', '', $parameters); $langs = self::readDirectory(dirname(__FILE__) . '/../locales/messages'); - $keys = explode('.', $locale.'.'.$key); + $keys = explode('.', $locale . '.' . $key); $result = $langs[array_shift($keys)]; foreach ($keys as $val) { @@ -37,12 +56,13 @@ protected static function readDirectory($directory) return self::$cache; } - $langs = array(); + $langs = []; + if ($handle = opendir($directory)) { while ($lang = readdir($handle)) { if (strpos($lang, '.php') !== false) { $langKey = str_replace('.php', '', $lang); - $langs[$langKey] = include $directory.'/'.$lang; + $langs[$langKey] = include $directory . '/' . $lang; } } diff --git a/lib/conekta-php/lib/Conekta/LineItem.php b/lib/conekta-php/lib/Conekta/LineItem.php index 6ed9b81dd..a6008b070 100644 --- a/lib/conekta-php/lib/Conekta/LineItem.php +++ b/lib/conekta-php/lib/Conekta/LineItem.php @@ -1,24 +1,46 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \Conekta\ConektaResource; -use \Conekta\Lang; -use \Conekta\Exceptions; -use \Conekta\Conekta; - class LineItem extends ConektaResource { - public $name = ""; - public $description = ""; - public $unitPrice = ""; - public $quantity = ""; - public $sku = ""; - public $shippable = ""; - public $tags = ""; - public $brand = ""; - public $type = ""; - public $parentId = ""; + public $name = ''; + + public $description = ''; + + public $unitPrice = ''; + + public $quantity = ''; + + public $sku = ''; + + public $shippable = ''; + + public $tags = ''; + + public $brand = ''; + + public $type = ''; + + public $parentId = ''; public function __get($property) { @@ -41,7 +63,7 @@ public function instanceUrl() $base = $this->classUrl($class); $extn = urlencode($id); $orderUrl = $this->order->instanceUrl(); - + return $orderUrl . $base . "/{$extn}"; } diff --git a/lib/conekta-php/lib/Conekta/Log.php b/lib/conekta-php/lib/Conekta/Log.php index ccadd5fa9..ca3812eb0 100644 --- a/lib/conekta-php/lib/Conekta/Log.php +++ b/lib/conekta-php/lib/Conekta/Log.php @@ -1,21 +1,46 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \Conekta\ConektaResource; - class Log extends ConektaResource { - public $method = ""; - public $url = ""; - public $status = ""; - public $version = ""; - public $ipAddress = ""; - public $related = ""; - public $requestBody = ""; - public $requestHeaders = ""; - public $createdAt = ""; - public $queryString = ""; + public $method = ''; + + public $url = ''; + + public $status = ''; + + public $version = ''; + + public $ipAddress = ''; + + public $related = ''; + + public $requestBody = ''; + + public $requestHeaders = ''; + + public $createdAt = ''; + + public $queryString = ''; public function __get($property) { diff --git a/lib/conekta-php/lib/Conekta/Method.php b/lib/conekta-php/lib/Conekta/Method.php index 31a664761..fad39c5fd 100644 --- a/lib/conekta-php/lib/Conekta/Method.php +++ b/lib/conekta-php/lib/Conekta/Method.php @@ -1,9 +1,25 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \Conekta\ConektaResource; - class Method extends ConektaResource { } diff --git a/lib/conekta-php/lib/Conekta/Order.php b/lib/conekta-php/lib/Conekta/Order.php index e37ef7e15..15e40390e 100644 --- a/lib/conekta-php/lib/Conekta/Order.php +++ b/lib/conekta-php/lib/Conekta/Order.php @@ -1,20 +1,44 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \Conekta\ConektaResource; - class Order extends ConektaResource { - public $livemode = ""; - public $amount = ""; - public $paymentStatus = ""; - public $customerId = ""; - public $currency = ""; - public $capture = ""; - public $metadata = ""; - public $createdAt = ""; - public $updatedAt = ""; + public $livemode = ''; + + public $amount = ''; + + public $paymentStatus = ''; + + public $customerId = ''; + + public $currency = ''; + + public $capture = ''; + + public $metadata = ''; + + public $createdAt = ''; + + public $updatedAt = ''; public function __get($property) { @@ -34,9 +58,9 @@ public function loadFromArray($values = null) parent::loadFromArray($values); } - $submodels = array( - 'tax_lines', 'shipping_lines', 'discount_lines', 'line_items', 'charges', 'returns' - ); + $submodels = [ + 'tax_lines', 'shipping_lines', 'discount_lines', 'line_items', 'charges', 'returns', + ]; foreach ($submodels as $submodel) { if (isset($values[$submodel])) { @@ -49,7 +73,7 @@ public function loadFromArray($values = null) $val->order = $this; } } else { - $this->$submodel = new ConektaList($submodel, array()); + $this->$submodel = new ConektaList($submodel, []); } } } diff --git a/lib/conekta-php/lib/Conekta/Payee.php b/lib/conekta-php/lib/Conekta/Payee.php index 9630c28e0..ff965d403 100644 --- a/lib/conekta-php/lib/Conekta/Payee.php +++ b/lib/conekta-php/lib/Conekta/Payee.php @@ -1,17 +1,38 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \Conekta\ConektaResource; - class Payee extends ConektaResource { - public $email = ""; - public $name = ""; - public $phone = ""; - public $livemode = ""; - public $defaultDestinationId = ""; - public $createdAt = ""; + public $email = ''; + + public $name = ''; + + public $phone = ''; + + public $livemode = ''; + + public $defaultDestinationId = ''; + + public $createdAt = ''; public function __get($property) { @@ -30,6 +51,7 @@ public function loadFromArray($values = null) if (isset($values)) { parent::loadFromArray($values); } + foreach ($this->payout_methods as $object => $val) { if (isset($val->deleted) != true) { $val->payee = &$this; diff --git a/lib/conekta-php/lib/Conekta/PaymentMethod.php b/lib/conekta-php/lib/Conekta/PaymentMethod.php index e2a5dc955..787ce09f5 100644 --- a/lib/conekta-php/lib/Conekta/PaymentMethod.php +++ b/lib/conekta-php/lib/Conekta/PaymentMethod.php @@ -1,9 +1,25 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \Conekta\ConektaResource; - class PaymentMethod extends ConektaResource { } diff --git a/lib/conekta-php/lib/Conekta/PaymentSource.php b/lib/conekta-php/lib/Conekta/PaymentSource.php index eaf13bbb2..6a75e5f44 100644 --- a/lib/conekta-php/lib/Conekta/PaymentSource.php +++ b/lib/conekta-php/lib/Conekta/PaymentSource.php @@ -1,16 +1,30 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \Conekta\ConektaResource; -use \Conekta\Lang; -use \Conekta\Error; -use \Conekta\Conekta; - class PaymentSource extends ConektaResource { - const TYPE_CARD = 'card'; - const TYPE_OXXO_RECURRENT = 'oxxo_recurrent'; + public const TYPE_CARD = 'card'; + + public const TYPE_OXXO_RECURRENT = 'oxxo_recurrent'; public function instanceUrl() { @@ -18,10 +32,10 @@ public function instanceUrl() $id = $this->id; parent::idValidator($id); $class = get_class($this); - $base = "/payment_sources"; + $base = '/payment_sources'; $extn = urlencode($id); $customerUrl = $this->customer->instanceUrl(); - + return $customerUrl . $base . "/{$extn}"; } @@ -37,7 +51,8 @@ public function delete() /** * Method for determine if is card - * @return boolean + * + * @return bool */ public function isCard() { @@ -46,7 +61,8 @@ public function isCard() /** * Method for determine if is oxxo recurrent - * @return boolean + * + * @return bool */ public function isOxxoRecurrent() { diff --git a/lib/conekta-php/lib/Conekta/Payout.php b/lib/conekta-php/lib/Conekta/Payout.php index 2bd123138..2e581ea7a 100644 --- a/lib/conekta-php/lib/Conekta/Payout.php +++ b/lib/conekta-php/lib/Conekta/Payout.php @@ -1,9 +1,25 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \Conekta\ConektaResource; - class Payout extends ConektaResource { public static function find($id) diff --git a/lib/conekta-php/lib/Conekta/PayoutMethod.php b/lib/conekta-php/lib/Conekta/PayoutMethod.php index 32bcb8f41..3b4ea3bec 100644 --- a/lib/conekta-php/lib/Conekta/PayoutMethod.php +++ b/lib/conekta-php/lib/Conekta/PayoutMethod.php @@ -1,12 +1,25 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \Conekta\ConektaResource; -use \Conekta\Lang; -use \Conekta\Exceptions; -use \Conekta\Conekta; - class PayoutMethod extends ConektaResource { public function instanceUrl() @@ -18,7 +31,7 @@ public function instanceUrl() $base = $this->classUrl($class); $extn = urlencode($id); $payeeUrl = $this->payee->instanceUrl(); - + return $payeeUrl . $base . "/{$extn}"; } diff --git a/lib/conekta-php/lib/Conekta/Plan.php b/lib/conekta-php/lib/Conekta/Plan.php index 3db5ba8c7..937783297 100644 --- a/lib/conekta-php/lib/Conekta/Plan.php +++ b/lib/conekta-php/lib/Conekta/Plan.php @@ -1,9 +1,25 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \Conekta\ConektaResource; - class Plan extends ConektaResource { public static function find($id) diff --git a/lib/conekta-php/lib/Conekta/Requestor.php b/lib/conekta-php/lib/Conekta/Requestor.php index a0c9e62af..ce674a344 100644 --- a/lib/conekta-php/lib/Conekta/Requestor.php +++ b/lib/conekta-php/lib/Conekta/Requestor.php @@ -1,23 +1,33 @@ - */ + * NOTICE OF LICENSE + * Title : Conekta Card Payment Gateway for Prestashop + * Author : Conekta.io + * URL : https://www.conekta.io/es/docs/plugins/prestashop. + * PHP Version 7.0.0 + * Conekta File Doc Comment + * + * @author Conekta + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \Conekta\Conekta; -use \Conekta\Handler; - /** - * @method string apiUrl($urls string) - * @method array() additionalPluginHeaders() - * @method array() setHeaders() - * @method json request($method string, $url string, $params array()) - * @method string buildQueryParamsUrl($url string, $params arraay()) - * @method string buildSegmentParamsUrl($url string, $params arraay()) - */ + * @method string apiUrl($urls string) + * @method array() additionalPluginHeaders() + * @method array() setHeaders() + * @method json request($method string, $url string, $params array()) + * @method string buildQueryParamsUrl($url string, $params arraay()) + * @method string buildSegmentParamsUrl($url string, $params arraay()) + */ class Requestor { public $apiKey; @@ -35,6 +45,7 @@ public function __construct() * get Base path of conekta api i.e. https://api.conekta.com * * @param url (string) endpoint to concatenate + * * @return (string) */ public static function apiUrl($url = '') @@ -53,10 +64,10 @@ public static function apiUrl($url = '') */ private function additionalPluginHeaders() { - return array( + return [ 'plugin_name' => Conekta::getPlugin(), - 'plugin_version' => Conekta::getPluginVersion() - ); + 'plugin_version' => Conekta::getPluginVersion(), + ]; } /** @@ -69,26 +80,26 @@ private function additionalPluginHeaders() private function setHeaders() { $pluginAgent = $this->additionalPluginHeaders(); - $userAgent = array( + $userAgent = [ 'bindings_version' => Conekta::VERSION, - 'lang' => 'php', - 'lang_version' => phpversion(), - 'publisher' => 'conekta', - 'uname' => php_uname(), - ); + 'lang' => 'php', + 'lang_version' => phpversion(), + 'publisher' => 'conekta', + 'uname' => php_uname(), + ]; if (array_filter($pluginAgent)) { $userAgent = array_merge($userAgent, $pluginAgent); } - - $headers = array( - 'Accept: application/vnd.conekta-v'.Conekta::$apiVersion.'+json', - 'Accept-Language: '.Conekta::$locale, - 'X-Conekta-Client-User-Agent: '.json_encode($userAgent), - 'User-Agent: Conekta/v1 PhpBindings/'.Conekta::VERSION, - 'Authorization: Basic '.base64_encode($this->apiKey.':'), - 'Content-Type: application/json' - ); + + $headers = [ + 'Accept: application/vnd.conekta-v' . Conekta::$apiVersion . '+json', + 'Accept-Language: ' . Conekta::$locale, + 'X-Conekta-Client-User-Agent: ' . json_encode($userAgent), + 'User-Agent: Conekta/v1 PhpBindings/' . Conekta::VERSION, + 'Authorization: Basic ' . base64_encode($this->apiKey . ':'), + 'Content-Type: application/json', + ]; return $headers; } @@ -101,6 +112,7 @@ private function setHeaders() * @param method (string) REST action [DELETE,PUT,POST,GET] * @param url (string) endpoint to concatenate * @param params (array) contains body request + * * @return (json) */ public function request($method, $url, $params = null) @@ -109,29 +121,37 @@ public function request($method, $url, $params = null) $headers = $this->setHeaders(); $curl = curl_init(); $method = strtolower($method); - $opts = array(); + $opts = []; switch ($method) { - case 'get': - $opts[CURLOPT_HTTPGET] = 1; - $url = $this->buildQueryParamsUrl($url, $params); - break; - case 'post': - $opts[CURLOPT_POST] = 1; - $opts[CURLOPT_POSTFIELDS] = $jsonParams; - break; - case 'put': - $opts[CURLOPT_RETURNTRANSFER] = 1; - $opts[CURLOPT_CUSTOMREQUEST] = 'PUT'; - $opts[CURLOPT_POSTFIELDS] = $jsonParams; - break; - case 'delete': - $opts[CURLOPT_CUSTOMREQUEST] = 'DELETE'; - $url = $this->buildSegmentParamsUrl($url, $params); - break; - default: - throw new \Exception('Wrong method'); - } + case 'get': + $opts[CURLOPT_HTTPGET] = 1; + $url = $this->buildQueryParamsUrl($url, $params); + + break; + + case 'post': + $opts[CURLOPT_POST] = 1; + $opts[CURLOPT_POSTFIELDS] = $jsonParams; + + break; + + case 'put': + $opts[CURLOPT_RETURNTRANSFER] = 1; + $opts[CURLOPT_CUSTOMREQUEST] = 'PUT'; + $opts[CURLOPT_POSTFIELDS] = $jsonParams; + + break; + + case 'delete': + $opts[CURLOPT_CUSTOMREQUEST] = 'DELETE'; + $url = $this->buildSegmentParamsUrl($url, $params); + + break; + + default: + throw new \Exception('Wrong method'); + } $url = $this->apiUrl($url); $opts[CURLOPT_URL] = $url; @@ -141,7 +161,7 @@ public function request($method, $url, $params = null) $opts[CURLOPT_RETURNTRANSFER] = true; $opts[CURLOPT_HTTPHEADER] = $headers; $opts[CURLOPT_SSLVERSION] = 6; - $opts[CURLOPT_CAINFO] = dirname(__FILE__).'/../ssl_data/ca_bundle.crt'; + $opts[CURLOPT_CAINFO] = dirname(__FILE__) . '/../ssl_data/ca_bundle.crt'; curl_setopt_array($curl, $opts); $response = curl_exec($curl); $responseCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); @@ -163,13 +183,14 @@ public function request($method, $url, $params = null) * * @param url (string) endpoint to concatenate * @param params (array) contains body request + * * @return (string) */ private function buildQueryParamsUrl($url, $params) { if (!is_null($params)) { $params = http_build_query($params); - $url = $url.'?'.$params; + $url = $url . '?' . $params; } return $url; @@ -182,12 +203,13 @@ private function buildQueryParamsUrl($url, $params) * * @param url (string) endpoint to concatenate * @param params (array) contains body request + * * @return (string) */ private function buildSegmentParamsUrl($url, $params) { if (!is_array($params)) { - $url = $url.urlencode($params); + $url = $url . urlencode($params); } return $url; diff --git a/lib/conekta-php/lib/Conekta/ShippingContact.php b/lib/conekta-php/lib/Conekta/ShippingContact.php index 0a550140a..a395b63ff 100644 --- a/lib/conekta-php/lib/Conekta/ShippingContact.php +++ b/lib/conekta-php/lib/Conekta/ShippingContact.php @@ -1,19 +1,36 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \Conekta\ConektaResource; -use \Conekta\Lang; -use \Conekta\Exceptions; -use \Conekta\Conekta; - class ShippingContact extends ConektaResource { - public $receiver = ""; - public $phone = ""; - public $betweenStreets = ""; - public $parentId = ""; - public $default = ""; + public $receiver = ''; + + public $phone = ''; + + public $betweenStreets = ''; + + public $parentId = ''; + + public $default = ''; public function __get($property) { @@ -27,7 +44,6 @@ public function __isset($property) return isset($this->$property); } - public function instanceUrl() { $this->apiVersion = Conekta::$apiVersion; @@ -37,7 +53,7 @@ public function instanceUrl() $base = $this->classUrl($class); $extn = urlencode($id); $customerUrl = $this->customer->instanceUrl(); - + return $customerUrl . $base . "/{$extn}"; } diff --git a/lib/conekta-php/lib/Conekta/ShippingLine.php b/lib/conekta-php/lib/Conekta/ShippingLine.php index 4c7c6a3db..dbd72b47b 100644 --- a/lib/conekta-php/lib/Conekta/ShippingLine.php +++ b/lib/conekta-php/lib/Conekta/ShippingLine.php @@ -1,12 +1,25 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \Conekta\ConektaResource; -use \Conekta\Lang; -use \Conekta\Exceptions; -use \Conekta\Conekta; - class ShippingLine extends ConektaResource { public function instanceUrl() @@ -18,7 +31,7 @@ public function instanceUrl() $base = $this->classUrl($class); $extn = urlencode($id); $orderUrl = $this->order->instanceUrl(); - + return $orderUrl . $base . "/{$extn}"; } diff --git a/lib/conekta-php/lib/Conekta/Subscription.php b/lib/conekta-php/lib/Conekta/Subscription.php index 726ed043c..c8bd09c4a 100644 --- a/lib/conekta-php/lib/Conekta/Subscription.php +++ b/lib/conekta-php/lib/Conekta/Subscription.php @@ -1,12 +1,25 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \Conekta\ConektaResource; -use \Conekta\Lang; -use \Conekta\Conekta; -use \Conekta\Exceptions; - class Subscription extends ConektaResource { public function instanceUrl() @@ -17,7 +30,7 @@ public function instanceUrl() $class = get_class($this); $base = '/subscription'; $customerUrl = $this->customer->instanceUrl(); - + return $customerUrl . $base; } diff --git a/lib/conekta-php/lib/Conekta/TaxLine.php b/lib/conekta-php/lib/Conekta/TaxLine.php index 8d30e6cec..1a19190d4 100644 --- a/lib/conekta-php/lib/Conekta/TaxLine.php +++ b/lib/conekta-php/lib/Conekta/TaxLine.php @@ -1,12 +1,25 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \Conekta\ConektaResource; -use \Conekta\Lang; -use \Conekta\Exceptions; -use \Conekta\Conekta; - class TaxLine extends ConektaResource { public function instanceUrl() @@ -18,7 +31,7 @@ public function instanceUrl() $base = $this->classUrl($class); $extn = urlencode($id); $orderUrl = $this->order->instanceUrl(); - + return $orderUrl . $base . "/{$extn}"; } diff --git a/lib/conekta-php/lib/Conekta/Token.php b/lib/conekta-php/lib/Conekta/Token.php index 33032cbb5..788ebc0d5 100644 --- a/lib/conekta-php/lib/Conekta/Token.php +++ b/lib/conekta-php/lib/Conekta/Token.php @@ -1,9 +1,25 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \Conekta\ConektaResource; - class Token extends ConektaResource { public static function find($id) @@ -16,7 +32,7 @@ public static function find($id) public static function create($params = null) { $class = get_called_class(); - + return parent::_scpCreate($class, $params); } diff --git a/lib/conekta-php/lib/Conekta/Util.php b/lib/conekta-php/lib/Conekta/Util.php index 57c3c7408..0f26dd616 100644 --- a/lib/conekta-php/lib/Conekta/Util.php +++ b/lib/conekta-php/lib/Conekta/Util.php @@ -1,43 +1,60 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \Conekta\ConektaObject; - abstract class Util { - public static $types = array( - 'webhook' => '\Conekta\Webhook', - 'webhook_log' => '\Conekta\WebhookLog', - 'billing_address' => '\Conekta\Address', + public static $types = [ + 'webhook' => '\Conekta\Webhook', + 'webhook_log' => '\Conekta\WebhookLog', + 'billing_address' => '\Conekta\Address', 'bank_transfer_payout_method' => '\Conekta\Method', - 'payout' => '\Conekta\Payout', - 'payee' => '\Conekta\Payee', - 'payout_method' => '\Conekta\PayoutMethod', - 'card_payment' => '\Conekta\PaymentMethod', - 'cash_payment' => '\Conekta\PaymentMethod', - 'bank_transfer_payment' => '\Conekta\PaymentMethod', - 'card' => '\Conekta\Card', - 'charge' => '\Conekta\Charge', - 'customer' => '\Conekta\Customer', - 'event' => '\Conekta\Event', - 'plan' => '\Conekta\Plan', - 'subscription' => '\Conekta\Subscription', - 'payment_source' => '\Conekta\PaymentSource', - 'tax_line' => '\Conekta\TaxLine', - 'shipping_line' => '\Conekta\ShippingLine', - 'discount_line' => '\Conekta\DiscountLine', - 'conekta_list' => '\Conekta\ConektaList', - 'shipping_contact' => '\Conekta\ShippingContact', - 'lang' => '\Conekta\Lang', - 'line_item' => '\Conekta\LineItem', - 'order' => '\Conekta\Order', - 'token' => '\Conekta\Token' - ); + 'payout' => '\Conekta\Payout', + 'payee' => '\Conekta\Payee', + 'payout_method' => '\Conekta\PayoutMethod', + 'card_payment' => '\Conekta\PaymentMethod', + 'cash_payment' => '\Conekta\PaymentMethod', + 'bank_transfer_payment' => '\Conekta\PaymentMethod', + 'card' => '\Conekta\Card', + 'charge' => '\Conekta\Charge', + 'customer' => '\Conekta\Customer', + 'event' => '\Conekta\Event', + 'plan' => '\Conekta\Plan', + 'subscription' => '\Conekta\Subscription', + 'payment_source' => '\Conekta\PaymentSource', + 'tax_line' => '\Conekta\TaxLine', + 'shipping_line' => '\Conekta\ShippingLine', + 'discount_line' => '\Conekta\DiscountLine', + 'conekta_list' => '\Conekta\ConektaList', + 'shipping_contact' => '\Conekta\ShippingContact', + 'lang' => '\Conekta\Lang', + 'line_item' => '\Conekta\LineItem', + 'order' => '\Conekta\Order', + 'token' => '\Conekta\Token', + ]; public static function convertToConektaObject($resp) { $types = self::$types; + if (is_array($resp)) { if (isset($resp['object']) && is_string($resp['object']) && isset($types[$resp['object']])) { $class = $types[$resp['object']]; diff --git a/lib/conekta-php/lib/Conekta/Webhook.php b/lib/conekta-php/lib/Conekta/Webhook.php index 32da670e8..c0ba1e3f2 100644 --- a/lib/conekta-php/lib/Conekta/Webhook.php +++ b/lib/conekta-php/lib/Conekta/Webhook.php @@ -1,9 +1,25 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \Conekta\ConektaResource; - class Webhook extends ConektaResource { public static function find($id) diff --git a/lib/conekta-php/lib/Conekta/WebhookLog.php b/lib/conekta-php/lib/Conekta/WebhookLog.php index 0cc757ce9..edb8cfe4b 100644 --- a/lib/conekta-php/lib/Conekta/WebhookLog.php +++ b/lib/conekta-php/lib/Conekta/WebhookLog.php @@ -1,9 +1,25 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \Conekta\ConektaResource; - class WebhookLog extends ConektaResource { } diff --git a/lib/conekta-php/lib/Conekta/index.php b/lib/conekta-php/lib/Conekta/index.php index 2f80a422e..db82febd0 100644 --- a/lib/conekta-php/lib/Conekta/index.php +++ b/lib/conekta-php/lib/Conekta/index.php @@ -1,32 +1,27 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * - * DISCLAIMER + * @category Conekta * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to http://www.prestashop.com for more information. + * @version GIT: @2.3.6@ * - * @author PrestaShop SA - * @copyright 2007-2017 PrestaShop SA - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA + * @see https://conekta.com/ */ -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); -header("Location: ../"); +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); +header('Location: ../'); + exit; diff --git a/lib/conekta-php/lib/index.php b/lib/conekta-php/lib/index.php index 2f80a422e..db82febd0 100644 --- a/lib/conekta-php/lib/index.php +++ b/lib/conekta-php/lib/index.php @@ -1,32 +1,27 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * - * DISCLAIMER + * @category Conekta * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to http://www.prestashop.com for more information. + * @version GIT: @2.3.6@ * - * @author PrestaShop SA - * @copyright 2007-2017 PrestaShop SA - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA + * @see https://conekta.com/ */ -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); -header("Location: ../"); +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); +header('Location: ../'); + exit; diff --git a/lib/conekta-php/lib/locales/index.php b/lib/conekta-php/lib/locales/index.php index 88fcd5f2d..db82febd0 100644 --- a/lib/conekta-php/lib/locales/index.php +++ b/lib/conekta-php/lib/locales/index.php @@ -1,35 +1,27 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * - * DISCLAIMER + * @category Conekta * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to http://www.prestashop.com for more information. + * @version GIT: @2.3.6@ * - * @author PrestaShop SA - * @copyright 2007-2017 PrestaShop SA - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA + * @see https://conekta.com/ */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); +header('Location: ../'); - /* -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); -header("Location: ../"); exit; -*/ diff --git a/lib/conekta-php/lib/locales/messages/en.php b/lib/conekta-php/lib/locales/messages/en.php index de3a0d968..cb72f51d5 100644 --- a/lib/conekta-php/lib/locales/messages/en.php +++ b/lib/conekta-php/lib/locales/messages/en.php @@ -1,14 +1,31 @@ array( - 'resource' => array( +/** + * NOTICE OF LICENSE + * Title : Conekta Card Payment Gateway for Prestashop + * Author : Conekta.io + * URL : https://www.conekta.io/es/docs/plugins/prestashop. + * PHP Version 7.0.0 + * Conekta File Doc Comment + * + * @author Conekta + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ +return [ + 'error' => [ + 'resource' => [ 'id' => 'Could not get the id of RESOURCE instance.', 'id_purchaser' => 'There was an error. Please contact system administrator.', - ), - 'requestor' => array( + ], + 'requestor' => [ 'connection' => 'Could not connect to BASE.', 'connection_purchaser' => 'Could not connect to payment system.', - ), - ), -); + ], + ], +]; diff --git a/lib/conekta-php/lib/locales/messages/es.php b/lib/conekta-php/lib/locales/messages/es.php index 06efe9739..45392a142 100644 --- a/lib/conekta-php/lib/locales/messages/es.php +++ b/lib/conekta-php/lib/locales/messages/es.php @@ -1,14 +1,31 @@ array( - 'resource' => array( +/** + * NOTICE OF LICENSE + * Title : Conekta Card Payment Gateway for Prestashop + * Author : Conekta.io + * URL : https://www.conekta.io/es/docs/plugins/prestashop. + * PHP Version 7.0.0 + * Conekta File Doc Comment + * + * @author Conekta + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ +return [ + 'error' => [ + 'resource' => [ 'id' => 'No se pudo obtener el id de la instancia de RESOURCE.', 'id_purchaser' => 'Hubo un error. Favor de contactar al administrador del sistema.', - ), - 'requestor' => array( + ], + 'requestor' => [ 'connection' => 'No se pudo conectar a BASE.', 'connection_purchaser' => 'No se pudo conectar al sistema de pagos.', - ), - ), -); + ], + ], +]; diff --git a/lib/conekta-php/lib/locales/messages/index.php b/lib/conekta-php/lib/locales/messages/index.php index 88fcd5f2d..db82febd0 100644 --- a/lib/conekta-php/lib/locales/messages/index.php +++ b/lib/conekta-php/lib/locales/messages/index.php @@ -1,35 +1,27 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * - * DISCLAIMER + * @category Conekta * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to http://www.prestashop.com for more information. + * @version GIT: @2.3.6@ * - * @author PrestaShop SA - * @copyright 2007-2017 PrestaShop SA - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA + * @see https://conekta.com/ */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); +header('Location: ../'); - /* -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); -header("Location: ../"); exit; -*/ diff --git a/lib/conekta-php/lib/ssl_data/index.php b/lib/conekta-php/lib/ssl_data/index.php index 88fcd5f2d..db82febd0 100644 --- a/lib/conekta-php/lib/ssl_data/index.php +++ b/lib/conekta-php/lib/ssl_data/index.php @@ -1,35 +1,27 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * - * DISCLAIMER + * @category Conekta * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to http://www.prestashop.com for more information. + * @version GIT: @2.3.6@ * - * @author PrestaShop SA - * @copyright 2007-2017 PrestaShop SA - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA + * @see https://conekta.com/ */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); +header('Location: ../'); - /* -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); -header("Location: ../"); exit; -*/ diff --git a/lib/conekta-php/test/BaseTest.php b/lib/conekta-php/test/BaseTest.php index 6099ec4f8..b2511c51b 100644 --- a/lib/conekta-php/test/BaseTest.php +++ b/lib/conekta-php/test/BaseTest.php @@ -1,14 +1,33 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; -use \PHPUnit\Framework\TestCase; +use PHPUnit\Framework\TestCase; class BaseTest extends TestCase { public function setApiKey() { $apiEnvKey = getenv('CONEKTA_API'); + if (!$apiEnvKey) { $apiEnvKey = 'key_ZLy4aP2szht1HqzkCezDEA'; } diff --git a/lib/conekta-php/test/Conekta-1.0/ChargeTest.php b/lib/conekta-php/test/Conekta-1.0/ChargeTest.php index b7ca3c521..4e4c5a661 100644 --- a/lib/conekta-php/test/Conekta-1.0/ChargeTest.php +++ b/lib/conekta-php/test/Conekta-1.0/ChargeTest.php @@ -1,68 +1,86 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; class ChargeTest extends BaseTest { - public static $valid_payment_method = array( + public static $valid_payment_method = [ 'amount' => 2000, 'currency' => 'mxn', 'description' => 'Some desc', - 'details' => array( + 'details' => [ 'name' => 'Arnulfo Quimare', 'phone' => '403-342-0642', 'email' => 'logan@x-men.org', - 'customer' => array( + 'customer' => [ 'logged_in' => true, 'successful_purchases' => 14, 'created_at' => 1379784950, 'updated_at' => 1379784950, 'offline_payments' => 4, - 'score' => 9 - ), - 'line_items' => array( - array( + 'score' => 9, + ], + 'line_items' => [ + [ 'name' => 'Box of Cohiba S1s', 'description' => 'Imported From Mex.', 'unit_price' => 20000, 'quantity' => 1, 'sku' => 'cohb_s1', - 'category' => 'food' - ) - ) - ) - ); + 'category' => 'food', + ], + ], + ], + ]; - public static $intvalid_payment_method = array( + public static $intvalid_payment_method = [ 'amount' => 10, 'currency' => 'mxn', 'description' => 'Some desc', - 'details' => array( + 'details' => [ 'name' => 'Arnulfo Quimare', 'phone' => '403-342-0642', 'email' => 'logan@x-men.org', - 'customer' => array( + 'customer' => [ 'logged_in' => true, 'successful_purchases' => 14, 'created_at' => 1379784950, 'updated_at' => 1379784950, 'offline_payments' => 4, - 'score' => 9 - ), - 'line_items' => array( - array( + 'score' => 9, + ], + 'line_items' => [ + [ 'name' => 'Box of Cohiba S1s', 'description' => 'Imported From Mex.', 'unit_price' => 20000, 'quantity' => 1, 'sku' => 'cohb_s1', - 'category' => 'food' - ) - ) - ) - ); + 'category' => 'food', + ], + ], + ], + ]; - public static $valid_visa_card = array('card' => 'tok_test_visa_4242'); + public static $valid_visa_card = ['card' => 'tok_test_visa_4242']; public function testSuccesfulWhere() { @@ -79,6 +97,7 @@ public function testUnsuccesfulPMCreate() $card = self::$valid_visa_card; $this->setApiKey(); $this->setApiVersion('1.0.0'); + try { $cpm = Charge::create(array_merge($pm, $card)); } catch (\Exception $e) { @@ -106,6 +125,7 @@ public function testUnsuccesfulRefund() $this->setApiVersion('1.0.0'); $cpm = Charge::create(array_merge($pm, $card)); $this->assertTrue($cpm->status == 'paid'); + try { $cpm->refund(3000); } catch (\Exception $e) { @@ -123,7 +143,7 @@ public function testSuccesfulCapture() $this->setApiVersion('1.0.0'); $pm = self::$valid_payment_method; $card = self::$valid_visa_card; - $capture = array('capture' => false); + $capture = ['capture' => false]; $this->setApiKey(); $cpm = Charge::create(array_merge($pm, $card, $capture)); $this->assertTrue($cpm->status == 'pre_authorized'); diff --git a/lib/conekta-php/test/Conekta-1.0/ConektaTest.php b/lib/conekta-php/test/Conekta-1.0/ConektaTest.php index fc0ebff76..db82febd0 100644 --- a/lib/conekta-php/test/Conekta-1.0/ConektaTest.php +++ b/lib/conekta-php/test/Conekta-1.0/ConektaTest.php @@ -1,30 +1,27 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); +header('Location: ../'); -namespace Conekta; - -class ConektaTest extends BaseTest -{ - public function setPlugin($plugin) - { - Conekta::setPlugin($plugin); - } - - public function setEnvLocale($locale) - { - Conekta::setLocale($locale); - } - - public function testApiLocaleInitializerStyle() - { - $this->setEnvLocale('en'); - $this->assertTrue(Conekta::$locale == 'en'); - $this->setEnvLocale('es'); - } - - public function testPluginInitializerStyle() - { - $this->setApiKey(); - $this->setPlugin('spree'); - $this->assertTrue(Conekta::$plugin == 'spree'); - } -} +exit; diff --git a/lib/conekta-php/test/Conekta-1.0/CustomerTest.php b/lib/conekta-php/test/Conekta-1.0/CustomerTest.php index b8dc6be67..82783cf02 100644 --- a/lib/conekta-php/test/Conekta-1.0/CustomerTest.php +++ b/lib/conekta-php/test/Conekta-1.0/CustomerTest.php @@ -1,13 +1,31 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; class CustomerTest extends BaseTest { - public static $validCustomer = array( + public static $validCustomer = [ 'email' => 'hola@hola.com', - 'name' => 'John Constantine' - ); + 'name' => 'John Constantine', + ]; public function testSuccesfulCustomerFind() { @@ -33,21 +51,20 @@ public function testSuccesfulCustomerUpdate() $this->setApiVersion('1.0.0'); $customer = Customer::create(self::$validCustomer); $customer->update( - array( - 'name' => 'Logan', + [ + 'name' => 'Logan', 'email' => 'logan@x-men.org', - ) + ] ); $this->assertTrue(strpos($customer->name, 'Logan') !== false); } - public function testAddCardToCustomer() { $this->setApiKey(); $this->setApiVersion('1.0.0'); $customer = Customer::create(self::$validCustomer); - $customer->createCard(array('token' => 'tok_test_visa_1881')); + $customer->createCard(['token' => 'tok_test_visa_1881']); $this->assertTrue(strpos(end($customer->cards)->last4, '1881') !== false); } @@ -55,7 +72,7 @@ public function testDeleteCard() { $this->setApiKey(); $this->setApiVersion('1.0.0'); - $card = array('cards' => array('tok_test_visa_4242')); + $card = ['cards' => ['tok_test_visa_4242']]; $customer = Customer::create(array_merge(self::$validCustomer, $card)); $card = $customer->cards[0]->delete(); $this->assertTrue($card->deleted == true); @@ -65,9 +82,9 @@ public function testUpdateCard() { $this->setApiKey(); $this->setApiVersion('1.0.0'); - $card = array('cards' => array('tok_test_visa_4242')); + $card = ['cards' => ['tok_test_visa_4242']]; $customer = Customer::create(array_merge(self::$validCustomer, $card)); - $customer->cards[0]->update(array('token' => 'tok_test_mastercard_4444', 'active' => false)); + $customer->cards[0]->update(['token' => 'tok_test_mastercard_4444', 'active' => false]); $this->assertTrue(strpos($customer->cards[0]->last4, '4444') !== false); } @@ -76,9 +93,9 @@ public function testSuccesfulSubscriptionCreate() $this->setApiKey(); $this->setApiVersion('1.0.0'); $customer = Customer::create(self::$validCustomer); - $card = array('cards' => array('tok_test_visa_4242')); + $card = ['cards' => ['tok_test_visa_4242']]; $customer = Customer::create(array_merge(self::$validCustomer, $card)); - $subscription = $customer->createSubscription(array('plan' => 'gold-plan')); + $subscription = $customer->createSubscription(['plan' => 'gold-plan']); $this->assertTrue(strpos(get_class($subscription), 'Conekta\Subscription') !== false); } @@ -87,26 +104,27 @@ public function testSuccesfulSubscriptionUpdate() $this->setApiKey(); $this->setApiVersion('1.0.0'); $customer = Customer::create(self::$validCustomer); - $card = array('cards' => array('tok_test_visa_4242')); + $card = ['cards' => ['tok_test_visa_4242']]; $customer = Customer::create(array_merge(self::$validCustomer, $card)); - $subscription = $customer->createSubscription(array('plan' => 'gold-plan')); + $subscription = $customer->createSubscription(['plan' => 'gold-plan']); + try { $plan = Plan::find('gold-plan2'); } catch (\Exception $e) { $plan = Plan::create( - array( - 'id' => 'gold-plan2', - 'name' => 'Gold Plan', - 'amount' => 10000, - 'currency' => 'MXN', - 'interval' => 'month', - 'frequency' => 1, + [ + 'id' => 'gold-plan2', + 'name' => 'Gold Plan', + 'amount' => 10000, + 'currency' => 'MXN', + 'interval' => 'month', + 'frequency' => 1, 'trial_period_days' => 15, - 'expiry_count' => 12, - ) + 'expiry_count' => 12, + ] ); } - $subscription->update(array('plan' => $plan->id)); + $subscription->update(['plan' => $plan->id]); $this->assertTrue(strpos($subscription->plan_id, 'gold-plan2') !== false); } @@ -115,9 +133,10 @@ public function testUnsuccesfulSubscriptionCreate() $this->setApiKey(); $this->setApiVersion('1.0.0'); $customer = Customer::create(self::$validCustomer); + try { - $subscription = $customer->createSubscription(array( - 'plan' => 'unexistent-plan', )); + $subscription = $customer->createSubscription([ + 'plan' => 'unexistent-plan', ]); } catch (\Exception $e) { $this->assertTrue(strpos($e->getMessage(), 'The object Plan "unexistent-plan" could not be found.') !== false); } @@ -128,9 +147,9 @@ public function testSuccesfulSubscriptionPause() $this->setApiKey(); $this->setApiVersion('1.0.0'); $customer = Customer::create(self::$validCustomer); - $card = array('cards' => array('tok_test_visa_4242')); + $card = ['cards' => ['tok_test_visa_4242']]; $customer = Customer::create(array_merge(self::$validCustomer, $card)); - $subscription = $customer->createSubscription(array('plan' => 'gold-plan')); + $subscription = $customer->createSubscription(['plan' => 'gold-plan']); $this->assertTrue(strpos(get_class($subscription), 'Subscription') !== false); $subscription->pause(); $this->assertTrue(strpos($subscription->status, 'paused') !== false); @@ -141,9 +160,9 @@ public function testSuccesfulSubscriptionResume() $this->setApiKey(); $this->setApiVersion('1.0.0'); $customer = Customer::create(self::$validCustomer); - $card = array('cards' => array('tok_test_visa_4242')); + $card = ['cards' => ['tok_test_visa_4242']]; $customer = Customer::create(array_merge(self::$validCustomer, $card)); - $subscription = $customer->createSubscription(array('plan' => 'gold-plan')); + $subscription = $customer->createSubscription(['plan' => 'gold-plan']); $this->assertTrue(strpos(get_class($subscription), 'Subscription') !== false); $subscription->pause(); $subscription->resume(); @@ -155,9 +174,9 @@ public function testSuccesfulSubscriptionCancel() $this->setApiKey(); $this->setApiVersion('1.0.0'); $customer = Customer::create(self::$validCustomer); - $card = array('cards' => array('tok_test_visa_4242')); + $card = ['cards' => ['tok_test_visa_4242']]; $customer = Customer::create(array_merge(self::$validCustomer, $card)); - $subscription = $customer->createSubscription(array('plan' => 'gold-plan')); + $subscription = $customer->createSubscription(['plan' => 'gold-plan']); $this->assertTrue(strpos(get_class($subscription), 'Subscription') !== false); $subscription->cancel(); $this->assertTrue(strpos($subscription->status, 'canceled') !== false); diff --git a/lib/conekta-php/test/Conekta-1.0/ErrorTest.php b/lib/conekta-php/test/Conekta-1.0/ErrorTest.php index 5b1a74bec..31c554e30 100644 --- a/lib/conekta-php/test/Conekta-1.0/ErrorTest.php +++ b/lib/conekta-php/test/Conekta-1.0/ErrorTest.php @@ -1,4 +1,22 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; @@ -10,37 +28,41 @@ public function unsetApiKey() $env = Conekta::setApiKey(''); } } - public static $validOrder = array( - 'line_items' => array( - array( + + public static $validOrder = [ + 'line_items' => [ + [ 'name' => 'Box of Cohiba S1s', 'description' => 'Imported From Mex.', 'unit_price' => 20000, 'quantity' => 1, 'sku' => 'cohb_s1', 'category' => 'food', - 'tags' => array('food', 'mexican food') - ) - ), - 'currency' => 'mxn', - 'metadata' => array('test' => 'extra info') - ); - public static $otherParams = array( + 'tags' => ['food', 'mexican food'], + ], + ], + 'currency' => 'mxn', + 'metadata' => ['test' => 'extra info'], + ]; + + public static $otherParams = [ 'currency' => 'mxn', - 'customer_info' => array( + 'customer_info' => [ 'name' => 'John Constantine', 'phone' => '+5213353319758', - 'email' => 'hola@hola.com' - ) - ); + 'email' => 'hola@hola.com', + ], + ]; + public static $invalidCustomer = - array('email' => 'hola@hola.com', - 'cards' => array('tok_test_visa_4241') - ); + ['email' => 'hola@hola.com', + 'cards' => ['tok_test_visa_4241'], + ]; public function testNoIdError() { $this->setApiKey(); + try { $customer = Customer::find('0'); } catch (\Exception $e) { @@ -53,8 +75,9 @@ public function testNoConnectionError() $this->setApiKey(); $apiUrl = Conekta::$apiBase; Conekta::$apiBase = 'http://localhost:3001'; + try { - $customer = Customer::create(array('cards' => array('tok_test_visa_4241'))); + $customer = Customer::create(['cards' => ['tok_test_visa_4241']]); } catch (\Exception $e) { $this->assertTrue(strpos(get_class($e), 'NoConnectionError') == true); } @@ -64,6 +87,7 @@ public function testNoConnectionError() public function testParameterValidationError() { $this->setApiKey(); + try { $customer = Customer::create(self::$invalidCustomer); } catch (\Exception $e) { @@ -74,15 +98,18 @@ public function testParameterValidationError() public function testResourceNotFoundError() { $this->setApiKey(); + try { $customer = Customer::find('2'); } catch (\Exception $e) { $this->assertTrue(strpos(get_class($e), 'ResourceNotFoundError') == true); } } + public function testAuthenticationError() { $this->unsetApiKey(); + try { $customer = Customer::create(); } catch (\Exception $e) { @@ -90,18 +117,19 @@ public function testAuthenticationError() } $this->setApiKey(); } + public function testUnknowApiRequest() { $this->setApiKey(); - $validVisaCard =array( - 'payment_method' => array( + $validVisaCard = [ + 'payment_method' => [ 'type' => 'card', - 'token_id' => 'tok_test_insufficient_funds') - ); + 'token_id' => 'tok_test_insufficient_funds', ], + ]; try { $orderParams = array_merge(self::$validOrder, self::$otherParams); - $order = Order::create($orderParams); + $order = Order::create($orderParams); $charge = $order->createCharge($validVisaCard); } catch (\Exception $e) { $this->assertTrue(strpos(get_class($e), 'ResourceNotFoundError') == true); diff --git a/lib/conekta-php/test/Conekta-1.0/EventTest.php b/lib/conekta-php/test/Conekta-1.0/EventTest.php index cab6848dc..8767a19c6 100644 --- a/lib/conekta-php/test/Conekta-1.0/EventTest.php +++ b/lib/conekta-php/test/Conekta-1.0/EventTest.php @@ -1,4 +1,22 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; diff --git a/lib/conekta-php/test/Conekta-1.0/LangTest.php b/lib/conekta-php/test/Conekta-1.0/LangTest.php index 5b447382f..db82febd0 100644 --- a/lib/conekta-php/test/Conekta-1.0/LangTest.php +++ b/lib/conekta-php/test/Conekta-1.0/LangTest.php @@ -1,16 +1,27 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); +header('Location: ../'); -namespace Conekta; - -class LangTest extends BaseTest -{ - public function testShouldTranslatesMessage() - { - $langEnTest = Lang::translate('error.resource.id_purchaser', Lang::EN); - $langEsTest = Lang::translate('error.resource.id_purchaser', Lang::ES); - $langEnOut = 'There was an error. Please contact system administrator.'; - $langEsOut = 'Hubo un error. Favor de contactar al administrador del sistema.'; - $this->assertTrue($langEnTest == $langEnOut); - $this->assertTrue($langEsTest == $langEsOut); - } -} +exit; diff --git a/lib/conekta-php/test/Conekta-1.0/LogTest.php b/lib/conekta-php/test/Conekta-1.0/LogTest.php index 53ab5a3fb..0e2ef3504 100644 --- a/lib/conekta-php/test/Conekta-1.0/LogTest.php +++ b/lib/conekta-php/test/Conekta-1.0/LogTest.php @@ -1,4 +1,22 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; diff --git a/lib/conekta-php/test/Conekta-1.0/PayoutTest.php b/lib/conekta-php/test/Conekta-1.0/PayoutTest.php index 97551a494..2cc7ad7b2 100644 --- a/lib/conekta-php/test/Conekta-1.0/PayoutTest.php +++ b/lib/conekta-php/test/Conekta-1.0/PayoutTest.php @@ -1,4 +1,22 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; @@ -9,18 +27,18 @@ public function testSuccesfulGetPayout() $this->setApiKey(); $this->setApiVersion('1.0.0'); $payee = Payee::create( - array( + [ 'name' => 'John Doe', 'email' => 'j_d@radcorp->com', 'phone' => '555555555', - 'bank' => array( + 'bank' => [ 'account_number' => '032180000118359719', 'account_holder' => 'J D - Radcorp', 'description' => 'Conekta To JD', 'statement_description' => 'Conekta To JD 111111111', 'statement_reference' => '111111111', - ), - 'billing_address' => array( + ], + 'billing_address' => [ 'company_name' => 'Rad Corp', 'tax_id' => 'tax121212abc', 'street1' => 'Guadalupe 73', @@ -30,8 +48,8 @@ public function testSuccesfulGetPayout() 'state' => 'DF', 'country' => 'MX', 'zip' => '06100', - ), - ) + ], + ] ); $this->assertTrue(strpos(get_class($payee), 'Payee') !== false); $this->assertTrue(strpos('555555555', $payee->phone) !== false); @@ -48,11 +66,11 @@ public function testSuccesfulGetPayout() $this->assertTrue(strpos('06100', $payee->billing_address->zip) !== false); $payout = Payout::create( - array( + [ 'amount' => 5000, 'currency' => 'MXN', 'payee' => $payee->id, - ) + ] ); $this->assertTrue(strpos(get_class($payout), 'Payout') !== false); $this->assertTrue(5000 == $payout->amount); @@ -61,6 +79,6 @@ public function testSuccesfulGetPayout() $this->assertTrue(strpos('032180000118359719', $payout->method->account_number) !== false); $this->assertTrue(strpos('J D - Radcorp', $payout->method->account_holder) !== false); $this->assertTrue(strpos('ixe', $payout->method->bank) !== false); - //$this->assertTrue(count($payout->transactions) == 0); // Not it the response + // $this->assertTrue(count($payout->transactions) == 0); // Not it the response } } diff --git a/lib/conekta-php/test/Conekta-1.0/PlanTest.php b/lib/conekta-php/test/Conekta-1.0/PlanTest.php index b115d4345..63e203667 100644 --- a/lib/conekta-php/test/Conekta-1.0/PlanTest.php +++ b/lib/conekta-php/test/Conekta-1.0/PlanTest.php @@ -1,4 +1,22 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; @@ -27,16 +45,16 @@ public function testSuccesfulPlanCreate() $this->setApiKey(); $this->setApiVersion('1.0.0'); $plans = Plan::where(); - $plan = Plan::create(array( - 'id' => 'gold-plan'.substr('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', mt_rand(0, 50), 1).substr(md5(time()), 1), - 'name' => 'Gold Plan', - 'amount' => 10000, - 'currency' => 'MXN', - 'interval' => 'month', - 'frequency' => 10, + $plan = Plan::create([ + 'id' => 'gold-plan' . substr('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', mt_rand(0, 50), 1) . substr(md5(time()), 1), + 'name' => 'Gold Plan', + 'amount' => 10000, + 'currency' => 'MXN', + 'interval' => 'month', + 'frequency' => 10, 'trial_period_days' => 15, - 'expiry_count' => 12, - )); + 'expiry_count' => 12, + ]); $this->assertTrue(strpos(get_class($plan), 'Plan') !== false); } @@ -46,7 +64,7 @@ public function testUpdatePlan() $this->setApiVersion('1.0.0'); $plans = Plan::where(); $plan = $plans[0]; - $plan->update(array('name' => 'Silver Plan')); + $plan->update(['name' => 'Silver Plan']); $this->assertTrue(strpos($plan->name, 'Silver Plan') !== false); } diff --git a/lib/conekta-php/test/Conekta-1.0/WebhookTest.php b/lib/conekta-php/test/Conekta-1.0/WebhookTest.php index d2bf6e506..9093f4ab1 100644 --- a/lib/conekta-php/test/Conekta-1.0/WebhookTest.php +++ b/lib/conekta-php/test/Conekta-1.0/WebhookTest.php @@ -1,24 +1,41 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; class WebhookTest extends BaseTest { - public static $events = array("events" => - array("charge.created", "charge.paid", "charge.under_fraud_review", - "charge.fraudulent", "charge.refunded", "charge.created", "customer.created", - "customer.updated", "customer.deleted", "webhook.created", "webhook.updated", - "webhook.deleted", "charge.chargeback.created", "charge.chargeback.updated", - "charge.chargeback.under_review", "charge.chargeback.lost", "charge.chargeback.won", - "payout.created", "payout.retrying", "payout.paid_out", "payout.failed", - "plan.created", "plan.updated", "plan.deleted", "subscription.created", - "subscription.paused", "subscription.resumed", "subscription.canceled", - "subscription.expired", "subscription.updated", "subscription.paid", - "subscription.payment_failed", "payee.created", "payee.updated", - "payee.deleted", "payee.payout_method.created", - "payee.payout_method.updated", "payee.payout_method.deleted")); + public static $events = ['events' => ['charge.created', 'charge.paid', 'charge.under_fraud_review', + 'charge.fraudulent', 'charge.refunded', 'charge.created', 'customer.created', + 'customer.updated', 'customer.deleted', 'webhook.created', 'webhook.updated', + 'webhook.deleted', 'charge.chargeback.created', 'charge.chargeback.updated', + 'charge.chargeback.under_review', 'charge.chargeback.lost', 'charge.chargeback.won', + 'payout.created', 'payout.retrying', 'payout.paid_out', 'payout.failed', + 'plan.created', 'plan.updated', 'plan.deleted', 'subscription.created', + 'subscription.paused', 'subscription.resumed', 'subscription.canceled', + 'subscription.expired', 'subscription.updated', 'subscription.paid', + 'subscription.payment_failed', 'payee.created', 'payee.updated', + 'payee.deleted', 'payee.payout_method.created', + 'payee.payout_method.updated', 'payee.payout_method.deleted', ]]; - public static $url = array("url" => "http://www.example.com/my_listener"); + public static $url = ['url' => 'http://www.example.com/my_listener']; public function testSuccesfulWebhookCreate() { @@ -26,9 +43,9 @@ public function testSuccesfulWebhookCreate() $this->setApiVersion('1.0.0'); $webhook = Webhook::create(array_merge(self::$url, self::$events)); $this->assertTrue(strpos(get_class($webhook), 'Webhook') !== false); - $this->assertTrue(strpos($webhook->webhook_url, self::$url["url"]) !== false); - $webhook->update(array("url" => "http://www.example.com/my_listener")); - $this->assertTrue(strpos($webhook->webhook_url, "http://www.example.com/my_listener") !== false); + $this->assertTrue(strpos($webhook->webhook_url, self::$url['url']) !== false); + $webhook->update(['url' => 'http://www.example.com/my_listener']); + $this->assertTrue(strpos($webhook->webhook_url, 'http://www.example.com/my_listener') !== false); $webhook->delete(); } } diff --git a/lib/conekta-php/test/Conekta-1.0/index.php b/lib/conekta-php/test/Conekta-1.0/index.php index 6e3bcab67..db82febd0 100644 --- a/lib/conekta-php/test/Conekta-1.0/index.php +++ b/lib/conekta-php/test/Conekta-1.0/index.php @@ -1,34 +1,27 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * - * DISCLAIMER + * @category Conekta * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to http://www.prestashop.com for more information. + * @version GIT: @2.3.6@ * - * @author PrestaShop SA - * @copyright 2007-2017 PrestaShop SA - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA + * @see https://conekta.com/ */ -/* -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); -header("Location: ../"); +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); +header('Location: ../'); + exit; -*/ diff --git a/lib/conekta-php/test/Conekta-2.0/ChargeTest.php b/lib/conekta-php/test/Conekta-2.0/ChargeTest.php index c4b4fd76d..ab770cfcd 100644 --- a/lib/conekta-php/test/Conekta-2.0/ChargeTest.php +++ b/lib/conekta-php/test/Conekta-2.0/ChargeTest.php @@ -1,50 +1,75 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; class ChargeTest extends BaseTest { - public static $validOrder = array( - 'line_items'=> array( - array( - 'name'=> 'Box of Cohiba S1s', - 'description'=> 'Imported From Mex.', - 'unit_price'=> 20000, - 'quantity'=> 1, - 'sku'=> 'cohb_s1', - 'category'=> 'food', - 'tags' => array('food', 'mexican food') - ) - ), - 'currency' => 'mxn', - 'metadata' => array('test' => 'extra info') - ); - public static $otherParams = array( - 'currency' => 'mxn', - 'customer_info' => array( + public static $validOrder = [ + 'line_items' => [ + [ + 'name' => 'Box of Cohiba S1s', + 'description' => 'Imported From Mex.', + 'unit_price' => 20000, + 'quantity' => 1, + 'sku' => 'cohb_s1', + 'category' => 'food', + 'tags' => ['food', 'mexican food'], + ], + ], + 'currency' => 'mxn', + 'metadata' => ['test' => 'extra info'], + ]; + + public static $otherParams = [ + 'currency' => 'mxn', + 'customer_info' => [ 'name' => 'John Constantine', 'phone' => '+5213353319758', - 'email' => 'hola@hola.com' - ) - ); - public static $chargeParams = array('payment_method' => array('type' => 'oxxo_cash'),'amount' => 20000); - public static $bank = array('payment_method' => array('type' => 'banorte',), 'amount' =>20000); - public static $spei = array('payment_method' => array('type' => 'spei',), 'amount' =>20000); - public static $validVisaCard =array('payment_method' => array('type' => 'card','token_id' => 'tok_test_visa_4242')); - public static $oxxo = array('payment_method' => array('type' => 'oxxo_cash',), 'amount' => 20000); + 'email' => 'hola@hola.com', + ], + ]; + + public static $chargeParams = ['payment_method' => ['type' => 'oxxo_cash'], 'amount' => 20000]; + + public static $bank = ['payment_method' => ['type' => 'banorte'], 'amount' => 20000]; + + public static $spei = ['payment_method' => ['type' => 'spei'], 'amount' => 20000]; + + public static $validVisaCard = ['payment_method' => ['type' => 'card', 'token_id' => 'tok_test_visa_4242']]; + + public static $oxxo = ['payment_method' => ['type' => 'oxxo_cash'], 'amount' => 20000]; + public function testCreateOrder() { $this->setApiKey(); $orderParams = array_merge(self::$validOrder, self::$otherParams); $order = Order::create($orderParams); $this->assertTrue(strpos(get_class($order), 'Order') !== false); - + return $order; } public function testSuccesfulFindCharge() { - $order = $this->testCreateOrder(); + $order = $this->testCreateOrder(); $charge = $order->createCharge(self::$chargeParams); $filterCharges = Order::find($charge->id); $validCharge = $filterCharges->charges[0]; @@ -53,10 +78,10 @@ public function testSuccesfulFindCharge() public function testSuccesfulSpeiPMCreate() { - $order = $this->testCreateOrder(); + $order = $this->testCreateOrder(); $charge = $order->createCharge(self::$spei); - $this->assertTrue($charge->payment_method->bank == "STP"); + $this->assertTrue($charge->payment_method->bank == 'STP'); $this->assertTrue(intval($charge->payment_method->clabe) > 0); $this->assertTrue(is_numeric($charge->payment_method->expires_at)); $this->assertTrue($charge->status == 'pending_payment'); @@ -64,7 +89,7 @@ public function testSuccesfulSpeiPMCreate() public function testSuccesfulCardPMCreate() { - $order = $this->testCreateOrder(); + $order = $this->testCreateOrder(); $charge = $order->createCharge(self::$validVisaCard); $this->assertTrue($charge->status == 'paid'); @@ -72,11 +97,11 @@ public function testSuccesfulCardPMCreate() public function testSuccesfulOxxoPMCreate() { - $order = $this->testCreateOrder(); + $order = $this->testCreateOrder(); $charge = $order->createCharge(self::$oxxo); $this->assertTrue(is_numeric($charge->payment_method->expires_at)); - $this->assertTrue($charge->payment_method->store_name == "OXXO"); + $this->assertTrue($charge->payment_method->store_name == 'OXXO'); $this->assertTrue($charge->status == 'pending_payment'); } } diff --git a/lib/conekta-php/test/Conekta-2.0/ConektaListTest.php b/lib/conekta-php/test/Conekta-2.0/ConektaListTest.php index e7f459a4a..8aea11547 100644 --- a/lib/conekta-php/test/Conekta-2.0/ConektaListTest.php +++ b/lib/conekta-php/test/Conekta-2.0/ConektaListTest.php @@ -1,4 +1,22 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; @@ -7,71 +25,73 @@ class ConektaListTest extends BaseTest public function testSuccessfulNext() { $orderList = $this->createResponseMockUp(); - $window = Order::where(array('limit' => 5, "next" => $orderList[9]->id)); + $window = Order::where(['limit' => 5, 'next' => $orderList[9]->id]); $this->assertTrue($window[0]->id == $orderList[10]->id); - $window->next(array('limit' => 1)); + $window->next(['limit' => 1]); $this->assertTrue($window[0]->id == $orderList[15]->id); } public function testSuccessfulPrevious() { $orderList = $this->createResponseMockUp(); - $window = Order::where(array('limit' => 5, 'next' => $orderList[14]->id)); + $window = Order::where(['limit' => 5, 'next' => $orderList[14]->id]); $this->assertTrue($window[0]->id == $orderList[15]->id); - $window->previous(array('limit' => 1)); + $window->previous(['limit' => 1]); $this->assertTrue($window[0]->id == $orderList[14]->id); } - + protected function createResponseMockUp() { $this->setApiKey(); - $overRootFolder = "../support/fixtures/orders.json"; - $insideTestFolder = "test/support/fixtures/orders.json"; - $path = file_exists($overRootFolder) ? $overRootFolder: $insideTestFolder; - $object = file_get_contents($path); - $jsonResponse = json_decode($object, true); - $orderList = new ConektaList("Order", $jsonResponse); + $overRootFolder = '../support/fixtures/orders.json'; + $insideTestFolder = 'test/support/fixtures/orders.json'; + $path = file_exists($overRootFolder) ? $overRootFolder : $insideTestFolder; + $object = file_get_contents($path); + $jsonResponse = json_decode($object, true); + $orderList = new ConektaList('Order', $jsonResponse); $orderList->loadFromArray($jsonResponse); - + return $orderList; } + public function testSuccessfulEmptyNext() { $orderList = $this->createResponseMockUp(); - $window = Order::where(array('limit' => 5)); + $window = Order::where(['limit' => 5]); $firtsOrderId = $window[0]->id; $window->next(); $secondOrderId = $window[0]->id; $firstNext = $window->count(); $actualOrderId = $window[0]->id; - $window->next(array('limit'=>10)); + $window->next(['limit' => 10]); $secondNext = $window->count(); - //first next witout params - $this->assertTrue($firstNext == 5); + // first next witout params + $this->assertTrue($firstNext == 5); // second next with limit 10 $this->assertTrue($secondNext == 10); - + // first order id index's never be the same after a next $this->assertTrue($firtsOrderId != $secondOrderId); } + public function testSuccessfulEmptyPrevious() { $orderList = $this->createResponseMockUp(); - $window = Order::where(array('limit' => 10)); + $window = Order::where(['limit' => 10]); $firtsOrderId = $window[0]->id; $window->next(); $firstNext = $window->count(); $window->previous(); $returnNext = $window->count(); - $window->previous(array('limit'=>10)); + $window->previous(['limit' => 10]); $secondOrderId = $window[0]->id; // after return both id's have to be the same - $this->assertTrue($secondOrderId == $firtsOrderId); + $this->assertTrue($secondOrderId == $firtsOrderId); // next match after return previous runs over same index's $this->assertTrue($returnNext == $firstNext); diff --git a/lib/conekta-php/test/Conekta-2.0/ConektaTest.php b/lib/conekta-php/test/Conekta-2.0/ConektaTest.php index 91a5ab521..c4dda3972 100644 --- a/lib/conekta-php/test/Conekta-2.0/ConektaTest.php +++ b/lib/conekta-php/test/Conekta-2.0/ConektaTest.php @@ -1,5 +1,23 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ + namespace Conekta; class ConektaTest extends BaseTest @@ -8,10 +26,12 @@ public function setEnvLocale($locale) { Conekta::setLocale($locale); } + public function setPlugin($plugin) { Conekta::setPlugin($plugin); } + public function setPluginVersion($version) { Conekta::setPluginVersion($version); diff --git a/lib/conekta-php/test/Conekta-2.0/CustomerTest.php b/lib/conekta-php/test/Conekta-2.0/CustomerTest.php index 33d491427..3d2ab603d 100644 --- a/lib/conekta-php/test/Conekta-2.0/CustomerTest.php +++ b/lib/conekta-php/test/Conekta-2.0/CustomerTest.php @@ -1,24 +1,44 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; class CustomerTest extends BaseTest { - public static $validCustomer = array( + public static $validCustomer = [ 'email' => 'hola@hola.com', - 'name' => 'John Constantine' - ); - public static $invalidCustomer = array( + 'name' => 'John Constantine', + ]; + + public static $invalidCustomer = [ 'email' => 'hola@hola.com', - 'names' => 'John Constantine' - ); - public static $validRecurrentCustomer = array( + 'names' => 'John Constantine', + ]; + + public static $validRecurrentCustomer = [ 'name' => 'John Constantine', 'email' => 'john_constantine@conekta.com', - 'payment_sources' => array(array( + 'payment_sources' => [[ 'type' => 'oxxo_recurrent', - )) - ); + ]], + ]; public function testSuccesfulCustomerCreate() { @@ -48,10 +68,11 @@ public function testSuccesfulDeleteCustomer() public function testUnsuccesfulCustomerCreate() { $this->setApiKey(); + try { $customer = Customer::create(self::$invalidCustomer); } catch (\Exception $e) { - $this->assertTrue(strpos($e->getMessage(), "El parametro \"name\" es requerido") !== false); + $this->assertTrue(strpos($e->getMessage(), 'El parametro "name" es requerido') !== false); } } @@ -59,10 +80,10 @@ public function testSuccesfulSourceCreate() { $this->setApiKey(); $customer = Customer::create(self::$validCustomer); - $source = $customer->createPaymentSource(array( + $source = $customer->createPaymentSource([ 'token_id' => 'tok_test_visa_4242', - 'type' => 'card' - )); + 'type' => 'card', + ]); $this->assertTrue(strpos(get_class($source), 'PaymentSource') !== false); $this->assertTrue($source->isCard()); $this->assertTrue(strpos(get_class($customer->payment_sources), 'ConektaList') !== false); @@ -73,14 +94,14 @@ public function testSuccessfulSourceDelete() { $this->setApiKey(); $customer = Customer::create(self::$validCustomer); - $firstSource = $customer->createPaymentSource(array( + $firstSource = $customer->createPaymentSource([ 'token_id' => 'tok_test_visa_4242', - 'type' => 'card' - )); - $secondSource = $customer->createPaymentSource(array( + 'type' => 'card', + ]); + $secondSource = $customer->createPaymentSource([ 'token_id' => 'tok_test_mastercard_4444', - 'type' => 'card' - )); + 'type' => 'card', + ]); $customer->deletePaymentSourceById($customer->payment_sources[1]->id); $this->assertTrue($customer->payment_sources[1]->deleted); } @@ -90,18 +111,18 @@ public function testSuccesfulShippingContactCreate() $this->setApiKey(); $customer = Customer::create(self::$validCustomer); $shippingContact = $customer->createShippingContact( - array( + [ 'receiver' => 'John Williams', 'phone' => '+523333350360', 'email' => 'test@conekta.io', - 'address' => array( + 'address' => [ 'street1' => 'Wallaaby', 'city' => 'Sydney', 'state' => 'P. Sherman', 'country' => 'MX', - 'postal_code' => '78215' - ) - ) + 'postal_code' => '78215', + ], + ] ); $this->assertTrue(strpos(get_class($shippingContact), 'ShippingContact') !== false); $this->assertTrue(strpos(get_class($customer->shipping_contacts), 'ConektaList') !== false); @@ -112,9 +133,9 @@ public function testOfflineRecurrentSourceIsCreated() { $this->setApiKey(); $customer = Customer::create(self::$validCustomer); - $source = $customer->createPaymentSource(array( - 'type' => 'oxxo_recurrent' - )); + $source = $customer->createPaymentSource([ + 'type' => 'oxxo_recurrent', + ]); $this->assertTrue(strpos(get_class($source), 'PaymentSource') !== false); $this->assertTrue(strpos(get_class($customer->payment_sources), 'ConektaList') !== false); $this->assertTrue($customer->payment_sources->total == 1); diff --git a/lib/conekta-php/test/Conekta-2.0/DiscountLineTest.php b/lib/conekta-php/test/Conekta-2.0/DiscountLineTest.php index cca4c5a21..77b2349d2 100644 --- a/lib/conekta-php/test/Conekta-2.0/DiscountLineTest.php +++ b/lib/conekta-php/test/Conekta-2.0/DiscountLineTest.php @@ -1,35 +1,53 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; class DiscountLineTest extends BaseTest { - public static $validOrder = array( - 'line_items'=> array( - array( - 'name'=> 'Box of Cohiba S1s', - 'description'=> 'Imported From Mex.', - 'unit_price'=> 20000, - 'quantity'=> 1, - 'sku'=> 'cohb_s1', - 'category'=> 'food', - 'tags' => array('food', 'mexican food') - ) - ), - 'currency' => 'mxn', - 'discount_lines' => array( - array( + public static $validOrder = [ + 'line_items' => [ + [ + 'name' => 'Box of Cohiba S1s', + 'description' => 'Imported From Mex.', + 'unit_price' => 20000, + 'quantity' => 1, + 'sku' => 'cohb_s1', + 'category' => 'food', + 'tags' => ['food', 'mexican food'], + ], + ], + 'currency' => 'mxn', + 'discount_lines' => [ + [ 'code' => 'Cupon de descuento', 'amount' => 10, - 'type' => 'loyalty' - ), - array( + 'type' => 'loyalty', + ], + [ 'code' => 'Cupon de descuento', 'amount' => 5, - 'type' => 'loyalty' - ) - ) - ); + 'type' => 'loyalty', + ], + ], + ]; public function testSuccessfulDiscountLineDelete() { @@ -46,7 +64,7 @@ public function testSuccessfulDiscountLineUpdate() $this->setApiKey(); $order = Order::create(self::$validOrder); $discountLine = $order->discount_lines[0]; - $discountLine->update(array('amount' => 11)); + $discountLine->update(['amount' => 11]); $this->assertTrue($discountLine->amount == 11); } @@ -56,8 +74,9 @@ public function testUnsuccessfulDiscountLineUpdate() $this->setApiKey(); $order = Order::create(self::$validOrder); $discountLine = $order->discount_lines[0]; + try { - $discountLine->update(array('amount' => -1)); + $discountLine->update(['amount' => -1]); } catch (\Exception $e) { $this->assertTrue(strpos(get_class($e), 'ParameterValidationError') == true); } diff --git a/lib/conekta-php/test/Conekta-2.0/ErrorHandlerTest.php b/lib/conekta-php/test/Conekta-2.0/ErrorHandlerTest.php index 06da4745b..0b2ff2dd5 100644 --- a/lib/conekta-php/test/Conekta-2.0/ErrorHandlerTest.php +++ b/lib/conekta-php/test/Conekta-2.0/ErrorHandlerTest.php @@ -1,36 +1,56 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; class ErrorHandlerTest extends BaseTest { - public static $validOrder = array( - 'line_items' => array( - array( + public static $validOrder = [ + 'line_items' => [ + [ 'name' => 'Box of Cohiba S1s', 'description' => 'Imported From Mex.', 'unit_price' => 20000, 'quantity' => 1, 'sku' => 'cohb_s1', 'category' => 'food', - 'tags' => array('food', 'mexican food') - ) - ), - 'currency' => 'mxn', - 'metadata' => array('test' => 'extra info') - ); - public static $otherParams = array( + 'tags' => ['food', 'mexican food'], + ], + ], 'currency' => 'mxn', - 'customer_info' => array( + 'metadata' => ['test' => 'extra info'], + ]; + + public static $otherParams = [ + 'currency' => 'mxn', + 'customer_info' => [ 'name' => 'John Constantine', 'phone' => '+5213353319758', - 'email' => 'hola@hola.com' - ) - ); - public static $invalidCustomer = array( + 'email' => 'hola@hola.com', + ], + ]; + + public static $invalidCustomer = [ 'email' => 'hola@hola.com', - 'cards' => array('tok_test_visa_4241') - ); + 'cards' => ['tok_test_visa_4241'], + ]; public function unsetApiKey() { @@ -42,6 +62,7 @@ public function unsetApiKey() public function testNoIdError() { $this->setApiKey(); + try { $customer = Customer::find('0'); } catch (\Exception $e) { @@ -54,8 +75,9 @@ public function testNoConnectionError() $this->setApiKey(); $apiUrl = Conekta::$apiBase; Conekta::$apiBase = 'http://localhost:3001'; + try { - $customer = Customer::create(array('cards' => array('tok_test_visa_4241'))); + $customer = Customer::create(['cards' => ['tok_test_visa_4241']]); } catch (\Exception $e) { $this->assertTrue(strpos(get_class($e), 'NoConnectionError') == true); } @@ -65,6 +87,7 @@ public function testNoConnectionError() public function testParameterValidationError() { $this->setApiKey(); + try { $customer = Customer::create(self::$invalidCustomer); } catch (\Exception $e) { @@ -75,15 +98,18 @@ public function testParameterValidationError() public function testResourceNotFoundError() { $this->setApiKey(); + try { $customer = Customer::find('2'); } catch (\Exception $e) { $this->assertTrue(strpos(get_class($e), 'ResourceNotFoundError') == true); } } + public function testAuthenticationError() { $this->unsetApiKey(); + try { $customer = Customer::create(); } catch (\Exception $e) { @@ -91,18 +117,19 @@ public function testAuthenticationError() } $this->setApiKey(); } + public function testUnknowApiRequest() { $this->setApiKey(); - $valid_visa_card =array( - 'payment_method' => array( + $valid_visa_card = [ + 'payment_method' => [ 'type' => 'card', - 'token_id' => 'tok_test_insufficient_funds') - ); + 'token_id' => 'tok_test_insufficient_funds', ], + ]; try { $orderParams = array_merge(self::$validOrder, self::$otherParams); - $order = Order::create($orderParams); + $order = Order::create($orderParams); $charge = $order->createCharge($valid_visa_card); } catch (\Exception $e) { $this->assertTrue(strpos(get_class($e), 'ProcessingError') == true); diff --git a/lib/conekta-php/test/Conekta-2.0/LangTest.php b/lib/conekta-php/test/Conekta-2.0/LangTest.php index 5b447382f..044ef0882 100644 --- a/lib/conekta-php/test/Conekta-2.0/LangTest.php +++ b/lib/conekta-php/test/Conekta-2.0/LangTest.php @@ -1,4 +1,22 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; @@ -8,8 +26,8 @@ public function testShouldTranslatesMessage() { $langEnTest = Lang::translate('error.resource.id_purchaser', Lang::EN); $langEsTest = Lang::translate('error.resource.id_purchaser', Lang::ES); - $langEnOut = 'There was an error. Please contact system administrator.'; - $langEsOut = 'Hubo un error. Favor de contactar al administrador del sistema.'; + $langEnOut = 'There was an error. Please contact system administrator.'; + $langEsOut = 'Hubo un error. Favor de contactar al administrador del sistema.'; $this->assertTrue($langEnTest == $langEnOut); $this->assertTrue($langEsTest == $langEsOut); } diff --git a/lib/conekta-php/test/Conekta-2.0/LineItemTest.php b/lib/conekta-php/test/Conekta-2.0/LineItemTest.php index 772cbd723..861c654a0 100644 --- a/lib/conekta-php/test/Conekta-2.0/LineItemTest.php +++ b/lib/conekta-php/test/Conekta-2.0/LineItemTest.php @@ -1,28 +1,46 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; class LineItemTest extends BaseTest { - public static $validOrder = array( - 'line_items' => array( - array( + public static $validOrder = [ + 'line_items' => [ + [ 'name' => 'Box of Cohiba S1s', 'description' => 'Imported From Mex.', 'unit_price' => 20000, 'quantity' => 1, - 'tags' => array('food', 'mexican food') - ), - array( + 'tags' => ['food', 'mexican food'], + ], + [ 'name' => 'Box of Cohiba S1s', 'description' => 'Imported From Mex.', 'unit_price' => 3500, 'quantity' => 1, - 'tags' => array('food') - ) - ), - 'currency' => 'mxn' - ); + 'tags' => ['food'], + ], + ], + 'currency' => 'mxn', + ]; public function testSuccessfulLineItemDelete() { @@ -39,7 +57,7 @@ public function testSuccessfulLineItemUpdate() $this->setApiKey(); $order = Order::create(self::$validOrder); $lineItem = $order->line_items[0]; - $lineItem->update(array('unit_price' => 1000)); + $lineItem->update(['unit_price' => 1000]); $this->assertTrue($lineItem->unit_price == 1000); } @@ -49,8 +67,9 @@ public function testUnsuccessfulLineItemUpdate() $this->setApiKey(); $order = Order::create(self::$validOrder); $lineItem = $order->line_items[0]; + try { - $lineItem->update(array('unit_price' => -1)); + $lineItem->update(['unit_price' => -1]); } catch (\Exception $e) { $this->assertTrue(strpos(get_class($e), 'ParameterValidationError') == true); } diff --git a/lib/conekta-php/test/Conekta-2.0/OrderTest.php b/lib/conekta-php/test/Conekta-2.0/OrderTest.php index d50c09e0b..d1ccae13b 100644 --- a/lib/conekta-php/test/Conekta-2.0/OrderTest.php +++ b/lib/conekta-php/test/Conekta-2.0/OrderTest.php @@ -1,58 +1,76 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; class OrderTest extends BaseTest { - public static $validOrder = array( - 'line_items' => array( - array( + public static $validOrder = [ + 'line_items' => [ + [ 'name' => 'Box of Cohiba S1s', 'description' => 'Imported From Mex.', 'unit_price' => 20000, 'quantity' => 1, 'sku' => 'cohb_s1', 'category' => 'food', - 'tags' => array('food', 'mexican food') - ) - ), + 'tags' => ['food', 'mexican food'], + ], + ], 'currency' => 'mxn', - 'metadata' => array('test' => 'extra info') - ); + 'metadata' => ['test' => 'extra info'], + ]; - public static $validRefund = array( + public static $validRefund = [ 'amount' => 20000, 'reason' => 'requested_by_client', 'currency' => 'MXN', - ); + ]; public function testSuccesfulCreateOrder() { $this->setApiKey(); $order = Order::create(self::$validOrder); - $this->assertTrue(strpos($order->metadata["test"], 'extra info') !== false); + $this->assertTrue(strpos($order->metadata['test'], 'extra info') !== false); $this->assertTrue(strpos(get_class($order), 'Order') !== false); } public function testSuccesfulCreateOrderWithCharges() { - $charges = array( - 'charges' => array( - array( - 'payment_method' => array( + $charges = [ + 'charges' => [ + [ + 'payment_method' => [ 'type' => 'oxxo_cash', - 'expires_at' => strtotime(date("Y-m-d H:i:s")) + "36000" - ), - 'amount' => 20000 - ) - ), - 'currency' => 'mxn', - 'customer_info' => array( + 'expires_at' => strtotime(date('Y-m-d H:i:s')) + '36000', + ], + 'amount' => 20000, + ], + ], + 'currency' => 'mxn', + 'customer_info' => [ 'name' => 'John Constantine', 'phone' => '+5213353319758', - 'email' => 'hola@hola.com' - ) - ); + 'email' => 'hola@hola.com', + ], + ]; $this->setApiKey(); $order = Order::create(array_merge(self::$validOrder, $charges)); $this->assertTrue(strpos(get_class($order), 'Order') !== false); @@ -62,46 +80,46 @@ public function testSuccesfulCreateOrderWithCharges() public function testSuccesfulCharge() { $other_params = - array( - 'currency' => 'mxn', - 'customer_info' => array( + [ + 'currency' => 'mxn', + 'customer_info' => [ 'name' => 'John Constantine', 'phone' => '+5213353319758', - 'email' => 'hola@hola.com' - ) - ); + 'email' => 'hola@hola.com', + ], + ]; $this->setApiKey(); $order = Order::create(array_merge(self::$validOrder, $other_params)); - $charge_params = array( - 'payment_method' => array('type' => 'oxxo_cash'), - 'amount' => 20000 - ); + $charge_params = [ + 'payment_method' => ['type' => 'oxxo_cash'], + 'amount' => 20000, + ]; $charge = $order->createCharge($charge_params); $this->assertTrue(strpos(get_class($charge), 'Charge') !== false); $this->assertTrue(strpos(get_class($order->charges), 'ConektaList') !== false); $this->assertTrue($order->charges->total == 1); } - #Update an order + // Update an order public function testSuccesfulOrderUpdate() { $this->setApiKey(); $order = Order::create(self::$validOrder); - $updated_parameters = array( - 'line_items'=> array( - array( - 'name'=> 'Box of chocolates', - 'description'=> 'Imported From Uruguay.', - 'unit_price'=> 30000, - 'quantity'=> 2, - 'sku'=> 'choc_s3', - 'category'=> 'expendables', - 'tags' => array('Chocolate', 'Sudamerican chocolates') - ) - ), - 'currency' => 'USD' - ); + $updated_parameters = [ + 'line_items' => [ + [ + 'name' => 'Box of chocolates', + 'description' => 'Imported From Uruguay.', + 'unit_price' => 30000, + 'quantity' => 2, + 'sku' => 'choc_s3', + 'category' => 'expendables', + 'tags' => ['Chocolate', 'Sudamerican chocolates'], + ], + ], + 'currency' => 'USD', + ]; $order->update($updated_parameters); $this->assertTrue(strpos(get_class($order), 'Order') !== false); @@ -109,19 +127,20 @@ public function testSuccesfulOrderUpdate() public function testUnsuccessfulOrderUpdate() { - $charges = array( - array( - 'payment_method' => array( - 'type' => 'oxxo_cash' - ), - 'amount' => 10 - ) - ); + $charges = [ + [ + 'payment_method' => [ + 'type' => 'oxxo_cash', + ], + 'amount' => 10, + ], + ]; $this->setApiKey(); $order = Order::create(self::$validOrder); + try { - $order->update(array('charges' => $charges)); + $order->update(['charges' => $charges]); } catch (\Exception $e) { $this->assertTrue(strpos(get_class($e), 'ParameterValidationError') == true); } @@ -150,13 +169,13 @@ public function testSuccessfulLineItem() $this->setApiKey(); $order = Order::create(self::$validOrder); - $line_item = $order->createLineItem(array( - 'name'=> 'Box of Cohiba S1s', - 'description'=> 'Imported From Mex.', - 'unit_price'=> 20000, - 'quantity'=> 1, - 'tags' => array('food', 'mexican food') - )); + $line_item = $order->createLineItem([ + 'name' => 'Box of Cohiba S1s', + 'description' => 'Imported From Mex.', + 'unit_price' => 20000, + 'quantity' => 1, + 'tags' => ['food', 'mexican food'], + ]); $this->assertTrue(strpos(get_class($line_item), 'LineItem') !== false); $this->assertTrue(strpos(get_class($order->line_items), 'ConektaList') !== false); @@ -168,15 +187,15 @@ public function testSuccessfulTaxLine() $this->setApiKey(); $order = Order::create(self::$validOrder); - $taxLine = $order->createTaxLine(array( + $taxLine = $order->createTaxLine([ 'description' => 'IVA', - 'amount' => 60 - )); + 'amount' => 60, + ]); - $taxLine = $order->createTaxLine(array( + $taxLine = $order->createTaxLine([ 'description' => 'ISR', - 'amount' => 6 - )); + 'amount' => 6, + ]); $this->assertTrue(strpos(get_class($taxLine), 'TaxLine') !== false); $this->assertTrue(strpos(get_class($order->tax_lines), 'ConektaList') !== false); @@ -188,13 +207,13 @@ public function testSuccessfulShippingLine() $this->setApiKey(); $order = Order::create(self::$validOrder); - $shippingLine = $order->createShippingLine(array( + $shippingLine = $order->createShippingLine([ 'description' => 'Free Shipping', 'amount' => 0, 'tracking_number' => 'TRACK123', 'carrier' => 'USPS', - 'method' => 'Train' - )); + 'method' => 'Train', + ]); $this->assertTrue(strpos(get_class($shippingLine), 'ShippingLine') !== false); $this->assertTrue(strpos(get_class($order->shipping_lines), 'ConektaList') !== false); @@ -205,11 +224,11 @@ public function testSuccessfulDiscountLine() { $this->setApiKey(); $order = Order::create(self::$validOrder); - $discountLine = $order->createDiscountLine(array( + $discountLine = $order->createDiscountLine([ 'code' => 'Cupon de descuento', 'amount' => 10, - 'type' => 'loyalty' - )); + 'type' => 'loyalty', + ]); $this->assertTrue(strpos(get_class($discountLine), 'DiscountLine') !== false); $this->assertTrue(strpos(get_class($order->discount_lines), 'ConektaList') !== false); $this->assertTrue($order->discount_lines->total == 1); @@ -217,26 +236,26 @@ public function testSuccessfulDiscountLine() public function testSuccessfulRefund() { - $charges = array( - 'charges' => array( - array( - 'payment_method' => array( + $charges = [ + 'charges' => [ + [ + 'payment_method' => [ 'type' => 'card', - 'token_id' => 'tok_test_visa_4242' - ), - 'amount' => 20000 - ) - ), - 'currency' => 'mxn', - 'customer_info' => array( + 'token_id' => 'tok_test_visa_4242', + ], + 'amount' => 20000, + ], + ], + 'currency' => 'mxn', + 'customer_info' => [ 'name' => 'John Constantine', 'phone' => '+5213353319758', - 'email' => 'hola@hola.com' - ) - ); + 'email' => 'hola@hola.com', + ], + ]; $this->setApiKey(); $order = Order::create(array_merge(self::$validOrder, $charges)); - $order->refund(array_merge(self::$validRefund, array('order_id' => $order->id))); + $order->refund(array_merge(self::$validRefund, ['order_id' => $order->id])); $refundedOrder = Order::find($order->id); $this->assertTrue($refundedOrder->payment_status == 'refunded'); @@ -245,24 +264,24 @@ public function testSuccessfulRefund() public function testSuccessfulCapture() { $charges = - array( + [ 'pre_authorize' => true, - 'charges' => array( - array( - 'payment_method' => array( - 'type' => 'card', - 'token_id' => 'tok_test_visa_4242' - ), - 'amount' => 20000 - ) - ), - 'currency' => 'mxn', - 'customer_info' => array( + 'charges' => [ + [ + 'payment_method' => [ + 'type' => 'card', + 'token_id' => 'tok_test_visa_4242', + ], + 'amount' => 20000, + ], + ], + 'currency' => 'mxn', + 'customer_info' => [ 'name' => 'John Constantine', 'phone' => '+5213353319758', - 'email' => 'hola@hola.com' - ) - ); + 'email' => 'hola@hola.com', + ], + ]; $this->setApiKey(); $order = Order::create(array_merge(self::$validOrder, $charges)); $this->assertTrue($order->payment_status == 'pre_authorized'); diff --git a/lib/conekta-php/test/Conekta-2.0/ShippingContactTest.php b/lib/conekta-php/test/Conekta-2.0/ShippingContactTest.php index 2551d0da5..41c51e53e 100644 --- a/lib/conekta-php/test/Conekta-2.0/ShippingContactTest.php +++ b/lib/conekta-php/test/Conekta-2.0/ShippingContactTest.php @@ -1,38 +1,56 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; class ShippingContactTest extends BaseTest { - public static $validCustomer = array('email' => 'hola@hola.com', + public static $validCustomer = ['email' => 'hola@hola.com', 'name' => 'John Constantine', - 'shipping_contacts' => array( - array( + 'shipping_contacts' => [ + [ 'receiver' => 'Jack Bauer', 'phone' => '+5213353319758', 'email' => 'thomas.logan@xmen.org', - 'address' => array( + 'address' => [ 'street1' => '250 Alexis St', 'city' => 'Red Deer', 'state' => 'Alberta', 'country' => 'CA', - 'postal_code' => 'T4N 0B8' - ) - ), - array( + 'postal_code' => 'T4N 0B8', + ], + ], + [ 'receiver' => 'John Williams', 'phone' => '+5213353319758', 'email' => 'rogue@xmen.org', - 'address' => array( + 'address' => [ 'street1' => '250 Alexis St', 'city' => 'Red Deer', 'state' => 'Alberta', 'country' => 'CA', - 'postal_code' => 'T4N 0B8' - ) - ) - ) - ); + 'postal_code' => 'T4N 0B8', + ], + ], + ], + ]; public function testSuccessfulShippingContactDelete() { @@ -48,7 +66,7 @@ public function testSuccessfulShippingContactUpdate() $this->setApiKey(); $customer = Customer::create(self::$validCustomer); $shippingContact = $customer->shipping_contacts[0]; - $shippingContact->update(array('receiver' => 'Tony Almeida')); + $shippingContact->update(['receiver' => 'Tony Almeida']); $this->assertTrue($shippingContact->receiver == 'Tony Almeida'); } @@ -57,8 +75,9 @@ public function testUnsuccessfulShippingContactUpdate() $this->setApiKey(); $customer = Customer::create(self::$validCustomer); $shippingContact = $customer->shipping_contacts[0]; + try { - $shippingContact->update(array('phone' => '')); + $shippingContact->update(['phone' => '']); } catch (\Exception $e) { $this->assertTrue(strpos(get_class($e), 'ParameterValidationError') == true); } diff --git a/lib/conekta-php/test/Conekta-2.0/ShippingLineTest.php b/lib/conekta-php/test/Conekta-2.0/ShippingLineTest.php index 02c4a3b45..017601d20 100644 --- a/lib/conekta-php/test/Conekta-2.0/ShippingLineTest.php +++ b/lib/conekta-php/test/Conekta-2.0/ShippingLineTest.php @@ -1,39 +1,57 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; class ShippingLineTest extends BaseTest { - public static $validOrder = array( - 'line_items'=> array( - array( - 'name'=> 'Box of Cohiba S1s', - 'description'=> 'Imported From Mex.', - 'unit_price'=> 20000, - 'quantity'=> 1, - 'sku'=> 'cohb_s1', - 'category'=> 'food', - 'tags' => array('food', 'mexican food') - ) - ), - 'currency' => 'mxn', - 'shipping_lines' => array( - array( + public static $validOrder = [ + 'line_items' => [ + [ + 'name' => 'Box of Cohiba S1s', + 'description' => 'Imported From Mex.', + 'unit_price' => 20000, + 'quantity' => 1, + 'sku' => 'cohb_s1', + 'category' => 'food', + 'tags' => ['food', 'mexican food'], + ], + ], + 'currency' => 'mxn', + 'shipping_lines' => [ + [ 'description' => 'Free Shipping', 'amount' => 0, 'tracking_number' => 'TRACK123', 'carrier' => 'USPS', - 'method' => 'Train' - ), - array( + 'method' => 'Train', + ], + [ 'description' => 'Free Shipping', 'amount' => 40, 'tracking_number' => 'TRACK124', 'carrier' => 'USPS', - 'method' => 'Train' - ) - ) - ); + 'method' => 'Train', + ], + ], + ]; public function testSuccessfulShippingLineDelete() { @@ -49,7 +67,7 @@ public function testSuccessfulShippingLineUpdate() $this->setApiKey(); $order = Order::create(self::$validOrder); $shippingLine = $order->shipping_lines[0]; - $shippingLine->update(array('method' => 'Air')); + $shippingLine->update(['method' => 'Air']); $this->assertTrue($shippingLine->method == 'Air'); } @@ -58,8 +76,9 @@ public function testUnsuccessfulShippingLineUpdate() $this->setApiKey(); $order = Order::create(self::$validOrder); $shippingLine = $order->shipping_lines[0]; + try { - $shippingLine->update(array('amount' => -1)); + $shippingLine->update(['amount' => -1]); } catch (\Exception $e) { $this->assertTrue(strpos(get_class($e), 'ParameterValidationError') == true); } diff --git a/lib/conekta-php/test/Conekta-2.0/SourceTest.php b/lib/conekta-php/test/Conekta-2.0/SourceTest.php index 852d756fc..db82febd0 100644 --- a/lib/conekta-php/test/Conekta-2.0/SourceTest.php +++ b/lib/conekta-php/test/Conekta-2.0/SourceTest.php @@ -1,47 +1,27 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); +header('Location: ../'); -namespace Conekta; - -class SourceTest extends BaseTest -{ - public static $validCustomer = array( - 'email' => 'hola@hola.com', - 'name' => 'John Constantine', - 'payment_sources' => array( - array( - 'token_id' => 'tok_test_visa_4242', - 'type' => 'card' - ) - ) - ); - - public function testSuccesfulDeleteSources() - { - $this->setApiKey(); - $customer = Customer::create(self::$validCustomer); - $paymentSource = $customer->payment_sources[0]; - $paymentSource->delete(); - $this->assertTrue($paymentSource->deleted == true); - } - - public function testSuccesfulUpdateSources() - { - $this->setApiKey(); - $customer = Customer::create(self::$validCustomer); - $paymentSource = $customer->payment_sources[0]; - $paymentSource->update(array('exp_month' => '11')); - $this->assertTrue($paymentSource->exp_month == '11'); - } - - public function testUnsuccesfulUpdateSources() - { - $this->setApiKey(); - $customer = Customer::create(self::$validCustomer); - $paymentSource = $customer->payment_sources[0]; - try { - $paymentSource->update(array('token_id' => 'tok_test_visa_4241')); - } catch (\Exception $e) { - $this->assertTrue(strpos(get_class($e), 'ParameterValidationError') == true); - } - } -} +exit; diff --git a/lib/conekta-php/test/Conekta-2.0/SubscriptionTest.php b/lib/conekta-php/test/Conekta-2.0/SubscriptionTest.php index f704652cb..da0ebc26c 100644 --- a/lib/conekta-php/test/Conekta-2.0/SubscriptionTest.php +++ b/lib/conekta-php/test/Conekta-2.0/SubscriptionTest.php @@ -1,21 +1,40 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; class SubscriptionTest extends BaseTest { - public static $validCustomer = array( + public static $validCustomer = [ 'email' => 'hola@hola.com', - 'name' => 'John Constantine' - ); - public static $validVisaCard =array('type' => 'card','token_id' => 'tok_test_visa_4242'); + 'name' => 'John Constantine', + ]; + + public static $validVisaCard = ['type' => 'card', 'token_id' => 'tok_test_visa_4242']; public function testSuccesfulSubscriptionCreate() { $this->setApiKey(); $customer = Customer::create(self::$validCustomer); $customer->createPaymentSource(self::$validVisaCard); - $subscription = $customer->createSubscription(array('plan' => 'gold-plan')); + $subscription = $customer->createSubscription(['plan' => 'gold-plan']); $this->assertTrue(strpos(get_class($subscription), 'Conekta\Subscription') !== false); } @@ -24,24 +43,25 @@ public function testSuccesfulSubscriptionUpdate() $this->setApiKey(); $customer = Customer::create(self::$validCustomer); $customer->createPaymentSource(self::$validVisaCard); - $subscription = $customer->createSubscription(array('plan' => 'gold-plan')); + $subscription = $customer->createSubscription(['plan' => 'gold-plan']); + try { $plan = Plan::find('gold-plan2'); } catch (\Exception $e) { $plan = Plan::create( - array( - 'id' => 'gold-plan2', - 'name' => 'Gold Plan', - 'amount' => 10000, - 'currency' => 'MXN', - 'interval' => 'month', - 'frequency' => 1, + [ + 'id' => 'gold-plan2', + 'name' => 'Gold Plan', + 'amount' => 10000, + 'currency' => 'MXN', + 'interval' => 'month', + 'frequency' => 1, 'trial_period_days' => 15, - 'expiry_count' => 12, - ) + 'expiry_count' => 12, + ] ); } - $subscription->update(array('plan' => $plan->id)); + $subscription->update(['plan' => $plan->id]); $this->assertTrue(strpos($subscription->plan_id, 'gold-plan2') !== false); } @@ -50,9 +70,10 @@ public function testUnsuccesfulSubscriptionCreate() $this->setApiKey(); $customer = Customer::create(self::$validCustomer); $customer->createPaymentSource(self::$validVisaCard); + try { - $subscription = $customer->createSubscription(array( - 'plan' => 'unexistent-plan', )); + $subscription = $customer->createSubscription([ + 'plan' => 'unexistent-plan', ]); } catch (\Exception $e) { $this->assertTrue(strpos($e->getMessage(), 'El recurso no ha sido encontrado') !== false); } @@ -63,7 +84,7 @@ public function testSuccesfulSubscriptionPause() $this->setApiKey(); $customer = Customer::create(self::$validCustomer); $customer->createPaymentSource(self::$validVisaCard); - $subscription = $customer->createSubscription(array('plan' => 'gold-plan')); + $subscription = $customer->createSubscription(['plan' => 'gold-plan']); $this->assertTrue(strpos(get_class($subscription), 'Subscription') !== false); $subscription->pause(); $this->assertTrue(strpos($subscription->status, 'paused') !== false); @@ -74,7 +95,7 @@ public function testSuccesfulSubscriptionResume() $this->setApiKey(); $customer = Customer::create(self::$validCustomer); $customer->createPaymentSource(self::$validVisaCard); - $subscription = $customer->createSubscription(array('plan' => 'gold-plan')); + $subscription = $customer->createSubscription(['plan' => 'gold-plan']); $this->assertTrue(strpos(get_class($subscription), 'Subscription') !== false); $subscription->pause(); $subscription->resume(); @@ -86,7 +107,7 @@ public function testSuccesfulSubscriptionCancel() $this->setApiKey(); $customer = Customer::create(self::$validCustomer); $customer->createPaymentSource(self::$validVisaCard); - $subscription = $customer->createSubscription(array('plan' => 'gold-plan')); + $subscription = $customer->createSubscription(['plan' => 'gold-plan']); $this->assertTrue(strpos(get_class($subscription), 'Subscription') !== false); $subscription->cancel(); $this->assertTrue(strpos($subscription->status, 'canceled') !== false); diff --git a/lib/conekta-php/test/Conekta-2.0/TaxLineTest.php b/lib/conekta-php/test/Conekta-2.0/TaxLineTest.php index d7febeff0..747b9bf21 100644 --- a/lib/conekta-php/test/Conekta-2.0/TaxLineTest.php +++ b/lib/conekta-php/test/Conekta-2.0/TaxLineTest.php @@ -1,33 +1,51 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; class TaxLineTest extends BaseTest { - public static $validOrder = array( - 'line_items' => array( - array( + public static $validOrder = [ + 'line_items' => [ + [ 'name' => 'Box of Cohiba S1s', 'description' => 'Imported From Mex.', 'unit_price' => 20000, 'quantity' => 1, 'sku' => 'cohb_s1', 'category' => 'food', - 'tags' => array('food', 'mexican food') - ) - ), - 'tax_lines' => array( - array( + 'tags' => ['food', 'mexican food'], + ], + ], + 'tax_lines' => [ + [ 'description' => 'IVA', - 'amount' => 60 - ), - array( + 'amount' => 60, + ], + [ 'description' => 'ISR', - 'amount' => 100 - ) - ), - 'currency' => 'mxn' - ); + 'amount' => 100, + ], + ], + 'currency' => 'mxn', + ]; public function testSuccessfulTaxLineDelete() { @@ -43,7 +61,7 @@ public function testSuccessfulTaxLineUpdate() $this->setApiKey(); $order = Order::create(self::$validOrder); $taxLine = $order->tax_lines[0]; - $taxLine->update(array('amount' => 10)); + $taxLine->update(['amount' => 10]); $this->assertTrue($taxLine->amount == 10); } @@ -52,8 +70,9 @@ public function testUnsuccessfulTaxLineUpdate() $this->setApiKey(); $order = Order::create(self::$validOrder); $taxLine = $order->tax_lines[0]; + try { - $taxLine->update(array('amount' => -1)); + $taxLine->update(['amount' => -1]); } catch (\Exception $e) { $this->assertTrue(strpos(get_class($e), 'ParameterValidationError') == true); } diff --git a/lib/conekta-php/test/Conekta-2.0/WebhookTest.php b/lib/conekta-php/test/Conekta-2.0/WebhookTest.php index b68a516be..54909f986 100644 --- a/lib/conekta-php/test/Conekta-2.0/WebhookTest.php +++ b/lib/conekta-php/test/Conekta-2.0/WebhookTest.php @@ -1,34 +1,52 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ namespace Conekta; class WebhookTest extends BaseTest { - public static $events = array( - "events" => array("charge.created", "charge.paid", "charge.under_fraud_review", - "charge.fraudulent", "charge.refunded", "charge.created", "customer.created", - "customer.updated", "customer.deleted", "webhook.created", "webhook.updated", - "webhook.deleted", "charge.chargeback.created", "charge.chargeback.updated", - "charge.chargeback.under_review", "charge.chargeback.lost", "charge.chargeback.won", - "payout.created", "payout.retrying", "payout.paid_out", "payout.failed", - "plan.created", "plan.updated", "plan.deleted", "subscription.created", - "subscription.paused", "subscription.resumed", "subscription.canceled", - "subscription.expired", "subscription.updated", "subscription.paid", - "subscription.payment_failed", "payee.created", "payee.updated", - "payee.deleted", "payee.payout_method.created", - "payee.payout_method.updated", "payee.payout_method.deleted") - ); + public static $events = [ + 'events' => ['charge.created', 'charge.paid', 'charge.under_fraud_review', + 'charge.fraudulent', 'charge.refunded', 'charge.created', 'customer.created', + 'customer.updated', 'customer.deleted', 'webhook.created', 'webhook.updated', + 'webhook.deleted', 'charge.chargeback.created', 'charge.chargeback.updated', + 'charge.chargeback.under_review', 'charge.chargeback.lost', 'charge.chargeback.won', + 'payout.created', 'payout.retrying', 'payout.paid_out', 'payout.failed', + 'plan.created', 'plan.updated', 'plan.deleted', 'subscription.created', + 'subscription.paused', 'subscription.resumed', 'subscription.canceled', + 'subscription.expired', 'subscription.updated', 'subscription.paid', + 'subscription.payment_failed', 'payee.created', 'payee.updated', + 'payee.deleted', 'payee.payout_method.created', + 'payee.payout_method.updated', 'payee.payout_method.deleted', ], + ]; - public static $url = array("url" => "http://www.example.com/my_listener"); + public static $url = ['url' => 'http://www.example.com/my_listener']; public function testSuccesfulWebhookCreate() { $this->setApiKey(); $webhook = Webhook::create(array_merge(self::$url, self::$events)); $this->assertTrue(strpos(get_class($webhook), 'Webhook') !== false); - $this->assertTrue(strpos($webhook->webhook_url, self::$url["url"]) !== false); - $webhook->update(array("url" => "http://www.example.com/my_listener")); - $this->assertTrue(strpos($webhook->webhook_url, "http://www.example.com/my_listener") !== false); + $this->assertTrue(strpos($webhook->webhook_url, self::$url['url']) !== false); + $webhook->update(['url' => 'http://www.example.com/my_listener']); + $this->assertTrue(strpos($webhook->webhook_url, 'http://www.example.com/my_listener') !== false); $webhook->delete(); } } diff --git a/lib/conekta-php/test/Conekta-2.0/index.php b/lib/conekta-php/test/Conekta-2.0/index.php index 81cbf5ee6..db82febd0 100644 --- a/lib/conekta-php/test/Conekta-2.0/index.php +++ b/lib/conekta-php/test/Conekta-2.0/index.php @@ -1,35 +1,27 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * - * DISCLAIMER + * @category Conekta * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to http://www.prestashop.com for more information. + * @version GIT: @2.3.6@ * - * @author PrestaShop SA - * @copyright 2007-2017 PrestaShop SA - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA + * @see https://conekta.com/ */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); +header('Location: ../'); -/* -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); -header("Location: ../"); exit; -*/ diff --git a/lib/conekta-php/test/bootstrap.php b/lib/conekta-php/test/bootstrap.php index d651df07e..749b3d357 100644 --- a/lib/conekta-php/test/bootstrap.php +++ b/lib/conekta-php/test/bootstrap.php @@ -1,3 +1,22 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ require_once __DIR__ . '/../lib/Conekta.php'; + require_once __DIR__ . '/BaseTest.php'; diff --git a/lib/conekta-php/test/index.php b/lib/conekta-php/test/index.php index 2f80a422e..db82febd0 100644 --- a/lib/conekta-php/test/index.php +++ b/lib/conekta-php/test/index.php @@ -1,32 +1,27 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * - * DISCLAIMER + * @category Conekta * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to http://www.prestashop.com for more information. + * @version GIT: @2.3.6@ * - * @author PrestaShop SA - * @copyright 2007-2017 PrestaShop SA - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA + * @see https://conekta.com/ */ -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); -header("Location: ../"); +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); +header('Location: ../'); + exit; diff --git a/lib/conekta-php/test/support/fixtures/index.php b/lib/conekta-php/test/support/fixtures/index.php index 81cbf5ee6..db82febd0 100644 --- a/lib/conekta-php/test/support/fixtures/index.php +++ b/lib/conekta-php/test/support/fixtures/index.php @@ -1,35 +1,27 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * - * DISCLAIMER + * @category Conekta * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to http://www.prestashop.com for more information. + * @version GIT: @2.3.6@ * - * @author PrestaShop SA - * @copyright 2007-2017 PrestaShop SA - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA + * @see https://conekta.com/ */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); +header('Location: ../'); -/* -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); -header("Location: ../"); exit; -*/ diff --git a/lib/conekta-php/test/support/fixtures/orders.json b/lib/conekta-php/test/support/fixtures/orders.json index c4286eb1e..e69de29bb 100644 --- a/lib/conekta-php/test/support/fixtures/orders.json +++ b/lib/conekta-php/test/support/fixtures/orders.json @@ -1,1127 +0,0 @@ -{ - "next_page_url": "https://api.conekta.io/orders?next=ord_2hAEAS9sBb2D15ohV", - "has_more": true, - "total": 649, - "object": "list", - "data": [ - { - "livemode": false, - "amount": 35600, - "currency": "MXN", - "amount_refunded": 0, - "customer_info": { - "email": "jul@conekta.io", - "phone": "+5215555555555", - "name": "Jul Ceballos", - "object": "customer_info" - }, - "object": "order", - "id": "ord_2hAEHpZAyVkhzMFM2", - "metadata": {}, - "created_at": 1504633928, - "updated_at": 1504633931, - "line_items": { - "object": "list", - "has_more": false, - "total": 1, - "data": [ - { - "name": "Box of Cohiba S1s", - "unit_price": 35000, - "quantity": 1, - "object": "line_item", - "id": "line_item_2hAEHpZAyVkhzMFLz", - "parent_id": "ord_2hAEHpZAyVkhzMFM2", - "metadata": { - "random_key": "random value" - }, - "antifraud_info": {} - } - ] - }, - "tax_lines": { - "object": "list", - "has_more": false, - "total": 1, - "data": [ - { - "description": "IVA", - "amount": 600, - "object": "tax_line", - "id": "tax_lin_2hAEHrZXjpJdQ8tvY", - "parent_id": "ord_2hAEHpZAyVkhzMFM2" - } - ] - } - }, - { - "livemode": false, - "amount": 35000, - "currency": "MXN", - "amount_refunded": 0, - "customer_info": { - "email": "jul@conekta.io", - "phone": "+5215555555555", - "name": "Jul Ceballos", - "object": "customer_info" - }, - "object": "order", - "id": "ord_2hAEHo2VS6gWBeAJx", - "metadata": {}, - "created_at": 1504633927, - "updated_at": 1504633927, - "line_items": { - "object": "list", - "has_more": false, - "total": 1, - "data": [ - { - "name": "Box of Cohiba S1s", - "unit_price": 35000, - "quantity": 1, - "object": "line_item", - "id": "line_item_2hAEHo2VS6gWBeAJv", - "parent_id": "ord_2hAEHo2VS6gWBeAJx", - "metadata": {}, - "antifraud_info": {} - } - ] - }, - "shipping_lines": { - "object": "list", - "has_more": false, - "total": 1, - "data": [ - { - "amount": 0, - "carrier": "UPS", - "method": "Train", - "tracking_number": "TRACK123", - "object": "shipping_line", - "id": "ship_lin_2hAEHpZAyVrhmrqBR", - "parent_id": "ord_2hAEHo2VS6gWBeAJx" - } - ] - } - }, - { - "livemode": false, - "amount": 35000, - "currency": "MXN", - "amount_refunded": 0, - "customer_info": { - "email": "jul@conekta.io", - "phone": "+5215555555555", - "name": "Jul Ceballos", - "object": "customer_info" - }, - "object": "order", - "id": "ord_2hAEHnsS8pXGecDro", - "metadata": {}, - "created_at": 1504633926, - "updated_at": 1504633926, - "line_items": { - "object": "list", - "has_more": false, - "total": 1, - "data": [ - { - "name": "Box of Cohiba S1s", - "unit_price": 35000, - "quantity": 1, - "object": "line_item", - "id": "line_item_2hAEHnsS8pXGecDrm", - "parent_id": "ord_2hAEHnsS8pXGecDro", - "metadata": {}, - "antifraud_info": {} - } - ] - } - }, - { - "livemode": false, - "amount": 34300, - "currency": "MXN", - "amount_refunded": 0, - "customer_info": { - "email": "jul@conekta.io", - "phone": "5575553324", - "name": "Jul Ceballos", - "object": "customer_info" - }, - "object": "order", - "id": "ord_2hAEHks5NW3TeWWjG", - "metadata": {}, - "created_at": 1504633923, - "updated_at": 1504633925, - "line_items": { - "object": "list", - "has_more": false, - "total": 1, - "data": [ - { - "name": "Box of Cohiba S1s", - "unit_price": 35000, - "quantity": 1, - "object": "line_item", - "id": "line_item_2hAEHks5NW3TeWWjE", - "parent_id": "ord_2hAEHks5NW3TeWWjG", - "metadata": {}, - "antifraud_info": {} - } - ] - }, - "discount_lines": { - "object": "list", - "has_more": false, - "total": 1, - "data": [ - { - "code": "567", - "amount": 700, - "type": "coupon", - "object": "discount_line", - "id": "dis_lin_2hAEHnLiQtxR5s9CR", - "parent_id": "ord_2hAEHks5NW3TeWWjG" - } - ] - } - }, - { - "livemode": false, - "amount": 35000, - "currency": "USD", - "amount_refunded": 0, - "customer_info": { - "email": "jul@conekta.io", - "phone": "+5215555555555", - "name": "Jul Ceballos", - "object": "customer_info" - }, - "object": "order", - "id": "ord_2hAEHibaJuAYV4EKb", - "metadata": {}, - "created_at": 1504633920, - "updated_at": 1504633923, - "line_items": { - "object": "list", - "has_more": false, - "total": 1, - "data": [ - { - "name": "Box of Cohiba S1s", - "unit_price": 35000, - "quantity": 1, - "object": "line_item", - "id": "line_item_2hAEHibaJuAYV4EKZ", - "parent_id": "ord_2hAEHibaJuAYV4EKb", - "metadata": {}, - "antifraud_info": {} - } - ] - } - }, - { - "livemode": false, - "amount": 35600, - "currency": "MXN", - "amount_refunded": 0, - "customer_info": { - "email": "jul@conekta.io", - "phone": "+5215555555555", - "name": "Jul Ceballos", - "object": "customer_info" - }, - "object": "order", - "id": "ord_2hAEHiSX1d9NtzEuy", - "metadata": {}, - "created_at": 1504633920, - "updated_at": 1504633920, - "line_items": { - "object": "list", - "has_more": false, - "total": 1, - "data": [ - { - "name": "Box of Cohiba S1s", - "unit_price": 35000, - "quantity": 1, - "object": "line_item", - "id": "line_item_2hAEHiSX1d9NtzEuw", - "parent_id": "ord_2hAEHiSX1d9NtzEuy", - "metadata": {}, - "antifraud_info": {} - } - ] - }, - "tax_lines": { - "object": "list", - "has_more": false, - "total": 1, - "data": [ - { - "description": "IVA", - "amount": 600, - "object": "tax_line", - "id": "tax_lin_2hAEHiSX1d6si85KU", - "parent_id": "ord_2hAEHiSX1d9NtzEuy", - "metadata": { - "random_key": "random_value" - } - } - ] - } - }, - { - "livemode": false, - "amount": 35000, - "currency": "MXN", - "amount_refunded": 0, - "customer_info": { - "email": "jul@conekta.io", - "phone": "+5215555555555", - "name": "Jul Ceballos", - "object": "customer_info" - }, - "object": "order", - "id": "ord_2hAEHhAymW3tbeQPt", - "metadata": {}, - "created_at": 1504633918, - "updated_at": 1504633918, - "line_items": { - "object": "list", - "has_more": false, - "total": 1, - "data": [ - { - "name": "Box of Cohiba S1s", - "unit_price": 35000, - "quantity": 1, - "object": "line_item", - "id": "line_item_2hAEHhAymW3tbeQPr", - "parent_id": "ord_2hAEHhAymW3tbeQPt", - "metadata": {}, - "antifraud_info": {} - } - ] - }, - "shipping_lines": { - "object": "list", - "has_more": false, - "total": 1, - "data": [ - { - "amount": 0, - "carrier": "USPS", - "method": "Train", - "tracking_number": "TRACK123", - "object": "shipping_line", - "id": "ship_lin_2hAEHhhhVRYBJFm8x", - "parent_id": "ord_2hAEHhAymW3tbeQPt", - "metadata": { - "random_key": "random_value" - } - } - ] - } - }, - { - "livemode": false, - "amount": 35000, - "currency": "MXN", - "payment_status": "paid", - "amount_refunded": 0, - "customer_info": { - "email": "jul@conekta.io", - "phone": "+5215555555555", - "name": "Jul Ceballos", - "object": "customer_info" - }, - "object": "order", - "id": "ord_2hAEHgP7kJbD8MW3A", - "metadata": {}, - "created_at": 1504633917, - "updated_at": 1504633953, - "line_items": { - "object": "list", - "has_more": false, - "total": 1, - "data": [ - { - "name": "Box of Cohiba S1s", - "unit_price": 35000, - "quantity": 1, - "object": "line_item", - "id": "line_item_2hAEHgP7kJbD8MW38", - "parent_id": "ord_2hAEHgP7kJbD8MW3A", - "metadata": {}, - "antifraud_info": {} - } - ] - }, - "charges": { - "object": "list", - "has_more": false, - "total": 1, - "data": [ - { - "id": "59aee43dedbb6e580e4325a5", - "livemode": false, - "created_at": 1504633917, - "currency": "MXN", - "payment_method": { - "service_name": "OxxoPay", - "object": "cash_payment", - "type": "oxxo", - "expires_at": 1513036800, - "store_name": "OXXO", - "reference": "93345678901234" - }, - "object": "charge", - "description": "Payment from order", - "status": "paid", - "amount": 35000, - "paid_at": 1504633953, - "fee": 1421, - "customer_id": "", - "order_id": "ord_2hAEHgP7kJbD8MW3A" - } - ] - } - }, - { - "livemode": false, - "amount": 70000, - "currency": "MXN", - "amount_refunded": 0, - "customer_info": { - "email": "jul@conekta.io", - "phone": "+5215555555555", - "name": "Jul Ceballos", - "object": "customer_info" - }, - "object": "order", - "id": "ord_2hAEHfeJE745QZnps", - "metadata": {}, - "created_at": 1504633916, - "updated_at": 1504633917, - "line_items": { - "object": "list", - "has_more": false, - "total": 2, - "data": [ - { - "name": "Box of Cohiba S1s", - "unit_price": 35000, - "quantity": 1, - "object": "line_item", - "id": "line_item_2hAEHgP7kJaETYu1L", - "parent_id": "ord_2hAEHfeJE745QZnps", - "metadata": {}, - "antifraud_info": {} - }, - { - "name": "Box of Cohiba S1s", - "unit_price": 35000, - "quantity": 1, - "object": "line_item", - "id": "line_item_2hAEHfeJE745QZnpq", - "parent_id": "ord_2hAEHfeJE745QZnps", - "metadata": {}, - "antifraud_info": {} - } - ] - } - }, - { - "livemode": false, - "amount": 34400, - "currency": "MXN", - "amount_refunded": 0, - "customer_info": { - "email": "jul@conekta.io", - "phone": "+5215555555555", - "name": "Jul Ceballos", - "object": "customer_info" - }, - "object": "order", - "id": "ord_2hAEHexXCuThSxDND", - "metadata": {}, - "created_at": 1504633915, - "updated_at": 1504633916, - "line_items": { - "object": "list", - "has_more": false, - "total": 1, - "data": [ - { - "name": "Box of Cohiba S1s", - "unit_price": 35000, - "quantity": 1, - "object": "line_item", - "id": "line_item_2hAEHexXCuThSxDNB", - "parent_id": "ord_2hAEHexXCuThSxDND", - "metadata": {}, - "antifraud_info": {} - } - ] - }, - "discount_lines": { - "object": "list", - "has_more": false, - "total": 1, - "data": [ - { - "code": "123", - "amount": 600, - "type": "loyalty", - "object": "discount_line", - "id": "dis_lin_2hAEHfVEvpxGWP4jZ", - "parent_id": "ord_2hAEHexXCuThSxDND" - } - ] - } - }, - { - "livemode": false, - "amount": 35000, - "currency": "MXN", - "payment_status": "refunded", - "amount_refunded": 35000, - "customer_info": { - "email": "jul@conekta.io", - "phone": "+5215555555555", - "name": "Jul Ceballos", - "object": "customer_info" - }, - "object": "order", - "id": "ord_2hAEHW3eTWhLyajEp", - "metadata": {}, - "created_at": 1504633903, - "updated_at": 1504633914, - "line_items": { - "object": "list", - "has_more": false, - "total": 1, - "data": [ - { - "name": "Box of Cohiba S1s", - "unit_price": 35000, - "quantity": 1, - "object": "line_item", - "id": "line_item_2hAEHW3eTWhLyajEn", - "parent_id": "ord_2hAEHW3eTWhLyajEp", - "metadata": {}, - "antifraud_info": {} - } - ] - }, - "charges": { - "object": "list", - "has_more": false, - "total": 1, - "data": [ - { - "id": "59aee430b795b0739bff75e2", - "livemode": false, - "created_at": 1504633904, - "currency": "MXN", - "device_fingerprint": "123456789abcdefghijkmnopqrstuv", - "payment_method": { - "name": "Jorge Lopez", - "exp_month": "12", - "exp_year": "19", - "auth_code": "061903", - "object": "card_payment", - "type": "credit", - "last4": "4242", - "brand": "visa", - "issuer": "", - "account_type": "", - "country": "US", - "fraud_score": 34, - "fraud_indicators": [] - }, - "object": "charge", - "description": "Payment from order", - "status": "refunded", - "amount": 35000, - "paid_at": 1504633913, - "fee": 1467, - "customer_id": "", - "order_id": "ord_2hAEHW3eTWhLyajEp", - "refunds": { - "object": "list", - "has_more": false, - "total": 1, - "data": [ - { - "object": "refund", - "amount": -35000, - "auth_code": "061903", - "id": "59aee43affecf9795eb29649", - "created_at": 1504633914 - } - ] - } - } - ] - } - }, - { - "livemode": false, - "amount": 35000, - "currency": "MXN", - "payment_status": "refunded", - "amount_refunded": 35000, - "customer_info": { - "email": "jul@conekta.io", - "phone": "+5215555555555", - "name": "Jul Ceballos", - "object": "customer_info" - }, - "object": "order", - "id": "ord_2hAEHM2kuqgTZj9oE", - "metadata": { - "yes": "nou" - }, - "created_at": 1504633891, - "updated_at": 1504633901, - "line_items": { - "object": "list", - "has_more": false, - "total": 1, - "data": [ - { - "name": "Box of Cohiba S1s", - "unit_price": 35000, - "quantity": 1, - "object": "line_item", - "id": "line_item_2hAEHM2kuqgTZj9oC", - "parent_id": "ord_2hAEHM2kuqgTZj9oE", - "metadata": {}, - "antifraud_info": {} - } - ] - }, - "charges": { - "object": "list", - "has_more": false, - "total": 1, - "data": [ - { - "id": "59aee423b795b015fcfdb42e", - "livemode": false, - "created_at": 1504633891, - "currency": "MXN", - "device_fingerprint": "123456789abcdefghijkmnopqrstuv", - "payment_method": { - "name": "Jorge Lopez", - "exp_month": "12", - "exp_year": "19", - "auth_code": "082539", - "object": "card_payment", - "type": "credit", - "last4": "4242", - "brand": "visa", - "issuer": "", - "account_type": "", - "country": "US", - "fraud_score": 34, - "fraud_indicators": [] - }, - "object": "charge", - "description": "Payment from order", - "status": "refunded", - "amount": 35000, - "paid_at": 1504633900, - "fee": 1467, - "customer_id": "", - "order_id": "ord_2hAEHM2kuqgTZj9oE", - "refunds": { - "object": "list", - "has_more": false, - "total": 1, - "data": [ - { - "object": "refund", - "amount": -35000, - "auth_code": "082539", - "id": "59aee42dedbb6e4f6542fab5", - "created_at": 1504633901 - } - ] - } - } - ] - } - }, - { - "livemode": false, - "amount": 35000, - "currency": "MXN", - "payment_status": "paid", - "amount_refunded": 0, - "customer_info": { - "email": "jul@conekta.io", - "phone": "+5215555555555", - "name": "Jul Ceballos", - "object": "customer_info" - }, - "object": "order", - "id": "ord_2hAEH9xU6rEjBgCSq", - "metadata": {}, - "created_at": 1504633876, - "updated_at": 1504633889, - "line_items": { - "object": "list", - "has_more": false, - "total": 1, - "data": [ - { - "name": "Box of Cohiba S1s", - "unit_price": 35000, - "quantity": 1, - "object": "line_item", - "id": "line_item_2hAEH9xU6rEjBgCSo", - "parent_id": "ord_2hAEH9xU6rEjBgCSq", - "metadata": {}, - "antifraud_info": {} - } - ] - }, - "charges": { - "object": "list", - "has_more": false, - "total": 1, - "data": [ - { - "id": "59aee415ffecf936c9b3d2b4", - "livemode": false, - "created_at": 1504633877, - "currency": "MXN", - "device_fingerprint": "123456789abcdefghijkmnopqrstuv", - "payment_method": { - "name": "Jorge Lopez", - "exp_month": "12", - "exp_year": "19", - "auth_code": "156573", - "object": "card_payment", - "type": "credit", - "last4": "4242", - "brand": "visa", - "issuer": "", - "account_type": "", - "country": "US", - "fraud_score": 34, - "fraud_indicators": [] - }, - "object": "charge", - "description": "Payment from order", - "status": "paid", - "amount": 35000, - "paid_at": 1504633889, - "fee": 1467, - "customer_id": "", - "order_id": "ord_2hAEH9xU6rEjBgCSq" - } - ] - } - }, - { - "livemode": false, - "amount": 1175000, - "currency": "MXN", - "amount_refunded": 0, - "customer_info": { - "email": "jul@conekta.io", - "phone": "+5215555555555", - "name": "Jul Ceballos", - "object": "customer_info" - }, - "object": "order", - "id": "ord_2hAEH9DeaepBkqNrt", - "metadata": {}, - "created_at": 1504633875, - "updated_at": 1504633875, - "line_items": { - "next_page_url": "https://api.conekta.io/orders/ord_2hAEH9DeaepBkqNrt/line_items?next=line_item_2hAEH9DeaepBkqNrn&limit=5", - "object": "list", - "has_more": true, - "total": 25, - "data": [ - { - "name": "Box of Cohiba S1s x", - "unit_price": 59000, - "quantity": 1, - "object": "line_item", - "id": "line_item_2hAEH9DeaepBkqNrr", - "parent_id": "ord_2hAEH9DeaepBkqNrt", - "metadata": {}, - "antifraud_info": {} - }, - { - "name": "Box of Cohiba S1s w", - "unit_price": 58000, - "quantity": 1, - "object": "line_item", - "id": "line_item_2hAEH9DeaepBkqNrq", - "parent_id": "ord_2hAEH9DeaepBkqNrt", - "metadata": {}, - "antifraud_info": {} - }, - { - "name": "Box of Cohiba S1s v", - "unit_price": 57000, - "quantity": 1, - "object": "line_item", - "id": "line_item_2hAEH9DeaepBkqNrp", - "parent_id": "ord_2hAEH9DeaepBkqNrt", - "metadata": {}, - "antifraud_info": {} - }, - { - "name": "Box of Cohiba S1s u", - "unit_price": 56000, - "quantity": 1, - "object": "line_item", - "id": "line_item_2hAEH9DeaepBkqNro", - "parent_id": "ord_2hAEH9DeaepBkqNrt", - "metadata": {}, - "antifraud_info": {} - }, - { - "name": "Box of Cohiba S1s t", - "unit_price": 55000, - "quantity": 1, - "object": "line_item", - "id": "line_item_2hAEH9DeaepBkqNrn", - "parent_id": "ord_2hAEH9DeaepBkqNrt", - "metadata": {}, - "antifraud_info": {} - } - ] - } - }, - { - "livemode": false, - "amount": 35700, - "currency": "MXN", - "amount_refunded": 0, - "object": "order", - "id": "ord_2hAEAZh7grx9s3rwb", - "metadata": {}, - "created_at": 1504633358, - "updated_at": 1504633358, - "line_items": { - "object": "list", - "has_more": false, - "total": 1, - "data": [ - { - "name": "Box of Cohiba S1s", - "description": "Imported From Mex.", - "unit_price": 35000, - "quantity": 1, - "tags": [ - "food", - "mexican food" - ], - "object": "line_item", - "id": "line_item_2hAEAZh7grx9s3rwY", - "parent_id": "ord_2hAEAZh7grx9s3rwb", - "metadata": {}, - "antifraud_info": {} - } - ] - }, - "tax_lines": { - "object": "list", - "has_more": false, - "total": 2, - "data": [ - { - "description": "ISR", - "amount": 100, - "object": "tax_line", - "id": "tax_lin_2hAEAZh7grx9s3rwa", - "parent_id": "ord_2hAEAZh7grx9s3rwb" - }, - { - "description": "IVA", - "amount": 600, - "object": "tax_line", - "id": "tax_lin_2hAEAZh7grx9s3rwZ", - "parent_id": "ord_2hAEAZh7grx9s3rwb" - } - ] - } - }, - { - "livemode": false, - "amount": 35650, - "currency": "MXN", - "amount_refunded": 0, - "object": "order", - "id": "ord_2hAEAZ1LffN8E3qcQ", - "metadata": {}, - "created_at": 1504633357, - "updated_at": 1504633357, - "line_items": { - "object": "list", - "has_more": false, - "total": 1, - "data": [ - { - "name": "Box of Cohiba S1s", - "description": "Imported From Mex.", - "unit_price": 35000, - "quantity": 1, - "tags": [ - "food", - "mexican food" - ], - "object": "line_item", - "id": "line_item_2hAEAZ1LffN8E3qcM", - "parent_id": "ord_2hAEAZ1LffN8E3qcQ", - "metadata": {}, - "antifraud_info": {} - } - ] - }, - "tax_lines": { - "object": "list", - "has_more": false, - "total": 2, - "data": [ - { - "description": "ISR", - "amount": 50, - "object": "tax_line", - "id": "tax_lin_2hAEAZ1LffN8E3qcP", - "parent_id": "ord_2hAEAZ1LffN8E3qcQ" - }, - { - "description": "IVA", - "amount": 600, - "object": "tax_line", - "id": "tax_lin_2hAEAZ1LffN8E3qcN", - "parent_id": "ord_2hAEAZ1LffN8E3qcQ" - } - ] - } - }, - { - "livemode": false, - "amount": 35600, - "currency": "MXN", - "amount_refunded": 0, - "object": "order", - "id": "ord_2hAEAY4RMBXQ1F7cu", - "metadata": {}, - "created_at": 1504633356, - "updated_at": 1504633356, - "line_items": { - "object": "list", - "has_more": false, - "total": 1, - "data": [ - { - "name": "Box of Cohiba S1s", - "description": "Imported From Mex.", - "unit_price": 35000, - "quantity": 1, - "tags": [ - "food", - "mexican food" - ], - "object": "line_item", - "id": "line_item_2hAEAY4RMBXQ1F7cr", - "parent_id": "ord_2hAEAY4RMBXQ1F7cu", - "metadata": {}, - "antifraud_info": {} - } - ] - }, - "tax_lines": { - "object": "list", - "has_more": false, - "total": 1, - "data": [ - { - "description": "IVA", - "amount": 600, - "object": "tax_line", - "id": "tax_lin_2hAEAY4RMBXQ1F7cs", - "parent_id": "ord_2hAEAY4RMBXQ1F7cu" - } - ] - } - }, - { - "livemode": false, - "amount": 35040, - "currency": "MXN", - "amount_refunded": 0, - "object": "order", - "id": "ord_2hAEAUXP3U1Z5yqyw", - "metadata": {}, - "created_at": 1504633351, - "updated_at": 1504633351, - "line_items": { - "object": "list", - "has_more": false, - "total": 1, - "data": [ - { - "name": "Box of Cohiba S1s", - "description": "Imported From Mex.", - "unit_price": 35000, - "quantity": 1, - "tags": [ - "food", - "mexican food" - ], - "object": "line_item", - "id": "line_item_2hAEAUXP3U1Z5yqyt", - "parent_id": "ord_2hAEAUXP3U1Z5yqyw", - "metadata": {}, - "antifraud_info": {} - } - ] - }, - "shipping_lines": { - "object": "list", - "has_more": false, - "total": 2, - "data": [ - { - "amount": 40, - "carrier": "USPS", - "method": "Train", - "tracking_number": "TRACK124", - "object": "shipping_line", - "id": "ship_lin_2hAEAUXP3U1Z5yqyv", - "parent_id": "ord_2hAEAUXP3U1Z5yqyw" - }, - { - "amount": 0, - "carrier": "USPS", - "method": "Train", - "tracking_number": "TRACK123", - "object": "shipping_line", - "id": "ship_lin_2hAEAUXP3U1Z5yqyu", - "parent_id": "ord_2hAEAUXP3U1Z5yqyw" - } - ] - } - }, - { - "livemode": false, - "amount": 35040, - "currency": "MXN", - "amount_refunded": 0, - "object": "order", - "id": "ord_2hAEAT6nW4oiKXfYV", - "metadata": {}, - "created_at": 1504633349, - "updated_at": 1504633349, - "line_items": { - "object": "list", - "has_more": false, - "total": 1, - "data": [ - { - "name": "Box of Cohiba S1s", - "description": "Imported From Mex.", - "unit_price": 35000, - "quantity": 1, - "tags": [ - "food", - "mexican food" - ], - "object": "line_item", - "id": "line_item_2hAEAT6nW4oiKXfYS", - "parent_id": "ord_2hAEAT6nW4oiKXfYV", - "metadata": {}, - "antifraud_info": {} - } - ] - }, - "shipping_lines": { - "object": "list", - "has_more": false, - "total": 2, - "data": [ - { - "amount": 40, - "carrier": "USPS", - "method": "Air", - "tracking_number": "TRACK124", - "object": "shipping_line", - "id": "ship_lin_2hAEAT6nW4oiKXfYU", - "parent_id": "ord_2hAEAT6nW4oiKXfYV" - }, - { - "amount": 0, - "carrier": "USPS", - "method": "Train", - "tracking_number": "TRACK123", - "object": "shipping_line", - "id": "ship_lin_2hAEAT6nW4oiKXfYT", - "parent_id": "ord_2hAEAT6nW4oiKXfYV" - } - ] - } - }, - { - "livemode": false, - "amount": 35000, - "currency": "MXN", - "amount_refunded": 0, - "object": "order", - "id": "ord_2hAEAS9sBb2D15ohV", - "metadata": {}, - "created_at": 1504633348, - "updated_at": 1504633349, - "line_items": { - "object": "list", - "has_more": false, - "total": 1, - "data": [ - { - "name": "Box of Cohiba S1s", - "description": "Imported From Mex.", - "unit_price": 35000, - "quantity": 1, - "tags": [ - "food", - "mexican food" - ], - "object": "line_item", - "id": "line_item_2hAEAS9sBb2D15ohS", - "parent_id": "ord_2hAEAS9sBb2D15ohV", - "metadata": {}, - "antifraud_info": {} - } - ] - }, - "shipping_lines": { - "object": "list", - "has_more": false, - "total": 1, - "data": [ - { - "amount": 0, - "carrier": "USPS", - "method": "Train", - "tracking_number": "TRACK123", - "object": "shipping_line", - "id": "ship_lin_2hAEAS9sBb2D15ohT", - "parent_id": "ord_2hAEAS9sBb2D15ohV" - } - ] - } - } - ] -} \ No newline at end of file diff --git a/lib/conekta-php/test/support/index.php b/lib/conekta-php/test/support/index.php index 88fcd5f2d..db82febd0 100644 --- a/lib/conekta-php/test/support/index.php +++ b/lib/conekta-php/test/support/index.php @@ -1,35 +1,27 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * - * DISCLAIMER + * @category Conekta * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to http://www.prestashop.com for more information. + * @version GIT: @2.3.6@ * - * @author PrestaShop SA - * @copyright 2007-2017 PrestaShop SA - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA + * @see https://conekta.com/ */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); +header('Location: ../'); - /* -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); -header("Location: ../"); exit; -*/ diff --git a/lib/index.php b/lib/index.php index 1ea68f214..db82febd0 100644 --- a/lib/index.php +++ b/lib/index.php @@ -1,33 +1,27 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * - * DISCLAIMER + * @category Conekta * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to http://www.prestashop.com for more information. + * @version GIT: @2.3.6@ * - * @author PrestaShop SA - * @copyright 2007-2022 PrestaShop SA - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA + * @see https://conekta.com/ */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); +header('Location: ../'); -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); -header("Location: ../"); exit; diff --git a/mails/en/index.php b/mails/en/index.php index 1ea68f214..db82febd0 100644 --- a/mails/en/index.php +++ b/mails/en/index.php @@ -1,33 +1,27 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * - * DISCLAIMER + * @category Conekta * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to http://www.prestashop.com for more information. + * @version GIT: @2.3.6@ * - * @author PrestaShop SA - * @copyright 2007-2022 PrestaShop SA - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA + * @see https://conekta.com/ */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); +header('Location: ../'); -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); -header("Location: ../"); exit; diff --git a/mails/es/index.php b/mails/es/index.php index 1ea68f214..db82febd0 100644 --- a/mails/es/index.php +++ b/mails/es/index.php @@ -1,33 +1,27 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * - * DISCLAIMER + * @category Conekta * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to http://www.prestashop.com for more information. + * @version GIT: @2.3.6@ * - * @author PrestaShop SA - * @copyright 2007-2022 PrestaShop SA - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA + * @see https://conekta.com/ */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); +header('Location: ../'); -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); -header("Location: ../"); exit; diff --git a/mails/index.php b/mails/index.php index 1ea68f214..db82febd0 100644 --- a/mails/index.php +++ b/mails/index.php @@ -1,33 +1,27 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * - * DISCLAIMER + * @category Conekta * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to http://www.prestashop.com for more information. + * @version GIT: @2.3.6@ * - * @author PrestaShop SA - * @copyright 2007-2022 PrestaShop SA - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA + * @see https://conekta.com/ */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); +header('Location: ../'); -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); -header("Location: ../"); exit; diff --git a/mails/mx/index.php b/mails/mx/index.php index 66c84ead2..db82febd0 100644 --- a/mails/mx/index.php +++ b/mails/mx/index.php @@ -1,32 +1,27 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * - * DISCLAIMER + * @category Conekta * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to http://www.prestashop.com for more information. + * @version GIT: @2.3.6@ * - * @author PrestaShop SA - * @copyright 2007-2022 PrestaShop SA - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA + * @see https://conekta.com/ */ -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); -header("Location: ../"); +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); +header('Location: ../'); + exit; diff --git a/model/Config.php b/model/Config.php index 9a40ce11a..b41b77564 100644 --- a/model/Config.php +++ b/model/Config.php @@ -1,50 +1,56 @@ -* @copyright 2012-2022 Conekta -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* @version v1.0.0 -*/ + * NOTICE OF LICENSE + * Title : Conekta Card Payment Gateway for Prestashop + * Author : Conekta.io + * URL : https://www.conekta.io/es/docs/plugins/prestashop. + * PHP Version 7.0.0 + * Conekta File Doc Comment + * + * @author Conekta + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ /** -* Class Config -*/ + * Class Config + */ class Config { public static function getLineItems($items = '') { - $lineItems = array(); + $lineItems = []; + foreach ($items as $item) { - $lineItems = array_merge($lineItems, array( - array( - 'name' => $item['name'], - 'unit_price' => (int)((float)$item['price'] * 100), - 'quantity' => (int)$item['cart_quantity'], - 'tags' => array("prestashop") - ) - )); + $lineItems = array_merge($lineItems, [ + [ + 'name' => $item['name'], + 'unit_price' => (int) ((float) $item['price'] * 100), + 'quantity' => (int) $item['cart_quantity'], + 'tags' => ['prestashop'], + ], + ]); if (Tools::strlen($item['reference']) > 0) { - array_merge($lineItems, array( - array( - 'sku' => $item['reference'] - ) - )); + array_merge($lineItems, [ + [ + 'sku' => $item['reference'], + ], + ]); } if (Tools::strlen($item['description_short']) > 2) { - array_merge($lineItems, array( - array( - 'description' => $item['reference'] - ) - )); + array_merge($lineItems, [ + [ + 'description' => $item['reference'], + ], + ]); } } @@ -53,16 +59,18 @@ public static function getLineItems($items = '') public static function getTaxLines($items = '') { - $tax_lines = array(); + $tax_lines = []; + foreach ($items as $item) { - $tax = (int)round(((float)$item['total_wt'] - (float)$item['total']) * 100); + $tax = (int) round(((float) $item['total_wt'] - (float) $item['total']) * 100); + if (!empty($item['tax_name'])) { - $tax_lines = array_merge($tax_lines, array( - array( + $tax_lines = array_merge($tax_lines, [ + [ 'description' => $item['tax_name'], - 'amount' => $tax - ) - )); + 'amount' => $tax, + ], + ]); } } @@ -71,65 +79,67 @@ public static function getTaxLines($items = '') public static function getDiscountLines($discounts) { - $discount_lines = array(); + $discount_lines = []; + if (!empty($discounts)) { foreach ($discounts as $discount) { $discount_lines = array_merge( $discount_lines, - array( - array( + [ + [ 'code' => (string) $discount['name'], - 'amount' => str_replace(',', '', number_format(($discount['value_real'] * 100))), - 'type'=>'coupon' - ) - ) + 'amount' => str_replace(',', '', number_format($discount['value_real'] * 100)), + 'type' => 'coupon', + ], + ] ); } } + return $discount_lines; } public static function getShippingLines($shipping_service, $shipping_carrier = '', $shipping_price = '') { - $shipping_price = str_replace(',', '', number_format(($shipping_price * 100))); - $shipping_lines = array( - array( - "amount" => $shipping_price, - "tracking_number" => $shipping_service, - "carrier" => $shipping_carrier, - "method" => $shipping_service - ) - ); + $shipping_price = str_replace(',', '', number_format($shipping_price * 100)); + $shipping_lines = [ + [ + 'amount' => $shipping_price, + 'tracking_number' => $shipping_service, + 'carrier' => $shipping_carrier, + 'method' => $shipping_service, + ], + ]; return $shipping_lines; } public static function getShippingContact($customer = '', $address_delivery = '', $state = '', $country = '') { - $shipping_contact = array( - "receiver" => $customer->firstname . " " . $customer->lastname, - "phone" => $address_delivery->phone, - "address" => array( - "street1" => $address_delivery->address1, - "city" => $address_delivery->city, - "state" => $state, - "country" => $country, - "postal_code" => $address_delivery->postcode - ), - "metadata" => array("soft_validations" => true) - ); + $shipping_contact = [ + 'receiver' => $customer->firstname . ' ' . $customer->lastname, + 'phone' => $address_delivery->phone, + 'address' => [ + 'street1' => $address_delivery->address1, + 'city' => $address_delivery->city, + 'state' => $state, + 'country' => $country, + 'postal_code' => $address_delivery->postcode, + ], + 'metadata' => ['soft_validations' => true], + ]; return $shipping_contact; } public static function getCustomerInfo($customer = '', $address_delivery = '') { - $customer_info = array( - "name" => $customer->firstname . " " . $customer->lastname, - "phone" => $address_delivery->phone, - "email" => $customer->email, - "metadata" => array("soft_validations" => true) - ); + $customer_info = [ + 'name' => $customer->firstname . ' ' . $customer->lastname, + 'phone' => $address_delivery->phone, + 'email' => $customer->email, + 'metadata' => ['soft_validations' => true], + ]; return $customer_info; } diff --git a/model/Database.php b/model/Database.php index 1aff196f8..df94ba2d0 100644 --- a/model/Database.php +++ b/model/Database.php @@ -1,34 +1,34 @@ - * @copyright 2012-2022 Conekta + * @copyright 2012-2023 Conekta * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - * @category Database - * @package Database - * @version GIT: @2.3.5@ - * @link https://conekta.com/ + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ */ /** * Database Class Doc Comment * * @author Conekta + * * @category Class - * @package Database + * * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - * @link https://conekta.com/ + * + * @see https://conekta.com/ */ - class Database { /** @@ -65,13 +65,13 @@ public static function getConektaTransaction($order_id) /** * Insert payment with oxxo * - * @param Order $order Object order - * @param array $charge_response Charges made on the order - * @param string $reference Payment reference code - * @param int $currentOrder Order ID - * @param int $cartId Cart ID + * @param Order $order Object order + * @param array $charge_response Charges made on the order + * @param string $reference Payment reference code + * @param int $currentOrder Order ID + * @param int $cartId Cart ID * - * @return boolean + * @return bool */ public static function insertOxxoPayment($order, $charge_response, $reference, $currentOrder, $cartId) { @@ -93,11 +93,11 @@ public static function insertOxxoPayment($order, $charge_response, $reference, $ /** * Create table ps_conekta_transaction * - * @return boolean + * @return bool */ public static function installDb() { - return ( + return Db::getInstance()->execute( 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'conekta_transaction` ( `id_conekta_transaction` int(11) NOT NULL AUTO_INCREMENT, @@ -118,17 +118,17 @@ public static function installDb() KEY `idx_transaction` (`type`,`id_order`,`status`)) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8 AUTO_INCREMENT=1' ) - ); + ; } /** * Create table ps_conekta_metadata * - * @return boolean + * @return bool */ public static function createTableMetaData() { - $table = _DB_PREFIX_."conekta_metadata"; + $table = _DB_PREFIX_ . 'conekta_metadata'; $sql = "CREATE TABLE IF NOT EXISTS $table ( id_conekta_metadata int(11) NOT NULL AUTO_INCREMENT, id_user int(11) unsigned NOT NULL, @@ -139,19 +139,19 @@ public static function createTableMetaData() KEY id_user (id_user), KEY id_conekta_metadata (id_conekta_metadata) ) - ENGINE=". _MYSQL_ENGINE_ . "DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;"; + ENGINE=" . _MYSQL_ENGINE_ . 'DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'; - return (Db::getInstance()->execute($sql)); + return Db::getInstance()->execute($sql); } /** * Create table ps_conekta_product_data * - * @return boolean + * @return bool */ public static function createTableProductData() { - $table = _DB_PREFIX_."conekta_product_data"; + $table = _DB_PREFIX_ . 'conekta_product_data'; $sql = "CREATE TABLE IF NOT EXISTS $table ( id_conekta_product_data int(11) NOT NULL AUTO_INCREMENT, id_product int(11) unsigned NOT NULL, @@ -161,19 +161,19 @@ public static function createTableProductData() KEY id_product (id_product), KEY id_conekta_product_data (id_conekta_product_data) ) - ENGINE=". _MYSQL_ENGINE_ . "DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;"; + ENGINE=" . _MYSQL_ENGINE_ . 'DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'; - return (Db::getInstance()->execute($sql)); + return Db::getInstance()->execute($sql); } /** * Create table ps_conekta_order_checkout * - * @return boolean + * @return bool */ public static function createTableConektaOrder() { - $table = _DB_PREFIX_."conekta_order_checkout"; + $table = _DB_PREFIX_ . 'conekta_order_checkout'; $sql = "CREATE TABLE IF NOT EXISTS $table ( id int(11) NOT NULL AUTO_INCREMENT, id_user int(11) unsigned NOT NULL, @@ -181,31 +181,31 @@ public static function createTableConektaOrder() `mode` enum(\"live\",\"test\") NOT NULL, id_conekta_order varchar(32) NOT NULL, `status` enum(\"paid\",\"pre_authorized\",\"unpaid\",\"pending_payment\",\"expired\",\"voided\"," - . "\"fraudulent\",\"preauthorized\",\"canceled\",\"pending_confirmation\",\"charged_back\"," - . "\"partially_refunded\",\"refunded\",\"reversed\",\"approved\",\"declined\",\"in_review\"," - . "\"insufficient_funds\",\"card_declined\",\"stolen_card\",\"suspected_fraud\"," - . "\"unprocessable_card_type\") NOT NULL, + . '"fraudulent","preauthorized","canceled","pending_confirmation","charged_back",' + . '"partially_refunded","refunded","reversed","approved","declined","in_review",' + . '"insufficient_funds","card_declined","stolen_card","suspected_fraud",' + . '"unprocessable_card_type") NOT NULL, PRIMARY KEY (id), KEY id_user (id_user), KEY id_cart (id_cart), KEY id (id), KEY id_conekta_order (id_conekta_order) ) - ENGINE=". _MYSQL_ENGINE_ . "DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;"; + ENGINE=' . _MYSQL_ENGINE_ . 'DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'; - return (Db::getInstance()->execute($sql)); + return Db::getInstance()->execute($sql); } /** * Insert payment with spei * - * @param Order $order Object order - * @param array $charge_response Charges made on the order - * @param string $reference Payment reference code - * @param int $currentOrder Order ID - * @param int $cartId Cart ID + * @param Order $order Object order + * @param array $charge_response Charges made on the order + * @param string $reference Payment reference code + * @param int $currentOrder Order ID + * @param int $cartId Cart ID * - * @return boolean + * @return bool */ public static function insertSpeiPayment($order, $charge_response, $reference, $currentOrder, $cartId) { @@ -215,7 +215,7 @@ public static function insertSpeiPayment($order, $charge_response, $reference, $ . 'status, currency, mode, date_add, reference, captured)' . 'VALUES (\'payment\', ' . (int) $cartId . ', ' . (int) $currentOrder . ', \'' . pSQL($order->id) . '\', \'' . pSQL($charge_response->id) . '\', \'' - . (float)($charge_response->amount * 0.01) . '\', \'' + . (float) ($charge_response->amount * 0.01) . '\', \'' . ($charge_response->status == 'paid' ? 'paid' : 'unpaid') . '\', \'' . pSQL($charge_response->currency) . '\', \'' . ($charge_response->livemode == 'true' ? 'live' : 'test') . '\', NOW(),\'' @@ -226,12 +226,12 @@ public static function insertSpeiPayment($order, $charge_response, $reference, $ /** * Insert payment with card * - * @param Order $order Object order + * @param Order $order Object order * @param array $charge_response Charges made on the order - * @param int $currentOrder Order ID - * @param int $cartId Cart ID + * @param int $currentOrder Order ID + * @param int $cartId Cart ID * - * @return boolean + * @return bool */ public static function insertCardPayment($order, $charge_response, $currentOrder, $cartId) { @@ -241,7 +241,7 @@ public static function insertCardPayment($order, $charge_response, $currentOrder . 'amount, status, currency, mode, date_add, captured)' . 'VALUES (\'payment\', ' . (int) $cartId . ', ' . (int) $currentOrder . ', \'' . pSQL($order->id) . '\', \'' . pSQL($charge_response->id) . '\',\'' - . (float)($charge_response->amount * 0.01) . '\', \'' + . (float) ($charge_response->amount * 0.01) . '\', \'' . ($charge_response->status == 'paid' ? 'paid' : 'unpaid') . '\', \'' . pSQL($charge_response->currency) . '\', \'' . ($charge_response->livemode == 'true' ? 'live' : 'test') . '\', NOW(), \'1\')' @@ -266,39 +266,39 @@ public static function getOrderById($id_order) /** * Returns the order information * - * @param int $user_id Order ID - * @param string $mode Mode (Production or Test) + * @param int $user_id Order ID + * @param string $mode Mode (Production or Test) * @param string $meta_options Metadata option to be searched * * @return array|string */ public static function getConektaMetadata($user_id, $mode, $meta_options) { - $table = _DB_PREFIX_."conekta_metadata"; + $table = _DB_PREFIX_ . 'conekta_metadata'; $sql = "SELECT meta_value FROM $table WHERE id_user = '{$user_id}' " . "AND meta_option = '{$meta_options}' " . "AND `mode` = '{$mode}'"; - return Db::getInstance()->getRow($sql); + return Db::getInstance()->getRow($sql); } /** * Returns the product information * - * @param int $id_product Product ID + * @param int $id_product Product ID * @param string $product_attribute Attribute of the product * * @return array|string */ public static function getConektaProductData($id_product, $product_attribute) { - $table = _DB_PREFIX_."conekta_product_data"; + $table = _DB_PREFIX_ . 'conekta_product_data'; $sql = "SELECT product_value FROM $table WHERE id_product = '{$id_product}' " . "AND product_attribute = '{$product_attribute}' "; - return Db::getInstance()->getRow($sql); + return Db::getInstance()->getRow($sql); } /** @@ -310,130 +310,132 @@ public static function getConektaProductData($id_product, $product_attribute) */ public static function getProductIdProductData($product_value) { - $table = _DB_PREFIX_."conekta_product_data"; + $table = _DB_PREFIX_ . 'conekta_product_data'; $sql = "SELECT id_product FROM $table WHERE product_value = '{$product_value}'"; - return Db::getInstance()->ExecuteS($sql); + return Db::getInstance()->ExecuteS($sql); } /** * Save or update value. * - * @param int $user_id User ID - * @param string $mode Mode (Production or Test) + * @param int $user_id User ID + * @param string $mode Mode (Production or Test) * @param string $meta_options Metadata option to save - * @param string $meta_value Value to be saved + * @param string $meta_value Value to be saved * - * @return boolean + * @return bool */ public static function updateConektaMetadata($user_id, $mode, $meta_options, $meta_value) { - $table = _DB_PREFIX_."conekta_metadata"; + $table = _DB_PREFIX_ . 'conekta_metadata'; if (empty(Database::getConektaMetadata($user_id, $mode, $meta_options))) { $sql = "INSERT INTO $table(id_user, mode, meta_option, meta_value) " . "VALUES ('{$user_id}','{$mode}','{$meta_options}','{$meta_value}')"; } else { - $sql ="UPDATE $table SET id_user = '{$user_id}', meta_option = '{$meta_options}', " + $sql = "UPDATE $table SET id_user = '{$user_id}', meta_option = '{$meta_options}', " . "meta_value = '{$meta_value}' WHERE id_user = '{$user_id}' AND meta_option = '{$meta_options}' " . "AND `mode` = '{$mode}'"; } + return Db::getInstance()->Execute($sql); } /** * Save or update value. * - * @param int $id_product User ID + * @param int $id_product User ID * @param string $product_attribute Mode (Production or Test) - * @param string $product_value Metadata option to save + * @param string $product_value Metadata option to save * - * @return boolean + * @return bool */ public static function updateConektaProductData($id_product, $product_attribute, $product_value) { - $table = _DB_PREFIX_."conekta_product_data"; + $table = _DB_PREFIX_ . 'conekta_product_data'; if (empty(self::getConektaProductData($id_product, $product_attribute))) { $sql = "INSERT INTO $table(id_product, product_attribute, product_value) " . "VALUES ('{$id_product}','{$product_attribute}','{$product_value}')"; } else { - $sql ="UPDATE $table SET product_value = '{$product_value}' " + $sql = "UPDATE $table SET product_value = '{$product_value}' " . "WHERE id_product = '{$id_product}' AND product_attribute = '{$product_attribute}' "; } + return Db::getInstance()->Execute($sql); } /** * Return if the product is a subscription * - * @param int $id_product User ID + * @param int $id_product User ID * - * @return boolean + * @return bool */ public static function isProductSubscription($id_product) { - $table = _DB_PREFIX_."conekta_product_data"; + $table = _DB_PREFIX_ . 'conekta_product_data'; $sql = "SELECT product_value FROM $table WHERE id_product = '{$id_product}' " - . "AND product_attribute = 'is_subscription' "; + . 'AND product_attribute = \'is_subscription\' '; $result = Db::getInstance()->getValue($sql); - return ($result == "true"); + return $result == 'true'; } /** * Return the ID plan * - * @param int $id_product User ID + * @param int $id_product User ID * * @return string */ public static function getIdPlan($id_product) { - $table = _DB_PREFIX_."conekta_product_data"; + $table = _DB_PREFIX_ . 'conekta_product_data'; $sql = "SELECT product_value FROM $table WHERE id_product = '{$id_product}' " - . "AND product_attribute = 'subscription_plan' "; + . 'AND product_attribute = \'subscription_plan\' '; - return Db::getInstance()->getValue($sql); + return Db::getInstance()->getValue($sql); } /** * Returns the id of the order created by conekta * - * @param int $user_id User ID - * @param string $mode Mode (Production or Test) - * @param int $cart_id Cart ID + * @param int $user_id User ID + * @param string $mode Mode (Production or Test) + * @param int $cart_id Cart ID * * @return array|string */ public static function getConektaOrder($user_id, $mode, $cart_id) { - $table = _DB_PREFIX_."conekta_order_checkout"; + $table = _DB_PREFIX_ . 'conekta_order_checkout'; $sql = "SELECT id_conekta_order, `status` FROM $table WHERE id_user = '{$user_id}' " . "AND `mode` = '{$mode}' AND `status` = 'unpaid' AND id_cart ='{$cart_id}'"; - return Db::getInstance()->getRow($sql); + return Db::getInstance()->getRow($sql); } /** * Add or update placed orders * - * @param int $user_id User ID - * @param int $cart_id Cart ID - * @param string $mode Mode (Production or Test) + * @param int $user_id User ID + * @param int $cart_id Cart ID + * @param string $mode Mode (Production or Test) * @param string $id_conekta_order Order ID generate for Conekta - * @param string $status Order status + * @param string $status Order status * - * @return boolean + * @return bool */ public static function updateConektaOrder($user_id, $cart_id, $mode, $id_conekta_order, $status) { - $table = _DB_PREFIX_."conekta_order_checkout"; + $table = _DB_PREFIX_ . 'conekta_order_checkout'; if (empty(Database::getConektaOrder($user_id, $mode, $cart_id))) { $sql = "INSERT INTO $table(id_user, id_cart, mode, id_conekta_order, `status`) " @@ -442,20 +444,22 @@ public static function updateConektaOrder($user_id, $cart_id, $mode, $id_conekta $sql = "UPDATE $table SET `status` = '{$status}' WHERE id_user = '{$user_id}' " . "AND id_cart = '{$cart_id}' AND id_conekta_order = '{$id_conekta_order}' AND `mode` = '{$mode}'"; } + return Db::getInstance()->Execute($sql); } /** * Returns the id of the order related to the reference_id * - * @param string $reference_id Alphabetical reference code assigned to the order. + * @param string $reference_id alphabetical reference code assigned to the order * * @return array|string */ public static function getOrderByReferenceId($reference_id) { - $table = _DB_PREFIX_."orders"; + $table = _DB_PREFIX_ . 'orders'; $sql = "SELECT id_order FROM $table WHERE reference = '{$reference_id}'"; + return Db::getInstance()->getRow($sql); } } diff --git a/model/index.php b/model/index.php index 1ea68f214..db82febd0 100644 --- a/model/index.php +++ b/model/index.php @@ -1,33 +1,27 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * - * DISCLAIMER + * @category Conekta * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to http://www.prestashop.com for more information. + * @version GIT: @2.3.6@ * - * @author PrestaShop SA - * @copyright 2007-2022 PrestaShop SA - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA + * @see https://conekta.com/ */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); +header('Location: ../'); -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); -header("Location: ../"); exit; diff --git a/notification.php b/notification.php index 34c6c4c18..5b7fa0ada 100644 --- a/notification.php +++ b/notification.php @@ -1,35 +1,34 @@ - * @copyright 2012-2019 Conekta + * @copyright 2012-2023 Conekta * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - * @category Notification - * @package Notification - * @version GIT: @2.3.5@ - * @link https://conekta.com/ * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ */ - require_once dirname(__FILE__) . '/../../config/config.inc.php'; + require_once dirname(__FILE__) . '/../../init.php'; + require_once dirname(__FILE__) . '/model/Database.php'; if (!defined('_PS_VERSION_')) { exit; } -define("ORDER_CANCELED", 6); -define("ORDER_REFUNDED", 7); +define('ORDER_CANCELED', 6); +define('ORDER_REFUNDED', 7); /* To configure, add webhook in account @@ -39,9 +38,10 @@ $body = Tools::file_get_contents('php://input'); authenticateEvent($body, filter_input(INPUT_SERVER, 'HTTP_DIGEST')); $event_json = Tools::jsonDecode($body); + if ($event_json->type == 'order.paid' && isset($event_json->data)) { $conekta_order = $event_json->data->object; - + $reference_id = (string) $conekta_order->metadata->reference_id; $result = Database::getOrderByReferenceId($reference_id); $id_order = $result['id_order']; @@ -56,7 +56,7 @@ if ($currency_payment[0]['iso_code'] === $conekta_order->currency) { if ($str_total_order_amount == $conekta_order->amount) { - $orderHistory = new OrderHistory(); + $orderHistory = new OrderHistory(); $orderHistory->id_order = (int) $order->id; $orderHistory->changeIdOrderState( (int) Configuration::get('PS_OS_PAYMENT'), @@ -66,45 +66,45 @@ $addIdTransaction = ''; if (isset($conekta_order->checkout->plan_id)) { - $addIdTransaction = ', id_transaction = '. json_encode($conekta_order->charges->data[0]->id); + $addIdTransaction = ', id_transaction = ' . json_encode($conekta_order->charges->data[0]->id); } - + Db::getInstance()->Execute( 'UPDATE ' . _DB_PREFIX_ - .'conekta_transaction SET status = "paid"' . $addIdTransaction . ' WHERE id_order = ' + . 'conekta_transaction SET status = "paid"' . $addIdTransaction . ' WHERE id_order = ' . pSQL($id_order) ); } } } elseif ($event_json->type == 'order.expired' && isset($event_json->data)) { $conekta_order = $event_json->data->object; - - $reference_id = (string) $conekta_order->metadata->reference_id; - $result = Database::getOrderByReferenceId($reference_id); - $id_order = $result['id_order']; + + $reference_id = (string) $conekta_order->metadata->reference_id; + $result = Database::getOrderByReferenceId($reference_id); + $id_order = $result['id_order']; Db::getInstance()->Execute( 'UPDATE ' . _DB_PREFIX_ - . 'orders SET current_state = '. ORDER_CANCELED .' WHERE id_order = ' + . 'orders SET current_state = ' . ORDER_CANCELED . ' WHERE id_order = ' . pSQL($id_order) ); } elseif ($event_json->type == 'order.canceled' && isset($event_json->data)) { $conekta_order = $event_json->data->object; - $reference_id = (string) $conekta_order->metadata->reference_id; - $result = Database::getOrderByReferenceId($reference_id); - $id_order = $result['id_order']; + $reference_id = (string) $conekta_order->metadata->reference_id; + $result = Database::getOrderByReferenceId($reference_id); + $id_order = $result['id_order']; Db::getInstance()->Execute( 'UPDATE ' . _DB_PREFIX_ - . 'orders SET current_state = '. ORDER_CANCELED .' WHERE id_order = ' + . 'orders SET current_state = ' . ORDER_CANCELED . ' WHERE id_order = ' . pSQL($id_order) ); } elseif ($event_json->type == 'order.refunded' && isset($event_json->data)) { $conekta_order = $event_json->data->object; - $reference_id = (string) $conekta_order->metadata->reference_id; - $result = Database::getOrderByReferenceId($reference_id); - $id_order = $result['id_order']; + $reference_id = (string) $conekta_order->metadata->reference_id; + $result = Database::getOrderByReferenceId($reference_id); + $id_order = $result['id_order']; Db::getInstance()->Execute( 'UPDATE ' . _DB_PREFIX_ - . 'orders SET current_state = '. ORDER_REFUNDED .' WHERE id_order = ' + . 'orders SET current_state = ' . ORDER_REFUNDED . ' WHERE id_order = ' . pSQL($id_order) ); } elseif ($event_json->type == 'plan.deleted' && isset($event_json->data)) { @@ -132,21 +132,23 @@ function authenticateEvent($body, $digest) } else { $private_key_string = Configuration::get('CONEKTA_SIGNATURE_KEY_TEST'); } + if (!empty($private_key_string) && !empty($body)) { if (!empty($digest)) { - $private_key = openssl_pkey_get_private($private_key_string); + $private_key = openssl_pkey_get_private($private_key_string); $encrypted_message = urldecode($digest); - $sha256_message = ""; + $sha256_message = ''; openssl_private_decrypt( $encrypted_message, $sha256_message, $private_key ); - if (hash("sha256", $body) != $sha256_message) { - authenticateLogger("unauthenticated event"); + + if (hash('sha256', $body) != $sha256_message) { + authenticateLogger('unauthenticated event'); } } else { - authenticateLogger("Empty digest"); + authenticateLogger('Empty digest'); } } } @@ -166,4 +168,5 @@ function authenticateLogger($log_message) } header('HTTP/1.1 200 OK'); + exit; diff --git a/views/css/index.php b/views/css/index.php index 2f80a422e..6ce9f5cdd 100644 --- a/views/css/index.php +++ b/views/css/index.php @@ -1,6 +1,6 @@ - * @copyright 2007-2017 PrestaShop SA * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) * International Registered Trademark & Property of PrestaShop SA */ -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); -header("Location: ../"); +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); +header('Location: ../'); + exit; diff --git a/views/img/index.php b/views/img/index.php index 1ea68f214..c5139d770 100644 --- a/views/img/index.php +++ b/views/img/index.php @@ -1,6 +1,6 @@ - * @copyright 2007-2022 PrestaShop SA * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) * International Registered Trademark & Property of PrestaShop SA */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); +header('Location: ../'); -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); -header("Location: ../"); exit; diff --git a/views/index.php b/views/index.php index f19f24e20..06c3fe9d3 100644 --- a/views/index.php +++ b/views/index.php @@ -1,35 +1,29 @@ -* @copyright 2007-2022 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); + * NOTICE OF LICENSE + * Title : Conekta Card Payment Gateway for Prestashop + * Author : Conekta.io + * URL : https://www.conekta.io/es/docs/plugins/prestashop. + * PHP Version 7.0.0 + * Conekta File Doc Comment + * + * @author Conekta + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @category Conekta + * + * @version GIT: @2.3.6@ + * + * @see https://conekta.com/ + */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); + +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); + exit; diff --git a/views/js/functions.js b/views/js/functions.js index 4413aed96..16d0097f0 100644 --- a/views/js/functions.js +++ b/views/js/functions.js @@ -1,5 +1,5 @@ /** -* 2007-2023 Conekta +* @copyright 2012-2023 Conekta * * NOTICE OF LICENSE * @@ -18,53 +18,52 @@ * needs please refer to http://www.prestashop.com for more information. * * @author Conekta -* @copyright 2012-2022 Conekta * @version v2.0.0 * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ function manageInstallments() { - let select = $("#PAYMENT_MONTHS_INSTALLMENT") - let elements = $(".checkbox > label[for^='INSTALLMENTS_'][for$='_MONTHS']").parent().parent().parent() + let select = $("#PAYMENT_MONTHS_INSTALLMENT"); + let elements = $(".checkbox > label[for^='INSTALLMENTS_'][for$='_MONTHS']").parent().parent().parent(); - if (select.val() === 'YES') { - elements.removeClass("hidden") + if (select.val() === "YES") { + elements.removeClass("hidden"); } else { - elements.addClass("hidden") + elements.addClass("hidden"); } } function showInstalmentsOptions() { const paymentCard = $("#PAYMENT_METHS_CARD"); - const selectMonthInstallments = $("#PAYMENT_MONTHS_INSTALLMENT") + const selectMonthInstallments = $("#PAYMENT_MONTHS_INSTALLMENT"); - if (paymentCard.is(':checked')) { - selectMonthInstallments.parent().parent().removeClass('hidden') + if (paymentCard.is(":checked")) { + selectMonthInstallments.parent().parent().removeClass("hidden"); } - if (!paymentCard.is(':checked')) { - selectMonthInstallments.parent().parent().addClass('hidden') - selectMonthInstallments.val('NO') + if (!paymentCard.is(":checked")) { + selectMonthInstallments.parent().parent().addClass("hidden"); + selectMonthInstallments.val("NO"); } - manageInstallments() + manageInstallments(); } $(document).ready(function () { //initial state let paymentCash = $("#PAYMENT_METHS_CASH"); - let expirationDateLimit = $("#EXPIRATION_DATE_LIMIT") - let paymentCashChecked = paymentCash.is(":checked") + let expirationDateLimit = $("#EXPIRATION_DATE_LIMIT"); + let paymentCashChecked = paymentCash.is(":checked"); $("#EXPIRATION_DATE_TYPE_DAYS").prop("disabled", !paymentCashChecked); $("#EXPIRATION_DATE_TYPE_HOURS").prop("disabled", !paymentCashChecked); expirationDateLimit.prop("disabled", !paymentCashChecked); - showInstalmentsOptions() + showInstalmentsOptions(); $("#PAYMENT_MONTHS_INSTALLMENT").change(manageInstallments); - $("#PAYMENT_METHS_CARD").change(showInstalmentsOptions) + $("#PAYMENT_METHS_CARD").change(showInstalmentsOptions); //onchange value paymentCash.change(function () { diff --git a/views/js/index.php b/views/js/index.php index 1ea68f214..f5948c806 100644 --- a/views/js/index.php +++ b/views/js/index.php @@ -19,15 +19,15 @@ * needs please refer to http://www.prestashop.com for more information. * * @author PrestaShop SA - * @copyright 2007-2022 PrestaShop SA + * @copyright 2007-2023 PrestaShop SA * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) * International Registered Trademark & Property of PrestaShop SA */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); +header('Location: ../'); -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); -header("Location: ../"); exit; diff --git a/views/js/tokenize.js b/views/js/tokenize.js index b80279b4e..2b30753ad 100644 --- a/views/js/tokenize.js +++ b/views/js/tokenize.js @@ -18,7 +18,7 @@ * needs please refer to http://www.prestashop.com for more information. * * @author Conekta -* @copyright 2012-2022 Conekta +* @copyright 2012-2023 Conekta * @version v2.0.0 * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA diff --git a/views/templates/front/index.php b/views/templates/front/index.php index 1ea68f214..f5948c806 100644 --- a/views/templates/front/index.php +++ b/views/templates/front/index.php @@ -19,15 +19,15 @@ * needs please refer to http://www.prestashop.com for more information. * * @author PrestaShop SA - * @copyright 2007-2022 PrestaShop SA + * @copyright 2007-2023 PrestaShop SA * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) * International Registered Trademark & Property of PrestaShop SA */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); +header('Location: ../'); -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); -header("Location: ../"); exit; diff --git a/views/templates/front/payment_form.tpl b/views/templates/front/payment_form.tpl index c1152961d..29c4ebf79 100644 --- a/views/templates/front/payment_form.tpl +++ b/views/templates/front/payment_form.tpl @@ -1,29 +1,18 @@ -{* - * 2007-2022 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author Conekta - * @copyright 2007-2022 PrestaShop SA and Contributors - * @version v1.0.0 - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - +/** +* NOTICE OF LICENSE +* Title : Conekta Card Payment Gateway for Prestashop +* Author : Conekta.io +* URL : https://www.conekta.io/es/docs/plugins/prestashop. +* PHP Version 7.0.0 +* Conekta File Doc Comment +* +* @author Conekta +* @copyright 2012-2023 Conekta +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* @category Conekta +* @version GIT: @2.3.6@ +* @see https://conekta.com/ +*/ {if isset($message)}
{$message|escape:'htmlall':'UTF-8'}
{/if} diff --git a/views/templates/front/payment_return.tpl b/views/templates/front/payment_return.tpl index 11ff7d547..394adb928 100644 --- a/views/templates/front/payment_return.tpl +++ b/views/templates/front/payment_return.tpl @@ -1,29 +1,18 @@ -{* - * 2007-2022 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author Conekta - * @copyright 2007-2022 PrestaShop SA and Contributors - * @version v1.0.0 - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - +/** +* NOTICE OF LICENSE +* Title : Conekta Card Payment Gateway for Prestashop +* Author : Conekta.io +* URL : https://www.conekta.io/es/docs/plugins/prestashop. +* PHP Version 7.0.0 +* Conekta File Doc Comment +* +* @author Conekta +* @copyright 2012-2023 Conekta +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* @category Conekta +* @version GIT: @2.3.6@ +* @see https://conekta.com/ +*/ {extends "$layout"} {block name="content"} diff --git a/views/templates/hook/admin-order.tpl b/views/templates/hook/admin-order.tpl index 4172a6d40..f9c4135a6 100644 --- a/views/templates/hook/admin-order.tpl +++ b/views/templates/hook/admin-order.tpl @@ -1,29 +1,18 @@ -{* - * 2007-2022 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author Conekta - * @copyright 2007-2022 PrestaShop SA and Contributors - * @version v1.0.0 - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - +/** +* NOTICE OF LICENSE +* Title : Conekta Card Payment Gateway for Prestashop +* Author : Conekta.io +* URL : https://www.conekta.io/es/docs/plugins/prestashop. +* PHP Version 7.0.0 +* Conekta File Doc Comment +* +* @author Conekta +* @copyright 2012-2023 Conekta +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* @category Conekta +* @version GIT: @2.3.6@ +* @see https://conekta.com/ +*/

{l s='Conekta Payment Details' mod='conekta'}

diff --git a/views/templates/hook/checkout-confirmation-all.tpl b/views/templates/hook/checkout-confirmation-all.tpl index 2a77eeb8e..0cf5a8c4b 100644 --- a/views/templates/hook/checkout-confirmation-all.tpl +++ b/views/templates/hook/checkout-confirmation-all.tpl @@ -1,29 +1,18 @@ -{* - * 2007-2022 PrestaShop and Contributors - * +/** * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. + * Title : Conekta Card Payment Gateway for Prestashop + * Author : Conekta.io + * URL : https://www.conekta.io/es/docs/plugins/prestashop. + * PHP Version 7.0.0 + * Conekta File Doc Comment * * @author Conekta - * @copyright 2007-2022 PrestaShop SA and Contributors - * @version v1.0.0 - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Conekta + * @version GIT: @2.3.6@ + * @see https://conekta.com/ + */ {if isset($cash)}

{l s='Informacion para realizar el pago:' mod='conekta'}



{l s='Monto:' mod='conekta'} $ {$conekta_order.amount|escape:'htmlall':'UTF-8' } diff --git a/views/templates/hook/error.tpl b/views/templates/hook/error.tpl index 5df6bdf5d..3539fc03c 100644 --- a/views/templates/hook/error.tpl +++ b/views/templates/hook/error.tpl @@ -1,29 +1,20 @@ -{* - * 2007-2022 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author Conekta - * @copyright 2007-2022 PrestaShop SA and Contributors - * @version v1.0.0 - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} +/** +* NOTICE OF LICENSE +* Title : Conekta Card Payment Gateway for Prestashop +* Author : Conekta.io +* URL : https://www.conekta.io/es/docs/plugins/prestashop. +* PHP Version 7.0.0 +* Conekta File Doc Comment +* +* @author Conekta +* @copyright 2012-2023 Conekta +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* @category Conekta +* @version GIT: @2.3.6@ +* @see https://conekta.com/ +*/

-

{$error_message|escape:'htmlall':'UTF-8'}
{l s='You can download the requirements needed here: http://addons.prestashop.com/en/modules-prestashop/6222-backwardcompatibility.html' mod='conekta'} -

+

{$error_message|escape:'htmlall':'UTF-8'} +
{l s='You can download the requirements needed here: http://addons.prestashop.com/en/modules-prestashop/6222-backwardcompatibility.html' mod='conekta'} +

\ No newline at end of file diff --git a/views/templates/hook/hook-header.tpl b/views/templates/hook/hook-header.tpl index a0aa9eb31..1047fbd54 100644 --- a/views/templates/hook/hook-header.tpl +++ b/views/templates/hook/hook-header.tpl @@ -1,28 +1,18 @@ -{* - * 2007-2022 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author Conekta - * @copyright 2007-2022 PrestaShop SA and Contributors - * @version v1.0.0 - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} +/** +* NOTICE OF LICENSE +* Title : Conekta Card Payment Gateway for Prestashop +* Author : Conekta.io +* URL : https://www.conekta.io/es/docs/plugins/prestashop. +* PHP Version 7.0.0 +* Conekta File Doc Comment +* +* @author Conekta +* @copyright 2012-2023 Conekta +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* @category Conekta +* @version GIT: @2.3.6@ +* @see https://conekta.com/ +*/ diff --git a/views/templates/hook/index.php b/views/templates/hook/index.php index 1ea68f214..db82febd0 100644 --- a/views/templates/hook/index.php +++ b/views/templates/hook/index.php @@ -1,33 +1,27 @@ + * @copyright 2012-2023 Conekta + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * - * DISCLAIMER + * @category Conekta * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to http://www.prestashop.com for more information. + * @version GIT: @2.3.6@ * - * @author PrestaShop SA - * @copyright 2007-2022 PrestaShop SA - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA + * @see https://conekta.com/ */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); +header('Location: ../'); -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); -header("Location: ../"); exit; diff --git a/views/templates/hook/infos.tpl b/views/templates/hook/infos.tpl index 2a5551596..4f061b113 100644 --- a/views/templates/hook/infos.tpl +++ b/views/templates/hook/infos.tpl @@ -1,29 +1,18 @@ -{* - * 2007-2022 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author Conekta - * @copyright 2007-2022 PrestaShop SA and Contributors - * @version v1.0.0 - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - +/** +* NOTICE OF LICENSE +* Title : Conekta Card Payment Gateway for Prestashop +* Author : Conekta.io +* URL : https://www.conekta.io/es/docs/plugins/prestashop. +* PHP Version 7.0.0 +* Conekta File Doc Comment +* +* @author Conekta +* @copyright 2012-2023 Conekta +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* @category Conekta +* @version GIT: @2.3.6@ +* @see https://conekta.com/ +*/