Skip to content

Commit 06d0857

Browse files
committed
Added upgrade script for Google Pay funding source creation
1 parent e949287 commit 06d0857

File tree

2 files changed

+72
-2
lines changed

2 files changed

+72
-2
lines changed

ps_checkout.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class Ps_checkout extends PaymentModule
113113

114114
// Needed in order to retrieve the module version easier (in api call headers) than instanciate
115115
// the module each time to get the version
116-
const VERSION = '8.4.0.1';
116+
const VERSION = '8.4.1.0';
117117

118118
const INTEGRATION_DATE = '2024-04-01';
119119

@@ -134,7 +134,7 @@ public function __construct()
134134

135135
// We cannot use the const VERSION because the const is not computed by addons marketplace
136136
// when the zip is uploaded
137-
$this->version = '8.4.0.1';
137+
$this->version = '8.4.1.0';
138138
$this->author = 'PrestaShop';
139139
$this->currencies = true;
140140
$this->currencies_mode = 'checkbox';

upgrade/upgrade-8.4.1.0.php

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
/**
3+
* Copyright since 2007 PrestaShop SA and Contributors
4+
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
5+
*
6+
* NOTICE OF LICENSE
7+
*
8+
* This source file is subject to the Academic Free License version 3.0
9+
* that is bundled with this package in the file LICENSE.md.
10+
* It is also available through the world-wide-web at this URL:
11+
* https://opensource.org/licenses/AFL-3.0
12+
* If you did not receive a copy of the license and are unable to
13+
* obtain it through the world-wide-web, please send an email
14+
* to [email protected] so we can send you a copy immediately.
15+
*
16+
* @author PrestaShop SA and Contributors <[email protected]>
17+
* @copyright Since 2007 PrestaShop SA and Contributors
18+
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
19+
*/
20+
if (!defined('_PS_VERSION_')) {
21+
exit;
22+
}
23+
24+
/**
25+
* Update main function for module version 8.4.1.0
26+
*
27+
* @param Ps_checkout $module
28+
*
29+
* @return bool
30+
*/
31+
function upgrade_module_8_4_1_0($module)
32+
{
33+
try {
34+
$db = Db::getInstance();
35+
$shopsList = \Shop::getShops(false, null, true);
36+
37+
foreach ($shopsList as $shopId) {
38+
$isGooglePayEligible = (bool) \Configuration::get(
39+
'PS_CHECKOUT_GOOGLE_PAY',
40+
null,
41+
null,
42+
$shopId
43+
);
44+
$hasFundingSourceGooglePay = (bool) $db->getValue('
45+
SELECT 1
46+
FROM `' . _DB_PREFIX_ . 'pscheckout_funding_source`
47+
WHERE `name` = "google_pay"
48+
AND `id_shop` = ' . (int) $shopId
49+
);
50+
51+
if (!$hasFundingSourceGooglePay) {
52+
$db->insert(
53+
'pscheckout_funding_source',
54+
[
55+
'name' => 'google_pay',
56+
'position' => 11,
57+
'active' => (int) $isGooglePayEligible,
58+
'id_shop' => (int) $shopId,
59+
]
60+
);
61+
}
62+
}
63+
} catch (Exception $exception) {
64+
PrestaShopLogger::addLog($exception->getMessage(), 4, 1, 'Module', $module->id);
65+
66+
return false;
67+
}
68+
69+
return true;
70+
}

0 commit comments

Comments
 (0)