-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blik payment method added #172
Merged
gentiprenaj
merged 2 commits into
develop
from
BP-3602-Add-payment-method-Blik-PrestaShop
Jul 8, 2024
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,29 @@ | ||
<?php | ||
/** | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Academic Free License (AFL 3.0) | ||
* It is available through the world-wide-web at this URL: | ||
* http://opensource.org/licenses/afl-3.0.php | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade this file | ||
* | ||
* @author Buckaroo.nl <[email protected]> | ||
* @copyright Copyright (c) Buckaroo B.V. | ||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) | ||
*/ | ||
if (!defined('_PS_VERSION_')) { | ||
exit; | ||
} | ||
|
||
require_once dirname(__FILE__) . '/../paymentmethod.php'; | ||
class Blik extends PaymentMethod | ||
{ | ||
public function __construct() | ||
{ | ||
$this->type = 'blik'; | ||
$this->version = 1; | ||
} | ||
} |
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,25 @@ | ||
<?php | ||
/** | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Academic Free License (AFL 3.0) | ||
* It is available through the world-wide-web at this URL: | ||
* http://opensource.org/licenses/afl-3.0.php | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade this file | ||
* | ||
* @author Buckaroo.nl <[email protected]> | ||
* @copyright Copyright (c) Buckaroo B.V. | ||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) | ||
*/ | ||
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; |
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
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
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
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
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
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,51 @@ | ||
<?php | ||
/** | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Academic Free License (AFL 3.0) | ||
* It is available through the world-wide-web at this URL: | ||
* http://opensource.org/licenses/afl-3.0.php | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade this file | ||
* | ||
* @author Buckaroo.nl <[email protected]> | ||
* @copyright Copyright (c) Buckaroo B.V. | ||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) | ||
*/ | ||
include_once _PS_MODULE_DIR_ . 'buckaroo3/library/checkout/checkout.php'; | ||
|
||
if (!defined('_PS_VERSION_')) { | ||
exit; | ||
} | ||
|
||
class BlikCheckout extends Checkout | ||
{ | ||
protected $customVars = []; | ||
|
||
final public function setCheckout() | ||
{ | ||
parent::setCheckout(); | ||
} | ||
|
||
public function startPayment() | ||
{ | ||
$this->payment_response = $this->payment_request->pay($this->customVars); | ||
} | ||
|
||
public function isRedirectRequired() | ||
{ | ||
return true; | ||
} | ||
|
||
public function isVerifyRequired() | ||
{ | ||
return false; | ||
} | ||
|
||
protected function initialize() | ||
{ | ||
$this->payment_request = PaymentRequestFactory::create(PaymentRequestFactory::REQUEST_TYPE_BLIK); | ||
} | ||
} |
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
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,46 @@ | ||
<?php | ||
/** | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Academic Free License (AFL 3.0) | ||
* It is available through the world-wide-web at this URL: | ||
* http://opensource.org/licenses/afl-3.0.php | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade this file | ||
* | ||
* @author Buckaroo.nl <[email protected]> | ||
* @copyright Copyright (c) Buckaroo B.V. | ||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) | ||
*/ | ||
|
||
use Buckaroo\PrestaShop\Src\Config\Config; | ||
|
||
if (!defined('_PS_VERSION_')) { | ||
exit; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
* @throws Exception | ||
*/ | ||
function upgrade_module_4_4_0($object) | ||
{ | ||
$blikData = [ | ||
'name' => 'blik', | ||
'label' => 'Blik', | ||
'icon' => 'Blik.svg', | ||
'template' => '', | ||
'is_payment_method' => '1', | ||
]; | ||
|
||
$keys = array_keys($blikData); | ||
$values = array_map(function ($value) { | ||
return pSQL($value); | ||
}, array_values($blikData)); | ||
|
||
$insertQuery = 'INSERT INTO ' . _DB_PREFIX_ . 'bk_payment_methods (' . implode(', ', $keys) . ') VALUES ("' . implode('", "', $values) . '")'; | ||
Db::getInstance()->execute($insertQuery); | ||
return true; | ||
} |
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,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Buckaroo\PaymentMethods\Blik; | ||
|
||
use Buckaroo\Models\Model; | ||
use Buckaroo\PaymentMethods\Blik\Models\Refund; | ||
use Buckaroo\PaymentMethods\Blik\Models\Pay; | ||
use Buckaroo\PaymentMethods\Interfaces\Combinable; | ||
use Buckaroo\PaymentMethods\PayablePaymentMethod; | ||
use Buckaroo\Transaction\Response\TransactionResponse; | ||
|
||
/** | ||
* | ||
*/ | ||
class Blik extends PayablePaymentMethod implements Combinable | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected string $paymentName = 'blik'; | ||
/** | ||
* @var int | ||
*/ | ||
protected int $serviceVersion = 0; | ||
|
||
/** | ||
* @param Model|null $model | ||
* @return TransactionResponse | ||
*/ | ||
public function pay(?Model $model = null): TransactionResponse | ||
{ | ||
return parent::pay($model ?? new Pay($this->payload)); | ||
} | ||
|
||
// /** | ||
// * @param Model|null $model | ||
// * @return TransactionResponse | ||
// */ | ||
// public function refund(?Model $model = null): TransactionResponse | ||
// { | ||
// return parent::refund($model ?? new Refund($this->payload)); | ||
// } | ||
// | ||
|
||
|
||
} |
28 changes: 28 additions & 0 deletions
28
vendor/buckaroo/sdk/src/PaymentMethods/Blik/Models/Pay.php
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,28 @@ | ||
<?php | ||
/* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the MIT License | ||
* It is available through the world-wide-web at this URL: | ||
* https://tldrlegal.com/license/mit-license | ||
* If you are unable to obtain it through the world-wide-web, please send an email | ||
* to [email protected] so we can send you a copy immediately. | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade this module to newer | ||
* versions in the future. If you wish to customize this module for your | ||
* needs please contact [email protected] for more information. | ||
* | ||
* @copyright Copyright (c) Buckaroo B.V. | ||
* @license https://tldrlegal.com/license/mit-license | ||
*/ | ||
|
||
namespace Buckaroo\PaymentMethods\Blik\Models; | ||
|
||
use Buckaroo\Models\ServiceParameter; | ||
|
||
class Pay extends ServiceParameter | ||
{ | ||
protected bool $saveToken; | ||
} |
58 changes: 58 additions & 0 deletions
58
vendor/buckaroo/sdk/src/PaymentMethods/Blik/Models/Refund.php
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,58 @@ | ||
<?php | ||
|
||
namespace Buckaroo\PaymentMethods\Blik\Models; | ||
|
||
use Buckaroo\Models\ServiceParameter; | ||
use Buckaroo\PaymentMethods\Afterpay\Service\ParameterKeys\ArticleAdapter; | ||
use Buckaroo\PaymentMethods\Traits\CountableGroupKey; | ||
|
||
class Refund extends ServiceParameter | ||
{ | ||
use CountableGroupKey; | ||
|
||
/** | ||
* @var array|string[] | ||
*/ | ||
private array $countableProperties = ['articles']; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected string $merchantImageUrl; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected string $summaryImageUrl; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected array $articles = []; | ||
|
||
/** | ||
* @var array|\string[][] | ||
*/ | ||
protected array $groupData = [ | ||
'articles' => [ | ||
'groupType' => 'Article', | ||
], | ||
]; | ||
|
||
/** | ||
* @param array|null $articles | ||
* @return array | ||
*/ | ||
public function articles(?array $articles = null) | ||
{ | ||
if (is_array($articles)) | ||
{ | ||
foreach ($articles as $article) | ||
{ | ||
$this->articles[] = new ArticleAdapter(new Article($article)); | ||
} | ||
} | ||
|
||
return $this->articles; | ||
} | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you also need to create a upgrade file to insert blik payment method when merchant has the plugin already installed