Skip to content

Commit

Permalink
Merge pull request #1 from aligent/feedback-updates
Browse files Browse the repository at this point in the history
Feedback updates
  • Loading branch information
phirunson authored Dec 22, 2016
2 parents f3be00a + b52c4fe commit 448d9db
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 29 deletions.
10 changes: 0 additions & 10 deletions Block/Form.php

This file was deleted.

2 changes: 0 additions & 2 deletions Model/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@ class ConfigProvider implements \Magento\Checkout\Model\ConfigProviderInterface
* @param RequestInterface $request
* @param UrlInterface $urlBuilder
* @param PaymentHelper $paymentHelper
* @param PinPayment $paymentMethod
* @param $methodCode
*/
public function __construct(
RequestInterface $request,
UrlInterface $urlBuilder,
PaymentHelper $paymentHelper,
PinPayment $paymentMethod,
$methodCode
) {
$this->request = $request;
Expand Down
29 changes: 13 additions & 16 deletions Model/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class Payment implements MethodInterface
*/
protected $_logger;


/**
* Payment constructor.
* @param ScopeConfigInterface $scopeConfigInterface
Expand Down Expand Up @@ -122,6 +121,7 @@ public function setStore($storeId)
public function getStore()
{
// TODO: Implement getStore() method.
return \Magento\Store\Model\Store::DEFAULT_STORE_ID;
}

/**
Expand Down Expand Up @@ -213,6 +213,7 @@ public function canUseCheckout()
public function canEdit()
{
// TODO: Implement canEdit() method.
return false;
}

/**
Expand All @@ -221,6 +222,7 @@ public function canEdit()
public function canFetchTransactionInfo()
{
// TODO: Implement canFetchTransactionInfo() method.
return true;
}

/**
Expand Down Expand Up @@ -305,6 +307,7 @@ public function setInfoInstance(InfoInterface $info)
public function validate()
{
// TODO: Implement validate()
return $this;
}

/**
Expand All @@ -328,13 +331,12 @@ public function getClient($payment, $order, $amount, $transactionType = self::RE
$endpoint = $this->getPaymentUrl() . 'charges';
$method = \Zend_Http_Client::POST;

if($transactionType === self::REQUEST_TYPE_CAPTURE_ONLY)
{
if ($transactionType === self::REQUEST_TYPE_CAPTURE_ONLY) {
$endpoint .= '/' . $payment->getCcTransId() . '/capture';
$method = \Zend_Http_Client::PUT;
}

$client->setAuth($this->getConfigData('secret_key'), $order->getStoreId());
$client->setAuth($this->getConfigData('secret_key', $order->getStoreId()));
$client->setConfig(['maxredirects' => 0, 'timeout' => 30]);
$client->setUri($endpoint);
$client->setMethod($method);
Expand All @@ -343,11 +345,9 @@ public function getClient($payment, $order, $amount, $transactionType = self::RE
* A capture-only request requires amount value as the only parameter.
* Note: the charge token is part of the URL.
*/
if($transactionType === self::REQUEST_TYPE_CAPTURE_ONLY)
{
$data = ['amount' => $this->_pinHelper->getRequestAmount($order->getBaseCurrencyCode(),$amount)];
}
else{
if ($transactionType === self::REQUEST_TYPE_CAPTURE_ONLY) {
$data = ['amount' => $this->_pinHelper->getRequestAmount($order->getBaseCurrencyCode(), $amount)];
} else {
$capture = $transactionType === self::REQUEST_TYPE_AUTH_CAPTURE;
$data = $this->_buildAuthRequest($order, $payment, $amount, $capture);
}
Expand Down Expand Up @@ -403,8 +403,7 @@ public function capture(\Magento\Payment\Model\InfoInterface $payment, $amount)
$order = $payment->getOrder();

$transactionType = self::REQUEST_TYPE_AUTH_CAPTURE;
if($payment->getCcTransId())
{
if ($payment->getCcTransId()) {
$transactionType = self::REQUEST_TYPE_CAPTURE_ONLY;
}
$client = $this->getClient($payment, $order, $amount, $transactionType);
Expand All @@ -431,8 +430,7 @@ protected function _handleResponse($response, $payment)
*/
$result = new Result($response);
$error = $result->getError();
if ($result->isSuccess())
{
if ($result->isSuccess()) {
$payment->setCcTransId($result->getToken());
$payment->setTransactionId($result->getToken());
} elseif ($error) {
Expand All @@ -450,10 +448,9 @@ protected function _handleResponse($response, $payment)
protected function _buildAuthRequest($order, $payment, $amount, $capture = true)
{
$descPrefix = $this->getConfigData('description_prefix', $order->getStoreId());
if(is_null($descPrefix)) {
if (is_null($descPrefix)) {
$descPrefix = '';
}
else{
} else {
$descPrefix = $descPrefix . ' ';
}
return [
Expand Down
3 changes: 2 additions & 1 deletion etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
<field id="publishable_key" translate="label" type="text" sortOrder="8" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Publishable Key</label>
</field>
<field id="secret_key" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="secret_key" translate="label" type="obscure" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Secret Key</label>
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
</field>
<field id="payment_action" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Payment Action</label>
Expand Down
1 change: 1 addition & 0 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<active>1</active>
<test_mode>1</test_mode>
<payment_action>authorize_capture</payment_action>
<secret_key backend_model="Magento\Config\Model\Config\Backend\Encrypted"/>
</pinpay>
</payment>
</default>
Expand Down
Empty file removed view/frontend/templates/form.phtml
Empty file.

0 comments on commit 448d9db

Please sign in to comment.