authorizenet 1.9.4 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/app/helpers/authorize_net_helper.rb +2 -3
- data/lib/authorize_net.rb +11 -56
- data/lib/authorize_net/api/LogHelper.rb +97 -0
- data/lib/authorize_net/api/SensitiveDataFilter.rb +92 -0
- data/lib/authorize_net/api/api_transaction.rb +95 -90
- data/lib/authorize_net/api/constants.yml +1 -1
- data/lib/authorize_net/api/schema.rb +1353 -994
- data/lib/authorize_net/api/transaction.rb +104 -102
- data/lib/authorize_net/authorize_net.rb +20 -27
- data/lib/authorize_net/response.rb +9 -15
- data/lib/authorize_net/transaction.rb +18 -26
- data/lib/authorize_net/xml_response.rb +36 -54
- data/lib/authorize_net/xml_transaction.rb +115 -134
- metadata +59 -73
- data/lib/authorize_net/addresses/address.rb +0 -29
- data/lib/authorize_net/addresses/shipping_address.rb +0 -26
- data/lib/authorize_net/aim/response.rb +0 -131
- data/lib/authorize_net/aim/transaction.rb +0 -190
- data/lib/authorize_net/arb/fields.rb +0 -24
- data/lib/authorize_net/arb/paging.rb +0 -33
- data/lib/authorize_net/arb/response.rb +0 -34
- data/lib/authorize_net/arb/sorting.rb +0 -43
- data/lib/authorize_net/arb/subscription.rb +0 -72
- data/lib/authorize_net/arb/subscription_detail.rb +0 -14
- data/lib/authorize_net/arb/subscription_list_response.rb +0 -43
- data/lib/authorize_net/arb/transaction.rb +0 -177
- data/lib/authorize_net/cim/customer_profile.rb +0 -19
- data/lib/authorize_net/cim/payment_profile.rb +0 -37
- data/lib/authorize_net/cim/response.rb +0 -116
- data/lib/authorize_net/cim/transaction.rb +0 -727
- data/lib/authorize_net/customer.rb +0 -27
- data/lib/authorize_net/email_receipt.rb +0 -24
- data/lib/authorize_net/fields.rb +0 -779
- data/lib/authorize_net/key_value_response.rb +0 -117
- data/lib/authorize_net/key_value_transaction.rb +0 -291
- data/lib/authorize_net/line_item.rb +0 -25
- data/lib/authorize_net/order.rb +0 -42
- data/lib/authorize_net/payment_methods/credit_card.rb +0 -62
- data/lib/authorize_net/payment_methods/echeck.rb +0 -72
- data/lib/authorize_net/reporting/batch.rb +0 -19
- data/lib/authorize_net/reporting/batch_statistics.rb +0 -19
- data/lib/authorize_net/reporting/fds_filter.rb +0 -11
- data/lib/authorize_net/reporting/response.rb +0 -163
- data/lib/authorize_net/reporting/returned_item.rb +0 -46
- data/lib/authorize_net/reporting/transaction.rb +0 -133
- data/lib/authorize_net/reporting/transaction_details.rb +0 -25
- data/lib/authorize_net/sim/hosted_payment_form.rb +0 -38
- data/lib/authorize_net/sim/hosted_receipt_page.rb +0 -37
- data/lib/authorize_net/sim/response.rb +0 -142
- data/lib/authorize_net/sim/transaction.rb +0 -138
- data/lib/generators/authorize_net/direct_post/direct_post_generator.rb +0 -53
- data/lib/generators/authorize_net/direct_post/templates/README-AuthorizeNet +0 -49
- data/lib/generators/authorize_net/direct_post/templates/config.yml.erb +0 -8
- data/lib/generators/authorize_net/direct_post/templates/config.yml.rails3.erb +0 -8
- data/lib/generators/authorize_net/direct_post/templates/controller.rb.erb +0 -31
- data/lib/generators/authorize_net/direct_post/templates/initializer.rb +0 -4
- data/lib/generators/authorize_net/direct_post/templates/layout.erb +0 -18
- data/lib/generators/authorize_net/direct_post/templates/payment.erb +0 -10
- data/lib/generators/authorize_net/direct_post/templates/payment.rails3.erb +0 -10
- data/lib/generators/authorize_net/direct_post/templates/receipt.erb +0 -1
- data/lib/generators/authorize_net/direct_post/templates/relay_response.erb +0 -1
- data/lib/generators/authorize_net/sim/sim_generator.rb +0 -47
- data/lib/generators/authorize_net/sim/templates/README-AuthorizeNet +0 -52
- data/lib/generators/authorize_net/sim/templates/config.yml.erb +0 -8
- data/lib/generators/authorize_net/sim/templates/config.yml.rails3.erb +0 -8
- data/lib/generators/authorize_net/sim/templates/controller.rb.erb +0 -21
- data/lib/generators/authorize_net/sim/templates/initializer.rb +0 -4
- data/lib/generators/authorize_net/sim/templates/layout.erb +0 -18
- data/lib/generators/authorize_net/sim/templates/payment.erb +0 -6
- data/lib/generators/authorize_net/sim/templates/payment.rails3.erb +0 -6
- data/lib/generators/authorize_net/sim/templates/thank_you.erb +0 -1
- data/lib/generators/generator_extensions.rb +0 -75
@@ -1,24 +0,0 @@
|
|
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
|
@@ -1,33 +0,0 @@
|
|
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
|
@@ -1,34 +0,0 @@
|
|
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
|
@@ -1,43 +0,0 @@
|
|
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
|
@@ -1,72 +0,0 @@
|
|
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
|
@@ -1,14 +0,0 @@
|
|
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
|
@@ -1,43 +0,0 @@
|
|
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
|
@@ -1,177 +0,0 @@
|
|
1
|
-
module AuthorizeNet::ARB
|
2
|
-
|
3
|
-
# The ARB transaction class.
|
4
|
-
class Transaction < AuthorizeNet::XmlTransaction
|
5
|
-
|
6
|
-
include AuthorizeNet::ARB::Fields
|
7
|
-
|
8
|
-
# The default options for the constructor.
|
9
|
-
@@option_defaults = {
|
10
|
-
:gateway => :production,
|
11
|
-
:verify_ssl => true,
|
12
|
-
:reference_id => nil
|
13
|
-
}
|
14
|
-
|
15
|
-
# Fields to convert to/from booleans.
|
16
|
-
@@boolean_fields = []
|
17
|
-
|
18
|
-
# Fields to convert to/from BigDecimal.
|
19
|
-
@@decimal_fields = [:amount, :trial_amount]
|
20
|
-
|
21
|
-
# Fields to convert to/from Date.
|
22
|
-
@@date_fields = [:subscription_start_date]
|
23
|
-
|
24
|
-
# The class to wrap our response in.
|
25
|
-
@response_class = AuthorizeNet::ARB::Response
|
26
|
-
|
27
|
-
# Constructs an ARB transaction. You can use the new ARB transaction object
|
28
|
-
# to issue a request to the payment gateway and parse the response into a new
|
29
|
-
# AuthorizeNet::ARB::Response object.
|
30
|
-
#
|
31
|
-
# +api_login_id+:: Your API login ID, as a string.
|
32
|
-
# +api_transaction_key+:: Your API transaction key, as a string.
|
33
|
-
# +options+:: A hash of options. See below for values.
|
34
|
-
#
|
35
|
-
# Options
|
36
|
-
# +gateway+:: The gateway to submit the transaction to. Can be a URL string, an AuthorizeNet::ARB::Transaction::Gateway constant, or one of the convenience symbols :sandbox, :test, :production, or :live (:test is an alias for :sandbox, and :live is an alias for :production).
|
37
|
-
# +verify_ssl+:: A boolean indicating if the SSL certificate of the +gateway+ should be verified. Defaults to true.
|
38
|
-
# +reference_id+:: A string that can be used to identify a particular transaction with its response. Will be echo'd in the response, only if it was provided in the transaction. Defaults to nil.
|
39
|
-
#
|
40
|
-
def initialize(api_login_id, api_transaction_key, options = {})
|
41
|
-
super
|
42
|
-
end
|
43
|
-
|
44
|
-
# Sets up and submits a start of subscription (ARBCreateSubscriptionRequest) transaction. Returns a response object. If the transaction
|
45
|
-
# has already been run, it will return nil.
|
46
|
-
#
|
47
|
-
# +subscription+:: An instance of AuthorizeNet::ARB::Subscription describing the recurring payment you would like to create.
|
48
|
-
#
|
49
|
-
#
|
50
|
-
# Typical usage:
|
51
|
-
#
|
52
|
-
# subscription = AuthorizeNet::ARB::Subscription.new(
|
53
|
-
# :name => "Monthly Gift Basket",
|
54
|
-
# :length => 1,
|
55
|
-
# :unit => :month,
|
56
|
-
# :start_date => Date.today,
|
57
|
-
# :total_occurrences => :unlimited,
|
58
|
-
# :amount => 100.00,
|
59
|
-
# :invoice_number => '1234567',
|
60
|
-
# :description => "John Doe's Monthly Gift Basket",
|
61
|
-
# :credit_card => AuthorizeNet::CreditCard.new('4111111111111111', '1120'),
|
62
|
-
# :billing_address => AuthorizeNet::Address.new(:first_name => 'John', :last_name => 'Doe')
|
63
|
-
# )
|
64
|
-
# response = transaction.create(subscription)
|
65
|
-
#
|
66
|
-
def create(subscription)
|
67
|
-
@type = Type::ARB_CREATE
|
68
|
-
set_fields(subscription.to_hash)
|
69
|
-
run
|
70
|
-
end
|
71
|
-
|
72
|
-
# Sets up and submits a subscription update (ARBUpdateSubscriptionRequest) transaction. Returns a response object. If the transaction
|
73
|
-
# has already been run, it will return nil.
|
74
|
-
#
|
75
|
-
# +subscription+:: An instance of AuthorizeNet::ARB::Subscription describing the changes to make. It must have a value for subscription_id so that the API knows what subscription to update. Note that some information (intervals, start dates, etc) can't be changed. See the ARB guide for more details.
|
76
|
-
#
|
77
|
-
#
|
78
|
-
# Typical usage:
|
79
|
-
#
|
80
|
-
# subscription = AuthorizeNet::ARB::Subscription.new(
|
81
|
-
# :billing_address => AuthorizeNet::Address.new(:first_name => 'Jane', :last_name => 'Doe'),
|
82
|
-
# :subscription_id => '123456'
|
83
|
-
# )
|
84
|
-
# response = transaction.update(subscription)
|
85
|
-
#
|
86
|
-
def update(subscription)
|
87
|
-
@type = Type::ARB_UPDATE
|
88
|
-
set_fields(subscription.to_hash)
|
89
|
-
run
|
90
|
-
end
|
91
|
-
|
92
|
-
# Sets up and submits a subscription status query (ARBGetSubscriptionStatusRequest) transaction. Returns a response object (which contains the subscription status). If the transaction
|
93
|
-
# has already been run, it will return nil.
|
94
|
-
#
|
95
|
-
# +subscription_id+:: Either the subscription id of the subscription to get the status of as a string, or a Subscription instance with a value for subscription_id set on it.
|
96
|
-
#
|
97
|
-
#
|
98
|
-
# Typical usage:
|
99
|
-
#
|
100
|
-
# response = transaction.get_status('123456')
|
101
|
-
# response.subscription_status # A value from AuthorizeNet::ARB::Subscription::Status
|
102
|
-
#
|
103
|
-
def get_status(subscription_id)
|
104
|
-
@type = Type::ARB_GET_STATUS
|
105
|
-
handle_subscription_id(subscription_id)
|
106
|
-
run
|
107
|
-
end
|
108
|
-
|
109
|
-
# Sets up and submits a subscription list query (ARBGetSubscriptionListRequest). Returns a response object
|
110
|
-
# which contains the list of subscription details and the total number of subscriptions matching the search
|
111
|
-
# criteria. Sorting and Paging are optional parameters.
|
112
|
-
#
|
113
|
-
# Valid values for search type parameter:
|
114
|
-
# cardExpiringThisMonth
|
115
|
-
# subscriptionActive
|
116
|
-
# subscriptionExpiringThisMonth
|
117
|
-
# subscriptionInactive
|
118
|
-
#
|
119
|
-
# Typical usage:
|
120
|
-
#
|
121
|
-
# sorting = AuthorizeNet::ARB::Sorting.new('name',true)
|
122
|
-
# paging = AuthorizeNet::ARB::Paging.new(1,1000)
|
123
|
-
# response = transaction.get_subscription_list('subscriptionActive',sorting,paging)
|
124
|
-
#
|
125
|
-
def get_subscription_list(search_type, sorting = nil, paging = nil)
|
126
|
-
unless search_type.nil?
|
127
|
-
self.class.instance_variable_set(:@response_class,SubscriptionListResponse)
|
128
|
-
@type = Type::ARB_GET_SUBSCRIPTION_LIST
|
129
|
-
set_fields(:search_type => search_type.to_s)
|
130
|
-
unless sorting.nil?
|
131
|
-
set_fields(sorting.to_hash)
|
132
|
-
end
|
133
|
-
unless paging.nil?
|
134
|
-
set_fields(paging.to_hash)
|
135
|
-
end
|
136
|
-
run
|
137
|
-
end
|
138
|
-
return response
|
139
|
-
end
|
140
|
-
|
141
|
-
# Sets up and submits a subscription cancelation (ARBCancelSubscriptionRequest) transaction. Returns a response object. If the transaction
|
142
|
-
# has already been run, it will return nil.
|
143
|
-
#
|
144
|
-
# +subscription_id+:: Either the subscription id of the subscription to get the status of as a string, or a Subscription instance with a value for subscription_id set on it.
|
145
|
-
#
|
146
|
-
#
|
147
|
-
# Typical usage:
|
148
|
-
#
|
149
|
-
# response = transaction.cancel('123456')
|
150
|
-
#
|
151
|
-
def cancel(subscription_id)
|
152
|
-
@type = Type::ARB_CANCEL
|
153
|
-
handle_subscription_id(subscription_id)
|
154
|
-
run
|
155
|
-
end
|
156
|
-
|
157
|
-
#:enddoc:
|
158
|
-
protected
|
159
|
-
|
160
|
-
# Internal method to handle multiple types of subscription id arguments.
|
161
|
-
def handle_subscription_id(subscription_id)
|
162
|
-
case subscription_id
|
163
|
-
when Subscription
|
164
|
-
set_fields(:subscription_id => subscription_id.subscription_id.to_s)
|
165
|
-
else
|
166
|
-
set_fields(:subscription_id => subscription_id.to_s)
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
# An internal method that builds the POST body, submits it to the gateway, and constructs a Response object with the response.
|
171
|
-
def make_request
|
172
|
-
set_fields(:reference_id => @reference_id)
|
173
|
-
super
|
174
|
-
end
|
175
|
-
|
176
|
-
end
|
177
|
-
end
|