Class: ActiveMerchant::Billing::TrustCommerceGateway

### Home Classes Methods

### In Files

- lib/active_merchant/billing/gateways/trust_commerce.rb

### Parent

ActiveMerchant::Billing::Gateway

### Methods

- ::new
- ::tclink?
- #authorize
- #capture
- #credit
- #purchase
- #recurring
- #refund
- #store
- #tclink?
- #test?
- #unstore
- #void

### Class/Module Index

Quicksearch

- ActiveMerchant
- ActiveMerchant::Billing
- ActiveMerchant::Billing::AVSResult
- ActiveMerchant::Billing::BarclaysEpdqGateway
- ActiveMerchant::Billing::BarclaysEpdqGateway::Document
- ActiveMerchant::Billing::BarclaysEpdqGateway::Parser
- ActiveMerchant::Billing::Base
- ActiveMerchant::Billing::BeanstreamGateway
- ActiveMerchant::Billing::BeanstreamInteracGateway
- ActiveMerchant::Billing::BeanstreamInteracResponse
- ActiveMerchant::Billing::BluePayGateway
- ActiveMerchant::Billing::BogusGateway
- ActiveMerchant::Billing::BraintreeBlueGateway
- ActiveMerchant::Billing::BraintreeGateway
- ActiveMerchant::Billing::BraintreeOrangeGateway
- ActiveMerchant::Billing::CVVResult
- ActiveMerchant::Billing::CardSaveGateway
- ActiveMerchant::Billing::CardStreamGateway
- ActiveMerchant::Billing::Check
- ActiveMerchant::Billing::CreditCard
- ActiveMerchant::Billing::CreditCardFormatting
- ActiveMerchant::Billing::CreditCardMethods
- ActiveMerchant::Billing::CreditCardMethods::ClassMethods
- ActiveMerchant::Billing::CyberSourceGateway
- ActiveMerchant::Billing::DataCashGateway
- ActiveMerchant::Billing::EfsnetGateway
- ActiveMerchant::Billing::ElavonGateway
- ActiveMerchant::Billing::EpayGateway
- ActiveMerchant::Billing::EwayGateway
- ActiveMerchant::Billing::EwayManagedGateway
- ActiveMerchant::Billing::EwayManagedGateway::EwayResponse
- ActiveMerchant::Billing::ExactGateway
- ActiveMerchant::Billing::FederatedCanadaGateway
- ActiveMerchant::Billing::FirstPayGateway
- ActiveMerchant::Billing::FirstPayGateway::FirstPayPostData
- ActiveMerchant::Billing::GarantiGateway
- ActiveMerchant::Billing::Gateway
- ActiveMerchant::Billing::IdealBaseGateway
- ActiveMerchant::Billing::IdealRabobankGateway
- ActiveMerchant::Billing::IdealResponse
- ActiveMerchant::Billing::InspireGateway
- ActiveMerchant::Billing::InstapayGateway
- ActiveMerchant::Billing::Integrations
- ActiveMerchant::Billing::Integrations::ActionViewHelper
- ActiveMerchant::Billing::Integrations::Bogus
- ActiveMerchant::Billing::Integrations::Bogus::Helper
- ActiveMerchant::Billing::Integrations::Bogus::Notification
- ActiveMerchant::Billing::Integrations::Bogus::Return
- ActiveMerchant::Billing::Integrations::Chronopay
- ActiveMerchant::Billing::Integrations::Chronopay::Helper
- ActiveMerchant::Billing::Integrations::Chronopay::Return
- ActiveMerchant::Billing::Integrations::DirecPay
- ActiveMerchant::Billing::Integrations::DirecPay::Helper
- ActiveMerchant::Billing::Integrations::DirecPay::Notification
- ActiveMerchant::Billing::Integrations::DirecPay::Return
- ActiveMerchant::Billing::Integrations::DirecPay::Status
- ActiveMerchant::Billing::Integrations::Directebanking
- ActiveMerchant::Billing::Integrations::Directebanking::Helper
- ActiveMerchant::Billing::Integrations::Directebanking::Notification
- ActiveMerchant::Billing::Integrations::Directebanking::Return
- ActiveMerchant::Billing::Integrations::Dwolla
- ActiveMerchant::Billing::Integrations::Dwolla::Helper
- ActiveMerchant::Billing::Integrations::Dwolla::Notification
- ActiveMerchant::Billing::Integrations::Dwolla::Return
- ActiveMerchant::Billing::Integrations::EPaymentPlans
- ActiveMerchant::Billing::Integrations::EPaymentPlans::Helper
- ActiveMerchant::Billing::Integrations::EPaymentPlans::Notification
- ActiveMerchant::Billing::Integrations::Gestpay
- ActiveMerchant::Billing::Integrations::Gestpay::Common
- ActiveMerchant::Billing::Integrations::Gestpay::Helper
- ActiveMerchant::Billing::Integrations::Gestpay::Notification
- ActiveMerchant::Billing::Integrations::Gestpay::Return
- ActiveMerchant::Billing::Integrations::HiTrust
- ActiveMerchant::Billing::Integrations::HiTrust::Notification
- ActiveMerchant::Billing::Integrations::HiTrust::Return
- ActiveMerchant::Billing::Integrations::Moneybookers
- ActiveMerchant::Billing::Integrations::Moneybookers::Helper
- ActiveMerchant::Billing::Integrations::Nochex
- ActiveMerchant::Billing::Integrations::Nochex::Helper
- ActiveMerchant::Billing::Integrations::Nochex::Notification
- ActiveMerchant::Billing::Integrations::Nochex::Return
- ActiveMerchant::Billing::Integrations::Notification
- ActiveMerchant::Billing::Integrations::PayflowLink
- ActiveMerchant::Billing::Integrations::PayflowLink::Helper
- ActiveMerchant::Billing::Integrations::PayflowLink::Notification
- ActiveMerchant::Billing::Integrations::Paypal
- ActiveMerchant::Billing::Integrations::Paypal::Helper
- ActiveMerchant::Billing::Integrations::Paypal::Notification
- ActiveMerchant::Billing::Integrations::Paypal::Return
- ActiveMerchant::Billing::Integrations::Quickpay
- ActiveMerchant::Billing::Integrations::Quickpay::Helper
- ActiveMerchant::Billing::Integrations::Quickpay::Notification
- ActiveMerchant::Billing::Integrations::Return
- ActiveMerchant::Billing::Integrations::SagePayForm
- ActiveMerchant::Billing::Integrations::SagePayForm::Encryption
- ActiveMerchant::Billing::Integrations::SagePayForm::Helper
- ActiveMerchant::Billing::Integrations::SagePayForm::Notification
- ActiveMerchant::Billing::Integrations::SagePayForm::Notification::CryptError
- ActiveMerchant::Billing::Integrations::SagePayForm::Notification::InvalidCryptData
- ActiveMerchant::Billing::Integrations::SagePayForm::Notification::MissingCryptData
- ActiveMerchant::Billing::Integrations::SagePayForm::Notification::MissingCryptKey
- ActiveMerchant::Billing::Integrations::SagePayForm::Return
- ActiveMerchant::Billing::Integrations::TwoCheckout
- ActiveMerchant::Billing::Integrations::TwoCheckout::Helper
- ActiveMerchant::Billing::Integrations::TwoCheckout::Notification
- ActiveMerchant::Billing::Integrations::TwoCheckout::Return
- ActiveMerchant::Billing::Integrations::Valitor
- ActiveMerchant::Billing::Integrations::Valitor::Helper
- ActiveMerchant::Billing::Integrations::Valitor::Notification
- ActiveMerchant::Billing::Integrations::Valitor::ResponseFields
- ActiveMerchant::Billing::Integrations::Valitor::Return
- ActiveMerchant::Billing::Integrations::WorldPay
- ActiveMerchant::Billing::Integrations::WorldPay::Helper
- ActiveMerchant::Billing::Integrations::WorldPay::Notification
- ActiveMerchant::Billing::IridiumGateway
- ActiveMerchant::Billing::JetpayGateway
- ActiveMerchant::Billing::LinkpointGateway
- ActiveMerchant::Billing::MerchantESolutionsGateway
- ActiveMerchant::Billing::MerchantWareGateway
- ActiveMerchant::Billing::ModernPaymentsGateway
- ActiveMerchant::Billing::MonerisGateway
- ActiveMerchant::Billing::NetRegistryGateway
- ActiveMerchant::Billing::NetaxeptGateway
- ActiveMerchant::Billing::NetaxeptGateway::Response
- ActiveMerchant::Billing::NetbillingGateway
- ActiveMerchant::Billing::NmiGateway
- ActiveMerchant::Billing::OptimalPaymentGateway
- ActiveMerchant::Billing::OrbitalSoftDescriptors
- ActiveMerchant::Billing::PayJunctionGateway
- ActiveMerchant::Billing::PaySecureGateway
- ActiveMerchant::Billing::PayboxDirectGateway
- ActiveMerchant::Billing::PayflowCommonAPI
- ActiveMerchant::Billing::PayflowExpressResponse
- ActiveMerchant::Billing::PayflowExpressUkGateway
- ActiveMerchant::Billing::PayflowGateway
- ActiveMerchant::Billing::PayflowResponse
- ActiveMerchant::Billing::PayflowUkGateway
- ActiveMerchant::Billing::PaymentExpressGateway
- ActiveMerchant::Billing::PaymentExpressResponse
- ActiveMerchant::Billing::PaypalCaGateway
- ActiveMerchant::Billing::PaypalCommonAPI
- ActiveMerchant::Billing::PaypalExpressCommon
- ActiveMerchant::Billing::PaypalExpressGateway
- ActiveMerchant::Billing::PaypalExpressResponse
- ActiveMerchant::Billing::PaypalGateway
- ActiveMerchant::Billing::PlugnpayGateway
- ActiveMerchant::Billing::PlugnpayGateway::PlugnpayPostData
- ActiveMerchant::Billing::PsigateGateway
- ActiveMerchant::Billing::QbmsGateway
- ActiveMerchant::Billing::QuantumGateway
- ActiveMerchant::Billing::QuickpayGateway
- ActiveMerchant::Billing::RealexGateway
- ActiveMerchant::Billing::Response
- ActiveMerchant::Billing::SageGateway
- ActiveMerchant::Billing::SagePayGateway
- ActiveMerchant::Billing::SallieMaeGateway
- ActiveMerchant::Billing::SamuraiGateway
- ActiveMerchant::Billing::SecureNetGateway
- ActiveMerchant::Billing::SecurePayAuGateway
- ActiveMerchant::Billing::SecurePayGateway
- ActiveMerchant::Billing::SecurePayTechGateway
- ActiveMerchant::Billing::SecurePayTechGateway::SecurePayTechPostData
- ActiveMerchant::Billing::SkipJackGateway
- ActiveMerchant::Billing::StripeGateway
- ActiveMerchant::Billing::TransFirstGateway
- ActiveMerchant::Billing::TransaxGateway
- ActiveMerchant::Billing::TrustCommerceGateway
- ActiveMerchant::Billing::UsaEpayAdvancedGateway
- ActiveMerchant::Billing::UsaEpayGateway
- ActiveMerchant::Billing::UsaEpayTransactionGateway
- ActiveMerchant::Billing::VerifiGateway
- ActiveMerchant::Billing::VerifiGateway::VerifiPostData
- ActiveMerchant::Billing::ViaklixGateway
- ActiveMerchant::Billing::WirecardGateway
- ActiveMerchant::Billing::WorldpayGateway
- ActiveMerchant::Billing::WorldpayGateway::MultiResponse
- BraintreeCommon
- OutboundHosts

