Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Arne Sødal 12 posts 112 karma points
    Feb 18, 2021 @ 13:46
    Arne Sødal
    0

    Payment inconsistency related to payment provider and custom order line calculator

    I have implemented an order line calculator that override the original unit price by collecting prices from an external API. Everything is working fine until I select Stripe as the payment provider.

    The payment captured by Stripe is correct, but the finalized orders total amount is incorrect compared to the order line calculator. The finalized order is now showing the original unit prices and not the calculator prices.

    The order line calculator collects prices by posting a customerID and productID to an API. The customerID is an custom order property and the productID is an custom order line property, so the problem is not related to different sessions, like the case described in this thread with a similar problem.

    All feedback is appreciated

    Arne

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Feb 19, 2021 @ 09:33
    Matt Brailsford
    0

    Hey Arne,

    This is strange indeed.

    Looking at the calculation logic for TC, it should indeed only recalculate order lines if the order isn't yet finalized, but after this point it should just use whatever order lines prices were previously calculated.

    Have you been able to replicate this locally? If so, I wonder if the best course of action would be to grab the source code for the Stripe provider here https://github.com/TeaCommerce/Tea-Commerce-Payment-Providers/tree/master/Source/TeaCommerce.PaymentProviders.Stripe, compile it in debug mode and set breakpoints in the various ProcessRequest methods to see if we can nail down at what point, and what actions cause the prices to change.

    Whilst the following link is for our Vendr ecommerce product, it should hold true for helping test the webhook locally so you can verify the webhook handling of payments https://vendr.net/docs/payment-providers/stripe/1-1-0/stripe-checkout/how-to-guides/testing-stripe-webhooks-locally/

    Give these a try and see if you are able to work out the moment the prices change.

    Hope this helps

    Matt

  • Arne Sødal 12 posts 112 karma points
    Feb 19, 2021 @ 10:13
    Arne Sødal
    0

    Hi and thanks for your reply

    It seems like the problem was related to the Stripe webhooks. I have been testing the solution on different sub domains, and there was created multiple webhook endpoints in Stripe. Every time I save the Stripe payment provider in Umbraco a new Stripe webhook is created. I did a manually cleanup and disable some endpoints and generated a new for my test domain. The finalized orders total amount is now correct, so the problem seems to be solved, although I do not quite understand why 😊

    My Umbraco installation contains two Tea commerce stores (different sub domains), both using Stripe as the payment provider. Can this cause a webhook problem? I guess the stores need different webhook endpoints. Perhaps its better to create a shared endpoint manually and disable the ones auto generated?

    Arne

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Feb 19, 2021 @ 10:30
    Matt Brailsford
    0

    Hey Arne,

    Ahhh, yea, the Stripe payment provider went through a few iterations quickly when the Stripe API changed and I believe one of those iterations attempted to create the webhook registrations automatically. I do believe in the latest version of the code this isn't the case anymore and I think it's a manual registration again.

    Having two stores using Stripe shouldn't be a problem, except (and this might actually be the reason for the problem) where both stores use the same order number prefix. The reason this is a problem is because it's the order number that is used to look up the order and so if you have two orders in different stores, it can get confused which order to use and thus is chooses the wrong one and you get issues like this.

    I don't think we can currently create a shared endpoint as the webhook urls contain information that tell which payment provider to invoke the request on, so you do currently need a unique webook per store.

    Hope this helps

    Matt

  • Arne Sødal 12 posts 112 karma points
    Feb 19, 2021 @ 10:56
    Arne Sødal
    100

    Thanks again

    Now I understand why the price calculator failed. The test installation of the store shares database with the live installation. The price calculator is missing on the live server, so this of course caused a problem with the price calculation as it was an active webhook pointing to this installation.

    My lack of control over active webhooks was the reason for the problems.

    Arne

Please Sign in or register to post replies

Write your reply to:

Draft