lib/active_merchant/billing/gateways/authorize_net.rb in activemerchant-1.16.0 vs lib/active_merchant/billing/gateways/authorize_net.rb in activemerchant-1.17.0

- old
+ new

@@ -17,11 +17,11 @@ # # ==== Automated Recurring Billing (ARB) # # Automated Recurring Billing (ARB) is an optional service for submitting and managing recurring, or subscription-based, transactions. # - # To use recurring, update_recurring, and cancel_recurring ARB must be enabled for your account. + # To use recurring, update_recurring, cancel_recurring and status_recurring ARB must be enabled for your account. # # Information about ARB is available on the {Authorize.Net website}[http://www.authorize.net/solutions/merchantsolutions/merchantservices/automatedrecurringbilling/]. # Information about the ARB API is available at the {Authorize.Net Integration Center}[http://developer.authorize.net/] class AuthorizeNetGateway < Gateway API_VERSION = '3.1' @@ -53,11 +53,12 @@ AUTHORIZE_NET_ARB_NAMESPACE = 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' RECURRING_ACTIONS = { :create => 'ARBCreateSubscription', :update => 'ARBUpdateSubscription', - :cancel => 'ARBCancelSubscription' + :cancel => 'ARBCancelSubscription', + :status => 'ARBGetSubscriptionStatus' } # Creates a new AuthorizeNetGateway # # The gateway requires that a valid login and password be passed @@ -147,16 +148,24 @@ # * <tt>options</tt> -- A hash of parameters. # # ==== Options # # * <tt>:card_number</tt> -- The credit card number the refund is being issued to. (REQUIRED) + # * <tt>:first_name</tt> -- The first name of the account being refunded. + # * <tt>:last_name</tt> -- The last name of the account being refunded. + # * <tt>:zip</tt> -- The postal code of the account being refunded. def refund(money, identification, options = {}) requires!(options, :card_number) post = { :trans_id => identification, :card_num => options[:card_number] } + + post[:first_name] = options[:first_name] if options[:first_name] + post[:last_name] = options[:last_name] if options[:last_name] + post[:zip] = options[:zip] if options[:zip] + add_invoice(post, options) add_duplicate_window(post) commit('CREDIT', money, post) end @@ -232,10 +241,23 @@ def cancel_recurring(subscription_id) request = build_recurring_request(:cancel, :subscription_id => subscription_id) recurring_commit(:cancel, request) end + # Get Subscription Status of a recurring payment. + # + # This transaction gets the status of an existing Automated Recurring Billing (ARB) subscription. Your account must have ARB enabled. + # + # ==== Parameters + # + # * <tt>subscription_id</tt> -- A string containing the +subscription_id+ of the recurring payment already in place + # for a given credit card. (REQUIRED) + def status_recurring(subscription_id) + request = build_recurring_request(:status, :subscription_id => subscription_id) + recurring_commit(:status, request) + end + private def commit(action, money, parameters) parameters[:amount] = amount(money) unless action == 'VOID' @@ -440,9 +462,16 @@ xml.target! end # Builds body for ARBCancelSubscriptionRequest def build_arb_cancel_subscription_request(xml, options) + xml.tag!('subscriptionId', options[:subscription_id]) + + xml.target! + end + + # Builds body for ARBGetSubscriptionStatusRequest + def build_arb_status_subscription_request(xml, options) xml.tag!('subscriptionId', options[:subscription_id]) xml.target! end