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
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.
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
Creates a new AuthorizeNetCimGateway
The gateway requires that a valid API Login ID and Transaction Key be passed in the options hash.
:login — The Authorize.Net API Login ID (REQUIRED)
:password — The Authorize.Net Transaction Key. (REQUIRED)
:test — true or false. If true, perform transactions against the test server. Otherwise, perform transactions against the production server.
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 97 97: def initialize(options = {}) 98: requires!(options, :login, :password) 99: @options = options 100: super 101: end
Creates a new customer payment profile for an existing customer profile.
: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 — A hash containing information on payment. Either :credit_card or :bank_account (REQUIRED)
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 129 129: def create_customer_payment_profile(options) 130: requires!(options, :customer_profile_id) 131: requires!(options, :payment_profile) 132: requires!(options[:payment_profile], :payment) 133: 134: request = build_request(:create_customer_payment_profile, options) 135: commit(:create_customer_payment_profile, request) 136: end
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.
TODO
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 113 113: def create_customer_profile(options) 114: # TODO Add requires 115: request = build_request(:create_customer_profile, options) 116: commit(:create_customer_profile, request) 117: end
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']
:transaction — A hash containing information on the transaction that is being requested. (REQUIRED)
: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, :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)
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)
: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 (wiseleyb@gmail.com))
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 343 343: def create_customer_profile_transaction(options) 344: requires!(options, :transaction) 345: requires!(options[:transaction], :type) 346: case options[:transaction][:type] 347: when :void 348: requires!(options[:transaction], :trans_id) 349: when :refund 350: requires!(options[:transaction], :trans_id) && 351: ( 352: (options[:transaction][:customer_profile_id] && options[:transaction][:customer_payment_profile_id]) || 353: options[:transaction][:credit_card_number_masked] || 354: (options[:transaction][:bank_routing_number_masked] && options[:transaction][:bank_account_number_masked]) 355: ) 356: when :prior_auth_capture 357: requires!(options[:transaction], :amount, :trans_id) 358: else 359: requires!(options[:transaction], :amount, :customer_profile_id, :customer_payment_profile_id) 360: end 361: request = build_request(:create_customer_profile_transaction, options) 362: commit(:create_customer_profile_transaction, request) 363: end
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']
:transaction — A hash containing information on the transaction that is being requested. (REQUIRED)
: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)
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 386 386: def create_customer_profile_transaction_for_refund(options) 387: requires!(options, :transaction) 388: options[:transaction][:type] = :refund 389: requires!(options[:transaction], :trans_id) 390: requires!(options[:transaction], :amount) 391: request = build_request(:create_customer_profile_transaction, options) 392: commit(:create_customer_profile_transaction, request) 393: end
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']
:transaction — A hash containing information on the transaction that is being requested. (REQUIRED)
: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.
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 411 411: def create_customer_profile_transaction_for_void(options) 412: requires!(options, :transaction) 413: options[:transaction][:type] = :void 414: requires!(options[:transaction], :trans_id) 415: request = build_request(:create_customer_profile_transaction, options) 416: commit(:create_customer_profile_transaction, request) 417: end
Creates a new customer shipping address for an existing customer profile.
: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)
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 144 144: def create_customer_shipping_address(options) 145: requires!(options, :customer_profile_id) 146: requires!(options, :address) 147: 148: request = build_request(:create_customer_shipping_address, options) 149: commit(:create_customer_shipping_address, request) 150: end
Deletes a customer payment profile from an existing customer profile.
: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)
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 170 170: def delete_customer_payment_profile(options) 171: requires!(options, :customer_profile_id) 172: requires!(options, :customer_payment_profile_id) 173: 174: request = build_request(:delete_customer_payment_profile, options) 175: commit(:delete_customer_payment_profile, request) 176: end
Deletes an existing customer profile along with all associated customer payment profiles and customer shipping addresses.
:customer_profile_id — The Customer Profile ID of the customer to be deleted. (REQUIRED)
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 157 157: def delete_customer_profile(options) 158: requires!(options, :customer_profile_id) 159: 160: request = build_request(:delete_customer_profile, options) 161: commit(:delete_customer_profile, request) 162: end
Deletes a customer shipping address from an existing customer profile.
: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)
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 184 184: def delete_customer_shipping_address(options) 185: requires!(options, :customer_profile_id) 186: requires!(options, :customer_address_id) 187: 188: request = build_request(:delete_customer_shipping_address, options) 189: commit(:delete_customer_shipping_address, request) 190: end
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.
: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)
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 215 215: def get_customer_payment_profile(options) 216: requires!(options, :customer_profile_id) 217: requires!(options, :customer_payment_profile_id) 218: 219: request = build_request(:get_customer_payment_profile, options) 220: commit(:get_customer_payment_profile, request) 221: end
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.
:customer_profile_id — The Customer Profile ID of the customer to retrieve. (REQUIRED)
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 199 199: def get_customer_profile(options) 200: requires!(options, :customer_profile_id) 201: 202: request = build_request(:get_customer_profile, options) 203: commit(:get_customer_profile, request) 204: end
Retrieve a customer shipping address for an existing customer profile.
Returns a Response whose params hash contains all the shipping address information.
: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)
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 231 231: def get_customer_shipping_address(options) 232: requires!(options, :customer_profile_id) 233: requires!(options, :customer_address_id) 234: 235: request = build_request(:get_customer_shipping_address, options) 236: commit(:get_customer_shipping_address, request) 237: end
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.
: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)
:customer_payment_profile_id — The Customer Payment Profile ID of the Customer Payment Profile to update. (REQUIRED)
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 274 274: def update_customer_payment_profile(options) 275: requires!(options, :customer_profile_id, :payment_profile) 276: requires!(options[:payment_profile], :customer_payment_profile_id) 277: 278: request = build_request(:update_customer_payment_profile, options) 279: commit(:update_customer_payment_profile, request) 280: end
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.
:profile — A hash containing the values the Customer Profile should be updated to. (REQUIRED)
:customer_profile_id — The Customer Profile ID of the customer profile to update. (REQUIRED)
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 252 252: def update_customer_profile(options) 253: requires!(options, :profile) 254: requires!(options[:profile], :customer_profile_id) 255: 256: request = build_request(:update_customer_profile, options) 257: commit(:update_customer_profile, request) 258: end
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.
: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)
:customer_address_id — The Customer Address ID of the Customer Payment Profile to update. (REQUIRED)
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 296 296: def update_customer_shipping_address(options) 297: requires!(options, :customer_profile_id, :address) 298: requires!(options[:address], :customer_address_id) 299: 300: request = build_request(:update_customer_shipping_address, options) 301: commit(:update_customer_shipping_address, request) 302: end
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']
: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.
:validation_mode — :live or :test In Test Mode, only field validation is performed. 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)
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 430 430: def validate_customer_payment_profile(options) 431: requires!(options, :customer_profile_id, :customer_payment_profile_id, :validation_mode) 432: 433: request = build_request(:validate_customer_payment_profile, options) 434: commit(:validate_customer_payment_profile, request) 435: end
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 679 679: def add_address(xml, address) 680: xml.tag!('firstName', address[:first_name]) 681: xml.tag!('lastName', address[:last_name]) 682: xml.tag!('company', address[:company]) 683: xml.tag!('address', address[:address1]) if address[:address1] 684: xml.tag!('address', address[:address]) if address[:address] 685: xml.tag!('city', address[:city]) 686: xml.tag!('state', address[:state]) 687: xml.tag!('zip', address[:zip]) 688: xml.tag!('country', address[:country]) 689: xml.tag!('phoneNumber', address[:phone_number]) if address[:phone_number] 690: xml.tag!('faxNumber', address[:fax_number]) if address[:fax_number] 691: 692: xml.tag!('customerAddressId', address[:customer_address_id]) if address[:customer_address_id] 693: end
Adds customer’s bank account information Note: This element should only be included when the payment method is bank account.
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 712 712: def add_bank_account(xml, bank_account) 713: raise StandardError, "Invalid Bank Account Type: #{bank_account[:account_type]}" unless BANK_ACCOUNT_TYPES.include?(bank_account[:account_type]) 714: raise StandardError, "Invalid eCheck Type: #{bank_account[:echeck_type]}" unless ECHECK_TYPES.include?(bank_account[:echeck_type]) 715: 716: xml.tag!('bankAccount') do 717: # The type of bank account 718: xml.tag!('accountType', BANK_ACCOUNT_TYPES[bank_account[:account_type]]) 719: # The routing number of the customer’s bank 720: xml.tag!('routingNumber', bank_account[:routing_number]) 721: # The bank account number 722: xml.tag!('accountNumber', bank_account[:account_number]) 723: # The full name of the individual associated 724: # with the bank account number 725: xml.tag!('nameOnAccount', bank_account[:name_on_account]) 726: # The type of electronic check transaction 727: xml.tag!('echeckType', ECHECK_TYPES[bank_account[:echeck_type]]) 728: # The full name of the individual associated 729: # with the bank account number (optional) 730: xml.tag!('bankName', bank_account[:bank_name]) if bank_account[:bank_name] 731: end 732: end
Adds customer’s credit card information Note: This element should only be included when the payment method is credit card.
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 698 698: def add_credit_card(xml, credit_card) 699: return unless credit_card 700: xml.tag!('creditCard') do 701: # The credit card number used for payment of the subscription 702: xml.tag!('cardNumber', credit_card.number) 703: # The expiration date of the credit card used for the subscription 704: xml.tag!('expirationDate', expdate(credit_card)) 705: xml.tag!('cardCode', credit_card.verification_value) if credit_card.verification_value? 706: end 707: end
Adds customer’s driver’s license information Note: This element is only required for Wells Fargo SecureSource eCheck.Net merchants
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 737 737: def add_drivers_license(xml, drivers_license) 738: xml.tag!('driversLicense') do 739: # The state of the customer's driver's license 740: # A valid two character state code 741: xml.tag!('state', drivers_license[:state]) 742: # The customer’s driver's license number 743: xml.tag!('number', drivers_license[:number]) 744: # The date of birth listed on the customer's driver's license 745: # YYYY-MM-DD 746: xml.tag!('dateOfBirth', drivers_license[:date_of_birth]) 747: end 748: end
Contains the merchant’s payment gateway account authentication information
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 459 459: def add_merchant_authentication(xml) 460: xml.tag!('merchantAuthentication') do 461: xml.tag!('name', @options[:login]) 462: xml.tag!('transactionKey', @options[:password]) 463: end 464: end
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 632 632: def add_order(xml, order) 633: xml.tag!('order') do 634: xml.tag!('invoiceNumber', order[:invoice_number]) if order[:invoice_number] 635: xml.tag!('description', order[:description]) if order[:description] 636: xml.tag!('purchaseOrderNumber', order[:purchase_order_number]) if order[:purchase_order_number] 637: end 638: end
:customer_type => ‘individual or business’, # Optional :bill_to => @address, :payment => @payment
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 649 649: def add_payment_profile(xml, payment_profile) 650: # 'individual' or 'business' (optional) 651: xml.tag!('customerType', payment_profile[:customer_type]) if payment_profile[:customer_type] 652: 653: if payment_profile[:bill_to] 654: xml.tag!('billTo') do 655: add_address(xml, payment_profile[:bill_to]) 656: end 657: end 658: 659: if payment_profile[:payment] 660: xml.tag!('payment') do 661: add_credit_card(xml, payment_profile[:payment][:credit_card]) if payment_profile[:payment].has_key?(:credit_card) 662: add_bank_account(xml, payment_profile[:payment][:bank_account]) if payment_profile[:payment].has_key?(:bank_account) 663: add_drivers_license(xml, payment_profile[:payment][:drivers_license]) if payment_profile[:payment].has_key?(:drivers_license) 664: # This element is only required for Wells Fargo SecureSource eCheck.Net merchants 665: # The customer's Social Security Number or Tax ID 666: xml.tag!('taxId', payment_profile[:payment]) if payment_profile[:payment].has_key?(:tax_id) 667: end 668: end 669: 670: xml.tag!('customerPaymentProfileId', payment_profile[:customer_payment_profile_id]) if payment_profile[:customer_payment_profile_id] 671: end
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 640 640: def add_payment_profiles(xml, payment_profiles) 641: xml.tag!('paymentProfiles') do 642: add_payment_profile(xml, payment_profiles) 643: end 644: end
:merchant_customer_id (Optional) :description (Optional) :email (Optional) :payment_profiles (Optional)
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 576 576: def add_profile(xml, profile, update = false) 577: xml.tag!('profile') do 578: # Merchant assigned ID for the customer. Up to 20 characters. (optional) 579: xml.tag!('merchantCustomerId', profile[:merchant_customer_id]) if profile[:merchant_customer_id] 580: # Description of the customer. Up to 255 Characters (optional) 581: xml.tag!('description', profile[:description]) if profile[:description] 582: # Email Address for the customer. Up to 255 Characters (optional) 583: xml.tag!('email', profile[:email]) if profile[:email] 584: 585: if update 586: xml.tag!('customerProfileId', profile[:customer_profile_id]) 587: else 588: add_payment_profiles(xml, profile[:payment_profiles]) if profile[:payment_profiles] 589: add_ship_to_list(xml, profile[:ship_to_list]) if profile[:ship_to_list] 590: end 591: end 592: end
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 673 673: def add_ship_to_list(xml, ship_to_list) 674: xml.tag!('shipToList') do 675: add_address(xml, ship_to_list) 676: end 677: end
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 594 594: def add_transaction(xml, transaction) 595: unless CIM_TRANSACTION_TYPES.include?(transaction[:type]) 596: raise StandardError, "Invalid Customer Information Manager Transaction Type: #{transaction[:type]}" 597: end 598: 599: xml.tag!('transaction') do 600: xml.tag!(CIM_TRANSACTION_TYPES[transaction[:type]]) do 601: # The amount to be billed to the customer 602: case transaction[:type] 603: when :void 604: tag_unless_blank(xml,'customerProfileId', transaction[:customer_profile_id]) 605: tag_unless_blank(xml,'customerPaymentProfileId', transaction[:customer_payment_profile_id]) 606: tag_unless_blank(xml,'customerShippingAddressId', transaction[:customer_shipping_address_id]) 607: xml.tag!('transId', transaction[:trans_id]) 608: when :refund 609: #TODO - add support for all the other options fields 610: xml.tag!('amount', transaction[:amount]) 611: tag_unless_blank(xml, 'customerProfileId', transaction[:customer_profile_id]) 612: tag_unless_blank(xml, 'customerPaymentProfileId', transaction[:customer_payment_profile_id]) 613: tag_unless_blank(xml, 'customerShippingAddressId', transaction[:customer_shipping_address_id]) 614: tag_unless_blank(xml, 'creditCardNumberMasked', transaction[:credit_card_number_masked]) 615: tag_unless_blank(xml, 'bankRoutingNumberMasked', transaction[:bank_routing_number_masked]) 616: tag_unless_blank(xml, 'bankAccountNumberMasked', transaction[:bank_account_number_masked]) 617: xml.tag!('transId', transaction[:trans_id]) 618: when :prior_auth_capture 619: xml.tag!('amount', transaction[:amount]) 620: xml.tag!('transId', transaction[:trans_id]) 621: else 622: xml.tag!('amount', transaction[:amount]) 623: xml.tag!('customerProfileId', transaction[:customer_profile_id]) 624: xml.tag!('customerPaymentProfileId', transaction[:customer_payment_profile_id]) 625: xml.tag!('approvalCode', transaction[:approval_code]) if transaction[:type] == :capture_only 626: end 627: add_order(xml, transaction[:order]) if transaction[:order] 628: end 629: end 630: end
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 472 472: def build_create_customer_payment_profile_request(xml, options) 473: xml.tag!('customerProfileId', options[:customer_profile_id]) 474: 475: xml.tag!('paymentProfile') do 476: add_payment_profile(xml, options[:payment_profile]) 477: end 478: 479: xml.tag!('validationMode', CIM_VALIDATION_MODES[options[:validation_mode]]) if options[:validation_mode] 480: 481: xml.target! 482: end
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 466 466: def build_create_customer_profile_request(xml, options) 467: add_profile(xml, options[:profile]) 468: 469: xml.target! 470: end
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 556 556: def build_create_customer_profile_transaction_request(xml, options) 557: add_transaction(xml, options[:transaction]) 558: xml.tag!('extraOptions', "x_test_request=TRUE") if @options[:test] 559: 560: xml.target! 561: end
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 484 484: def build_create_customer_shipping_address_request(xml, options) 485: xml.tag!('customerProfileId', options[:customer_profile_id]) 486: 487: xml.tag!('address') do 488: add_address(xml, options[:address]) 489: end 490: 491: xml.target! 492: end
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 499 499: def build_delete_customer_payment_profile_request(xml, options) 500: xml.tag!('customerProfileId', options[:customer_profile_id]) 501: xml.tag!('customerPaymentProfileId', options[:customer_payment_profile_id]) 502: xml.target! 503: end
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 494 494: def build_delete_customer_profile_request(xml, options) 495: xml.tag!('customerProfileId', options[:customer_profile_id]) 496: xml.target! 497: end
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 505 505: def build_delete_customer_shipping_address_request(xml, options) 506: xml.tag!('customerProfileId', options[:customer_profile_id]) 507: xml.tag!('customerAddressId', options[:customer_address_id]) 508: xml.target! 509: end
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 516 516: def build_get_customer_payment_profile_request(xml, options) 517: xml.tag!('customerProfileId', options[:customer_profile_id]) 518: xml.tag!('customerPaymentProfileId', options[:customer_payment_profile_id]) 519: xml.target! 520: end
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 511 511: def build_get_customer_profile_request(xml, options) 512: xml.tag!('customerProfileId', options[:customer_profile_id]) 513: xml.target! 514: end
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 522 522: def build_get_customer_shipping_address_request(xml, options) 523: xml.tag!('customerProfileId', options[:customer_profile_id]) 524: xml.tag!('customerAddressId', options[:customer_address_id]) 525: xml.target! 526: end
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 443 443: def build_request(action, options = {}) 444: unless CIM_ACTIONS.include?(action) 445: raise StandardError, "Invalid Customer Information Manager Action: #{action}" 446: end 447: 448: xml = Builder::XmlMarkup.new(:indent => 2) 449: xml.instruct!(:xml, :version => '1.0', :encoding => 'utf-8') 450: xml.tag!("#{CIM_ACTIONS[action]}Request", :xmlns => AUTHORIZE_NET_CIM_NAMESPACE) do 451: add_merchant_authentication(xml) 452: # Merchant-assigned reference ID for the request 453: xml.tag!('refId', options[:ref_id]) if options[:ref_id] 454: send("build_#{action}_request", xml, options) 455: end 456: end
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 534 534: def build_update_customer_payment_profile_request(xml, options) 535: xml.tag!('customerProfileId', options[:customer_profile_id]) 536: 537: xml.tag!('paymentProfile') do 538: add_payment_profile(xml, options[:payment_profile]) 539: end 540: 541: xml.tag!('validationMode', CIM_VALIDATION_MODES[options[:validation_mode]]) if options[:validation_mode] 542: 543: xml.target! 544: end
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 528 528: def build_update_customer_profile_request(xml, options) 529: add_profile(xml, options[:profile], true) 530: 531: xml.target! 532: end
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 546 546: def build_update_customer_shipping_address_request(xml, options) 547: xml.tag!('customerProfileId', options[:customer_profile_id]) 548: 549: xml.tag!('address') do 550: add_address(xml, options[:address]) 551: end 552: 553: xml.target! 554: end
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 563 563: def build_validate_customer_payment_profile_request(xml, options) 564: xml.tag!('customerProfileId', options[:customer_profile_id]) 565: xml.tag!('customerPaymentProfileId', options[:customer_payment_profile_id]) 566: xml.tag!('customerShippingAddressId', options[:customer_address_id]) if options[:customer_address_id] 567: xml.tag!('validationMode', CIM_VALIDATION_MODES[options[:validation_mode]]) if options[:validation_mode] 568: 569: xml.target! 570: end
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 750 750: def commit(action, request) 751: url = test? ? test_url : live_url 752: xml = ssl_post(url, request, "Content-Type" => "text/xml") 753: 754: response_params = parse(action, xml) 755: 756: message = response_params['messages']['message']['text'] 757: test_mode = test? || message =~ /Test Mode/ 758: success = response_params['messages']['result_code'] == 'Ok' 759: 760: response = Response.new(success, message, response_params, 761: :test => test_mode, 762: :authorization => response_params['customer_profile_id'] || (response_params['profile'] ? response_params['profile']['customer_profile_id'] : nil) 763: ) 764: 765: response.params['direct_response'] = parse_direct_response(response) if response.params['direct_response'] 766: response 767: end
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 439 439: def expdate(credit_card) 440: sprintf('%04d-%02d', credit_card.year, credit_card.month) 441: end
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 823 823: def parse(action, xml) 824: xml = REXML::Document.new(xml) 825: root = REXML::XPath.first(xml, "//#{CIM_ACTIONS[action]}Response") || 826: REXML::XPath.first(xml, "//ErrorResponse") 827: if root 828: response = parse_element(root) 829: end 830: 831: response 832: end
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 773 773: def parse_direct_response(response) 774: direct_response = {'raw' => response.params['direct_response']} 775: direct_response_fields = response.params['direct_response'].split(',') 776: 777: direct_response.merge( 778: { 779: 'response_code' => direct_response_fields[0], 780: 'response_subcode' => direct_response_fields[1], 781: 'response_reason_code' => direct_response_fields[2], 782: 'message' => direct_response_fields[3], 783: 'approval_code' => direct_response_fields[4], 784: 'avs_response' => direct_response_fields[5], 785: 'transaction_id' => direct_response_fields[6], 786: 'invoice_number' => direct_response_fields[7], 787: 'order_description' => direct_response_fields[8], 788: 'amount' => direct_response_fields[9], 789: 'method' => direct_response_fields[10], 790: 'transaction_type' => direct_response_fields[11], 791: 'customer_id' => direct_response_fields[12], 792: 'first_name' => direct_response_fields[13], 793: 'last_name' => direct_response_fields[14], 794: 'company' => direct_response_fields[15], 795: 'address' => direct_response_fields[16], 796: 'city' => direct_response_fields[17], 797: 'state' => direct_response_fields[18], 798: 'zip_code' => direct_response_fields[19], 799: 'country' => direct_response_fields[20], 800: 'phone' => direct_response_fields[21], 801: 'fax' => direct_response_fields[22], 802: 'email_address' => direct_response_fields[23], 803: 'ship_to_first_name' => direct_response_fields[24], 804: 'ship_to_last_name' => direct_response_fields[25], 805: 'ship_to_company' => direct_response_fields[26], 806: 'ship_to_address' => direct_response_fields[27], 807: 'ship_to_city' => direct_response_fields[28], 808: 'ship_to_state' => direct_response_fields[29], 809: 'ship_to_zip_code' => direct_response_fields[30], 810: 'ship_to_country' => direct_response_fields[31], 811: 'tax' => direct_response_fields[32], 812: 'duty' => direct_response_fields[33], 813: 'freight' => direct_response_fields[34], 814: 'tax_exempt' => direct_response_fields[35], 815: 'purchase_order_number' => direct_response_fields[36], 816: 'md5_hash' => direct_response_fields[37], 817: 'card_code' => direct_response_fields[38], 818: 'cardholder_authentication_verification_response' => direct_response_fields[39] 819: } 820: ) 821: end
# File lib/active_merchant/billing/gateways/authorize_net_cim.rb, line 834 834: def parse_element(node) 835: if node.has_elements? 836: response = {} 837: node.elements.each{ |e| 838: key = e.name.underscore 839: value = parse_element(e) 840: if response.has_key?(key) 841: if response[key].is_a?(Array) 842: response[key].push(value) 843: else 844: response[key] = [response[key], value] 845: end 846: else 847: response[key] = parse_element(e) 848: end 849: } 850: else 851: response = node.text 852: end 853: 854: response 855: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.