No matching classes.

# ActiveMerchant::Billing::TrustCommerceGateway

TO USE: First, make sure you have everything setup correctly and all of your dependencies in place with:

    require 'rubygems'
    require 'active_merchant'

ActiveMerchant expects amounts to be Integer values in cents

    tendollar = 1000

Next, create a credit card object using a TC approved test card.

    creditcard = ActiveMerchant::Billing::CreditCard.new(
        :number => '4111111111111111',
        :month => 8,
        :year => 2006,
        :first_name => 'Longbob',
      :last_name => 'Longsen'
    )

To finish setting up, create the active_merchant object you will be using, with the TrustCommerce gateway. If you have a functional TrustCommerce account, replace login and password with your account info. Otherwise the defaults will work for testing.

    gateway = ActiveMerchant::Billing::Base.gateway(:trust_commerce).new(:login => "TestMerchant", :password => "password")

Now we are ready to process our transaction

    response = gateway.purchase(tendollar, creditcard)

Sending a transaction to TrustCommerce with active_merchant returns a Response object, which consistently allows you to:

1) Check whether the transaction was successful

    response.success?

2) Retrieve any message returned by TrustCommerce, either a "transaction was successful" note or an explanation of why the transaction was rejected.

    response.message

3) Retrieve and store the unique transaction ID returned by Trust Commerece, for use in referencing the transaction in the future.

    response.params["transid"]

