Class: ActiveMerchant::Billing::AuthorizeNetCimGateway
- Defined in:
- lib/active_merchant/billing/gateways/authorize_net_cim.rb
Overview
Customer Information Manager (CIM)
The Authorize.Net Customer Information Manager (CIM) is an optional additional service that allows you to store sensitive payment information on Authorize.Net’s servers, simplifying payments for returning customers and recurring transactions. It can also help with Payment Card Industry (PCI) Data Security Standard compliance, since customer data is no longer stored locally.
To use the AuthorizeNetCimGateway CIM must be enabled for your account.
Information about CIM is available on the Authorize.Net website. Information about the CIM API is available at the Authorize.Net Integration Center
Login and Password
The login and password are not the username and password you use to login to the Authorize.Net Merchant Interface. Instead, you will use the API Login ID as the login and Transaction Key as the password.
How to Get Your API Login ID and Transaction Key
-
Log into the Merchant Interface
-
Select Settings from the Main Menu
-
Click on API Login ID and Transaction Key in the Security section
-
Type in the answer to the secret question configured on setup
-
Click Submit
Constant Summary collapse
- AUTHORIZE_NET_CIM_NAMESPACE =
'AnetApi/xml/v1/schema/AnetApiSchema.xsd'
- CIM_ACTIONS =
{ :create_customer_profile => 'createCustomerProfile', :create_customer_payment_profile => 'createCustomerPaymentProfile', :create_customer_shipping_address => 'createCustomerShippingAddress', :get_customer_profile => 'getCustomerProfile', :get_customer_profile_ids => 'getCustomerProfileIds', :get_customer_payment_profile => 'getCustomerPaymentProfile', :get_customer_shipping_address => 'getCustomerShippingAddress', :delete_customer_profile => 'deleteCustomerProfile', :delete_customer_payment_profile => 'deleteCustomerPaymentProfile', :delete_customer_shipping_address => 'deleteCustomerShippingAddress', :update_customer_profile => 'updateCustomerProfile', :update_customer_payment_profile => 'updateCustomerPaymentProfile', :update_customer_shipping_address => 'updateCustomerShippingAddress', :create_customer_profile_transaction => 'createCustomerProfileTransaction', :validate_customer_payment_profile => 'validateCustomerPaymentProfile' }
- CIM_TRANSACTION_TYPES =
{ :auth_capture => 'profileTransAuthCapture', :auth_only => 'profileTransAuthOnly', :capture_only => 'profileTransCaptureOnly', :prior_auth_capture => 'profileTransPriorAuthCapture', :refund => 'profileTransRefund', :void => 'profileTransVoid' }
- CIM_VALIDATION_MODES =
{ :none => 'none', :test => 'testMode', :live => 'liveMode', :old => 'oldLiveMode' }
- BANK_ACCOUNT_TYPES =
{ :checking => 'checking', :savings => 'savings', :business_checking => 'businessChecking' }
- ECHECK_TYPES =
{ :ccd => 'CCD', :ppd => 'PPD', :web => 'WEB' }
Constants inherited from Gateway
Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::CURRENCIES_WITHOUT_FRACTIONS, Gateway::DEBIT_CARDS
Instance Attribute Summary
Attributes inherited from Gateway
Instance Method Summary collapse
-
#create_customer_payment_profile(options) ⇒ Object
Creates a new customer payment profile for an existing customer profile.
-
#create_customer_profile(options) ⇒ Object
Creates a new customer profile along with any customer payment profiles and customer shipping addresses for the customer profile.
-
#create_customer_profile_transaction(options) ⇒ Object
Creates a new payment transaction from an existing customer profile.
-
#create_customer_profile_transaction_for_refund(options) ⇒ Object
Creates a new payment transaction for refund from an existing customer profile.
-
#create_customer_profile_transaction_for_void(options) ⇒ Object
Creates a new payment transaction for void from an existing customer profile.
-
#create_customer_shipping_address(options) ⇒ Object
Creates a new customer shipping address for an existing customer profile.
-
#delete_customer_payment_profile(options) ⇒ Object
Deletes a customer payment profile from an existing customer profile.
-
#delete_customer_profile(options) ⇒ Object
Deletes an existing customer profile along with all associated customer payment profiles and customer shipping addresses.
-
#delete_customer_shipping_address(options) ⇒ Object
Deletes a customer shipping address from an existing customer profile.
-
#get_customer_payment_profile(options) ⇒ Object
Retrieve a customer payment profile for an existing customer profile.
-
#get_customer_profile(options) ⇒ Object
Retrieves an existing customer profile along with all the associated customer payment profiles and customer shipping addresses.
- #get_customer_profile_ids(options = {}) ⇒ Object
-
#get_customer_shipping_address(options) ⇒ Object
Retrieve a customer shipping address for an existing customer profile.
-
#initialize(options = {}) ⇒ AuthorizeNetCimGateway
constructor
Creates a new AuthorizeNetCimGateway.
-
#update_customer_payment_profile(options) ⇒ Object
Updates a customer payment profile for an existing customer profile.
-
#update_customer_profile(options) ⇒ Object
Updates an existing customer profile.
-
#update_customer_shipping_address(options) ⇒ Object
Updates a customer shipping address for an existing customer profile.
-
#validate_customer_payment_profile(options) ⇒ Object
Verifies an existing customer payment profile by generating a test transaction.
Methods inherited from Gateway
#card_brand, card_brand, inherited, supports?, #test?
Methods included from CreditCardFormatting
Constructor Details
#initialize(options = {}) ⇒ AuthorizeNetCimGateway
Creates a new AuthorizeNetCimGateway
The gateway requires that a valid API Login ID and Transaction Key be passed in the options
hash.
Options
-
:login
– The Authorize.Net API Login ID (REQUIRED) -
:password
– The Authorize.Net Transaction Key. (REQUIRED) -
:test
–true
orfalse
. If true, perform transactions against the test server. Otherwise, perform transactions against the production server. -
:test_requests
–true
orfalse
. If true, perform transactions without the test flag. This is useful when you need to generate card declines, AVS or CVV erros. Will hold the same value as :test by default. -
:delimiter
– The delimiter used in the direct response. Default is ‘,’ (comma).
101 102 103 104 105 |
# File 'lib/active_merchant/billing/gateways/authorize_net_cim.rb', line 101 def initialize( = {}) requires!(, :login, :password) super @options[:test_requests] = test? if @options[:test_requests].nil? end |
Instance Method Details
#create_customer_payment_profile(options) ⇒ Object
Creates a new customer payment profile for an existing customer profile.
Options
-
:customer_profile_id
– The Customer Profile ID of the customer the payment profile will be added to. (REQUIRED) -
:payment_profile
– A hash containing the elements of the new payment profile (REQUIRED)
Payment Profile
-
:payment
– A hash containing information on payment. Either :credit_card or :bank_account (REQUIRED)
150 151 152 153 154 155 156 157 |
# File 'lib/active_merchant/billing/gateways/authorize_net_cim.rb', line 150 def create_customer_payment_profile() requires!(, :customer_profile_id) requires!(, :payment_profile) requires!([:payment_profile], :payment) request = build_request(:create_customer_payment_profile, ) commit(:create_customer_payment_profile, request) end |
#create_customer_profile(options) ⇒ Object
Creates a new customer profile along with any customer payment profiles and customer shipping addresses for the customer profile.
Returns a Response with the Customer Profile ID of the new customer profile in the authorization field. It is CRITICAL that you save this ID. There is no way to retrieve this through the API. You will not be able to create another Customer Profile with the same information.
Options
-
:profile
– A hash containing at least one of the CONDITIONAL profile options below (REQUIRED)
Profile
-
:email
– Email address associated with the customer profile (CONDITIONAL) -
:description
– Description of the customer or customer profile (CONDITIONAL) -
:merchant_customer_id
– Merchant assigned ID for the customer (CONDITIONAL) -
:payment_profile
– A hash containing the elements of the new payment profile (optional)
Payment Profile
-
:payment
– A hash containing information on payment. Either :credit_card or :bank_account (optional)
130 131 132 133 134 135 136 137 138 |
# File 'lib/active_merchant/billing/gateways/authorize_net_cim.rb', line 130 def create_customer_profile() requires!(, :profile) requires!([:profile], :email) unless [:profile][:merchant_customer_id] || [:profile][:description] requires!([:profile], :description) unless [:profile][:email] || [:profile][:merchant_customer_id] requires!([:profile], :merchant_customer_id) unless [:profile][:description] || [:profile][:email] request = build_request(:create_customer_profile, ) commit(:create_customer_profile, request) end |
#create_customer_profile_transaction(options) ⇒ Object
Creates a new payment transaction from an existing customer profile
This is what is used to charge a customer whose information you have stored in a Customer Profile.
Returns a Response object that contains the result of the transaction in params['direct_response']
Options
-
:transaction
– A hash containing information on the transaction that is being requested. (REQUIRED)
Transaction
-
:type
– The type of transaction. Can be either:auth_only
,:capture_only
,:auth_capture
,:prior_auth_capture
,:refund
or:void
. (REQUIRED) -
:amount
– The amount for the tranaction. Formatted with a decimal. For example “4.95” (CONDITIONAL)- :type == :void (NOT USED) - :type == :refund (OPTIONAL) - :type == (:auth_only, :capture_only, :auth_capture, :prior_auth_capture) (REQUIRED)
-
:customer_profile_id
– The Customer Profile ID of the customer to use in this transaction. (CONDITIONAL)- :type == (:void, :prior_auth_capture) (OPTIONAL) - :type == :refund (CONDITIONAL - required if masked information is not being submitted [see below]) - :type == (:auth_only, :capture_only, :auth_capture) (REQUIRED)
-
:customer_payment_profile_id
– The Customer Payment Profile ID of the Customer Payment Profile to use in this transaction. (CONDITIONAL)- :type == (:void, :prior_auth_capture) (OPTIONAL) - :type == :refund (CONDITIONAL - required if masked information is not being submitted [see below]) - :type == (:auth_only, :capture_only, :auth_capture) (REQUIRED)
-
:trans_id
– The payment gateway assigned transaction ID of the original transaction (CONDITIONAL):- :type = (:void, :refund, :prior_auth_capture) (REQUIRED) - :type = (:auth_only, :capture_only, :auth_capture) (NOT USED)
-
:card_code
– CVV/CCV code (OPTIONAL)- :type = (:void, :refund, :prior_auth_capture) (NOT USED) - :type = (:auth_only, :capture_only, :auth_capture) (OPTIONAL)
-
:customer_shipping_address_id
– Payment gateway assigned ID associated with the customer shipping address (CONDITIONAL)- :type = (:void, :refund) (OPTIONAL) - :type = (:auth_only, :capture_only, :auth_capture) (NOT USED) - :type = (:prior_auth_capture) (OPTIONAL)
For :type == :refund only
-
:credit_card_number_masked
– (CONDITIONAL - requied for credit card refunds is :customer_profile_id AND :customer_payment_profile_id are missing) -
:bank_routing_number_masked && :bank_account_number_masked
– (CONDITIONAL - requied for electronic check refunds is :customer_profile_id AND :customer_payment_profile_id are missing) (NOT ABLE TO TEST - I keep getting “ACH transactions are not accepted by this merchant.” when trying to make a payment and, until that’s possible I can’t refund ([email protected]))
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 |
# File 'lib/active_merchant/billing/gateways/authorize_net_cim.rb', line 374 def create_customer_profile_transaction() requires!(, :transaction) requires!([:transaction], :type) case [:transaction][:type] when :void requires!([:transaction], :trans_id) when :refund requires!([:transaction], :trans_id) && ( ([:transaction][:customer_profile_id] && [:transaction][:customer_payment_profile_id]) || [:transaction][:credit_card_number_masked] || ([:transaction][:bank_routing_number_masked] && [:transaction][:bank_account_number_masked]) ) when :prior_auth_capture requires!([:transaction], :amount, :trans_id) else requires!([:transaction], :amount, :customer_profile_id, :customer_payment_profile_id) end request = build_request(:create_customer_profile_transaction, ) commit(:create_customer_profile_transaction, request) end |
#create_customer_profile_transaction_for_refund(options) ⇒ Object
Creates a new payment transaction for refund from an existing customer profile
This is what is used to refund a transaction you have stored in a Customer Profile.
Returns a Response object that contains the result of the transaction in params['direct_response']
Options
-
:transaction
– A hash containing information on the transaction that is being requested. (REQUIRED)
Transaction
-
:amount
– The total amount to be refunded (REQUIRED) -
:customer_profile_id
– The Customer Profile ID of the customer to use in this transaction. (CONDITIONAL :customer_payment_profile_id must be included if used) -
:customer_payment_profile_id
– The Customer Payment Profile ID of the Customer Payment Profile to use in this transaction. (CONDITIONAL :customer_profile_id must be included if used) -
:credit_card_number_masked
– Four Xs follwed by the last four digits of the credit card (CONDITIONAL - used if customer_profile_id and customer_payment_profile_id aren’t given) -
:bank_routing_number_masked
– The last four gidits of the routing number to be refunded (CONDITIONAL - must be used with :bank_account_number_masked) -
:bank_account_number_masked
– The last four digis of the bank account number to be refunded, Ex. XXXX1234 (CONDITIONAL - must be used with :bank_routing_number_masked) -
:tax
- A hash containing tax information for the refund (OPTIONAL -:amount
,:name
(31 characters),:description
(255 characters)) -
:duty
- A hash containting duty information for the refund (OPTIONAL -:amount
,:name
(31 characters),:description
(255 characters)) -
:shipping
- A hash containing shipping information for the refund (OPTIONAL -:amount
,:name
(31 characters),:description
(255 characters))
421 422 423 424 425 426 427 428 |
# File 'lib/active_merchant/billing/gateways/authorize_net_cim.rb', line 421 def create_customer_profile_transaction_for_refund() requires!(, :transaction) [:transaction][:type] = :refund requires!([:transaction], :trans_id) requires!([:transaction], :amount) request = build_request(:create_customer_profile_transaction, ) commit(:create_customer_profile_transaction, request) end |
#create_customer_profile_transaction_for_void(options) ⇒ Object
Creates a new payment transaction for void from an existing customer profile
This is what is used to void a transaction you have stored in a Customer Profile.
Returns a Response object that contains the result of the transaction in params['direct_response']
Options
-
:transaction
– A hash containing information on the transaction that is being requested. (REQUIRED)
Transaction
-
:trans_id
– The payment gateway assigned transaction id of the original transaction. (REQUIRED) -
:customer_profile_id
– The Customer Profile ID of the customer to use in this transaction. -
:customer_payment_profile_id
– The Customer Payment Profile ID of the Customer Payment Profile to use in this transaction. -
:customer_shipping_address_id
– Payment gateway assigned ID associated with the customer shipping address.
446 447 448 449 450 451 452 |
# File 'lib/active_merchant/billing/gateways/authorize_net_cim.rb', line 446 def create_customer_profile_transaction_for_void() requires!(, :transaction) [:transaction][:type] = :void requires!([:transaction], :trans_id) request = build_request(:create_customer_profile_transaction, ) commit(:create_customer_profile_transaction, request) end |
#create_customer_shipping_address(options) ⇒ Object
Creates a new customer shipping address for an existing customer profile.
Options
-
:customer_profile_id
– The Customer Profile ID of the customer the payment profile will be added to. (REQUIRED) -
:address
– A hash containing the elements of the shipping address (REQUIRED)
165 166 167 168 169 170 171 |
# File 'lib/active_merchant/billing/gateways/authorize_net_cim.rb', line 165 def create_customer_shipping_address() requires!(, :customer_profile_id) requires!(, :address) request = build_request(:create_customer_shipping_address, ) commit(:create_customer_shipping_address, request) end |
#delete_customer_payment_profile(options) ⇒ Object
Deletes a customer payment profile from an existing customer profile.
Options
-
:customer_profile_id
– The Customer Profile ID of the customer with the payment profile to be deleted. (REQUIRED) -
:customer_payment_profile_id
– The Payment Profile ID of the payment profile to be deleted. (REQUIRED)
191 192 193 194 195 196 197 |
# File 'lib/active_merchant/billing/gateways/authorize_net_cim.rb', line 191 def delete_customer_payment_profile() requires!(, :customer_profile_id) requires!(, :customer_payment_profile_id) request = build_request(:delete_customer_payment_profile, ) commit(:delete_customer_payment_profile, request) end |
#delete_customer_profile(options) ⇒ Object
Deletes an existing customer profile along with all associated customer payment profiles and customer shipping addresses.
Options
-
:customer_profile_id
– The Customer Profile ID of the customer to be deleted. (REQUIRED)
178 179 180 181 182 183 |
# File 'lib/active_merchant/billing/gateways/authorize_net_cim.rb', line 178 def delete_customer_profile() requires!(, :customer_profile_id) request = build_request(:delete_customer_profile, ) commit(:delete_customer_profile, request) end |
#delete_customer_shipping_address(options) ⇒ Object
Deletes a customer shipping address from an existing customer profile.
Options
-
:customer_profile_id
– The Customer Profile ID of the customer with the payment profile to be deleted. (REQUIRED) -
:customer_address_id
– The Shipping Address ID of the shipping address to be deleted. (REQUIRED)
205 206 207 208 209 210 211 |
# File 'lib/active_merchant/billing/gateways/authorize_net_cim.rb', line 205 def delete_customer_shipping_address() requires!(, :customer_profile_id) requires!(, :customer_address_id) request = build_request(:delete_customer_shipping_address, ) commit(:delete_customer_shipping_address, request) end |
#get_customer_payment_profile(options) ⇒ Object
Retrieve a customer payment profile for an existing customer profile.
Returns a Response whose params hash contains all the payment profile information. Sensitive information such as credit card numbers will be masked.
Options
-
:customer_profile_id
– The Customer Profile ID of the customer with the payment profile to be retrieved. (REQUIRED) -
:customer_payment_profile_id
– The Payment Profile ID of the payment profile to be retrieved. (REQUIRED)
241 242 243 244 245 246 247 |
# File 'lib/active_merchant/billing/gateways/authorize_net_cim.rb', line 241 def get_customer_payment_profile() requires!(, :customer_profile_id) requires!(, :customer_payment_profile_id) request = build_request(:get_customer_payment_profile, ) commit(:get_customer_payment_profile, request) end |
#get_customer_profile(options) ⇒ Object
Retrieves an existing customer profile along with all the associated customer payment profiles and customer shipping addresses.
Returns a Response whose params hash contains all the profile information.
Options
-
:customer_profile_id
– The Customer Profile ID of the customer to retrieve. (REQUIRED)
220 221 222 223 224 225 |
# File 'lib/active_merchant/billing/gateways/authorize_net_cim.rb', line 220 def get_customer_profile() requires!(, :customer_profile_id) request = build_request(:get_customer_profile, ) commit(:get_customer_profile, request) end |
#get_customer_profile_ids(options = {}) ⇒ Object
227 228 229 230 |
# File 'lib/active_merchant/billing/gateways/authorize_net_cim.rb', line 227 def get_customer_profile_ids( = {}) request = build_request(:get_customer_profile_ids, ) commit(:get_customer_profile_ids, request) end |
#get_customer_shipping_address(options) ⇒ Object
Retrieve a customer shipping address for an existing customer profile.
Returns a Response whose params hash contains all the shipping address information.
Options
-
:customer_profile_id
– The Customer Profile ID of the customer with the payment profile to be retrieved. (REQUIRED) -
:customer_address_id
– The Shipping Address ID of the shipping address to be retrieved. (REQUIRED)
257 258 259 260 261 262 263 |
# File 'lib/active_merchant/billing/gateways/authorize_net_cim.rb', line 257 def get_customer_shipping_address() requires!(, :customer_profile_id) requires!(, :customer_address_id) request = build_request(:get_customer_shipping_address, ) commit(:get_customer_shipping_address, request) end |
#update_customer_payment_profile(options) ⇒ Object
Updates a customer payment profile for an existing customer profile.
Warning: if you do not provide a parameter in the :payment_profile
hash, it is automatically set to nil at Authorize.Net. You will most likely want to first get the profile hash using get_customer_payment_profile and then only change the elements you wish to change.
Options
-
:customer_profile_id
– The Customer Profile ID of the customer with the payment profile to be updated. (REQUIRED) -
:payment_profile
– A hash containing the values the Customer Payment Profile should be updated to. (REQUIRED)
Payment Profile
-
:customer_payment_profile_id
– The Customer Payment Profile ID of the Customer Payment Profile to update. (REQUIRED)
300 301 302 303 304 305 306 |
# File 'lib/active_merchant/billing/gateways/authorize_net_cim.rb', line 300 def update_customer_payment_profile() requires!(, :customer_profile_id, :payment_profile) requires!([:payment_profile], :customer_payment_profile_id) request = build_request(:update_customer_payment_profile, ) commit(:update_customer_payment_profile, request) end |
#update_customer_profile(options) ⇒ Object
Updates an existing customer profile.
Warning: if you do not provide a parameter in the :payment_profile
hash, it is automatically set to nil at Authorize.Net. You will most likely want to first get the profile hash using get_customer_profile and then only change the elements you wish to change.
Options
-
:profile
– A hash containing the values the Customer Profile should be updated to. (REQUIRED)
Profile
-
:customer_profile_id
– The Customer Profile ID of the customer profile to update. (REQUIRED)
278 279 280 281 282 283 284 |
# File 'lib/active_merchant/billing/gateways/authorize_net_cim.rb', line 278 def update_customer_profile() requires!(, :profile) requires!([:profile], :customer_profile_id) request = build_request(:update_customer_profile, ) commit(:update_customer_profile, request) end |
#update_customer_shipping_address(options) ⇒ Object
Updates a customer shipping address for an existing customer profile.
Warning: if you do not provide a parameter in the :address
hash, it is automatically set to nil at Authorize.Net. You will most likely want to first get the profile hash using get_customer_shipping_address and then only change the elements you wish to change.
Options
-
:customer_profile_id
– The Customer Profile ID of the customer with the payment profile to be updated. (REQUIRED) -
:address
– A hash containing the values the Customer Shipping Address should be updated to. (REQUIRED)
Address
-
:customer_address_id
– The Customer Address ID of the Customer Payment Profile to update. (REQUIRED)
322 323 324 325 326 327 328 |
# File 'lib/active_merchant/billing/gateways/authorize_net_cim.rb', line 322 def update_customer_shipping_address() requires!(, :customer_profile_id, :address) requires!([:address], :customer_address_id) request = build_request(:update_customer_shipping_address, ) commit(:update_customer_shipping_address, request) end |
#validate_customer_payment_profile(options) ⇒ Object
Verifies an existing customer payment profile by generating a test transaction
Returns a Response object that contains the result of the transaction in params['direct_response']
Options
-
:customer_profile_id
– The Customer Profile ID of the customer to use in this transaction. (REQUIRED) -
:customer_payment_profile_id
– The Customer Payment Profile ID of the Customer Payment Profile to be verified. (REQUIRED) -
:customer_address_id
– The Customer Address ID of the Customer Shipping Address to be verified. (OPTIONAL) -
:card_code
– If the payment profile is a credit card, the CCV/CVV code to validate with (OPTIONAL) -
:validation_mode
–:live
or:test
In Test Mode, only field validation is performed. (REQUIRED In Live Mode, a transaction is generated and submitted to the processor with the amount of $0.01. If successful, the transaction is immediately voided. (REQUIRED)
466 467 468 469 470 471 |
# File 'lib/active_merchant/billing/gateways/authorize_net_cim.rb', line 466 def validate_customer_payment_profile() requires!(, :customer_profile_id, :customer_payment_profile_id, :validation_mode) request = build_request(:validate_customer_payment_profile, ) commit(:validate_customer_payment_profile, request) end |