Skip to content

Commit

Permalink
Merge pull request #1056 from buckaroo-it/develop
Browse files Browse the repository at this point in the history
BP-3754-Update-test-release-1.50.0
  • Loading branch information
vegimcarkaxhija authored Sep 17, 2024
2 parents 5401b46 + fd78c7b commit 0f588c5
Show file tree
Hide file tree
Showing 46 changed files with 1,741 additions and 529 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/icons.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Copy payment method icons
run: |
cd "${{ github.workspace }}/Media/Payment methods/SVG/"
rm -f ideal-qr.svg knaken.svg paylink.svg paybybank.svg pos-nfc.svg riverty.svg
rm -f ideal-qr.svg knaken.svg paylink.svg paybybank.svg pos-nfc.svg
cd ${{ github.workspace }}/Media
cp -R "Payment methods/SVG/." ${{ github.workspace }}/view/base/web/images/svg/
- name: Copy creditcards icons
Expand Down
5 changes: 3 additions & 2 deletions Api/PaypalExpressQuoteCreateInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
namespace Buckaroo\Magento2\Api;

use Buckaroo\Magento2\Api\Data\PaypalExpress\ShippingAddressRequestInterface;
use Buckaroo\Magento2\Api\Data\QuoteCreateResponseInterface;

interface PaypalExpressQuoteCreateInterface
{
Expand All @@ -31,8 +32,8 @@ interface PaypalExpressQuoteCreateInterface
* @param \Buckaroo\Magento2\Api\Data\PaypalExpress\ShippingAddressRequestInterface $shipping_address
* @param string $page
* @param string|null $order_data
* @return \Buckaroo\Magento2\Api\Data\PaypalExpress\QuoteCreateResponseInterface
*/
* @return QuoteCreateResponseInterface
*/
public function execute(
ShippingAddressRequestInterface $shipping_address,
string $page,
Expand Down
4 changes: 2 additions & 2 deletions Block/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ public function getPayPerEmailMethod()
public function getPaymentLogo(string $method): string
{
$mappings = [
"afterpay2" => "svg/afterpay.svg",
"afterpay20" => "svg/afterpay.svg",
"afterpay2" => "svg/riverty.svg",
"afterpay20" => "svg/riverty.svg",
"capayablein3" => "svg/in3.svg",
"capayablepostpay" => "svg/in3.svg",
"creditcard" => "svg/creditcards.svg",
Expand Down
3 changes: 2 additions & 1 deletion Block/Widget/Button/Toolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ class Toolbar
'buckaroo_magento2_wechatpay',
'buckaroo_magento2_p24',
'buckaroo_magento2_trustly',
'buckaroo_magento2_pospayment'
'buckaroo_magento2_pospayment',
'buckaroo_magento2_blik',
];

/**
Expand Down
45 changes: 20 additions & 25 deletions Controller/Redirect/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Buckaroo\Magento2\Logging\Log;
use Buckaroo\Magento2\Model\Config\Source\InvoiceHandlingOptions;
use Magento\Framework\App\Request\Http as Http;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Sales\Api\Data\TransactionInterface;
use Magento\Sales\Api\Data\OrderPaymentInterface;
use Buckaroo\Magento2\Model\Method\AbstractMethod;
Expand Down Expand Up @@ -466,6 +467,10 @@ protected function setPaymentOutOfTransit(OrderPaymentInterface $payment)
->setAdditionalInformation(AbstractMethod::BUCKAROO_PAYMENT_IN_TRANSIT, false)
->save();
}

/**
* @throws NoSuchEntityException
*/
protected function handleFailed($statusCode)
{
$this->logger->addDebug(__METHOD__ . '|7|');
Expand All @@ -476,7 +481,7 @@ protected function handleFailed($statusCode)
$this->removeAmastyGiftcardOnFailed();

if (!$this->getSkipHandleFailedRecreate()) {
if (!$this->quoteRecreate->recreate($this->quote)) {
if (!$this->quoteRecreate->recreate($this->quote, $this->response)) {
$this->logging->addError('Could not recreate the quote.');
}
}
Expand All @@ -489,35 +494,25 @@ protected function handleFailed($statusCode)
*/

// StatusCode specified error messages
$statusCodeAddErrorMessage = [];
$statusCodeAddErrorMessage[$this->helper->getStatusCode('BUCKAROO_MAGENTO2_ORDER_FAILED')] =
'Unfortunately an error occurred while processing your payment. Please try again. If this' .
' error persists, please choose a different payment method.';
$statusCodeAddErrorMessage[$this->helper->getStatusCode('BUCKAROO_MAGENTO2_STATUSCODE_FAILED')] =
'Unfortunately an error occurred while processing your payment. Please try again. If this' .
' error persists, please choose a different payment method.';
$statusCodeAddErrorMessage[$this->helper->getStatusCode('BUCKAROO_MAGENTO2_STATUSCODE_REJECTED')] =
'Unfortunately an error occurred while processing your payment. Please try again. If this' .
' error persists, please choose a different payment method.';
$statusCodeAddErrorMessage[
$this->helper->getStatusCode('BUCKAROO_MAGENTO2_STATUSCODE_CANCELLED_BY_USER')
] = 'According to our system, you have canceled the payment. If this' .
' is not the case, please contact us.';

$this->addErrorMessage(
__(
$statusCodeAddErrorMessage[$statusCode]
)
);

//skip cancel order for PPE
$statusCodeAddErrorMessage = [
$this->helper->getStatusCode('BUCKAROO_MAGENTO2_ORDER_FAILED') => 'Unfortunately an error occurred while processing your payment. Please try again. If this error persists, please choose a different payment method.',
$this->helper->getStatusCode('BUCKAROO_MAGENTO2_STATUSCODE_FAILED') => 'Unfortunately an error occurred while processing your payment. Please try again. If this error persists, please choose a different payment method.',
$this->helper->getStatusCode('BUCKAROO_MAGENTO2_STATUSCODE_REJECTED') => 'Unfortunately an error occurred while processing your payment. Please try again. If this error persists, please choose a different payment method.',
$this->helper->getStatusCode('BUCKAROO_MAGENTO2_STATUSCODE_CANCELLED_BY_USER') => 'According to our system, you have canceled the payment. If this is not the case, please contact us.'
];

$this->addErrorMessage(__($statusCodeAddErrorMessage[$statusCode] ?? 'An error occurred while processing your payment.'));

// Skip cancel order for PPE
if (isset($this->response['add_frompayperemail'])) {
return $this->redirectFailure();
}

// Cancel the order and log an error if it fails
if (!$this->cancelOrder($statusCode)) {
$this->logger->addError('Could not cancel the order.');
}

$this->logger->addDebug(__METHOD__ . '|8|');
return $this->redirectFailure();
}
Expand Down Expand Up @@ -778,7 +773,7 @@ public function setSkipHandleFailedRecreate($value)

/**
* Remove coupon from failed order if magento enterprise
*
*
* @return void
*/
protected function removeCoupon()
Expand All @@ -789,7 +784,7 @@ protected function removeCoupon()
if (!(is_object($couponFactory) && method_exists($couponFactory, 'load'))) {
return;
}

$coupon = $couponFactory->load($couponCode, 'code');
$resourceModel = $this->_objectManager->get(\Magento\SalesRule\Model\Spi\CouponResourceInterface::class);
if (!(is_object($resourceModel) && method_exists($resourceModel, 'delete'))) {
Expand Down
1 change: 1 addition & 0 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ public function getPaymentMethodsList()
['value' => 'transfer', 'label' => __('Bank Transfer')],
['value' => 'trustly', 'label' => __('Trustly')],
['value' => 'wechatpay', 'label' => __('WeChatPay')],
['value' => 'blik', 'label' => __('Blik')],
];
}

Expand Down
1 change: 1 addition & 0 deletions Model/Config/Source/PaymentMethods/AfterExpiry.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function toOptionArray()
['value' => 'wechatpay', 'label' => __('WeChatPay')],
['value' => 'p24', 'label' => __('P24')],
['value' => 'trustly', 'label' => __('Trustly')],
['value' => 'blik', 'label' => __('Blik')],
];

return $options;
Expand Down
1 change: 1 addition & 0 deletions Model/Config/Source/PaymentMethods/PayLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function toOptionArray()
['value' => 'wechatpay', 'label' => __('WeChatPay')],
['value' => 'p24', 'label' => __('P24')],
['value' => 'trustly', 'label' => __('Trustly')],
['value' => 'blik', 'label' => __('Blik')],
];

return $options;
Expand Down
5 changes: 5 additions & 0 deletions Model/Config/Source/PaymentMethods/PayPerEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ public function toOptionArray()
'value' => 'trustly',
'label' => __('Trustly'),
'code' => 'buckaroo_magento2_trustly'
],
[
'value' => 'blik',
'label' => __('Blik'),
'code' => 'buckaroo_magento2_blik'
]
];

