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
Unable to JSON Serialize Result #102
Comments
Hi, thanks for reaching out. Can you share the code snippet and the logs so we have a better idea of what solution would work? |
The log is simply an exception that states the following result can't be parsed to JSON.
I'm working around this by taking the response and breaking it into a simplified custom response. I also can't find anywhere in the BrainTree docs where it states what should be returned to the Drop-In-UI. |
The returned object in result after calling I also wanted to confirm if you see an object description when you print Please let me know if you have any more comments or problems. Thanks! |
I will give those suggestions a try. When I try to use payment_method_token the request always fails, however when I use payment_method_nonce it returns succesful.
Jameson W Parker
Owner & Software Developer
www.selectedpixel.com
920.203.4106
… On Jul 16, 2018, at 5:04 PM, Yash Agrawal ***@***.***> wrote:
The returned object in result after calling gateway.subscription.create is not JSON serializable. You could use a toString method or __repr__ if that serves your needs.
I also wanted to confirm if you see an object description when you print json.dumps(result) because from the snippet you sent, it seems like you are passing a nonce for the payment_method_token. Since you need a vaulted payment method before associating it with a subscription usually the simplest method is to pass a payment_method_token. Read this for more info.
Please let me know if you have any more comments or problems. Thanks!
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Comment if the issue persists. |
Hey.. Its 2 years since your comment. But I still see this as an issue. Please let me know if someone was able to convert this String representation to a well formed Json ( Not sure why its not JSON in the first place.. it would have been best). I get this right now. |
@TheAshwanik You're right that these aren't JSON serializable strings. We can look into adding this functionality in a future major version update. |
hey @TheAshwanik @demerino was there any solution to this? cheers |
No additional work on adding this was done. This is not a high priority for us at this time (too many other things to work on right now), but we'd love to review a pull request if anyone feels passionately about adding this functionality. |
@crookedneighbor class ErrorResults(dict):
def __init__(self, fname):
dict.__init__(self, fname=fname)
# directly dump the object
errs = ErrorResults()
json.dumps(errs) maybe I can make a PR |
Any updates on this? error handling is a bit of a mess in the python api |
General information
Issue description
Hello, I'm having trouble JSON serializing the result object that is returned when calling
gateway.subscription.create
. I've tried using json.dumps and it just tells me the object cannot be serialized. I'm sure this is something I'm doing wrong, but I don't really know where else to go.Thank you.
The text was updated successfully, but these errors were encountered: