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

Manually finalize cart to order #5

Open
Xurk opened this issue Apr 24, 2024 · 4 comments
Open

Manually finalize cart to order #5

Xurk opened this issue Apr 24, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@Xurk
Copy link

Xurk commented Apr 24, 2024

Is your feature request related to a problem? Please describe.
Occasionally the Adyen Checkout webhook fails to supply Adyen with the correct response (200 OK with a body [accepted]) despite the transaction in Adyen being successful. It is unclear where exactly something goes awry, but the fact of the matter is that the order does not get finalized by Adyen, meaning confirmation e-mails are not sent out and the orders are not sent to a third-party CRM to continue the workflow of processing and delivering to the customer. There is currently no way of manually finalizing the order in Umbraco / Vendr to allow the workflow to continue, seeing as the customer has paid for the order.

Describe the solution you'd like
On either the Carts overview or the Cart Details page (or both) in the Umbraco Commerce section, there should be a button which can be used to manually finalize a cart so that it becomes an order, and the OrderFinalizedNotification event is fired.

Describe alternatives you've considered
A custom API controller could be written which can have a cart reference passed to it and which triggers the OrderFinalizedNotification event, or performs code which will lead to it being triggered. This could either be a URL which can be called (authorized API controller) or a custom Tree in Umbraco. This could however require a lot of time to deliver and might overlook certain actions which should additionally be performed at this moment.

The core code for Vendr and AdyenCheckout could also be forked and adjusted in our own solution to ensure that a cart is finalized when Adyen is attempting to communicate that a transaction has been successful. However, this would mean that updating to future versions of Adyen would be more difficult.

Additional context
These are mock-ups of how I believe this feature could be implemented in Vendr:

Vendr - Carts Overview - Finalize

Vendr - Cart Detail - Finalize

@Xurk Xurk added the enhancement New feature or request label Apr 24, 2024
@mattbrailsford
Copy link
Member

The real question is what is causing the reply to Adyen to fail? Would be good to know why first.

Really though, Adyen should be retrying the webhook callback if it receives a non 200 response. Webhooks should be expected to fall on occasions so Adyen should detect this and retry until it receives a success response. Are you saying Adyen never retries?

@Xurk
Copy link
Author

Xurk commented Apr 25, 2024

@mattbrailsford: Thank you for responding.

You're correct in that Adyen retries the webhook and continues to do so at increasing intervals ad infinitum. I have attached a screenshot of this:

Adyen - Webhook - Retries

Also if I manually click the "Retry" button in Adyen I receive the same error:

Adyen - Webhook - Failed retry

As I mentioned in the opening post, Adyen wants a 200 OK result with [accepted] in the body, but is not receiving this. We are using the Adyen Checkout add-on for Vendr which I believe should work out of the box and it does in fact work most of the time, but occasionally we are faced with the issue which has now led me to create this feature request.

Occasionally the Adyen event logs display "ACCEPTED" for the webhook but 9 times out of 10 it displays "FAILED", thankfully most times it did however succeed to finalize the order in Vendr.

As you can imagine, this uncertainty is unacceptable for the client who has customers purchasing orders for several thousand euros/pounds (per order). I'm not sure if there's anything we as a solution partner can do as we're reliant on the code in Vendr and Adyen Checkout? From what I can tell by inspecting the code it appears that in AdyenCheckoutPaymentProvider method ProcessCallbackAsync(PaymentProviderContext<AdyenCheckoutSettings> ctx) the if (adyenEvent.Success) line (link to repository file and line) is evaluating as false causing the CallbackResult to not be initialized and no HTTP response to be returned containing the [accepted] body. This is despite the fact that the request body from Adyen actually does state "success": true:

{
   "live" : true,
   "notificationItems" : [
      {
         "NotificationRequestItem" : {
            "additionalData" : {
               "expiryDate" : "*******",
               "metadata.orderNumber" : "*********",
               "authCode" : "******",
               "paymentLinkId" : "******************",
               "cardSummary" : "2661",
               "metadata.orderReference" : "************************************************************",
               "cardFunction" : "********",
               "hmacSignature" : "**************",
               "metadata.orderId" : "************************************"
            },
            "amount" : {
               "currency" : "GBP",
               "value" : 3720
            },
            "eventCode" : "AUTHORISATION",
            "eventDate" : "2024-04-23T10:59:05+02:00",
            "merchantAccountCode" : "***************",
            "merchantReference" : "500000178",
            "operations" : [
               "CANCEL",
               "CAPTURE",
               "REFUND"
            ],
            "paymentMethod" : "visa",
            "pspReference" : "*************",
            "reason" : "035905:2661:03\/2028",
            "success" : true
         }
      }
   ]
}

In conclusion, I believe this feature request would at least give us some way of resolving the issue when it does occur and prevent the order flow from entering a limbo state we are unable to free it from. I'm sure there are other scenarios in which such a button ("Finalize" for Carts) could prove very useful 👍🏼

@mattbrailsford
Copy link
Member

Sure, it's a good idea, but unfortunately it wouldn't get added to Vendr as it is in support phase only. I can add the suggestion to the Umbraco Commerce issue tracker though for us to review at a later point.

My best suggestion would be to dig into the source code of the Adyen payment provider https://github.com/vendrcontrib/vendr-payment-provider-adyen and see why it's returning false. Fixing that should make it at least a little more reliable.

It might also be worth asking on the Adyen issue tracker to see if the original developer might be able to help. Unfortunately the Adyen provider was a community contributed provider and so isn't covered under our support.

@Xurk
Copy link
Author

Xurk commented Apr 25, 2024

Thanks once again @mattbrailsford. It's too bad to hear that Vendr for U8 likely won't receive any (feature) updates and that the Adyen Checkout itself is a community contribution and therefore not covered.

I actually have already dug into the source code, I actually forked it and added it to our solution so that I could debug more. I added a few dozen logger lines so that I could see which code is and isn't being executed, which is how I reached my hypothesis I shared in my previous comment.

Seeing as I don't expect to be able to fix the Adyen Checkout code myself (without spending countless hours, also seeing as debugging on a local development environment with the Adyen webhooks is very tricky), could you perhaps give me any pointers in what would be the best approach were I to implement one of the alternatives I mentioned in my opening post? I.e., using an authorized API controller to manually trigger the OrderFinalizedNotification event in Vendr for a specified cart? I want to make sure I don't overlook anything else that might need to trigger simultaneously/parallel to this event, when finalizing a cart to an order.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants