Coder Social home page Coder Social logo

chargebee-ruby's People

Contributors

ball-hayden avatar cb-alish avatar cb-bharathvaj avatar cb-gaurav avatar cb-goutham avatar cb-karthikp avatar cb-khushbubibay avatar cb-navaneedhan avatar cb-nithins avatar cb-prajaktachavan avatar cb-sriramthiagarajan avatar cb-thiyagu avatar cb-thushitamariaselvan avatar cb-yateshmathuria avatar hellokps avatar nijikon avatar railis avatar rraman avatar sangeethabaskaran avatar saravana-cb avatar skrish avatar vaibhav1510 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chargebee-ruby's Issues

Use the latest version of rest-client (why a downgrade!?)

Hello,

Why is there a downgrade of the rest-client gem? Your commit message is empty...

Please clarify the motivation and fix this in order to use the latest version. It is important to use always the latest gem version to avoid bugs and security issues.

Update SSL certs to SHA256

As latest browser versions are removing the support for SSL Certificates signed with SHA1, we will be updating our SSL Certificate to SHA256 hash algorithm on Dec 16th, 2015, to improve application security.

So if you are using Chargebee API, please make sure that you are using the latest certificate bundles when accessing Chargebee as a client.

json_pure version

What is the reason for holding back the json_pure version?

If it's to support older versions of ruby, someone in that situation can deal with that by holding the version back themselves in their own Gemfile.

Error when creating subscription

Hi there.

I might be missing something but I'm fighting with this bug when creating a simple subscription as stated in the doc here. Any idea on this?

ChargeBee::IOError: IO Exception when trying to connect to chargebee with url https://snapshift-test.chargebee.com/api/v2/subscriptions . Reason undefined method[]' for #<Set: {#<MIME::Type: application/json>}>`

Failing Test

The following test is failing on master:

rspec spec

F.......

Failures:

  1) ChargeBee::ListResult returns list object, with next offset attribute
     Failure/Error: list.next_offset.should =~ ["1345724673000", "1510"]
       expected: ["1345724673000", "1510"]
            got: "[\"1345724673000\", \"1510\"]" (using =~)
     # ./spec/chargebee/list_result_spec.rb:51:in `block (2 levels) in <top (required)>'

This API operation is not enabled for this site for syncing invoices

Hey all,
I'm getting the following error after hitting the invoice.sync_usages:

{
  "message":"This API operation is not enabled for this site. Please contact [email protected] to get this enabled",
  "api_error_code":"configuration_incompatible",
  "error_code":"api_restricted",
  "error_msg":"This API operation is not enabled for this site. Please contact [email protected] to get this enabled",
  "http_status_code":400
}

There is nothing about this endpoint being a special endpoint in the documentation https://apidocs.chargebee.com/docs/api/invoices?prod_cat_ver=2&lang=curl#sync_usages so I was wondering if I'm using it wrong or missing something else?

Fails to decode gzipped responses from Chargebee

When executing ChargeBee::Subscription.retrieve(subscription_id).subscription.as_json

The following error occurs

       Response not in JSON format. Probably not a ChargeBee response
        "\u001F\x8B\b\u0000\u0000\u0000\u0000\u0000

custom fields with spaces causing the API to fail

The recent changes in the UI allowed users to insert custom attributes with spaces.

image

This is causing a bug in the API.

::ChargeBee::Customer.retrieve('test-custome-id', environment).customer
NameError: `@cf_my My customer field' is not allowed as an instance variable name
from /usr/local/bundle/gems/chargebee-2.31.1/lib/chargebee/models/model.rb:39:in `instance_variable_set'

Commit messages

Hey, Just a quick one.
It might be helpful to give a quick summary on the first line of the commit messages to this repo.
The detail when you dig into them is great but because the first line is just stars it makes a flick through the git commit log pretty difficult to establish what's happening.

image

API Operation not enabled error

I am using the 2.10 version and I can confirm that my product catalog is using version 2.0. However, I am getting the following error "This API operation is not enabled for this site. Please contact [email protected] to get this enabled (ChargeBee::APIError)" for requests such as ChargeBee::Plan.list.

Any suggestions on moving forward? Thanks!

RestClient::BadRequest Error and JSON::ParseError not Caught

Using v2.6.5.

There's a ChargeBee::Error class but this code does not handle all exceptions so RestClient::BadRequest squeaks through.