Expand Down
87 changes: 87 additions & 0 deletions Model/ConfigProvider/Method/Blik.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?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\Magento2\Model\ConfigProvider\Method;

class Blik extends AbstractConfigProvider
{
const XPATH_BLIK_PAYMENT_FEE = 'payment/buckaroo_magento2_blik/payment_fee';
const XPATH_BLIK_PAYMENT_FEE_LABEL = 'payment/buckaroo_magento2_blik/payment_fee_label';
const XPATH_BLIK_ACTIVE = 'payment/buckaroo_magento2_blik/active';
const XPATH_BLIK_SUBTEXT = 'payment/buckaroo_magento2_blik/subtext';
const XPATH_BLIK_SUBTEXT_STYLE = 'payment/buckaroo_magento2_blik/subtext_style';
const XPATH_BLIK_SUBTEXT_COLOR = 'payment/buckaroo_magento2_blik/subtext_color';
const XPATH_BLIK_ACTIVE_STATUS = 'payment/buckaroo_magento2_blik/active_status';
const XPATH_BLIK_ORDER_STATUS_SUCCESS = 'payment/buckaroo_magento2_blik/order_status_success';
const XPATH_BLIK_ORDER_STATUS_FAILED = 'payment/buckaroo_magento2_blik/order_status_failed';
const XPATH_BLIK_AVAILABLE_IN_BACKEND = 'payment/buckaroo_magento2_blik/available_in_backend';

const XPATH_ALLOWED_CURRENCIES = 'payment/buckaroo_magento2_blik/allowed_currencies';

const XPATH_ALLOW_SPECIFIC = 'payment/buckaroo_magento2_blik/allowspecific';
const XPATH_SPECIFIC_COUNTRY = 'payment/buckaroo_magento2_blik/specificcountry';
const XPATH_SPECIFIC_CUSTOMER_GROUP = 'payment/buckaroo_magento2_blik/specificcustomergroup';

/**
* @var array
*/
protected $allowedCurrencies = [
'PLN'
];
/**
* @return array|void
*/
public function getConfig()
{
$paymentFeeLabel = $this->getBuckarooPaymentFeeLabel(
\Buckaroo\Magento2\Model\Method\Blik::PAYMENT_METHOD_CODE
);

return [
'payment' => [
'buckaroo' => [
'blik' => [
'paymentFeeLabel' => $paymentFeeLabel,
'subtext' => $this->getSubtext(),
'subtext_style' => $this->getSubtextStyle(),
'subtext_color' => $this->getSubtextColor(),
'allowedCurrencies' => $this->getAllowedCurrencies(),
],
],
],
];
}

/**
* @param null|int $storeId
*
* @return float
*/
public function getPaymentFee($storeId = null)
{
$paymentFee = $this->scopeConfig->getValue(
self::XPATH_BLIK_PAYMENT_FEE,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$storeId
);

return $paymentFee ? $paymentFee : false;
}
}
103 changes: 103 additions & 0 deletions Model/Method/Blik.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?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\Magento2\Model\Method;

