Skip to content

Commit

Permalink
Fix api code (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
krzGablo authored Jan 5, 2024
1 parent 3a474c9 commit 22abed7
Show file tree
Hide file tree
Showing 57 changed files with 6,182 additions and 712 deletions.
12 changes: 4 additions & 8 deletions Api/Sales/OrderRepositoryInterface.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
<?php

declare(strict_types=1);

namespace tpaycom\magento2basic\Api\Sales;

use Magento\Sales\Api\OrderRepositoryInterface as MagentoOrderRepositoryInterface;

interface OrderRepositoryInterface extends MagentoOrderRepositoryInterface
{
/**
* Return new instance of Order by increment ID
*
* @param string $incrementId
*
* @return \Magento\Sales\Api\Data\OrderInterface
*/
public function getByIncrementId($incrementId);
/** Return new instance of Order by increment ID */
public function getByIncrementId(string $incrementId): \Magento\Sales\Api\Data\OrderInterface;
}
163 changes: 73 additions & 90 deletions Api/TpayInterface.php
Original file line number Diff line number Diff line change
@@ -1,100 +1,83 @@
<?php

declare(strict_types=1);

namespace tpaycom\magento2basic\Api;

/**
* @api
*/
interface TpayInterface
{
const CODE = 'tpaycom_magento2basic';
const CHANNEL = 'group';
const BLIK_CODE = 'blik_code';
const TERMS_ACCEPT = 'accept_tos';

/**
* Return string for redirection
*
* @return string
*/
public function getRedirectURL();

/**
* Return data for form
*
* @param null|int $orderId
*
* @return array
*/
public function getTpayFormData($orderId = null);

/** @return string */
public function getApiPassword();

/** @return string */
public function getApiKey();

/** @return string */
public function getSecurityCode();

/** @return int */
public function getMerchantId();

/**
* Check that the BLIK Level 0 should be active on a payment channels list
*
* @return bool
*/
public function checkBlikLevel0Settings();

/** @return bool */
public function getBlikLevelZeroStatus();

/** @return bool */
public function onlyOnlineChannels();

/** @return bool */
public function redirectToChannel();

/**
* Return url to redirect after placed order
*
* @return string
*/
public function getPaymentRedirectUrl();

/**
* Return url for a tpay.com terms
*
* @return string
*/
public function getTermsURL();

/**
* Check if send an email about the new invoice to customer
*
* @return string
*/
public function getInvoiceSendMail();

/**
* Check if Tpay notification server IP is forwarded by proxy
*
* @return bool
*/
public function getCheckProxy();

/**
* Check Tpay notification server IP
*
* @return bool
*/
public function getCheckTpayIP();

/**
* Check if checkout amount is in range of installments payment channel
*
* @return bool
*/
public function getInstallmentsAmountValid();
public const CODE = 'tpaycom_magento2basic';
public const CHANNEL = 'group';
public const BLIK_CODE = 'blik_code';
public const TERMS_ACCEPT = 'accept_tos';
public const CARDDATA = 'card_data';
public const CARD_SAVE = 'card_save';
public const CARD_ID = 'card_id';
public const CARD_VENDOR = 'card_vendor';
public const SHORT_CODE = 'short_code';

/** Return string for redirection */
public function getRedirectURL(): string;

/** Return data for form */
public function getTpayFormData(?string $orderId = null): array;

public function getApiPassword(): string;

public function getApiKey(): string;

public function getSecurityCode(): string;

public function getOpenApiSecurityCode(): ?string;

public function getMerchantId(): int;

/** Check that the BLIK Level 0 should be active on a payment channels list */
public function checkBlikLevel0Settings(): bool;

public function getBlikLevelZeroStatus(): bool;

public function onlyOnlineChannels(): bool;

public function redirectToChannel(): bool;

/** Return url to redirect after placed order */
public function getPaymentRedirectUrl(): string;

/** Return url for a tpay.com terms */
public function getTermsURL(): string;

/** Check if send an email about the new invoice to customer */
public function getInvoiceSendMail(): string;

public function useSandboxMode(): bool;

/** Check if checkout amount is in range of installments payment channel */
public function getInstallmentsAmountValid(): bool;

// KARTY
public function getCardApiKey(): ?string;

public function getCardApiPassword(): ?string;

public function getCardSaveEnabled(): bool;

public function getCheckoutCustomerId(): ?string;

public function getRSAKey(): string;

public function isCustomerLoggedIn(): bool;

public function getHashType(): string;

public function getVerificationCode(): string;

/** @param string $orderId */
public function getCustomerId($orderId);

/** @param string $orderId */
public function isCustomerGuest($orderId);
}
60 changes: 0 additions & 60 deletions Controller/Tpaycom.php

This file was deleted.

56 changes: 56 additions & 0 deletions Controller/tpay/CardPayment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

namespace tpaycom\magento2basic\Controller\tpay;

use Magento\Checkout\Model\Session;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Model\Context as ModelContext;
use Magento\Framework\Registry;
use Tpay\OriginApi\Utilities\Util;
use tpaycom\magento2basic\Api\TpayInterface;
use tpaycom\magento2basic\Model\ApiFacade\CardTransaction\CardApiFacade;
use tpaycom\magento2basic\Service\TpayService;
use tpaycom\magento2basic\Service\TpayTokensService;

class CardPayment extends Action
{
/** @var TpayService */
protected $tpayService;

/** @var Session */
protected $checkoutSession;

/** @var TpayInterface */
private $tpay;

/** @var TpayTokensService */
private $tokensService;

public function __construct(Context $context, TpayInterface $tpayModel, TpayService $tpayService, Session $checkoutSession, ModelContext $modelContext, Registry $registry, ResourceConnection $resourceConnection)
{
$this->tpay = $tpayModel;
$this->tpayService = $tpayService;
$this->checkoutSession = $checkoutSession;
$this->tokensService = new TpayTokensService($modelContext, $registry, $resourceConnection);
Util::$loggingEnabled = false;

Check failure on line 37 in Controller/tpay/CardPayment.php

View workflow job for this annotation

GitHub Actions / analyse

Access to static property $loggingEnabled on an unknown class Tpay\OriginApi\Utilities\Util.

Check failure on line 37 in Controller/tpay/CardPayment.php

View workflow job for this annotation

GitHub Actions / analyse

Access to static property $loggingEnabled on an unknown class Tpay\OriginApi\Utilities\Util.

Check failure on line 37 in Controller/tpay/CardPayment.php

View workflow job for this annotation

GitHub Actions / analyse

Access to static property $loggingEnabled on an unknown class Tpay\OriginApi\Utilities\Util.

Check failure on line 37 in Controller/tpay/CardPayment.php

View workflow job for this annotation

GitHub Actions / analyse

Access to static property $loggingEnabled on an unknown class Tpay\OriginApi\Utilities\Util.
parent::__construct($context);
}

public function execute()
{
/** @var int $orderId */
$orderId = $this->checkoutSession->getLastRealOrderId();

if ($orderId) {
$cardTransaction = new CardApiFacade($this->tpay, $this->tokensService, $this->tpayService);
$redirectUrl = $cardTransaction->makeCardTransaction($orderId);

return $this->_redirect($redirectUrl);
}
$this->checkoutSession->unsQuoteId();

return $this->_redirect('magento2basic/tpay/error');
}
}
Loading

0 comments on commit 22abed7

Please sign in to comment.