authorizenet_blaq 1.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +7 -0
  2. data/lib/app/helpers/authorize_net_helper.rb +24 -0
  3. data/lib/authorize_net/addresses/address.rb +29 -0
  4. data/lib/authorize_net/addresses/shipping_address.rb +26 -0
  5. data/lib/authorize_net/aim/response.rb +131 -0
  6. data/lib/authorize_net/aim/transaction.rb +190 -0
  7. data/lib/authorize_net/api/api_transaction.rb +123 -0
  8. data/lib/authorize_net/api/constants.yml +1 -0
  9. data/lib/authorize_net/api/schema.rb +4985 -0
  10. data/lib/authorize_net/api/transaction.rb +258 -0
  11. data/lib/authorize_net/arb/fields.rb +24 -0
  12. data/lib/authorize_net/arb/paging.rb +33 -0
  13. data/lib/authorize_net/arb/response.rb +34 -0
  14. data/lib/authorize_net/arb/sorting.rb +43 -0
  15. data/lib/authorize_net/arb/subscription.rb +72 -0
  16. data/lib/authorize_net/arb/subscription_detail.rb +14 -0
  17. data/lib/authorize_net/arb/subscription_list_response.rb +43 -0
  18. data/lib/authorize_net/arb/transaction.rb +177 -0
  19. data/lib/authorize_net/authorize_net.rb +154 -0
  20. data/lib/authorize_net/cim/customer_profile.rb +19 -0
  21. data/lib/authorize_net/cim/payment_profile.rb +37 -0
  22. data/lib/authorize_net/cim/response.rb +116 -0
  23. data/lib/authorize_net/cim/transaction.rb +727 -0
  24. data/lib/authorize_net/customer.rb +27 -0
  25. data/lib/authorize_net/email_receipt.rb +24 -0
  26. data/lib/authorize_net/fields.rb +779 -0
  27. data/lib/authorize_net/key_value_response.rb +117 -0
  28. data/lib/authorize_net/key_value_transaction.rb +291 -0
  29. data/lib/authorize_net/line_item.rb +25 -0
  30. data/lib/authorize_net/order.rb +42 -0
  31. data/lib/authorize_net/payment_methods/credit_card.rb +62 -0
  32. data/lib/authorize_net/payment_methods/echeck.rb +72 -0
  33. data/lib/authorize_net/reporting/batch.rb +19 -0
  34. data/lib/authorize_net/reporting/batch_statistics.rb +19 -0
  35. data/lib/authorize_net/reporting/fds_filter.rb +11 -0
  36. data/lib/authorize_net/reporting/response.rb +163 -0
  37. data/lib/authorize_net/reporting/returned_item.rb +46 -0
  38. data/lib/authorize_net/reporting/transaction.rb +133 -0
  39. data/lib/authorize_net/reporting/transaction_details.rb +25 -0
  40. data/lib/authorize_net/response.rb +27 -0
  41. data/lib/authorize_net/sim/hosted_payment_form.rb +38 -0
  42. data/lib/authorize_net/sim/hosted_receipt_page.rb +37 -0
  43. data/lib/authorize_net/sim/response.rb +142 -0
  44. data/lib/authorize_net/sim/transaction.rb +138 -0
  45. data/lib/authorize_net/transaction.rb +66 -0
  46. data/lib/authorize_net/xml_response.rb +172 -0
  47. data/lib/authorize_net/xml_transaction.rb +298 -0
  48. data/lib/authorize_net.rb +107 -0
  49. data/lib/authorizenet_blaq.rb +4 -0
  50. data/lib/generators/authorize_net/direct_post/direct_post_generator.rb +53 -0
  51. data/lib/generators/authorize_net/direct_post/templates/README-AuthorizeNet +49 -0
  52. data/lib/generators/authorize_net/direct_post/templates/config.yml.erb +8 -0
  53. data/lib/generators/authorize_net/direct_post/templates/config.yml.rails3.erb +8 -0
  54. data/lib/generators/authorize_net/direct_post/templates/controller.rb.erb +31 -0
  55. data/lib/generators/authorize_net/direct_post/templates/initializer.rb +4 -0
  56. data/lib/generators/authorize_net/direct_post/templates/layout.erb +18 -0
  57. data/lib/generators/authorize_net/direct_post/templates/payment.erb +10 -0
  58. data/lib/generators/authorize_net/direct_post/templates/payment.rails3.erb +10 -0
  59. data/lib/generators/authorize_net/direct_post/templates/receipt.erb +1 -0
  60. data/lib/generators/authorize_net/direct_post/templates/relay_response.erb +1 -0
  61. data/lib/generators/authorize_net/sim/sim_generator.rb +47 -0
  62. data/lib/generators/authorize_net/sim/templates/README-AuthorizeNet +52 -0
  63. data/lib/generators/authorize_net/sim/templates/config.yml.erb +8 -0
  64. data/lib/generators/authorize_net/sim/templates/config.yml.rails3.erb +8 -0
  65. data/lib/generators/authorize_net/sim/templates/controller.rb.erb +21 -0
  66. data/lib/generators/authorize_net/sim/templates/initializer.rb +4 -0
  67. data/lib/generators/authorize_net/sim/templates/layout.erb +18 -0
  68. data/lib/generators/authorize_net/sim/templates/payment.erb +6 -0
  69. data/lib/generators/authorize_net/sim/templates/payment.rails3.erb +6 -0
  70. data/lib/generators/authorize_net/sim/templates/thank_you.erb +1 -0
  71. data/lib/generators/generator_extensions.rb +75 -0
  72. metadata +196 -0
