dmjio / stripe

:moneybag: Stripe API
http://hackage.haskell.org/package/stripe-haskell
177 stars 74 forks source link

ToJSON for StripeError #36

Open bitemyapp opened 8 years ago

bitemyapp commented 8 years ago

Is there ever sensitive information in the StripeError value? If not, could there be a ToJSON instance? It'd spare me playing data-relay with the error since I'd just be passing the same information down to the JS client.

dmjio commented 8 years ago

Hey, I don't think any sensitive info would be transmitted in the error messages (certainly not API keys, although maybe customer ids - but those aren't understandable). I see nothing wrong with a ToJSON instance for StripeError, as long as consumers of this library know that it is for convenience purposes. Since StripeErrors can only be received from stripe. The only alternative would be to wrap StripeError in a newtype. So yea, ToJSON StripeError sounds good to me. :+1:

bitemyapp commented 8 years ago

Also, screenshot from 2016-04-14 14-30-46 screenshot from 2016-04-14 14-30-42

@dmjio so, do you usually make one-off API types for this sort of thing?

dmjio commented 8 years ago

Stripe's APIs don't accept JSON, but return it. A NewCard is meant to be submitted as a form url-encoded query parameter.

bitemyapp commented 8 years ago

@dmjio oh sure, I was thinking of recycling the datatype for inputs from our SPA client, reduce petty surface area.

dmjio commented 8 years ago

@bitemyapp, Ah I see, I suppose we could add To/FromJSON instances to types like NewCard. I can see how that would fit a use case. Would need to ensure the isomorphisms hold. Want to avoid user confusion though.

dmjio commented 8 years ago

@bitemyapp would you want just NewCard? Or others as well? I assume a lot of people are probably going to want to this as well ...

bitemyapp commented 8 years ago

@dmjio well, sorta just plugging away as I go really. Think NewCard, SubscriptionId, and StripeError would cover it for now.

dmjio commented 8 years ago

Sounds like the beginnings of a branch, I'll start one.

bitemyapp commented 8 years ago

@dmjio ty ty <3

dmjio commented 8 years ago

:)