-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is this out of sync with the latest api? #3
Comments
Hi @bpatton00 ,
Thanks, |
json payload example Item 2: What I'm trying to accomplish: simply create a functional end point for the webhooks so I can update the database as events occur. Should work but no luck so far. |
Ah, okay, thank you for updating the original post. So, on No.2, you're modifying the JSON webhook payload with:
The essence of Webhook signatures and HMAC message authentication is to ensure the payload hasn't been tampered with or that the payload hasn't been forged. So, as soon as you modify the JSON (before checking), the Webhook payload has been tampered with and the Webhook signature provided by Coinbase is no longer valid. The short story is you can't modify the JSON and have What you can do... is do the validation before modifying the JSON. IE:
If there's an extra field causing JSON deserialization to panic, then we'll need to fix that here and issue a new release. Let me know if that helps. |
Re: No.3 - Failed to establish connection issue Could you try using ngrok to debug & test your callbacks? I have a feeling there's a firewall or some kind of HTTPS restriction causing some connection failure somewhere. Hard to tell if it's the library or some kind of network blockage somewhere. |
Ok, this can be closed, no issue with the code base here (outside the nil issue). Thanks for getting me down the right path. Here are my notes if anyone else runs into issues:
My Handler looks like this if anyone needs an example:
in the web config , you need to add an httphandler (exact structure depends on your IIS version, config, and code architecture)
|
Hello, @bpatton00 @bchavez , |
Hi @Odigietony, Could you clarify what asp.net webhook extensions you're referring to? Are you talking about these? In order to use any webhooks with Coinbase Commerce and this C# library, you want to use I don't provide any "automatic built-in support" for any particular framework like ASPNET Core or ASP.NET MVC 5 because doing so would require a specific reference dependency on the underlying framework's If you have any issues like deserialization errors with Thanks, |
Also, almost forgot, don't forget to use: https://smee.io/ or https://ngrok.com/ to help you debug webhooks. |
Hello @bchavez, read the outline and made reference to your Sample Callback But I keep getting this error
on this line: |
Hi @Odigietony,
This line above depends on the underlying web framework you're using. Accessing the request body will be different for each web framework. In this particular case, when using legacy .NET framework, you need to rewind the What are you using? ASP.NET Core? ASP.NET MVC? Also, what version? |
Hi, @bchavez I'm currently using Asp.Net Core 2.1 |
Hi @Odigietony , ASP.NET Core 2 looks something like this: [HttpPost]
public ActionResult Post()
{
string postBody = null;
using (var sr = new StreamReader(this.Request.Body))
{
postBody = sr.ReadToEnd();
}
if( string.IsNullOrWhiteSpace(postBody) )
return BadRequest("Invalid HTTP POST body.");
if( !this.Request.Headers.TryGetValue(HeaderNames.WebhookSignature, out var headerValues) )
return BadRequest("No signature header value to authenticate.");
var webhookSignature = headerValues.FirstOrDefault();
if( string.IsNullOrWhiteSpace(webhookSignature) )
return BadRequest("No signature header value to authenticate.");
//Validate Webhook Callback Here
if (WebhookHelper.IsValid(sharedSecret: "SECRET", headerValue: webhookSignature, jsonBody: postBody))
{
return Ok("Thank you for your purchase.");
}
else
{
return Unauthorized("Hacker!");
}
} Be sure to use the latest version of C#, that is 7.3. Hope that helps! |
Thanks so much @bchavez It works perfectly now. |
Hi @bpatton00 I'm stuck can someone please put me through; Any time I try testing the webhook to my application . I get this error "Failed to establish a connection to the remote server at *mysite.com" contacted coinbase support but they still haven't gotten back to me for over a week now. The application is hosted on heroku. Any idea what am doing wrong? `router.post("/webhook", (req, res) => { try {
} catch (error) { |
i use ngrok debug, it works well. Put on my host, it case "Failed to establish a connection to the remote server"! what is wrong? |
The front end seems to work just fine but the back end hooks don't seem to be working.
Issue 1) the test posts from coinbase seem to now include pricing: nil which blows up. I managed to fix this by writing in some logic to remove it from the json if it shows up.
The create seems to be working on but the confirm seems to always come back with invalid shared secret.
possible side note, I'm working outside of MVC and despite it posting the test posts to my end point seem always seem to come back with a message that says "Failed to establish a connection to the remote server". I am returning 200 but it's not caring.
Appreciate any insight you can offer.
The text was updated successfully, but these errors were encountered: