Copied to clipboard

Flag this post as spam?

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


  • Gordon Saxby 1461 posts 1883 karma points
    Nov 15, 2022 @ 12:01
    Gordon Saxby
    0

    Handling a webhook call

    The payment provider I am working with allows the use of webhooks but they are configured at the Account level, rather than as part of the Checkout. Therefore I cannot set it up using "context.Urls.CallbackUrl".

    They say:

    You would need to supply a URL for an application within your environment which listens for async notifications about transactions. Every time a transaction is created (or its status is updated) you will get a notification to the webhook URL. It is not possible to set this up on the createCheckout API request, and you will need to set it up at an account level. Here is an example of the raw webhook content:

    {"timestamp":"2022-11-15T02:45:09.784Z","requestid":"6372fd3526b16b4838a09e1b","id":"637258218b5ace447155e01a","type":"transaction"}

    The ‘_id’ value is the Transaction ID which was created or updated.

    Is it possible to handle this via the Vendr Payment Provider code, or would it need to be a separate API endpoint?

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Nov 15, 2022 @ 13:19
    Matt Brailsford
    100

    Hi Gordon,

    Yea, this is possible. Take a look at the Stripe docs about webhooks as this works in a similar way, registering a global webhook handler https://vendr.net/docs/payment-providers/stripe/2.0.0/stripe-checkout/getting-started/configuring-stripe/#webhook

    The main difference is that the globaly registered webhook handlers don't hold an order ID / Number in their URL and so in your payment provider you will have to also implement the GetOrderReference method and in it perform some requests back to the payment provider gateway in order to extract the details of the order the webhook communication is for. In Vendr we have a OrderReference entity you need to return which is basically an order ID + order Number combo.

    The usual way of doing this is when you place the payment at the payment provider, store the order reference as meta data on the transaction, and then in GetOrderReference lookup the payment and extract the reference.

    Here's the code for the Stripe provider which does the same https://github.com/vendrhub/vendr-payment-provider-stripe/blob/v2/dev/src/Vendr.PaymentProviders.Stripe/StripePaymentProviderBase.cs#L45

  • Gordon Saxby 1461 posts 1883 karma points
    Nov 15, 2022 @ 14:07
    Gordon Saxby
    0

    Thanks Matt.

    I am storing the order reference with the payment provider, is that what you mean?

    E.g.

    vendr://order/74f99af0-1cca-42eb-95e0-01847b12d0a5/CART-01049-41762-KYH53
    

    Is there an existing handy utility function to split it up?

    EDIT: ah, is it this

    OrderReference.Parse(stripeSession.ClientReferenceId)
    
  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Nov 15, 2022 @ 14:20
    Matt Brailsford
    0

    Yup 👍

    PS it should be order number on the end, not cart number

  • Gordon Saxby 1461 posts 1883 karma points
    Nov 15, 2022 @ 14:22
    Gordon Saxby
    0

    I'm creating the reference using this when creating the checkout at the payment provider (before sending the user to the checkout page (or the payment provider)

    context.Order.GenerateOrderReference()
    

    is that not correct?

    Just noticed Vendr has been setup like this:

    enter image description here

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Nov 15, 2022 @ 14:46
    Matt Brailsford
    0

    Ahh, that'll be why 👍

  • Gordon Saxby 1461 posts 1883 karma points
    Nov 15, 2022 @ 14:48
    Gordon Saxby
    0

    Yeah, I didn't set the project / site up ... waiting to find out why it's been done that way 😕

Please Sign in or register to post replies

Write your reply to:

Draft