Skip to content

Commit

Permalink
Rename PMNTS -> Fat Zebra
Browse files Browse the repository at this point in the history
  • Loading branch information
amasses committed Mar 10, 2020
1 parent 3a7d7aa commit 8147d7d
Show file tree
Hide file tree
Showing 31 changed files with 248 additions and 248 deletions.
4 changes: 2 additions & 2 deletions Block/Customer/CardRenderer.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace PMNTS\Gateway\Block\Customer;
namespace FatZebra\Gateway\Block\Customer;

use Magento\Vault\Api\Data\PaymentTokenInterface;
use Magento\Vault\Block\AbstractCardRenderer;
Expand All @@ -20,7 +20,7 @@ class CardRenderer extends AbstractCardRenderer
*/
public function canRender(PaymentTokenInterface $token)
{
return $token->getPaymentMethodCode() === \PMNTS\Gateway\Helper\Data::METHOD_CODE;
return $token->getPaymentMethodCode() === \FatZebra\Gateway\Helper\Data::METHOD_CODE;
}

/**
Expand Down
26 changes: 13 additions & 13 deletions Gateway/AbstractCommand.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php

namespace PMNTS\Gateway\Gateway;
namespace FatZebra\Gateway\Gateway;

abstract class AbstractCommand implements \Magento\Payment\Gateway\CommandInterface
{
/** @var \Magento\Framework\App\Config\ScopeConfigInterface */
protected $scopeConfig;

/** @var \PMNTS\Gateway\Helper\Data */
protected $pmntsHelper;
/** @var \FatZebra\Gateway\Helper\Data */
protected $fatzebraHelper;

/** @var \PMNTS\Gateway\Model\GatewayFactory */
/** @var \FatZebra\Gateway\Model\GatewayFactory */
protected $gatewayFactory;

/** @var \Psr\Log\LoggerInterface */
Expand All @@ -19,42 +19,42 @@ abstract class AbstractCommand implements \Magento\Payment\Gateway\CommandInterf
/**
* AbstractCommand constructor.
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \PMNTS\Gateway\Helper\Data $pmntsHelper
* @param \PMNTS\Gateway\Model\GatewayFactory $gatewayFactory
* @param \FatZebra\Gateway\Helper\Data $fatzebraHelper
* @param \FatZebra\Gateway\Model\GatewayFactory $gatewayFactory
* @param \Psr\Log\LoggerInterface $logger
*/
public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\PMNTS\Gateway\Helper\Data $pmntsHelper,
\PMNTS\Gateway\Model\GatewayFactory $gatewayFactory,
\FatZebra\Gateway\Helper\Data $fatzebraHelper,
\FatZebra\Gateway\Model\GatewayFactory $gatewayFactory,
\Psr\Log\LoggerInterface $logger
) {
$this->scopeConfig = $scopeConfig;
$this->pmntsHelper = $pmntsHelper;
$this->fatzebraHelper = $fatzebraHelper;
$this->gatewayFactory = $gatewayFactory;
$this->logger = $logger;
}

