Skip to content

Commit

Permalink
Paymill changes toupload (#4)
Browse files Browse the repository at this point in the history
* Updated README.md

* Fix bugs, Magento 2 marketplace compatible
  • Loading branch information
RidiQirici authored and ekarakashi committed Feb 22, 2017
1 parent 85ddd23 commit b143ed7
Show file tree
Hide file tree
Showing 15 changed files with 40 additions and 92 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ PAYMILL-Magento-2 Extension for credit card and direct debit payments (beta)
PAYMILL extension for Magento 2 compatible with: 2.0.x, 2.1.x (tested for 2.2.0). This extension installs two payment methods: Credit card and direct debit.

##### Note: This is an all new version of the PAYMILL Magento 2 Extension.
This extension is fully and actively maintained by Paymill Official Partner [IMB sh.p.k](http://www.imb.al/en/)(contact mailto:[email protected]).
This extension is fully and actively maintained by Paymill Official Partner [IMB sh.p.k](http://www.imb.al/en/) [contact](mailto:[email protected]).

## Your Advantages
* PCI DSS compatibility
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function execute ()

$this->messageManager->addSuccess(
__("paymill_hook_action_success"));
} catch (Exception $e) {
} catch (\Paymill\Paymill\Services\Exception $e) {
$this->messageManager->addError($e->getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function execute ()
}
$this->messageManager->addSuccess(
__("paymill_log_action_success"));
} catch (Exception $e) {
} catch (\Paymill\Paymill\Services\Exception $e) {
$this->messageManager->addError($e->getMessage());
}
}
Expand Down
3 changes: 1 addition & 2 deletions app/code/Paymill/Paymill/Controller/Token/Total.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ public function __construct (\Magento\Framework\App\Action\Context $context,
}

public function execute ()
{
echo $this->paymillPaymentHelperHelper->getAmount();
{
}

}
5 changes: 3 additions & 2 deletions app/code/Paymill/Paymill/Helper/LoggingHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ public function log ($merchantInfo, $devInfo = null, $devInfoAdditional = null)
* @return Collection Description
*/
public function getEntries ()
{
$collection = Mage::getModel('paymill/log');
{
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$collection = $objectManager->get('paymill/log');
return $collection;
}

Expand Down
8 changes: 4 additions & 4 deletions app/code/Paymill/Paymill/Helper/RefundHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function createRefund ($creditmemo, $payment)
$refundsObject = new \Paymill\Paymill\Services\Refunds(
$this->paymillOptionHelperHelper->getPrivateKey(),
$this->paymillHelper->getApiUrl());
} catch (Exception $ex) {
} catch (\Paymill\Paymill\Services\Exception $ex) {
$this->paymillLoggingHelperHelper->log(
"No Refund created due to illegal parameters.",
$ex->getMessage());
Expand All @@ -138,7 +138,7 @@ public function createRefund ($creditmemo, $payment)

try {
$refund = $refundsObject->create($params);
} catch (Exception $ex) {
} catch (\Paymill\Paymill\Services\Exception $ex) {
$this->paymillLoggingHelperHelper->log("No Refund created.",
$ex->getMessage(), var_export($params, true));
return false;
Expand All @@ -151,8 +151,8 @@ public function createRefund ($creditmemo, $payment)
public function creditmemo (\Magento\Sales\Model\Order $order, $refundId)
{
if ($order->canCreditmemo()) {

$service = Mage::getModel('sales/service_order', $order);
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$service = $objectManager->get('sales/service_order', $order);
$creditmemo = $service->prepareCreditmemo();

$creditmemo->setOfflineRequested(true);
Expand Down
18 changes: 17 additions & 1 deletion app/code/Paymill/Paymill/Model/PaymillConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
use Magento\Framework\View\Asset\Repository;
use Paymill\Paymill\Helper\OptionHelper;
use Magento\Framework\App\RequestInterface;
use Paymill\Paymill\Helper\PaymentHelper as PaymentHelperTotal;


class PaymillConfigProvider implements ConfigProviderInterface
{
Expand All @@ -39,6 +41,12 @@ class PaymillConfigProvider implements ConfigProviderInterface
*/
protected $request;

/**
*
* @var \Paymill\Paymill\Helper\PaymentHelper
*/
protected $paymillPaymentHelperHelper;

/**
*
* @var \Paymill\Paymill\Helper\OptionHelper
Expand Down Expand Up @@ -92,13 +100,15 @@ class PaymillConfigProvider implements ConfigProviderInterface
public function __construct (PaymentHelper $paymentHelper, Escaper $escaper,
PaymentConfig $paymentConfig, UrlInterface $urlBuilder,
Repository $assetRepo, OptionHelper $paymillOptionHelperHelper,
PaymentHelperTotal $paymillPaymentHelperHelper,
RequestInterface $request)
{
$this->escaper = $escaper;
$this->config = $paymentConfig;
$this->urlBuilder = $urlBuilder;
$this->assetRepo = $assetRepo;
$this->paymillOptionHelperHelper = $paymillOptionHelperHelper;
$this->paymillPaymentHelperHelper = $paymillPaymentHelperHelper;
$this->request = $request;
foreach ($this->methodCodes as $code) {
$this->methods[$code] = $paymentHelper->getMethodInstance($code);
Expand Down Expand Up @@ -151,6 +161,7 @@ public function getConfig ()
$config['payment']['getPaymillCcYears'][$code] = $this->getPaymillCcYears(
$code);
$config['payment']['getTokenUrl'][$code] = $this->getTokenUrl();
$config['payment']['getPaymentTotal'][$code] = $this->getPaymentTotal();
$config['payment']['getCurrency'][$code] = $this->getCurrency(
$code);
$config['payment']['getCustomerEmail'][$code] = $this->getCustomerEmail(
Expand Down Expand Up @@ -223,6 +234,11 @@ private function getCustomerEmail ($method)
return $this->methods[$method]->getCustomerEmail();
}

private function getPaymentTotal()
{
return $this->paymillPaymentHelperHelper->getAmount();
}

/**
* Retrieve credit card expire months
*
Expand Down Expand Up @@ -317,7 +333,7 @@ public function getViewFileUrl($fileId, array $params = [])
try {
$params = array_merge(['_secure' => $this->request->isSecure()], $params);
return $this->assetRepo->getUrlWithParams($fileId, $params);
} catch (LocalizedException $e) {
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->logger->critical($e);
return $this->urlBuilder->getUrl('', ['_direct' => 'core/index/notFound']);
}
Expand Down
1 change: 0 additions & 1 deletion app/code/Paymill/Paymill/Setup/InstallSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,3 @@ public function install (SchemaSetupInterface $setup,
}

}
?>

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

42 changes: 4 additions & 38 deletions app/code/Paymill/Paymill/view/frontend/web/js/Creditcard.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ define(
}

return {
amount_int : parseInt(this.getTokenAmount()),
amount_int : parseInt(this.helper
.getElementValue('paymill-payment-total-log-cc')),
currency : this.helper
.getElementValue('.paymill-payment-currency-cc'),
number : this.helper
Expand All @@ -265,48 +266,13 @@ define(
};
},

getTokenAmount : function() {
var that = this;
var returnVal = null;

new Ajax.Request(
this.helper
.getElementValue('.paymill-payment-token-url-cc'),
{
asynchronous : false,
parameters : {
form_key : $.cookie('form_key')
},
onSuccess : function(response) {
returnVal = response.transport.responseText;
},
onFailure : function() {
Object
.extend(
Validation.methods,
{
'paymill-validate-cc-token' : new Validator(
'paymill-validate-cc-token',
that.helper
.getElementValue('.paymill-payment-error-cc-token')
+ " Amount not accessable.",
function(value) {
return value !== '';
}, '')
});
}

});

return returnVal;
},

getFrameTokenParameter : function() {
PAYMILL_PUBLIC_KEY = this.helper
.getElementValue('.paymill-info-public_key-cc');

return {
amount_int : parseInt(this.getTokenAmount()),
amount_int : parseInt(this.helper
.getElementValue('paymill-payment-total-log-cc')),
currency : this.helper
.getElementValue('.paymill-payment-currency-cc'),
email : this.helper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,16 @@ define(
.getCode()];
},

getPaymentTotal : function() {
return window.checkoutConfig.payment.getPaymentTotal[this
.getCode()];
},

getTokenLog : function() {
return window.checkoutConfig.payment.getTokenLog[this
.getCode()];
},

getCvvImageUrl : function() {
return window.checkoutConfig.payment.getCvvImageUrl[this
.getCode()];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@
data-bind="value: getTokenUrl()" /> <input
class="paymill-payment-token-log-cc" type="hidden"
data-bind="value: getTokenLog()" /> <input
class="paymill-payment-total-cc" type="hidden"
data-bind="value: getPaymentTotal()" /> <input
class="paymill-payment-currency-cc" type="hidden"
data-bind="value: getCurrency()" /> <input
class="paymill-payment-customer-email-cc" type="hidden"
Expand Down

0 comments on commit b143ed7

Please sign in to comment.