def recurring(money, payment_source, options = {})
requires!(options, [:periodicity, :monthly, :weekly, :daily], :payments)
periodic_type = case options[:periodicity]
when :monthly
'month'
when :weekly
'week'
when :daily
'day'
end
if options[:starting_at].nil?
start_date = Time.now.strftime('%Y-%m-%d')
elsif options[:starting_at].is_a?(String)
sa = options[:starting_at]
start_date = "#{sa[0..3]}-#{sa[4..5]}-#{sa[6..7]}"
else
start_date = options[:starting_at].strftime('%Y-%m-%d')
end
parameters = {
:transaction_amount => amount(money),
:schedule_periodic_type => periodic_type,
:schedule_create => 'true',
:schedule_limit => options[:payments].to_i > 1 ? options[:payments] : 1,
:schedule_periodic_number => 1,
:schedule_start => start_date
}
add_payment_source(parameters, payment_source)
add_optional_fields(parameters, options)
add_address(parameters, options)
commit('AUTHORIZATION_CAPTURE', parameters)
end