Class: ActiveMerchant::Billing::VindiciaGateway

Inherits:
Gateway
  • Object
show all
Defined in:
lib/active_merchant/billing/gateways/vindicia.rb

Overview

For more information on the Vindicia Gateway please visit their website

The login and password are not the username and password you use to login to the Vindicia Merchant Portal.

Recurring Billing

AutoBills are an feature of Vindicia’s API that allows for creating and managing subscriptions.

For more information about Vindicia’s API and various other services visit their Resource Center

Constant Summary

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::CURRENCIES_WITHOUT_FRACTIONS, Gateway::DEBIT_CARDS

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#card_brand, card_brand, inherited, supports?, #test?

Methods included from CreditCardFormatting

#format

Constructor Details

#initialize(options = {}) ⇒ VindiciaGateway

Creates a new VindiciaGateway

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

Options

  • :login – Vindicia SOAP login (REQUIRED)

  • :password – Vindicia SOAP password (REQUIRED)

  • :api_version – Vindicia API Version - defaults to 3.6 (OPTIONAL)

  • :account_id – Account Id which all transactions will be run against. (REQUIRED)

  • :transaction_prefix – Prefix to order id for one-time transactions - defaults to ‘X’ (OPTIONAL

  • :min_chargeback_probability – Minimum score for chargebacks - defaults to 65 (OPTIONAL)

  • :cvn_success – Array of valid CVN Check return values - defaults to [M, P] (OPTIONAL)

  • :avs_success – Array of valid AVS Check return values - defaults to [X, Y, A, W, Z] (OPTIONAL)



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/active_merchant/billing/gateways/vindicia.rb', line 48

def initialize(options = {})
  requires!(options, :login, :password)
  super

  config = lambda do |config|
    config. = options[:login]
    config.password = options[:password]
    config.api_version = options[:api_version] || "3.6"
    config.endpoint = test? ? self.test_url : self.live_url
    config.namespace = "http://soap.vindicia.com"
  end

  if Vindicia.config.is_configured?
    config.call(Vindicia.config)
  else
    Vindicia.configure(&config)
  end

  requires!(options, :account_id)
  @account_id = options[:account_id]

  @transaction_prefix = options[:transaction_prefix] || "X"

  @min_chargeback_probability = options[:min_chargeback_probability] || 65
  @cvn_success = options[:cvn_success] || %w{M P}
  @avs_success = options[:avs_success] || %w{X Y A W Z}

  @allowed_authorization_statuses = %w{Authorized}
end

Instance Method Details

#authorize(money, creditcard, options = {}) ⇒ Object

Performs an authorization, which reserves the funds on the customer’s credit card, but does not charge the card.

Parameters

  • money – The amount to be authorized as an Integer value in cents.

  • creditcard – The CreditCard details for the transaction.

  • options – A hash of optional parameters.



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/active_merchant/billing/gateways/vindicia.rb', line 100

def authorize(money, creditcard, options = {})
  vindicia_transaction = authorize_transaction(money, creditcard, options)
  response = check_transaction(vindicia_transaction)

  # if this response is under fraud review because of our AVS/CVV checks void the transaction
  if !response.success? && response.fraud_review? && !response.authorization.blank?
    void_response = void([vindicia_transaction[:transaction][:merchantTransactionId]], options)
    if void_response.success?
      return response
    else
      return void_response
    end
  end

  response
end

#capture(money, identification, options = {}) ⇒ Object

Captures the funds from an authorized transaction.

Parameters

  • money – The amount to be captured as an Integer value in cents.

  • identification – The authorization returned from the previous authorize request.



123
124
125
126
127
128
129
130
131
132
133
# File 'lib/active_merchant/billing/gateways/vindicia.rb', line 123

def capture(money, identification, options = {})
  response = post(Vindicia::Transaction.capture({
    :transactions => [{ :merchantTransactionId => identification }]
  }))

  if response[:return][:returnCode] != '200' || response[:qtyFail].to_i > 0
    return fail(response)
  end

  success(response, identification)
end

#purchase(money, creditcard, options = {}) ⇒ Object

Perform a purchase, which is essentially an authorization and capture in a single operation.

Parameters

  • money – The amount to be purchased as an Integer value in cents.

  • creditcard – The CreditCard details for the transaction.

  • options – A hash of optional parameters.



85
86
87
88
89
90
# File 'lib/active_merchant/billing/gateways/vindicia.rb', line 85

def purchase(money, creditcard, options = {})
  response = authorize(money, creditcard, options)
  return response if !response.success? || response.fraud_review?

  capture(money, response.authorization, options)
end

#recurring(money, creditcard, options = {}) ⇒ Object

Perform a recurring billing, which is essentially a purchase and autobill setup in a single operation.

Parameters

  • money – The amount to be purchased as an Integer value in cents.

  • creditcard – The CreditCard details for the transaction.

  • options – A hash of parameters.

Options

  • :product_sku – The subscription product’s sku

  • :autobill_prefix – Prefix to order id for subscriptions - defaults to ‘A’ (OPTIONAL)



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/active_merchant/billing/gateways/vindicia.rb', line 169

def recurring(money, creditcard, options={})
  options[:recurring] = true
  @autobill_prefix = options[:autobill_prefix] || "A"

  response = authorize(money, creditcard, options)
  return response if !response.success? || response.fraud_review?

  capture_resp = capture(money, response.authorization, options)
  return capture_resp if !response.success?

  # Setting up a recurring AutoBill requires an associated product
  requires!(options, :product_sku)
  autobill_response = check_subscription(authorize_subscription(options.merge(:product_sku => options[:product_sku])))

  if autobill_response.success?
    autobill_response
  else
    # If the AutoBill fails to set-up, void the transaction and return it as the response
    void_response = void(capture_resp.authorization, options)
    if void_response.success?
      return autobill_response
    else
      return void_response
    end
  end
end

#void(identification, options = {}) ⇒ Object

Void a previous transaction

Parameters

  • identification - The authorization returned from the previous authorize request.

  • options - Extra options (currently only :ip used)



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/active_merchant/billing/gateways/vindicia.rb', line 141

def void(identification, options = {})
  response = post(Vindicia::Transaction.cancel({
    :transactions => [{
      :account => { :merchantAccountId => @account_id },
      :merchantTransactionId => identification,
      :sourceIp => options[:ip]
    }]
  }))

  if response[:return][:returnCode] == '200' && response[:qtyFail].to_i == 0
    success(response, identification)
  else
    fail(response)
  end
end