Class: Cardgate::Payment
- Inherits:
-
Object
- Object
- Cardgate::Payment
- Defined in:
- lib/cardgate/payment.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#city ⇒ Object
Returns the value of attribute city.
-
#company_name ⇒ Object
Returns the value of attribute company_name.
-
#control_url ⇒ Object
Returns the value of attribute control_url.
-
#country_code ⇒ Object
Returns the value of attribute country_code.
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#description ⇒ Object
Returns the value of attribute description.
-
#email ⇒ Object
Returns the value of attribute email.
-
#first_name ⇒ Object
Returns the value of attribute first_name.
-
#ip_address ⇒ Object
Returns the value of attribute ip_address.
-
#language ⇒ Object
Returns the value of attribute language.
-
#last_name ⇒ Object
Returns the value of attribute last_name.
-
#phone_number ⇒ Object
Returns the value of attribute phone_number.
-
#postal_code ⇒ Object
Returns the value of attribute postal_code.
-
#provider ⇒ Object
Returns the value of attribute provider.
-
#ref ⇒ Object
Returns the value of attribute ref.
-
#return_url ⇒ Object
Returns the value of attribute return_url.
-
#site_id ⇒ Object
Returns the value of attribute site_id.
-
#state ⇒ Object
Returns the value of attribute state.
Instance Method Summary collapse
- #api_payment_endpoint ⇒ Object
- #default_params ⇒ Object
-
#initialize(attributes = {}) ⇒ Payment
constructor
A new instance of Payment.
- #initiate ⇒ Object
- #params ⇒ Object
- #payment_params ⇒ Object
- #payment_url ⇒ Object
- #transaction_id ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Payment
Returns a new instance of Payment.
10 11 12 13 14 |
# File 'lib/cardgate/payment.rb', line 10 def initialize(attributes = {}) attributes.each do |k,v| send("#{k}=", v) end end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
5 6 7 |
# File 'lib/cardgate/payment.rb', line 5 def address @address end |
#amount ⇒ Object
Returns the value of attribute amount.
5 6 7 |
# File 'lib/cardgate/payment.rb', line 5 def amount @amount end |
#city ⇒ Object
Returns the value of attribute city.
5 6 7 |
# File 'lib/cardgate/payment.rb', line 5 def city @city end |
#company_name ⇒ Object
Returns the value of attribute company_name.
5 6 7 |
# File 'lib/cardgate/payment.rb', line 5 def company_name @company_name end |
#control_url ⇒ Object
Returns the value of attribute control_url.
5 6 7 |
# File 'lib/cardgate/payment.rb', line 5 def control_url @control_url end |
#country_code ⇒ Object
Returns the value of attribute country_code.
5 6 7 |
# File 'lib/cardgate/payment.rb', line 5 def country_code @country_code end |
#currency ⇒ Object
Returns the value of attribute currency.
5 6 7 |
# File 'lib/cardgate/payment.rb', line 5 def currency @currency end |
#description ⇒ Object
Returns the value of attribute description.
5 6 7 |
# File 'lib/cardgate/payment.rb', line 5 def description @description end |
#email ⇒ Object
Returns the value of attribute email.
5 6 7 |
# File 'lib/cardgate/payment.rb', line 5 def email @email end |
#first_name ⇒ Object
Returns the value of attribute first_name.
5 6 7 |
# File 'lib/cardgate/payment.rb', line 5 def first_name @first_name end |
#ip_address ⇒ Object
Returns the value of attribute ip_address.
5 6 7 |
# File 'lib/cardgate/payment.rb', line 5 def ip_address @ip_address end |
#language ⇒ Object
Returns the value of attribute language.
5 6 7 |
# File 'lib/cardgate/payment.rb', line 5 def language @language end |
#last_name ⇒ Object
Returns the value of attribute last_name.
5 6 7 |
# File 'lib/cardgate/payment.rb', line 5 def last_name @last_name end |
#phone_number ⇒ Object
Returns the value of attribute phone_number.
5 6 7 |
# File 'lib/cardgate/payment.rb', line 5 def phone_number @phone_number end |
#postal_code ⇒ Object
Returns the value of attribute postal_code.
5 6 7 |
# File 'lib/cardgate/payment.rb', line 5 def postal_code @postal_code end |
#provider ⇒ Object
Returns the value of attribute provider.
5 6 7 |
# File 'lib/cardgate/payment.rb', line 5 def provider @provider end |
#ref ⇒ Object
Returns the value of attribute ref.
5 6 7 |
# File 'lib/cardgate/payment.rb', line 5 def ref @ref end |
#return_url ⇒ Object
Returns the value of attribute return_url.
5 6 7 |
# File 'lib/cardgate/payment.rb', line 5 def return_url @return_url end |
#site_id ⇒ Object
Returns the value of attribute site_id.
5 6 7 |
# File 'lib/cardgate/payment.rb', line 5 def site_id @site_id end |
#state ⇒ Object
Returns the value of attribute state.
5 6 7 |
# File 'lib/cardgate/payment.rb', line 5 def state @state end |
Instance Method Details
#api_payment_endpoint ⇒ Object
68 69 70 |
# File 'lib/cardgate/payment.rb', line 68 def api_payment_endpoint "/rest/v1/#{provider}/payment/" end |
#default_params ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/cardgate/payment.rb', line 16 def default_params default_params = { payment: { site_id: @site_id, currency: @currency, ref: @ref, return_url: @return_url, control_url: @control_url, currency: @currency, language: @language, ip_address: @ip_address, description: @description, amount: @amount } } customer_fields = %w(first_name last_name company_name address city state postal_code country_code phone_number email) customer_fields.each do |field| var = instance_variable_get("@#{field}") if !var.nil? && !var.empty? default_params[:payment][:customer] = {} if default_params[:payment][:customer].nil? default_params[:payment][:customer][field.to_sym] = var end end return default_params end |
#initiate ⇒ Object
46 47 48 49 50 |
# File 'lib/cardgate/payment.rb', line 46 def initiate @response ||= response self end |
#params ⇒ Object
60 61 62 |
# File 'lib/cardgate/payment.rb', line 60 def params default_params.deep_merge!(payment_params) end |
#payment_params ⇒ Object
64 65 66 |
# File 'lib/cardgate/payment.rb', line 64 def payment_params {} end |
#payment_url ⇒ Object
52 53 54 |
# File 'lib/cardgate/payment.rb', line 52 def payment_url @response.body['payment']['issuer_auth_url'] end |
#transaction_id ⇒ Object
56 57 58 |
# File 'lib/cardgate/payment.rb', line 56 def transaction_id @response.body['payment']['transaction_id'] end |