Skip to content

Commit

Permalink
Merge pull request #16 from Xaxxis/master
Browse files Browse the repository at this point in the history
2.3.2 Fix bug default client-key
  • Loading branch information
Zaki Ibrahim authored Sep 16, 2020
2 parents 4f055b2 + 92329f8 commit 3dabce6
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 38 deletions.
86 changes: 49 additions & 37 deletions Model/Config/Source/Payment/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ protected function getDataConfig($pathXML)

public function isProduction()
{
return $this->getDataConfig('payment/snap/settings/is_production') == '1' ? true : false;
return $this->getDataConfig('payment/snap/settings/is_production') == 1;
}

public function isRedirect()
{
return $this->getDataConfig('payment/snap/settings/enable_redirect') == '1' ? true : false;
return $this->getDataConfig('payment/snap/settings/enable_redirect') == 1;
}

public function getMerchantId()
Expand Down Expand Up @@ -67,7 +67,7 @@ public function getDefaultServerKey()
}

public function enableLog() {
return $this->getDataConfig('payment/settings/enable_log') == 1 ? true : false;
return $this->getDataConfig('payment/settings/enable_log') == 1;
}

public function getOrderStatus() {
Expand All @@ -78,8 +78,8 @@ public function getConfigSnap() {
$config = array();
$config['bank'] = $this->getDataConfig('payment/snap/basic/cc_config/bank');
$config['custom_expiry'] = $this->getDataConfig('payment/snap/custom_expiry');
$config['is3ds'] = $this->getDataConfig('payment/snap/is3ds') == 1 ? true : false;
$config['one_click'] = $this->getDataConfig('payment/snap/one_click') == 1 ? true : false;
$config['is3ds'] = $this->getDataConfig('payment/snap/is3ds') == 1;
$config['one_click'] = $this->getDataConfig('payment/snap/one_click') == 1;
$config['bin'] = $this->getDataConfig('payment/snap/basic/cc_config/bin');
return $config;
}
Expand All @@ -88,8 +88,8 @@ public function getConfigSpecific() {
$configSpecific = array();
$configSpecific['bank'] = $this->getDataConfig('payment/snap/specific/cc_config/bank');
$configSpecific['custom_expiry'] = $this->getDataConfig('payment/specific/custom_expiry');
$configSpecific['is3ds'] = $this->getDataConfig('payment/specific/is3ds') == 1 ? true : false;
$configSpecific['one_click'] = $this->getDataConfig('payment/specific/one_click') == 1 ? true : false;
$configSpecific['is3ds'] = $this->getDataConfig('payment/specific/is3ds') == 1;
$configSpecific['one_click'] = $this->getDataConfig('payment/specific/one_click') == 1;
$configSpecific['bin'] = $this->getDataConfig('payment/snap/specific/cc_config/bin');
$configSpecific['enabled_payments'] = $this->getDataConfig('payment/snap/specific/enable_payment');
return $configSpecific;
Expand All @@ -98,8 +98,8 @@ public function getConfigSpecific() {
public function getConfigInstallment() {
$configInstallment = array();
$configInstallment['custom_expiry'] = $this->getDataConfig('payment/installment/custom_expiry');
$configInstallment['is3ds'] = $this->getDataConfig('payment/installment/is3ds') == 1 ? true : false;
$configInstallment['one_click'] = $this->getDataConfig('payment/installment/one_click') == 1 ? true : false;
$configInstallment['is3ds'] = $this->getDataConfig('payment/installment/is3ds') == 1;
$configInstallment['one_click'] = $this->getDataConfig('payment/installment/one_click') == 1;
$configInstallment['minimal_amount'] = $this->getDataConfig('payment/installment/minimal_amount');
return $configInstallment;
}
Expand All @@ -108,8 +108,8 @@ public function getConfigOffline() {
$configOffline = array();
$configOffline['bank'] = $this->getDataConfig('payment/snap/offline/cc_config/bank');
$configOffline['custom_expiry'] = $this->getDataConfig('payment/offline/custom_expiry');
$configOffline['is3ds'] = $this->getDataConfig('payment/offline/is3ds') == 1 ? true : false;
$configOffline['one_click'] = $this->getDataConfig('payment/offline/one_click') == 1 ? true : false;
$configOffline['is3ds'] = $this->getDataConfig('payment/offline/is3ds') == 1;
$configOffline['one_click'] = $this->getDataConfig('payment/offline/one_click') == 1;
$configOffline['bin'] = $this->getDataConfig('payment/snap/offline/cc_config/bin');
$configOffline['minimal_amount'] = $this->getDataConfig('payment/offline/minimal_amount');
$configOffline['terms'] = $this->getDataConfig('payment/snap/offline/cc_config/term');
Expand All @@ -118,56 +118,60 @@ public function getConfigOffline() {

public function isNotificationLogEnabled()
{
return $this->getDataConfig('payment/settings/notification_log') == 1 ? true : false;
return $this->getDataConfig('payment/settings/notification_log') == 1;
}

public function isRequestLogEnabled()
{
return $this->getDataConfig('payment/settings/request_log') == 1 ? true : false;
return $this->getDataConfig('payment/settings/request_log') == 1;
}

public function isErrorLogEnabled()
{
return $this->getDataConfig('payment/settings/error_log') == 1 ? true : false;
return $this->getDataConfig('payment/settings/error_log') == 1;
}

public function isExceptionEnabled()
{
return $this->getDataConfig('payment/settings/throw_exception') == 1 ? true : false;
return $this->getDataConfig('payment/settings/throw_exception') == 1;
}

public function getSpecificMerchantId()
{
return $this->getDataConfig('payment/snap/specific/specific_access/merchant_id');
if ($this->getDataConfig('payment/specific/use_specific_account') == 1) {
return $this->getDataConfig('payment/snap/specific/specific_access/merchant_id');
} else {
return $this->getMerchantId();
}
}

public function getSpecificClientKey()
{
if ($this->isProduction()) {
if ($this->getDataConfig('payment/specific/use_specific_account') == 1 ? true : false) {
if ($this->getDataConfig('payment/specific/use_specific_account') == 1) {
return $this->getDataConfig('payment/snap/specific/specific_access/production_client_key');
} else {
return $this->getDefaultServerKey();
return $this->getDefaultClientKey();
}
} else {
if ($this->getDataConfig('payment/specific/use_specific_account') == 1 ? true : false) {
if ($this->getDataConfig('payment/specific/use_specific_account') == 1) {
return $this->getDataConfig('payment/snap/specific/specific_access/sandbox_client_key');
} else {
return $this->getDefaultServerKey();
return $this->getDefaultClientKey();
}
}
}

public function getSpecificServerKey()
{
if ($this->isProduction()) {
if ($this->getDataConfig('payment/specific/use_specific_account') == 1 ? true : false) {
if ($this->getDataConfig('payment/specific/use_specific_account') == 1) {
return $this->getDataConfig('payment/snap/specific/specific_access/production_server_key');
} else {
return $this->getDefaultServerKey();
}
} else {
if ($this->getDataConfig('payment/specific/use_specific_account') == 1 ? true : false) {
if ($this->getDataConfig('payment/specific/use_specific_account') == 1) {
return $this->getDataConfig('payment/snap/specific/specific_access/sandbox_server_key');
} else {
return $this->getDefaultServerKey();
Expand All @@ -177,36 +181,40 @@ public function getSpecificServerKey()

public function getInstallmentMerchantId()
{
return $this->getDataConfig('payment/snap/installment/installment_access/merchant_id');
if ($this->getDataConfig('payment/installment/use_specific_account') == 1) {
return $this->getDataConfig('payment/snap/installment/installment_access/merchant_id');
} else {
return $this->getMerchantId();
}
}

public function getInstallmentClientKey()
{
if ($this->isProduction()) {
if ($this->getDataConfig('payment/installment/use_specific_account') == 1 ? true : false) {
if ($this->getDataConfig('payment/installment/use_specific_account') == 1) {
return $this->getDataConfig('payment/snap/installment/installment_access/production_client_key');
} else {
return $this->getDefaultServerKey();
return $this->getDefaultClientKey();
}
} else {
if ($this->getDataConfig('payment/installment/use_specific_account') == 1 ? true : false) {
if ($this->getDataConfig('payment/installment/use_specific_account') == 1) {
return $this->getDataConfig('payment/snap/installment/installment_access/sandbox_client_key');
} else {
return $this->getDefaultServerKey();
return $this->getDefaultClientKey();
}
}
}

public function getInstallmentServerKey()
{
if ($this->isProduction()) {
if ($this->getDataConfig('payment/installment/use_specific_account') == 1 ? true : false) {
if ($this->getDataConfig('payment/installment/use_specific_account') == 1) {
return $this->getDataConfig('payment/snap/installment/installment_access/production_server_key');
} else {
return $this->getDefaultServerKey();
}
} else {
if ($this->getDataConfig('payment/offline/use_specific_account') == 1 ? true : false) {
if ($this->getDataConfig('payment/offline/use_specific_account') == 1) {
return $this->getDataConfig('payment/snap/installment/installment_access/sandbox_server_key');
} else {
return $this->getDefaultServerKey();
Expand All @@ -216,40 +224,44 @@ public function getInstallmentServerKey()

public function getOfflineMerchantId()
{
return $this->getDataConfig('payment/snap/offline/offline_access/merchant_id');
if ($this->getDataConfig('payment/offline/use_specific_account') == 1) {
return $this->getDataConfig('payment/snap/offline/offline_access/merchant_id');
} else {
return $this->getMerchantId();
}
}

public function getOfflineClientKey()
{
if ($this->isProduction()) {
if ($this->getDataConfig('payment/offline/use_specific_account') == 1 ? true : false) {
if ($this->getDataConfig('payment/offline/use_specific_account') == 1) {
return $this->getDataConfig('payment/snap/offline/offline_access/production_client_key');
} else {
return $this->getDefaultServerKey();
return $this->getDefaultClientKey();
}
} else {
if ($this->getDataConfig('payment/offline/use_specific_account') == 1 ? true : false) {
if ($this->getDataConfig('payment/offline/use_specific_account') == 1) {
return $this->getDataConfig('payment/snap/offline/offline_access/sandbox_client_key');
} else {
return $this->getDefaultServerKey();
return $this->getDefaultClientKey();
}
}
}

public function getOfflineServerKey()
{
if ($this->isProduction()) {
if ($this->getDataConfig('payment/offline/use_specific_account') == 1 ? true : false) {
if ($this->getDataConfig('payment/offline/use_specific_account') == 1) {
return $this->getDataConfig('payment/snap/offline/offline_access/production_server_key');
} else {
return $this->getDefaultServerKey();
}
} else {
if ($this->getDataConfig('payment/offline/use_specific_account') == 1 ? true : false) {
if ($this->getDataConfig('payment/offline/use_specific_account') == 1) {
return $this->getDataConfig('payment/snap/offline/offline_access/sandbox_server_key');
} else {
return $this->getDefaultServerKey();
}
}
}
}
}
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": "midtrans/snap",
"description": "Midtrans Accept Online Payment Magento 2 module",
"type": "magento2-module",
"version": "2.3.1",
"version": "2.3.2",
"authors" : [
{
"name": "Zaki Ibrahim",
Expand Down

0 comments on commit 3dabce6

Please sign in to comment.