Class: ActiveMerchant::Billing::DataCashGateway
- 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'
- REFUND_TYPE =
'refund'
- TRANSACTION_REFUND_TYPE =
'txn_refund'
- 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
Constants included from PostsData
PostsData::MAX_RETRIES, PostsData::OPEN_TIMEOUT, PostsData::READ_TIMEOUT
Instance Attribute Summary
Attributes inherited from Gateway
Instance Method Summary collapse
-
#authorize(money, authorization_or_credit_card, options = {}) ⇒ Object
Performs an authorization, which reserves the funds on the customer’s credit card, but does not charge the card.
-
#capture(money, authorization, options = {}) ⇒ Object
Captures the funds from an authorized transaction.
-
#credit(money, reference_or_credit_card, options = {}) ⇒ Object
Refund to a card.
-
#initialize(options = {}) ⇒ DataCashGateway
constructor
Creates a new DataCashGateway.
-
#purchase(money, authorization_or_credit_card, options = {}) ⇒ Object
Perform a purchase, which is essentially an authorization and capture in a single operation.
-
#test? ⇒ Boolean
Is the gateway running in test mode?.
-
#void(authorization, options = {}) ⇒ Object
Void a previous transaction.
Methods inherited from Gateway
#card_brand, card_brand, inherited, supports?
Methods included from Utils
Methods included from CreditCardFormatting
Methods included from RequiresParameters
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.
52 53 54 55 56 |
# File 'lib/active_merchant/billing/gateways/data_cash.rb', line 52 def initialize( = {}) requires!(, :login, :password) @options = super end |
Instance Method Details
#authorize(money, authorization_or_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. authorization_or_credit_card
-
The continuous authority reference or CreditCard details for the transaction.
-
options
A hash of optional parameters.-
:order_id
A unique reference for this order (corresponds to merchantreference in datacash documentation) :set_up_continuous_authority
-
Set to true to set up a recurring historic transaction account be set up. Only supported for :visa, :master and :american_express card types See www.datacash.com/services/recurring/historic.php for more details of historic transactions.
:address
-
billing address for card
-
The continuous authority reference will be available in response#params if you have requested one
100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/active_merchant/billing/gateways/data_cash.rb', line 100 def (money, , = {}) requires!(, :order_id) if .is_a?(String) request = (AUTH_TYPE, money, , ) else request = (PRE_TYPE, money, , ) end commit(request) 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.
118 119 120 |
# File 'lib/active_merchant/billing/gateways/data_cash.rb', line 118 def capture(money, , = {}) commit(build_void_or_capture_request(FULFILL_TYPE, money, , )) end |
#credit(money, reference_or_credit_card, options = {}) ⇒ Object
Refund to a card
Parameters
-
money
The amount to be refunded. Either an Integer value in cents or a Money object. Set to nil for a full refund on existing transaction. -
reference_or_credit_card
The credit card you want to refund OR the datacash_reference for the existing transaction you are refunding -
options
Are ignored when refunding via reference to an existing transaction, otherwise-
:order_id
A unique reference for this order (corresponds to merchantreference in datacash documentation) :address
-
billing address for card
-
142 143 144 145 146 147 148 149 150 |
# File 'lib/active_merchant/billing/gateways/data_cash.rb', line 142 def credit(money, reference_or_credit_card, = {}) if reference_or_credit_card.is_a?(String) request = build_transaction_refund_request(money, reference_or_credit_card) else request = build_refund_request(money, reference_or_credit_card, ) end commit(request) end |
#purchase(money, authorization_or_credit_card, options = {}) ⇒ Object
Perform a purchase, which is essentially an authorization and capture in a single operation.
Parameters
-
money
The amount to be authorized. Either an Integer value in cents or a Money object. authorization_or_credit_card
-
The continuous authority reference or CreditCard details for the transaction.
-
options
A hash of optional parameters.-
:order_id
A unique reference for this order (corresponds to merchantreference in datacash documentation) -
:set_up_continuous_authority
Set to true to set up a recurring historic transaction account be set up. Only supported for :visa, :master and :american_express card types See http://www.datacash.com/services/recurring/historic.php for more details of historic transactions.
:address
-
billing address for card
-
The continuous authority reference will be available in response#params if you have requested one
72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/active_merchant/billing/gateways/data_cash.rb', line 72 def purchase(money, , = {}) requires!(, :order_id) if .is_a?(String) request = (AUTH_TYPE, money, , ) else request = (AUTH_TYPE, money, , ) end commit(request) end |
#test? ⇒ Boolean
Is the gateway running in test mode?
153 154 155 |
# File 'lib/active_merchant/billing/gateways/data_cash.rb', line 153 def test? @options[:test] || super end |
#void(authorization, options = {}) ⇒ Object
Void a previous transaction
Parameters
-
authorization
- The authorization returned from the previous authorize request.
127 128 129 130 131 |
# File 'lib/active_merchant/billing/gateways/data_cash.rb', line 127 def void(, = {}) request = build_void_or_capture_request(CANCEL_TYPE, nil, , ) commit(request) end |