Copied to clipboard

Flag this post as spam?

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


  • Fedor Krutko 13 posts 123 karma points
    May 01, 2021 @ 21:17
    Fedor Krutko
    0

    How to fill TransactionInfo

    Hi,

    I'm trying to use the unofficial plugin for Dibs Easy (but I guess official Dibs D2 plugin works the same way), and I was wondering how to fill the TransactionInfo of current order to use in FetchPaymentStatus (or any other) method.

    That is, it can be set only privately, and I don't see any method that can set it.

    Thanks

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    May 04, 2021 @ 08:03
    Matt Brailsford
    0

    Hi Fedor,

    To update the transaction info on an order you either need to call order.Finalize or order.UpdateTransaction if the order is already finalized.

    Hope this helps

    Matt

  • Fedor Krutko 13 posts 123 karma points
    May 09, 2021 @ 08:56
    Fedor Krutko
    0

    Hi Matt,

    thank you for the answer. I've ended up with something like this:

    var order = sessionManager.GetCurrentOrder(store.Id).AsWritable(uow).UpdateTransaction(0, paymentId, Vendr.Core.Models.PaymentStatus.PendingExternalSystem);
    orderService.SaveOrder(order);
    
    var status = dibs.FetchPaymentStatus(order, payment.PaymentProviderSettings);
    
    if (status?.TransactionInfo?.PaymentStatus == Vendr.Core.Models.PaymentStatus.Authorized || status?.TransactionInfo?.PaymentStatus == Vendr.Core.Models.PaymentStatus.Captured)
    {
        order.Finalize(order.TotalPrice.Value.WithTax, paymentId, status.TransactionInfo.PaymentStatus);
    }
    

    Is this the correct way of finalizing the order?

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    May 10, 2021 @ 08:21
    Matt Brailsford
    0

    it'll probably work, but is a few things I'd recommend against.

    You are current updating the transaction and then finalizing it depending on the payment status returned but there is no point calling the UpdateTransaction method if you are going to finalize so I'd probably put that in an if/else.

    For the finalized amount you are just passing the order total price through but this should really be retrieved from the payment gateway as the purpose of this is to say "this is the amount that was captured by the gateway". Also, if you are using Vendr 1.5.0+ then if you are to use the order amount, you should really be using the order.TransactionAmount property.

    Generally speaking, there should only be a need to "Save" an order once per request. Given everything is happening within a Unit of Work, this makes it all transnational and so you should only really need to save at the end of the transaction.

    Matt

  • Fedor Krutko 13 posts 123 karma points
    May 11, 2021 @ 13:31
    Fedor Krutko
    0

    I agree that UpdateTransaction looks out of place here, but I don't see how else should I fetch the payment status when I get redirected to thank you page from the payment gateway.

    The way I see it - I need to call the UpdateTransaction to fill the TransactioId property of the current order with the transaction id passed by the payment provider gateway in the thank you url.

    Then I can get the payment status by calling the FetchPaymentStatus, which uses order.TransactionInfo.TransactionId to query the payment provider API.

    There must be something I'm missing here, I'm sure, but I don't see it, and I couldn't find any example of handling the payment flow, be it older DIBS D2, or any other payment system.

    Thanks, Fedor

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    May 12, 2021 @ 08:07
    Matt Brailsford
    0

    Hi Fedor,

    From what you are saying, I'm not sure you are going about things the right way.

    Is this a follow on from your custom payment provider implementation question previously? If so, this should all really be part of the payment provider, but from what you are saying here, it sounds like you are doing this all on your continue page and then updating the transaction info externally.

    If you are implementing a payment provider, and you need to process the payment at the point of returning to the site then you should pass the continueUrl we provide you during the payment providers GenerateForm method to the gateway and also set your payment provider to have FinalizeAtContinueUrl set to true. When this is set to true, when the gateway returns you to the continue URL, it will also trigger the ProcessCallback method where you can extract your transaction information and return it in the CallbackResult where Vendr will take care of finalizing the order for you. Once it's done that it will automatically redirect you to the confirmation page configured in your payment provider.

    There really should be any need for you to do all of this stuff external to a payment provider implementation.

    Matt

  • Fedor Krutko 13 posts 123 karma points
    May 13, 2021 @ 11:22
    Fedor Krutko
    0

    Hi Matt,

    I'm trying to implement the Dibs Easy payment. I'm using the unofficial plugin from here: https://github.com/bjarnef/vendr-payment-provider-dibs/tree/feature/dibs-easy

    I have now refactored my code, so that it should be more in line with checkout flow schematic (i.e. using BeginPaymentForm).

    But @using (Html.BeginPaymentForm do crash with "System.UriFormatException: Invalid URI: The URI is empty"

    I guess it can't find the callback url, and, honestly, I can't find where to put it either. There is no callback url property in Payment method settings, and looks like no method to do so from code.

    Maybe @bjarnef could please help?

    Thanks, Fedor

  • Fedor Krutko 13 posts 123 karma points
    May 19, 2021 @ 15:43
    Fedor Krutko
    100

    So it seems I'm not very bright, as it took me some time to figure this out :)

    All I had to do was use Html.BeginPaymentForm and Vendr and payment plugin would handle all the rest.

    It's all good now.

Please Sign in or register to post replies

Write your reply to:

Draft