authorizenet_blaq 1.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/app/helpers/authorize_net_helper.rb +24 -0
- data/lib/authorize_net/addresses/address.rb +29 -0
- data/lib/authorize_net/addresses/shipping_address.rb +26 -0
- data/lib/authorize_net/aim/response.rb +131 -0
- data/lib/authorize_net/aim/transaction.rb +190 -0
- data/lib/authorize_net/api/api_transaction.rb +123 -0
- data/lib/authorize_net/api/constants.yml +1 -0
- data/lib/authorize_net/api/schema.rb +4985 -0
- data/lib/authorize_net/api/transaction.rb +258 -0
- data/lib/authorize_net/arb/fields.rb +24 -0
- data/lib/authorize_net/arb/paging.rb +33 -0
- data/lib/authorize_net/arb/response.rb +34 -0
- data/lib/authorize_net/arb/sorting.rb +43 -0
- data/lib/authorize_net/arb/subscription.rb +72 -0
- data/lib/authorize_net/arb/subscription_detail.rb +14 -0
- data/lib/authorize_net/arb/subscription_list_response.rb +43 -0
- data/lib/authorize_net/arb/transaction.rb +177 -0
- data/lib/authorize_net/authorize_net.rb +154 -0
- data/lib/authorize_net/cim/customer_profile.rb +19 -0
- data/lib/authorize_net/cim/payment_profile.rb +37 -0
- data/lib/authorize_net/cim/response.rb +116 -0
- data/lib/authorize_net/cim/transaction.rb +727 -0
- data/lib/authorize_net/customer.rb +27 -0
- data/lib/authorize_net/email_receipt.rb +24 -0
- data/lib/authorize_net/fields.rb +779 -0
- data/lib/authorize_net/key_value_response.rb +117 -0
- data/lib/authorize_net/key_value_transaction.rb +291 -0
- data/lib/authorize_net/line_item.rb +25 -0
- data/lib/authorize_net/order.rb +42 -0
- data/lib/authorize_net/payment_methods/credit_card.rb +62 -0
- data/lib/authorize_net/payment_methods/echeck.rb +72 -0
- data/lib/authorize_net/reporting/batch.rb +19 -0
- data/lib/authorize_net/reporting/batch_statistics.rb +19 -0
- data/lib/authorize_net/reporting/fds_filter.rb +11 -0
- data/lib/authorize_net/reporting/response.rb +163 -0
- data/lib/authorize_net/reporting/returned_item.rb +46 -0
- data/lib/authorize_net/reporting/transaction.rb +133 -0
- data/lib/authorize_net/reporting/transaction_details.rb +25 -0
- data/lib/authorize_net/response.rb +27 -0
- data/lib/authorize_net/sim/hosted_payment_form.rb +38 -0
- data/lib/authorize_net/sim/hosted_receipt_page.rb +37 -0
- data/lib/authorize_net/sim/response.rb +142 -0
- data/lib/authorize_net/sim/transaction.rb +138 -0
- data/lib/authorize_net/transaction.rb +66 -0
- data/lib/authorize_net/xml_response.rb +172 -0
- data/lib/authorize_net/xml_transaction.rb +298 -0
- data/lib/authorize_net.rb +107 -0
- data/lib/authorizenet_blaq.rb +4 -0
- data/lib/generators/authorize_net/direct_post/direct_post_generator.rb +53 -0
- data/lib/generators/authorize_net/direct_post/templates/README-AuthorizeNet +49 -0
- data/lib/generators/authorize_net/direct_post/templates/config.yml.erb +8 -0
- data/lib/generators/authorize_net/direct_post/templates/config.yml.rails3.erb +8 -0
- data/lib/generators/authorize_net/direct_post/templates/controller.rb.erb +31 -0
- data/lib/generators/authorize_net/direct_post/templates/initializer.rb +4 -0
- data/lib/generators/authorize_net/direct_post/templates/layout.erb +18 -0
- data/lib/generators/authorize_net/direct_post/templates/payment.erb +10 -0
- data/lib/generators/authorize_net/direct_post/templates/payment.rails3.erb +10 -0
- data/lib/generators/authorize_net/direct_post/templates/receipt.erb +1 -0
- data/lib/generators/authorize_net/direct_post/templates/relay_response.erb +1 -0
- data/lib/generators/authorize_net/sim/sim_generator.rb +47 -0
- data/lib/generators/authorize_net/sim/templates/README-AuthorizeNet +52 -0
- data/lib/generators/authorize_net/sim/templates/config.yml.erb +8 -0
- data/lib/generators/authorize_net/sim/templates/config.yml.rails3.erb +8 -0
- data/lib/generators/authorize_net/sim/templates/controller.rb.erb +21 -0
- data/lib/generators/authorize_net/sim/templates/initializer.rb +4 -0
- data/lib/generators/authorize_net/sim/templates/layout.erb +18 -0
- data/lib/generators/authorize_net/sim/templates/payment.erb +6 -0
- data/lib/generators/authorize_net/sim/templates/payment.rails3.erb +6 -0
- data/lib/generators/authorize_net/sim/templates/thank_you.erb +1 -0
- data/lib/generators/generator_extensions.rb +75 -0
- metadata +196 -0
@@ -0,0 +1,258 @@
|
|
1
|
+
module AuthorizeNet::API
|
2
|
+
class Transaction < ApiTransaction
|
3
|
+
attr_accessor :access_token
|
4
|
+
attr_accessor :options_OAuth
|
5
|
+
|
6
|
+
def initialize(api_login_id = nil, api_transaction_key = nil, options = {})
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
10
|
+
# This request enables you to create a transaction, and optional customer profile.
|
11
|
+
# NOTE: Tokenized transactions (e.g. Apple Pay), or PayPal should not be used to
|
12
|
+
# create payment profiles.
|
13
|
+
#
|
14
|
+
# See spec/api_spec.rb for usage examples
|
15
|
+
def create_transaction(request)
|
16
|
+
make_request(request,CreateTransactionResponse,Type::API_CREATE_TRANSACTION)
|
17
|
+
end
|
18
|
+
|
19
|
+
# This request enables you to create a recurring billing subscription
|
20
|
+
#
|
21
|
+
# See spec/api_spec.rb for usage examples
|
22
|
+
def create_subscription(request)
|
23
|
+
make_request(request,ARBCreateSubscriptionResponse,Type::API_CREATE_SUBSCRIPTION)
|
24
|
+
end
|
25
|
+
|
26
|
+
# This request enables you to update a recurring billing subscription
|
27
|
+
#
|
28
|
+
# See spec/api_spec.rb for usage examples
|
29
|
+
def update_subscription(request)
|
30
|
+
make_request(request,ARBUpdateSubscriptionResponse,Type::API_UPDATE_SUBSCRIPTION)
|
31
|
+
end
|
32
|
+
|
33
|
+
# This request enables you to cancel a recurring billing subscription
|
34
|
+
#
|
35
|
+
# See spec/api_spec.rb for usage examples
|
36
|
+
def cancel_subscription(request)
|
37
|
+
make_request(request,ARBCancelSubscriptionResponse,Type::API_CANCEL_SUBSCRIPTION)
|
38
|
+
end
|
39
|
+
|
40
|
+
# This request enables you to get a recurring billing subscription status
|
41
|
+
#
|
42
|
+
# See spec/api_spec.rb for usage examples
|
43
|
+
def get_subscription_status(request)
|
44
|
+
make_request(request,ARBGetSubscriptionStatusResponse,Type::API_GET_SUBSCRIPTION_STATUS)
|
45
|
+
end
|
46
|
+
|
47
|
+
# This request enables you to get a list of all recurring billing subscriptions
|
48
|
+
#
|
49
|
+
# See spec/api_spec.rb for usage examples
|
50
|
+
def get_subscription_list(request)
|
51
|
+
make_request(request,ARBGetSubscriptionListResponse,Type::API_GET_SUBSCRIPTION_LIST)
|
52
|
+
end
|
53
|
+
|
54
|
+
# This request enables you to create a customer profile
|
55
|
+
#
|
56
|
+
# See spec/api_spec.rb for usage examples
|
57
|
+
def create_customer_profile(request)
|
58
|
+
make_request(request,CreateCustomerProfileResponse,Type::API_CREATE_CUSTOMER_PROFILE)
|
59
|
+
end
|
60
|
+
|
61
|
+
# This request enables you to retrieve a customer profile
|
62
|
+
#
|
63
|
+
# See spec/api_spec.rb for usage examples
|
64
|
+
def get_customer_profile(request)
|
65
|
+
make_request(request,GetCustomerProfileResponse,Type::API_GET_CUSTOMER_PROFILE)
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
# This request enables you to retrieve all customer profile ids
|
70
|
+
#
|
71
|
+
# See spec/api_spec.rb for usage examples
|
72
|
+
def get_customer_profile_ids(request)
|
73
|
+
make_request(request,GetCustomerProfileIdsResponse,Type::API_GET_CUSTOMER_PROFILE_IDS)
|
74
|
+
end
|
75
|
+
|
76
|
+
# This request enables you to update a customer profile
|
77
|
+
#
|
78
|
+
# See spec/api_spec.rb for usage examples
|
79
|
+
def update_customer_profile(request)
|
80
|
+
make_request(request,UpdateCustomerProfileResponse,Type::API_UPDATE_CUSTOMER_PROFILE)
|
81
|
+
end
|
82
|
+
|
83
|
+
# This request enables you to delete a customer profile
|
84
|
+
#
|
85
|
+
# See spec/api_spec.rb for usage examples
|
86
|
+
def delete_customer_profile(request)
|
87
|
+
make_request(request,DeleteCustomerProfileResponse,Type::API_DELETE_CUSTOMER_PROFILE)
|
88
|
+
end
|
89
|
+
|
90
|
+
# This request enables you to create a customer payment profile
|
91
|
+
#
|
92
|
+
# See spec/api_spec.rb for usage examples
|
93
|
+
def create_customer_payment_profile(request)
|
94
|
+
make_request(request,CreateCustomerPaymentProfileResponse,Type::API_CREATE_CUSTOMER_PAYMENT_PROFILE)
|
95
|
+
end
|
96
|
+
|
97
|
+
# This request enables you to retrieve a customer payment profile
|
98
|
+
#
|
99
|
+
# See spec/api_spec.rb for usage examples
|
100
|
+
def get_customer_payment_profile(request)
|
101
|
+
make_request(request,GetCustomerPaymentProfileResponse,Type::API_GET_CUSTOMER_PAYMENT_PROFILE)
|
102
|
+
end
|
103
|
+
|
104
|
+
# This request enables you to update a customer payment profile
|
105
|
+
#
|
106
|
+
# See spec/api_spec.rb for usage examples
|
107
|
+
def update_customer_payment_profile(request)
|
108
|
+
make_request(request,UpdateCustomerPaymentProfileResponse,Type::API_UPDATE_CUSTOMER_PAYMENT_PROFILE)
|
109
|
+
end
|
110
|
+
|
111
|
+
# This request enables you to delete a customer payment profile
|
112
|
+
#
|
113
|
+
# See spec/api_spec.rb for usage examples
|
114
|
+
def delete_customer_payment_profile(request)
|
115
|
+
make_request(request,DeleteCustomerPaymentProfileResponse,Type::API_DELETE_CUSTOMER_PAYMENT_PROFILE)
|
116
|
+
end
|
117
|
+
|
118
|
+
# This request enables you to create a customer shipping profile
|
119
|
+
#
|
120
|
+
# See spec/api_spec.rb for usage examples
|
121
|
+
def create_customer_shipping_profile(request)
|
122
|
+
make_request(request,CreateCustomerShippingAddressResponse,Type::API_CREATE_CUSTOMER_SHIPPING_PROFILE)
|
123
|
+
end
|
124
|
+
|
125
|
+
# This request enables you to retrieve a customer shipping profile
|
126
|
+
#
|
127
|
+
# See spec/api_spec.rb for usage examples
|
128
|
+
def get_customer_shipping_profile(request)
|
129
|
+
make_request(request,GetCustomerShippingAddressResponse,Type::API_GET_CUSTOMER_SHIPPING_PROFILE)
|
130
|
+
end
|
131
|
+
|
132
|
+
# This request enables you to update a customer shipping profile
|
133
|
+
#
|
134
|
+
# See spec/api_spec.rb for usage examples
|
135
|
+
def update_customer_shipping_profile(request)
|
136
|
+
make_request(request,UpdateCustomerShippingAddressResponse,Type::API_UPDATE_CUSTOMER_SHIPPING_PROFILE)
|
137
|
+
end
|
138
|
+
|
139
|
+
# This request enables you to delete a customer shipping profile
|
140
|
+
#
|
141
|
+
# See spec/api_spec.rb for usage examples
|
142
|
+
def delete_customer_shipping_profile(request)
|
143
|
+
make_request(request,DeleteCustomerShippingAddressResponse,Type::API_DELETE_CUSTOMER_SHIPPING_PROFILE)
|
144
|
+
end
|
145
|
+
|
146
|
+
|
147
|
+
# This request enables you to create a customer profile, payment profile,
|
148
|
+
# and shipping profile from an existing successful transaction.
|
149
|
+
# NOTE: Tokenized transactions (e.g. Apple Pay), or PayPal should not be used to
|
150
|
+
# create payment profiles.
|
151
|
+
#
|
152
|
+
# See spec/api_spec.rb for usage examples
|
153
|
+
def create_customer_profile_from_transaction(request)
|
154
|
+
make_request(request,CreateProfileResponse,Type::API_CREATE_CUSTOMER_PROFILE_FROM_TRANSACTION)
|
155
|
+
end
|
156
|
+
|
157
|
+
# This request enables you to decrypt a payment data blob.
|
158
|
+
#
|
159
|
+
# See spec/api_spec.rb for usage examples
|
160
|
+
def decrypt_payment_data(request)
|
161
|
+
make_request(request,DecryptPaymentDataResponse,Type::API_DECRYPT_PAYMENT_DATA)
|
162
|
+
end
|
163
|
+
|
164
|
+
# This request enables confirm authentication values
|
165
|
+
#
|
166
|
+
# See spec/api_spec.rb for usage examples
|
167
|
+
def authenticate_test_request(request)
|
168
|
+
make_request(request,AuthenticateTestResponse,Type::API_AUTHENTICATE_TEST_REQUEST)
|
169
|
+
end
|
170
|
+
|
171
|
+
# This request enables you to get batch statistics details
|
172
|
+
#
|
173
|
+
# See spec/api_spec.rb for usage examples
|
174
|
+
def get_batch_statistics(request)
|
175
|
+
make_request(request,GetBatchStatisticsResponse,Type::API_GET_BATCH_STATISTICS)
|
176
|
+
end
|
177
|
+
|
178
|
+
# This request enables you to get batch transaction details
|
179
|
+
#
|
180
|
+
# See spec/api_spec.rb for usage examples
|
181
|
+
def get_transaction_details(request)
|
182
|
+
make_request(request,GetTransactionDetailsResponse,Type::API_GET_TRANSACTION_DETAILS)
|
183
|
+
end
|
184
|
+
|
185
|
+
# This request enables you to get batch settled transaction details
|
186
|
+
#
|
187
|
+
# See spec/api_spec.rb for usage examples
|
188
|
+
def get_settled_batch_list(request)
|
189
|
+
make_request(request,GetSettledBatchListResponse,Type::API_GET_SETTLED_BATCH_LIST)
|
190
|
+
end
|
191
|
+
|
192
|
+
# This request enables you to get batch unsettled transaction details
|
193
|
+
#
|
194
|
+
# See spec/api_spec.rb for usage examples
|
195
|
+
def get_unsettled_transaction_list(request)
|
196
|
+
make_request(request,GetUnsettledTransactionListResponse,Type::API_GET_UNSETTLED_TRANSACTION_LIST)
|
197
|
+
end
|
198
|
+
|
199
|
+
# This request enables confirm authentication values
|
200
|
+
#
|
201
|
+
# See spec/api_spec.rb for usage examples
|
202
|
+
def get_hosted_profile_page(request)
|
203
|
+
make_request(request,GetHostedProfilePageResponse,Type::API_GET_HOSTED_PROFILE_PAGE)
|
204
|
+
end
|
205
|
+
|
206
|
+
# This request enables you to update split tender group
|
207
|
+
#
|
208
|
+
# See spec/api_spec.rb for usage examples
|
209
|
+
def update_split_tender_group(request)
|
210
|
+
make_request(request,UpdateSplitTenderGroupResponse,Type::API_UPDATE_SPLIT_TENDER_GROUP)
|
211
|
+
end
|
212
|
+
|
213
|
+
# This request enables you to get customer payment profile list
|
214
|
+
#
|
215
|
+
# See spec/api_spec.rb for usage examples
|
216
|
+
def get_customer_payment_profile_list(request)
|
217
|
+
make_request(request,GetCustomerPaymentProfileListResponse,Type::API_GET_CUSTOMER_PAYMENT_PROFILE_LIST)
|
218
|
+
end
|
219
|
+
|
220
|
+
# This request enables you to get ARB Subscription
|
221
|
+
#
|
222
|
+
# See spec/api_spec.rb for usage examples
|
223
|
+
def arb_get_subscription_request(request)
|
224
|
+
make_request(request,ARBGetSubscriptionResponse,Type::API_ARB_GET_SUBSCRIPTION_REQUEST)
|
225
|
+
end
|
226
|
+
|
227
|
+
# This request enables you to get transaction list
|
228
|
+
#
|
229
|
+
# See spec/api_spec.rb for usage examples
|
230
|
+
def get_transaction_list(request)
|
231
|
+
make_request(request,GetTransactionListResponse,Type::API_GET_TRANSACTION_LIST)
|
232
|
+
end
|
233
|
+
|
234
|
+
# This request enables you to validate customer payment profile
|
235
|
+
#
|
236
|
+
# See spec/api_spec.rb for usage examples
|
237
|
+
def validate_customer_payment_profile(request)
|
238
|
+
make_request(request,ValidateCustomerPaymentProfileResponse,Type::API_VALIDATE_CUSTOMER_PAYMENT_PROFILE)
|
239
|
+
end
|
240
|
+
|
241
|
+
def get_merchant_details(request)
|
242
|
+
make_request(request,GetMerchantDetailsResponse,Type::API_GET_MERCHANT_DETAILS)
|
243
|
+
end
|
244
|
+
|
245
|
+
def get_hosted_payment_page(request)
|
246
|
+
make_request(request,GetHostedPaymentPageResponse,Type::API_GET_HOSTED_PAYMENT_PAGE)
|
247
|
+
end
|
248
|
+
|
249
|
+
def update_held_transaction(request)
|
250
|
+
make_request(request,UpdateHeldTransactionResponse,Type::API_UDPATE_HELD_TRANSACTION)
|
251
|
+
end
|
252
|
+
|
253
|
+
def get_transaction_list_for_customer(request)
|
254
|
+
make_request(request,GetTransactionListResponse,Type::API_GET_TRANSACTION_LIST_FOR_CUSTOMER)
|
255
|
+
end
|
256
|
+
|
257
|
+
end
|
258
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module AuthorizeNet::ARB
|
2
|
+
module Fields
|
3
|
+
EntityDescription = Struct.new(:node_structure, :entity_class, :arg_mapping)
|
4
|
+
|
5
|
+
SUBSCRIPTION_DETAIL_ENTITY_DESCRIPTION = EntityDescription.new(
|
6
|
+
[
|
7
|
+
{:id => :id},
|
8
|
+
{:name => :name},
|
9
|
+
{:status => :status},
|
10
|
+
{:createTimeStampUTC => :create_time_stamp_utc},
|
11
|
+
{:firstName => :first_name},
|
12
|
+
{:lastName => :last_name},
|
13
|
+
{:totalOccurrences => :total_occurrences},
|
14
|
+
{:pastOccurrences => :past_occurrences},
|
15
|
+
{:paymentMethod => :payment_method},
|
16
|
+
{:accountNumber => :account_number},
|
17
|
+
{:invoice => :invoice},
|
18
|
+
{:amount => :amount},
|
19
|
+
{:currencyId => :currency_id}
|
20
|
+
],
|
21
|
+
AuthorizeNet::ARB::SubscriptionDetail
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module AuthorizeNet::ARB
|
2
|
+
|
3
|
+
class Paging
|
4
|
+
|
5
|
+
# Models Paging
|
6
|
+
include AuthorizeNet::Model
|
7
|
+
|
8
|
+
attr_accessor :offset,:limit
|
9
|
+
|
10
|
+
# Initializes Paging object.
|
11
|
+
#
|
12
|
+
# Typical usage:
|
13
|
+
# paging = AuthorizeNet::ARB::Paging.new(1,1000)
|
14
|
+
#
|
15
|
+
# Valid values for offset: 1 to 100000
|
16
|
+
# Valid values for limit: 1 to 1000
|
17
|
+
#
|
18
|
+
def initialize(offset,limit)
|
19
|
+
@offset = offset
|
20
|
+
@limit = limit
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_hash
|
24
|
+
hash = {
|
25
|
+
:offset => @offset,
|
26
|
+
:limit => @limit
|
27
|
+
}
|
28
|
+
hash.delete_if {|k, v| v.nil?}
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module AuthorizeNet::ARB
|
2
|
+
|
3
|
+
# The ARB response class.
|
4
|
+
class Response < AuthorizeNet::XmlResponse
|
5
|
+
|
6
|
+
# Constructs a new response object from a +raw_response. You don't typically
|
7
|
+
# construct this object yourself, as AuthorizeNet::ARB::Transaction will
|
8
|
+
# build one for you when it makes the request to the gateway.
|
9
|
+
def initialize(raw_response, transaction)
|
10
|
+
super
|
11
|
+
unless connection_failure?
|
12
|
+
begin
|
13
|
+
@subscription_id = node_content_unless_nil(@root.at_css('subscriptionId'))
|
14
|
+
@subscription_status = node_content_unless_nil(@root.at_css('Status'))
|
15
|
+
rescue
|
16
|
+
@raw_response = $!
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Returns the subscriptionId from the response if there is one. Otherwise returns nil.
|
22
|
+
def subscription_id
|
23
|
+
@subscription_id
|
24
|
+
end
|
25
|
+
|
26
|
+
# Returns the status of the Subscription from the response if there is one. Otherwise returns nil. This value
|
27
|
+
# is only returned in response to a get_status transaction.
|
28
|
+
def subscription_status
|
29
|
+
@subscription_status
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module AuthorizeNet::ARB
|
2
|
+
|
3
|
+
class Sorting
|
4
|
+
|
5
|
+
# Models Sorting
|
6
|
+
include AuthorizeNet::Model
|
7
|
+
|
8
|
+
attr_accessor :order_by, :order_descending
|
9
|
+
|
10
|
+
# Initializes Sorting object.
|
11
|
+
#
|
12
|
+
# Typical usage:
|
13
|
+
# sorting = AuthorizeNet::ARB::Sorting.new('name',true)
|
14
|
+
#
|
15
|
+
# Valid values for order_by values of the AuthorizeNet::ARB::Sorting:
|
16
|
+
# id
|
17
|
+
# name
|
18
|
+
# status
|
19
|
+
# createTimeStampUTC
|
20
|
+
# lastName
|
21
|
+
# firstName
|
22
|
+
# accountNumber
|
23
|
+
# amount
|
24
|
+
# pastOccurrences
|
25
|
+
#
|
26
|
+
# Valid values for order_descending: true, false, 1, 0
|
27
|
+
#
|
28
|
+
def initialize(order_by, order_descending)
|
29
|
+
@order_by = order_by
|
30
|
+
@order_descending = order_descending
|
31
|
+
end
|
32
|
+
|
33
|
+
def to_hash
|
34
|
+
hash = {
|
35
|
+
:order_by => @order_by,
|
36
|
+
:order_descending => @order_descending
|
37
|
+
}
|
38
|
+
hash.delete_if {|k, v| v.nil?}
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module AuthorizeNet::ARB
|
2
|
+
|
3
|
+
# Models an ARB subscription.
|
4
|
+
class Subscription
|
5
|
+
|
6
|
+
# Use this constant for the value of total_occurrences to get a subscription with no end.
|
7
|
+
UNLIMITED_OCCURRENCES = 9999
|
8
|
+
|
9
|
+
# Constants for the various interval units supported by the ARB API.
|
10
|
+
module IntervalUnits
|
11
|
+
MONTH = 'months'
|
12
|
+
DAY = 'days'
|
13
|
+
end
|
14
|
+
|
15
|
+
# Constants for the various statuses a subscription can have. These are returned by the get_status call.
|
16
|
+
module Status
|
17
|
+
ACTIVE = 'active'
|
18
|
+
EXPIRED = 'expired'
|
19
|
+
SUSPENDED = 'suspended'
|
20
|
+
CANCELED = 'canceled'
|
21
|
+
TERMINATED = 'terminated'
|
22
|
+
end
|
23
|
+
|
24
|
+
include AuthorizeNet::Model
|
25
|
+
|
26
|
+
attr_accessor :name, :length, :unit, :start_date, :total_occurrences, :trial_occurrences, :amount, :trial_amount, :invoice_number, :description, :subscription_id, :credit_card, :billing_address, :shipping_address, :customer
|
27
|
+
|
28
|
+
# Override the total_occurrences setter to provide support for :unlimited shortcut.
|
29
|
+
def total_occurrences=(new_total_occurrences) #:nodoc:
|
30
|
+
if new_total_occurrences == :unlimited
|
31
|
+
@total_occurrences = UNLIMITED_OCCURRENCES
|
32
|
+
else
|
33
|
+
@total_occurrences = new_total_occurrences
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Override the unit setter to provide support for :day, :days, :month, :months shortcut. Do not document this method in rdoc.
|
38
|
+
def unit=(new_unit) #:nodoc:
|
39
|
+
case new_unit
|
40
|
+
when :day, :days
|
41
|
+
@unit = IntervalUnits::DAY
|
42
|
+
when :month, :months
|
43
|
+
@unit = IntervalUnits::MONTH
|
44
|
+
else
|
45
|
+
@unit = new_unit
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def to_hash
|
50
|
+
hash = {
|
51
|
+
:subscription_name => @name,
|
52
|
+
:subscription_length => @length,
|
53
|
+
:subscription_unit => @unit,
|
54
|
+
:subscription_start_date => @start_date,
|
55
|
+
:subscription_total_occurrences => @total_occurrences,
|
56
|
+
:subscription_trial_occurrences => @trial_occurrences,
|
57
|
+
:subscription_amount => @amount,
|
58
|
+
:subscription_trial_amount => @trial_amount,
|
59
|
+
:invoice_num => @invoice_number,
|
60
|
+
:description => @description,
|
61
|
+
:subscription_id => @subscription_id
|
62
|
+
}
|
63
|
+
hash.merge!(@credit_card.to_hash) unless @credit_card.nil?
|
64
|
+
hash.merge!(@billing_address.to_hash) unless @billing_address.nil?
|
65
|
+
hash.merge!(@shipping_address.to_hash) unless @shipping_address.nil?
|
66
|
+
hash.merge!(@customer.to_hash) unless @customer.nil?
|
67
|
+
hash.delete_if {|k, v| v.nil?}
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module AuthorizeNet::ARB
|
2
|
+
|
3
|
+
# Models Subscription Detail.
|
4
|
+
class SubscriptionDetail
|
5
|
+
|
6
|
+
include AuthorizeNet::Model
|
7
|
+
|
8
|
+
attr_accessor :id, :name, :status, :create_time_stamp_utc, :first_name,
|
9
|
+
:last_name, :total_occurrences, :past_occurrences,
|
10
|
+
:payment_method, :account_number, :invoice, :amount, :currency_id
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module AuthorizeNet::ARB
|
2
|
+
|
3
|
+
class SubscriptionListResponse < AuthorizeNet::XmlResponse
|
4
|
+
# Constructs a new response object from a +raw_response. You don't typically
|
5
|
+
# construct this object yourself, as AuthorizeNet::ARB::Transaction will
|
6
|
+
# build one for you when it makes the request to the gateway.
|
7
|
+
def initialize(raw_response, transaction)
|
8
|
+
super
|
9
|
+
unless connection_failure?
|
10
|
+
begin
|
11
|
+
@subscription_details = @root.at_css('subscriptionDetails')
|
12
|
+
@subscription_detail = @root.at_css('subscriptionDetail')
|
13
|
+
@total_num_in_resultset = node_content_unless_nil(@root.at_css('totalNumInResultSet'))
|
14
|
+
|
15
|
+
rescue
|
16
|
+
@raw_response = $!
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Returns total number of subscriptions matching the search criteria
|
22
|
+
def total_num_in_resultset
|
23
|
+
@total_num_in_resultset
|
24
|
+
end
|
25
|
+
|
26
|
+
# Returns an Array of SubscriptionDetail objects built from the entities returned in the response. Returns nil if no subscriptions were returned.
|
27
|
+
def subscription_details
|
28
|
+
unless @subscription_details.nil?
|
29
|
+
subscription_details = []
|
30
|
+
@subscription_details.element_children.each do |child|
|
31
|
+
unless child.nil?
|
32
|
+
subscription_detail = build_entity(child, Fields::SUBSCRIPTION_DETAIL_ENTITY_DESCRIPTION)
|
33
|
+
|
34
|
+
subscription_details <<= subscription_detail
|
35
|
+
end
|
36
|
+
end
|
37
|
+
return subscription_details unless subscription_details.length == 0
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|