Skip to content

Commit

Permalink
Ai 73 update conekta plugin prestashop (#122)
Browse files Browse the repository at this point in the history
* Refactor gitignore and composer.json, update PHP version and add new dependencies

- Updated .gitignore to ignore additional files and directories
- Updated composer.json to require a minimum PHP version of 7.4
- Added new dependencies: conekta/conekta-php v6.0.9

* Update Conekta plugin version to 3.0.0

- Update the plugin version in config.xml
- Update the plugin version in conekta.php
- Update the plugin version in HelperGateway.php
- Update the plugin version in README.md

CreateWebhook use case:
- Remove Conekta namespace import and replace it with WebhooksApi, Configuration, and WebhookRequest imports from Conekta SDK.
- Replace `Conekta::setApiKey` with creating a new instance of WebhooksApi using `getApiWebHookInstance` method.
- Replace `Webhook::where()` with calling `getWebhooks` method on `$webhookApi`.
- Replace `Webhook::create` with calling `createWebhook` method on `$webhookApi`.

* commit

* feat: Update Conekta payment module

- Updated hook registration for displayPaymentReturn
- Refactored code in hookDisplayPaymentReturn to simplify logic
- Added redirection_time parameter to checkout configuration
- Updated PHP version requirement to 7.4 or greater
- Improved error handling and response messages in notification controller
- Fixed typo in mail templates file header comment
- Renamed method insertOxxoPayment to insertCashPayment in Database class
- Updated version number in file headers

* Update Conekta module version to 3.0.0 and add Prestashop and plugin versions to metadata

- Update Conekta module version from 2.3.7 to 3.0.0
- Add 'plugin_version' and 'prestashop_version' fields to metadata in the checkout request

* AI-73 add if validation for conekta plugin

* AI-73 add if validation for conekta plugin

* Update conekta/conekta-php dependency to "dev-update-lib"

- Updated the version of conekta/conekta-php in composer.json
- Updated the autoload.php file with the new class name
- Updated the autoload_real.php file with the new class name
- Updated the autoload_static.php file with the new class name
- Updated installed.json and installed.php files with the new version and reference

This commit updates the dependency on conekta/conekta-php to use a development branch named "dev-update-lib".

* AI-73 add version 3.0 for prestashop 8.0

* AI-73 add text in readme

* AI-73 add text in readme

* AI-73 add text in readme

* AI-73 add text in readme

---------

Co-authored-by: Franklin <[email protected]>
  • Loading branch information
jalozanot-conekta and fcarrero authored Oct 28, 2024
1 parent 5c5b589 commit d74abc9
Show file tree
Hide file tree
Showing 51 changed files with 1,203 additions and 4,660 deletions.
27 changes: 27 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile
{
"name": "Existing Dockerfile",
"build": {
// Sets the run context to one level up instead of the .devcontainer folder.
"context": "..",
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerfile": "../Dockerfile"
}

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": "cat /etc/os-release",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "devcontainer"

}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/composer.lock
/.php-cs-fixer.cache
.DS_Store
.DS_Store
.idea
/vendor
/node_modules
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,4 @@
- Sandbox testing capability.
- Client side validation for credit cards.
- All card data is sent directly to Conekta's servers so you don't have to be PCI compliant.
- compatibility with prestashop 1.7.6.0
- compatibility with prestashop 8.0
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM php:7.4-cli-alpine



COPY --from=composer:2.5.1 /usr/bin/composer /usr/bin/composer

RUN composer global require phpunit/phpunit ~9
54 changes: 14 additions & 40 deletions HelperGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* @category Conekta
*
* @version GIT: @2.3.8@
* @version GIT: @3.0.0@
*
* @see https://conekta.com/
*/
Expand All @@ -35,25 +35,22 @@ class HelperGateway
/**
* Add tax lines
*
* @param array $taxlines Tax of the Order
* @param array|null $taxlines Tax of the Order
*
* @return array
*/
public static function addTaxLines($taxlines = null)
public static function addTaxLines(array $taxlines = null): array
{
$tax_lines = [
'tax_lines' => [],
];

if (isset($taxlines)) {
foreach ($taxlines as $tax) {
array_push(
$tax_lines['tax_lines'],
[
'description' => HelperGateway::removeSpecialCharacter($tax['description']),
'amount' => $tax['amount'],
]
);
$tax_lines['tax_lines'][] = [
'description' => HelperGateway::removeSpecialCharacter($tax['description']),
'amount' => $tax['amount'],
];
}
}

Expand All @@ -67,23 +64,20 @@ public static function addTaxLines($taxlines = null)
*
* @return array
*/
public static function addShippingLines($shippingLines = null)
public static function addShippingLines($shippingLines = null): array
{
$shippingLinesArray = [
'shipping_lines' => [],
];

if (isset($shippingLines)) {
foreach ($shippingLines as $shipping) {
array_push(
$shippingLinesArray['shipping_lines'],
[
'amount' => $shipping['amount'],
'tracking_number' => HelperGateway::removeSpecialCharacter($shipping['tracking_number']),
'carrier' => HelperGateway::removeSpecialCharacter($shipping['carrier']),
'method' => HelperGateway::removeSpecialCharacter($shipping['method']),
]
);
$shippingLinesArray['shipping_lines'][] = [
'amount' => $shipping['amount'],
'tracking_number' => HelperGateway::removeSpecialCharacter($shipping['tracking_number']),
'carrier' => HelperGateway::removeSpecialCharacter($shipping['carrier']),
'method' => HelperGateway::removeSpecialCharacter($shipping['method']),
];
}
}

Expand Down Expand Up @@ -164,26 +158,6 @@ public static function validateItems($items)
return true;
}

/**
* Validates the plan and order amounts match
*
* @param array $items items in the order
* @param int $amount of the order
*
* @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;
}

/**
* Validate if items are unsubscribed
*
Expand Down
29 changes: 25 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Comando principal
zip:
zip -r conekta-prestashop ./ -x '*.git*' -x '*.idea*' -x '*.github*' -x 'node_modules*'
# Define variables
ZIP_NAME = conekta.zip
FOLDER_NAME = conekta
EXCLUDES = "*.git*" "*.idea*" "composer.lock" ".gitignore" ".DS_Store" "conekta"

# Target por defecto
all: zip

# Crea el archivo ZIP
zip: $(FOLDER_NAME)
zip -r $(ZIP_NAME) $(FOLDER_NAME) -x $(EXCLUDES) && rm -rf $(FOLDER_NAME)

# Crea la carpeta conekta y mueve los archivos
$(FOLDER_NAME):
mkdir -p $@
cp -r ./* $@ # Copia todos los archivos al directorio conekta
rm -rf $@/.git # Elimina la carpeta .git si existe
rm -rf $@/.idea # Elimina la carpeta .idea si existe
rm -f $@/composer.lock # Elimina el archivo composer.lock si existe
rm -f $@/.gitignore # Elimina el archivo .gitignore si existe
rm -f $@/.DS_Store # Elimina el archivo .DS_Store si existe

# Clean para eliminar el ZIP y la carpeta temporal
clean:
rm -rf $(ZIP_NAME) $(FOLDER_NAME)

.PHONY: zip
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
Prestashop [1.7.8.x] Plugin v2.3.8
Prestashop Compatibility
=======================
This plugin is an official and stable version of the Conekta Prestashop extension. It bundles functionality to process credit cards, SPEI, Banorte and OXXO payments securely as well as send email notifications to your customers when they complete a successful purchase.
Prestashop [8.x.x] - Plugin v3.0.0
If you're using Prestashop version 8.x.x, you should install Conekta Plugin version 3.0.0.

Don't worry about managing the status of your orders, the plugin will automatically changes orders to paid as long as your webhooks are properly configured.
Prestashop [7.x.x] - Plugin v2.x.x
If you're using Prestashop version 7.x.x, you should install Conekta Plugin version 2.x.x.

This plugin is an official and stable version of the Conekta Prestashop extension. It bundles functionality to process credit cards, SPEI and Conekta efectivo payments securely as well as send email notifications to your customers when they complete a successful purchase.

Don't worry about managing the status of your orders, the plugin will automatically change orders to pay as long as your webhooks are properly configured.

Features
--------
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
}
],
"require": {
"php": ">=7.1"
"php": ">=7.4",
"conekta/conekta-php": "6.0.9"
},
"config": {
"preferred-install": "dist",
"prepend-autoloader": false
},
"type": "prestashop-module",
"version": "2.3.8",
"version": "3.0.0",
"autoload": {
"psr-4": {"Conekta\\Payments\\": "src/"}
}
Expand Down
Loading

0 comments on commit d74abc9

Please sign in to comment.