Skip to content

Commit

Permalink
Fix config groups
Browse files Browse the repository at this point in the history
  • Loading branch information
krzGablo committed Jan 15, 2024
1 parent 1684c1f commit 3463250
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 44 deletions.
2 changes: 0 additions & 2 deletions Api/TpayInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ public function getSecurityCode(): ?string;

public function getOpenApiClientId(): ?string;

public function getOpenApiSecurityCode(): ?string;

public function getMerchantId(): ?int;

/** Check that the BLIK Level 0 should be active on a payment channels list */
Expand Down
11 changes: 1 addition & 10 deletions Controller/tpay/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __construct(Context $context, RemoteAddress $remoteAddress, Tpay
public function execute()
{
try {
$notification = $this->generateNotification();
$notification = (new JWSVerifiedPaymentNotification($this->tpay->getSecurityCode(), !$this->tpay->useSandboxMode()))->getNotification();
$notification = $notification->getNotificationAssociative();
$orderId = base64_decode($notification['tr_crc']);

Expand Down Expand Up @@ -121,13 +121,4 @@ private function saveCard(array $notification, string $orderId)
}
}
}

private function generateNotification()
{
try {
return (new JWSVerifiedPaymentNotification($this->tpay->getSecurityCode(), !$this->tpay->useSandboxMode()))->getNotification();
} catch (Exception $e) {
return (new JWSVerifiedPaymentNotification($this->tpay->getOpenApiSecurityCode(), !$this->tpay->useSandboxMode()))->getNotification();
}
}
}
54 changes: 22 additions & 32 deletions Model/Tpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
use tpaycom\magento2basic\Api\Sales\OrderRepositoryInterface;
use tpaycom\magento2basic\Api\TpayInterface;
use tpaycom\magento2basic\Model\ApiFacade\Refund\RefundApiFacade;
use tpayLibs\src\_class_tpay\Validators\FieldsValidator;
use Tpay\OriginApi\Validators\FieldsValidator;

class Tpay extends AbstractMethod implements TpayInterface
{
Expand Down Expand Up @@ -142,32 +142,32 @@ public function getInstallmentsAmountValid(): bool

public function getBlikLevelZeroStatus(): bool
{
return (bool) $this->getConfigData('blik_level_zero');
return (bool) $this->getConfigData('general_settings/blik_level_zero');
}

public function getApiKey(): ?string
{
return $this->getConfigData('api_key_tpay');
return $this->getConfigData('originapi_settings/api_key_tpay');
}

public function getCardApiKey(): ?string
{
return $this->getConfigData('card_api_key_tpay');
return $this->getConfigData('originapi_settings/card_api_key_tpay');
}

public function getApiPassword(): ?string
{
return $this->getConfigData('api_password');
return $this->getConfigData('originapi_settings/api_password');
}

public function getCardApiPassword(): ?string
{
return $this->getConfigData('card_api_password');
return $this->getConfigData('originapi_settings/card_api_password');
}

public function getInvoiceSendMail(): string
{
return $this->getConfigData('send_invoice_email');
return $this->getConfigData('sale_settings/send_invoice_email');
}

public function getTermsURL(): string
Expand All @@ -177,7 +177,7 @@ public function getTermsURL(): string

public function getOpenApiPassword()
{
return $this->getConfigData('open_api_password');
return $this->getConfigData('openapi_settings/open_api_password');
}

public function getTpayFormData(?string $orderId = null): array
Expand Down Expand Up @@ -216,27 +216,22 @@ public function getTpayFormData(?string $orderId = null): array

public function getMerchantId(): ?int
{
return (int) $this->getConfigData('merchant_id');
return (int) $this->getConfigData('general_settings/merchant_id');
}

public function getOpenApiClientId(): ?string
{
return $this->getConfigData('open_api_client_id');
return $this->getConfigData('openapi_settings/open_api_client_id');
}

public function getSecurityCode(): ?string
{
return $this->getConfigData('security_code');
}

public function getOpenApiSecurityCode(): ?string
{
return $this->getConfigData('open_api_security_code');
return $this->getConfigData('general_settings/security_code');
}

public function onlyOnlineChannels(): bool
{
return (bool) $this->getConfigData('show_payment_channels_online');
return (bool) $this->getConfigData('general_settings/show_payment_channels_online');
}

public function redirectToChannel(): bool
Expand All @@ -251,12 +246,12 @@ public function setTitle(string $title): void

public function getTitle(): string
{
return $this->_title ?? $this->getConfigData('title');
return $this->_title ?? $this->getConfigData('general_settings/title');
}

public function useSandboxMode(): bool
{
return (bool) $this->getConfigData('use_sandbox');
return (bool) $this->getConfigData('general_settings/use_sandbox');
}

public function getPaymentRedirectUrl(): string
Expand All @@ -270,8 +265,8 @@ public function getPaymentRedirectUrl(): string
*/
public function isAvailable(?CartInterface $quote = null)
{
$minAmount = $this->getConfigData('min_order_total');
$maxAmount = $this->getConfigData('max_order_total');
$minAmount = $this->getConfigData('sale_settings/min_order_total');
$maxAmount = $this->getConfigData('sale_settings/max_order_total');

if ($quote && ($quote->getBaseGrandTotal() < $minAmount || ($maxAmount && $quote->getBaseGrandTotal() > $maxAmount))) {
return false;
Expand Down Expand Up @@ -366,7 +361,7 @@ public function getConfigData($field, $storeId = null)
// KARTY
public function getCardSaveEnabled(): bool
{
return (bool) $this->getConfigData('card_save_enabled');
return (bool) $this->getConfigData('cardpayment_settings/card_save_enabled');
}

public function getCheckoutCustomerId(): ?string
Expand All @@ -381,7 +376,7 @@ public function getCheckoutCustomerId(): ?string

public function getRSAKey(): string
{
return $this->getConfigData('rsa_key');
return $this->getConfigData('cardpayment_settings/rsa_key');
}

public function isCustomerLoggedIn(): bool
Expand All @@ -396,12 +391,12 @@ public function isCustomerLoggedIn(): bool

public function getHashType(): string
{
return $this->getConfigData('hash_type');
return $this->getConfigData('cardpayment_settings/hash_type');
}

public function getVerificationCode(): string
{
return $this->getConfigData('verification_code');
return $this->getConfigData('cardpayment_settings/verification_code');
}

/**
Expand Down Expand Up @@ -435,15 +430,10 @@ public function getISOCurrencyCode($orderCurrency)
return $this->validateCardCurrency($orderCurrency);
}

public function getClientId(): ?string
{
return $this->getConfigData('client_id');
}

public function isCartValid(?float $grandTotal = null): bool
{
$minAmount = $this->getConfigData('min_order_total');
$maxAmount = $this->getConfigData('max_order_total');
$minAmount = $this->getConfigData('sale_settings/min_order_total');
$maxAmount = $this->getConfigData('sale_settings/max_order_total');

if ($grandTotal && ($grandTotal < $minAmount || ($maxAmount && $grandTotal > $maxAmount))) {
return false;
Expand Down

0 comments on commit 3463250

Please sign in to comment.