Skip to content

Commit

Permalink
BP-2434 - Create a service for checking type of payment method
Browse files Browse the repository at this point in the history
  • Loading branch information
LucianTuriacArnia committed Mar 28, 2023
1 parent ed9dcb7 commit b4555b0
Showing 1 changed file with 49 additions and 50 deletions.
99 changes: 49 additions & 50 deletions Service/CheckPaymentType.php
Original file line number Diff line number Diff line change
@@ -1,50 +1,49 @@
<?php

namespace Buckaroo\Magento2\Service;

use Buckaroo\Magento2\Model\Method\BuckarooAdapter;
use Magento\Sales\Api\Data\OrderPaymentInterface;

class CheckPaymentType
{
/**
* Is one of Buckaroo payment methods by string
*
* @param string $paymentMethod
* @return boolean
*/
public function isBuckarooMethod(string $paymentMethod): bool
{
return strpos($paymentMethod, 'buckaroo_magento2_') !== false;
}

/**
* Is one of Buckaroo payment methods by PaymentMethod
*
* @param OrderPaymentInterface|null $payment
* @return boolean
*/
public function isBuckarooPayment(?OrderPaymentInterface $payment): bool
{
if (!$payment instanceof OrderPaymentInterface) {
return false;
}
return strpos($payment->getMethod(), 'buckaroo_magento2') !== false;
}

/**
* Check if user is on the payment provider page
*
* @param OrderPaymentInterface|null $payment
* @return boolean
*/
public function isPaymentInTransit(?OrderPaymentInterface $payment): bool
{
if (!$payment instanceof OrderPaymentInterface) {
return false;
}

return $payment->getAdditionalInformation(BuckarooAdapter::BUCKAROO_PAYMENT_IN_TRANSIT) == true;
}

}
<?php

namespace Buckaroo\Magento2\Service;

use Buckaroo\Magento2\Model\Method\BuckarooAdapter;
use Magento\Sales\Api\Data\OrderPaymentInterface;

class CheckPaymentType
{
/**
* Is one of Buckaroo payment methods by string
*
* @param string $paymentMethod
* @return boolean
*/
public function isBuckarooMethod(string $paymentMethod): bool
{
return strpos($paymentMethod, 'buckaroo_magento2_') !== false;
}

/**
* Is one of Buckaroo payment methods by PaymentMethod
*
* @param OrderPaymentInterface|null $payment
* @return boolean
*/
public function isBuckarooPayment(?OrderPaymentInterface $payment): bool
{
if (!$payment instanceof OrderPaymentInterface) {
return false;
}
return strpos($payment->getMethod(), 'buckaroo_magento2') !== false;
}

/**
* Check if user is on the payment provider page
*
* @param OrderPaymentInterface|null $payment
* @return boolean
*/
public function isPaymentInTransit(?OrderPaymentInterface $payment): bool
{
if (!$payment instanceof OrderPaymentInterface) {
return false;
}

return $payment->getAdditionalInformation(BuckarooAdapter::BUCKAROO_PAYMENT_IN_TRANSIT) == true;
}
}

0 comments on commit b4555b0

Please sign in to comment.