event sales_quote_address_collect_totals_after is changing paid amount
I am adding some custom value in my tax amount after select country by using sales_quote_address_collect_totals_after even, everything is working fine but after complete the online payment my paid amount increase by this custom tax value means grand total and paid amount is different, paid amount is more than grand total, even at the time of payment gateway show correct grand total value but after payment paid amount increase by custom tax value.
Below is the code that I am using to increasing tax value
Instead of using the sales_quote_address_collect_totals_after event, you can try using a different event that occurs before the payment is processed. For example, you can use the sales_quote_collect_totals_before event, which is triggered before the totals are collected and processed.
Make sure the priority of the event observer sales_quote_address_collect_totals_after is set appropriately. If it has a high priority, try reducing it so that it executes earlier in the event chain.
Review the payment process implementation to ensure that it correctly handles the additional tax value and updates the paid amount accordingly. Check if there are any modifications or calculations being applied during the payment process that might be affecting the paid amount incorrectly.
Insert debug statements or log messages in the event observer method and the payment process code to track the flow of execution and identify any discrepancies or unexpected behavior.
Try testing the payment process with different payment methods to determine if the issue is specific to a particular payment method. It's possible that the problem lies within the integration of the payment method you're using.
Instead of modifying the tax amount directly in the sales_quote_address_collect_totals_after event, you can explore other approaches. For example, you can consider using a custom attribute to store the additional tax value temporarily and apply it during a different event or at a different point in the payment flow.