Class: EZPaypal::Cart::RecurringProfile

Inherits:
HashWithIndifferentAccess
  • Object
show all
Defined in:
lib/core/data.rb

Instance Method Summary (collapse)

Constructor Details

- (RecurringProfile) initialize(profile)

Setup profile

Parameters:

  • profile (Hash)

    "email", "currency" => "USD" (default "USD"),

    "item_code", "unit_price", "quantity", "amount", "initial_amount" => "0" (recurring profile will do auto-charge since begining! do not use this if you are not sure), "start_date" => "2012/02/02" (Default Time.now), "period" => "Day/Week/Month/Year" (default "Month"), "frequency" => "1" (how many periods a purchase, default 1), "cycles" => "0" (total cycles of recurring billing, default 0 means infinite)

    
    


190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/core/data.rb', line 190

def initialize(profile)
  item = profile
  options = {
      "TOKEN" => item["token"],
      "EMAIL" => item["email"],
      "CURRENCYCODE" => item["currency"] || "USD",
      "FAILEDINITAMTACTION" => "CancelOnFailure", #ContinueOnFailure / CancelOnFailure

      # Display details
      "L_PAYMENTREQUEST_0_ITEMCATEGORY0" => item["category"] || "Physical",
      "L_PAYMENTREQUEST_0_NAME0" => item["item_code"] || "",
      "L_PAYMENTREQUEST_0_AMT0" => item["unit_price"] || "0",
      "L_PAYMENTREQUEST_0_QTY0" => item["quantity"] || "0",

      # Profile details
      "DESC" => item["item_code"] || "",
      "AMT" => item["amount"] || "0",
      "QTY" => item["quantity"] || "0",
      "INITAMT" => item["initial_amount"] || "0",

      # Recurring details
      "PROFILESTARTDATE" => item["start_date"] || Time.now,
      "BILLINGFREQUENCY" => item["frequency"] || "1",
      "BILLINGPERIOD" => item["period"] || "Month",
      "TOTALBILLINGCYCLES" => item["cycles"] || "0"

  }

  self.merge!(options)
end