Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ivan Klimchuk
committed
Jul 19, 2021
1 parent
83e3dcc
commit 0f68858
Showing
3 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
/** | ||
* Copyright (c) Ivan Klimchuk - All Rights Reserved | ||
* Unauthorized copying, changing, distributing this file, via any medium, is strictly prohibited. | ||
* Written by Ivan Klimchuk <ivan@klimchuk.com>, 2021 | ||
*/ | ||
|
||
/** @var xPDOTransport $transport */ | ||
/** @var array $options */ | ||
|
||
if (!$transport->xpdo && !$transport->xpdo instanceof modX) { | ||
return true; | ||
} | ||
|
||
switch ($options[xPDOTransport::PACKAGE_ACTION]) { | ||
case xPDOTransport::ACTION_INSTALL: | ||
|
||
$transport->xpdo->newObject( | ||
msPayment::class, | ||
[ | ||
'name' => 'Klarna', | ||
'description' => null, | ||
'price' => 0, | ||
'rank' => 0, | ||
'active' => 1, | ||
'class' => KlarnaHandler::class, | ||
'properties' => null // todo: setup minimal default properties | ||
] | ||
)->save(); | ||
|
||
break; | ||
|
||
case xPDOTransport::ACTION_UNINSTALL: | ||
|
||
$transport->xpdo->removeObject(msPayment::class, ['class' => KlarnaHandler::class]); | ||
|
||
break; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
/** | ||
* Copyright (c) Ivan Klimchuk - All Rights Reserved | ||
* Unauthorized copying, changing, distributing this file, via any medium, is strictly prohibited. | ||
* Written by Ivan Klimchuk <ivan@klimchuk.com>, 2021 | ||
*/ | ||
|
||
declare(strict_types = 1); | ||
|
||
/** @var xPDOTransport $transport */ | ||
/** @var array $options */ | ||
|
||
if (!$transport->xpdo && !$transport->xpdo instanceof modX) { | ||
return true; | ||
} | ||
|
||
switch ($options[xPDOTransport::PACKAGE_ACTION]) { | ||
case xPDOTransport::ACTION_INSTALL: | ||
case xPDOTransport::ACTION_UPGRADE: | ||
|
||
/** @var miniShop2 $shop */ | ||
if ($shop = $transport->xpdo->getService('miniShop2')) { | ||
$shop->addService('payment', KlarnaHandler::class, '{core_path}components/mspklarna/KlarnaHandler.class.php'); | ||
} | ||
|
||
break; | ||
|
||
case xPDOTransport::ACTION_UNINSTALL: | ||
|
||
/** @var miniShop2 $shop */ | ||
if ($shop = $transport->xpdo->getService('miniShop2')) { | ||
$shop->removeService('payment', KlarnaHandler::class); | ||
} | ||
|
||
break; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
/** | ||
* Copyright (c) Ivan Klimchuk - All Rights Reserved | ||
* Unauthorized copying, changing, distributing this file, via any medium, is strictly prohibited. | ||
* Written by Ivan Klimchuk <ivan@klimchuk.com>, 2019 | ||
*/ | ||
|
||
declare(strict_types = 1); | ||
|
||
/** @var xPDOTransport $transport */ | ||
/** @var array $options */ | ||
|
||
if (!$transport->xpdo) { | ||
return false; | ||
} | ||
|
||
$extensions = [ | ||
'pdo' => 'PHP Data Objects', | ||
'curl' => 'Client URL Library', | ||
'simplexml' => 'SimpleXML', | ||
'json' => 'JavaScript Object Notation', | ||
'xmlwriter' => 'XMLWriter', | ||
'bcmath' => 'BCMath Arbitrary Precision Mathematics', | ||
'openssl' => 'OpenSSL' | ||
]; | ||
|
||
foreach ($extensions as $ext => $title) { | ||
if (!extension_loaded($ext)) { | ||
$msg = sprintf(' | ||
PHP extension `%s` (https://php.net/manual/en/book.%s.php) does not loaded. | ||
This PHP extension is required for a proper work of this package. | ||
Please, ask your sysadmin or hosting company to install and configure it before continue.', | ||
$title, $ext === 'bcmath' ? 'bc' : $ext | ||
); | ||
|
||
$transport->xpdo->log(modX::LOG_LEVEL_ERROR, $msg); | ||
|
||
return false; | ||
} | ||
} | ||
|
||
|
||
return true; |