Issue in generating invoice using Stripe api - ruby-on-rails

I have integrated stripe API in my Rails application. I am facing a problem while getting invoiceitems from the JSON object.
Here i have provide you the details.
OS: CentOS
Ruby: v1.9.3
Rails: v3.0
Stripe: v1.8.3
cus_invoices = Stripe::Invoice.all(:customer=>customer.id, :count=>1).data
cus_invoices.each do |invoices|
invoiceitems = invoices.lines.invoiceitems.each do |lineitems|
Here, the transaction got successful and while returning the stripe ListObject, it throws an error as follows.
CLASS_NAME: NoMethodError
MESSAGE: undefined method invoiceitems' for #<Stripe::ListObject:0xbd9b13c>
TRACE: /usr/local/lib/ruby/gems/1.9.1/gems/stripe-1.8.3/lib/stripe/stripe_object.rb:148:inmethod_missing'
I didn't face this issue previously. Please let me know if any change in JSON object structure.
Kindly provide your support to solve this issue.
Thanks,
Jude

https://stripe.com/docs/api#list_customer_invoices shows the json
invoices.lines.each do |line|
line_item = line.data
line_item.id
line_item.amount
end
You should check your API version (https://stripe.com/docs/api#versioning). If Stripe makes backward incompatible changes, it ups the API version.
Stripe sets the API version based on when you first use the API. So, if you recently got new API keys, it could use a new API version than when you originally started using it.
You can change your API version in your config initializer. Example:
Stripe.api_version = "2013-02-13"

Related

Docusign gem block request

I'm using the DocuSign ruby client (https://github.com/docusign/docusign-ruby-client) on ruby on rails to send a document via email to some clients, but when I deploy the project after 15 minutes the request between the application and DocuSign gets "paused". For some reason the gem creates the request but doesn't send it as you can see in the next image where I enable the debug in the gem:
In that point the log doesn't print any more after 15 minutes.
The code that send the message in my app is:
access_token = "xxxxxxx"
account_id = "xxxxxxxxx"
base_path = "xxxxxxxxxx"
envelope_args = {
signer_email: contact.email,
signer_name: contact.name,
template_id: document.docusign_id
}
#args = {
account_id: account_id,
base_path: base_path,
access_token: access_token,
envelope_args: envelope_args
}
envelope_args = #args[:envelope_args]
# 1. Create the envelope request object
envelope_definition = make_envelope(envelope_args)
# 2. Call Envelopes::create API method
# Exceptions will be caught by the calling function
envelope_api = create_envelope_api(#args)
envelope_api.create_envelope #args[:account_id], envelope_definition
I don't know what can I do.
Thank you
Your screenshot shows everything happening at 18:29:05 -- I don't understand the issue.
Also, have you tried install/using the RoR code example?
See if it has the same problem.
We looked for the issue in our code, but we saw that in the step which the request is send in the gem here always freezes. So we debugged there and we saw that curl was being used for ruby. At that point we saw that curl was trying to reconnect with Docusign but it wasn't success, so we found this issue in the version of curl that we had (https://github.com/curl/curl/issues/4499 )
To fix it we updated the version to the latest, and it fixed the issue.
Thanks for your answers.

Installing Mollie payments API: unpermitted_parameters

I am installing the Mollie payments API. Unfortunately, I get an unpermitted parameters: _method, authenticity_token (in the log). Here I would expect that a new window is opened that connects with Mollie.
I call the API by:
if #reservation
mollie = Mollie::API::Client.new('test_gUejkz43UkdeCauC22J6UNqqVRdpwW')
payment = mollie.payments.create(
amount: 10.00,
description: 'My first API payment',
redirectUrl: 'http://localhost:3000'
)
The reservation is made and the site does not give an active error, which makes me think the API is not called. Does anyone see what I am doing wrong? I installed the gem, I use Rails 4 and use require 'Mollie/API/Client' on top of the controller.
Any suggestionis highly appreciated! Thanks

Koala gem get_object returns GraphMethodException

I'm using the Koala gem to get metrics (likes, comments, and shares) on Facebook posts. I literally have not touched the Koala code in months, yet is suddenly stopped working. I'm able to get likes and comments, but not shares. I checked the docs for the gem as well as the issues on GitHub and didn't see anything related to my issue. Not sure if it's my code or the gem or a change to Facebook's API.
I have the following method, which is called by another method, which is responsible for updating all metrics on the post.
def call_facebook_api(client, method, pid, metric)
resp = client.method(method).call(pid, metric)
rescue Koala::Facebook::ClientError => e
puts "Rescue from #{e}"
puts "Method: #{method}"
puts "Metric: #{metric}"
puts "Post ID: #{pid}"
return nil
end
Here are some sample values for the method arguments:
client
=> #<Koala::Facebook::API:0x007fbbfdf25dd0 #access_token="super_secret",#app_secret="super_duper_secret">
method
=> :get_object
pid
=> "202001613484188_1142111705834093"
metric
=> {:fields=>["shares"]}
When I run the method above with these inputs it returns this error:
Koala::Facebook::ClientError: type: GraphMethodException, code: 100, message: Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api [HTTP 400]
from /Users/ACIDSTEALTH/.gem/ruby/2.3.0/gems/koala-2.2.0/lib/koala/api/graph_api.rb:515:in `block in graph_call'
I've also tried the following combinations unsuccessfully:
client.get_object(pid)
client.get_object(pid, fields: ['shares'])
client.get_object(pid, 'shares')
client.get_object("#{pid}/sharedposts")
client.get_object("#{pid}?fields=sharedposts")
client.get_object("#{pid}?fields=shared")
client.get_object("#{pid}?fields=shares")
client.get_connections(pid)
client.get_connections(pid, 'shares')
client.get_connections("#{pid}/sharedposts")
Referencing the Graph API docs hasn't given me any new insights into the problem.
As I said before, I haven't touched the above code in months, yet it only recently stopped working. I did recently upgrade my Rails app from 4.06 to 4.2.5.1. I also upgraded from Ruby 2.0.0 to 2.3.0. I did not upgrade the Koala gem though. I was already running 2.2.0 (latest).

Invalid scope error

I'm trying to send bitcons using coinbase ruby gem but I'm having a hard time getting it to work. I'm authenticating like this:
c = Coinbase::Wallet::Client.new(api_key: ENV["COINBASE_KEY"], api_secret: ENV["COINBASE_SECRET"])
ca = c.account(User.last.account.account_id)
ca.send(to: ENV["BITCOIN_ADDRESS"], amount: '0.0001', currency: 'BTC')
This is the error I'm getting back.
Coinbase::Wallet::InvalidScopeError: Api::BaseController::InvalidScopeError
To be clear, the API key has the required permission set in the dashboard. what could i be doing wrong?
The new Ruby gem uses API v2 which requires v2 scope, wallet:transactions:send instead of v1's send. Can you check that you have this enabled?

Trouble with authlogic_rpx

I'm trying to run http://github.com/tardate/rails-authlogic-rpx-sample (only rails version was changed) but get error message http://gist.github.com/385696, when RPX returns information after successful authentication via Google Account. What is wrong here? And how I can fix it?
The code was successfully tested with rails 2.3.3 by its author: http://rails-authlogic-rpx-sample.heroku.com/
I run on Windows with cygwin and rails (2.3.5), rpx_now (0.6.20), authlogic_rpx (1.1.1).
Update
In several hours RPX rejected my app http://img96.imageshack.us/img96/2508/14128362.png
Update2
The same error message ( http://gist.github.com/386124) appears with http://github.com/grosser/rpx_now_example , but in this case RPX allows me to sign in (so far).
Solved
See below
Got error: Invalid parameter: apiKey (code: 1), HTTP status: 200
You have to first register your RPX app at http://www.RPXnow.com and set its name. You'll be assigned an API key which you should set in the config/environment.rb file:
RPX_API_KEY = ENV["RPX_API_KEY"]
RPX_APP_NAME = "your_app_name_here!"
Or: Read slide 35: http://www.slideshare.net/tardate/srbauthlogicrpx
You shouldn't have any constraints enforced at the database level.
The reason was trailing \r character in my API key. Apparently, non of the steps did key trimming and the exception was not processed in a good way.

Resources