@@ -0,0 +1,177 @@
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
@@ -0,0 +1,154 @@
1
+ # :title: Authorize.Net Ruby SDK
2
+ # The core AuthoizeNet module. The entire SDK is name-spaced inside of this module.
3
+ module AuthorizeNet
4
+
5
+ # Some type conversion routines that will be injected into our Transaction/Response
6
+ # classes.
7
+ module TypeConversions
8
+
9
+ API_FIELD_PREFIX = 'x_'
10
+
11
+ # Coverts a value received from Authorize.Net into a boolean if possible. This
12
+ # is designed to handle the wide range of boolean formats that Authorize.Net uses.
13
+ def value_to_boolean(value)
14
+ case value
15
+ when "TRUE", "T", "YES", "Y", "1", "true"
16
+ true
17
+ when "FALSE", "F", "NO", "N", "0", "false"
18
+ false
19
+ else
20
+ value
21
+ end
22
+ end
23
+
24
+ # Converts a boolean into an Authorize.Net boolean value string. This
25
+ # is designed to handle the wide range of boolean formats that Authorize.Net
26
+ # uses. If bool isn't a Boolean, its converted to a string and passed along.
27
+ def boolean_to_value(bool)
28
+ case bool
29
+ when TrueClass, FalseClass
30
+ bool ? 'TRUE' : 'FALSE'
31
+ else
32
+ bool.to_s
33
+ end
34
+ end
35
+
36
+ # Coverts a value received from Authorize.Net into a BigDecimal.
37
+ def value_to_decimal(value)
38
+ BigDecimal.new(value)
39
+ end
40
+
41
+ # Converts a BigDecimal (or Float) into an Authorize.Net float value string. If float isn't
42
+ # a BigDecimal (or Float), its converted to a string and passed along.
43
+ def decimal_to_value(float)
44
+ case float
45
+ when Float
46
+ "%0.2f" % float
47
+ when BigDecimal
48
+ float.truncate(2).to_s('F')
49
+ else
50
+ float.to_s
51
+ end
52
+ end
53
+
54
+ # Coverts a value received from Authorize.Net into a Date.
55
+ def value_to_date(value)
56
+ Date.strptime(value, '%Y-%m-%d')
57
+ end
58
+
59
+ # Converts a Date (or DateTime, or Time) into an Authorize.Net date value string. If date isn't
60
+ # a Date (or DateTime, or Time), its converted to a string and passed along.
61
+ def date_to_value(date)
62
+ case date
63
+ when Date, DateTime, Time
64
+ date.strftime('%Y-%m-%d')
65
+ else
66
+ date.to_s
67
+ end
68
+ end
69
+
70
+ # Coverts a value received from Authorize.Net into a DateTime.
71
+ def value_to_datetime(value)
72
+ DateTime.strptime(value, '%Y-%m-%dT%H:%M:%S')
73
+ end
74
+
75
+ # Converts a Date (or DateTime, or Time) into an Authorize.Net datetime value string. If date isn't
76
+ # a Date (or DateTime, or Time), its converted to a string and passed along.
77
+ def datetime_to_value(datetime)
78
+ case datetime
79
+ when Date, DateTime
80
+ datetime.new_offset(0).strftime('%Y-%m-%dT%H:%M:%SZ')
81
+ when Time
82
+ datetime.utc.strftime('%Y-%m-%dT%H:%M:%SZ')
83
+ else
84
+ datetime.to_s
85
+ end
86
+ end
87
+
88
+ # Coverts a value received from Authorize.Net into an Integer.
89
+ def value_to_integer(value)
90
+ value.to_s.to_i
91
+ end
92
+
93
+ # Coverts an Integer into an Authorize.Net integer string.
94
+ def integer_to_value(int)
95
+ int.to_s
96
+ end
97
+
98
+ # Converts a key value pair into a HTTP POST parameter. The key is prefixed
99
+ # with key_prefix when being converted to a parameter name.
100
+ def to_param(key, value, key_prefix = API_FIELD_PREFIX)
101
+ key_str = "#{key_prefix}#{key}="
102
+ if value.kind_of?(Array)
103
+ (value.collect do |v|
104
+ key_str + CGI::escape(v.to_s)
105
+ end).join('&')
106
+ else
107
+ key_str + CGI::escape(value.to_s)
108
+ end
109
+ end
110
+
111
+
112
+ # Converts an internal field name (Symbol) into an external field name (Symbol)
113
+ # that can be consumed by the Authorize.Net API.
114
+ def to_external_field(key)
115
+ (API_FIELD_PREFIX + key.to_s).to_sym
116
+ end
117
+
118
+ # Converts an external field name (Symbol) into an internal field name (Symbol). This
119
+ # is the exact inverse of to_external_field. Running to_internal_field(to_external_field(:foo))
120
+ # would return :foo back.
121
+ def to_internal_field(key)
122
+ k_str = key.to_s
123
+ k_str[API_FIELD_PREFIX.length..k_str.length].to_sym
124
+ end
125
+ end
126
+
127
+ # Provides some basic methods used by the various model classes.
128
+ module Model
129
+
130
+ # The constructor for models. Takes any of the supported attributes
131
+ # as key/value pairs.
132
+ def initialize(fields = {})
133
+ fields.each do |k, v|
134
+ method_name = (k.to_s + '=').to_sym
135
+ if self.respond_to?(method_name)
136
+ self.send(method_name, v)
137
+ end
138
+ end
139
+ end
140
+
141
+ def to_a
142
+ [self]
143
+ end
144
+
145
+ #:enddoc:
146
+ protected
147
+
148
+ def handle_multivalue_hashing(obj)
149
+ obj.to_a.collect(&:to_hash)
150
+ end
151
+
152
+ end
153
+
154
+ end
@@ -0,0 +1,19 @@
1
+ module AuthorizeNet::CIM
2
+
3
+ # Models a customer profile.
4
+ class CustomerProfile < AuthorizeNet::Customer
5
+
6
+ include AuthorizeNet::Model
7
+
8
+ attr_accessor :customer_profile_id, :payment_profiles
9
+
10
+ def to_hash
11
+ hash = super
12
+ hash.delete_if {|k, v| v.nil?}
13
+ hash[:payment_profiles] = handle_multivalue_hashing(@payment_profiles)
14
+ hash
15
+ end
16
+
17
+ end
18
+
19
+ end
@@ -0,0 +1,37 @@
1
+ module AuthorizeNet::CIM
2
+ # Models a payment profile.
3
+ class PaymentProfile
4
+
5
+ module CustomerType
6
+ INDIVIDUAL = 'individual'
7
+ BUSINESS = 'business'
8
+ end
9
+
10
+ include AuthorizeNet::Model
11
+
12
+ attr_accessor :cust_type, :billing_address, :payment_method, :customer_payment_profile_id
13
+
14
+ def cust_type=(type) #:nodoc:
15
+ case type
16
+ when :business
17
+ @cust_type = CustomerType::BUSINESS
18
+ when :individual
19
+ @cust_type = CustomerType::INDIVIDUAL
20
+ else
21
+ @cust_type = type
22
+ end
23
+ end
24
+
25
+ def to_hash
26
+ hash = {
27
+ :cust_type => @cust_type,
28
+ :customer_payment_profile_id => @customer_payment_profile_id
29
+ }
30
+ hash.delete_if {|k, v| v.nil?}
31
+ hash.merge!(@billing_address.to_hash) unless @billing_address.nil?
32
+ hash.merge!(@payment_method.to_hash) unless @payment_method.nil?
33
+ hash
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,116 @@
1
+ module AuthorizeNet::CIM
2
+
3
+ # The CIM response class.
4
+ class Response < AuthorizeNet::XmlResponse
5
+
6
+ include AuthorizeNet::CIM::Fields
7
+
8
+ # Constructs a new response object from raw_response in the context of transaction.
9
+ # You don‘t typically construct this object yourself, as AuthorizeNet::CIM::Transaction
10
+ # will build one for you when it makes the request to the gateway.
11
+ def initialize(raw_response, transaction)
12
+ super
13
+ unless connection_failure?
14
+ begin
15
+ @customer_profile_id = node_content_unless_nil(@root.at_css('customerProfileId'))
16
+ @customer_payment_profile_id = node_content_unless_nil(@root.at_css('customerPaymentProfileId'))
17
+ @customer_payment_profile_id_list = node_child_content_unless_nil(@root.at_css('customerPaymentProfileIdList'))
18
+ @customer_shipping_address_id_list = node_child_content_unless_nil(@root.at_css('customerShippingAddressIdList'))
19
+ @customer_address_id = node_content_unless_nil(@root.at_css('customerAddressId'))
20
+ @validation_direct_response_list = @root.at_css('validationDirectResponseList')
21
+ @validation_direct_response = @root.at_css('validationDirectResponse')
22
+ @direct_response = @root.at_css('directResponse')
23
+ @customer_profile_id_list = node_child_content_unless_nil(@root.at_css('ids'))
24
+ @address = @root.at_css('address')
25
+ @payment_profile = @root.at_css('paymentProfile')
26
+ @profile = @root.at_css('profile')
27
+ @token = node_content_unless_nil(@root.at_css('token'))
28
+ rescue
29
+ @raw_response = $!
30
+ end
31
+ end
32
+ end
33
+
34
+ # Returns a CustomerProfile ID if one was returned by the gateway. Returns nil otherwise.
35
+ # Note that this method will return nil if we got back a list of IDs (see profile_ids).
36
+ def profile_id
37
+ @customer_profile_id
38
+ end
39
+
40
+ # Returns a list of CustomerProfile IDs if any were returned by the gateway. Returns nil otherwise.
41
+ def profile_ids
42
+ @customer_profile_id_list
43
+ end
44
+
45
+ # Returns an Address ID if one was returned by the gateway. Returns nil otherwise.
46
+ # Note that this method will return nil if we got back a list of IDs (see address_ids).
47
+ def address_id
48
+ @customer_address_id
49
+ end
50
+
51
+ # Returns a list of Address IDs if any were returned by the gateway. Returns nil otherwise.
52
+ def address_ids
53
+ @customer_shipping_address_id_list
54
+ end
55
+
56
+ # Returns a PaymentProfile ID if one was returned by the gateway. Returns nil otherwise.
57
+ # Note that this method will return nil if we got back a list of IDs (see payment_profile_ids).
58
+ def payment_profile_id
59
+ @customer_payment_profile_id
60
+ end
61
+
62
+ # Returns a list of PaymentProfile IDs if any were returned by the gateway. Returns nil otherwise.
63
+ def payment_profile_ids
64
+ @customer_payment_profile_id_list
65
+ end
66
+
67
+ # Returns hosted profile access token when requested. Returns nil otherwise.
68
+ def token
69
+ @token
70
+ end
71
+
72
+ # Returns a validation response as an AuthorizeNet::AIM::Response object if a validation response was returned
73
+ # by the gateway. Returns nil otherwise.
74
+ # Note that this method will return nil if we got back a list of IDs (see validation_responses).
75
+ def validation_response
76
+ AuthorizeNet::AIM::Response.new(@validation_direct_response.dup, @transaction) unless @validation_direct_response.nil?
77
+ end
78
+
79
+ # Returns a list of validation response as an AuthorizeNet::AIM::Response objects if a list of validation response was returned
80
+ # by the gateway. Returns nil otherwise.
81
+ def validation_responses
82
+ unless @validation_direct_response_list.nil?
83
+ responses = []
84
+ @validation_direct_response_list.element_children.each do |child|
85
+ responses <<= AuthorizeNet::AIM::Response.new(child.dup, @transaction) unless child.nil?
86
+ end
87
+ return responses unless responses.length == 0
88
+ end
89
+ end
90
+
91
+ # Returns the direct response as an AuthorizeNet::AIM::Response object if a direct response was returned
92
+ # by the gateway. Returns nil otherwise.
93
+ def direct_response
94
+ AuthorizeNet::AIM::Response.new(@direct_response.dup, @transaction) unless @direct_response.nil?
95
+ end
96
+
97
+ # Returns a CustomerProfile built from the entity returned by the gateway. Returns nil otherwise.
98
+ def profile
99
+ build_entity(@profile, Fields::PROFILE_ENTITY_DESCRIPTION) unless @profile.nil?
100
+ end
101
+
102
+ # Returns a PaymentProfile built from the entity returned by the gateway. Returns nil otherwise.
103
+ def payment_profile
104
+ build_entity(@payment_profile, Fields::PAYMENT_PROFILE_ENTITY_DESCRIPTION) unless @payment_profile.nil?
105
+ end
106
+
107
+ # Returns an Address built from the entity returned by the gateway. Returns nil otherwise.
108
+ def address
109
+ build_entity(@address, Fields::ADDRESS_ENTITY_DESCRIPTION) unless @address.nil?
110
+ end
111
+
112
+ #:enddoc:
113
+ protected
114
+
115
+ end
116
+ end