Skip to content
This repository has been archived by the owner on Feb 16, 2022. It is now read-only.

Commit

Permalink
Merge pull request #58 from heidelpay/develop
Browse files Browse the repository at this point in the history
Merge for new release
  • Loading branch information
sixer1182 authored Apr 12, 2018
2 parents 837ed34 + 1b21425 commit 920f301
Show file tree
Hide file tree
Showing 55 changed files with 2,536 additions and 257 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@

This project does not follow a versioning standard. Versions are crafted after the dates; for example, the version 17.7.25 was released on July, 25th in 2017

## 18.4.12

## Added
- BasketApi support in general and activated it for InvoiceSecuredPaymentMethod.
- Basket helper class to provide for general BasketApi support.
- Trait to be able to dump getter results from a class to an array.
- BasketApi integration tests.
- Refactored payment method classes with regards to the payment code.

## Changed
- Refactored configuration reading (heidelpay main and payment specific config) in order to inject it where needed.
- Replaced obsolete PhpApi with PhpPaymentApi.

## Fixed
- Set Order to the correct state when receiving a receipt via push.

## 18.3.1

## Changed
Expand Down
26 changes: 15 additions & 11 deletions Controller/Adminhtml/Order/Shipment/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

namespace Heidelpay\Gateway\Controller\Adminhtml\Order\Shipment;

use Heidelpay\Gateway\Gateway\Config\HgwBasePaymentConfigInterface;
use Heidelpay\Gateway\Gateway\Config\HgwMainConfigInterface;
use Heidelpay\Gateway\PaymentMethods\HeidelpayAbstractPaymentMethod;
use Heidelpay\PhpApi\TransactionTypes\FinalizeTransactionType;
use Heidelpay\PhpPaymentApi\TransactionTypes\FinalizeTransactionType;
use Magento\Sales\Model\Order;

/**
Expand Down Expand Up @@ -95,21 +97,23 @@ public function beforeExecute()

// only fire the shipping when a heidelpay payment method is used.
if ($method instanceof HeidelpayAbstractPaymentMethod) {
// get the php-api instance.
// get the php-payment-api instance.
$heidelpayMethod = $method->getHeidelpayPaymentMethodInstance();

// if the payment method uses the Finalize Transaction type, we'll send a FIN request to the payment api.
if (in_array(FinalizeTransactionType::class, class_uses($heidelpayMethod))) {
// get the heidelpay configuration for the given payment method and store.
$paymentConfig = $method->getMainConfig($method->getCode(), $method->getStore());
/** @var HgwMainConfigInterface $mainConfig */
$mainConfig = $method->getMainConfig();

/** @var HgwBasePaymentConfigInterface $methodConfig */
$methodConfig = $method->getConfig();

// set the authentification data
$heidelpayMethod->getRequest()->authentification(
$paymentConfig['SECURITY.SENDER'],
$paymentConfig['USER.LOGIN'],
$paymentConfig['USER.PWD'],
$paymentConfig['TRANSACTION.CHANNEL'],
$paymentConfig['TRANSACTION.MODE']
$mainConfig->getSecuritySender(),
$mainConfig->getUserLogin(),
$mainConfig->getUserPasswd(),
$methodConfig->getChannel(),
$mainConfig->isSandboxModeActive()
);

// set the basket data (for amount and currency and a secret hash for fraud checking)
Expand All @@ -121,7 +125,7 @@ public function beforeExecute()
);

// send the finalize request
/** @var \Heidelpay\PhpApi\Response $response */
/** @var \Heidelpay\PhpPaymentApi\Response $response */
$heidelpayMethod->finalize($order->getPayment()->getLastTransId());

// if the response isn't successful, redirect back to the order view.
Expand Down
2 changes: 1 addition & 1 deletion Controller/Index/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function execute()
$payment = $quote->getPayment()->getMethodInstance();

// get the response object from the initial request.
/** @var \Heidelpay\PhpApi\Response $response */
/** @var \Heidelpay\PhpPaymentApi\Response $response */
$response = $payment->getHeidelpayUrl($quote);

$this->_logger->debug('Heidelpay init respose : ' . print_r($response, 1));
Expand Down
8 changes: 4 additions & 4 deletions Controller/Index/Push.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Push extends \Heidelpay\Gateway\Controller\HgwAbstract
protected $order;

/**
* @var \Heidelpay\PhpApi\Push
* @var \Heidelpay\PhpPaymentApi\Push
*/
protected $heidelpayPush;