The exception is not documented (as most Ruby libs and their exceptions aren't) but it and others are placed into the RestClient::Exceptions::EXCEPTION_MAP constant.


No JSON exceptions are caught here.


There's probably more but that's what I've seen so far.

Also note that RESTClient seems dead. But, maybe that's okay.

Offset being ignored when calling ChargeBee::Customer.list({:limit => limit, :offset => offset})

Hi there,

I've found a bug in Chargebee Gem (1.4.6), where the offset parameter is being ignored when called in the ChargeBee::Customer.list({:limit => limit, :offset => offset}) function. Where limit is an int and offset is returned from a previous call to ChargeBee::Customer.list().

I should be able to pass in an offset returned from the last call, and get the next set of results as per the documentation here: https://apidocs.chargebee.com/docs/api/customers#list_customers
However, I always get the same results regardless of what offset value is supplied.

I've prepared a gist to help illustrate the point here: https://gist.github.com/sebastiansibelle/4a374f1ffa4ebfc40633

I need to use this function very soon, so the quicker you could turn around a fix the better!

Thanks,

Sebastian

warning: URI.escape is obsolete

warning: URI.escape is obsolete

ruby 2.1.8

chargebee-2.2.7/lib/chargebee/models/model.rb:59:in `block in uri_path': warning: URI.escape is obsolete

Create subscription with Stripe token raising exception

I'm trying to leverage both the Stripe and Chargebee APIs to create subscriptions and I'm running into an issue with the card parameters.

According to the documentation, if the card[tmp_token] is set, there is no need to provide additional parameters.

If this value is specified, there is no need to specify other card details (like number, cvv, etc).

Here's a simplified version of the code I'm sandboxing at the moment:

require "stripe"
require "chargebee"

Stripe.api_key = "sk_test_************************"

ChargeBee.configure(
  site: "******-test",
  api_key: "test_********************************"
)

token = Stripe::Token.create(
  card: {
    number: "4242424242424242",
    exp_month: 8,
    exp_year: 2018,
    cvc: "314",
  },
)

result = ChargeBee::Subscription.create(
  {
    plan_id: "standard",
    customer: {}, # ...
    billing_address: {}, # ...
    card: {
      tmp_token: token.id, # tok_************************
    },
  }
)

The Stripe-part will later be replaced with Stripe.js for PCI compliance reasons, but I'm using it here to sandbox and prepare working code for my development environment.

By the time the Ruby interpreter calls ChargeBee::Subscription.create, it raises the following exception:

/Users/michael/.gem/ruby/2.4.0/gems/chargebee-2.3.3/lib/chargebee/rest.rb:78:in `handle_for_error': card[billing_addr1] : cannot be blank (ChargeBee::PaymentError)

It's complaining that it wants the billing_addr1 property, while the documentation states it isn't required. But, even if I, in addition to the tmp_token add the billing_addr1 property, it still continues to raise the same exception.

Any idea why this is happening? Thanks!

IO Exception "Reason cookie store unavailable: :hash"

I'm encountering the following error. Not sure whether it's an API or client issue.

IO Exception when trying to connect to chargebee with url https://imazen.chargebee.com/api/v2/subscriptions/[redacted] . Reason cookie store unavailable: :hash
/app/vendor/bundle/ruby/2.5.0/bundler/gems/chargebee-ruby-143900d4d74f/lib/chargebee/rest.rb:53:in `rescue in request'
/app/vendor/bundle/ruby/2.5.0/bundler/gems/chargebee-ruby-143900d4d74f/lib/chargebee/rest.rb:44:in `request'
/app/vendor/bundle/ruby/2.5.0/bundler/gems/chargebee-ruby-143900d4d74f/lib/chargebee/request.rb:18:in `send'
/app/vendor/bundle/ruby/2.5.0/bundler/gems/chargebee-ruby-143900d4d74f/lib/chargebee/models/subscription.rb:44:in `retrieve'

undefined method `update_payment_method' for ChargeBee::HostedPage:Class

I have been trying to follow the API guide to generate a hosted page link for customers to update their card info. Apparently ChargeBee::HostedPage.update_payment_method is not defined.

I have also tried ChargeBee::HostedPage.update_card but it gave me this error:

ChargeBee::APIError: 
from /Users/.../gems/chargebee-1.5.0/lib/chargebee/rest.rb:85:in `handle_for_error'

Any idea?

Contract Term Model should be included

The model class https://github.com/chargebee/chargebee-ruby/blob/master/lib/chargebee/models/contract_term.rb

Is not included in
https://github.com/chargebee/chargebee-ruby/blob/master/lib/chargebee.rb

To reproduce try https://apidocs.chargebee.com/docs/api/subscriptions?prod_cat_ver=1&lang=ruby#list_contract_terms_for_a_subscription

require 'chargebee'
ChargeBee.configure(:site => "{site}",
  :api_key => "{site_api_key}")
list = ChargeBee::Subscription.contract_terms_for_subscription("__test__8asukSOXdty0Mv")
list.each do |entry|
  contract_term = entry.contract_term
end

=> (uninitialized constant ChargeBee::Result::ContractTerm)
Did you mean? ChargeBee::Contact

ChargeBee::APIError#message overrides (and breaks) StandardError#message

Reproduction steps:

Assuming that you have ChargeBee already configured, run

begin
  ChargeBee::Addon.retrieve(1) # or any other ID which does NOT exit in your environment
rescue ChargeBee::Error => e
  p e.message
end

Current output:

nil

Expected output:

Sorry, we couldn't find that resource

Cause:

ChargeBee::APIError (indirectly) inherits from StandardError and passes message from json_obj[:message] as a parameter to StandardError constructor. Normally that should make message accessible as .message, but APIError defines attr_accessor :message which is never initialized.

NoMethodError (undefined method `encode' for URI:Module)

Ruby version: 3.0.0

URI.encode removed in Ruby 3.

irb(main):001:0> URI.encode
Traceback (most recent call last):
        4: from /Users/bojacobson/.rbenv/versions/3.0.0/bin/irb:23:in `<main>'
        3: from /Users/bojacobson/.rbenv/versions/3.0.0/bin/irb:23:in `load'
        2: from /Users/bojacobson/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/irb-1.3.0/exe/irb:11:in `<top (required)>'
        1: from (irb):1:in `<main>'
NoMethodError (undefined method `encode' for URI:Module)
Chargebee::Subscription.retreive("subscription-id")

=> NoMethodError (undefined method `encode' for URI:Module)

here is the culprit: b9b6a69#diff-c9a289b8798c75c2b395c35fb0b44ec0a272ab762005e9bc3b259140035874f3R59

I was able to fix this by defining the URI.encode:

module URI
  def self.encode(string)
    return URI.encode_www_form_component(string)
  end
end

Can't get subscription after creation at once

We could create a subscription without any errors.
But when trying to get a subscription by customer id in a short time, we couldn't get the subscription.
This happens sometimes.

# Create subscription
ChargeBee::Subscription.create_for_customer(chargebee_customer_id, params)


# Get subscription by customer id
list = ChargeBee::Subscription.list({"customer_id[is]" => chargebee_customer_id, limit: 1})
subscription = list.first.subscription # ERROR: undefined method `subscription' for nil:NilClass

I think there should be a delay on Chargebee and it should take few seconds to create a subscription.

What is the way to fix this issue and how long does it take to be created?

Make HTTP timeout configurable

Description

After the recent availability problems of the ChargeBee service, I had problems in my own service that relies on chargebee due to the long timeouts set in the ChargeBee ruby client. Therefore I would like to propose that the SDK allows a user to specify to set their own HTTP timeout limits as a configuration parameter.

Feature request: Webhook objects for test

Hi team,
Could you provide something like this for test webhooks behaviour in ruby test?
https://developers.braintreepayments.com/reference/general/webhooks/subscription/ruby

In my case, I created a class that provides a Chargebee webhook response, but I think that a official solution could be great. Here's my code: https://gist.github.com/patriciojofre/03464fa01b3267a6da0cabc5c99ec4b7
(I copied response from a real webhook received and then create dynamic objects)

Thanks!

Update json_pure dependency to v2

Currently in you Gemfile you have this dependency:

s.add_dependency('json_pure', '~> 1.5')

You should update that to use '~> 2.0'or at least use '>= 1.5'.

The outdated dependency also causes incompatibility with the AWS official gem that also depends on json_pure.

Timeout errors are not properly detected

At least some timeout errors do not have valid JSON, and although their body contains the reason they end up here https://github.com/chargebee/chargebee-ruby/blob/master/lib/chargebee/rest.rb#L82 resulting with a generic error.
Also, rest.rb has JSON parsing on two places, which should be unified.

A/C: Properly handle timeout errors and eventually use this code for them: https://github.com/chargebee/chargebee-ruby/blob/master/lib/chargebee/rest.rb#L65

Bonus points: create different exception types for different failure reasons.

ChargeBee::Customer.list filter param operators ("email[is]") do not work

ChargeBee::Customer.list({
    limit: 2,
    "email[is]" => "[email protected]"
})

The above code fails to find the user with the specified email. Instead it just lists all customers, most recent first.

EDIT: I have verified that this does work with curl, so it's not an API bug.

EDIT: I have tested this in 1.7.2 and 1.6.3

EDIT: Just realised I'm using V2 API code with V1 API client (1.7.2), hence why it's not working

Nested array attributes are incorrectly serialized

According to the Chargebee documentations, when a coupon with nested attributes is serialized, the path of the nested attributes should be preserved and double-nested arrays should be json encoded as arrays.

{"item_constraints": [{"item_price_ids": ["id1"]}]}

Is expected to be serialized to parameters as:

item_constraints[item_price_ids][0]=["id1"] 

However when this resource is serialized using this library, the nested array is not correctly nested

ChargeBee::Util.serialize({item_constraints: [{item_price_ids: ['id1']}]})

=> {"item_price_ids[0]"=>"id1"}

Syntax error, while using require "chargebee"

SyntaxError: /usr/lib/ruby/gems/1.8/gems/chargebee-2.0.9/lib/chargebee/rest.rb:7: syntax error, unexpected ')', expecting '='
/usr/lib/ruby/gems/1.8/gems/chargebee-2.0.9/lib/chargebee/rest.rb:90: syntax error, unexpected kEND, expecting $end
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require' from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in require_without_desert' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:521:innew_constants_in'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in require_without_desert' from /usr/lib/ruby/gems/1.8/gems/desert-0.5.3/lib/desert/ruby/object.rb:8:inrequire'
from /usr/lib/ruby/gems/1.8/gems/desert-0.5.3/lib/desert/ruby/object.rb:32:in __each_matching_file' from /usr/lib/ruby/gems/1.8/gems/desert-0.5.3/lib/desert/ruby/object.rb:7:inrequire'
from /usr/lib/ruby/gems/1.8/gems/chargebee-2.0.9/lib/chargebee.rb:2
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in gem_original_require' from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:inrequire'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in require_without_desert' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:521:innew_constants_in'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in require_without_desert' from /usr/lib/ruby/gems/1.8/gems/desert-0.5.3/lib/desert/ruby/object.rb:8:inrequire'
from /usr/lib/ruby/gems/1.8/gems/desert-0.5.3/lib/desert/ruby/object.rb:32:in __each_matching_file' from /usr/lib/ruby/gems/1.8/gems/desert-0.5.3/lib/desert/ruby/object.rb:7:inrequire'

Typo and wrong version in dev dependencies

hi, while debugging other stuff i noticed that you have typo in dependencies. also i had to upgrade rspec version to get specs working
it should be:

s.add_development_dependency('rspec', '~> 3.0.0')
instead:
s.add_development_dependency('rpsec', '~> 2.9.0')
                          typo ^          ^ version

create_for_customer method is not rejecting braintree invalid-nonces

Hi,
I'm creating Chargebee subscriptions (in sandbox) using a Braintree nonce, specific the fake-invalid-nonce. When I call ChargeBee::Subscription.create_for_customer("customer_id", {}) method, this respond like a valid nonce. Instead, if I use ChargeBee::Subscription.create({}) sent nonce is rejected as expected.

Changelog address missing from gemspec file

The chargebee.gemspec doesn't contain a link to the changelog of the project, this prevent Dependabot to automatically fetch the changes made in new versions.

Here's a screenshot for the latest version of Chargebee-ruby:

Screenshot 2023-06-01 at 08 44 29

A simple way to fix is to add the following key in chargebee.gemspec:

s.metadata = {
  "changelog_uri" => "https://github.com/chargebee/chargebee-ruby/blob/master/CHANGELOG.md",
}

You can find the documentation about the metadata key here.

Get total size of list items

I have a requirement of getting the total number of Subscriptions of specific plan within duration of one month.

A work around is to use ChargeBee::Subscription.list( ... ).count and set the limit to a very big number (and use next_offset, if ever needed).

To save resources, is there a better way of getting the total items count?

https://apidocs.chargebee.com/docs/api/subscriptions

Item model is not available for use

Script to replicate the issue:

require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'

  gem 'chargebee', '~> 2'
end

ChargeBee::Item

Running this gives following error:

Traceback (most recent call last):
chargebee_check.rb:9:in `<main>': uninitialized constant ChargeBee::Item (NameError)

We are unable to access these Items APIs.

Item and related models should be added to require list here.

Switch to MultiJson?

Hi,

Any chance you'd consider switching your JSON dependency to MultiJson? This allows the user to decide the JSON implementation themselves, while still allowing json_pure as an option for those that want it.

The reason for this is that json_pure defines ::JSON and is not always API compatible with other implementations. If another gem uses a different library that also defines ::JSON, the two implementations can fight and slightly different behaviours can occur. Including Chargebee in the project has caused a lot of JSON errors elsewhere for me because of issues like this.

Bad uri error fetching Customer Data

HTML encode requests for customer and subscription data.

In Chargebee we setup a customer with an ID like the following Customer [Dotcom]. The Chargebee UI allows this as a valid name. When calling for the customer data via the gem ChargeBee::Customer.retrieve(team.chargebee_customer_id) the gem throws a bad uri error

bad URI(is not URI?): "https://captionhub.chargebee.com/api/v2/customers/Customer%20[Dotcom]"

It looks like the gem could benefit from some further encoding

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.