For higher performance and failover with the TrustCommerceGateway you can install the TCLink library from www.trustcommerce.com/tclink.html. Follow the instructions available there to get it working on your system. ActiveMerchant will automatically use tclink if available.

The TCLink library has the following added benefits:

    * Good transaction times. Transaction duration under 1.2 seconds are common.
    * Fail-over to geographically distributed servers for extreme reliability

Once it is installed, you should be able to make sure that it is visible to your ruby install by opening irb and typing "require 'tclink'", which should return "true".

This should be enough to get you started with Trust Commerce and active_merchant. For further information, review the methods below and the rest of active_merchant's documentation, as well as Trust Commerce's user and developer documentation.

### Constants

BADDATA_CODES
DECLINE_CODES
ERROR_CODES
SUCCESS_TYPES
TEST_LOGIN
TEST_PASSWORD
URL

### Public Class Methods

new(options = {}) click to toggle source

Creates a new TrustCommerceGateway

The gateway requires that a valid login and password be passed in the `options` hash.

#### Options

- `:login` -- The TrustCommerce account login.

- `:password` -- The TrustCommerce account password.

- `:test => true or false` -- Perform test transactions

#### Test Account Credentials

- `:login` -- TestMerchant

- `:password` -- password

    # File lib/active_merchant/billing/gateways/trust_commerce.rb, line 131
    def initialize(options = {})
      requires!(options, :login, :password)

      @options = options
      super
    end

