Method: ActiveMerchant::Billing::AuthorizeNetArbGateway#recurring

Defined in:
lib/active_merchant/billing/gateways/authorize_net_arb.rb

#recurring(money, creditcard, options = {}) ⇒ Object

Create a recurring payment.

This transaction creates a new Automated Recurring Billing (ARB) subscription. Your account must have ARB enabled.

Parameters

  • money – The amount to be charged to the customer at each interval as an Integer value in cents.

  • creditcard – The CreditCard details for the transaction.

  • options – A hash of parameters.

Options

  • :interval – A hash containing information about the interval of time between payments. Must contain the keys :length and :unit. :unit can be either :months or :days. If :unit is :months then :length must be an integer between 1 and 12 inclusive. If :unit is :days then :length must be an integer between 7 and 365 inclusive. For example, to charge the customer once every three months the hash would be :interval => { :unit => :months, :length => 3 } (REQUIRED)

  • :duration – A hash containing keys for the :start_date the subscription begins (also the date the initial billing occurs) and the total number of billing :occurrences or payments for the subscription. (REQUIRED)



85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/active_merchant/billing/gateways/authorize_net_arb.rb', line 85

def recurring(money, creditcard, options = {})
  requires!(options, :interval, :duration, :billing_address)
  requires!(options[:interval], :length, %i[unit days months])
  requires!(options[:duration], :start_date, :occurrences)
  requires!(options[:billing_address], :first_name, :last_name)

  options[:credit_card] = creditcard
  options[:amount] = money

  request = build_recurring_request(:create, options)
  recurring_commit(:create, request)
end