/**
* @param $storeId
* @return \Pmnts\Gateway\Model\Gateway
* @return \FatZebra\Gateway\Model\Gateway
*/
public function getGateway($storeId)
{
$username = $this->scopeConfig->getValue(
\PMNTS\Gateway\Helper\Data::CONFIG_PATH_PMNTS_USERNAME,
\FatZebra\Gateway\Helper\Data::CONFIG_PATH_FATZEBRA_USERNAME,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$storeId
);

$token = $this->scopeConfig->getValue(
\PMNTS\Gateway\Helper\Data::CONFIG_PATH_PMNTS_TOKEN,
\FatZebra\Gateway\Helper\Data::CONFIG_PATH_FATZEBRA_TOKEN,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$storeId
);

$sandbox = (bool)$this->scopeConfig->getValue(
\PMNTS\Gateway\Helper\Data::CONFIG_PATH_PMNTS_SANDBOX,
\FatZebra\Gateway\Helper\Data::CONFIG_PATH_FATZEBRA_SANDBOX,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$storeId
);
Expand Down
34 changes: 17 additions & 17 deletions Gateway/CaptureCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
/**
* Capture command (with tokenization if opted-in by customer)
*
* @category PMNTS
* @package PMNTS_Gateway
* @copyright PMNTS (http://PMNTS.io)
* @category Fat Zebra
* @package FatZebra_Gateway
* @copyright Fat Zebra (https://www.fatzebra.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
namespace PMNTS\Gateway\Gateway;
namespace FatZebra\Gateway\Gateway;

class CaptureCommand extends AbstractCommand
{
Expand Down Expand Up @@ -37,8 +37,8 @@ class CaptureCommand extends AbstractCommand
/**
* CaptureCommand constructor.
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \PMNTS\Gateway\Helper\Data $pmntsHelper
* @param \PMNTS\Gateway\Model\GatewayFactory $gatewayFactory
* @param \FatZebra\Gateway\Helper\Data $fatzebraHelper
* @param \FatZebra\Gateway\Model\GatewayFactory $gatewayFactory
* @param \Psr\Log\LoggerInterface $logger
* @param \Magento\Vault\Model\PaymentTokenFactory $paymentTokenFactory
* @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
Expand All @@ -48,16 +48,16 @@ class CaptureCommand extends AbstractCommand
*/
public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\PMNTS\Gateway\Helper\Data $pmntsHelper,
\PMNTS\Gateway\Model\GatewayFactory $gatewayFactory,
\FatZebra\Gateway\Helper\Data $fatzebraHelper,
\FatZebra\Gateway\Model\GatewayFactory $gatewayFactory,
\Psr\Log\LoggerInterface $logger,
\Magento\Vault\Model\PaymentTokenFactory $paymentTokenFactory,
\Magento\Customer\Api\CustomerRepositoryInterface $customerRepository,
\Magento\Vault\Api\PaymentTokenRepositoryInterface $paymentTokenRepository,
\Magento\Framework\Serialize\Serializer\Json $json,
\Magento\Sales\Api\Data\OrderPaymentExtensionInterfaceFactory $paymentExtensionInterfaceFactory
) {
parent::__construct($scopeConfig, $pmntsHelper, $gatewayFactory, $logger);
parent::__construct($scopeConfig, $fatzebraHelper, $gatewayFactory, $logger);
$this->paymentTokenFactory = $paymentTokenFactory;
$this->customerRepository = $customerRepository;
$this->paymentTokenRepository = $paymentTokenRepository;
Expand All @@ -77,16 +77,16 @@ public function execute(array $commandSubject)
/** @var \Magento\Sales\Model\Order $order */
$order = $payment->getOrder();

$pmntsToken = $payment->getAdditionalInformation('pmnts_token');
$fatzebraToken = $payment->getAdditionalInformation('fatzebra_token');

/** @var \PMNTS\Gateway\Model\Gateway $gateway */
/** @var \FatZebra\Gateway\Model\Gateway $gateway */
$gateway = $this->getGateway($order->getStoreId());

$reference = $this->pmntsHelper->getOrderReference($order);
$fraudData = $this->pmntsHelper->buildFraudPayload($order);
$reference = $this->fatzebraHelper->getOrderReference($order);
$fraudData = $this->fatzebraHelper->buildFraudPayload($order);

/** @var array $result */
$result = $gateway->token_purchase($pmntsToken, $commandSubject['amount'], $reference, null, $fraudData);
$result = $gateway->token_purchase($fatzebraToken, $commandSubject['amount'], $reference, null, $fraudData);

if ($result && isset($result['response'])) {
if ($result['response']['successful'] === false) {
Expand All @@ -102,7 +102,7 @@ public function execute(array $commandSubject)
throw new \Magento\Framework\Validator\Exception(__('Payment gateway error, please contact customer service.'));
}

if ($payment->getAdditionalInformation('pmnts_save_token') && $order->getCustomerId()) {
if ($payment->getAdditionalInformation('fatzebra_save_token') && $order->getCustomerId()) {
try {
$paymentTokenDetails = $this->getTokenDetails($result['response']);
} catch (\Exception $ex) {
Expand All @@ -115,14 +115,14 @@ public function execute(array $commandSubject)
$paymentToken->setType(\Magento\Vault\Api\Data\PaymentTokenFactoryInterface::TOKEN_TYPE_CREDIT_CARD);
$paymentToken->setTokenDetails($this->json->serialize($paymentTokenDetails));
$paymentToken->setExpiresAt(new \DateTime($result['response']['card_expiry']));
$paymentToken->setGatewayToken($pmntsToken);
$paymentToken->setGatewayToken($fatzebraToken);
/** @var \Magento\Sales\Api\Data\OrderPaymentExtension $extension */
$paymentExtension = $this->paymentExtensionInterfaceFactory->create();
$paymentExtension->setVaultPaymentToken($paymentToken);
$payment->setExtensionAttributes($paymentExtension);
} else {
// If the customer has not opted into the token storage, do not persist it to the database
$payment->unsAdditionalInformation('pmnts_token');
$payment->unsAdditionalInformation('fatzebra_token');
}
}

Expand Down
12 changes: 6 additions & 6 deletions Gateway/RefundCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
/**
* Refund command
*
* @category PMNTS
* @package PMNTS_Gateway
* @copyright PMNTS (http://PMNTS.io)
* @category Fat Zebra
* @package FatZebra_Gateway
* @copyright Fat Zebra (https://www.fatzebra.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
namespace PMNTS\Gateway\Gateway;
namespace FatZebra\Gateway\Gateway;

class RefundCommand extends AbstractCommand
{
Expand All @@ -20,11 +20,11 @@ public function execute(array $commandSubject)
{
/** @var \Magento\Sales\Model\Order\Payment $payment */
$payment = $commandSubject['payment']->getPayment();
/** @var \PMNTS\Gateway\Model\Gateway $gateway */
/** @var \FatZebra\Gateway\Model\Gateway $gateway */
$gateway = $this->getGateway($payment->getOrder()->getStoreId());
// At this point, we don't have a CreditMemo increment ID, so append a timestamp to ensure uniqueness in the event
// of multiple refunds against a single invoice.
$reference = $this->pmntsHelper->getOrderReference($payment->getOrder()) . '-R-' . (new \DateTime())->format('ymdhi');
$reference = $this->fatzebaHelper->getOrderReference($payment->getOrder()) . '-R-' . (new \DateTime())->format('ymdhi');
$response = $gateway->refund($payment->getLastTransId(), $commandSubject['amount'], $reference);
if (is_array($response) && array_key_exists('successful', $response)) {
if ($response['successful'] === true) {
Expand Down
24 changes: 12 additions & 12 deletions Gateway/VaultCaptureCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
/**
* Vault capture command
*
* @category PMNTS
* @package PMNTS_Gateway
* @copyright PMNTS (http://PMNTS.io)
* @category Fat Zebra
* @package FatZebra_Gateway
* @copyright Fat Zebra (https://www.fatzebra.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
namespace PMNTS\Gateway\Gateway;
namespace FatZebra\Gateway\Gateway;

use Psr\Log\LoggerInterface;

Expand All @@ -22,19 +22,19 @@ class VaultCaptureCommand extends AbstractCommand
/**
* VaultCaptureCommand constructor.
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \PMNTS\Gateway\Helper\Data $pmntsHelper
* @param \PMNTS\Gateway\Model\GatewayFactory $gatewayFactory
* @param \FatZebra\Gateway\Helper\Data $fatzebraHelper
* @param \FatZebra\Gateway\Model\GatewayFactory $gatewayFactory
* @param LoggerInterface $logger
* @param \Magento\Vault\Api\PaymentTokenManagementInterface $tokenManagement
*/
public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\PMNTS\Gateway\Helper\Data $pmntsHelper,
\PMNTS\Gateway\Model\GatewayFactory $gatewayFactory,
\FatZebra\Gateway\Helper\Data $fatzebraHelper,
\FatZebra\Gateway\Model\GatewayFactory $gatewayFactory,
\Psr\Log\LoggerInterface $logger,
\Magento\Vault\Api\PaymentTokenManagementInterface $tokenManagement
) {
parent::__construct($scopeConfig, $pmntsHelper, $gatewayFactory, $logger);
parent::__construct($scopeConfig, $fatzebraHelper, $gatewayFactory, $logger);
$this->tokenManagement = $tokenManagement;
}

Expand Down Expand Up @@ -63,14 +63,14 @@ public function execute(array $commandSubject)
);

if ($token) {
/** @var \PMNTS\Gateway\Model\Gateway $gateway */
/** @var \FatZebra\Gateway\Model\Gateway $gateway */
$gateway = $this->getGateway($storeId);
$fraudData = $this->pmntsHelper->buildFraudPayload($order);
$fraudData = $this->fatzebraHelper->buildFraudPayload($order);

$result = $gateway->token_purchase(
$token->getGatewayToken(),
$commandSubject['amount'],
$this->pmntsHelper->getOrderReference($order),
$this->fatzebraHelper->getOrderReference($order),
null,
$fraudData
);
Expand Down
16 changes: 8 additions & 8 deletions Helper/Data.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php
namespace PMNTS\Gateway\Helper;
namespace FatZebra\Gateway\Helper;

class Data extends \Magento\Framework\App\Helper\AbstractHelper
{
const METHOD_CODE = 'pmnts_gateway';
const VAULT_METHOD_CODE = 'pmnts_gateway_vault';
const METHOD_CODE = 'fatzebra_gateway';
const VAULT_METHOD_CODE = 'fatzebra_gateway_vault';

const CONFIG_PATH_PMNTS_USERNAME = 'payment/pmnts_gateway/username';
const CONFIG_PATH_PMNTS_TOKEN = 'payment/pmnts_gateway/token';
const CONFIG_PATH_PMNTS_SANDBOX = 'payment/pmnts_gateway/sandbox_mode';
const CONFIG_PATH_FATZEBRA_USERNAME = 'payment/fatzebra_gateway/username';
const CONFIG_PATH_FATZEBRA_TOKEN = 'payment/fatzebra_gateway/token';
const CONFIG_PATH_FATZEBRA_SANDBOX = 'payment/fatzebra_gateway/sandbox_mode';


const RE_ANS = "/[^A-Z\d\-_',\.;:\s]*/i";
Expand Down Expand Up @@ -137,7 +137,7 @@ public function buildFraudPayload($order)
"id" => $this->cleanForFraud($customerId, self::RE_ANS, 16),
"post_code" => $this->cleanForFraud($billing->getPostcode(), self::RE_AN, 9)
],
"device_id" => $payment->getAdditionalInformation('pmnts_device_id'),
"device_id" => $payment->getAdditionalInformation('pmmts_device_id'),
"items" => $orderItems,
"recipients" => [
[
Expand Down Expand Up @@ -252,6 +252,6 @@ public function getFraudShippingMethod($order)

protected function getConfigData($field, $storeId = 0)
{
return $this->scopeConfig->getValue('payment/pmnts_gateway/' . $field, 'stores', $storeId);
return $this->scopeConfig->getValue('payment/fatzebra_gateway/' . $field, 'stores', $storeId);
}
}
22 changes: 11 additions & 11 deletions Model/Config/PmntsConfigProvider.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

namespace PMNTS\Gateway\Model\Config;
namespace FatZebra\Gateway\Model\Config;

use Magento\Checkout\Model\ConfigProviderInterface;

class PmntsConfigProvider implements ConfigProviderInterface
class FatZebraConfigProvider implements ConfigProviderInterface
{

/** @var string */
protected $methodCode = \PMNTS\Gateway\Helper\Data::METHOD_CODE;
protected $methodCode = \FatZebra\Gateway\Helper\Data::METHOD_CODE;

/** @var \Magento\Payment\Model\MethodInterface */
protected $method;
Expand Down Expand Up @@ -48,13 +48,13 @@ public function getConfig()
{
$config = [
'payment' => [
'pmntsGateway' => [
'FatZebraGateway' => [
'iframeSrc' => $this->getIframeSrc(),
'fraudFingerprintSrc' => $this->getFraudFingerprintSource(),
'isSandbox' => $this->getIsSandbox(),
'canSaveCard' => $this->canSaveCard(),
'customerHasSavedCC' => $this->customerHasSavedCC(),
'ccVaultCode' => \PMNTS\Gateway\Helper\Data::VAULT_METHOD_CODE
'ccVaultCode' => \FatZebra\Gateway\Helper\Data::VAULT_METHOD_CODE
]
]
];
Expand All @@ -71,9 +71,9 @@ private function getFraudFingerprintSource()
$is_sandbox = $this->getConfigValue("sandbox_mode");
$username = $this->getConfigValue("username");
if ($is_sandbox) {
return "https://gateway.pmnts-sandbox.io/fraud/fingerprint/{$username}.js";
return "https://gateway.FatZebra-sandbox.io/fraud/fingerprint/{$username}.js";
} else {
return "https://gateway.pmnts.io/fraud/fingerprint/{$username}.js";
return "https://gateway.FatZebra.io/fraud/fingerprint/{$username}.js";
}
}

Expand All @@ -86,9 +86,9 @@ private function getIframeSrc()
$hash_payload = "{$nonce}:1.0:AUD";
$hash = hash_hmac("md5", $hash_payload, $shared_secret);

$base_url = "https://paynow.pmnts.io";
$base_url = "https://paynow.FatZebra.io";
if ($is_sandbox) {
$base_url = "https://paynow.pmnts-sandbox.io";
$base_url = "https://paynow.FatZebra-sandbox.io";
}

$url = "{$base_url}/v2/{$username}/{$nonce}/AUD/1.0/{$hash}?show_extras=false&show_email=false&iframe=true&paypal=false&tokenize_only=true&masterpass=false&visacheckout=false&hide_button=true&postmessage=true&return_target=_self&ajax=true";
Expand All @@ -113,7 +113,7 @@ private function getIsSandbox()
private function canSaveCard()
{
$customer = $this->currentCustomer->getCustomerId();
return !is_null($customer) && $this->scopeConfig->getValue('payment/pmnts_gateway_vault/active', 'stores');
return !is_null($customer) && $this->scopeConfig->getValue('payment/fatzebra_gateway_vault/active', 'stores');
}

private function customerHasSavedCC()
Expand All @@ -129,7 +129,7 @@ private function customerHasSavedCC()
}
$tokens = $this->paymentTokenManagement->getVisibleAvailableTokens($customerId);
foreach ($tokens as $token) {
if ($token->getPaymentMethodCode() === \PMNTS\Gateway\Helper\Data::METHOD_CODE) {
if ($token->getPaymentMethodCode() === \FatZebra\Gateway\Helper\Data::METHOD_CODE) {
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Model/Config/Source/Order/Status/Pendingpayment.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace PMNTS\Gateway\Model\Config\Source\Order\Status;
namespace FatZebra\Gateway\Model\Config\Source\Order\Status;

use Magento\Sales\Model\Order;
use Magento\Sales\Model\Config\Source\Order\Status;
Expand Down
Loading

0 comments on commit 8147d7d

Please sign in to comment.