class AuthorizeNet::ARB::Transaction
The ARB
transaction class.
Public Class Methods
Constructs an ARB
transaction. You can use the new ARB
transaction object to issue a request to the payment gateway and parse the response into a new AuthorizeNet::ARB::Response
object.
api_login_id
-
Your
API
login ID, as a string. api_transaction_key
-
Your
API
transaction key, as a string. options
-
A hash of options. See below for values.
Options
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).
verify_ssl
-
A boolean indicating if the SSL certificate of the
gateway
should be verified. Defaults to true. 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.
AuthorizeNet::XmlTransaction::new
# File lib/authorize_net/arb/transaction.rb, line 40 def initialize(api_login_id, api_transaction_key, options = {}) super end
Public Instance Methods
Sets up and submits a subscription cancelation (ARBCancelSubscriptionRequest) transaction. Returns a response object. If the transaction has already been run, it will return nil.
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.
Typical usage:
response = transaction.cancel('123456')
# File lib/authorize_net/arb/transaction.rb, line 151 def cancel(subscription_id) @type = Type::ARB_CANCEL handle_subscription_id(subscription_id) run end
Sets up and submits a start of subscription (ARBCreateSubscriptionRequest) transaction. Returns a response object. If the transaction has already been run, it will return nil.
subscription
-
An instance of
AuthorizeNet::ARB::Subscription
describing the recurring payment you would like to create.
Typical usage:
subscription = AuthorizeNet::ARB::Subscription.new( :name => "Monthly Gift Basket", :length => 1, :unit => :month, :start_date => Date.today, :total_occurrences => :unlimited, :amount => 100.00, :invoice_number => '1234567', :description => "John Doe's Monthly Gift Basket", :credit_card => AuthorizeNet::CreditCard.new('4111111111111111', '1120'), :billing_address => AuthorizeNet::Address.new(:first_name => 'John', :last_name => 'Doe') ) response = transaction.create(subscription)
# File lib/authorize_net/arb/transaction.rb, line 66 def create(subscription) @type = Type::ARB_CREATE set_fields(subscription.to_hash) run end
Sets up and submits a subscription status query (ARBGetSubscriptionStatusRequest) transaction. Returns a response object (which contains the subscription status). If the transaction has already been run, it will return nil.
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.
Typical usage:
response = transaction.get_status('123456') response.subscription_status # A value from AuthorizeNet::ARB::Subscription::Status
# File lib/authorize_net/arb/transaction.rb, line 103 def get_status(subscription_id) @type = Type::ARB_GET_STATUS handle_subscription_id(subscription_id) run end
Sets up and submits a subscription list query (ARBGetSubscriptionListRequest). Returns a response object which contains the list of subscription details and the total number of subscriptions matching the search criteria. Sorting
and Paging
are optional parameters.
Valid values for search type parameter:
cardExpiringThisMonth subscriptionActive subscriptionExpiringThisMonth subscriptionInactive
Typical usage:
sorting = AuthorizeNet::ARB::Sorting.new('name',true) paging = AuthorizeNet::ARB::Paging.new(1,1000) response = transaction.get_subscription_list('subscriptionActive',sorting,paging)
# File lib/authorize_net/arb/transaction.rb, line 125 def get_subscription_list(search_type, sorting = nil, paging = nil) unless search_type.nil? self.class.instance_variable_set(:@response_class,SubscriptionListResponse) @type = Type::ARB_GET_SUBSCRIPTION_LIST set_fields(:search_type => search_type.to_s) unless sorting.nil? set_fields(sorting.to_hash) end unless paging.nil? set_fields(paging.to_hash) end run end return response end
Sets up and submits a subscription update (ARBUpdateSubscriptionRequest) transaction. Returns a response object. If the transaction has already been run, it will return nil.
subscription
-
An instance of
AuthorizeNet::ARB::Subscription
describing the changes to make. It must have a value for subscription_id so that theAPI
knows what subscription to update. Note that some information (intervals, start dates, etc) can't be changed. See theARB
guide for more details.
Typical usage:
subscription = AuthorizeNet::ARB::Subscription.new( :billing_address => AuthorizeNet::Address.new(:first_name => 'Jane', :last_name => 'Doe'), :subscription_id => '123456' ) response = transaction.update(subscription)
# File lib/authorize_net/arb/transaction.rb, line 86 def update(subscription) @type = Type::ARB_UPDATE set_fields(subscription.to_hash) run end