tclink?() click to toggle source

    # File lib/active_merchant/billing/gateways/trust_commerce.rb, line 113
    def self.tclink?
      defined?(TCLink)
    end

### Public Instance Methods

authorize(money, creditcard_or_billing_id, options = {}) click to toggle source

authorize() is the first half of the preauth(authorize)/postauth(capture) model. The TC API docs call this preauth, we preserve active_merchant's nomenclature of authorize() for consistency with the rest of the library. This method simply checks to make sure funds are available for a transaction, and returns a transid that can be used later to postauthorize (capture) the funds.

    # File lib/active_merchant/billing/gateways/trust_commerce.rb, line 152
    def authorize(money, creditcard_or_billing_id, options = {})
      parameters = {
        :amount => amount(money),
      }

      add_order_id(parameters, options)
      add_customer_data(parameters, options)
      add_payment_source(parameters, creditcard_or_billing_id)
      add_addresses(parameters, options)
      commit('preauth', parameters)
    end

capture(money, authorization, options = {}) click to toggle source

capture() is the second half of the preauth(authorize)/postauth(capture) model. The TC API docs call this postauth, we preserve active_merchant's nomenclature of capture() for consistency with the rest of the library. To process a postauthorization with TC, you need an amount in cents or a money object, and a TC transid.

    # File lib/active_merchant/billing/gateways/trust_commerce.rb, line 181
    def capture(money, authorization, options = {})
      parameters = {
        :amount => amount(money),
        :transid => authorization,
      }

      commit('postauth', parameters)
    end

credit(money, identification, options = {}) click to toggle source

    # File lib/active_merchant/billing/gateways/trust_commerce.rb, line 201
    def credit(money, identification, options = {})
      deprecated CREDIT_DEPRECATION_MESSAGE
      refund(money, identification, options)
    end

purchase(money, creditcard_or_billing_id, options = {}) click to toggle source

purchase() is a simple sale. This is one of the most common types of transactions, and is extremely simple. All that you need to process a purchase are an amount in cents or a money object and a creditcard object or billingid string.

    # File lib/active_merchant/billing/gateways/trust_commerce.rb, line 166
    def purchase(money, creditcard_or_billing_id, options = {})
      parameters = {
        :amount => amount(money),
      }

      add_order_id(parameters, options)
      add_customer_data(parameters, options)
      add_payment_source(parameters, creditcard_or_billing_id)
      add_addresses(parameters, options)
      commit('sale', parameters)
    end

