Affirm / Salesforce_Commerce_Cloud_Affirm

BSD 3-Clause "New" or "Revised" License
1 stars 5 forks source link

Refreshing/reloading the order confirmation page voids order #84

Open moorena opened 5 hours ago

moorena commented 5 hours ago

https://github.com/Affirm/Salesforce_Commerce_Cloud_Affirm/blob/afee5206a92ff0f50ae0740c2e34e4d994a6ae24/cartridges/int_affirm_sfra/cartridge/controllers/Affirm.js#L175-L180

If your customer completes checkout and gets the order confirmation page, and then refreshes it, we re-enter this controller.

The basket will be empty (since the code calls getCurrentOrNewBasket) but the checkout token is still valid, and eventually, the checkCart → syncBasket → checkTotalPrice call chain will fail because the basket total is $0 but the authorized amount was whatever the posted order is.

That leads the code to call the Affirm void service to void the Affirm transaction. (and does not do any updates to the SFCC order)

Since we're only doing AUTH (capture is done later during fulfillment), when we go to capture payment, it fails (404/not found) because the transaction was voided on Affirm's side.

moorena commented 5 hours ago

Unsure of the way to fix: should it call getCurrentBasket instead and fail is there is none ?