Skip to content

Commit

Permalink
Merge pull request #38 from paynl/feature/PLUG-446
Browse files Browse the repository at this point in the history
Updated paymentmethod name
  • Loading branch information
woutse authored Jun 3, 2021
2 parents 475f82c + 36e1ba8 commit edf090a
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions paynlpaymentmethods/paynlpaymentmethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function __construct()
{
$this->name = 'paynlpaymentmethods';
$this->tab = 'payments_gateways';
$this->version = '4.2.14';
$this->version = '4.2.15';

$this->payLogEnabled = null;
$this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_);
Expand Down Expand Up @@ -136,18 +136,27 @@ public function hookDisplayAdminOrder($params)
$orderPayment = reset($orderPayments);

$status = 'unavailable';
$method = $order->payment;
$currency = new Currency($orderPayment->id_currency);
$transactionId = $orderPayment->transaction_id;
$payOrderAmount = 0;
$methodName = 'PAY.';

try {
$transaction = $this->getTransaction($transactionId);
$arrTransactionDetails = $transaction->getData();
$payOrderAmount = $transaction->getPaidAmount();
$status = $arrTransactionDetails['paymentDetails']['stateName'];
$method = $arrTransactionDetails['paymentDetails']['paymentProfileName'];
$showRefundButton = $transaction->isPaid() || $transaction->isPartiallyRefunded();
$transaction = $this->getTransaction($transactionId);
$arrTransactionDetails = $transaction->getData();
$payOrderAmount = $transaction->getPaidAmount();
$status = $arrTransactionDetails['paymentDetails']['stateName'];
$profileId = $transaction->getPaymentProfileId();
$settings = $this->getPaymentMethodSettings($profileId);

# Get the custom method name
if ($profileId == 613) {
$methodName = 'Sandbox';
} else {
$methodName = empty($settings->name) ? $profileId : $settings->name;
}

$showRefundButton = $transaction->isPaid() || $transaction->isPartiallyRefunded();
} catch (Exception $exception) {
$showRefundButton = false;
}
Expand All @@ -165,7 +174,7 @@ public function hookDisplayAdminOrder($params)
'currency' => $currency->iso_code,
'pay_orderid' => $transactionId,
'status' => $status,
'method' => $method,
'method' => $methodName,
'ajaxURL' => $this->context->link->getModuleLink($this->name, 'ajax', array(), true),
'showRefundButton' => $showRefundButton,
));
Expand Down Expand Up @@ -632,15 +641,16 @@ public function processPayment($transactionId, &$message = null)
}

try {
$profileId = $arrPayData['paymentDetails']['paymentOptionId'];
$paymentMethodName = $arrPayData['paymentDetails']['paymentProfileName'];
$profileId = $transaction->getPaymentProfileId();

# Profile 613 is for testing purposes
if($profileId != 613) {
$settings = $this->getPaymentMethodSettings($profileId);
if ($profileId == 613) {
$paymentMethodName = 'Sandbox';
} else {
$settings = $this->getPaymentMethodSettings($profileId);

# Get the custom method name
$paymentMethodName = empty($settings->name) ? '' : $settings->name;
# Get the custom method name
$paymentMethodName = empty($settings->name) ? '' : $settings->name;
}

if (empty($paymentMethodName)) {
Expand Down Expand Up @@ -686,7 +696,6 @@ public function processPayment($transactionId, &$message = null)
public function getTransaction($transactionId)
{
$this->sdkLogin();

return \Paynl\Transaction::status($transactionId);
}

Expand Down

0 comments on commit edf090a

Please sign in to comment.