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
3202b52c
Commit
3202b52c
authored
Jul 31, 2020
by
Alexandros Moraitis
Committed by
GitHub
Jul 31, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #779 from Adyen/develop
Release 6.4.0
parents
842509ae
ab9f4bcc
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
132 additions
and
31 deletions
+132
-31
Block/Checkout/Success.php
Block/Checkout/Success.php
+61
-10
Helper/PaymentMethods.php
Helper/PaymentMethods.php
+24
-4
composer.json
composer.json
+1
-1
view/frontend/layout/checkout_onepage_success.xml
view/frontend/layout/checkout_onepage_success.xml
+11
-6
view/frontend/requirejs-config.js
view/frontend/requirejs-config.js
+2
-1
view/frontend/templates/checkout/success.phtml
view/frontend/templates/checkout/success.phtml
+33
-9
No files found.
Block/Checkout/Success.php
View file @
3202b52c
...
...
@@ -32,22 +32,28 @@ class Success extends \Magento\Framework\View\Element\Template
/**
* @var \Magento\Sales\Model\Order $order
*/
protected
$
_
order
;
protected
$order
;
/**
* @var \Magento\Checkout\Model\Session
*/
protected
$
_
checkoutSession
;
protected
$checkoutSession
;
/**
* @var \Magento\Checkout\Model\OrderFactory
*/
protected
$_orderFactory
;
protected
$orderFactory
;
/**
* @var \Adyen\Payment\Helper\Data
*/
protected
$adyenHelper
;
/**
* @var \Magento\
Framework\Pricing\Helper\Data
* @var \Magento\
Store\Model\StoreManagerInterface
*/
p
ublic
$priceHelp
er
;
p
rotected
$storeManag
er
;
/**
* Success constructor.
...
...
@@ -63,11 +69,15 @@ class Success extends \Magento\Framework\View\Element\Template
\Magento\Checkout\Model\Session
$checkoutSession
,
\Magento\Sales\Model\OrderFactory
$orderFactory
,
\Magento\Framework\Pricing\Helper\Data
$priceHelper
,
\Adyen\Payment\Helper\Data
$adyenHelper
,
\Magento\Store\Model\StoreManagerInterface
$storeManager
,
array
$data
=
[]
)
{
$this
->
_
checkoutSession
=
$checkoutSession
;
$this
->
_
orderFactory
=
$orderFactory
;
$this
->
checkoutSession
=
$checkoutSession
;
$this
->
orderFactory
=
$orderFactory
;
$this
->
priceHelper
=
$priceHelper
;
$this
->
adyenHelper
=
$adyenHelper
;
$this
->
storeManager
=
$storeManager
;
parent
::
__construct
(
$context
,
$data
);
}
...
...
@@ -151,14 +161,55 @@ class Success extends \Magento\Framework\View\Element\Template
return
$result
;
}
/**
* If PresentToShopper resultCode and action has provided render this with the checkout component on the success page
* @return bool
*/
public
function
renderAction
()
{
if
(
!
empty
(
$this
->
getOrder
()
->
getPayment
()
->
getAdditionalInformation
(
'resultCode'
))
&&
$this
->
getOrder
()
->
getPayment
()
->
getAdditionalInformation
(
'resultCode'
)
==
'PresentToShopper'
&&
!
empty
(
$this
->
getOrder
()
->
getPayment
()
->
getAdditionalInformation
(
'action'
))
)
{
return
true
;
}
return
false
;
}
public
function
getAction
()
{
return
json_encode
(
$this
->
getOrder
()
->
getPayment
()
->
getAdditionalInformation
(
'action'
));
}
public
function
getLocale
()
{
return
$this
->
adyenHelper
->
getCurrentLocaleCode
(
$this
->
storeManager
->
getStore
()
->
getId
()
);
}
public
function
getOriginKey
()
{
return
$this
->
adyenHelper
->
getOriginKeyForBaseUrl
();
}
public
function
getEnvironment
()
{
return
$this
->
adyenHelper
->
getCheckoutEnvironment
(
$this
->
storeManager
->
getStore
()
->
getId
()
);
}
/**
* @return \Magento\Sales\Model\Order
*/
public
function
getOrder
()
{
if
(
$this
->
_
order
==
null
)
{
$this
->
_order
=
$this
->
_orderFactory
->
create
()
->
load
(
$this
->
_
checkoutSession
->
getLastOrderId
());
if
(
$this
->
order
==
null
)
{
$this
->
order
=
$this
->
orderFactory
->
create
()
->
load
(
$this
->
checkoutSession
->
getLastOrderId
());
}
return
$this
->
_
order
;
return
$this
->
order
;
}
}
Helper/PaymentMethods.php
View file @
3202b52c
...
...
@@ -173,7 +173,7 @@ class PaymentMethods extends AbstractHelper
"countryCode"
=>
$this
->
getCurrentCountryCode
(
$store
,
$country
),
"amount"
=>
[
"currency"
=>
$currencyCode
,
"value"
=>
(
int
)
$this
->
adyenHelper
->
formatAmount
(
"value"
=>
$this
->
adyenHelper
->
formatAmount
(
$this
->
getCurrentPaymentAmount
(),
$currencyCode
),
...
...
@@ -253,14 +253,34 @@ class PaymentMethods extends AbstractHelper
}
/**
* @return
bool|in
t
* @return
floa
t
*/
protected
function
getCurrentPaymentAmount
()
{
if
((
$grandTotal
=
$this
->
getQuote
()
->
getGrandTotal
())
>
0
)
{
$grandTotal
=
$this
->
getQuote
()
->
getGrandTotal
();
if
(
!
is_numeric
(
$grandTotal
))
{
throw
new
\Exception
(
sprintf
(
'Cannot retrieve a valid grand total from quote ID: `%s`. Expected a numeric value.'
,
$this
->
getQuote
()
->
getEntityId
()
)
);
}
$grandTotal
=
(
float
)
$grandTotal
;
if
(
$grandTotal
>
0
)
{
return
$grandTotal
;
}
return
10
;
throw
new
\Exception
(
sprintf
(
'Cannot retrieve a valid grand total from quote ID: `%s`. Expected a float > `0`, got `%f`.'
,
$this
->
getQuote
()
->
getEntityId
(),
$grandTotal
)
);
}
/**
...
...
composer.json
View file @
3202b52c
...
...
@@ -2,7 +2,7 @@
"name"
:
"adyen/module-payment"
,
"description"
:
"Official Magento2 Plugin to connect to Payment Service Provider Adyen."
,
"type"
:
"magento2-module"
,
"version"
:
"6.
3
.0"
,
"version"
:
"6.
4
.0"
,
"license"
:
[
"OSL-3.0"
,
"AFL-3.0"
...
...
view/frontend/layout/checkout_onepage_success.xml
View file @
3202b52c
...
...
@@ -22,10 +22,15 @@
* Author: Adyen <magento@adyen.com>
*/
-->
<page
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation=
"urn:magento:framework:View/Layout/etc/page_configuration.xsd"
>
<body>
<referenceContainer
name=
"order.success.additional.info"
>
<block
class=
"Adyen\Payment\Block\Checkout\Success"
name=
"onepage.success.adyen_payment"
template=
"checkout/success.phtml"
cacheable=
"false"
/>
</referenceContainer>
</body>
<page
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation=
"urn:magento:framework:View/Layout/etc/page_configuration.xsd"
>
<head>
<css
src=
"Adyen_Payment::css/styles.css"
/>
</head>
<body>
<referenceContainer
name=
"order.success.additional.info"
>
<block
class=
"Adyen\Payment\Block\Checkout\Success"
name=
"onepage.success.adyen_payment"
template=
"checkout/success.phtml"
cacheable=
"false"
/>
</referenceContainer>
</body>
</page>
view/frontend/requirejs-config.js
View file @
3202b52c
...
...
@@ -14,7 +14,8 @@ var config = {
},
map
:
{
'
*
'
:
{
'
adyenCheckout
'
:
'
https://checkoutshopper-live.adyen.com/checkoutshopper/sdk/3.4.0/adyen.js
'
'
adyenCheckout
'
:
'
https://checkoutshopper-live.adyen.com/checkoutshopper/sdk/3.4.0/adyen.js
'
,
'
adyenCheckout3101
'
:
'
https://checkoutshopper-live.adyen.com/checkoutshopper/sdk/3.10.1/adyen.js
'
}
}
};
view/frontend/templates/checkout/success.phtml
View file @
3202b52c
...
...
@@ -25,7 +25,28 @@
* @var \Adyen\Payment\Block\Checkout\Success $block
*/
?>
<?php
if
(
$block
->
isBoletoPayment
())
:
?>
<?php
if
(
$block
->
renderAction
())
:
?>
<script
type=
"text/javascript"
>
require
([
'
jquery
'
,
'
adyenCheckout3101
'
],
function
(
$
,
AdyenCheckout
)
{
var
action
=
JSON
.
parse
(
'
<?=
/* @noEscape */
$block
->
getAction
();
?>
'
);
var
checkoutComponent
=
new
AdyenCheckout
({
locale
:
'
<?=
$block
->
escapeHtml
(
$block
->
getLocale
());
?>
'
,
environment
:
'
<?=
$block
->
escapeHtml
(
$block
->
getEnvironment
());
?>
'
,
originKey
:
'
<?=
$block
->
escapeHtml
(
$block
->
getOriginKey
());
?>
'
});
try
{
checkoutComponent
.
createFromAction
(
action
).
mount
(
'
#ActionContainer
'
);
}
catch
(
err
)
{
// Action component cannot be created
}
});
</script>
<div
id=
"ActionContainer"
></div>
<?php
else
:
?>
<?php
if
(
$block
->
isBoletoPayment
())
:
?>
<?php
$boletoData
=
$block
->
getBoletoData
();
?>
...
...
@@ -37,21 +58,22 @@
</p>
<?php
endif
;
?>
<?php
if
(
!
empty
(
$block
->
getBankTransferData
()))
:
?>
<?php
if
(
!
empty
(
$block
->
getBankTransferData
()))
:
?>
<?php
$banktranferData
=
$block
->
getBankTransferData
();
$order
=
$block
->
getOrder
();
?>
<h2>
<?=
$block
->
escapeHtml
(
__
(
'Pay using Bank transfer'
));
?>
</h2>
<p>
<?=
$block
->
escapeHtml
(
__
(
'Please transfer the amount using the reference below to the following bank account'
)
__
(
'Please transfer the amount using the reference below to the following bank account'
)
);
?>
</p>
<table>
<tbody>
<?php
if
(
!
empty
(
$order
->
getGrandTotal
()))
:
?>
<tr>
<th
scope=
"row"
>
<?=
$block
->
escapeHtml
(
__
(
'Amount'
));
?>
</th>
<td>
<?=
/* @noEscape */
$order
->
formatPrice
(
$order
->
getGrandTotal
());
?>
</td>
<td>
<?=
/* @noEscape */
$order
->
formatPrice
(
$order
->
getGrandTotal
());
?>
</td>
</tr>
<?php
endif
;
?>
...
...
@@ -97,10 +119,10 @@
?>
<h2>
<?=
$block
->
escapeHtml
(
__
(
'Pay using Multibanco'
));
?>
</h2>
<p>
<?=
$block
->
escapeHtml
(
__
(
'Please pay with the provided Multibanco reference and entity before payment deadline in order to '
.
'complete our payment'
)
__
(
'Please pay with the provided Multibanco reference and entity before payment deadline in order to '
.
'complete our payment'
)
);
?>
</p>
<table>
<tbody>
...
...
@@ -122,7 +144,8 @@
<?php
if
(
!
empty
(
$multibancoData
[
'totalAmount'
]))
:
?>
<tr>
<th
scope=
"row"
>
<?=
$block
->
escapeHtml
(
__
(
'Amount'
));
?>
</th>
<td>
<?=
/* @noEscape */
$block
->
priceHelper
->
currency
(
$multibancoData
[
'totalAmount'
][
'value'
]);
?>
<td>
<?=
/* @noEscape */
$block
->
priceHelper
->
currency
(
$multibancoData
[
'totalAmount'
][
'value'
]);
?>
</td>
</tr>
<?php
endif
;
?>
...
...
@@ -135,4 +158,5 @@
<?php
endif
;
?>
</tbody>
</table>
<?php
endif
;
?>
<?php
endif
;
?>
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