Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
woutse committed Mar 27, 2023
2 parents a5ffabd + a11c681 commit 8e460a1
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 8 deletions.
15 changes: 13 additions & 2 deletions Controller/Checkout/Finish.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public function execute()
$bPending = in_array($orderStatusId, Config::ORDERSTATUS_PENDING);
$bDenied = $orderStatusId === Config::ORDERSTATUS_DENIED;
$bCanceled = $orderStatusId === Config::ORDERSTATUS_CANCELED;
$bVerify = $orderStatusId === Config::ORDERSTATUS_VERIFY;
$isPinTransaction = false;

try {
Expand Down Expand Up @@ -143,7 +144,7 @@ public function execute()
$bSuccess = ($transaction->isPaid() || $transaction->isAuthorized());
}

if ($bSuccess) {
if ($bSuccess || $bVerify) {
$successUrl = $this->config->getSuccessPage($payment->getMethod());
if (empty($successUrl)) {
$successUrl = ($payment->getMethod() == 'paynl_payment_paylink' || $this->config->sendEcommerceAnalytics()) ? Config::FINISH_PAY : Config::FINISH_STANDARD;
Expand All @@ -152,9 +153,19 @@ public function execute()
if ($isPinTransaction && $pinStatus->getTransactionState() !== 'approved') {
$this->messageManager->addNoticeMessage(__('Order has been made and the payment is pending.'));
}
if ($bVerify) {
$order->addStatusHistoryComment(__('PAY. - This payment has been flagged as possibly fraudulent. Please verify this transaction in the Pay. portal.'));
$this->orderRepository->save($order);
}
$this->deactivateCart($order, $payOrderId);
} elseif ($bPending) {
$resultRedirect->setPath(Config::PENDING_PAY);
$successUrl = Config::FINISH_STANDARD;
if ($this->config->getPendingPage()) {
$successUrl = Config::PENDING_PAY;
} elseif ($this->config->sendEcommerceAnalytics()) {
$successUrl = Config::FINISH_PAY;
}
$resultRedirect->setPath($successUrl, ['_query' => ['utm_nooverride' => '1']]);
$this->deactivateCart($order, $payOrderId);
} else {
$cancelMessage = $bDenied ? __('Payment denied') : __('Payment canceled');
Expand Down
9 changes: 9 additions & 0 deletions Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Config
public const ORDERSTATUS_PENDING = array(20, 25, 40, 50, 90);
public const ORDERSTATUS_DENIED = -63;
public const ORDERSTATUS_CANCELED = -90;
public const ORDERSTATUS_VERIFY = 85;

/** @var Store */
private $store;
Expand Down Expand Up @@ -328,6 +329,14 @@ public function sendEcommerceAnalytics()
return $this->store->getConfig('payment/paynl/google_analytics_ecommerce') == 1;
}

/**
* @return boolean
*/
public function getPendingPage()
{
return $this->store->getConfig('payment/paynl/pay_pending_page') == 1;
}

/**
* @param string $methodCode
* @return string
Expand Down
16 changes: 11 additions & 5 deletions Model/PayPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ class PayPayment
*/
private $builderInterface;

/**
*
* @var Magento\Sales\Model\Order\PaymentFactory
*/
private $paymentFactory;

private $paynlConfig;

/**
Expand All @@ -57,6 +63,7 @@ class PayPayment
* @param OrderRepository $orderRepository
* @param \Paynl\Payment\Model\Config $paynlConfig
* @param \Magento\Sales\Model\Order\Payment\Transaction\BuilderInterface $builderInterface
* @param \Magento\Sales\Model\Order\PaymentFactory $paymentFactory
*/
public function __construct(
\Paynl\Payment\Model\Config $config,
Expand All @@ -65,7 +72,8 @@ public function __construct(
\Magento\Framework\Event\ManagerInterface $eventManager,
OrderRepository $orderRepository,
\Paynl\Payment\Model\Config $paynlConfig,
\Magento\Sales\Model\Order\Payment\Transaction\BuilderInterface $builderInterface
\Magento\Sales\Model\Order\Payment\Transaction\BuilderInterface $builderInterface,
\Magento\Sales\Model\Order\PaymentFactory $paymentFactory
) {
$this->eventManager = $eventManager;
$this->config = $config;
Expand All @@ -74,6 +82,7 @@ public function __construct(
$this->orderRepository = $orderRepository;
$this->paynlConfig = $paynlConfig;
$this->builderInterface = $builderInterface;
$this->paymentFactory = $paymentFactory;
}

/**
Expand Down Expand Up @@ -254,9 +263,6 @@ private function processB2BPayment(Transaction $transaction, Order $order, Inter
public function processPartiallyPaidOrder(Order $order, string $payOrderId)
{
$returnResult = false;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$orderPaymentFactory = $objectManager->get(\Magento\Sales\Model\Order\PaymentFactory::class);

try {
$details = \Paynl\Transaction::details($payOrderId);

Expand All @@ -278,7 +284,7 @@ public function processPartiallyPaidOrder(Order $order, string $payOrderId)

/** @var Interceptor $orderPayment */
if (!$firstPayment) {
$orderPayment = $orderPaymentFactory->create();
$orderPayment = $this->paymentFactory->create();
} else {
$orderPayment = $order->getPayment();
}
Expand Down
8 changes: 7 additions & 1 deletion etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<frontend_model>Paynl\Payment\Block\Adminhtml\Render\Credentials</frontend_model>
</field>
<field id="tokencode" translate="label, comment" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Tokencode</label>
<label>Token code</label>
<comment>
<![CDATA[Get your AT-code <a target='_blank' href='https://admin.pay.nl/company/tokens'>here</a>. Not registered at PAY? Sign up <a target='_blank' href='https://www.pay.nl/en?register'>here</a>!]]>
</comment>
Expand Down Expand Up @@ -190,6 +190,12 @@
<source_model>Paynl\Payment\Model\Config\Source\GoogleAnalytics</source_model>
<config_path>payment/paynl/google_analytics_ecommerce</config_path>
</field>
<field id="pay_pending_page" translate="label,comment" type="select" sortOrder="109" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Pending page</label>
<comment><![CDATA[Select whether you want to use the PAY. thank you page when transaction is pending.]]></comment>
<source_model>Paynl\Payment\Model\Config\Source\OffOn</source_model>
<config_path>payment/paynl/pay_pending_page</config_path>
</field>
</group>
</section>
<section id="payment">
Expand Down
1 change: 1 addition & 0 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<discount_tax>1</discount_tax>
<pay_style_checkout>1</pay_style_checkout>
<order_description_prefix>Order </order_description_prefix>
<pay_pending_page>1</pay_pending_page>
</paynl>
<paynl_payment_paylink>
<active>0</active>
Expand Down
2 changes: 2 additions & 0 deletions i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,5 @@
"Check version","Check version"
"You are up to date with the latest version","You are up to date with the latest version"
"There is a new version available (","There is a new version available ("
"PAY. - This payment has been flagged as possibly fraudulent. Please verify this transaction in the Pay. portal.","PAY. - This payment has been flagged as possibly fraudulent. Please verify this transaction in the Pay. portal."
"Select whether you want to use the PAY. thank you page when transaction is pending.","Select whether you want to use the PAY. thank you page when transaction is pending."
2 changes: 2 additions & 0 deletions i18n/nl_NL.csv
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,5 @@
"Check version","Check versie"
"You are up to date with the latest version","U bent up to date met de laatste versie"
"There is a new version available (","Er is een nieuwe versie beschikbaar ("
"PAY. - This payment has been flagged as possibly fraudulent. Please verify this transaction in the Pay. portal.","PAY. - Deze betaling is gemarkeerd als mogelijk frauduleus. Controleer deze transactie in het Pay. portaal."
"Select whether you want to use the PAY. thank you page when transaction is pending.","Selecteer of u gebruik wilt maken van de PAY. bedankpagina wanneer de transactie in behandeling is."

0 comments on commit 8e460a1

Please sign in to comment.