【发布时间】:2011-07-29 19:33:27
【问题描述】:
我目前正在开发一个 Rails 应用程序来接受使用 Chargify 的定期计费。我已经安装了their gem 并设法使用 gem 连接到 Chargify。但是,有些订阅会通过,有些则不会。
我的问题是,一旦 gem 与服务器通信,我该如何处理甚至处理响应?
我在开发日志中看不到任何数据传输成功或失败的迹象。 gem 文档也没有提到任何关于此的内容。
感谢收看。
更新
我正在使用的代码在我的结帐控制器中:
默认结帐 @customer = Customer.new(params[:customer])
Chargify::Customer.create(
:first_name => "Charlie",
:last_name => "Bull",
:email => "charlie@example.com",
: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
结束
客户创建正在进行,但订阅没有。我只是在寻找来自服务器的回调,以便我可以根据它是否成功采取行动,并找出订阅未通过的原因。
【问题讨论】:
-
看起来代码检查了一些请求的响应代码,如果它得到意外的响应,它会引发 UnexpectedResponseError。你能给我们一些示例代码吗?
-
放上我的控制器代码。感谢您的回复。
标签: ruby-on-rails ruby-on-rails-3 chargify