saleor icon indicating copy to clipboard operation
saleor copied to clipboard

Automatically charge transactions for orders when auto-confirm enabled

Open witoszekdev opened this issue 1 year ago • 1 comments

Problem

Based on the changes defined here: https://github.com/saleor/saleor/issues/15239, only fully paid orders should be marked as confirmed. automatically_confirm_all_new_orders when enabled should trigger charge-request to any transaction that is authorized and assigned to the order. After receiving success event from payment app, Saleor will mark the order as confirmed (as explained in #15239 )


1. General Assumptions

We should extend the transaction API, to take into account the value of the "auto-confirm" flag. If feature is enabled, Saleor should trigger the charge-request for the transaction that is authorized and assigned to the order. There are few situations that we need to cover for this feature:

  • new order is created from checkout. The order has transactions with authorizedAmount - we need to trigger the charge-request
  • unconfirmed order receives a new transactions with authorizedAmount
  • transaction assigned to the unconfirmed order receives the update from authorize-pending to authorized

This means, that we need cover the flow in different places:

  • logic triggered by mutations transactionInitialize, transactionProcess
  • mutations transactionEventReport - used by app to report any changes that happened for the payment represented by specific transactionItem (like moving funds from charge-pending into charged)
  • mutations transactionCreate and transactionUpdate

[!NOTE] The charge-request should be triggered only when transaction has CHARGE in transaction.available_actions

[!NOTE] The implementation should be generic, and re-usable in all places mentioned above (if possible)

Acceptance Criteria

  • [ ] Automatically confirmed orders have their payments charged
  • [ ] If the charge-request fails, the order should remain unconfirmed
  • [ ] charge-request is triggered only when transaction has CHARGE action available.

5. To Do list

### Tasks
- [ ] Add a draft title or issue reference here

6. To Test

  • [ ]
  • [ ]

witoszekdev avatar Oct 18 '23 10:10 witoszekdev

Edit: Updated the scope, to match to approach that we want to introduce

korycins avatar Jan 17 '24 06:01 korycins

This has been resolved in https://github.com/saleor/saleor/pull/16254 and ported to versions down to 3.14.

aniav avatar Jul 16 '24 11:07 aniav