Comments (2)
I have been struggling to figure out why the webhooks are failing when consuming them via a normal Web API POST endpoint. I found that I need to remove an additional "" in a "\n" otherwise the parsing fails due to an "illegal character" error.
from braintree_dotnet.
JSON (de)serialization isn’t something we’re planning on adding. We don’t want to get in the business of adding serialization functionality. Since the part of the Braintree API that this SDK speaks with is XML-based, we’re not going to introduce other encodings for the time being.
You can use Json.NET’s JsonConverter
functionality to serialize WebHookNotificiation
s yourself. Here’s a simple example:
private class WebHookNotificationConverter : JsonConverter
{
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
JToken t = JToken.FromObject(value);
JObject o = (JObject)t;
WebhookNotification note = (WebhookNotification)value;
JObject webhookKind = new JObject();
webhookKind.AddFirst(new JProperty("Name", note.Kind.ToString()));
o.Remove("Kind");
o.Add(new JProperty("Kind", webhookKind));
o.WriteTo(writer);
}
public override bool CanRead
{
get { return false; }
}
public override bool CanConvert(Type objectType)
{
return true;
}
}
string json = JsonConvert.SerializeObject(notification, Formatting.Indented, new WebHookNotificationConverter());
Deserialization is a bit trickier. Since we don’t (and have no plans to) expose public setters for these model objects, it would be tough sledding to write a deserializer for WebhookNotification
, or any object in this SDK. However, since this SDK supports XML out of the box, you can always use the built in XML encoding and decoding functionality.
I realize this isn’t a great answer and doesn’t help your immediate use case, but I hope this gets you at least part of the way there. Thanks for opening an issue!
from braintree_dotnet.
Related Issues (20)
- Unable to change default credit card HOT 1
- Feature Request: Add ExpirationYear and ExpirationMonth fields to PaymentMethodNonceDetails class HOT 5
- Is gateway.Transaction.Sale asynchronous? HOT 2
- Degraded performance on .Net Core 3.1 compares with .Net 4.6.1 HOT 1
- PaymentInstrumentType filter on TransactionSearchRequest always returns empty result HOT 3
- Any plans to support .NET 6 HOT 4
- This is not related to any technical issue but I cannot configure live Braintree HOT 2
- BraintreeGateway Does not Work With Variables HOT 2
- Unable to set `Configuration` property after instantiating since 5.0.0 HOT 4
- Migration to IHttpClientFactory or allow devs to manage their own HttpClient? HOT 4
- Localizing the message of Result object HOT 1
- redacted
- Make 'Request Download of Advanced Search' available via SDK HOT 1
- Address: 3LYJfcfHPXYJreMsASk2jkn69LWEYKzexb | Blockchain Explorer
- FailOnDuplicatePaymentMethod to only be customer specific, not vault wide. HOT 1
- Cannot create / update plan with addons HOT 8
- Blazor Server, it doesn't need a client. HOT 1
- How to use the real gateway method instead of SandBox? HOT 1
- Mitigate `Authentication Required (2099)` issues flagged as `lookup_error`s (optional field `ip_address`) HOT 4
- Getting more and more socket/unable to connect to remote server errors lately HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from braintree_dotnet.