Copied to clipboard

Flag this post as spam?

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


  • Michel Collard 44 posts 264 karma points c-trib
    Sep 10, 2020 @ 08:26
    Michel Collard
    0

    Payment Provider CallbackResult

    Hi,

    First of all, I want to thank you for this great package. Vendr is really awesome!

    I'm building my own PaymentProvider which actually works great thanks to al the other projects that I could use as an example on GitHub.

    There is just one thing I can't really get my head around.

    When the CallbackResult is returned in my payment provider, it is possible to send TransactionInfo, MetaData and an HttpResponseMessage. Is it possible to send some kind of information in this CallbackResult which can be shown in the payment failed page?

    It is possible to get the finalized order in the succes page but I can't seem to get any information from the failed order in the payment failed page.

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Sep 10, 2020 @ 08:40
    Matt Brailsford
    0

    Hi Michel,

    Really glad to hear you are liking Vendr, and also really cool you've created your own payment provider. What payment gateway is it for?

    I think before I can give you a definitive answer I could really do with knowing the flow of the payment provider you've created and what actions your are performing where in the lifecycle of the payment provider as there are a number of way a payment provider can actually work dependent on the payment gateways API.

    If you can provider a bit more detail, I'll see what I can suggest.

    Matt

  • Michel Collard 44 posts 264 karma points c-trib
    Sep 10, 2020 @ 09:35
    Michel Collard
    0

    The Payment Provider is for Buckaroo. Instead of the Buckaroo SDK, I made my own implementation.

    Let me just take one example which has the least communication and doesn't have a redirect to any gateway.

    GenerateForm will be called with all the order information needed. (Without communication to the payment gateway.) Next, I will return a new PaymentFormResult() containing the continueUrl and the FormMethod.Post.

    (The review page is shown.) And after clicking the submit button, the ProcessCallback will be called. Inside this method, we send a request to Buckaroo which will then immediately give back a response containing the status and a description.

    I'd like to do something with this response.

    The ProcessCallback will return this(at the moment):

    return CallbackResult.Ok(new TransactionInfo
    {
        AmountAuthorized = transactionResponse.AmountCredit,
        TransactionId = transactionResponse.Key,
        PaymentStatus = GetPaymentStatus(transactionResponse.Status.Code.CodeProperty)
    });
    

    But I would like to send some info, maybe like this?:

    return new CallbackResult() { 
        TransactionInfo = new TransactionInfo
        {
            AmountAuthorized = transactionResponse.AmountDebit,
            TransactionId = transactionResponse.Key,
            PaymentStatus = GetPaymentStatus(transactionResponse.Status.Code.CodeProperty)
        },
        HttpResponse = new HttpResponseMessage(System.Net.HttpStatusCode.OK)
        {
            Content = new StringContent($"Paymentstatus={transactionResponse.Status.Code.Description}")                        
        }//, Could add extra MetaData from Buckaroo.
    };
    

    After this method it will navigate to the payment succes and payment failed screen.

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Sep 10, 2020 @ 09:42
    Matt Brailsford
    0

    Oh cool, did you know there is already a Buckaroo payment provider available?

    https://www.nuget.org/packages/Vendr.Contrib.PaymentProviders.Buckaroo/

    This one is a community contributed provider with all the source code available at https://github.com/vendrcontrib/vendr-payment-provider-buckaroo

    Would this suite your needs? Or do you require to use an alternative Buckaroo approach?

    Matt

  • Michel Collard 44 posts 264 karma points c-trib
    Sep 10, 2020 @ 10:07
    Michel Collard
    0

    Thanks for the quick reply!

    Yes, i did! That's a great way to get a quick start with Buckaroo for Vendr. But it didn't quite suit our needs.

    The contrib package actually does kind of the same thing in the processcallback method. Which(I think) still doesn't give me any info on the failed order in the payment failed page?

    Maybe in the future I will merge my custom project and this contrib package to add some awesome features(if it is compatible*). But for the time being, we require an alternative approach.

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Sep 10, 2020 @ 10:31
    Matt Brailsford
    100

    No problem. Would be cool if you could merge anything you come up with if it's an improvement of what is there.

    Anyways, in that case, it's important to know that the ProcessCallback method here is being called in response to a webhook request from the payment gateway, which means, this is happening external to the checkout process and so returning something from this method, isn't going to help you here as this will get returned to the payment gateway, not to your customer.

    One thing you could do is return MetaData from the callback response which is essentially a dictionary for you to store any data you like. This will ultimately get stored on the order in it's Properties collection. So, you could set a "BuckarooPaymentStatusDescription" meta data property and populate it with the message, and then in your error page, check to see if that property exists on the order.

    It's important to note here though, that as mentioned above, ProcessCallback is called async, so it might be that you hit the confirmation page before the webhook is called, and so this property might not be set by then. This all depends on how Buckaroo works, as some gateways do wait till they get a response from the webhook before redirecting back to the site.

    I think this really is the only way to pass data back from that method, but I guess it also depends on how Buckaroo redirects back, and whether there is anything in the request that can be processed inside the GetErrorUrl method that you could then re-append onto the error URL as a querystring.

    Matt

Please Sign in or register to post replies

Write your reply to:

Draft