我目前正在開發一個Rails應用程序接受使用Chargify定期結算使用官方Chargify寶石響應。我已經安裝了their gem並設法連接到Chargify的寶石。但是,有些訂閱會通過,有些則不會。如何處理來自Rails的3
我的問題是我該如何處理,甚至處理響應,一旦創業板與服務器進行通信?
我沒有看到任何的開發日誌,讓我一個成功的數據傳輸或失敗的一個跡象。寶石文檔也沒有提到這方面的任何事情。
感謝您尋找。
UPDATE
我跟在我結賬控制器玩弄代碼:
高清結賬 @customer = Customer.new(PARAMS [:客戶])
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
結束
客戶創建正在經歷,但訂閱沒有。我只是尋找服務器的回調,以便我可以根據它是否成功並找出訂閱未通過的原因。
它看起來像代碼檢查幾個請求的響應代碼,如果它得到意外的響應,它會引發一個UnexpectedResponseError。你能給我們一些示例代碼嗎? –
把我的控制器代碼。感謝您的迴應。 – jklina