Files
2026-09-15 10:35:56 +08:00

52 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace Esun\Oceanpayment\Model;
use Magento\Framework\DataObject;
use Magento\Payment\Model\Method\AbstractMethod;
use Magento\Quote\Api\Data\CartInterface;
use Magento\Sales\Model\Order;
class PaymentMethod extends AbstractMethod
{
protected $_code = Config::METHOD_CODE;
protected $_isGateway = true;
protected $_isOffline = false;
protected $_canUseInternal = false;
protected $_canUseCheckout = true;
protected $_isInitializeNeeded = true;
protected $_debugReplacePrivateDataKeys = [
'account',
'terminal',
'secure_code',
'public_key',
'key',
'signValue',
];
public function initialize($paymentAction, $stateObject): self
{
if ($stateObject instanceof DataObject) {
$stateObject->setState(Order::STATE_PENDING_PAYMENT);
$stateObject->setStatus(
$this->getConfigData('new_order_status') ?: Order::STATE_PENDING_PAYMENT
);
$stateObject->setIsNotified(false);
}
return $this;
}
public function isAvailable(?CartInterface $quote = null): bool
{
if (!parent::isAvailable($quote)) {
return false;
}
return trim((string)$this->getConfigData('account')) !== ''
&& trim((string)$this->getConfigData('terminal')) !== ''
&& trim((string)$this->getConfigData('secure_code')) !== '';
}
}