Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Adyen Magento2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shared Libs
Adyen Magento2
Commits
aa9e2b6a
Commit
aa9e2b6a
authored
Aug 01, 2016
by
Rik ter Beek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#67 Adyen Pos is now using the Facade implementation
parent
43ca397e
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
414 additions
and
983 deletions
+414
-983
Block/Redirect/Pos.php
Block/Redirect/Pos.php
+177
-15
Gateway/Command/PosCommand.php
Gateway/Command/PosCommand.php
+66
-0
Model/Method/Hpp.php
Model/Method/Hpp.php
+0
-481
Model/Method/Pos.php
Model/Method/Pos.php
+0
-486
Model/Ui/AdyenPosConfigProvider.php
Model/Ui/AdyenPosConfigProvider.php
+105
-0
etc/config.xml
etc/config.xml
+11
-1
etc/di.xml
etc/di.xml
+54
-0
etc/frontend/di.xml
etc/frontend/di.xml
+1
-0
No files found.
Block/Redirect/Pos.php
View file @
aa9e2b6a
...
@@ -39,6 +39,17 @@ class Pos extends \Magento\Payment\Block\Form
...
@@ -39,6 +39,17 @@ class Pos extends \Magento\Payment\Block\Form
*/
*/
protected
$_order
;
protected
$_order
;
/**
* @var \Adyen\Payment\Helper\Data
*/
protected
$_adyenHelper
;
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
protected
$_adyenLogger
;
/**
/**
* Pos constructor.
* Pos constructor.
*
*
...
@@ -46,17 +57,29 @@ class Pos extends \Magento\Payment\Block\Form
...
@@ -46,17 +57,29 @@ class Pos extends \Magento\Payment\Block\Form
* @param array $data
* @param array $data
* @param \Magento\Sales\Model\OrderFactory $orderFactory
* @param \Magento\Sales\Model\OrderFactory $orderFactory
* @param \Magento\Checkout\Model\Session $checkoutSession
* @param \Magento\Checkout\Model\Session $checkoutSession
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
*/
*/
public
function
__construct
(
public
function
__construct
(
\Magento\Framework\View\Element\Template\Context
$context
,
\Magento\Framework\View\Element\Template\Context
$context
,
array
$data
=
[],
array
$data
=
[],
\Magento\Sales\Model\OrderFactory
$orderFactory
,
\Magento\Sales\Model\OrderFactory
$orderFactory
,
\Magento\Checkout\Model\Session
$checkoutSession
\Magento\Checkout\Model\Session
$checkoutSession
,
\Adyen\Payment\Helper\Data
$adyenHelper
,
\Adyen\Payment\Logger\AdyenLogger
$adyenLogger
)
{
)
{
$this
->
_orderFactory
=
$orderFactory
;
$this
->
_orderFactory
=
$orderFactory
;
$this
->
_checkoutSession
=
$checkoutSession
;
$this
->
_checkoutSession
=
$checkoutSession
;
parent
::
__construct
(
$context
,
$data
);
parent
::
__construct
(
$context
,
$data
);
$this
->
_getOrder
();
$this
->
_request
=
$context
->
getRequest
();
$this
->
_adyenHelper
=
$adyenHelper
;
$this
->
_adyenLogger
=
$adyenLogger
;
if
(
!
$this
->
_order
)
{
$incrementId
=
$this
->
_getCheckout
()
->
getLastRealOrderId
();
$this
->
_order
=
$this
->
_orderFactory
->
create
()
->
loadByIncrementId
(
$incrementId
);
}
}
}
/**
/**
...
@@ -72,33 +95,162 @@ class Pos extends \Magento\Payment\Block\Form
...
@@ -72,33 +95,162 @@ class Pos extends \Magento\Payment\Block\Form
*/
*/
public
function
getLaunchLink
()
public
function
getLaunchLink
()
{
{
$
result
=
""
;
$
launchlink
=
""
;
try
{
try
{
$order
=
$this
->
_order
;
if
(
$this
->
_order
->
getPayment
())
if
(
$order
->
getPayment
())
{
{
$result
=
$this
->
_order
->
getPayment
()
->
getMethodInstance
()
->
getLaunchLink
();
$realOrderId
=
$this
->
_order
->
getRealOrderId
();
$orderCurrencyCode
=
$this
->
_order
->
getOrderCurrencyCode
();
$amount
=
$this
->
_adyenHelper
->
formatAmount
(
$this
->
_order
->
getGrandTotal
(),
$orderCurrencyCode
);
$shopperEmail
=
$this
->
_order
->
getCustomerEmail
();
$customerId
=
$this
->
_order
->
getCustomerId
();
$callbackUrl
=
$this
->
_urlBuilder
->
getUrl
(
'adyen/process/resultpos'
,
[
'_secure'
=>
$this
->
_getRequest
()
->
isSecure
()]);
$addReceiptOrderLines
=
$this
->
_adyenHelper
->
getAdyenPosConfigData
(
"add_receipt_order_lines"
);
$recurringContract
=
$this
->
_adyenHelper
->
getAdyenPosConfigData
(
'recurring_type'
);
$currencyCode
=
$orderCurrencyCode
;
$paymentAmount
=
$amount
;
$merchantReference
=
$realOrderId
;
$shopperReference
=
(
!
empty
(
$customerId
))
?
$customerId
:
self
::
GUEST_ID
.
$realOrderId
;
$shopperEmail
=
$shopperEmail
;
$recurringParams
=
""
;
if
(
$this
->
_order
->
getPayment
()
->
getAdditionalInformation
(
"store_cc"
)
!=
""
)
{
$recurringParams
=
"&recurringContract="
.
urlencode
(
$recurringContract
)
.
"&shopperReference="
.
urlencode
(
$shopperReference
)
.
"&shopperEmail="
.
urlencode
(
$shopperEmail
);
}
$receiptOrderLines
=
""
;
if
(
$addReceiptOrderLines
)
{
$orderLines
=
base64_encode
(
$this
->
_getReceiptOrderLines
(
$this
->
_order
));
$receiptOrderLines
=
"&receiptOrderLines="
.
urlencode
(
$orderLines
);
}
// extra parameters so that you alway's return these paramters from the application
$extraParamaters
=
urlencode
(
"/?originalCustomCurrency="
.
$currencyCode
.
"&originalCustomAmount="
.
$paymentAmount
.
"&originalCustomMerchantReference="
.
$merchantReference
.
"&originalCustomSessionId="
.
session_id
());
$launchlink
=
"adyen://payment?sessionId="
.
session_id
()
.
"&amount="
.
$paymentAmount
.
"¤cy="
.
$currencyCode
.
"&merchantReference="
.
$merchantReference
.
$recurringParams
.
$receiptOrderLines
.
"&callback="
.
$callbackUrl
.
$extraParamaters
;
// cash not working see ticket
// https://youtrack.is.adyen.com/issue/IOS-130#comment=102-20285
// . "&transactionType=CASH";
$this
->
_adyenLogger
->
addAdyenDebug
(
print_r
(
$launchlink
,
true
));
}
}
}
catch
(
Exception
$e
)
{
}
catch
(
Exception
$e
)
{
// do nothing for now
// do nothing for now
throw
(
$e
);
throw
(
$e
);
}
}
return
$
result
;
return
$
launchlink
;
}
}
/**
/**
* Get order object
* @param \Magento\Sales\Model\Order $order
*
* @return string
* @return \Magento\Sales\Model\Order
*/
*/
protected
function
_get
Order
(
)
protected
function
_get
ReceiptOrderLines
(
\Magento\Sales\Model\Order
$order
)
{
{
if
(
!
$this
->
_order
)
{
$myReceiptOrderLines
=
""
;
$incrementId
=
$this
->
_getCheckout
()
->
getLastRealOrderId
();
$this
->
_order
=
$this
->
_orderFactory
->
create
()
->
loadByIncrementId
(
$incrementId
);
$currency
=
$order
->
getOrderCurrencyCode
();
$formattedAmountValue
=
$this
->
_currencyFactory
->
create
()
->
format
(
$order
->
getGrandTotal
(),
[
'display'
=>
\Magento\Framework\Currency
::
NO_SYMBOL
],
false
);
$taxAmount
=
$order
->
getTaxAmount
();
$formattedTaxAmount
=
$this
->
_currencyFactory
->
create
()
->
format
(
$taxAmount
,
[
'display'
=>
\Magento\Framework\Currency
::
NO_SYMBOL
],
false
);
$myReceiptOrderLines
.=
"---||C
\n
"
.
"====== YOUR ORDER DETAILS ======||CB
\n
"
.
"---||C
\n
"
.
" No. Description |Piece Subtotal|
\n
"
;
foreach
(
$order
->
getItemsCollection
()
as
$item
)
{
//skip dummies
if
(
$item
->
isDummy
())
{
continue
;
};
$singlePriceFormat
=
$this
->
_currencyFactory
->
create
()
->
format
(
$item
->
getPriceInclTax
(),
[
'display'
=>
\Magento\Framework\Currency
::
NO_SYMBOL
],
false
);
$itemAmount
=
$item
->
getPriceInclTax
()
*
(
int
)
$item
->
getQtyOrdered
();
$itemAmountFormat
=
$this
->
_currencyFactory
->
create
()
->
format
(
$itemAmount
,
[
'display'
=>
\Magento\Framework\Currency
::
NO_SYMBOL
],
false
);
$myReceiptOrderLines
.=
" "
.
(
int
)
$item
->
getQtyOrdered
()
.
" "
.
trim
(
substr
(
$item
->
getName
(),
0
,
25
))
.
"| "
.
$currency
.
" "
.
$singlePriceFormat
.
" "
.
$currency
.
" "
.
$itemAmountFormat
.
"|
\n
"
;
}
//discount cost
if
(
$order
->
getDiscountAmount
()
>
0
||
$order
->
getDiscountAmount
()
<
0
)
{
$discountAmountFormat
=
$this
->
_currencyFactory
->
create
()
->
format
(
$order
->
getDiscountAmount
(),
[
'display'
=>
\Magento\Framework\Currency
::
NO_SYMBOL
],
false
);
$myReceiptOrderLines
.=
" "
.
1
.
" "
.
$this
->
__
(
'Total Discount'
)
.
"| "
.
$currency
.
" "
.
$discountAmountFormat
.
"|
\n
"
;
}
//shipping cost
if
(
$order
->
getShippingAmount
()
>
0
||
$order
->
getShippingTaxAmount
()
>
0
)
{
$shippingAmountFormat
=
$this
->
_currencyFactory
->
create
()
->
format
(
$order
->
getShippingAmount
(),
[
'display'
=>
\Magento\Framework\Currency
::
NO_SYMBOL
],
false
);
$myReceiptOrderLines
.=
" "
.
1
.
" "
.
$order
->
getShippingDescription
()
.
"| "
.
$currency
.
" "
.
$shippingAmountFormat
.
"|
\n
"
;
}
}
return
$this
->
_order
;
if
(
$order
->
getPaymentFeeAmount
()
>
0
)
{
$paymentFeeAmount
=
$this
->
_currencyFactory
->
create
()
->
format
(
$order
->
getPaymentFeeAmount
(),
[
'display'
=>
\Magento\Framework\Currency
::
NO_SYMBOL
],
false
);
$myReceiptOrderLines
.=
" "
.
1
.
" "
.
$this
->
__
(
'Payment Fee'
)
.
"| "
.
$currency
.
" "
.
$paymentFeeAmount
.
"|
\n
"
;
}
$myReceiptOrderLines
.=
"|--------|
\n
"
.
"|Order Total: "
.
$currency
.
" "
.
$formattedAmountValue
.
"|B
\n
"
.
"|Tax: "
.
$currency
.
" "
.
$formattedTaxAmount
.
"|B
\n
"
.
"||C
\n
"
;
/*
* New header for card details section!
* Default location is After Header so simply add to Order Details as separator
*/
$myReceiptOrderLines
.=
"---||C
\n
"
.
"====== YOUR PAYMENT DETAILS ======||CB
\n
"
.
"---||C
\n
"
;
return
$myReceiptOrderLines
;
}
}
/**
/**
...
@@ -110,4 +262,14 @@ class Pos extends \Magento\Payment\Block\Form
...
@@ -110,4 +262,14 @@ class Pos extends \Magento\Payment\Block\Form
{
{
return
$this
->
_checkoutSession
;
return
$this
->
_checkoutSession
;
}
}
/**
* Retrieve request object
*
* @return \Magento\Framework\App\RequestInterface
*/
protected
function
_getRequest
()
{
return
$this
->
_request
;
}
}
}
\ No newline at end of file
Gateway/Command/PosCommand.php
0 → 100644
View file @
aa9e2b6a
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace
Adyen\Payment\Gateway\Command
;
use
Magento\Payment\Gateway\Command
;
use
Magento\Payment\Gateway\CommandInterface
;
class
PosCommand
implements
CommandInterface
{
/**
* @var \Adyen\Payment\Helper\Data
*/
protected
$_adyenHelper
;
/**
* HppCommand constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public
function
__construct
(
\Adyen\Payment\Helper\Data
$adyenHelper
)
{
$this
->
_adyenHelper
=
$adyenHelper
;
}
/**
* @param array $commandSubject
* @return $this
*/
public
function
execute
(
array
$commandSubject
)
{
$payment
=
\Magento\Payment\Gateway\Helper\SubjectReader
::
readPayment
(
$commandSubject
);
$stateObject
=
\Magento\Payment\Gateway\Helper\SubjectReader
::
readStateObject
(
$commandSubject
);
// do not send email
$payment
=
$payment
->
getPayment
();
$payment
->
getOrder
()
->
setCanSendNewEmailFlag
(
false
);
// update status and state
$stateObject
->
setState
(
\Magento\Sales\Model\Order
::
STATE_NEW
);
$stateObject
->
setStatus
(
$this
->
_adyenHelper
->
getAdyenAbstractConfigData
(
'order_status'
));
$stateObject
->
setIsNotified
(
false
);
return
$this
;
}
}
\ No newline at end of file
Model/Method/Hpp.php
deleted
100755 → 0
View file @
43ca397e
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace
Adyen\Payment\Model\Method
;
use
Magento\Framework\DataObject
;
use
Magento\Payment\Model\Method\ConfigInterface
;
use
Magento\Payment\Model\Method\Online\GatewayInterface
;
/**
* @SuppressWarnings(PHPMD.ExcessivePublicCount)
* @SuppressWarnings(PHPMD.TooManyFields)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class
Hpp
extends
\Magento\Payment\Model\Method\AbstractMethod
implements
GatewayInterface
{
const
METHOD_CODE
=
'adyen_hpp'
;
/**
* @var string
*/
protected
$_code
=
self
::
METHOD_CODE
;
/**
* @var GUEST_ID , used when order is placed by guests
*/
const
GUEST_ID
=
'customer_'
;
/**
* @var string
*/
protected
$_infoBlockType
=
'Adyen\Payment\Block\Info\Hpp'
;
/**
* Payment Method feature
*
* @var bool
*/
protected
$_canAuthorize
=
true
;
/**
* @var bool
*/
protected
$_canCapture
=
true
;
/**
* @var bool
*/
protected
$_canCapturePartial
=
true
;
/**
* @var bool
*/
protected
$_canCaptureOnce
=
true
;
/**
* @var bool
*/
protected
$_canRefund
=
true
;
/**
* @var bool
*/
protected
$_canRefundInvoicePartial
=
true
;
/**
* @var bool
*/
protected
$_isGateway
=
true
;
/**
* @var bool
*/
protected
$_isInitializeNeeded
=
true
;
/**
* @var bool
*/
protected
$_canUseInternal
=
false
;
/**
* @var \Adyen\Payment\Model\Api\PaymentRequest
*/
protected
$_paymentRequest
;
/**
* @var \Adyen\Payment\Helper\Data
*/
protected
$_adyenHelper
;
/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
protected
$_storeManager
;
/**
* @var \Magento\Framework\UrlInterface
*/
protected
$_urlBuilder
;
/**
* @var ResolverInterface
*/
protected
$_resolver
;
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
protected
$_adyenLogger
;
/**
* Hpp constructor.
* @param \Magento\Framework\App\RequestInterface $request
* @param \Adyen\Payment\Model\Api\PaymentRequest $paymentRequest
* @param \Magento\Framework\UrlInterface $urlBuilder
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Framework\Locale\ResolverInterface $resolver
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory
* @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory
* @param \Magento\Payment\Helper\Data $paymentData
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Magento\Payment\Model\Method\Logger $logger
* @param \Magento\Framework\Model\ResourceModel\AbstractResource|null $resource
* @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection
* @param array $data
*/
public
function
__construct
(
\Magento\Framework\App\RequestInterface
$request
,
\Adyen\Payment\Model\Api\PaymentRequest
$paymentRequest
,
\Magento\Framework\UrlInterface
$urlBuilder
,
\Adyen\Payment\Helper\Data
$adyenHelper
,
\Magento\Store\Model\StoreManagerInterface
$storeManager
,
\Magento\Framework\Locale\ResolverInterface
$resolver
,
\Adyen\Payment\Logger\AdyenLogger
$adyenLogger
,
\Magento\Framework\Model\Context
$context
,
\Magento\Framework\Registry
$registry
,
\Magento\Framework\Api\ExtensionAttributesFactory
$extensionFactory
,
\Magento\Framework\Api\AttributeValueFactory
$customAttributeFactory
,
\Magento\Payment\Helper\Data
$paymentData
,
\Magento\Framework\App\Config\ScopeConfigInterface
$scopeConfig
,
\Magento\Payment\Model\Method\Logger
$logger
,
\Magento\Framework\Model\ResourceModel\AbstractResource
$resource
=
null
,
\Magento\Framework\Data\Collection\AbstractDb
$resourceCollection
=
null
,
array
$data
=
[]
)
{
parent
::
__construct
(
$context
,
$registry
,
$extensionFactory
,
$customAttributeFactory
,
$paymentData
,
$scopeConfig
,
$logger
,
$resource
,
$resourceCollection
,
$data
);
$this
->
_paymentRequest
=
$paymentRequest
;
$this
->
_urlBuilder
=
$urlBuilder
;
$this
->
_adyenHelper
=
$adyenHelper
;
$this
->
_storeManager
=
$storeManager
;
$this
->
_resolver
=
$resolver
;
$this
->
_adyenLogger
=
$adyenLogger
;
$this
->
_request
=
$request
;
}
/**
* @var string
*/
protected
$_paymentMethodType
=
'hpp'
;
/**
* @return string
*/
public
function
getPaymentMethodType
()
{
return
$this
->
_paymentMethodType
;
}
/**
* @param string $paymentAction
* @param object $stateObject
* @throws \Magento\Framework\Exception\LocalizedException
*/
public
function
initialize
(
$paymentAction
,
$stateObject
)
{
/*
* do not send order confirmation mail after order creation wait for
* Adyen AUTHORIISATION notification
*/
$payment
=
$this
->
getInfoInstance
();
$order
=
$payment
->
getOrder
();
$order
->
setCanSendNewEmailFlag
(
false
);
$stateObject
->
setState
(
\Magento\Sales\Model\Order
::
STATE_NEW
);
$stateObject
->
setStatus
(
$this
->
_adyenHelper
->
getAdyenAbstractConfigData
(
'order_status'
));
$stateObject
->
setIsNotified
(
false
);
}
/**
* Assign data to info model instance
*
* @param \Magento\Framework\DataObject|mixed $data
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
public
function
assignData
(
\Magento\Framework\DataObject
$data
)
{
parent
::
assignData
(
$data
);
if
(
!
$data
instanceof
\Magento\Framework\DataObject
)
{
$data
=
new
\Magento\Framework\DataObject
(
$data
);
}
$additionalData
=
$data
->
getAdditionalData
();
$infoInstance
=
$this
->
getInfoInstance
();
if
(
isset
(
$additionalData
[
'brand_code'
]))
{
$infoInstance
->
setAdditionalInformation
(
'brand_code'
,
$additionalData
[
'brand_code'
]);
}
if
(
isset
(
$additionalData
[
'issuer_id'
]))
{
$infoInstance
->
setAdditionalInformation
(
'issuer_id'
,
$additionalData
[
'issuer_id'
]);
}
$this
->
_adyenLogger
->
addAdyenDebug
(
print_r
(
$data
,
1
));
return
$this
;
}
/**
* Checkout redirect URL getter for onepage checkout (hardcode)
*
* @see \Magento\Checkout\Controller\Onepage::savePaymentAction()
* @see \Magento\Quote\Model\Quote\Payment::getCheckoutRedirectUrl()
* @return string
*/
public
function
getCheckoutRedirectUrl
()
{
return
$this
->
_urlBuilder
->
getUrl
(
'adyen/process/redirect'
,
[
'_secure'
=>
$this
->
_getRequest
()
->
isSecure
()]);
}
/**
* Retrieve request object
*
* @return \Magento\Framework\App\RequestInterface
*/
protected
function
_getRequest
()
{
return
$this
->
_request
;
}
/**
* Post request to gateway and return response
*
* @param DataObject $request
* @param ConfigInterface $config
*/
public
function
postRequest
(
DataObject
$request
,
ConfigInterface
$config
)
{
// Implement postRequest() method.
}
/**
* @desc Get url of Adyen payment
* @return string
*/
public
function
getFormUrl
()
{
$paymentRoutine
=
$this
->
getConfigData
(
'payment_routine'
);
switch
(
$this
->
_adyenHelper
->
isDemoMode
())
{
case
true
:
if
(
$paymentRoutine
==
'single'
&&
$this
->
getPaymentMethodSelectionOnAdyen
())
{
$url
=
'https://test.adyen.com/hpp/pay.shtml'
;
}
else
{
$url
=
(
$this
->
getPaymentMethodSelectionOnAdyen
())
?
'https://test.adyen.com/hpp/select.shtml'
:
"https://test.adyen.com/hpp/details.shtml"
;
}
break
;
default
:
if
(
$paymentRoutine
==
'single'
&&
$this
->
getPaymentMethodSelectionOnAdyen
())
{
$url
=
'https://live.adyen.com/hpp/pay.shtml'
;
}
else
{
$url
=
(
$this
->
getPaymentMethodSelectionOnAdyen
())
?
'https://live.adyen.com/hpp/select.shtml'
:
"https://live.adyen.com/hpp/details.shtml"
;
}
break
;
}
return
$url
;
}
/**
* @return array
* @throws \Magento\Framework\Exception\LocalizedException
*/
public
function
getFormFields
()
{
$paymentInfo
=
$this
->
getInfoInstance
();
$order
=
$paymentInfo
->
getOrder
();
$realOrderId
=
$order
->
getRealOrderId
();
$orderCurrencyCode
=
$order
->
getOrderCurrencyCode
();
$skinCode
=
trim
(
$this
->
getConfigData
(
'skin_code'
));
$amount
=
$this
->
_adyenHelper
->
formatAmount
(
$order
->
getGrandTotal
(),
$orderCurrencyCode
);
$merchantAccount
=
trim
(
$this
->
_adyenHelper
->
getAdyenAbstractConfigData
(
'merchant_account'
));
$shopperEmail
=
$order
->
getCustomerEmail
();
$customerId
=
$order
->
getCustomerId
();
$shopperIP
=
$order
->
getRemoteIp
();
$browserInfo
=
$_SERVER
[
'HTTP_USER_AGENT'
];
$deliveryDays
=
$this
->
getConfigData
(
'delivery_days'
);
$shopperLocale
=
trim
(
$this
->
getConfigData
(
'shopper_locale'
));
$shopperLocale
=
(
!
empty
(
$shopperLocale
))
?
$shopperLocale
:
$this
->
_resolver
->
getLocale
();
$countryCode
=
trim
(
$this
->
getConfigData
(
'country_code'
));
$countryCode
=
(
!
empty
(
$countryCode
))
?
$countryCode
:
false
;
// if directory lookup is enabled use the billingadress as countrycode
if
(
$countryCode
==
false
)
{
if
(
$order
->
getBillingAddress
()
&&
$order
->
getBillingAddress
()
->
getCountryId
()
!=
""
)
{
$countryCode
=
$order
->
getBillingAddress
()
->
getCountryId
();
}
}
$formFields
=
[];
$formFields
[
'merchantAccount'
]
=
$merchantAccount
;
$formFields
[
'merchantReference'
]
=
$realOrderId
;
$formFields
[
'paymentAmount'
]
=
(
int
)
$amount
;
$formFields
[
'currencyCode'
]
=
$orderCurrencyCode
;
$formFields
[
'shipBeforeDate'
]
=
date
(
"Y-m-d"
,
mktime
(
date
(
"H"
),
date
(
"i"
),
date
(
"s"
),
date
(
"m"
),
date
(
"j"
)
+
$deliveryDays
,
date
(
"Y"
))
);
$formFields
[
'skinCode'
]
=
$skinCode
;
$formFields
[
'shopperLocale'
]
=
$shopperLocale
;
$formFields
[
'countryCode'
]
=
$countryCode
;
$formFields
[
'shopperIP'
]
=
$shopperIP
;
$formFields
[
'browserInfo'
]
=
$browserInfo
;
$formFields
[
'sessionValidity'
]
=
date
(
DATE_ATOM
,
mktime
(
date
(
"H"
)
+
1
,
date
(
"i"
),
date
(
"s"
),
date
(
"m"
),
date
(
"j"
),
date
(
"Y"
))
);
$formFields
[
'shopperEmail'
]
=
$shopperEmail
;
// recurring
$recurringType
=
trim
(
$this
->
_adyenHelper
->
getAdyenAbstractConfigData
(
'recurring_type'
));
$brandCode
=
$order
->
getPayment
()
->
getAdditionalInformation
(
"brand_code"
);
// Paypal does not allow ONECLICK,RECURRING only RECURRING
if
(
$brandCode
==
"paypal"
&&
$recurringType
==
'ONECLICK,RECURRING'
)
{
$recurringType
=
"RECURRING"
;
}
$formFields
[
'recurringContract'
]
=
$recurringType
;
$formFields
[
'shopperReference'
]
=
(
!
empty
(
$customerId
))
?
$customerId
:
self
::
GUEST_ID
.
$realOrderId
;
//blocked methods
$formFields
[
'blockedMethods'
]
=
""
;
$baseUrl
=
$this
->
_storeManager
->
getStore
(
$this
->
getStore
())
->
getBaseUrl
(
\Magento\Framework\UrlInterface
::
URL_TYPE_LINK
);
$formFields
[
'resURL'
]
=
$baseUrl
.
'adyen/process/result'
;
$hmacKey
=
$this
->
_adyenHelper
->
getHmac
();
if
(
$brandCode
)
{
$formFields
[
'brandCode'
]
=
$brandCode
;
}
$issuerId
=
$order
->
getPayment
()
->
getAdditionalInformation
(
"issuer_id"
);
if
(
$issuerId
)
{
$formFields
[
'issuerId'
]
=
$issuerId
;
}
// Sort the array by key using SORT_STRING order
ksort
(
$formFields
,
SORT_STRING
);
// Generate the signing data string
$signData
=
implode
(
":"
,
array_map
([
$this
,
'escapeString'
],
array_merge
(
array_keys
(
$formFields
),
array_values
(
$formFields
))));
$merchantSig
=
base64_encode
(
hash_hmac
(
'sha256'
,
$signData
,
pack
(
"H*"
,
$hmacKey
),
true
));
$formFields
[
'merchantSig'
]
=
$merchantSig
;
$this
->
_adyenLogger
->
addAdyenDebug
(
print_r
(
$formFields
,
true
));
return
$formFields
;
}
/**
* The character escape function is called from the array_map function in _signRequestParams
*
* @param $val
* @return mixed
*/
protected
function
escapeString
(
$val
)
{
return
str_replace
(
':'
,
'\\:'
,
str_replace
(
'\\'
,
'\\\\'
,
$val
));
}
/**
* @return mixed
*/
public
function
getPaymentMethodSelectionOnAdyen
()
{
return
$this
->
getConfigData
(
'payment_selection_on_adyen'
);
}
/**
* Capture on Adyen
*
* @param \Magento\Payment\Model\InfoInterface $payment
* @param float $amount
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
public
function
capture
(
\Magento\Payment\Model\InfoInterface
$payment
,
$amount
)
{
parent
::
capture
(
$payment
,
$amount
);
$this
->
_paymentRequest
->
capture
(
$payment
,
$amount
);
return
$this
;
}
/**
* Refund specified amount for payment
*
* @param \Magento\Payment\Model\InfoInterface $payment
* @param float $amount
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
public
function
refund
(
\Magento\Payment\Model\InfoInterface
$payment
,
$amount
)
{
parent
::
refund
(
$payment
,
$amount
);
// get pspReference
$pspReference
=
$payment
->
getAdyenPspReference
();
$order
=
$payment
->
getOrder
();
/*
* if amount is a full refund send a refund/cancelled request
* so if it is not captured yet it will cancel the order
*/
$grandTotal
=
$order
->
getGrandTotal
();
if
(
$grandTotal
==
$amount
)
{
$this
->
_paymentRequest
->
cancelOrRefund
(
$payment
);
}
else
{
$this
->
_paymentRequest
->
refund
(
$payment
,
$amount
);
}
return
$this
;
}
}
\ No newline at end of file
Model/Method/Pos.php
deleted
100755 → 0
View file @
43ca397e
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace
Adyen\Payment\Model\Method
;
use
Magento\Framework\DataObject
;
use
Magento\Payment\Model\Method\ConfigInterface
;
use
Magento\Payment\Model\Method\Online\GatewayInterface
;
/**
* @SuppressWarnings(PHPMD.ExcessivePublicCount)
* @SuppressWarnings(PHPMD.TooManyFields)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class
Pos
extends
\Magento\Payment\Model\Method\AbstractMethod
implements
GatewayInterface
{
const
METHOD_CODE
=
'adyen_pos'
;
/**
* @var string
*/
protected
$_code
=
self
::
METHOD_CODE
;
/**
* @var GUEST_ID , used when order is placed by guests
*/
const
GUEST_ID
=
'customer_'
;
/**
* @var string
*/
protected
$_infoBlockType
=
'Adyen\Payment\Block\Info\Pos'
;
/**
* Payment Method feature
*
* @var bool
*/
protected
$_canAuthorize
=
true
;
/**
* @var bool
*/
protected
$_canCapture
=
true
;
/**
* @var bool
*/
protected
$_canCapturePartial
=
true
;
/**
* @var bool
*/
protected
$_canCaptureOnce
=
true
;
/**
* @var bool
*/
protected
$_canRefund
=
true
;
/**
* @var bool
*/
protected
$_canRefundInvoicePartial
=
true
;
/**
* @var bool
*/
protected
$_isGateway
=
true
;
/**
* @var bool
*/
protected
$_isInitializeNeeded
=
true
;
/**
* @var bool
*/
protected
$_canUseInternal
=
false
;
/**
* @var \Adyen\Payment\Model\Api\PaymentRequest
*/
protected
$_paymentRequest
;
/**
* @var \Adyen\Payment\Helper\Data
*/
protected
$_adyenHelper
;
/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
protected
$storeManager
;
/**
* @var \Magento\Framework\UrlInterface
*/
protected
$_urlBuilder
;
/**
* @var ResolverInterface
*/
protected
$resolver
;
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
protected
$_adyenLogger
;
/**
* Currency factory
*
* @var CurrencyFactory
*/
protected
$_currencyFactory
;
/**
* Request object
*
* @var \Magento\Framework\App\RequestInterface
*/
protected
$_request
;
/**
* Pos constructor.
*
* @param \Magento\Directory\Model\CurrencyFactory $currencyFactory
* @param \Magento\Framework\App\RequestInterface $request
* @param \Adyen\Payment\Model\Api\PaymentRequest $paymentRequest
* @param \Magento\Framework\UrlInterface $urlBuilder
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Framework\Locale\ResolverInterface $resolver
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory
* @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory
* @param \Magento\Payment\Helper\Data $paymentData
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Magento\Payment\Model\Method\Logger $logger
* @param \Magento\Framework\Model\ResourceModel\AbstractResource|null $resource
* @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection
* @param array $data
*/
public
function
__construct
(
\Magento\Directory\Model\CurrencyFactory
$currencyFactory
,
\Magento\Framework\App\RequestInterface
$request
,
\Adyen\Payment\Model\Api\PaymentRequest
$paymentRequest
,
\Magento\Framework\UrlInterface
$urlBuilder
,
\Adyen\Payment\Helper\Data
$adyenHelper
,
\Magento\Store\Model\StoreManagerInterface
$storeManager
,
\Magento\Framework\Locale\ResolverInterface
$resolver
,
\Adyen\Payment\Logger\AdyenLogger
$adyenLogger
,
\Magento\Framework\Model\Context
$context
,
\Magento\Framework\Registry
$registry
,
\Magento\Framework\Api\ExtensionAttributesFactory
$extensionFactory
,
\Magento\Framework\Api\AttributeValueFactory
$customAttributeFactory
,
\Magento\Payment\Helper\Data
$paymentData
,
\Magento\Framework\App\Config\ScopeConfigInterface
$scopeConfig
,
\Magento\Payment\Model\Method\Logger
$logger
,
\Magento\Framework\Model\ResourceModel\AbstractResource
$resource
=
null
,
\Magento\Framework\Data\Collection\AbstractDb
$resourceCollection
=
null
,
array
$data
=
[]
)
{
parent
::
__construct
(
$context
,
$registry
,
$extensionFactory
,
$customAttributeFactory
,
$paymentData
,
$scopeConfig
,
$logger
,
$resource
,
$resourceCollection
,
$data
);
$this
->
_paymentRequest
=
$paymentRequest
;
$this
->
_urlBuilder
=
$urlBuilder
;
$this
->
_adyenHelper
=
$adyenHelper
;
$this
->
storeManager
=
$storeManager
;
$this
->
resolver
=
$resolver
;
$this
->
_adyenLogger
=
$adyenLogger
;
$this
->
_request
=
$request
;
$this
->
_currencyFactory
=
$currencyFactory
;
}
/**
* @var string
*/
protected
$_paymentMethodType
=
'hpp'
;
/**
* @return string
*/
public
function
getPaymentMethodType
()
{
return
$this
->
_paymentMethodType
;
}
/**
* @param string $paymentAction
* @param object $stateObject
* @throws \Magento\Framework\Exception\LocalizedException
*/
public
function
initialize
(
$paymentAction
,
$stateObject
)
{
/*
* do not send order confirmation mail after order creation wait for
* Adyen AUTHORIISATION notification
*/
$payment
=
$this
->
getInfoInstance
();
$order
=
$payment
->
getOrder
();
$order
->
setCanSendNewEmailFlag
(
false
);
$stateObject
->
setState
(
\Magento\Sales\Model\Order
::
STATE_NEW
);
$stateObject
->
setStatus
(
$this
->
_adyenHelper
->
getAdyenAbstractConfigData
(
'order_status'
));
$stateObject
->
setIsNotified
(
false
);
}
/**
* Assign data to info model instance
*
* @param \Magento\Framework\DataObject|mixed $data
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
public
function
assignData
(
\Magento\Framework\DataObject
$data
)
{
parent
::
assignData
(
$data
);
return
$this
;
}
/**
* Checkout redirect URL getter for onepage checkout (hardcode)
*
* @see \Magento\Checkout\Controller\Onepage::savePaymentAction()
* @see \Magento\Quote\Model\Quote\Payment::getCheckoutRedirectUrl()
* @return string
*/
public
function
getCheckoutRedirectUrl
()
{
return
$this
->
_urlBuilder
->
getUrl
(
'adyen/process/redirectPos'
,
[
'_secure'
=>
$this
->
_getRequest
()
->
isSecure
()]);
}
/**
* Retrieve request object
*
* @return \Magento\Framework\App\RequestInterface
*/
protected
function
_getRequest
()
{
return
$this
->
_request
;
}
/**
* Post request to gateway and return response
*
* @param DataObject $request
* @param ConfigInterface $config
*/
public
function
postRequest
(
DataObject
$request
,
ConfigInterface
$config
)
{
// Implement postRequest() method.
}
/**
* @return string
* @throws \Magento\Framework\Exception\LocalizedException
*/
public
function
getLaunchLink
()
{
$paymentInfo
=
$this
->
getInfoInstance
();
$order
=
$paymentInfo
->
getOrder
();
$realOrderId
=
$order
->
getRealOrderId
();
$orderCurrencyCode
=
$order
->
getOrderCurrencyCode
();
$amount
=
$this
->
_adyenHelper
->
formatAmount
(
$order
->
getGrandTotal
(),
$orderCurrencyCode
);
$shopperEmail
=
$order
->
getCustomerEmail
();
$customerId
=
$order
->
getCustomerId
();
$callbackUrl
=
$this
->
_urlBuilder
->
getUrl
(
'adyen/process/resultpos'
,
[
'_secure'
=>
$this
->
_getRequest
()
->
isSecure
()]);
$addReceiptOrderLines
=
$this
->
_adyenHelper
->
getAdyenPosConfigData
(
"add_receipt_order_lines"
);
$recurringContract
=
$this
->
_adyenHelper
->
getAdyenPosConfigData
(
'recurring_type'
);
$currencyCode
=
$orderCurrencyCode
;
$paymentAmount
=
$amount
;
$merchantReference
=
$realOrderId
;
$shopperReference
=
(
!
empty
(
$customerId
))
?
$customerId
:
self
::
GUEST_ID
.
$realOrderId
;
$shopperEmail
=
$shopperEmail
;
$recurringParams
=
""
;
if
(
$order
->
getPayment
()
->
getAdditionalInformation
(
"store_cc"
)
!=
""
)
{
$recurringParams
=
"&recurringContract="
.
urlencode
(
$recurringContract
)
.
"&shopperReference="
.
urlencode
(
$shopperReference
)
.
"&shopperEmail="
.
urlencode
(
$shopperEmail
);
}
$receiptOrderLines
=
""
;
if
(
$addReceiptOrderLines
)
{
$orderLines
=
base64_encode
(
$this
->
getReceiptOrderLines
(
$order
));
$receiptOrderLines
=
"&receiptOrderLines="
.
urlencode
(
$orderLines
);
}
// extra parameters so that you alway's return these paramters from the application
$extraParamaters
=
urlencode
(
"/?originalCustomCurrency="
.
$currencyCode
.
"&originalCustomAmount="
.
$paymentAmount
.
"&originalCustomMerchantReference="
.
$merchantReference
.
"&originalCustomSessionId="
.
session_id
());
$launchlink
=
"adyen://payment?sessionId="
.
session_id
()
.
"&amount="
.
$paymentAmount
.
"¤cy="
.
$currencyCode
.
"&merchantReference="
.
$merchantReference
.
$recurringParams
.
$receiptOrderLines
.
"&callback="
.
$callbackUrl
.
$extraParamaters
;
// cash not working see ticket
// https://youtrack.is.adyen.com/issue/IOS-130#comment=102-20285
// . "&transactionType=CASH";
$this
->
_adyenLogger
->
addAdyenDebug
(
print_r
(
$launchlink
,
true
));
return
$launchlink
;
}
/**
* @param $order
* @return string
*/
private
function
getReceiptOrderLines
(
\Magento\Sales\Model\Order
$order
)
{
$myReceiptOrderLines
=
""
;
$currency
=
$order
->
getOrderCurrencyCode
();
$formattedAmountValue
=
$this
->
_currencyFactory
->
create
()
->
format
(
$order
->
getGrandTotal
(),
[
'display'
=>
\Magento\Framework\Currency
::
NO_SYMBOL
],
false
);
$taxAmount
=
$order
->
getTaxAmount
();
$formattedTaxAmount
=
$this
->
_currencyFactory
->
create
()
->
format
(
$taxAmount
,
[
'display'
=>
\Magento\Framework\Currency
::
NO_SYMBOL
],
false
);
$myReceiptOrderLines
.=
"---||C
\n
"
.
"====== YOUR ORDER DETAILS ======||CB
\n
"
.
"---||C
\n
"
.
" No. Description |Piece Subtotal|
\n
"
;
foreach
(
$order
->
getItemsCollection
()
as
$item
)
{
//skip dummies
if
(
$item
->
isDummy
())
{
continue
;
};
$singlePriceFormat
=
$this
->
_currencyFactory
->
create
()
->
format
(
$item
->
getPriceInclTax
(),
[
'display'
=>
\Magento\Framework\Currency
::
NO_SYMBOL
],
false
);
$itemAmount
=
$item
->
getPriceInclTax
()
*
(
int
)
$item
->
getQtyOrdered
();
$itemAmountFormat
=
$this
->
_currencyFactory
->
create
()
->
format
(
$itemAmount
,
[
'display'
=>
\Magento\Framework\Currency
::
NO_SYMBOL
],
false
);
$myReceiptOrderLines
.=
" "
.
(
int
)
$item
->
getQtyOrdered
()
.
" "
.
trim
(
substr
(
$item
->
getName
(),
0
,
25
))
.
"| "
.
$currency
.
" "
.
$singlePriceFormat
.
" "
.
$currency
.
" "
.
$itemAmountFormat
.
"|
\n
"
;
}
//discount cost
if
(
$order
->
getDiscountAmount
()
>
0
||
$order
->
getDiscountAmount
()
<
0
)
{
$discountAmountFormat
=
$this
->
_currencyFactory
->
create
()
->
format
(
$order
->
getDiscountAmount
(),
[
'display'
=>
\Magento\Framework\Currency
::
NO_SYMBOL
],
false
);
$myReceiptOrderLines
.=
" "
.
1
.
" "
.
$this
->
__
(
'Total Discount'
)
.
"| "
.
$currency
.
" "
.
$discountAmountFormat
.
"|
\n
"
;
}
//shipping cost
if
(
$order
->
getShippingAmount
()
>
0
||
$order
->
getShippingTaxAmount
()
>
0
)
{
$shippingAmountFormat
=
$this
->
_currencyFactory
->
create
()
->
format
(
$order
->
getShippingAmount
(),
[
'display'
=>
\Magento\Framework\Currency
::
NO_SYMBOL
],
false
);
$myReceiptOrderLines
.=
" "
.
1
.
" "
.
$order
->
getShippingDescription
()
.
"| "
.
$currency
.
" "
.
$shippingAmountFormat
.
"|
\n
"
;
}
if
(
$order
->
getPaymentFeeAmount
()
>
0
)
{
$paymentFeeAmount
=
$this
->
_currencyFactory
->
create
()
->
format
(
$order
->
getPaymentFeeAmount
(),
[
'display'
=>
\Magento\Framework\Currency
::
NO_SYMBOL
],
false
);
$myReceiptOrderLines
.=
" "
.
1
.
" "
.
$this
->
__
(
'Payment Fee'
)
.
"| "
.
$currency
.
" "
.
$paymentFeeAmount
.
"|
\n
"
;
}
$myReceiptOrderLines
.=
"|--------|
\n
"
.
"|Order Total: "
.
$currency
.
" "
.
$formattedAmountValue
.
"|B
\n
"
.
"|Tax: "
.
$currency
.
" "
.
$formattedTaxAmount
.
"|B
\n
"
.
"||C
\n
"
;
/*
* New header for card details section!
* Default location is After Header so simply add to Order Details as separator
*/
$myReceiptOrderLines
.=
"---||C
\n
"
.
"====== YOUR PAYMENT DETAILS ======||CB
\n
"
.
"---||C
\n
"
;
return
$myReceiptOrderLines
;
}
/**
* Capture on Adyen
*
* @param \Magento\Payment\Model\InfoInterface $payment
* @param float $amount
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
public
function
capture
(
\Magento\Payment\Model\InfoInterface
$payment
,
$amount
)
{
parent
::
capture
(
$payment
,
$amount
);
$this
->
_paymentRequest
->
capture
(
$payment
,
$amount
);
return
$this
;
}
/**
* Refund specified amount for payment
*
* @param \Magento\Payment\Model\InfoInterface $payment
* @param float $amount
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
public
function
refund
(
\Magento\Payment\Model\InfoInterface
$payment
,
$amount
)
{
parent
::
refund
(
$payment
,
$amount
);
$order
=
$payment
->
getOrder
();
/*
* if amount is a full refund send a refund/cancelled request
* so if it is not captured yet it will cancel the order
*/
$grandTotal
=
$order
->
getGrandTotal
();
if
(
$grandTotal
==
$amount
)
{
$this
->
_paymentRequest
->
cancelOrRefund
(
$payment
);
}
else
{
$this
->
_paymentRequest
->
refund
(
$payment
,
$amount
);
}
return
$this
;
}
}
\ No newline at end of file
Model/Ui/AdyenPosConfigProvider.php
0 → 100755
View file @
aa9e2b6a
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace
Adyen\Payment\Model\Ui
;
use
Magento\Checkout\Model\ConfigProviderInterface
;
use
Magento\Payment\Helper\Data
as
PaymentHelper
;
use
Magento\Directory\Helper\Data
;
class
AdyenPosConfigProvider
implements
ConfigProviderInterface
{
const
CODE
=
'adyen_pos'
;
/**
* @var PaymentHelper
*/
protected
$_paymentHelper
;
/**
* @var \Adyen\Payment\Helper\Data
*/
protected
$_adyenHelper
;
/**
* Request object
*
* @var \Magento\Framework\App\RequestInterface
*/
protected
$_request
;
/**
* @var \Magento\Framework\UrlInterface
*/
protected
$_urlBuilder
;
/**
* AdyenHppConfigProvider constructor.
*
* @param PaymentHelper $paymentHelper
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public
function
__construct
(
PaymentHelper
$paymentHelper
,
\Adyen\Payment\Helper\Data
$adyenHelper
,
\Magento\Framework\App\RequestInterface
$request
,
\Magento\Framework\UrlInterface
$urlBuilder
)
{
$this
->
_paymentHelper
=
$paymentHelper
;
$this
->
_adyenHelper
=
$adyenHelper
;
$this
->
_request
=
$request
;
$this
->
_urlBuilder
=
$urlBuilder
;
}
/**
* Set configuration for AdyenHPP payemnt method
*
* @return array
*/
public
function
getConfig
()
{
// set to active
$config
=
[
'payment'
=>
[
self
::
CODE
=>
[
'isActive'
=>
true
,
'redirectUrl'
=>
$this
->
_urlBuilder
->
getUrl
(
'adyen/process/redirect'
,
[
'_secure'
=>
$this
->
_getRequest
()
->
isSecure
()])
]
]
];
return
$config
;
}
/**
* Retrieve request object
*
* @return \Magento\Framework\App\RequestInterface
*/
protected
function
_getRequest
()
{
return
$this
->
_request
;
}
}
\ No newline at end of file
etc/config.xml
View file @
aa9e2b6a
...
@@ -132,7 +132,7 @@
...
@@ -132,7 +132,7 @@
</adyen_sepa>
</adyen_sepa>
<adyen_pos>
<adyen_pos>
<active>
0
</active>
<active>
0
</active>
<model>
Adyen
\Payment\Model\Method\Pos
</model>
<model>
Adyen
PaymentPosFacade
</model>
<order_status>
pending
</order_status>
<order_status>
pending
</order_status>
<title>
Adyen POS
</title>
<title>
Adyen POS
</title>
<allowspecific>
0
</allowspecific>
<allowspecific>
0
</allowspecific>
...
@@ -140,6 +140,16 @@
...
@@ -140,6 +140,16 @@
<place_order_url>
adyen/process/redirect
</place_order_url>
<place_order_url>
adyen/process/redirect
</place_order_url>
<order_place_redirect_url>
adyen/process/redirect
</order_place_redirect_url>
<order_place_redirect_url>
adyen/process/redirect
</order_place_redirect_url>
<payment_action>
order
</payment_action>
<payment_action>
order
</payment_action>
<can_initialize>
1
</can_initialize>
<is_gateway>
1
</is_gateway>
<can_use_checkout>
1
</can_use_checkout>
<can_capture>
1
</can_capture>
<can_capture_partial>
1
</can_capture_partial>
<can_use_internal>
1
</can_use_internal>
<can_refund_partial_per_invoice>
1
</can_refund_partial_per_invoice>
<can_refund>
1
</can_refund>
<can_void>
1
</can_void>
<can_cancel>
1
</can_cancel>
<group>
adyen
</group>
<group>
adyen
</group>
</adyen_pos>
</adyen_pos>
<adyen_pay_by_mail>
<adyen_pay_by_mail>
...
...
etc/di.xml
View file @
aa9e2b6a
...
@@ -76,6 +76,16 @@
...
@@ -76,6 +76,16 @@
<argument
name=
"commandPool"
xsi:type=
"object"
>
AdyenPaymentBoletoCommandPool
</argument>
<argument
name=
"commandPool"
xsi:type=
"object"
>
AdyenPaymentBoletoCommandPool
</argument>
</arguments>
</arguments>
</virtualType>
</virtualType>
<virtualType
name=
"AdyenPaymentPosFacade"
type=
"Magento\Payment\Model\Method\Adapter"
>
<arguments>
<argument
name=
"code"
xsi:type=
"const"
>
Adyen\Payment\Model\Ui\AdyenPosConfigProvider::CODE
</argument>
<argument
name=
"formBlockType"
xsi:type=
"string"
>
Adyen\Payment\Block\Form\Pos
</argument>
<argument
name=
"infoBlockType"
xsi:type=
"string"
>
Adyen\Payment\Block\Info\Pos
</argument>
<argument
name=
"valueHandlerPool"
xsi:type=
"object"
>
AdyenPaymentPosValueHandlerPool
</argument>
<argument
name=
"validatorPool"
xsi:type=
"object"
>
AdyenPaymentPosValidatorPool
</argument>
<argument
name=
"commandPool"
xsi:type=
"object"
>
AdyenPaymentPosCommandPool
</argument>
</arguments>
</virtualType>
<!-- Value handlers infrastructure -->
<!-- Value handlers infrastructure -->
<virtualType
name=
"AdyenPaymentCcValueHandlerPool"
type=
"Magento\Payment\Gateway\Config\ValueHandlerPool"
>
<virtualType
name=
"AdyenPaymentCcValueHandlerPool"
type=
"Magento\Payment\Gateway\Config\ValueHandlerPool"
>
...
@@ -143,6 +153,19 @@
...
@@ -143,6 +153,19 @@
</arguments>
</arguments>
</virtualType>
</virtualType>
<virtualType
name=
"AdyenPaymentPosValueHandlerPool"
type=
"Magento\Payment\Gateway\Config\ValueHandlerPool"
>
<arguments>
<argument
name=
"handlers"
xsi:type=
"array"
>
<item
name=
"default"
xsi:type=
"string"
>
AdyenPaymentPosConfigValueHandler
</item>
</argument>
</arguments>
</virtualType>
<virtualType
name=
"AdyenPaymentPosConfigValueHandler"
type=
"Magento\Payment\Gateway\Config\ConfigValueHandler"
>
<arguments>
<argument
name=
"configInterface"
xsi:type=
"object"
>
AdyenPaymentPosConfig
</argument>
</arguments>
</virtualType>
<!-- Configuration reader -->
<!-- Configuration reader -->
<virtualType
name=
"AdyenPaymentCcConfig"
type=
"Magento\Payment\Gateway\Config\Config"
>
<virtualType
name=
"AdyenPaymentCcConfig"
type=
"Magento\Payment\Gateway\Config\Config"
>
<arguments>
<arguments>
...
@@ -169,6 +192,11 @@
...
@@ -169,6 +192,11 @@
<argument
name=
"methodCode"
xsi:type=
"const"
>
Adyen\Payment\Model\Ui\AdyenBoletoConfigProvider::CODE
</argument>
<argument
name=
"methodCode"
xsi:type=
"const"
>
Adyen\Payment\Model\Ui\AdyenBoletoConfigProvider::CODE
</argument>
</arguments>
</arguments>
</virtualType>
</virtualType>
<virtualType
name=
"AdyenPaymentPosConfig"
type=
"Magento\Payment\Gateway\Config\Config"
>
<arguments>
<argument
name=
"methodCode"
xsi:type=
"const"
>
Adyen\Payment\Model\Ui\AdyenPosConfigProvider::CODE
</argument>
</arguments>
</virtualType>
<!-- Commands infrastructure -->
<!-- Commands infrastructure -->
...
@@ -234,6 +262,18 @@
...
@@ -234,6 +262,18 @@
</arguments>
</arguments>
</virtualType>
</virtualType>
<virtualType
name=
"AdyenPaymentPosCommandPool"
type=
"Magento\Payment\Gateway\Command\CommandPool"
>
<arguments>
<argument
name=
"commands"
xsi:type=
"array"
>
<item
name=
"initialize"
xsi:type=
"string"
>
Adyen\Payment\Gateway\Command\PosCommand
</item>
<item
name=
"capture"
xsi:type=
"string"
>
AdyenPaymentCaptureCommand
</item>
<item
name=
"void"
xsi:type=
"string"
>
AdyenPaymentCancelCommand
</item>
<item
name=
"refund"
xsi:type=
"string"
>
AdyenPaymentRefundCommand
</item>
<item
name=
"cancel"
xsi:type=
"string"
>
AdyenPaymentCancelCommand
</item>
</argument>
</arguments>
</virtualType>
<!-- Authorization command -->
<!-- Authorization command -->
<virtualType
name=
"AdyenPaymentCcAuthorizeCommand"
type=
"Magento\Payment\Gateway\Command\GatewayCommand"
>
<virtualType
name=
"AdyenPaymentCcAuthorizeCommand"
type=
"Magento\Payment\Gateway\Command\GatewayCommand"
>
<arguments>
<arguments>
...
@@ -552,6 +592,20 @@
...
@@ -552,6 +592,20 @@
</arguments>
</arguments>
</virtualType>
</virtualType>
<virtualType
name=
"AdyenPaymentPosValidatorPool"
type=
"Magento\Payment\Gateway\Validator\ValidatorPool"
>
<arguments>
<argument
name=
"validators"
xsi:type=
"array"
>
<item
name=
"country"
xsi:type=
"string"
>
AdyenPosCountryValidator
</item>
</argument>
</arguments>
</virtualType>
<!--FIXME: Config does not exists-->
<virtualType
name=
"AdyenPosCountryValidator"
type=
"Magento\Payment\Gateway\Validator\CountryValidator"
>
<arguments>
<argument
name=
"config"
xsi:type=
"object"
>
Adyen\Payment\Gateway\Config\PosConfig
</argument>
</arguments>
</virtualType>
<!--General Response validator-->
<!--General Response validator-->
<virtualType
name=
"GeneralResponseValidator"
type=
"Adyen\Payment\Gateway\Validator\GeneralResponseValidator"
>
<virtualType
name=
"GeneralResponseValidator"
type=
"Adyen\Payment\Gateway\Validator\GeneralResponseValidator"
>
...
...
etc/frontend/di.xml
View file @
aa9e2b6a
...
@@ -33,6 +33,7 @@
...
@@ -33,6 +33,7 @@
<item
name=
"adyen_hpp_config_provider"
xsi:type=
"object"
>
Adyen\Payment\Model\Ui\AdyenHppConfigProvider
</item>
<item
name=
"adyen_hpp_config_provider"
xsi:type=
"object"
>
Adyen\Payment\Model\Ui\AdyenHppConfigProvider
</item>
<item
name=
"adyen_sepa_config_provider"
xsi:type=
"object"
>
Adyen\Payment\Model\Ui\AdyenSepaConfigProvider
</item>
<item
name=
"adyen_sepa_config_provider"
xsi:type=
"object"
>
Adyen\Payment\Model\Ui\AdyenSepaConfigProvider
</item>
<item
name=
"adyen_boleto_config_provider"
xsi:type=
"object"
>
Adyen\Payment\Model\Ui\AdyenBoletoConfigProvider
</item>
<item
name=
"adyen_boleto_config_provider"
xsi:type=
"object"
>
Adyen\Payment\Model\Ui\AdyenBoletoConfigProvider
</item>
<item
name=
"adyen_pos_config_provider"
xsi:type=
"object"
>
Adyen\Payment\Model\Ui\AdyenPosConfigProvider
</item>
</argument>
</argument>
</arguments>
</arguments>
</type>
</type>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment