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
-
#complete_transaction(transaction_token) ⇒ 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, options = {}) ⇒ Object
-
#purchase_on_gateway(gateway_token, payment_method_token, amount, options = {}) ⇒ Object
-
#recache_payment_method(payment_method_token, options = {}) ⇒ Object
-
#receiver_options ⇒ Object
-
#redact_gateway(gateway_token, options = {}) ⇒ Object
-
#redact_payment_method(payment_method_token, options = {}) ⇒ Object
-
#redact_receiver(receiver_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, #complete_transaction_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, #recache_payment_method_url, #receiver_options_url, #redact_gateway_url, #redact_payment_method_url, #redact_receiver_url, #refund_transaction_url, #retain_payment_method_url, #store_url, #update_payment_method_url, #verify_url, #void_transaction_url
#ssl_get, #ssl_post, #ssl_put, #ssl_raw_get
Constructor Details
#initialize(environment_key, access_secret, options = {}) ⇒ Environment
Returns a new instance of Environment.
13
14
15
16
17
|
# File 'lib/spreedly/environment.rb', line 13
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.
11
12
13
|
# File 'lib/spreedly/environment.rb', line 11
def base_url
@base_url
end
|
#currency_code ⇒ Object
Returns the value of attribute currency_code.
11
12
13
|
# File 'lib/spreedly/environment.rb', line 11
def currency_code
@currency_code
end
|
#key ⇒ Object
Returns the value of attribute key.
11
12
13
|
# File 'lib/spreedly/environment.rb', line 11
def key
@key
end
|
Class Method Details
.gateway_options ⇒ Object
126
127
128
|
# File 'lib/spreedly/environment.rb', line 126
def self.gateway_options
self.new("", "").gateway_options
end
|
.receiver_options ⇒ Object
135
136
137
|
# File 'lib/spreedly/environment.rb', line 135
def self.receiver_options
self.new("", "").receiver_options
end
|
Instance Method Details
#add_credit_card(options) ⇒ Object
151
152
153
|
# File 'lib/spreedly/environment.rb', line 151
def add_credit_card(options)
api_post(add_payment_method_url, add_credit_card_body(options), false)
end
|
#add_gateway(gateway_type, credentials = {}) ⇒ Object
139
140
141
142
143
|
# File 'lib/spreedly/environment.rb', line 139
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
145
146
147
148
149
|
# File 'lib/spreedly/environment.rb', line 145
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
48
49
50
51
|
# File 'lib/spreedly/environment.rb', line 48
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
62
63
64
|
# File 'lib/spreedly/environment.rb', line 62
def capture_transaction(authorization_token, options = {})
api_post(capture_url(authorization_token), capture_body(options))
end
|
#complete_transaction(transaction_token) ⇒ Object
53
54
55
|
# File 'lib/spreedly/environment.rb', line 53
def complete_transaction(transaction_token)
api_post(complete_transaction_url(transaction_token), '')
end
|
#deliver_to_receiver(receiver_token, payment_method_token, receiver_options) ⇒ Object
161
162
163
164
|
# File 'lib/spreedly/environment.rb', line 161
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
38
39
40
41
|
# File 'lib/spreedly/environment.rb', line 38
def find_gateway(token)
xml_doc = ssl_get(find_gateway_url(token), )
Gateway.new(xml_doc)
end
|
#find_payment_method(token) ⇒ Object
23
24
25
26
|
# File 'lib/spreedly/environment.rb', line 23
def find_payment_method(token)
xml_doc = ssl_get(find_payment_method_url(token), )
PaymentMethod.new_from(xml_doc)
end
|
#find_transaction(token) ⇒ Object
28
29
30
31
|
# File 'lib/spreedly/environment.rb', line 28
def find_transaction(token)
xml_doc = ssl_get(find_transaction_url(token), )
Transaction.new_from(xml_doc)
end
|
#find_transcript(transaction_token) ⇒ Object
33
34
35
36
|
# File 'lib/spreedly/environment.rb', line 33
def find_transcript(transaction_token)
transcript_url = find_transcript_url(transaction_token)
ssl_raw_get(transcript_url, )
end
|
#gateway_options ⇒ Object
121
122
123
124
|
# File 'lib/spreedly/environment.rb', line 121
def gateway_options
xml_doc = ssl_get(gateway_options_url, )
GatewayClass.new_list_from(xml_doc)
end
|
#list_gateways(since_token = nil) ⇒ Object
111
112
113
114
|
# File 'lib/spreedly/environment.rb', line 111
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
106
107
108
109
|
# File 'lib/spreedly/environment.rb', line 106
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, options = {}) ⇒ Object
101
102
103
104
|
# File 'lib/spreedly/environment.rb', line 101
def list_transactions(since_token = nil, payment_method_token = nil, options = {})
xml_doc = ssl_get(list_transactions_url(since_token, payment_method_token, options), )
Transaction.new_list_from(xml_doc)
end
|
#purchase_on_gateway(gateway_token, payment_method_token, amount, options = {}) ⇒ Object
43
44
45
46
|
# File 'lib/spreedly/environment.rb', line 43
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
|
#recache_payment_method(payment_method_token, options = {}) ⇒ Object
85
86
87
88
89
|
# File 'lib/spreedly/environment.rb', line 85
def recache_payment_method(payment_method_token, options = {})
body = recache_payment_method_body(options)
xml_doc = ssl_put(recache_payment_method_url(payment_method_token), body, )
RecacheSensitiveData.new_from(xml_doc)
end
|
#receiver_options ⇒ Object
130
131
132
133
|
# File 'lib/spreedly/environment.rb', line 130
def receiver_options
xml_doc = ssl_get(receiver_options_url, )
ReceiverClass.new_list_from(xml_doc)
end
|
#redact_gateway(gateway_token, options = {}) ⇒ Object
91
92
93
94
|
# File 'lib/spreedly/environment.rb', line 91
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
79
80
81
82
83
|
# File 'lib/spreedly/environment.rb', line 79
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
|
#redact_receiver(receiver_token, options = {}) ⇒ Object
96
97
98
99
|
# File 'lib/spreedly/environment.rb', line 96
def redact_receiver(receiver_token, options = {})
xml_doc = ssl_put(redact_receiver_url(receiver_token), '', )
Transaction.new_from(xml_doc)
end
|
#refund_transaction(token, options = {}) ⇒ Object
70
71
72
|
# File 'lib/spreedly/environment.rb', line 70
def refund_transaction(token, options = {})
api_post(refund_transaction_url(token), refund_body(options))
end
|
#retain_payment_method(payment_method_token) ⇒ Object
74
75
76
77
|
# File 'lib/spreedly/environment.rb', line 74
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
116
117
118
119
|
# File 'lib/spreedly/environment.rb', line 116
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
|
19
20
21
|
# File 'lib/spreedly/environment.rb', line 19
def transparent_redirect_form_action
"#{base_url}/v1/payment_methods"
end
|
#update_credit_card(credit_card_token, options) ⇒ Object
155
156
157
158
159
|
# File 'lib/spreedly/environment.rb', line 155
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
57
58
59
60
|
# File 'lib/spreedly/environment.rb', line 57
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
66
67
68
|
# File 'lib/spreedly/environment.rb', line 66
def void_transaction(token, options = {})
api_post(void_transaction_url(token), void_body(options))
end
|