Module: PaypalSubscribe

Extended by:
PaypalSubscribe
Included in:
PaypalSubscribe
Defined in:
lib/paypal-subscribe.rb,
lib/paypal-subscribe/errors.rb

Defined Under Namespace

Modules: Errors

Constant Summary collapse

SHIPPING =
{
  :address          => 0,
  :none             => 1,
  :require_address  => 2 
}
@@paypal_config_hash =
{}
@@business =
"[email protected]"
@@item_name =
"my_logo.png"
@@success_callback =
:paypal_success
@@failure_callback =
:paypal_failure
@@notify_callback =
:paypal_notify
@@currency_code =
"EUR"

Instance Method Summary collapse

Instance Method Details

#additional_values=(method) ⇒ Object

Extend config options which ever you want. See cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_Appx_websitestandard_htmlvariables

This has to be a lambda:

PaypalSubscribe.additional_values = ->(config) do

  config[:modify] = value_for_modify

  return config
end


186
187
188
189
190
191
192
# File 'lib/paypal-subscribe.rb', line 186

def additional_values=(method)
  unless method.is_a?(Proc)
    raise Errors::ArgumentError.new("Expected a proc (lambda) as argument.") 
  else
    @@paypal_config_hash = method.call(@@paypal_config_hash)
  end
end

#no_note=(value) ⇒ Object

Do not prompt buyers to include a note with their payments.



151
152
153
# File 'lib/paypal-subscribe.rb', line 151

def no_note=(value)
  @@no_note = no_able(value)
end

#no_shipping=(value) ⇒ Object

Do not prompt buyers for a shipping address.

Allowable values are:

:address – prompt for an address, but do not require one 
:none - do not prompt for an address 
:required_address – prompt for an address, and require one


163
164
165
# File 'lib/paypal-subscribe.rb', line 163

def no_shipping=(value)
  @@no_shipping = SHIPPING[value]
end

#paypal_configObject

INTERNAL - Builds the form config hash

Returns a hash with all config options.



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/paypal-subscribe.rb', line 197

def paypal_config
  exceptionals = {:success_callback => :return, 
                  :failure_callback => :cancel_return,
                  :notify_callback  => :notify_url}
  self.class_variables.each do |c_var|
    key = c_var.to_s.gsub("@@","").to_sym
    unless key.eql?(:paypal_config_hash)
      if exceptionals.keys.include?(key)
        key = exceptionals[key]
      end
      @@paypal_config_hash[key] = self.class_variable_get(c_var)
    end
  end
  return @@paypal_config_hash
end

#paypal_urlObject

INTERNAL - Form url.

For production environment:

- https://www.paypal.com/cgi-bin/webscr

In any other environment it returns a sandbox link.



36
37
38
39
40
41
42
# File 'lib/paypal-subscribe.rb', line 36

def paypal_url
  if defined?(Rails.env)
    return Rails.env.eql?("production") ? @production_uri : @sandbox_uri
  else
    return @sandbox_uri
  end
end

#setup {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



213
214
215
# File 'lib/paypal-subscribe.rb', line 213

def setup(&block)
  yield(self)
end

#sra=(value) ⇒ Object



138
139
140
# File 'lib/paypal-subscribe.rb', line 138

def sra=(value)
  @@sra = no_able(value)
end

#src=(value) ⇒ Object



131
132
133
# File 'lib/paypal-subscribe.rb', line 131

def src=(value)
  @@src = no_able(value)
end