recurring(money, creditcard, options = {}) click to toggle source

recurring() a TrustCommerce account that is activated for Citatdel, TrustCommerce's hosted customer billing info database.

Recurring billing uses the same TC action as a plain-vanilla 'store', but we have a separate method for clarity. It can be called like store, with the addition of a required 'periodicity' parameter:

The parameter :periodicity should be specified as either :bimonthly, :monthly, :biweekly, :weekly, :yearly or :daily

    gateway.recurring(tendollar, creditcard, :periodicity => :weekly)

You can optionally specify how long you want payments to continue using 'payments'

    # File lib/active_merchant/billing/gateways/trust_commerce.rb, line 239
    def recurring(money, creditcard, options = {})
      requires!(options, [:periodicity, :bimonthly, :monthly, :biweekly, :weekly, :yearly, :daily] )

      cycle = case options[:periodicity]
      when :monthly
        '1m'
      when :bimonthly
        '2m'
      when :weekly
        '1w'
      when :biweekly
        '2w'
      when :yearly
        '1y'
      when :daily
        '1d'
      end

      parameters = {
        :amount => amount(money),
        :cycle => cycle,
        :verify => options[:verify] || 'y',
        :billingid => options[:billingid] || nil,
        :payments => options[:payments] || nil,
      }

      add_creditcard(parameters, creditcard)

      commit('store', parameters)
    end

refund(money, identification, options = {}) click to toggle source

refund() allows you to return money to a card that was previously billed. You need to supply the amount, in cents or a money object, that you want to refund, and a TC transid for the transaction that you are refunding.

    # File lib/active_merchant/billing/gateways/trust_commerce.rb, line 192
    def refund(money, identification, options = {})
      parameters = {
        :amount => amount(money),
        :transid => identification
      }

      commit('credit', parameters)
    end

store(creditcard, options = {}) click to toggle source

store() requires a TrustCommerce account that is activated for Citatdel. You can call it with a credit card and a billing ID you would like to use to reference the stored credit card info for future captures. Use 'verify' to specify whether you want to simply store the card in the DB, or you want TC to verify the data first.

    # File lib/active_merchant/billing/gateways/trust_commerce.rb, line 274
    def store(creditcard, options = {})
      parameters = {
        :verify => options[:verify] || 'y',
        :billingid => options[:billingid] || options[:billing_id] || nil,
      }

      add_creditcard(parameters, creditcard)
      add_addresses(parameters, options)
      commit('store', parameters)
    end

tclink?() click to toggle source

    # File lib/active_merchant/billing/gateways/trust_commerce.rb, line 138
    def tclink?
      self.class.tclink?
    end

test?() click to toggle source

    # File lib/active_merchant/billing/gateways/trust_commerce.rb, line 142
    def test?
      @options[:login] == TEST_LOGIN &&
        @options[:password] == TEST_PASSWORD || @options[:test] || super
    end

unstore(identification, options = {}) click to toggle source

To unstore a creditcard stored in Citadel using store() or recurring(), all that is required is the billing id. When you run unstore() the information will be removed and a Response object will be returned indicating the success of the action.

    # File lib/active_merchant/billing/gateways/trust_commerce.rb, line 287
    def unstore(identification, options = {})
      parameters = {
        :billingid => identification,
      }

      commit('unstore', parameters)
    end

void(authorization, options = {}) click to toggle source

void() clears an existing authorization and releases the reserved fund s back to the cardholder. The TC API refers to this transaction as a reversal. After voiding, you will no longer be able to capture funds from this authorization. TrustCommerce seems to always return a status of "accepted" even if the transid you are trying to deauthorize has already been captured. Note: Your account needs to be configured by TrustCommerce to allow for reversal transactions before you can use this method.

NOTE: AMEX preauth's cannot be reversed. If you want to clear it more quickly than the automatic expiration (7-10 days), you will have to capture it and then immediately issue a credit for the same amount which should clear the customers credit card with 48 hours according to TC.

    # File lib/active_merchant/billing/gateways/trust_commerce.rb, line 220
    def void(authorization, options = {})
      parameters = {
        :transid => authorization,
      }

      commit('reversal', parameters)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.