Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PW-7147] Handle Capture Requests triggered from Customer Area #1714

Merged
merged 20 commits into from
Sep 22, 2022

Conversation

RokPopov
Copy link
Contributor

Description
Currently in our plugin, if a capture request is triggered from the CA, the plugin is not handling the corresponding webhook and the order is not updated on Magento.
This PR introduces a solution where Adyen and Magento invoice are created during the processing of the CAPTURE webhook. This process creates entries in both sales_invoice and adyen_invoice tables.
With this PR, only full capture flow is supported. In cases where partial capture is initiated from the Adyen Customer Area, the webhook gets processed but no invoice is created on Magento's end. The merchant has to create the offline invoice from the admin panel.

Tested scenarios

  • process CAPTURE notification with full order amount and see whether both invoices are created and linked
  • process CAPTURE notification with partial amount of the order and make sure no invoice is created and the order can still be invoiced offline

Fixes: #1682

Helper/Invoice.php Outdated Show resolved Hide resolved
Helper/Invoice.php Outdated Show resolved Hide resolved
Helper/Invoice.php Show resolved Hide resolved
Helper/Invoice.php Outdated Show resolved Hide resolved
Helper/Invoice.php Outdated Show resolved Hide resolved
RokPopov and others added 2 commits September 20, 2022 10:34
Co-authored-by: Can Demiralp <ecandemiralp@gmail.com>
Co-authored-by: Can Demiralp <ecandemiralp@gmail.com>
candemiralp
candemiralp previously approved these changes Sep 20, 2022
peterojo
peterojo previously approved these changes Sep 20, 2022
@peterojo peterojo mentioned this pull request Sep 20, 2022
Helper/Invoice.php Outdated Show resolved Hide resolved
@RokPopov RokPopov dismissed stale reviews from peterojo and candemiralp via e2eccb7 September 21, 2022 14:36
Co-authored-by: Michael Paul <michael.paul@adyen.com>
peterojo
peterojo previously approved these changes Sep 22, 2022
AlexandrosMor
AlexandrosMor previously approved these changes Sep 22, 2022
@peterojo peterojo requested a review from a team as a code owner September 22, 2022 07:46
Helper/Invoice.php Outdated Show resolved Hide resolved
@sonarcloud
Copy link

sonarcloud bot commented Sep 22, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@peterojo peterojo merged commit adb1cf6 into develop Sep 22, 2022
@peterojo peterojo deleted the PW-7147 branch September 22, 2022 14:51
RokPopov added a commit that referenced this pull request Sep 22, 2022
* create adyen and magento invoice from webhook if captured manually in CA

* remove code smells

* throw exception if adyen_invoice null and canInvoice is false

* throw exception in case of CA initiated partial manual capture

* use AdyenWebhookException instead of a generic one

* rename method

Co-authored-by: Can Demiralp <ecandemiralp@gmail.com>

* use renamed method

Co-authored-by: Can Demiralp <ecandemiralp@gmail.com>

* update $adyenInvoice

Co-authored-by: Michael Paul <michael.paul@adyen.com>

* resolve merge conflicts

* get rid of code smells

* remove final code smells

* use $adyenInvoiceObject instead of $adyenInvoice

* remove code smell

Co-authored-by: Can Demiralp <ecandemiralp@gmail.com>
Co-authored-by: Michael Paul <michael.paul@adyen.com>
Co-authored-by: Peter Ojo <peterojo@users.noreply.github.com>
RokPopov added a commit that referenced this pull request Sep 28, 2022
* add test for isFullAmountFinalized - immediate capture

* [PW-7208] Update adyen method call for virtual products (#1716)

* Update adyen method call for virtual products

* Remove checking for shipping adress before doing the payment methods call

Co-authored-by: Jeantwan Teuma <Morerice@users.noreply.github.com>
Co-authored-by: Peter Ojo <peterojo@users.noreply.github.com>

* Version bump 8.6.0

* [PW-7147] Handle Capture Requests triggered from Customer Area (#1714)

* create adyen and magento invoice from webhook if captured manually in CA

* remove code smells

* throw exception if adyen_invoice null and canInvoice is false

* throw exception in case of CA initiated partial manual capture

* use AdyenWebhookException instead of a generic one

* rename method

Co-authored-by: Can Demiralp <ecandemiralp@gmail.com>

* use renamed method

Co-authored-by: Can Demiralp <ecandemiralp@gmail.com>

* update $adyenInvoice

Co-authored-by: Michael Paul <michael.paul@adyen.com>

* resolve merge conflicts

* get rid of code smells

* remove final code smells

* use $adyenInvoiceObject instead of $adyenInvoice

* remove code smell

Co-authored-by: Can Demiralp <ecandemiralp@gmail.com>
Co-authored-by: Michael Paul <michael.paul@adyen.com>
Co-authored-by: Peter Ojo <peterojo@users.noreply.github.com>

* refactor the way we are building mock AdyenOrderPaymentHelper, fix testCreateAdyenOrderPayment

* setup testIsFullAmountAuthorized()

* add testIsFullAmountNotFinalizedManualCapture() and testIsFullAmountAuthorized()

* setup testRefundAdyenOrderPayment()

* remove code smells

* align params - code smell

* fix testRefundAdyenOrderPayment

Co-authored-by: Alexandros Moraitis <alexandros.moraitis@adyen.com>
Co-authored-by: Jeantwan Teuma <Morerice@users.noreply.github.com>
Co-authored-by: Peter Ojo <peterojo@users.noreply.github.com>
Co-authored-by: peterojo <peter.ojo@adyen.com>
Co-authored-by: Can Demiralp <ecandemiralp@gmail.com>
Co-authored-by: Michael Paul <michael.paul@adyen.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants