I am using Remit gem for Amazon FPS(Recurring) for Ruby on Rails(rails
2.3.8).
I followed the process mentioned at
https://github.com/nyc-ruby-meetup/remit
The coding used for this process:
require 'remit'
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
#protect_from_forgery # See
ActionController::RequestForgeryProtection for details
private
def remit
@remit ||= begin
sandbox = !Rails.env.production?
Remit::API.new(FPS_ACCESS_KEY, FPS_SECRET_KEY, sandbox)
end
end
end
class UsersController < ApplicationController
def subscribe
amount = "10"
return_url = url_for(:controller => "users", :action =>
"pay", :trns_amt => amount)
response = remit.get_tokens
recurring_use_pipeline = remit.get_recurring_use_pipeline(
:caller_reference => Time.now.to_i.to_s,
:recipient_token => response.tokens.first.token_id,
:transaction_amount => amount,
:recurring_period => "1 Month",
:return_url => return_url,
:caller_key => remit.access_key
)
redirect_to(recurring_use_pipeline.url)
end
def pay
amount = params[:trns_amt]
response = remit.get_tokens
request = Remit::Pay::Request.new(
:caller_token_id => response.tokens.first.token_id,
:recipient_token_id => response.tokens.first.token_id,
:sender_token_id => params[:tokenID],
:transaction_amount => Remit::RequestTypes::Amount.new(
:amount => amount,
:currency_code => "USD"
),
:charge_fee_to => "Recipient",
:caller_reference => Time.now.to_i.to_s
)
pay_response = remit.pay(request)
if pay_response.successful? &&
pay_response.transaction_response.success?
puts pay_response.transaction_response.transaction_id
else
puts pay_response.transaction_response.status
end
end
end
The subscribe method successfully redirect to amazon site and got
authorization and send back to my site(returnURL) with tokenID,
status(SA/SB/SC), etc. When it calls pay method, there is nothing
return in 'pay_response'.
I am not able to understand which error its giving.
I tried to find at amazon developers forum but there is no comment on
it.
What is the right way for this 'pay' request? Please take me out of
this problem.
Thanks in advance.