Class: SpreedlyCore::PaymentMethod
- Defined in:
- lib/spreedly_core/payment_method.rb,
lib/spreedly_core/test_extensions.rb
Instance Attribute Summary collapse
-
#address1 ⇒ Object
readonly
Returns the value of attribute address1.
-
#address2 ⇒ Object
readonly
Returns the value of attribute address2.
-
#card_type ⇒ Object
readonly
Returns the value of attribute card_type.
-
#city ⇒ Object
readonly
Returns the value of attribute city.
-
#country ⇒ Object
readonly
Returns the value of attribute country.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#first_name ⇒ Object
readonly
Returns the value of attribute first_name.
-
#last_four_digits ⇒ Object
readonly
Returns the value of attribute last_four_digits.
-
#last_name ⇒ Object
readonly
Returns the value of attribute last_name.
-
#month ⇒ Object
readonly
Returns the value of attribute month.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#payment_method_type ⇒ Object
readonly
Returns the value of attribute payment_method_type.
-
#phone_number ⇒ Object
readonly
Returns the value of attribute phone_number.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
-
#verification_value ⇒ Object
readonly
Returns the value of attribute verification_value.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
-
#zip ⇒ Object
readonly
Returns the value of attribute zip.
Class Method Summary collapse
-
.additional_required_cc_fields(*fields) ⇒ Object
configure additional required fiels.
-
.create_test_token(cc_data = {}, pass_through_data = nil) ⇒ Object
Call spreedly core to create a test token.
-
.find(token) ⇒ Object
Lookup the PaymentMethod by token.
-
.reset_additional_required_cc_fields ⇒ Object
clear the configured additional required fields.
-
.submit_url ⇒ Object
Returns the URL that CC data should be submitted to.
Instance Method Summary collapse
-
#authorize(amount, currency = nil, _gateway_token = nil, ip_address = nil) ⇒ Object
Make an authorize against payment method.
-
#initialize(attrs = {}) ⇒ PaymentMethod
constructor
Create a new PaymentMethod based on the attrs hash and then validate.
-
#purchase(amount, currency = nil, _gateway_token = nil, ip_address = nil) ⇒ Object
Make a purchase against the payment method.
-
#redact ⇒ Object
Redact the payment method.
-
#retain ⇒ Object
Retain the payment method.
- #valid? ⇒ Boolean
Methods inherited from Base
configure, gateway_token, login, verify_get, verify_options, verify_post, verify_put, verify_request
Constructor Details
#initialize(attrs = {}) ⇒ PaymentMethod
Create a new PaymentMethod based on the attrs hash and then validate
29 30 31 32 |
# File 'lib/spreedly_core/payment_method.rb', line 29 def initialize(attrs={}) super(attrs) validate end |
Instance Attribute Details
#address1 ⇒ Object (readonly)
Returns the value of attribute address1.
3 4 5 |
# File 'lib/spreedly_core/payment_method.rb', line 3 def address1 @address1 end |
#address2 ⇒ Object (readonly)
Returns the value of attribute address2.
3 4 5 |
# File 'lib/spreedly_core/payment_method.rb', line 3 def address2 @address2 end |
#card_type ⇒ Object (readonly)
Returns the value of attribute card_type.
3 4 5 |
# File 'lib/spreedly_core/payment_method.rb', line 3 def card_type @card_type end |
#city ⇒ Object (readonly)
Returns the value of attribute city.
3 4 5 |
# File 'lib/spreedly_core/payment_method.rb', line 3 def city @city end |
#country ⇒ Object (readonly)
Returns the value of attribute country.
3 4 5 |
# File 'lib/spreedly_core/payment_method.rb', line 3 def country @country end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
3 4 5 |
# File 'lib/spreedly_core/payment_method.rb', line 3 def created_at @created_at end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
3 4 5 |
# File 'lib/spreedly_core/payment_method.rb', line 3 def data @data end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
3 4 5 |
# File 'lib/spreedly_core/payment_method.rb', line 3 def email @email end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
3 4 5 |
# File 'lib/spreedly_core/payment_method.rb', line 3 def errors @errors end |
#first_name ⇒ Object (readonly)
Returns the value of attribute first_name.
3 4 5 |
# File 'lib/spreedly_core/payment_method.rb', line 3 def first_name @first_name end |
#last_four_digits ⇒ Object (readonly)
Returns the value of attribute last_four_digits.
3 4 5 |
# File 'lib/spreedly_core/payment_method.rb', line 3 def last_four_digits @last_four_digits end |
#last_name ⇒ Object (readonly)
Returns the value of attribute last_name.
3 4 5 |
# File 'lib/spreedly_core/payment_method.rb', line 3 def last_name @last_name end |
#month ⇒ Object (readonly)
Returns the value of attribute month.
3 4 5 |
# File 'lib/spreedly_core/payment_method.rb', line 3 def month @month end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
3 4 5 |
# File 'lib/spreedly_core/payment_method.rb', line 3 def number @number end |
#payment_method_type ⇒ Object (readonly)
Returns the value of attribute payment_method_type.
3 4 5 |
# File 'lib/spreedly_core/payment_method.rb', line 3 def payment_method_type @payment_method_type end |
#phone_number ⇒ Object (readonly)
Returns the value of attribute phone_number.
3 4 5 |
# File 'lib/spreedly_core/payment_method.rb', line 3 def phone_number @phone_number end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
3 4 5 |
# File 'lib/spreedly_core/payment_method.rb', line 3 def state @state end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
3 4 5 |
# File 'lib/spreedly_core/payment_method.rb', line 3 def token @token end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
3 4 5 |
# File 'lib/spreedly_core/payment_method.rb', line 3 def updated_at @updated_at end |
#verification_value ⇒ Object (readonly)
Returns the value of attribute verification_value.
3 4 5 |
# File 'lib/spreedly_core/payment_method.rb', line 3 def verification_value @verification_value end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
3 4 5 |
# File 'lib/spreedly_core/payment_method.rb', line 3 def year @year end |
#zip ⇒ Object (readonly)
Returns the value of attribute zip.
3 4 5 |
# File 'lib/spreedly_core/payment_method.rb', line 3 def zip @zip end |
Class Method Details
.additional_required_cc_fields(*fields) ⇒ Object
configure additional required fiels. Like :address1, :city, :state
9 10 11 12 |
# File 'lib/spreedly_core/payment_method.rb', line 9 def self.additional_required_cc_fields *fields @@additional_required_fields ||= Set.new @@additional_required_fields += fields end |
.create_test_token(cc_data = {}, pass_through_data = nil) ⇒ Object
Call spreedly core to create a test token. pass_through_data will be added as the “data” field.
46 47 48 49 50 51 52 53 54 |
# File 'lib/spreedly_core/test_extensions.rb', line 46 def self.create_test_token(cc_data={}, pass_through_data=nil) data = cc_data.merge(:redirect_url => "http://example.com", :api_login => SpreedlyCore::Base.login, :data => pass_through_data) self.verify_post "/payment_methods", :body => data, :has_key => "transaction" do |r| r['transaction']['payment_method']['token'] end end |
.find(token) ⇒ Object
Lookup the PaymentMethod by token
20 21 22 23 24 25 26 |
# File 'lib/spreedly_core/payment_method.rb', line 20 def self.find(token) return nil if token.nil? verify_get("/payment_methods/#{token}.xml", :has_key => "payment_method") do |response| new(response.parsed_response["payment_method"]) end end |
.reset_additional_required_cc_fields ⇒ Object
clear the configured additional required fields
15 16 17 |
# File 'lib/spreedly_core/payment_method.rb', line 15 def self.reset_additional_required_cc_fields @@additional_required_fields = Set.new end |
.submit_url ⇒ Object
Returns the URL that CC data should be submitted to.
61 62 63 |
# File 'lib/spreedly_core/payment_method.rb', line 61 def self.submit_url Base.base_uri + '/payment_methods' end |
Instance Method Details
#authorize(amount, currency = nil, _gateway_token = nil, ip_address = nil) ⇒ Object
Make an authorize against payment method. You can then later capture against the authorize
56 57 58 |
# File 'lib/spreedly_core/payment_method.rb', line 56 def (amount, currency=nil, _gateway_token=nil, ip_address=nil) (:authorize, amount, currency, _gateway_token, ip_address) end |
#purchase(amount, currency = nil, _gateway_token = nil, ip_address = nil) ⇒ Object
Make a purchase against the payment method
51 52 53 |
# File 'lib/spreedly_core/payment_method.rb', line 51 def purchase(amount, currency=nil, _gateway_token=nil, ip_address=nil) (:purchase, amount, currency, _gateway_token, ip_address) end |
#redact ⇒ Object
Redact the payment method
43 44 45 46 47 48 |
# File 'lib/spreedly_core/payment_method.rb', line 43 def redact self.class.verify_put("/payment_methods/#{token}/redact.xml", :body => {}, :has_key => "transaction") do |response| RedactTransaction.new(response.parsed_response["transaction"]) end end |
#retain ⇒ Object
Retain the payment method
35 36 37 38 39 40 |
# File 'lib/spreedly_core/payment_method.rb', line 35 def retain self.class.verify_put("/payment_methods/#{token}/retain.xml", :body => {}, :has_key => "transaction") do |response| RetainTransaction.new(response.parsed_response["transaction"]) end end |
#valid? ⇒ Boolean
65 66 67 |
# File 'lib/spreedly_core/payment_method.rb', line 65 def valid? @errors.empty? end |