diff --git a/api/paymentmethods/blik/blik.php b/api/paymentmethods/blik/blik.php new file mode 100644 index 00000000..0562ea26 --- /dev/null +++ b/api/paymentmethods/blik/blik.php @@ -0,0 +1,29 @@ + + * @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; + } +} diff --git a/api/paymentmethods/blik/index.php b/api/paymentmethods/blik/index.php new file mode 100644 index 00000000..97ec565f --- /dev/null +++ b/api/paymentmethods/blik/index.php @@ -0,0 +1,25 @@ + + * @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; diff --git a/api/paymentmethods/paymentrequestfactory.php b/api/paymentmethods/paymentrequestfactory.php index cb12cda2..3c83f999 100644 --- a/api/paymentmethods/paymentrequestfactory.php +++ b/api/paymentmethods/paymentrequestfactory.php @@ -28,6 +28,7 @@ class PaymentRequestFactory public const REQUEST_TYPE_KBCPAYMENTBUTTON = 'kbcpaymentbutton'; public const REQUEST_TYPE_SEPADIRECTDEBIT = 'sepadirectdebit'; public const REQUEST_TYPE_BANCONTACTMRCASH = 'bancontactmrcash'; + public const REQUEST_TYPE_BLIK = 'blik'; public const REQUEST_TYPE_SOFORTBANKING = 'sofortueberweisung'; public const REQUEST_TYPE_GIFTCARD = 'giftcard'; public const REQUEST_TYPE_CREDITCARD = 'creditcard'; @@ -60,6 +61,7 @@ class PaymentRequestFactory PaymentRequestFactory::REQUEST_TYPE_GIROPAY => 'Giropay', PaymentRequestFactory::REQUEST_TYPE_KBCPAYMENTBUTTON => 'Kbcpaymentbutton', PaymentRequestFactory::REQUEST_TYPE_BANCONTACTMRCASH => 'Bancontactmrcash', + PaymentRequestFactory::REQUEST_TYPE_BLIK => 'Blik', PaymentRequestFactory::REQUEST_TYPE_SOFORTBANKING => 'Sofortbanking', PaymentRequestFactory::REQUEST_TYPE_GIFTCARD => 'GiftCard', PaymentRequestFactory::REQUEST_TYPE_CREDITCARD => 'CreditCard', diff --git a/dev/lang/php_de.json b/dev/lang/php_de.json index 3c609ab9..f9670367 100644 --- a/dev/lang/php_de.json +++ b/dev/lang/php_de.json @@ -182,6 +182,7 @@ "payment_methods.bancontactmrcash": "Bancontact", "payment_methods.belfius": "Belfius", "payment_methods.billink": "Billink", + "payment_methods.blik": "Blik", "payment_methods.creditcard": "Karten", "payment_methods.eps": "EPS", "payment_methods.giftcard": "Geschenkkarte", diff --git a/dev/lang/php_en.json b/dev/lang/php_en.json index 01bc73ea..62fde675 100644 --- a/dev/lang/php_en.json +++ b/dev/lang/php_en.json @@ -183,6 +183,7 @@ "payment_methods.bancontactmrcash": "Bancontact", "payment_methods.belfius": "Belfius", "payment_methods.billink": "Billink", + "payment_methods.blik": "Blik", "payment_methods.creditcard": "Cards", "payment_methods.eps": "EPS", "payment_methods.giftcard": "Giftcard", diff --git a/dev/lang/php_fr.json b/dev/lang/php_fr.json index b0c6bb54..4b16d128 100644 --- a/dev/lang/php_fr.json +++ b/dev/lang/php_fr.json @@ -182,6 +182,7 @@ "payment_methods.bancontactmrcash": "Bancontact", "payment_methods.belfius": "Belfius", "payment_methods.billink": "Lien de facturation", + "payment_methods.blik": "Blik", "payment_methods.creditcard": "Cartes", "payment_methods.eps": "PSE", "payment_methods.giftcard": "Carte cadeau", diff --git a/dev/lang/php_nl.json b/dev/lang/php_nl.json index 88fd4ef4..5cc31827 100644 --- a/dev/lang/php_nl.json +++ b/dev/lang/php_nl.json @@ -178,6 +178,7 @@ "payment_methods.bancontactmrcash": "Bancontact", "payment_methods.belfius": "Belfius", "payment_methods.billink": "Billink", + "payment_methods.blik": "Blik", "payment_methods.creditcard": "Cards", "payment_methods.eps": "EPS", "payment_methods.giftcard": "Giftcard", diff --git a/library/checkout/BlikCheckout.php b/library/checkout/BlikCheckout.php new file mode 100644 index 00000000..7df6e557 --- /dev/null +++ b/library/checkout/BlikCheckout.php @@ -0,0 +1,51 @@ + + * @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); + } +} diff --git a/src/Repository/RawPaymentMethodRepository.php b/src/Repository/RawPaymentMethodRepository.php index 4a9a48d4..e4d47acc 100644 --- a/src/Repository/RawPaymentMethodRepository.php +++ b/src/Repository/RawPaymentMethodRepository.php @@ -128,6 +128,7 @@ private function getPaymentMethodsData() ['name' => 'giropay', 'label' => 'GiroPay', 'icon' => 'Giropay.svg', 'template' => '', 'is_payment_method' => '1'], ['name' => 'kbcpaymentbutton', 'label' => 'KBC', 'icon' => 'KBC.svg', 'template' => '', 'is_payment_method' => '1'], ['name' => 'bancontactmrcash', 'label' => 'Bancontact', 'icon' => 'Bancontact.svg', 'template' => '', 'is_payment_method' => '1'], + ['name' => 'blik', 'label' => 'Blik', 'icon' => 'Blik.svg', 'template' => '', 'is_payment_method' => '1'], ['name' => 'giftcard', 'label' => 'Giftcards', 'icon' => 'Giftcards.svg', 'template' => 'payment_giftcards.tpl', 'is_payment_method' => '1'], ['name' => 'creditcard', 'label' => 'Cards', 'icon' => 'Creditcards.svg', 'template' => 'payment_creditcard.tpl', 'is_payment_method' => '1'], ['name' => 'sofortueberweisung', 'label' => 'Sofortbanking', 'icon' => 'Sofort.svg', 'template' => '', 'is_payment_method' => '1'], diff --git a/upgrade/upgrade-4.4.0.php b/upgrade/upgrade-4.4.0.php new file mode 100644 index 00000000..75fb79b6 --- /dev/null +++ b/upgrade/upgrade-4.4.0.php @@ -0,0 +1,46 @@ + + * @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; +} diff --git a/vendor/buckaroo/sdk/src/PaymentMethods/Blik/Blik.php b/vendor/buckaroo/sdk/src/PaymentMethods/Blik/Blik.php new file mode 100644 index 00000000..5c02d2ff --- /dev/null +++ b/vendor/buckaroo/sdk/src/PaymentMethods/Blik/Blik.php @@ -0,0 +1,48 @@ +payload)); + } + +// /** +// * @param Model|null $model +// * @return TransactionResponse +// */ +// public function refund(?Model $model = null): TransactionResponse +// { +// return parent::refund($model ?? new Refund($this->payload)); +// } +// + + +} diff --git a/vendor/buckaroo/sdk/src/PaymentMethods/Blik/Models/Pay.php b/vendor/buckaroo/sdk/src/PaymentMethods/Blik/Models/Pay.php new file mode 100644 index 00000000..a69ad864 --- /dev/null +++ b/vendor/buckaroo/sdk/src/PaymentMethods/Blik/Models/Pay.php @@ -0,0 +1,28 @@ + [ + '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; + } +} diff --git a/vendor/buckaroo/sdk/src/PaymentMethods/PaymentMethodFactory.php b/vendor/buckaroo/sdk/src/PaymentMethods/PaymentMethodFactory.php index 2840b750..f8a0b33c 100644 --- a/vendor/buckaroo/sdk/src/PaymentMethods/PaymentMethodFactory.php +++ b/vendor/buckaroo/sdk/src/PaymentMethods/PaymentMethodFactory.php @@ -51,6 +51,7 @@ use Buckaroo\PaymentMethods\KlarnaPay\KlarnaPay; use Buckaroo\PaymentMethods\WeChatPay\WeChatPay; use Buckaroo\PaymentMethods\Bancontact\Bancontact; +use Buckaroo\PaymentMethods\Blik\Blik; use Buckaroo\PaymentMethods\CreditCard\CreditCard; use Buckaroo\PaymentMethods\Multibanco\Multibanco; use Buckaroo\PaymentMethods\Przelewy24\Przelewy24; @@ -82,6 +83,7 @@ class PaymentMethodFactory Billink::class => ['billink'], Belfius::class => ['belfius'], BuckarooWallet::class => ['buckaroo_wallet'], + Blik::class => ['blik'], CreditCard::class => [ 'creditcard', 'mastercard', 'visa', diff --git a/views/img/buckaroo/Payment methods/SVG/Blik.svg b/views/img/buckaroo/Payment methods/SVG/Blik.svg new file mode 100644 index 00000000..96f194fd --- /dev/null +++ b/views/img/buckaroo/Payment methods/SVG/Blik.svg @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + +