Skip to content

Commit

Permalink
Merge pull request #11 from appinlet/release/1.8.3
Browse files Browse the repository at this point in the history
2024-01-04: v1.8.3
  • Loading branch information
appinlet committed Jan 4, 2024
2 parents ba1713c + e2d75dc commit 2968372
Show file tree
Hide file tree
Showing 18 changed files with 696 additions and 93 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# PayWeb_PrestaShop
## Paygate PrestaShop plugin v1.8.2 for PrestaShop v8.1.2
## Paygate PrestaShop plugin v1.8.3 for PrestaShop v8.1.3

This is the Paygate PayWeb3 plugin for PrestaShop. Please feel free to contact the Payfast support team at support@payfast.help should you require any assistance.

## Installation
Please navigate to the [releases page](https://github.com/PayGate/PayWeb_PrestaShop/releases), download the latest release (v1.8.2) and unzip. You will then be able to follow the integration guide PDF which is included in the zip.
Please navigate to the [releases page](https://github.com/PayGate/PayWeb_PrestaShop/releases), download the latest release (v1.8.3) and unzip. You will then be able to follow the integration guide PDF which is included in the zip.

## Collaboration

Expand Down
9 changes: 9 additions & 0 deletions paygate/assets/images/apple-pay.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions paygate/assets/images/rcs.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions paygate/assets/images/samsung-pay.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions paygate/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Date : Version: Description
=====================================

2024-01-04: v1.8.3 : Update for PHP 8.1 and Prestashop 8.1.3.
Add PayVault feature.
Add Apple Pay, Samsung Pay and RCS payment types.

2023-11-15: v1.8.2 : Update for PHP 8.0.
Test on Prestashop 8.1.2.

Expand Down
95 changes: 95 additions & 0 deletions paygate/classes/PayVault.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?php
/*
* Copyright (c) 2024 Payfast (Pty) Ltd
*
* Author: App Inlet (Pty) Ltd
*
* Released under the GNU General Public License
*/

class PayVault
{
/**
* @param int $customerId
* @param array $result
*
* @return void
* @throws \PrestaShopDatabaseException
*/
public static function storeVault(int $customerId, array $result): void
{
PrestaShopLogger::addLog('In storeVault: ' . $customerId);
if ((int)Configuration::get('PAYGATE_PAY_VAULT') === 1 && !empty($result['VAULT_ID'])) {
$dbPrefix = _DB_PREFIX_;
$existing = Db::getInstance()->getValue(
"SELECT id_vault FROM `{$dbPrefix}paygate_vaults` WHERE vault_id='{$result['VAULT_ID']}'"
);

$firstSix = substr($result['PAYVAULT_DATA_1'], 0, 6);
$lastFour = substr($result['PAYVAULT_DATA_1'], -4, 4);

if (!$existing) {
Db::getInstance()->insert(
'paygate_vaults',
[
'id_customer' => $customerId,
'vault_id' => $result['VAULT_ID'],
'first_six' => $firstSix,
'last_four' => $lastFour,
'expiry' => $result['PAYVAULT_DATA_2'],
]
);
} else {
Db::getInstance()->update(
'paygate_vaults',
[
'id_customer' => $customerId,
'first_six' => $firstSix,
'last_four' => $lastFour,
'expiry' => $result['PAYVAULT_DATA_2'],
],
"vault_id = '$result[VAULT_ID]'"
);
}
}
}

/**
* @param int $customerId
*
* @return array
* @throws \PrestaShopDatabaseException
*/
public static function customerVaults(int $customerId): array
{
$dbPrefix = _DB_PREFIX_;
$db = Db::getInstance();
$query = $db->query(
"SELECT * FROM `{$dbPrefix}paygate_vaults` WHERE id_customer='$customerId'"
);
$vaults = [];
while ($row = $db->nextRow($query)) {
$vaults[] = $row;
}

return $vaults;
}

/**
* @param int $customerId
* @param string $idVault
*
* @return bool|string
*/
public static function customerVault(int $customerId, string $idVault): bool|string
{
$dbPrefix = _DB_PREFIX_;
$db = Db::getInstance();
$vault = $db->getValue(
"select vault_id from `{$dbPrefix}paygate_vaults` where id_vault='$idVault'
and id_customer='$customerId'"
) ?? '';

return $vault;
}
}
2 changes: 1 addition & 1 deletion paygate/classes/countries.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* Copyright (c) 2023 Payfast (Pty) Ltd
* Copyright (c) 2024 Payfast (Pty) Ltd
*
* Author: App Inlet (Pty) Ltd
*
Expand Down
28 changes: 26 additions & 2 deletions paygate/classes/methods.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* Copyright (c) 2023 Payfast (Pty) Ltd
* Copyright (c) 2024 Payfast (Pty) Ltd
*
* Author: App Inlet (Pty) Ltd
*
Expand All @@ -19,7 +19,7 @@ public function getPaygateMethodsList()
'label' => 'Card',
'img' => '../modules/paygate/assets/images/mastercard-visa.svg',
'ptype' => 'CC',
'ptypedetail' => 'Card',
'ptypedetail' => 'Credit Card',
'type' => 'radio',
'value' => 'creditcard',
'title' => 'Card',
Expand Down Expand Up @@ -81,6 +81,30 @@ public function getPaygateMethodsList()
'ptypedetail' => 'MasterPass',
'type' => 'radio',
],
'applepay' => [
'name' => 'paygate-paymethod',
'label' => 'ApplePay',
'img' => '../modules/paygate/assets/images/apple-pay.svg',
'ptype' => 'CC',
'ptypedetail' => 'Applepay',
'type' => 'radio',
],
'rcs' => [
'name' => 'paygate-paymethod',
'label' => 'RCS',
'img' => '../modules/paygate/assets/images/rcs.svg',
'ptype' => 'EW',
'ptypedetail' => 'RCS',
'type' => 'radio',
],
'samsungpay' => [
'name' => 'paygate-paymethod',
'label' => 'SamsungPay',
'img' => '../modules/paygate/assets/images/samsung-pay.svg',
'ptype' => 'EW',
'ptypedetail' => 'Samsungpay',
'type' => 'radio',
],
];
}

Expand Down
4 changes: 2 additions & 2 deletions paygate/config.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
/*
* Copyright (c) 2023 Payfast (Pty) Ltd
* Copyright (c) 2024 Payfast (Pty) Ltd
*
* Author: App Inlet (Pty) Ltd
*
Expand All @@ -11,7 +11,7 @@
<module>
<name>paygate</name>
<displayName><![CDATA[Paygate]]></displayName>
<version><![CDATA[1.8.2]]></version>
<version><![CDATA[1.8.3]]></version>
<description><![CDATA[Accept payments via Paygate.]]></description>
<author><![CDATA[Paygate]]></author>
<tab><![CDATA[payments_gateways]]></tab>
Expand Down
Loading

0 comments on commit 2968372

Please sign in to comment.