How do I process responses from using the official Chargify gem in Rails 3.

I'm currently developing a Rails application to accept recurring billing using Chargify. I've installed their gem and managed to connect to Chargify with the gem. However, some subscriptions go through and some do not.

My question is how do I handle or even process the response once the gem communicates with the server?

I don't see anything in the development logs that gives me any indication of a successful data transfer or a failed one. The gem documentation also does not mention anything regarding this.

Thanks for looking.

UPDATE

The code I'm playing around with is in my checkout controller:

def checkout @customer = Customer.new(params[:customer])

Chargify::Customer.create( :first_name => "Charlie", :last_name => "Bull", :email => "[email protected]", :organization => "Chargify" ) Chargify::Subscription.create( :product_handle => 'recurring', :customer_attriburtes => { :first_name => @customer.shipping_first_name, :last_name => @customer.shipping_last_name, :email => @customer.email }, :payment_profile_attributes => { :first_name => @customer.shipping_first_name, :last_name => @customer.shipping_last_name, :full_number => "1", :expiration_month => 1, :expiration_year => 2012, :billing_address => @customer.shipping_street_address, :billing_city => @customer.shipping_city, :billing_state => @customer.shipping_state, :billing_zip => @customer.shipping_zip_code, :billing_country => @customer.shipping_country } ) #if @subscription.save # logger.info "saved description" # redirect_to process_path #else # redirect_to :back, :alert =>"There was an error." #end

end

The customer create is going through, but the Subscription does not. I'm just looking for a callback from the server so I can act based off whether it succeeded and find out why the subscription isn't going through.

-------------Problems Reply------------

Since this whole gem uses ActiveResource cant you just call something like:

# Create a subscription from a customer reference
subscription = Chargify::Subscription.create(
:customer_reference => 'moklett',
:product_handle => 'chargify-api-ares-test',
:credit_card_attributes => {
:first_name => "Michael",
:last_name => "Klett",
:expiration_month => 1,
:expiration_year => 2020,
:full_number => "1"
}
)
if subscription.save
puts "Created Subscription!"
else
puts "Subscription Failed!"
end

and see if the record has been created correctly?

EDIT: Your code should work but I see that the call to save is commented out. When you call save it creates or updates the record and testing this should allow you to determine if your record was created or not.

Category:ruby on rails Views:0 Time:2011-07-29

Related post

  • Error processing response stream. The XML element contains mixed content 2011-06-06

    I'm calling a stored procedure via WCf-DataService and EF4. Other method works fine but one which return List failed with the exception Error processing response stream. The XML element contains mixed content. Here is the XML return by the method (ca

  • Processing Response in WP7 login Service calls 2011-07-14

    I need to call web services from my WP7 client application for user login pop up, and display the user the response whether the user is authenticated or not. My challenge is since all web service calls in WP7 are async, I am not sure how to pass the

  • Get a process response 2010-07-24

    I am looking for a way to get a response in a form of a javascript alert after a form has been submitted using a php script. I guess ajax should do this but Im not an Ajax guy yet. A simple sample code would help a lot. Thanks for reading -----------

  • Calling and processing response from Rest service in WP7 app 2011-03-22

    I am new to WP7 and I am working on a WP7 app that communicates with a Rest service using C#. I have been able to successfully develop the async code using HttpWebRequest to interact with it. However, I am having difficulty with the login aspect (the

  • Firefox processing response from servlet 2011-06-17

    I have a javascript which receives info from a servlet using jQuery: $.get("authenticate", {badge:$('input#badge').val()}, function(data) { console.log("xml: "+data); displayInfoReturn(data); }); When I process the result in Safari, everything works

  • I can't to process response to a jsonp request 2011-12-08

    I have url http://translate.google.ru/translate_a/t?client=x&text=enter text&sl=en&tl=pl If you will go through this link in response you will have js file with text: {"sentences":[{"trans":"wprowadzania tekstu","orig":"enter text","trans

  • Cannot process response from jQuery.post() 2011-12-13

    I have the following code $(function() { $('.apply').click(function(e) { var z = $(this).attr('z-id'); var r = $(this).attr('r-id'); $.post( "/r-set-z", "z_id=" + z + "&r_id=" + r, function(data) { alert(data); } ); }); }); It works correct excep

  • Facebook Javascript SDK: Processing Response from Facebook 2012-02-03

    I'm having trouble understanding how to process the response when you make an API call to facebook. Should mention that I'm new to javascript. Say I want to get the mutual friends between me and some user, and then write it to a text box. I took a sh

  • Processing Response from URL Call 2012-03-20

    I am trying to simply submit a url and get the response back so I can read it and do other actions, in JavaScript or LotusScript. What is the simplest/best way to do this? Fyi, the reason I'm trying to do this is to submit order information to PayPal

  • Is there a .NET ready made method to process response body of a HttpListener HttpListenerRequest body? 2009-11-20

    I'm using HttpListener to provide a web server to an application written in another technology on localhost. The application is using a simple form submission (application/x-www-form-urlencoded) to make its requests to my software. I want to know if

  • Filtering the result of a JSON.parse response in Ruby (and the JSON gem) 2009-11-15

    In a little app I'm building, I'm using the the twitter_oauth gem (source of the methods I'm using), which incidentally means I'm dealing with the JSON ruby gem. I'm using the messages method, whose source is as follows: def messages(page=1) oauth_re

  • Controller waiting for response and then the application fails Ruby on rails 2010-08-12

    My Controller waits for a response from a lib folder ruby file which it is calling. lib.rb runs for about 4 minutes and returns a string as result. The controller waits for the string response and then application breaks after a minute showing Intern

  • How do I specify a response format based on a form option in Rails 3.0.x 2011-03-01

    Environment: Rails 3.0.4 and Ruby 1.9.2 I have the following form: <%= form_tag( {:action => 'show', :format => :pdf}, :method => :post) do %> .. list of items ... <%= submit_tag "Show", :onclick => "return checkAllFields(4);", :

  • Regarding Mailman gem in Rails Email inbound processing 2011-03-10

    I need to work on Email receiving and inbound processing. But I don't know how to run the Email server to receive mail. I'm searching for the way to find a solution for setting up email server to receive mail. Can Any one please suggest how to config

  • Process Credit Card Later Without Authorize method on Gateway - Rails 3 2011-06-10

    I'm working on processing credit card orders only if a certain quantity of a deal are met. (Think Groupon). I'm using ActiveMerchant in my rails app. Processing orders after minimum order met - Rails 3 The gateway I'm using only (Eway) which doesn't

  • How to generate a response in a long running synchronous request in Rails? 2012-01-01

    I'm having trouble figuring out how to do this using Rails, though it is probably cause I don't know the proper term for it. I basically want to do this: def my_action sleep 1 # output something in the request, but keep it open print '{"progress":15}

  • Weird response for controller.request.format.html? in Rails 2009-10-01

    In my main controller, I have this: class MainController < ApplicationController before_filter do |controller| logger.info "controller.request.format.html? = #{controller.request.format.html?}" logger.info "controller.request.format.fbml? = #{cont

  • How can I obfuscate a test in code to prevent tampering with response processing? 2009-12-11

    I am looking for a way to obfuscate (in the object code) a test - something like what might be done to check that a license key is valid. What I am trying to prevent is someone searching through an image binary for the code that processes the respons

  • Calling a url to another server during controller response process? 2010-08-12

    I think that I am having a slow evening but I have a question regarding calling a URL as part of a controller call in a Zend Framework application. I'm trying integrate an affiliate tracking application into my code, and the only way to register a co

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.118 (s). 11 q(s)