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 #21 from heidelpay/develop
Browse files Browse the repository at this point in the history
Release 17.4.16 - Secured Invoice and heidelpay Push notifications
  • Loading branch information
devheidelpay authored Apr 18, 2017
2 parents 8ce35eb + 8e22f3d commit cb32125
Show file tree
Hide file tree
Showing 45 changed files with 1,955 additions and 362 deletions.
8 changes: 6 additions & 2 deletions Api/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,10 @@ public function saveGuestAdditionalPaymentInfo($cartId, $method, $additionalData
/**
* Create a shipping hash.
*
* @param \Magento\Quote\Model\Quote\Address $address
* @param \Magento\Quote\Api\Data\AddressInterface $address
* @return string
*/
private function createShippingHash(\Magento\Quote\Model\Quote\Address $address)
private function createShippingHash(\Magento\Quote\Api\Data\AddressInterface $address)
{
return $this->encryptor->hash(
implode('', [
Expand Down Expand Up @@ -233,6 +233,10 @@ private function getAdditionalDataForPaymentMethod($method, $quote)
$result['hgw_holder'] = $quote->getBillingAddress()->getName(); // full billing name
break;

case 'hgwivs':
$result['hgw_birthdate'] = $quote->getCustomer()->getDob();
break;

default:
$result = null;
break;
Expand Down
4 changes: 2 additions & 2 deletions Api/PaymentInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function getAdditionalPaymentInformation($quoteId, $paymentMethod);
*
* @param int $cartId
* @param string $method The payment method code
* @param mixed $additionalData
* @param string[] $additionalData
* @return string
*/
public function saveAdditionalPaymentInfo($cartId, $method, $additionalData);
Expand All @@ -50,7 +50,7 @@ public function saveAdditionalPaymentInfo($cartId, $method, $additionalData);
*
* @param string $cartId
* @param string $method The payment method code
* @param mixed $additionalData
* @param string[] $additionalData
* @return string
*/
public function saveGuestAdditionalPaymentInfo($cartId, $method, $additionalData);
Expand Down
11 changes: 7 additions & 4 deletions Block/Checkout/Success.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@
*/
class Success extends \Magento\Checkout\Block\Onepage\Success
{
/**
* @return \Magento\Framework\Phrase|null
*/
public function getHeidelpayInfo()
{
$info = ($this->_checkoutSession->getHeidelpayInfo() !== false)
? $this->_checkoutSession->getHeidelpayInfo()
: false;
// get the heidelpay additional information
$info = $this->_checkoutSession->getHeidelpayInfo();

$this->_checkoutSession->setHeidelpayInfo(false);
// clear the additional information
$this->_checkoutSession->setHeidelpayInfo(null);

return $info;
}
Expand Down
247 changes: 247 additions & 0 deletions Block/Info/InvoiceSecured.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
<?php

namespace Heidelpay\Gateway\Block\Info;

use Heidelpay\Gateway\Model\ResourceModel\Transaction\CollectionFactory as HeidelpayTransactionCollectionFactory;
use Heidelpay\Gateway\Model\Transaction;
use Magento\Framework\View\Element\Template;

/**
* Summary
* @license Use of this software requires acceptance of the License Agreement. See LICENSE file.
* @copyright Copyright © 2016-present Heidelberger Payment GmbH. All rights reserved.
* @link https://dev.heidelpay.de/magento2
* @author Stephano Vogel
* @package heidelpay
* @subpackage magento2
* @category magento2
*/
class InvoiceSecured extends \Magento\Payment\Block\Info
{
/** @var HeidelpayTransactionCollectionFactory */
protected $transactionCollectionFactory;

/** @var Transaction */
protected $transactionInfo;

/**
* @var \Heidelpay\Gateway\Helper\Payment
*/
protected $paymentHelper = null;

/**
* @var string
*/
protected $_template = 'Heidelpay_Gateway::info/invoice_secured.phtml';

/**
* InvoiceSecured constructor.
*
* @param Template\Context $context
* @param HeidelpayTransactionCollectionFactory $collectionFactory
* @param \Heidelpay\Gateway\Helper\Payment $paymentHelper
* @param array $data
*/
public function __construct(
Template\Context $context,
HeidelpayTransactionCollectionFactory $collectionFactory,
\Heidelpay\Gateway\Helper\Payment $paymentHelper,
array $data = []
) {
$this->transactionCollectionFactory = $collectionFactory;
$this->paymentHelper = $paymentHelper;

parent::__construct($context, $data);
}

/**
* Returns the Connector Account Holder Name.
*
* @return string
*/
public function getAccountHolder()
{
if ($this->transactionInfo === null) {
$this->loadTransactionInfo();
}

if (isset($this->transactionInfo->getJsonResponse()['CONNECTOR_ACCOUNT_HOLDER'])) {
return $this->transactionInfo->getJsonResponse()['CONNECTOR_ACCOUNT_HOLDER'];
}

return '-';
}

/**
* Returns the Connector Account IBAN.
*
* @return string
*/
public function getAccountIban()
{
if ($this->transactionInfo === null) {
$this->loadTransactionInfo();
}

if (isset($this->transactionInfo->getJsonResponse()['CONNECTOR_ACCOUNT_IBAN'])) {
return $this->transactionInfo->getJsonResponse()['CONNECTOR_ACCOUNT_IBAN'];
}

return '-';
}

/**
* Returns the Connector Account BIC.
*
* @return string
*/
public function getAccountBic()
{
if ($this->transactionInfo === null) {
$this->loadTransactionInfo();
}

if (isset($this->transactionInfo->getJsonResponse()['CONNECTOR_ACCOUNT_BIC'])) {
return $this->transactionInfo->getJsonResponse()['CONNECTOR_ACCOUNT_BIC'];
}

return '-';
}

public function printAdditionalInformationHtml()
{
if ($this->transactionInfo === null) {
$this->loadTransactionInfo();
}

return $this->getMethod()->additionalPaymentInformation($this->transactionInfo->getJsonResponse());
}

/**
* Returns the Customer Birthdate (provided in this order).
*
* @return string
*/
public function getCustomerBirthdate()
{
if (!$this->getIsSecureMode()) {
if ($this->transactionInfo === null) {
$this->loadTransactionInfo();
}

if (isset($this->transactionInfo->getJsonResponse()['NAME_BIRTHDATE'])) {
return $this->transactionInfo->getJsonResponse()['NAME_BIRTHDATE'];
}
}

return '-';
}

/**
* Returns the Customer Salutation (provided in this order).
*
* @return string
*/
public function getCustomerSalutation()
{
if (!$this->getIsSecureMode()) {
if ($this->transactionInfo === null) {
$this->loadTransactionInfo();
}

if (isset($this->transactionInfo->getJsonResponse()['NAME_SALUTATION'])) {
return $this->transactionInfo->getJsonResponse()['NAME_SALUTATION'];
}
}

return '-';
}

/**
* Returns the Short ID for this order/transaction.
*
* @return string
*/
public function getIdentificationNumber()
{
if ($this->transactionInfo === null) {
$this->loadTransactionInfo();
}

if (isset($this->transactionInfo->getJsonResponse()['IDENTIFICATION_SHORTID'])) {
return $this->transactionInfo->getJsonResponse()['IDENTIFICATION_SHORTID'];
}

return '-';
}

/**
* Returns the Amount to be paid.
*
* @return string
*/
public function getPresentationAmount()
{
if ($this->transactionInfo === null) {
$this->loadTransactionInfo();
}

if (isset($this->transactionInfo->getJsonResponse()['PRESENTATION_AMOUNT'])) {
return $this->paymentHelper->format($this->transactionInfo->getJsonResponse()['PRESENTATION_AMOUNT']);
}

return '-';
}

/**
* Returns the Currency of the Amount to be paid.
*
* @return string
*/
public function getPresentationCurrency()
{
if ($this->transactionInfo === null) {
$this->loadTransactionInfo();
}

if (isset($this->transactionInfo->getJsonResponse()['PRESENTATION_CURRENCY'])) {
return $this->transactionInfo->getJsonResponse()['PRESENTATION_CURRENCY'];
}

return '-';
}

/**
* Returns Transaction information, if a transaction ID is set.
*
* @return Transaction|null
*/
public function getTransactionInfo()
{
if ($this->transactionInfo === null) {
$this->loadTransactionInfo();
}

return $this->transactionInfo;
}

/**
* Loads heidelpay transaction details by the last_trans_id of this order.
*/
private function loadTransactionInfo()
{
if ($this->getInfo()->getLastTransId() !== null) {
$factory = $this->transactionCollectionFactory->create();
$this->transactionInfo = $factory->loadByTransactionId($this->getInfo()->getLastTransId());
}
}

/**
* @return string
*/
public function toPdf()
{
$this->setTemplate('Heidelpay_Gateway::info/pdf/invoice_secured.phtml');
return $this->toHtml();
}
}
26 changes: 0 additions & 26 deletions Block/Payment/HgwDirectDebit.php

This file was deleted.

11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Release Notes - heidelpay Payment Gateway for Magento 2

## v17.4.16

### Added
- Secured Invoice (B2C) Payment Method (DE, AT, CH)
- Sending Finalize notifications to heidelpay when Shipment is created (Secured Invoice only)
- Added Push functionality to e.g. receive REC requests for Prepayment and Invoice payment methods

### Changed
- Invoices now contain information about payments (e.g. where to send the amount, in case of Prepayment, Invoice)
- When errors after sending the request or during the redirect are occuring, the customer will be redirected to the checkout/cart instead of seeing a blank page

## v17.3.28

### Added
Expand Down
Loading

0 comments on commit cb32125

Please sign in to comment.