Expand Down Expand Up @@ -71,7 +71,7 @@ class Push extends \Heidelpay\Gateway\Controller\HgwAbstract
* @param \Magento\Customer\Model\Url $customerUrl
* @param OrderRepository $orderRepository
* @param \Magento\Sales\Api\Data\OrderInterface $order
* @param \Heidelpay\PhpApi\Push $heidelpayPush
* @param \Heidelpay\PhpPaymentApi\Push $heidelpayPush
* @param HeidelpayTransactionCollectionFactory $collectionFactory
* @param SearchCriteriaBuilder $searchCriteriaBuilder
*/
Expand All @@ -93,7 +93,7 @@ public function __construct(
\Magento\Customer\Model\Url $customerUrl,
OrderRepository $orderRepository,
\Magento\Sales\Api\Data\OrderInterface $order,
\Heidelpay\PhpApi\Push $heidelpayPush,
\Heidelpay\PhpPaymentApi\Push $heidelpayPush,
HeidelpayTransactionCollectionFactory $collectionFactory,
SearchCriteriaBuilder $searchCriteriaBuilder
) {
Expand Down Expand Up @@ -178,7 +178,7 @@ public function execute()
$paidAmount = (float)$this->heidelpayPush->getResponse()->getPresentation()->getAmount();
$dueLeft = (float)($order->getTotalDue() - $paidAmount);

$state = Order::STATE_COMPLETE;
$state = Order::STATE_PROCESSING;
$comment = 'heidelpay - Purchase Complete';

// if payment is not complete
Expand Down
6 changes: 3 additions & 3 deletions Controller/Index/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Redirect extends \Heidelpay\Gateway\Controller\HgwAbstract
protected $resultPageFactory;
protected $logger;

/** @var \Heidelpay\PhpApi\Response The heidelpay response class */
/** @var \Heidelpay\PhpPaymentApi\Response The heidelpay response class */
protected $heidelpayResponse;

/** @var \Heidelpay\Gateway\Model\ResourceModel\Transaction\CollectionFactory */
Expand Down Expand Up @@ -57,7 +57,7 @@ class Redirect extends \Heidelpay\Gateway\Controller\HgwAbstract
* @param OrderCommentSender $orderCommentSender
* @param \Magento\Framework\Encryption\Encryptor $encryptor
* @param \Magento\Customer\Model\Url $customerUrl
* @param \Heidelpay\PhpApi\Response $heidelpayResponse
* @param \Heidelpay\PhpPaymentApi\Response $heidelpayResponse
* @param \Heidelpay\Gateway\Model\ResourceModel\Transaction\CollectionFactory $transactionCollectionFactory
*/
public function __construct(
Expand All @@ -77,7 +77,7 @@ public function __construct(
OrderCommentSender $orderCommentSender,
\Magento\Framework\Encryption\Encryptor $encryptor,
\Magento\Customer\Model\Url $customerUrl,
\Heidelpay\PhpApi\Response $heidelpayResponse,
\Heidelpay\PhpPaymentApi\Response $heidelpayResponse,
\Heidelpay\Gateway\Model\ResourceModel\Transaction\CollectionFactory $transactionCollectionFactory
) {
parent::__construct(
Expand Down
8 changes: 4 additions & 4 deletions Controller/Index/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Heidelpay\Gateway\Helper\Payment as HeidelpayHelper;
use Heidelpay\Gateway\Model\ResourceModel\PaymentInformation\CollectionFactory as PaymentInformationCollectionFactory;
use Heidelpay\PhpApi\Exceptions\HashVerificationException;
use Heidelpay\PhpPaymentApi\Exceptions\HashVerificationException;
use Magento\Sales\Model\Order\Email\Sender\InvoiceSender;
use Magento\Sales\Model\Order\Email\Sender\OrderCommentSender;
use Magento\Sales\Model\Order\Email\Sender\OrderSender;
Expand Down Expand Up @@ -42,7 +42,7 @@ class Response extends \Heidelpay\Gateway\Controller\HgwAbstract
/** @var \Magento\Framework\Controller\Result\RawFactory */
protected $resultFactory;

/** @var \Heidelpay\PhpApi\Response The heidelpay response object */
/** @var \Heidelpay\PhpPaymentApi\Response The heidelpay response object */
protected $heidelpayResponse;

/** @var \Heidelpay\Gateway\Model\TransactionFactory */
Expand Down Expand Up @@ -71,7 +71,7 @@ class Response extends \Heidelpay\Gateway\Controller\HgwAbstract
* @param \Magento\Customer\Model\Url $customerUrl
* @param \Magento\Framework\Controller\Result\RawFactory $rawResultFactory
* @param \Magento\Quote\Model\QuoteRepository $quoteRepository
* @param \Heidelpay\PhpApi\Response $heidelpayResponse
* @param \Heidelpay\PhpPaymentApi\Response $heidelpayResponse
* @param PaymentInformationCollectionFactory $paymentInformationCollectionFactory,
* @param \Heidelpay\Gateway\Model\TransactionFactory $transactionFactory
*/
Expand All @@ -93,7 +93,7 @@ public function __construct(
\Magento\Customer\Model\Url $customerUrl,
\Magento\Framework\Controller\Result\RawFactory $rawResultFactory,
\Magento\Quote\Model\QuoteRepository $quoteRepository,
\Heidelpay\PhpApi\Response $heidelpayResponse,
\Heidelpay\PhpPaymentApi\Response $heidelpayResponse,
PaymentInformationCollectionFactory $paymentInformationCollectionFactory,
\Heidelpay\Gateway\Model\TransactionFactory $transactionFactory
) {
Expand Down
122 changes: 122 additions & 0 deletions Gateway/Config/HgwBasePaymentConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<?php
/**
* Payment config representation handling the parameters every payment method has.
*
* @license Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
* @copyright Copyright © 2016-present heidelpay GmbH. All rights reserved.
*
* @link http://dev.heidelpay.com/
*
* @author Simon Gabriel <[email protected]>
*
* @package heidelpay/magento2
*/
namespace Heidelpay\Gateway\Gateway\Config;

use Heidelpay\Gateway\Traits\DumpGetterReturnsTrait;
use \Magento\Payment\Gateway\Config\Config as BaseConfig;

class HgwBasePaymentConfig extends BaseConfig implements HgwBasePaymentConfigInterface
{
use DumpGetterReturnsTrait;

const KEY_ACTIVE = 'active';
const KEY_CHANNEL = 'channel';
const KEY_ALLOW_SPECIFIC = 'allowspecific';
const KEY_SPECIFIC = 'specificcountry';
const KEY_RECOGNITION = 'recognition';
const KEY_MIN_ORDER_TOTAL = 'min_order_total';
const KEY_MAX_ORDER_TOTAL = 'max_order_total';
const KEY_NEEDS_EXTERNAL_INFO_IN_CHECKOUT = 'needs_external_info_in_checkout';
const KEY_BOOKING_MODE = 'bookingmode';

const VALUE_ALL_COUNTRIES = 0;
const VALUE_SPECIFIC_COUNTRIES = 1;

/**
* Get payment configuration status
*
* @return bool
*/
public function isActive()
{
return (bool) $this->getValue(self::KEY_ACTIVE);
}

/**
* Get payment channel id.
*
* @return string
*/
public function getChannel()
{
return $this->getValue(self::KEY_CHANNEL);
}

/**
* Get allow specific flag
*
* @return int
*/
public function getAllowSpecific()
{
return (int) $this->getValue(self::KEY_ALLOW_SPECIFIC);
}

/**
* Get allowed countries
*
* @return array
*/
public function getSpecificCountries()
{
if ($this->getAllowSpecific() === self::VALUE_ALL_COUNTRIES) {
return [];
}

return explode(',', $this->getValue(self::KEY_SPECIFIC));
}

/** todo-simon: is this int or float? */
/**
* Get the minimum amount the total has to be in order to make this payment method available.
*
* @return int
*/
public function getMinOrderTotal()
{
return (int) $this->getValue(self::KEY_MIN_ORDER_TOTAL);
}

/* todo-simon: is this int or float? */
/**
* Get the maximum amount the total has to be in order to make this payment method available.
*
* @return int
*/
public function getMaxOrderTotal()
{
return (int) $this->getValue(self::KEY_MAX_ORDER_TOTAL);
}

/**
* Returns true if the payment method needs to be initialized to be rendered due to additional text
* to be output in the payment form.
*
* @return bool
*/
public function getNeedsExternalInfoInCheckout()
{
return (bool) $this->getValue(self::KEY_NEEDS_EXTERNAL_INFO_IN_CHECKOUT);
}

/**
* Get the configured booking mode e.g. authorize, debit,...
*
* @return int
*/
public function getBookingMode()
{
return $this->getValue(self::KEY_BOOKING_MODE);
}
}
74 changes: 74 additions & 0 deletions Gateway/Config/HgwBasePaymentConfigInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php
/**
* Interface for the payment config representation handling the parameters every payment method has.
*
* @license Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
* @copyright Copyright © 2016-present heidelpay GmbH. All rights reserved.
*
* @link http://dev.heidelpay.com/
*
* @author Simon Gabriel <[email protected]>
*
* @package heidelpay/magento2
*/
namespace Heidelpay\Gateway\Gateway\Config;

interface HgwBasePaymentConfigInterface
{
/**
* Get payment configuration status
*
* @return bool
*/
public function isActive();

/**
* Get payment channel id.
*
* @return string
*/
public function getChannel();

/**
* Get allow specific flag
*
* @return int
*/
public function getAllowSpecific();

/**
* Get allowed countries
*
* @return array
*/
public function getSpecificCountries();

/**
* Get the minimum amount the total has to be in order to make this payment method available.
*
* @return int
*/
public function getMinOrderTotal();

/**
* Get the maximum amount the total has to be in order to make this payment method available.
*
* @return int
*/
public function getMaxOrderTotal();

/**
* Returns true if the payment method needs to be initialized to be rendered due to additional text
* to be output in the payment form.
*
* @return bool
*/
public function getNeedsExternalInfoInCheckout();

/**
* Get the configured booking mode e.g. authorize, debit,...
*
* @return int
*/
public function getBookingMode();
}
Loading

0 comments on commit 920f301

Please sign in to comment.