Skip to content

Commit

Permalink
1.5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
zlatinov committed Apr 1, 2019
1 parent b7e13c9 commit 060c1fd
Show file tree
Hide file tree
Showing 89 changed files with 6,122 additions and 350 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ Requirements
------------

* Magento Community Edition > 1.7 (Tested up to: __1.9.3.1__)
* [GenesisPHP v1.8.3](https://github.com/GenesisGateway/genesis_php/releases/tag/1.8.3) - (Integrated in Module)
* [GenesisPHP v1.13.0](https://github.com/GenesisGateway/genesis_php/releases/tag/1.13.0) - (Integrated in Module)
* PCI-certified server in order to use ```emerchantpay Direct```

*Note:* This module has been tested only with Magento __Community Edition__, it may not work
as intended with Magento __Enterprise Edition__

*Note:* If you are using Tokenization with the Checkout module, Guest Checkout must be disabled.

GenesisPHP Requirements
------------

Expand Down Expand Up @@ -90,10 +92,10 @@ Supported Transactions
* __InitRecurringSale__
* __InitRecurringSale (3D-Secure)__
* __Neteller__
* __OnlineBanking__
* __P24__
* __PayPal Express__
* __PaySafeCard__
* __PaySec__
* __PayByVoucher (Sale)__
* __PayByVoucher (oBeP)__
* __POLi__
Expand All @@ -105,7 +107,6 @@ Supported Transactions
* __Przelewy24__
* __Qiwi__
* __SafetyPay__
* __TeleIngreso__
* __TrustPay__
* __RecurringSale__
* __Sale__
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,73 +65,71 @@ public function toOptionArray()
protected function getTransactionTypes()
{
return array(
\Genesis\API\Constants\Transaction\Types::ABNIDEAL =>
\Genesis\API\Constants\Transaction\Types::ABNIDEAL =>
Mage::helper('emerchantpay')->__('ABN iDEAL'),
\Genesis\API\Constants\Transaction\Types::ALIPAY =>
\Genesis\API\Constants\Transaction\Types::ALIPAY =>
Mage::helper('emerchantpay')->__('Alipay'),
\Genesis\API\Constants\Transaction\Types::AUTHORIZE =>
\Genesis\API\Constants\Transaction\Types::AUTHORIZE =>
Mage::helper('emerchantpay')->__('Authorize'),
\Genesis\API\Constants\Transaction\Types::AUTHORIZE_3D =>
\Genesis\API\Constants\Transaction\Types::AUTHORIZE_3D =>
Mage::helper('emerchantpay')->__('Authorize (3D-Secure)'),
\Genesis\API\Constants\Transaction\Types::CASHU =>
\Genesis\API\Constants\Transaction\Types::CASHU =>
Mage::helper('emerchantpay')->__('CashU'),
\Genesis\API\Constants\Transaction\Types::CITADEL_PAYIN =>
\Genesis\API\Constants\Transaction\Types::CITADEL_PAYIN =>
Mage::helper('emerchantpay')->__('Citadel'),
\Genesis\API\Constants\Payment\Methods::EPS =>
\Genesis\API\Constants\Payment\Methods::EPS =>
Mage::helper('emerchantpay')->__('eps'),
\Genesis\API\Constants\Transaction\Types::EZEEWALLET =>
\Genesis\API\Constants\Transaction\Types::EZEEWALLET =>
Mage::helper('emerchantpay')->__('eZeeWallet'),
\Genesis\API\Constants\Payment\Methods::GIRO_PAY =>
\Genesis\API\Constants\Payment\Methods::GIRO_PAY =>
Mage::helper('emerchantpay')->__('GiroPay'),
\Genesis\API\Constants\Transaction\Types::IDEBIT_PAYIN =>
\Genesis\API\Constants\Transaction\Types::IDEBIT_PAYIN =>
Mage::helper('emerchantpay')->__('iDebit'),
\Genesis\API\Constants\Transaction\Types::INPAY =>
\Genesis\API\Constants\Transaction\Types::INPAY =>
Mage::helper('emerchantpay')->__('INPay'),
\Genesis\API\Constants\Transaction\Types::INSTA_DEBIT_PAYIN =>
\Genesis\API\Constants\Transaction\Types::INSTA_DEBIT_PAYIN =>
Mage::helper('emerchantpay')->__('InstaDebit'),
\Genesis\API\Constants\Payment\Methods::BCMC =>
\Genesis\API\Constants\Payment\Methods::BCMC =>
Mage::helper('emerchantpay')->__('Mr.Cash'),
\Genesis\API\Constants\Payment\Methods::MYBANK =>
\Genesis\API\Constants\Payment\Methods::MYBANK =>
Mage::helper('emerchantpay')->__('MyBank'),
\Genesis\API\Constants\Transaction\Types::NETELLER =>
\Genesis\API\Constants\Transaction\Types::NETELLER =>
Mage::helper('emerchantpay')->__('Neteller'),
\Genesis\API\Constants\Transaction\Types::P24 =>
\Genesis\API\Constants\Transaction\Types::ONLINE_BANKING_PAYIN =>
Mage::helper('emerchantpay')->__('OnlineBanking'),
\Genesis\API\Constants\Transaction\Types::P24 =>
Mage::helper('emerchantpay')->__('P24'),
\Genesis\API\Constants\Transaction\Types::PAYSAFECARD =>
\Genesis\API\Constants\Transaction\Types::PAYSAFECARD =>
Mage::helper('emerchantpay')->__('PaySafeCard'),
\Genesis\API\Constants\Transaction\Types::PAYSEC_PAYIN =>
Mage::helper('emerchantpay')->__('PaySec'),
\Genesis\API\Constants\Transaction\Types::PAYBYVOUCHER_SALE =>
\Genesis\API\Constants\Transaction\Types::PAYBYVOUCHER_SALE =>
Mage::helper('emerchantpay')->__('PayByVoucher (Sale)'),
\Genesis\API\Constants\Transaction\Types::PAYBYVOUCHER_YEEPAY =>
\Genesis\API\Constants\Transaction\Types::PAYBYVOUCHER_YEEPAY =>
Mage::helper('emerchantpay')->__('PayByVoucher (oBeP)'),
\Genesis\API\Constants\Transaction\Types::PAYPAL_EXPRESS =>
\Genesis\API\Constants\Transaction\Types::PAYPAL_EXPRESS =>
Mage::helper('emerchantpay')->__('PayPal Express'),
\Genesis\API\Constants\Transaction\Types::POLI =>
\Genesis\API\Constants\Transaction\Types::POLI =>
Mage::helper('emerchantpay')->__('POLi'),
\Genesis\API\Constants\Payment\Methods::PRZELEWY24 =>
\Genesis\API\Constants\Payment\Methods::PRZELEWY24 =>
Mage::helper('emerchantpay')->__('Przelewy24'),
\Genesis\API\Constants\Payment\Methods::QIWI =>
\Genesis\API\Constants\Payment\Methods::QIWI =>
Mage::helper('emerchantpay')->__('Qiwi'),
\Genesis\API\Constants\Payment\Methods::SAFETY_PAY =>
\Genesis\API\Constants\Payment\Methods::SAFETY_PAY =>
Mage::helper('emerchantpay')->__('SafetyPay'),
\Genesis\API\Constants\Transaction\Types::SALE =>
\Genesis\API\Constants\Transaction\Types::SALE =>
Mage::helper('emerchantpay')->__('Sale'),
\Genesis\API\Constants\Transaction\Types::SALE_3D =>
\Genesis\API\Constants\Transaction\Types::SALE_3D =>
Mage::helper('emerchantpay')->__('Sale (3D-Secure)'),
\Genesis\API\Constants\Transaction\Types::SDD_SALE =>
\Genesis\API\Constants\Transaction\Types::SDD_SALE =>
Mage::helper('emerchantpay')->__('Sepa Direct Debit'),
\Genesis\API\Constants\Transaction\Types::SOFORT =>
\Genesis\API\Constants\Transaction\Types::SOFORT =>
Mage::helper('emerchantpay')->__('SOFORT'),
\Genesis\API\Constants\Payment\Methods::TELEINGRESO =>
Mage::helper('emerchantpay')->__('TeleIngreso'),
\Genesis\API\Constants\Transaction\Types::TRUSTLY_SALE =>
\Genesis\API\Constants\Transaction\Types::TRUSTLY_SALE =>
Mage::helper('emerchantpay')->__('Trustly'),
\Genesis\API\Constants\Payment\Methods::TRUST_PAY =>
\Genesis\API\Constants\Payment\Methods::TRUST_PAY =>
Mage::helper('emerchantpay')->__('TrustPay'),
\Genesis\API\Constants\Transaction\Types::WEBMONEY =>
\Genesis\API\Constants\Transaction\Types::WEBMONEY =>
Mage::helper('emerchantpay')->__('WebMoney'),
\Genesis\API\Constants\Transaction\Types::WECHAT =>
\Genesis\API\Constants\Transaction\Types::WECHAT =>
Mage::helper('emerchantpay')->__('WeChat'),
);
}
Expand Down
75 changes: 72 additions & 3 deletions app/code/community/EMerchantPay/Genesis/Model/Checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,15 @@ class EMerchantPay_Genesis_Model_Checkout
{
protected $_code = 'emerchantpay_checkout';

const LOG_FILE_NAME = "emerchantpay_genesis.log";
/**
* Value has to be the same as XML tag in system.xml
*/
const TOKENIZATION_ENABLED_CONFIG_KEY = 'tokenization_enabled';
const LOG_FILE_NAME = 'emerchantpay_genesis.log';
/**
* Value has to be the same as defined in setup class EMerchantPay_Genesis_Model_Resource_Setup
*/
const CONSUMER_ID_DATA_KEY = 'consumer_id';

protected $_formBlockType = 'emerchantpay/form_checkout';
protected $_infoBlockType = 'emerchantpay/info_checkout';
Expand Down Expand Up @@ -120,8 +128,28 @@ public function order(Varien_Object $payment, $amount)

$this->addTransactionTypesToGatewayRequest($genesis, $orderItemsList);

if ($this->isTokenizationEnabled()) {
if (!$this->getHelper()->getCustomerSession()->isLoggedIn()) {
throw new LogicException(
$this->getHelper()->__('You cannot finish the payment as a guest, please login / register.')
);
}

$genesis->request()->setRememberCard(true);

$customer = $this->getCustomerFromOrder($order);
$consumerId = $this->getConsumerIdFromCustomer($customer);
if ($consumerId) {
$genesis->request()->setConsumerId($consumerId);
}
}

$genesis->execute();

if ($this->isTokenizationEnabled() && !empty($genesis->response()->getResponseObject()->consumer_id)) {
$this->setConsumerIdForCustomer($customer, $genesis->response()->getResponseObject()->consumer_id);
}

$payment
->setTransactionId(
$genesis->response()->getResponseObject()->unique_id
Expand All @@ -148,6 +176,49 @@ public function order(Varien_Object $payment, $amount)
return $this;
}

/**
* @return bool
*/
protected function isTokenizationEnabled()
{
return $this->getHelper()->getConfigBoolValue(
$this->_code,
self::TOKENIZATION_ENABLED_CONFIG_KEY
);
}

/**
* @param Mage_Sales_Model_Order $order
*
* @return Mage_Core_Model_Abstract
*/
protected function getCustomerFromOrder(Mage_Sales_Model_Order $order)
{
return Mage::getModel('customer/customer')->load($order->getCustomerId());
}

/**
* @param Mage_Core_Model_Abstract $customer
*
* @return string
*/
protected function getConsumerIdFromCustomer(Mage_Core_Model_Abstract $customer)
{
return $customer->getData(self::CONSUMER_ID_DATA_KEY);
}

/**
* @param Mage_Core_Model_Abstract $customer
* @param string $consumerId
*
* @throws Exception
*/
protected function setConsumerIdForCustomer(Mage_Core_Model_Abstract $customer, $consumerId)
{
$customer->setData(self::CONSUMER_ID_DATA_KEY, $consumerId);
$customer->save();
}

/**
* @param \Genesis\Genesis $genesis
* @param string $orderItemsList
Expand Down Expand Up @@ -865,8 +936,6 @@ public function getTransactionTypes()
\Genesis\API\Constants\Transaction\Types::PPRO,
\Genesis\API\Constants\Payment\Methods::SAFETY_PAY =>
\Genesis\API\Constants\Transaction\Types::PPRO,
\Genesis\API\Constants\Payment\Methods::TELEINGRESO =>
\Genesis\API\Constants\Transaction\Types::PPRO,
\Genesis\API\Constants\Payment\Methods::TRUST_PAY =>
\Genesis\API\Constants\Transaction\Types::PPRO,
\Genesis\API\Constants\Payment\Methods::BCMC =>
Expand Down
26 changes: 26 additions & 0 deletions app/code/community/EMerchantPay/Genesis/Model/Resource/Setup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
/*
* Copyright (C) 2018 emerchantpay Ltd.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* @author emerchantpay
* @copyright 2018 emerchantpay Ltd.
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License, version 2 (GPL-2.0)
*/

/**
* Class EMerchantPay_Genesis_Model_Resources_Setup
*/
class EMerchantPay_Genesis_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
{
const CONSUMER_ID_DATA_KEY = 'consumer_id';
}
24 changes: 23 additions & 1 deletion app/code/community/EMerchantPay/Genesis/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ GNU General Public License for more details.
<config>
<modules>
<EMerchantPay_Genesis>
<version>1.5.1</version>
<version>1.5.2</version>
</EMerchantPay_Genesis>
</modules>

Expand Down Expand Up @@ -66,6 +66,28 @@ GNU General Public License for more details.
</observers>
</sales_quote_address_collect_totals_before>
</events>

<resources>
<EMerchantPay_Genesis_setup>
<setup>
<module>EMerchantPay_Genesis</module>
<class>EMerchantPay_Genesis_Model_Resource_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</EMerchantPay_Genesis_setup>
<EMerchantPay_Genesis_write>
<connection>
<use>core_write</use>
</connection>
</EMerchantPay_Genesis_write>
<EMerchantPay_Genesis_read>
<connection>
<use>core_read</use>
</connection>
</EMerchantPay_Genesis_read>
</resources>

</global>

Expand Down
Loading

0 comments on commit 060c1fd

Please sign in to comment.