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, Gateway::RECURRING_DEPRECATION_MESSAGE

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#card_brand, card_brand, #generate_unique_id, inherited, supported_countries, #supported_countries, supported_countries=, supports?, #test?

Methods included from CreditCardFormatting

#expdate, #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)



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/active_merchant/billing/gateways/vindicia.rb', line 42

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

  @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.



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/active_merchant/billing/gateways/vindicia.rb', line 79

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.



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

def capture(money, identification, options = {})
  response = post(:capture) do |xml|
    add_hash(xml, transactions: [{ merchantTransactionId: identification }])
  end

  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.



64
65
66
67
68
69
# File 'lib/active_merchant/billing/gateways/vindicia.rb', line 64

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)



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/active_merchant/billing/gateways/vindicia.rb', line 148

def recurring(money, creditcard, options={})
  ActiveMerchant.deprecated RECURRING_DEPRECATION_MESSAGE

  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)



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

def void(identification, options = {})
  response = post(:cancel) do |xml|
    add_hash(xml, transactions: [{
      account: {merchantAccountId: @account_id},
      merchantTransactionId: identification,
      sourceIp: options[:ip]
    }])
  end

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