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 false. 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 41 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 120 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 67 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 104 def get_status(subscription_id) @type = Type::ARB_GET_STATUS handle_subscription_id(subscription_id) run 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 the API 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 87 def update(subscription) @type = Type::ARB_UPDATE set_fields(subscription.to_hash) run end