Aaron Langley - 440 - May 20, 2014

Is the ServiceStack.Stripe API (4.0.20) up to date or I’m using it wrong?

I need to pass the Card as a token using client side Stripe.js. And also I was getting a data type issue, Stripe is expecting the TrialEnd date to be an int (Unix date) . I’m getting around it by posting this:

public class CreateStripeCustomerFromToken : CreateStripeCustomer
{
   public new string Card { get; set; }
   public new long TrialEnd { get; set; }
}
Just curious if others have the same issue? For the date issue I guess it could be one of these overrides that we rely on else where causing an issue. –  JsConfig<DateTime>.SerializeFn = … etc.

Aaron Langley:

Customer.Subscription appears to be Customer.Subscriptions collection now. However I see how easy it is to replace or override this service contract in my own code now.

Aaron Langley:

Actually is there a way I can control the scope of:  ServiceStack.Text.JsConfig<DateTime>.SerializeFn ?

Aaron Langley:

There is JsConfig.BeginScope() however it doesn’t apply to these functions. According to this* and by my testing.  But is it thread safe to do what is suggested in the answer? I can’t see how it would be.

*http://stackoverflow.com/questions/17848932/servicestack-set-serialize-function-within-a-scope

Are you doing this from within the StripeGateway? because each call to Stripe is already run within a customized scope which converts DateTime’s to Unix timestamps, see:
https://github.com/ServiceStack/Stripe/blob/master/src/Stripe/StripeGateway.cs#L392

Aaron Langley:

It seems like ServiceStack.Text has two systems - the scoped one you mention and the intercepts in the generic JsConfig<T>.SerializeFn / DeserializeFn - can these ones be scoped too? 

Aaron Langley:

In my custom serializeFn this check appears to work:
if (JsConfig.DateHandler == DateHandler.UnixTime) {
    return date.ToUnixTime().ToJson();
}

ok great, because the type-specific JsConfig<T> config can’t be scoped.