Class: OffsitePayments::Helper
- Inherits:
-
Object
- Object
- OffsitePayments::Helper
show all
- Defined in:
- lib/offsite_payments/helper.rb
Overview
Direct Known Subclasses
Integrations::A1agregator::Helper, Integrations::AuthorizeNetSim::Helper, Integrations::BitPay::Helper, Integrations::Bogus::Helper, Integrations::Chronopay::Helper, Integrations::Citrus::Helper, Integrations::Coinbase::Helper, Integrations::DirecPay::Helper, Integrations::Directebanking::Helper, Integrations::Doku::Helper, Integrations::Dotpay::Helper, Integrations::Dwolla::Helper, Integrations::EPaymentPlans::Helper, Integrations::EasyPay::Helper, Integrations::Epay::Helper, Integrations::Gestpay::Helper, Integrations::HiTrust::Helper, Integrations::Ipay88::Helper, Integrations::Klarna::Helper, Integrations::Liqpay::Helper, Integrations::Maksuturva::Helper, Integrations::Megakassa::Helper, Integrations::MollieIdeal::Helper, Integrations::MollieMistercash::Helper, Integrations::Molpay::Helper, Integrations::Moneybookers::Helper, Integrations::Nochex::Helper, Integrations::PagSeguro::Helper, Integrations::Paxum::Helper, Integrations::PayFast::Helper, Integrations::Paydollar::Helper, Integrations::PayflowLink::Helper, Integrations::Paypal::Helper, Integrations::Paysbuy::Helper, Integrations::PayuIn::Helper, Integrations::Platron::Helper, Integrations::Pxpay::Helper, Integrations::Quickpay::Helper, Integrations::Rbkmoney::Helper, Integrations::RealexOffsite::Helper, Integrations::Robokassa::Helper, Integrations::SagePayForm::Helper, Integrations::TwoCheckout::Helper, Integrations::Universal::Helper, Integrations::Valitor::Helper, Integrations::Verkkomaksut::Helper, Integrations::WebPay::Helper, Integrations::Webmoney::Helper, Integrations::WirecardCheckoutPage::Helper, Integrations::WorldPay::Helper, Integrations::YandexMoney::Helper
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(order, account, options = {}) ⇒ Helper
Returns a new instance of Helper.
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/offsite_payments/helper.rb', line 18
def initialize(order, account, options = {})
options.assert_valid_keys([:amount, :currency, :test, :credential2, :credential3, :credential4, :country, :account_name, :description, :transaction_type, :authcode, :notify_url, :return_url, :redirect_param, :forward_url, :checkout_token])
@fields = {}
@raw_html_fields = []
@test = options[:test]
self.order = order
self.account = account
self.amount = options[:amount]
self.currency = options[:currency]
self.credential2 = options[:credential2]
self.credential3 = options[:credential3]
self.credential4 = options[:credential4]
self.notify_url = options[:notify_url]
self.return_url = options[:return_url]
self.redirect_param = options[:redirect_param]
self.checkout_token = options[:checkout_token]
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_id, *args) ⇒ Object
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
# File 'lib/offsite_payments/helper.rb', line 100
def method_missing(method_id, *args)
method_id = method_id.to_s.gsub(/=$/, '').to_sym
return if mappings[method_id].nil?
mapping = mappings[method_id]
case mapping
when Array
mapping.each{ |field| add_field(field, args.last) }
when Hash
options = args.last.is_a?(Hash) ? args.pop : {}
mapping.each{ |key, field| add_field(field, options[key]) }
else
add_field(mapping, args.last)
end
end
|
Instance Attribute Details
#fields ⇒ Object
Returns the value of attribute fields.
3
4
5
|
# File 'lib/offsite_payments/helper.rb', line 3
def fields
@fields
end
|
Class Method Details
.inherited(subclass) ⇒ Object
14
15
16
|
# File 'lib/offsite_payments/helper.rb', line 14
def self.inherited(subclass)
subclass.mappings ||= {}
end
|
.mapping(attribute, options = {}) ⇒ Object
36
37
38
|
# File 'lib/offsite_payments/helper.rb', line 36
def self.mapping(attribute, options = {})
self.mappings[attribute] = options
end
|
Instance Method Details
#add_field(name, value) ⇒ Object
40
41
42
43
|
# File 'lib/offsite_payments/helper.rb', line 40
def add_field(name, value)
return if name.blank? || value.blank?
@fields[name.to_s] = value.to_s
end
|
#add_fields(subkey, params = {}) ⇒ Object
45
46
47
48
49
50
|
# File 'lib/offsite_payments/helper.rb', line 45
def add_fields(subkey, params = {})
params.each do |k, v|
field = mappings[subkey][k]
add_field(field, v) unless field.blank?
end
end
|
#add_raw_html_field(name, value) ⇒ Object
Add a field that has characters that CGI::escape would mangle. Allows for multiple fields with the same name (e.g., to support line items).
54
55
56
57
|
# File 'lib/offsite_payments/helper.rb', line 54
def add_raw_html_field(name, value)
return if name.blank? || value.blank?
@raw_html_fields << [name, value]
end
|
#billing_address(params = {}) ⇒ Object
63
64
65
|
# File 'lib/offsite_payments/helper.rb', line 63
def billing_address(params = {})
add_address(:billing_address, params)
end
|
71
72
73
|
# File 'lib/offsite_payments/helper.rb', line 71
def form_fields
@fields
end
|
79
80
81
|
# File 'lib/offsite_payments/helper.rb', line 79
def form_method
"POST"
end
|
#raw_html_fields ⇒ Object
59
60
61
|
# File 'lib/offsite_payments/helper.rb', line 59
def raw_html_fields
@raw_html_fields
end
|
#shipping_address(params = {}) ⇒ Object
67
68
69
|
# File 'lib/offsite_payments/helper.rb', line 67
def shipping_address(params = {})
add_address(:shipping_address, params)
end
|
#test? ⇒ Boolean
75
76
77
|
# File 'lib/offsite_payments/helper.rb', line 75
def test?
@test_mode ||= OffsitePayments.mode == :test || !!@test
end
|