Skip to content
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

Cancel subscription call returns JSON error? #9

Open
robmomary opened this issue Sep 12, 2014 · 12 comments
Open

Cancel subscription call returns JSON error? #9

robmomary opened this issue Sep 12, 2014 · 12 comments

Comments

@robmomary
Copy link

Hi,

Using rails 4.1.0, wepay 0.0.3

ONLY when I call a cancel subscription call, i am getting this error:

JSON::ParserError:
A JSON text must at least contain two octets!

When i do a raise on the response.body object (raise response.body.inspect) I get this:

"{"subscription_plan_id":1425787008}"

The JSON looks ok. Also, when I do:

JSON.parse("{"subscription_plan_id":1425787008}")

It parses just fine? I am totally stumped as to why I'm getting this error. Anyone else having this problem?

@scottefein
Copy link

Can you print the response out without doing inspect + raising? And could you check the type of what's returned?

@robmomary
Copy link
Author

when i do a "puts response.body" I get:

{"subscription_plan_id":1029356427}

I added the following code to debug insidewepay.rb:

    puts "Call: #{call}"
    puts "Response: #{response}"
    puts "Response.body: #{response.body}"
    puts "Response.http_version: #{response.http_version}"
    puts "Response.message: #{response.message}"
    puts "Response.code: #{response.code}"

And this is what i get :

DESTROYING SUBSCRIPTION
Call: #Net::HTTP::Post:0x007f8ec9564cf8
Response: #Net::HTTPInternalServerError:0x007f8ec9574108
Response.body:
Response.http_version: 1.1
Response.message: Internal Server Error
Response.code: 500

Call: #Net::HTTP::Post:0x007f8ec958edf0
Response: #Net::HTTPOK:0x007f8ec959d8c8
Response.body: {"subscription_plan_id":548391780,"state":"Deleted"}
Response.http_version: 1.1
Response.message: OK
Response.code: 200

Not sure why i'm getting two calls there?

On Sep 15, 2014, at 5:55 PM, Scott Feinberg [email protected] wrote:

Can you print the response out without doing inspect + raising? And could you check the type of what's returned?


Reply to this email directly or view it on GitHub.

@scottefein
Copy link

What's weird is that none of the IDs match up...

@vasusen what do you think?

@robmomary
Copy link
Author

Im creating and deleting a subscription each time i run a test

On Sep 15, 2014, at 6:18 PM, Scott Feinberg [email protected] wrote:

What's weird is that none of the IDs match up...

@vasusen what do you think?


Reply to this email directly or view it on GitHub.

@scottefein
Copy link

I'm wondering if there's a race condition here. Can you add a 10 second
wait after you create?

On Mon, Sep 15, 2014 at 4:24 PM, robmomary [email protected] wrote:

Im creating and deleting a subscription each time i run a test

On Sep 15, 2014, at 6:18 PM, Scott Feinberg [email protected]
wrote:

What's weird is that none of the IDs match up...

@vasusen what do you think?


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub
#9 (comment).

@robmomary
Copy link
Author

I can - but i got the same response after i did a delete in the app (not testing) - the record had been created a while ago

On Sep 15, 2014, at 6:26 PM, Scott Feinberg [email protected] wrote:

I'm wondering if there's a race condition here. Can you add a 10 second
wait after you create?

On Mon, Sep 15, 2014 at 4:24 PM, robmomary [email protected] wrote:

Im creating and deleting a subscription each time i run a test

On Sep 15, 2014, at 6:18 PM, Scott Feinberg [email protected]
wrote:

What's weird is that none of the IDs match up...

@vasusen what do you think?


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub
#9 (comment).


Reply to this email directly or view it on GitHub.

@scottefein
Copy link

Just trying to rule out the 500 error

On Mon, Sep 15, 2014 at 4:29 PM, robmomary [email protected] wrote:

I can - but i got the same response after i did a delete in the app (not
testing) - the record had been created a while ago

On Sep 15, 2014, at 6:26 PM, Scott Feinberg [email protected]
wrote:

I'm wondering if there's a race condition here. Can you add a 10 second
wait after you create?

On Mon, Sep 15, 2014 at 4:24 PM, robmomary [email protected]
wrote:

Im creating and deleting a subscription each time i run a test

On Sep 15, 2014, at 6:18 PM, Scott Feinberg <
[email protected]>
wrote:

What's weird is that none of the IDs match up...

@vasusen what do you think?


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub
#9 (comment).


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub
#9 (comment).

@robmomary
Copy link
Author

Hey there,

I just added "sleep 10" before the call, got this:

DESTROYING SUBSCRIPTION
Call: #Net::HTTP::Post:0x007f8ed2a8e180
Response: #Net::HTTPInternalServerError:0x007f8ed2a95368
Response.body:
Response.http_version: 1.1
Response.message: Internal Server Error
Response.code: 500
Call: #Net::HTTP::Post:0x007f8ed2aa7e28
Response: #Net::HTTPOK:0x007f8ed2ab5d70
Response.body: {"subscription_plan_id":456914568,"state":"Deleted"}
Response.http_version: 1.1
Response.message: OK
Response.code: 200

On Sep 15, 2014, at 6:30 PM, Scott Feinberg [email protected] wrote:

Just trying to rule out the 500 error

On Mon, Sep 15, 2014 at 4:29 PM, robmomary [email protected] wrote:

I can - but i got the same response after i did a delete in the app (not
testing) - the record had been created a while ago

On Sep 15, 2014, at 6:26 PM, Scott Feinberg [email protected]
wrote:

I'm wondering if there's a race condition here. Can you add a 10 second
wait after you create?

On Mon, Sep 15, 2014 at 4:24 PM, robmomary [email protected]
wrote:

Im creating and deleting a subscription each time i run a test

On Sep 15, 2014, at 6:18 PM, Scott Feinberg <
[email protected]>
wrote:

What's weird is that none of the IDs match up...

@vasusen what do you think?


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub
#9 (comment).


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub
#9 (comment).


Reply to this email directly or view it on GitHub.

@robmomary
Copy link
Author

any update on this?

@scottefein
Copy link

Sorry for the delay here-had to dive into this. While it correctly deletes the subscription, there appears to be a bug on our side that's returning 500. We're working on a fix and will let you know once it's resolved. The SDK is retrying after it gets 500 the first time, which is what you're seeing.

Sorry about that! Will let you know once we have a resolution.

@robmomary
Copy link
Author

ping :)

@saida
Copy link

saida commented Mar 4, 2015

Getting the same error when I make a call to '/user'

> WEPAY.call('/user', wepay_access_token)
JSON::ParserError: A JSON text must at least contain two octets!
    from /Library/Ruby/Gems/2.0.0/gems/json-1.8.1/lib/json/common.rb:155:in `initialize'
    from /Library/Ruby/Gems/2.0.0/gems/json-1.8.1/lib/json/common.rb:155:in `new'
    from /Library/Ruby/Gems/2.0.0/gems/json-1.8.1/lib/json/common.rb:155:in `parse'
    from /Library/Ruby/Gems/2.0.0/gems/wepay-0.0.3/lib/wepay.rb:60:in `call'
    from (irb):23
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.1.5/lib/rails/commands/console.rb:90:in `start'
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.1.5/lib/rails/commands/console.rb:9:in `start'
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:69:in `console'
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.1.5/lib/rails/commands.rb:17:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants