Class: Spreedly::Environment
- Inherits:
-
Object
- Object
- Spreedly::Environment
show all
- Includes:
- SslRequester, Urls
- Defined in:
- lib/spreedly/environment.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
-
#add_credit_card(options) ⇒ Object
-
#add_gateway(gateway_type, credentials = {}) ⇒ Object
-
#add_receiver(receiver_type, host_names = nil, credentials = []) ⇒ Object
-
#authorize_on_gateway(gateway_token, payment_method_token, amount, options = {}) ⇒ Object
-
#capture_transaction(authorization_token, options = {}) ⇒ Object
-
#deliver_to_receiver(receiver_token, payment_method_token, receiver_options) ⇒ Object
-
#find_gateway(token) ⇒ Object
-
#find_payment_method(token) ⇒ Object
-
#find_transaction(token) ⇒ Object
-
#find_transcript(transaction_token) ⇒ Object
-
#gateway_options ⇒ Object
-
#initialize(environment_key, access_secret, options = {}) ⇒ Environment
constructor
A new instance of Environment.
-
#list_gateways(since_token = nil) ⇒ Object
-
#list_payment_methods(since_token = nil) ⇒ Object
-
#list_transactions(since_token = nil, payment_method_token = nil) ⇒ Object
-
#purchase_on_gateway(gateway_token, payment_method_token, amount, options = {}) ⇒ Object
-
#redact_gateway(gateway_token, options = {}) ⇒ Object
-
#redact_payment_method(payment_method_token, options = {}) ⇒ Object
-
#refund_transaction(token, options = {}) ⇒ Object
-
#retain_payment_method(payment_method_token) ⇒ Object
-
#store_on_gateway(gateway_token, payment_method_token, options = {}) ⇒ Object
-
#transparent_redirect_form_action ⇒ Object
-
#update_credit_card(credit_card_token, options) ⇒ Object
-
#verify_on_gateway(gateway_token, payment_method_token, options = {}) ⇒ Object
-
#void_transaction(token, options = {}) ⇒ Object
Methods included from Urls
#add_gateway_url, #add_payment_method_url, #add_receiver_url, #authorize_url, #capture_url, #deliver_to_receiver_url, #find_gateway_url, #find_payment_method_url, #find_transaction_url, #find_transcript_url, #gateway_options_url, #list_gateways_url, #list_payment_methods_url, #list_transactions_url, #purchase_url, #redact_gateway_url, #redact_payment_method_url, #refund_transaction_url, #retain_payment_method_url, #store_url, #update_payment_method_url, #verify_url, #void_transaction_url
#ssl_get, #ssl_options, #ssl_post, #ssl_put, #ssl_raw_get
Constructor Details
#initialize(environment_key, access_secret, options = {}) ⇒ Environment
Returns a new instance of Environment.
12
13
14
15
16
|
# File 'lib/spreedly/environment.rb', line 12
def initialize(environment_key, access_secret, options={})
@key, @access_secret = environment_key, access_secret
@base_url = options[:base_url] || "https://core.spreedly.com"
@currency_code = options[:currency_code] || 'USD'
end
|
Instance Attribute Details
#base_url ⇒ Object
Returns the value of attribute base_url.
10
11
12
|
# File 'lib/spreedly/environment.rb', line 10
def base_url
@base_url
end
|
#currency_code ⇒ Object
Returns the value of attribute currency_code.
10
11
12
|
# File 'lib/spreedly/environment.rb', line 10
def currency_code
@currency_code
end
|
#key ⇒ Object
Returns the value of attribute key.
10
11
12
|
# File 'lib/spreedly/environment.rb', line 10
def key
@key
end
|
Class Method Details
.gateway_options ⇒ Object
109
110
111
|
# File 'lib/spreedly/environment.rb', line 109
def self.gateway_options
self.new("", "").gateway_options
end
|
Instance Method Details
#add_credit_card(options) ⇒ Object
125
126
127
|
# File 'lib/spreedly/environment.rb', line 125
def add_credit_card(options)
api_post(add_payment_method_url, add_credit_card_body(options), false)
end
|
#add_gateway(gateway_type, credentials = {}) ⇒ Object
113
114
115
116
117
|
# File 'lib/spreedly/environment.rb', line 113
def add_gateway(gateway_type, credentials = {})
body = add_gateway_body(gateway_type, credentials)
xml_doc = ssl_post(add_gateway_url, body, )
Gateway.new(xml_doc)
end
|
#add_receiver(receiver_type, host_names = nil, credentials = []) ⇒ Object
119
120
121
122
123
|
# File 'lib/spreedly/environment.rb', line 119
def add_receiver(receiver_type, host_names = nil, credentials = [])
body = add_receiver_body(receiver_type, host_names, credentials)
xml_doc = ssl_post(add_receiver_url, body, )
Receiver.new(xml_doc)
end
|
#authorize_on_gateway(gateway_token, payment_method_token, amount, options = {}) ⇒ Object
46
47
48
49
|
# File 'lib/spreedly/environment.rb', line 46
def authorize_on_gateway(gateway_token, payment_method_token, amount, options = {})
body = auth_purchase_body(amount, payment_method_token, options)
api_post(authorize_url(gateway_token), body)
end
|
#capture_transaction(authorization_token, options = {}) ⇒ Object
56
57
58
|
# File 'lib/spreedly/environment.rb', line 56
def capture_transaction(authorization_token, options = {})
api_post(capture_url(authorization_token), capture_body(options))
end
|
#deliver_to_receiver(receiver_token, payment_method_token, receiver_options) ⇒ Object
135
136
137
138
|
# File 'lib/spreedly/environment.rb', line 135
def deliver_to_receiver(receiver_token, payment_method_token, receiver_options)
body = deliver_to_receiver_body(payment_method_token, receiver_options)
api_post(deliver_to_receiver_url(receiver_token), body)
end
|
#find_gateway(token) ⇒ Object
36
37
38
39
|
# File 'lib/spreedly/environment.rb', line 36
def find_gateway(token)
xml_doc = ssl_get(find_gateway_url(token), )
Gateway.new(xml_doc)
end
|
#find_payment_method(token) ⇒ Object
22
23
24
25
|
# File 'lib/spreedly/environment.rb', line 22
def find_payment_method(token)
xml_doc = ssl_get(find_payment_method_url(token), )
PaymentMethod.new_from(xml_doc)
end
|
#find_transaction(token) ⇒ Object
27
28
29
30
|
# File 'lib/spreedly/environment.rb', line 27
def find_transaction(token)
xml_doc = ssl_get(find_transaction_url(token), )
Transaction.new_from(xml_doc)
end
|
#find_transcript(transaction_token) ⇒ Object
32
33
34
|
# File 'lib/spreedly/environment.rb', line 32
def find_transcript(transaction_token)
ssl_raw_get(find_transcript_url(transaction_token), )
end
|
#gateway_options ⇒ Object
104
105
106
107
|
# File 'lib/spreedly/environment.rb', line 104
def gateway_options
xml_doc = ssl_options(gateway_options_url)
GatewayClass.new_list_from(xml_doc)
end
|
#list_gateways(since_token = nil) ⇒ Object
94
95
96
97
|
# File 'lib/spreedly/environment.rb', line 94
def list_gateways(since_token = nil)
xml_doc = ssl_get(list_gateways_url(since_token), )
Gateway.new_list_from(xml_doc)
end
|
#list_payment_methods(since_token = nil) ⇒ Object
89
90
91
92
|
# File 'lib/spreedly/environment.rb', line 89
def list_payment_methods(since_token = nil)
xml_doc = ssl_get(list_payment_methods_url(since_token), )
PaymentMethod.new_list_from(xml_doc)
end
|
#list_transactions(since_token = nil, payment_method_token = nil) ⇒ Object
84
85
86
87
|
# File 'lib/spreedly/environment.rb', line 84
def list_transactions(since_token = nil, payment_method_token = nil)
xml_doc = ssl_get(list_transactions_url(since_token, payment_method_token), )
Transaction.new_list_from(xml_doc)
end
|
#purchase_on_gateway(gateway_token, payment_method_token, amount, options = {}) ⇒ Object
41
42
43
44
|
# File 'lib/spreedly/environment.rb', line 41
def purchase_on_gateway(gateway_token, payment_method_token, amount, options = {})
body = auth_purchase_body(amount, payment_method_token, options)
api_post(purchase_url(gateway_token), body)
end
|
#redact_gateway(gateway_token, options = {}) ⇒ Object
79
80
81
82
|
# File 'lib/spreedly/environment.rb', line 79
def redact_gateway(gateway_token, options = {})
xml_doc = ssl_put(redact_gateway_url(gateway_token), '', )
Transaction.new_from(xml_doc)
end
|
#redact_payment_method(payment_method_token, options = {}) ⇒ Object
73
74
75
76
77
|
# File 'lib/spreedly/environment.rb', line 73
def redact_payment_method(payment_method_token, options = {})
body = redact_payment_method_body(options)
xml_doc = ssl_put(redact_payment_method_url(payment_method_token), body, )
Transaction.new_from(xml_doc)
end
|
#refund_transaction(token, options = {}) ⇒ Object
64
65
66
|
# File 'lib/spreedly/environment.rb', line 64
def refund_transaction(token, options = {})
api_post(refund_transaction_url(token), refund_body(options))
end
|
#retain_payment_method(payment_method_token) ⇒ Object
68
69
70
71
|
# File 'lib/spreedly/environment.rb', line 68
def retain_payment_method(payment_method_token)
xml_doc = ssl_put(retain_payment_method_url(payment_method_token), '', )
Transaction.new_from(xml_doc)
end
|
#store_on_gateway(gateway_token, payment_method_token, options = {}) ⇒ Object
99
100
101
102
|
# File 'lib/spreedly/environment.rb', line 99
def store_on_gateway(gateway_token, payment_method_token, options = {})
body = store_body(payment_method_token, options)
api_post(store_url(gateway_token), body)
end
|
18
19
20
|
# File 'lib/spreedly/environment.rb', line 18
def transparent_redirect_form_action
"#{base_url}/v1/payment_methods"
end
|
#update_credit_card(credit_card_token, options) ⇒ Object
129
130
131
132
133
|
# File 'lib/spreedly/environment.rb', line 129
def update_credit_card(credit_card_token, options)
body = update_credit_card_body(options)
xml_doc = ssl_put(update_payment_method_url(credit_card_token), body, )
PaymentMethod.new_from(xml_doc)
end
|
#verify_on_gateway(gateway_token, payment_method_token, options = {}) ⇒ Object
51
52
53
54
|
# File 'lib/spreedly/environment.rb', line 51
def verify_on_gateway(gateway_token, payment_method_token, options = {})
body = verify_body(payment_method_token, options)
api_post(verify_url(gateway_token), body)
end
|
#void_transaction(token, options = {}) ⇒ Object
60
61
62
|
# File 'lib/spreedly/environment.rb', line 60
def void_transaction(token, options = {})
api_post(void_transaction_url(token), void_body(options))
end
|