How to override AbstractMethod Capture function Magento 2
I need to update amount in capture function of abstract method. For this I have created a plugin.
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace VendorMyModuleModelPlugin;
class OrderCapture extends MagentoPaymentModelMethodAbstractMethod
{
public function capture(MagentoPaymentModelInfoInterface $payment, $amount)
{
print_r($payment);
exit;
}
}
It is not reflecting any changes when I place an order.
Please do suggest
magento2 sales-order plugin
add a comment |
I need to update amount in capture function of abstract method. For this I have created a plugin.
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace VendorMyModuleModelPlugin;
class OrderCapture extends MagentoPaymentModelMethodAbstractMethod
{
public function capture(MagentoPaymentModelInfoInterface $payment, $amount)
{
print_r($payment);
exit;
}
}
It is not reflecting any changes when I place an order.
Please do suggest
magento2 sales-order plugin
add a comment |
I need to update amount in capture function of abstract method. For this I have created a plugin.
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace VendorMyModuleModelPlugin;
class OrderCapture extends MagentoPaymentModelMethodAbstractMethod
{
public function capture(MagentoPaymentModelInfoInterface $payment, $amount)
{
print_r($payment);
exit;
}
}
It is not reflecting any changes when I place an order.
Please do suggest
magento2 sales-order plugin
I need to update amount in capture function of abstract method. For this I have created a plugin.
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace VendorMyModuleModelPlugin;
class OrderCapture extends MagentoPaymentModelMethodAbstractMethod
{
public function capture(MagentoPaymentModelInfoInterface $payment, $amount)
{
print_r($payment);
exit;
}
}
It is not reflecting any changes when I place an order.
Please do suggest
magento2 sales-order plugin
magento2 sales-order plugin
edited 1 hour ago
Shoaib Munir
1,328523
1,328523
asked Jul 27 '18 at 6:48
Kritika KedawatKritika Kedawat
66
66
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Try this:
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace VendorMyModuleModelPlugin;
use MagentoPaymentModelInfoInterface;
use MagentoPaymentModelMethodInterface;
use MagentoAuthorizenetModelDirectpost;
class OrderCapture
{
public function beforeCapture(Directpost $subject, $result,InfoInterface $payment,$amount)
{
print_r($payment);
exit;
}
}
And XML will be like this:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoAuthorizenetModelDirectpost">
<plugin name="order_order_capture" type="VendorMyModuleModelPluginOrderCapture" sortOrder="1" />
</type>
</config>
No its not working. I want to update amount beforeCapture. I am using authorize.net payment method.
– Kritika Kedawat
Jul 27 '18 at 8:21
you can do that withbeforeCapture
– kunj
Jul 27 '18 at 9:04
I did. But no luck. Nothing will be print
– Kritika Kedawat
Jul 27 '18 at 9:40
I looked into this. This payment method is using directPost.php initialize function. How do i override capture amount of all payment method in my custom module?
– Kritika Kedawat
Jul 27 '18 at 10:21
I have updated answer
– kunj
Jul 27 '18 at 10:44
|
show 2 more comments
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f236179%2fhow-to-override-abstractmethod-capture-function-magento-2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try this:
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace VendorMyModuleModelPlugin;
use MagentoPaymentModelInfoInterface;
use MagentoPaymentModelMethodInterface;
use MagentoAuthorizenetModelDirectpost;
class OrderCapture
{
public function beforeCapture(Directpost $subject, $result,InfoInterface $payment,$amount)
{
print_r($payment);
exit;
}
}
And XML will be like this:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoAuthorizenetModelDirectpost">
<plugin name="order_order_capture" type="VendorMyModuleModelPluginOrderCapture" sortOrder="1" />
</type>
</config>
No its not working. I want to update amount beforeCapture. I am using authorize.net payment method.
– Kritika Kedawat
Jul 27 '18 at 8:21
you can do that withbeforeCapture
– kunj
Jul 27 '18 at 9:04
I did. But no luck. Nothing will be print
– Kritika Kedawat
Jul 27 '18 at 9:40
I looked into this. This payment method is using directPost.php initialize function. How do i override capture amount of all payment method in my custom module?
– Kritika Kedawat
Jul 27 '18 at 10:21
I have updated answer
– kunj
Jul 27 '18 at 10:44
|
show 2 more comments
Try this:
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace VendorMyModuleModelPlugin;
use MagentoPaymentModelInfoInterface;
use MagentoPaymentModelMethodInterface;
use MagentoAuthorizenetModelDirectpost;
class OrderCapture
{
public function beforeCapture(Directpost $subject, $result,InfoInterface $payment,$amount)
{
print_r($payment);
exit;
}
}
And XML will be like this:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoAuthorizenetModelDirectpost">
<plugin name="order_order_capture" type="VendorMyModuleModelPluginOrderCapture" sortOrder="1" />
</type>
</config>
No its not working. I want to update amount beforeCapture. I am using authorize.net payment method.
– Kritika Kedawat
Jul 27 '18 at 8:21
you can do that withbeforeCapture
– kunj
Jul 27 '18 at 9:04
I did. But no luck. Nothing will be print
– Kritika Kedawat
Jul 27 '18 at 9:40
I looked into this. This payment method is using directPost.php initialize function. How do i override capture amount of all payment method in my custom module?
– Kritika Kedawat
Jul 27 '18 at 10:21
I have updated answer
– kunj
Jul 27 '18 at 10:44
|
show 2 more comments
Try this:
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace VendorMyModuleModelPlugin;
use MagentoPaymentModelInfoInterface;
use MagentoPaymentModelMethodInterface;
use MagentoAuthorizenetModelDirectpost;
class OrderCapture
{
public function beforeCapture(Directpost $subject, $result,InfoInterface $payment,$amount)
{
print_r($payment);
exit;
}
}
And XML will be like this:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoAuthorizenetModelDirectpost">
<plugin name="order_order_capture" type="VendorMyModuleModelPluginOrderCapture" sortOrder="1" />
</type>
</config>
Try this:
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace VendorMyModuleModelPlugin;
use MagentoPaymentModelInfoInterface;
use MagentoPaymentModelMethodInterface;
use MagentoAuthorizenetModelDirectpost;
class OrderCapture
{
public function beforeCapture(Directpost $subject, $result,InfoInterface $payment,$amount)
{
print_r($payment);
exit;
}
}
And XML will be like this:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoAuthorizenetModelDirectpost">
<plugin name="order_order_capture" type="VendorMyModuleModelPluginOrderCapture" sortOrder="1" />
</type>
</config>
edited Jul 27 '18 at 10:44
answered Jul 27 '18 at 7:05
kunjkunj
2,6322423
2,6322423
No its not working. I want to update amount beforeCapture. I am using authorize.net payment method.
– Kritika Kedawat
Jul 27 '18 at 8:21
you can do that withbeforeCapture
– kunj
Jul 27 '18 at 9:04
I did. But no luck. Nothing will be print
– Kritika Kedawat
Jul 27 '18 at 9:40
I looked into this. This payment method is using directPost.php initialize function. How do i override capture amount of all payment method in my custom module?
– Kritika Kedawat
Jul 27 '18 at 10:21
I have updated answer
– kunj
Jul 27 '18 at 10:44
|
show 2 more comments
No its not working. I want to update amount beforeCapture. I am using authorize.net payment method.
– Kritika Kedawat
Jul 27 '18 at 8:21
you can do that withbeforeCapture
– kunj
Jul 27 '18 at 9:04
I did. But no luck. Nothing will be print
– Kritika Kedawat
Jul 27 '18 at 9:40
I looked into this. This payment method is using directPost.php initialize function. How do i override capture amount of all payment method in my custom module?
– Kritika Kedawat
Jul 27 '18 at 10:21
I have updated answer
– kunj
Jul 27 '18 at 10:44
No its not working. I want to update amount beforeCapture. I am using authorize.net payment method.
– Kritika Kedawat
Jul 27 '18 at 8:21
No its not working. I want to update amount beforeCapture. I am using authorize.net payment method.
– Kritika Kedawat
Jul 27 '18 at 8:21
you can do that with
beforeCapture
– kunj
Jul 27 '18 at 9:04
you can do that with
beforeCapture
– kunj
Jul 27 '18 at 9:04
I did. But no luck. Nothing will be print
– Kritika Kedawat
Jul 27 '18 at 9:40
I did. But no luck. Nothing will be print
– Kritika Kedawat
Jul 27 '18 at 9:40
I looked into this. This payment method is using directPost.php initialize function. How do i override capture amount of all payment method in my custom module?
– Kritika Kedawat
Jul 27 '18 at 10:21
I looked into this. This payment method is using directPost.php initialize function. How do i override capture amount of all payment method in my custom module?
– Kritika Kedawat
Jul 27 '18 at 10:21
I have updated answer
– kunj
Jul 27 '18 at 10:44
I have updated answer
– kunj
Jul 27 '18 at 10:44
|
show 2 more comments
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f236179%2fhow-to-override-abstractmethod-capture-function-magento-2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown