Skip to content

Commit

Permalink
Added setting for authorisation transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
woutse committed Mar 31, 2021
1 parent 2a7c420 commit f2e1c20
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 27 deletions.
18 changes: 8 additions & 10 deletions Controller/Checkout/Exchange.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,18 +172,19 @@ public function execute()
}
if ($action == 'capture') {
$payment = $order->getPayment();
if(!empty($payment) && $payment->getAdditionalInformation('manual_capture')){
if (!empty($payment) && $payment->getAdditionalInformation('manual_capture')) {
$this->logger->debug('Already captured.');

return $this->result->setContents('TRUE| Already captured.');
}
}

if ($transaction->isPaid() || $transaction->isAuthorized()) {
return $this->processPaidOrder($transaction, $order);
} elseif ($transaction->isCanceled()) {
if ($order->isCanceled()) {
return $this->result->setContents("TRUE| ALLREADY CANCELED");
if ($order->getState() == Order::STATE_PROCESSING) {
return $this->result->setContents("TRUE| Ignoring cancel, order is `processing`");
} elseif ($order->isCanceled()) {
return $this->result->setContents("TRUE| Already canceled");
} else {
return $this->cancelOrder($order);
}
Expand Down Expand Up @@ -330,14 +331,11 @@ private function processPaidOrder(Transaction $transaction, Order $order)
}
}

# Make the invoice and send it to the customer
if ($transaction->isAuthorized()) {
$paidAmount = $transaction->getCurrencyAmount();
$payment->registerAuthorizationNotification($paidAmount);
$authAmount = $this->config->useMagOrderAmountForAuth() ? $order->getBaseGrandTotal() : $transaction->getCurrencyAmount();
$payment->registerAuthorizationNotification($authAmount);
} else {
$payment->registerCaptureNotification(
$paidAmount, $this->config->isSkipFraudDetection()
);
$payment->registerCaptureNotification($paidAmount, $this->config->isSkipFraudDetection());
}

$this->orderRepository->save($order);
Expand Down
7 changes: 6 additions & 1 deletion Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ public function isAlwaysBaseCurrency()
return $this->store->getConfig('payment/paynl/always_base_currency') == 1;
}

public function useMagOrderAmountForAuth()
{
return $this->store->getConfig('payment/paynl/use_magorder_for_auth') == 1;
}

public function getLanguage()
{
$language = $this->store->getConfig('payment/paynl/language');
Expand Down Expand Up @@ -130,7 +135,7 @@ public function ignoreB2BInvoice($methodCode)
{
return $this->store->getConfig('payment/' . $methodCode . '/turn_off_invoices_b2b') == 1;
}

public function autoCaptureEnabled()
{
return $this->store->getConfig('payment/paynl/auto_capture') == 1;
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "paynl/magento2-plugin",
"description": "PAY. Magento2 Payment methods",
"type": "magento2-module",
"version": "1.7.4",
"version": "1.7.5",
"require": {
"magento/module-sales": "100 - 103",
"magento/module-payment": "100 - 103",
Expand Down
8 changes: 6 additions & 2 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,16 @@
This can be used if uncancelling the order in case of a second chance payment produces errors. WARNING! Orders will never be cancelled automaticly]]></comment>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="always_base_currency" translate="label,comment" type="select" sortOrder="70" showInDefault="1"
showInWebsite="1" showInStore="1">
<field id="always_base_currency" translate="label,comment" type="select" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Always use base currency</label>
<comment><![CDATA[Set this to yes if you always want to process payments in the base currency of this store. Magento acts strange when trying to register a payment in another currency than the base currency. The base currency MUST be EUR]]></comment>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="use_magorder_for_auth" translate="label,comment" type="select" sortOrder="71" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Use base amount for authorisations</label>
<comment><![CDATA[Set this to yes to use base amount as authorize amount instead of currencyamount]]></comment>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="skip_fraud_detection" translate="label,comment" type="select" sortOrder="80" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Skip fraud detection</label>
Expand Down
26 changes: 13 additions & 13 deletions view/frontend/web/js/view/payment/method-renderer/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ define(
dateofbirth: null,
billink_agree: null,
initialize: function () {
this._super();
if(!quote.paymentMethod() && window.checkoutConfig.payment.defaultpaymentoption[this.item.method]){
this._super();
if (!quote.paymentMethod() && window.checkoutConfig.payment.defaultpaymentoption[this.item.method]) {
this.selectPaymentMethod();
}
return this;
Expand All @@ -38,10 +38,10 @@ define(
return false;
}
}
if(this.getforCompany() == 1 && this.getCompany().length != 0){
if (this.getforCompany() == 1 && this.getCompany().length != 0) {
return false;
}
if(this.getforCompany() == 2 && this.getCompany().length == 0){
if (this.getforCompany() == 2 && this.getCompany().length == 0) {
return false;
}
if (!this.currentIpIsValid()) {
Expand All @@ -60,16 +60,16 @@ define(
},
getDisallowedShipping: function () {
return window.checkoutConfig.payment.disallowedshipping[this.item.method];
},
getCompany: function () {
},
getCompany: function () {
if (typeof quote.billingAddress._latestValue.company !== 'undefined' && quote.billingAddress._latestValue.company !== null) {
return quote.billingAddress._latestValue.company;
}
return '';
},
return '';
},
getforCompany : function () {
return window.checkoutConfig.payment.showforcompany[this.item.method];
},
},
getInstructions: function () {
return window.checkoutConfig.payment.instructions[this.item.method];
},
Expand All @@ -80,23 +80,23 @@ define(
return this.getKVK() > 0;
},
getKVK: function () {
return window.checkoutConfig.payment.showkvk[this.item.method];
return (typeof window.checkoutConfig.payment.showkvk !== 'undefined') ? window.checkoutConfig.payment.showkvk[this.item.method] : '';
},
showDOB: function () {
return this.getDOB() > 0;
},
getDOB: function () {
return window.checkoutConfig.payment.showdob[this.item.method];
return (typeof window.checkoutConfig.payment.showdob !== 'undefined') ? window.checkoutConfig.payment.showdob[this.item.method] : '';
},
showKVKDOB: function () {
return this.getKVKDOB() > 0;
},
getKVKDOB: function () {
return (this.getDOB() > 0 && this.getKVK() > 0);
},
},
showBanks: function(){
return window.checkoutConfig.payment.banks[this.item.method].length > 0;
},
},
getBanks: function(){
return window.checkoutConfig.payment.banks[this.item.method];
},
Expand Down

0 comments on commit f2e1c20

Please sign in to comment.