ruby-on-railsrubyrecurly

Invalid billing_info when upgrading Recurly Gem


Going from version 2.9.3 -> 2.18.0 for the ruby gem. Have been using v4 for Recurly.js so that stays the same.

This has been working for years and I decided to upgrade the gem.

I am generating the front end token with:

recurly.configure({ publicKey: RECURLY_JS_PUBLIC_KEY })

It generates a token and pass it along to the backend where we do:

Recurly::Account.create!(
  account_code: account_code,
  billing_info: { token_id: params['recurly-token'] }
)

It keeps raising this error:

Recurly::Resource::Invalid (billing_info is invalid)

I've been messing around with this a lot. Putting in a random string as the token or waiting 20 minutes for the token to expire will throw a different error message:

Recurly::Resource::Invalid:  Token (billing_info.token_id) is either invalid or expired

So I feel like it is reading my token correctly and the keys are correct. Could it be that maybe the billing info that I used to generate the token be bad? I've filled out so many different combinations of correct addresses and test credit card numbers.

I'm out of ideas and any help would be nice.


Solution

  • Figured out the issue.

    There was a problem with the country input. Originally the ISO alpha-2 code worked for the country. But once I updated the gem, the ISO alpha-2 code no longer worked. The front end validation would work and it would create a token fine but the backend would not accept that token.

    So using US did not work anymore but United States worked.

    I ended up building a dropdown from this list: https://docs.recurly.com/docs/countries-provinces-and-states