Class: ActiveMerchant::Billing::FirstData::Gateway

Inherits:
Gateway
  • Object
show all
Defined in:
lib/active_merchant/billing/first_data/gateway.rb

Defined Under Namespace

Classes: Error

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Gateway

Creates a new FirstDataGateway

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

Parameters:

  • (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :pem (String)

    First Data cert/key (REQUIRED)

  • :pem_password (String)

    First Data cert password (REQUIRED)



37
38
39
40
41
# File 'lib/active_merchant/billing/first_data/gateway.rb', line 37

def initialize(options = {})
  requires!(options, :pem, :pem_password)
  @options = options
  super
end

Instance Method Details

#authorize(amount, params = {}) ⇒ ActiveSupport::HashWithIndifferentAccess

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

Registering of DMS authorisation

Parameters:

  • transaction amount in minor units, mandatory

  • (defaults to: {})

    a customizable set of options

Options Hash (params):

  • :currency (Integer, String)

    transaction currency code, mandatory

  • :client_ip_addr (String)

    client’s IP address, mandatory

  • :description (String)

    description of transaction, optional

  • :language (String)

    authorization language identificator, optional

Returns:

  • TRANSACTION_ID



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/active_merchant/billing/first_data/gateway.rb', line 77

def authorize(amount, params = {})
  params = params.reverse_merge(
    :command => :a,
    :msg_type => 'DMS',
    :amount => amount,
    :currency => default_currency
  )
  lookup_currency(params)
  requires!(params, :amount, :currency, :client_ip_addr, :msg_type)
  commit(params)
end

#capture(amount, trans_id, params = {}) ⇒ ActiveSupport::HashWithIndifferentAccess

Captures the funds from an authorized transaction.

Making of DMS transaction

Parameters:

  • transaction amount in minor units, mandatory

  • id of previously made successeful authorisation

  • (defaults to: {})

    a customizable set of options

Options Hash (params):

  • :currency (Integer, String)

    transaction currency code, mandatory

  • :client_ip_addr (String)

    client’s IP address, mandatory

  • :description (String)

    description of transaction, optional

Returns:

  • RESULT, RESULT_CODE, RRN, APPROVAL_CODE



100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/active_merchant/billing/first_data/gateway.rb', line 100

def capture(amount, trans_id, params = {})
  params = params.reverse_merge(
    :command => :t,
    :msg_type => 'DMS',
    :trans_id => trans_id,
    :amount => amount,
    :currency => default_currency
  )
  lookup_currency(params)
  requires!(params, :trans_id, :amount, :currency, :client_ip_addr)
  commit(params)
end

#close_dayObject

Close business day.



235
236
237
# File 'lib/active_merchant/billing/first_data/gateway.rb', line 235

def close_day
  commit({ :command => :b })
end

#credit(amount, trans_id = nil) ⇒ Object



146
147
148
149
# File 'lib/active_merchant/billing/first_data/gateway.rb', line 146

def credit(amount, trans_id = nil)
  deprecated CREDIT_DEPRECATION_MESSAGE
  refund(amount, trans_id)
end

#endpoint_urlObject



239
240
241
# File 'lib/active_merchant/billing/first_data/gateway.rb', line 239

def endpoint_url
  test? ? test_url : live_url
end

#execute_recurring(amount, params = {}) ⇒ ActiveSupport::HashWithIndifferentAccess

Execute subsequent recurring payment

Parameters:

  • transaction amount in minor units, mandatory (up to 12 digits)

  • (defaults to: {})

    a customizable set of options

Options Hash (params):

  • :currency (Integer, String)

    transaction currency code, mandatory

  • :client_ip_addr (String)

    client’s IP address, mandatory (the same IP address which was provided when registered recurring payment)

  • :description (String)

    transaction details, mandatory (up to 125 characters)

  • :biller_client_id (String)

    recurring payment identifier, mandatory (up to 30 characters)

Returns:

  • TRANSACTION_ID, RESULT, RESULT_CODE, RRN, APPROVAL_CODE



193
194
195
196
197
198
199
200
201
202
# File 'lib/active_merchant/billing/first_data/gateway.rb', line 193

def execute_recurring(amount, params = {})
  params = params.reverse_merge(
    :command => :e,
    :amount => amount,
    :currency => default_currency
  )
  lookup_currency(params)
  requires!(params, :amount, :currency, :client_ip_addr, :description, :biller_client_id)
  commit(params)
end

#purchase(amount, params = {}) ⇒ ActiveSupport::HashWithIndifferentAccess

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

Registering of SMS transaction

Parameters:

  • transaction amount in minor units, mandatory

  • (defaults to: {})

    a customizable set of options

Options Hash (params):

  • :currency (Integer, String)

    transaction currency code, mandatory

  • :client_ip_addr (String)

    client’s IP address, mandatory

  • :description (String)

    description of transaction, optional

  • :language (String)

    authorization language identificator, optional

Returns:

  • TRANSACTION_ID



54
55
56
57
58
59
60
61
62
63
# File 'lib/active_merchant/billing/first_data/gateway.rb', line 54

def purchase(amount, params = {})
  params = params.reverse_merge(
    :command => :v,
    :amount => amount,
    :currency => default_currency
  )
  lookup_currency(params)
  requires!(params, :amount, :currency, :client_ip_addr)
  commit(params)
end

#recurring(amount, params = {}) ⇒ ActiveSupport::HashWithIndifferentAccess

Register new recurring payment along with the first payment

Afterwards when transaction result is requested then result response includes also RECC_PMNT_ID and RECC_PMNT_EXPIRY

Parameters:

  • transaction amount in minor units, mandatory (up to 12 digits)

  • (defaults to: {})

    a customizable set of options

Options Hash (params):

  • :currency (Integer, String)

    transaction currency code, mandatory

  • :client_ip_addr (String)

    client’s IP address, mandatory

  • :description (String)

    transaction details, mandatory (up to 125 characters)

  • :biller_client_id (String)

    recurring payment identifier, mandatory (up to 30 characters)

  • :perspayee_expiry (String)

    preferred deadline for a Recurring payment, mandatory (MMYY) (system will compare two expiry dates - recurring payment expiry date provided by Merchant and card expiry date provided by Cardholder. In response Merchant will receive back the earliest expiry dates of both). For example, Recurring payment date is 1214 but card expiry date 1213 then Merchant will receive back 1213. First Data system will save the earliest expiry date as Recurring payment expiry date.

  • :perspayee_overwrite (Integer)

    set to 1 to overwrite existing recurring payment card data together with payment, optional

  • :language (String)

    authorization language identificator, optional

Returns:

  • TRANSACTION_ID



170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/active_merchant/billing/first_data/gateway.rb', line 170

def recurring(amount, params = {})
  params = params.reverse_merge(
    :command => :z,
    :amount => amount,
    :currency => default_currency,
    :msg_type => 'SMS',
    :perspayee_gen => 1
  )
  lookup_currency(params)
  requires!(params, :amount, :currency, :client_ip_addr, :description, :biller_client_id, :perspayee_expiry)
  commit(params)
end

#redirect_url(trans_id = nil) ⇒ Object



243
244
245
246
247
# File 'lib/active_merchant/billing/first_data/gateway.rb', line 243

def redirect_url(trans_id = nil)
  url = test? ? test_redirect_url : live_redirect_url
  url += "?trans_id=#{CGI.escape trans_id}" if trans_id
  url
end

#refund(amount, trans_id = nil) ⇒ ActiveSupport::HashWithIndifferentAccess

refund() allows you to return money to a card that was previously billed.

Transaction reversal

Parameters:

  • transaction amount in minor units, mandatory

  • (defaults to: nil)

    transaction identifier, mandatory

Returns:

  • RESULT, RESULT_CODE



136
137
138
139
140
141
142
143
144
# File 'lib/active_merchant/billing/first_data/gateway.rb', line 136

def refund(amount, trans_id = nil)
  params = {
    :command => :r,
    :trans_id => trans_id,
    :amount => amount
  }
  requires!(params, :command, :trans_id, :amount)
  commit(params)
end

#result(trans_id, params = {}) ⇒ ActiveSupport::HashWithIndifferentAccess

Transaction result

Parameters:

  • transaction identifier, mandatory

  • (defaults to: {})

    a customizable set of options

Options Hash (params):

  • :client_ip_addr (String)

    client’s IP address, mandatory

Returns:

  • RESULT, RESULT_CODE, 3DSECURE, AAV, RRN, APPROVAL_CODE



119
120
121
122
123
124
125
126
# File 'lib/active_merchant/billing/first_data/gateway.rb', line 119

def result(trans_id, params = {})
  params = params.reverse_merge(
    :command => :c,
    :trans_id => trans_id
  )
  requires!(params, :trans_id, :client_ip_addr)
  commit(params)
end

#update_recurring(params = {}) ⇒ ActiveSupport::HashWithIndifferentAccess

Overwriting existing recurring payment card data without payment

Afterwards when transaction result is requested then result response includes also RECC_PMNT_ID and RECC_PMNT_EXPIRY

Parameters:

  • (defaults to: {})

    a customizable set of options

Options Hash (params):

  • :currency (Integer, String)

    transaction currency code, mandatory

  • :client_ip_addr (String)

    client’s IP address, mandatory

  • :description (String)

    transaction details, mandatory (up to 125 characters)

  • :biller_client_id (String)

    existing recurring payment identifier, mandatory (up to 30 characters)

  • :perspayee_expiry (String)

    preferred deadline for a Recurring payment, mandatory (MMYY) (system will compare two expiry dates - recurring payment expiry date provided by Merchant and card expiry date provided by Cardholder. In response Merchant will receive back the earliest expiry dates of both). For example, Recurring payment date is 1214 but card expiry date 1213 then Merchant will receive back 1213. First Data system will save the earliest expiry date as Recurring payment expiry date.

  • :language (String)

    authorization language identificator, optional

Returns:

  • TRANSACTION_ID



220
221
222
223
224
225
226
227
228
229
230
231
232
# File 'lib/active_merchant/billing/first_data/gateway.rb', line 220

def update_recurring(params = {})
  params = params.reverse_merge(
    :command => :p,
    :amount => 0,
    :currency => default_currency,
    :msg_type => 'AUTH',
    :perspayee_gen => 1,
    :perspayee_overwrite => 1
  )
  lookup_currency(params)
  requires!(params, :currency, :client_ip_addr, :description, :biller_client_id, :perspayee_expiry)
  commit(params)
end