-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BP-2434 - Create a service for checking type of payment method
- Loading branch information
1 parent
ed9dcb7
commit b4555b0
Showing
1 changed file
with
49 additions
and
50 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 |
---|---|---|
@@ -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; | ||
} | ||
} |