Giter VIP home page Giter VIP logo

rechargesharp's Introduction

rechargesharp's People

Contributors

dependabot[bot] avatar jnysteen avatar jonpmckinley avatar jrummell-elite avatar mattgenious avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

rechargesharp's Issues

ShippingRate response model does not match Recharge API

The developer API for retrieving shipping rates for a checkout shows phone_required as a boolean value, however my testing reveals that this property is possibly null.

This causes a Newtonsoft JSON deserialization exception:

Newtonsoft.Json.JsonSerializationException: Error converting value {null} to type 'System.Boolean'. Path 'shipping_rates[0].phone_required', line 1, position 229.   ---> System.InvalidCastException: Null object cannot be converted to a value type.     at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)     at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)     --- End of inner exception stack trace ---     at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)     at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)     at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)     at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)     at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)     at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)     at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)     at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)     at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)     at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)     at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)     at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)     at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)     at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)     at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)     at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)     at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)     at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)     at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value)     at RechargeSharp.Services.Checkouts.CheckoutService.RetrieveShippingRatesAsync(String token, OverrideShippingLinesRequest overrideShippingLinesRequest)     at Amora.Promotions.Web.Infrastructure.Services.ApiRequestServiceExtensions.LogAsync[TResponse](IApiRequestService service, ApiRequestTypeEnum requestType, HttpMethod method, String url, Func`1 requestFunc, Object request, Order order) in C:\Users\Jon\source\repos\***\Services\ApiRequestServiceExtensions.cs:line 48

As a resolution to this issue, I propose changing ShippingRate.PhoneRequired to a bool? type. I intend to submit a PR to resolve this issue shortly.

Here is an example Postman request showing the property as null:

image

Analytics data is missing from create checkout request

I might be missing something, but I can't find a way to include analytics data when creating a checkout.

Here's an excerpt from the API documentation:

utm_params optional
utm_params will be added to subscription, customer and charge objects after successful processing of the checkout.

https://developer.rechargepayments.com/v1#create-a-checkout

{
  "analytics_data": {
    "utm_params": [{
      "utm_campaign": "spring_sale",
      "utm_content": "textlink",
      "utm_data_source": "shopify_cookie",
      "utm_medium": "cpc",
      "utm_source": "google",
      "utm_term": "mleko",
      "utm_timestamp": "2020-03-05"
    }]
  },
  "discount_code": "POPUS_25",
  "email":"[email protected]",
  "..."

I'm happy to submit a pull request as we need this functionality to complete a Recharge integration for a client.

`Checkout.ShippingRate` response model does not match Recharge API

Hello again,

The developer API reference for retrieving a checkout and updating a checkout shipping line show that Checkout.ShippingRate should be a single ShippingRate object, and not a List<ShippingRate> object.

Through my testing, I've confirmed this and found that it is causing a deserialization issue because it is a single object whereas it is expecting an array:

Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[RechargeSharp.Entities.Shared.ShippingRate]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.  To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.  Path 'checkout.shipping_rate.code', line 1, position 2399.

image

As a resolution to this issue, I propose changing Checkout.ShippingRate to a single ShippingRate object. I will be submitting a PR shortly to resolve this deserialization issue!

A generic Exception is thrown when Shopify responds with 429 (rate limiting)

When Shopify returns HTTP status code 429 (rate limiting), the Recharge API wraps it in a response with HTTP status code 400, which, in turn, makes this client throw an Exception, with no structured information about what went wrong.

Expected behaviour: The RechargeSharp client should handle retries/backoff and shield the consumer from this, or at least return enough structured information for the consumer to properly deal with the error.

A real-life example (sensitive info has been replaced with XXX's):

Message

"Method: POST, RequestUri: 'https://api.rechargeapps.com/charges/XXXX/process', Version: 1.1, Content: System.Net.Http.StringContent, Headers:
{
  Accept: application/json
  X-Recharge-Access-Token: XXXX
  traceparent: XXX
  Content-Type: application/json
  Content-Length: 2
}
StatusCode: 400, ReasonPhrase: 'BAD REQUEST', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
{
  Server: nginx
  Date: Thu, 24 Mar 2022 12:49:59 GMT
  Connection: keep-alive
  X-Recharge-Version: 2021-01
  Access-Control-Expose-Headers: link, x-request-id, x-recharge-limit, x-recharge-version
  Access-Control-Allow-Origin: https://admin.rechargeapps.com
  Vary: Origin, Cookie
  X-Recharge-Limit: 1/40
  Set-Cookie: session=XXXX; Secure; HttpOnly; Path=/; SameSite=None
  X-Request-ID: XXXX
  X-Content-Type-Options: nosniff
  Strict-Transport-Security: max-age=63072000; includeSubdomains
  Content-Type: application/json
  Content-Length: 292
}
{\"error\":\"Shopify returned 429 rate limit regarding this call, please wait and try again Payment Processor stripe Transaction Id XXXX Refunded Transaction ID XXXX - Shopify returned 429 rate limit regarding this call, please wait and try again\"}
"

StackTrace

"   at RechargeSharp.Utilities.ExceptionUtility.ThrowIfSuitableExceptionFound(HttpResponseMessage responseMessage)
   at RechargeSharp.Services.RechargeSharpService.HandleHttpResponseMessage(HttpResponseMessage httpResponseMessage)
   at Polly.PolicyBuilder`1.<>c__DisplayClass14_0.<OrResult>b__0(TResult result)
   at Polly.ResultPredicates`1.<>c__DisplayClass2_0.<AnyMatch>b__0(ResultPredicate`1 predicate)
   at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
   at Polly.Retry.AsyncRetryEngine.<ImplementationAsync>d__0`1.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at Polly.AsyncPolicy`1.<ExecuteAsync>d__13.MoveNext()
   at System.Runtim…	string`

Enums for statuses

For example there should be enums for subscriptions status as you should not have to know if ReCharge writes "active", "Active" or "ACTIVE in the status string field.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.