Class: ActiveMerchant::Billing::LinkpointGateway

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

Overview

Initialization Options :login Your store number :pem The text of your linkpoint PEM file. Note

this is not the path to file, but its
contents. If you are only using one PEM
file on your site you can declare it
globally and then you won't need to
include this option

A valid store number is required. Unfortunately, with LinkPoint YOU CAN’T JUST USE ANY OLD STORE NUMBER. Also, you can’t just generate your own PEM file. You’ll need to use a special PEM file provided by LinkPoint.

Go to www.linkpoint.com/support/sup_teststore.asp to set up a test account and obtain your PEM file.

Declaring PEM file Globally ActiveMerchant::Billing::LinkpointGateway.pem_file = File.read( File.dirname(__FILE__) + ‘/../mycert.pem’ )

Valid Order Options :result =>

LIVE                  Production mode
GOOD                  Approved response in test mode
DECLINE               Declined response in test mode
DUPLICATE             Duplicate response in test mode

:ponumber Order number

:transactionorigin => Source of the transaction

ECI                  Email or Internet
MAIL                 Mail order
MOTO                 Mail order/Telephone
TELEPHONE            Telephone
RETAIL               Face-to-face

:ordertype =>

SALE                 Real live sale
PREAUTH              Authorize only
POSTAUTH             Forced Ticket or Ticket Only transaction
VOID
CREDIT
CALCSHIPPING         For shipping charges calculations
CALCTAX              For sales tax calculations

Recurring Options :action =>

SUBMIT
MODIFY
CANCEL

:installments Identifies how many recurring payments to charge the customer :startdate Date to begin charging the recurring payments. Format: YYYYMMDD or “immediate” :periodicity =>

MONTHLY
BIMONTHLY
WEEKLY
BIWEEKLY
YEARLY
DAILY

:threshold Tells how many times to retry the transaction (if it fails) before contacting the merchant. :comments Uh… comments

For reference:

www.linkpointcentral.com/lpc/docs/Help/APIHelp/lpintguide.htm

Entities = {
  :payment => [:subtotal, :tax, :vattax, :shipping, :chargetotal],
  :billing => [:name, :address1, :address2, :city, :state, :zip, :country, :email, :phone, :fax, :addrnum],
  :shipping => [:name, :address1, :address2, :city, :state, :zip, :country, :weight, :items, :carrier, :total],
  :creditcard => [:cardnumber, :cardexpmonth, :cardexpyear, :cvmvalue, :track],
  :telecheck => [:routing, :account, :checknumber, :bankname, :bankstate, :dl, :dlstate, :void, :accounttype, :ssn],
  :transactiondetails => [:transactionorigin, :oid, :ponumber, :taxexempt, :terminaltype, :ip, :reference_number, :recurring, :tdate],
  :periodic => [:action, :installments, :threshold, :startdate, :periodicity, :comments],
  :notes => [:comments, :referred]
  :items => [:item => [:price, :quantity, :description, :id, :options => [:option => [:name, :value]]]]
}

LinkPoint’s Items entity is an optional entity that can be attached to orders. It is entered as :line_items to be consistent with the CyberSource implementation

The line_item hash goes in the options hash and should look like

:line_items => [
  {
    :id => '123456',
    :description => 'Logo T-Shirt',
    :price => '12.00',
    :quantity => '1',
    :options => [
      {
        :name => 'Color',
        :value => 'Red'
      },
      {
        :name => 'Size',
        :value => 'XL'
      }
    ]
  },
  {
    :id => '111',
    :description => 'keychain',
    :price => '3.00',
    :quantity => '1'
  }
]

This functionality is only supported by this particular gateway may be changed at any time

Constant Summary

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::DEBIT_CARDS, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE

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?, #supports_network_tokenization?, #supports_scrubbing?, #test?

Methods included from CreditCardFormatting

#expdate, #format

Methods included from PostsData

included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request

Constructor Details

#initialize(options = {}) ⇒ LinkpointGateway

Returns a new instance of LinkpointGateway.

Raises:

  • (ArgumentError)