class Blik extends AbstractMethod
{
/**
* Payment Code
*/
const PAYMENT_METHOD_CODE = 'buckaroo_magento2_blik';

/**
* @var string
*/
public $buckarooPaymentMethodCode = 'blik';

/**
* Payment method code
*
* @var string
*/
protected $_code = self::PAYMENT_METHOD_CODE;

/**
* {@inheritdoc}
*/
public function getOrderTransactionBuilder($payment)
{
$transactionBuilder = $this->transactionBuilderFactory->get('order');

$services = [
'Name' => 'blik',
'Action' => 'Pay',
'Version' => 0,
];

/**
* @noinspection PhpUndefinedMethodInspection
*/
$transactionBuilder->setOrder($payment->getOrder())
->setServices($services)
->setMethod('TransactionRequest');

return $transactionBuilder;
}

/**
* {@inheritdoc}
*/
public function getCaptureTransactionBuilder($payment)
{
return false;
}

/**
* {@inheritdoc}
*/
public function getAuthorizeTransactionBuilder($payment)
{
return false;
}

/**
* {@inheritdoc}
*/
public function getVoidTransactionBuilder($payment)
{
return true;
}

/**
* @param \Magento\Sales\Api\Data\OrderPaymentInterface|\Magento\Payment\Model\InfoInterface $payment
*
* @return bool|string
*/
public function getPaymentMethodName($payment)
{
return 'blik';
}

protected function getRefundTransactionBuilderChannel()
{
return 'Web';
}
}
5 changes: 5 additions & 0 deletions Model/Method/Giropay.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,9 @@ public function getPaymentMethodName($payment)
{
return $this->buckarooPaymentMethodCode;
}

protected function getRefundTransactionBuilderChannel()
{
return 'Web';
}
}
4 changes: 3 additions & 1 deletion Model/Service/CreateInvoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ public function createInvoiceGeneralSetting(Order $order, array $invoiceItems):

$transactionSave->save();

$this->registry->unregister('current_invoice');

$payment = $invoice->getOrder()->getPayment();

$transactionKey = (string)$payment->getAdditionalInformation(
Expand Down Expand Up @@ -225,4 +227,4 @@ public function addTransactionData($payment, $transactionKey = false, $datas = f

return $payment;
}
}
}
Loading

0 comments on commit 0f588c5

Please sign in to comment.