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:
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.
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)
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:
Is it possible to handle this via the Vendr Payment Provider code, or would it need to be a separate API endpoint?
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 aOrderReference
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
Thanks Matt.
I am storing the order reference with the payment provider, is that what you mean?
E.g.
Is there an existing handy utility function to split it up?
EDIT: ah, is it this
Yup 👍
PS it should be order number on the end, not cart number
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)
is that not correct?
Just noticed Vendr has been setup like this:
Ahh, that'll be why 👍
Yeah, I didn't set the project / site up ... waiting to find out why it's been done that way 😕
is working on a reply...