138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/active_merchant/billing/gateways/linkpoint.rb', line 138

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

  @options = {
    :result => 'LIVE',
    :pem => LinkpointGateway.pem_file
  }.update(options)

  raise ArgumentError, "You need to pass in your pem file using the :pem parameter or set it globally using ActiveMerchant::Billing::LinkpointGateway.pem_file = File.read( File.dirname(__FILE__) + '/../mycert.pem' ) or similar" if @options[:pem].blank?

  @options[:pem].strip!
end

Instance Method Details

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

Authorize the transaction

Reserves the funds on the customer’s credit card, but does not charge the card.



201
202
203
204
205
206
207
# File 'lib/active_merchant/billing/gateways/linkpoint.rb', line 201

def authorize(money, creditcard, options = {})
  requires!(options, :order_id)
  options.update(
    :ordertype => "PREAUTH"
  )
  commit(money, creditcard, options)
end

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

Post an authorization.

Captures the funds from an authorized transaction. Order_id must be a valid order id from a prior authorized transaction.



215
216
217
218
219
220
221
# File 'lib/active_merchant/billing/gateways/linkpoint.rb', line 215

def capture(money, authorization, options = {})
  options.update(
    :order_id => authorization,
    :ordertype => "POSTAUTH"
  )
  commit(money, nil, options)
end

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



245
246
247
248
# File 'lib/active_merchant/billing/gateways/linkpoint.rb', line 245

def credit(money, identification, options = {})
  ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
  refund(money, identification, options)
end

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

Buy the thing



188
189
190
191
192
193
194
# File 'lib/active_merchant/billing/gateways/linkpoint.rb', line 188

def purchase(money, creditcard, options={})
  requires!(options, :order_id)
  options.update(
    :ordertype => "SALE"
  )
  commit(money, creditcard, options)
end

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

Send a purchase request with periodic options Recurring Options :action =>

SUBMIT
MODIFY
CANCEL

:installments Identifies how many recurring payments to charge the customer :startdate Date to begin charging the recurring payments. Format: YYYYMMDD or “immediate” :periodicity =>

:monthly
:bimonthly
:weekly
:biweekly
:yearly
:daily

:threshold Tells how many times to retry the transaction (if it fails) before contacting the merchant. :comments Uh… comments



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/active_merchant/billing/gateways/linkpoint.rb', line 170

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

  requires!(options, [:periodicity, :bimonthly, :monthly, :biweekly, :weekly, :yearly, :daily], :installments, :order_id )

  options.update(
    :ordertype => "SALE",
    :action => options[:action] || "SUBMIT",
    :installments => options[:installments] || 12,
    :startdate => options[:startdate] || "immediate",
    :periodicity => options[:periodicity].to_s || "monthly",
    :comments => options[:comments] || nil,
    :threshold => options[:threshold] || 3
  )
  commit(money, creditcard, options)
end

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

Refund an order

identification must be a valid order id previously submitted by SALE



237
238
239
240
241
242
243
# File 'lib/active_merchant/billing/gateways/linkpoint.rb', line 237

def refund(money, identification, options = {})
  options.update(
    :ordertype => "CREDIT",
    :order_id => identification
  )
  commit(money, nil, options)
end

#scrub(transcript) ⇒ Object



254
255
256
257
258
259
# File 'lib/active_merchant/billing/gateways/linkpoint.rb', line 254

def scrub(transcript)
  transcript.
    gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
    gsub(%r((<cardnumber>)\d+(</cardnumber>))i, '\1[FILTERED]\2').
    gsub(%r((<cvmvalue>)\d+(</cvmvalue>))i, '\1[FILTERED]\2')
end

#supports_scrubbingObject



250
251
252
# File 'lib/active_merchant/billing/gateways/linkpoint.rb', line 250

def supports_scrubbing
  true
end

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

Void a previous transaction



224
225
226
227
228
229
230
# File 'lib/active_merchant/billing/gateways/linkpoint.rb', line 224

def void(identification, options = {})
  options.update(
    :order_id => identification,
    :ordertype => "VOID"
  )
  commit(nil, nil, options)
end