Class: ActiveMerchant::Billing::DataCashGateway

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

Constant Summary collapse

TEST_URL =

Datacash server URLs

'https://testserver.datacash.com/Transaction'
LIVE_URL =
'https://mars.transaction.datacash.com/Transaction'
AUTH_TYPE =

Different Card Transaction Types

'auth'
CANCEL_TYPE =
'cancel'
FULFILL_TYPE =
'fulfill'
PRE_TYPE =
'pre'
POLICY_ACCEPT =

Constant strings for use in the ExtendedPolicy complex element for CV2 checks

'accept'
POLICY_REJECT =
'reject'
DATACASH_SUCCESS =

Datacash success code

'1'

Constants inherited from Gateway

Gateway::DEBIT_CARDS

Constants included from PostsData

PostsData::MAX_RETRIES, PostsData::OPEN_TIMEOUT, PostsData::READ_TIMEOUT

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

inherited, supports?

Methods included from Utils

generate_unique_id

Methods included from CreditCardFormatting

#format

Methods included from RequiresParameters

#requires!

Methods included from PostsData

included, #retry_exceptions, #ssl_post

Constructor Details

#initialize(options = {}) ⇒ DataCashGateway

Creates a new DataCashGateway

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

Options

  • :login – The Datacash account login.

  • :password – The Datacash account password.

  • :test => true or false – Use the test or live Datacash url.



49
50
51
52
53
# File 'lib/active_merchant/billing/gateways/data_cash.rb', line 49

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

Instance Method Details

#authorize(money, credit_card, 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. Either an Integer value in cents or a Money object.

  • credit_card – The CreditCard details for the transaction.

  • options – A hash of optional parameters.



74
75
76
# File 'lib/active_merchant/billing/gateways/data_cash.rb', line 74

def authorize(money, credit_card, options = {})
  commit(build_purchase_or_authorization_request(PRE_TYPE, money, credit_card, options))
end

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

Captures the funds from an authorized transaction.

Parameters

  • money – The amount to be captured. Either an Integer value in cents or a Money object.

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



84
85
86
# File 'lib/active_merchant/billing/gateways/data_cash.rb', line 84

def capture(money, authorization, options = {})
  commit(build_void_or_capture_request(FULFILL_TYPE, money, authorization, options))
end

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

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

Parameters

  • money – The amount to be purchased. Either an Integer value in cents or a Money object.

  • credit_card – The CreditCard details for the transaction.

  • options – A hash of optional parameters.



62
63
64
# File 'lib/active_merchant/billing/gateways/data_cash.rb', line 62

def purchase(money, credit_card, options = {})
  commit(build_purchase_or_authorization_request(AUTH_TYPE, money, credit_card, options))
end

#test?Boolean

Is the gateway running in test mode?

Returns:

  • (Boolean)


100
101
102
# File 'lib/active_merchant/billing/gateways/data_cash.rb', line 100

def test?
  @options[:test] || super
end

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

Void a previous transaction

Parameters

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



93
94
95
96
97
# File 'lib/active_merchant/billing/gateways/data_cash.rb', line 93

def void(authorization, options = {})
  request = build_void_or_capture_request(CANCEL_TYPE, nil, authorization, options)
  
  commit(request)
end