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

Orders not placed when receiving webhook notification #733

Closed
wouterwp opened this issue Nov 16, 2022 · 13 comments
Closed

Orders not placed when receiving webhook notification #733

wouterwp opened this issue Nov 16, 2022 · 13 comments

Comments

@wouterwp
Copy link

wouterwp commented Nov 16, 2022

The intention of this code seems to be that an order that is not yet placed will be placed when a webhook notification of a successful payment authorization is received:

if (order.status === Order.ORDER_STATUS_CREATED) {
// custom fraudDetection
var fraudDetectionStatus = {
status: 'success'
};
var placeOrderResult = COHelpers.placeOrder(order, fraudDetectionStatus);

But this does not work, since order.status === Order.ORDER_STATUS_CREATED will always be false, also for orders with status 'Created'. Since order.status is of type dw.value.EnumValue and Order.ORDER_STATUS_CREATED is numeric using === will always be false. Please change this to either using == or to order.status.value === Order.ORDER_STATUS_CREATED.

Similar issues are present at:

} else if (order.status.value === Order.ORDER_STATUS_FAILED) {

if (order.paymentStatus.value === Order.PAYMENT_STATUS_PAID) {

if (order === null || order.status !== dw.order.Order.ORDER_STATUS_CREATED || handlerResult.RefusedHpp) {

@olga-adyen
Copy link
Contributor

Hi @wouterwp,

We are investigating this case internally.
I'll close this issue if we can't reproduce the issue, otherwise we will release a fix for the issue.

With kind regards,
Olga Kostina
Adyen

@prestarihab
Copy link

hello , I had this issue also when i place order with 3DS

ERROR PipelineCallServlet|1706873868|Sites-celio-Site|Adyen-ShowConfirmation|PipelineCall|zKqDPsYdQL custom.Adyen [] Could not verify /payment/details: SystemError: com.demandware.beehive.orm.capi.common.ORMOptimisticLockingException: Optimistic locking failure. Object couldn't be updated. [com.demandware.beehive.bts.internal.orderprocess.fulfillment.OrderPO, com.demandware.beehive.orm.internal.state2.RelationalObjectInstanceState@f2399d1[com.demandware.beehive.core.capi.domain.PersistentObjectPOKey(com.demandware.beehive.bts.internal.orderprocess.fulfillment.OrderPO) [2ae33b4e8c95d0d11ba3461318]], com.demandware.beehive.core.capi.domain.PersistentObjectPOKey(com.demandware.beehive.bts.internal.orderprocess.fulfillment.OrderPO) [2ae33b4e8c95d0d11ba3461318], OCA=523194088] in int_adyen_SFRA/cartridge/controllers/middlewares/adyen/showConfirmation/order.js:12

@olga-adyen
Copy link
Contributor

Hi @prestarihab could you please share the cartridge version and SFCC version you're on?

@prestarihab
Copy link

hello @olga-adyen I use the last version 23.2.0 and SFCC version SFRA 6.1.0.
Thanks

@KennethRobbeFrucon
Copy link

@olga-adyen I can confirm the issue described by Wouter in the original comment. The issue is still present in the last version (v23.2.1).

We had to add a customization to resolve it. Without the fix, we were encountering paid orders that weren't properly placed / exported, because the logic inside cartridges/int_adyen_SFRA/cartridge/scripts/adyenService.js fails to execute. The condition order.status === Order.ORDER_STATUS_CREATED can never be true, so the logic to place the order is never executed.

@nsquar3d
Copy link

Adding another comment to this because my company ran into this issue as well. We will be implementing a customization for this in our cartridge. There are scenarios (such as iDeal payments in NL) where, if a redirect back to the website doesn't execute properly, then the bank account is debited but the order is never updated via webhook, and thus the order stays in "Created" status until it ultimately fails after X amount of time.

Not a great user experience for our customers if there are issues with redirect.

@amihajlovski
Copy link
Contributor

amihajlovski commented Sep 28, 2023

Hello

This is already fixed on develop #966
and will be included in the next release

Kind Regards
Aleksandar
Adyen

@sunil-veerapura
Copy link

sunil-veerapura commented Sep 28, 2023

Hello @olga-adyen, Any idea on this issue? Is this resolved in any latest versions?

I am getting the same issue mentioned here very often on production environment. #733 (comment)

Currently we are using https://github.com/Adyen/adyen-salesforce-commerce-cloud/tree/c3737fcafe1898e74cf2639f477cf09848a75e11

Error:
SystemError: com.demandware.beehive.orm.capi.common.ORMOptimisticLockingException: Optimistic locking failure. Object couldn't be updated. [com.demandware.beehive.bts.internal.orderprocess.fulfillment.OrderPO, com.demandware.beehive.orm.internal.state2.RelationalObjectInstanceState@455f995[com.demandware.beehive.core.capi.domain.PersistentObjectPOKey(com.demandware.beehive.bts.internal.orderprocess.fulfillment.OrderPO) [50fa75e142588324f534e48ea6]], com.demandware.beehive.core.capi.domain.PersistentObjectPOKey(com.demandware.beehive.bts.internal.orderprocess.fulfillment.OrderPO) [50fa75e142588324f534e48ea6], OCA=528290224]

Thanks,
Sunil

@olga-adyen
Copy link
Contributor

@sunil-veerapura

Pls see the comment of Aleksandar above:

This is already fixed on develop #966
and will be included in the next release

Thank you,
Olga
Adyen

@sunil-veerapura
Copy link

@olga-adyen - I don't understand how this fix will resolve the optimistic locking issue which we are getting while placing order through 3DS. We don't get this for everything order. 1 order in 10 is having such issue but not every order.

If you can give me bit more explaination about how this fix will resolve the issue, it would help us communicate to our client.

@wouterwp
Copy link
Author

@sunil-veerapura It seems to me that the issue that you describe is a different one then reported here.

It could be that the custom objects containing the notifications are processed at the same time as that the customer returns from the 3DS verification, so two processed are trying to modify the same order. Our solution was to add a 1 minute delay in the processing of the notification custom objects by comparing the order creation time to the current time.

@sunil-veerapura
Copy link

@wouterwp , Yes its a different issue for me. We don't use the notification and custom objects in our project. Its a straight process in checkout and we get this error only during 3DS order placement. Also I found multiple transaction code written in the 3DS flow. I am guessing this is causing the issue where the previous transaction has not released the order object yet and the next one tries to process it.

@amihajlovski
Copy link
Contributor

Hello @wouterwp

This issue is now fixed in latest release

Kind Regards
Aleksandar
Adyen

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

No branches or pull requests

7 participants