Class: BluePay

Inherits:
Object
  • Object
show all
Defined in:
lib/bluepay.rb,
lib/api_request.rb,
lib/api_response.rb

Constant Summary collapse

SERVER =
"secure.bluepay.com"
RootCA =

Make sure this is the correct path to your CA certificates directory

"/"
RootCAFile =
"cacert.pem"

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ BluePay

Returns a new instance of BluePay.



16
17
18
19
20
# File 'lib/bluepay.rb', line 16

def initialize(params = {})
  @ACCOUNT_ID = params[:account_id]
  @SECRET_KEY = params[:secret_key]
  @PARAM_HASH = {'MODE' => params[:mode]}
end

Instance Method Details

#add_def_protected_status(string) ⇒ Object

Adds optional protected keys to a string. Must be used with generate_url.



493
494
495
496
497
498
499
# File 'lib/bluepay.rb', line 493

def add_def_protected_status(string)
  string.concat(' AMOUNT') if @PARAM_HASH['PROTECT_AMOUNT'] == 'Yes'
  string.concat(' REBILLING REB_CYCLES REB_AMOUNT REB_EXPR REB_FIRST_DATE') if @PARAM_HASH['REB_PROTECT'] == 'Yes'
  string.concat(' CUSTOM_ID') if @PARAM_HASH['PROTECT_CUSTOM_ID'] == 'Yes'
  string.concat(' CUSTOM_ID2') if @PARAM_HASH['PROTECT_CUSTOM_ID2'] == 'Yes'
  return string 
end

#add_level2_information(params) ⇒ Object

Adds information required for level 2 processing.



177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/bluepay.rb', line 177

def add_level2_information(params)
  @PARAM_HASH['LV2_ITEM_TAX_RATE'] = params[:tax_rate] || ''
  @PARAM_HASH['LV2_ITEM_GOODS_TAX_RATE'] = params[:goods_tax_rate] || ''
  @PARAM_HASH['LV2_ITEM_GOODS_TAX_AMOUNT'] = params[:goods_tax_amount] || ''
  @PARAM_HASH['LV2_ITEM_SHIPPING_AMOUNT'] = params[:shipping_amount] || ''
  @PARAM_HASH['LV2_ITEM_DISCOUNT_AMOUNT'] = params[:discount_amount] || ''
  @PARAM_HASH['LV2_ITEM_CUST_PO'] = params[:cust_po] || ''
  @PARAM_HASH['LV2_ITEM_GOODS_TAX_ID'] = params[:goods_tax_id] || ''
  @PARAM_HASH['LV2_ITEM_TAX_ID'] = params[:tax_id] || ''
  @PARAM_HASH['LV2_ITEM_CUSTOMER_TAX_ID'] = params[:customer_tax_id] || ''
  @PARAM_HASH['LV2_ITEM_DUTY_AMOUNT'] = params[:duty_amount] || ''
  @PARAM_HASH['LV2_ITEM_SUPPLEMENTAL_DATA'] = params[:supplemental_data] || ''
  @PARAM_HASH['LV2_ITEM_CITY_TAX_RATE'] = params[:city_tax_rate] || ''
  @PARAM_HASH['LV2_ITEM_CITY_TAX_AMOUNT'] = params[:city_tax_amount] || ''
  @PARAM_HASH['LV2_ITEM_COUNTY_TAX_RATE'] = params[:county_tax_rate] || ''
  @PARAM_HASH['LV2_ITEM_COUNTY_TAX_AMOUNT'] = params[:county_tax_amount] || ''
  @PARAM_HASH['LV2_ITEM_STATE_TAX_RATE'] = params[:state_tax_rate] || ''
  @PARAM_HASH['LV2_ITEM_STATE_TAX_AMOUNT'] = params[:state_tax_amount] || ''
  @PARAM_HASH['LV2_ITEM_BUYER_NAME'] = params[:buyer_name] || ''
  @PARAM_HASH['LV2_ITEM_CUSTOMER_REFERENCE'] = params[:customer_reference] || ''
  @PARAM_HASH['LV2_ITEM_CUSTOMER_NUMBER'] = params[:customer_number] || ''
  @PARAM_HASH['LV2_ITEM_SHIP_NAME'] = params[:ship_name] || ''
  @PARAM_HASH['LV2_ITEM_SHIP_ADDR1'] = params[:ship_addr1] || ''
  @PARAM_HASH['LV2_ITEM_SHIP_ADDR2'] = params[:ship_addr2] || ''
  @PARAM_HASH['LV2_ITEM_SHIP_CITY'] = params[:ship_city] || ''
  @PARAM_HASH['LV2_ITEM_SHIP_STATE'] = params[:ship_state] || ''
  @PARAM_HASH['LV2_ITEM_SHIP_ZIP'] = params[:ship_zip] || ''
  @PARAM_HASH['LV2_ITEM_SHIP_COUNTRY'] = params[:ship_country] || ''
end

#add_line_item(params) ⇒ Object

Adds a line item for level 3 processing. Repeat method for each item up to 99 items. For Canadian and AMEX processors, ensure required Level 2 information is present.



209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/bluepay.rb', line 209

def add_line_item(params)
  # Creates line items counter necessary for prefix.
  @LINE_ITEMS = 0 if !@LINE_ITEMS                                                              
  @LINE_ITEMS += 1                                                              #  VALUE REQUIRED IN:
  prefix = "LV3_ITEM#{@LINE_ITEMS}_"                                            #  USA | CANADA
  @PARAM_HASH[prefix + 'UNIT_COST'] = params[:unit_cost]                        #   *      *
  @PARAM_HASH[prefix + 'QUANTITY'] = params[:quantity]                          #   *      *
  @PARAM_HASH[prefix + 'ITEM_SKU'] = params[:item_sku] || ''                    #          *
  @PARAM_HASH[prefix + 'ITEM_DESCRIPTOR'] = params[:descriptor] || ''           #   *      *
  @PARAM_HASH[prefix + 'COMMODITY_CODE'] = params[:commodity_code] || ''        #   *      *
  @PARAM_HASH[prefix + 'PRODUCT_CODE'] = params[:product_code] || ''            #   *    
  @PARAM_HASH[prefix + 'MEASURE_UNITS'] = params[:measure_units] || ''          #   *      *
  @PARAM_HASH[prefix + 'ITEM_DISCOUNT'] = params[:item_discount] || ''          #          *
  @PARAM_HASH[prefix + 'TAX_RATE'] = params[:tax_rate] || ''                    #   *    
  @PARAM_HASH[prefix + 'GOODS_TAX_RATE'] = params[:goods_tax_rate] || ''        #          *
  @PARAM_HASH[prefix + 'TAX_AMOUNT'] = params[:tax_amount] || ''                #   *    
  @PARAM_HASH[prefix + 'GOODS_TAX_AMOUNT'] = params[:goods_tax_amount] || ''    #          *
  @PARAM_HASH[prefix + 'CITY_TAX_RATE'] = params[:city_tax_rate] || ''          #
  @PARAM_HASH[prefix + 'CITY_TAX_AMOUNT'] = params[:city_tax_amount] || ''      #
  @PARAM_HASH[prefix + 'COUNTY_TAX_RATE'] = params[:county_tax_rate] || ''      #
  @PARAM_HASH[prefix + 'COUNTY_TAX_AMOUNT'] = params[:county_tax_amount] || ''  #
  @PARAM_HASH[prefix + 'STATE_TAX_RATE'] = params[:state_tax_rate] || ''        #
  @PARAM_HASH[prefix + 'STATE_TAX_AMOUNT'] = params[:state_tax_amount] || ''    #
  @PARAM_HASH[prefix + 'CUST_SKU'] = params[:cust_sku] || ''                    #
  @PARAM_HASH[prefix + 'CUST_PO'] = params[:cust_po] || ''                      #
  @PARAM_HASH[prefix + 'SUPPLEMENTAL_DATA'] = params[:supplemental_data] || ''  #
  @PARAM_HASH[prefix + 'GL_ACCOUNT_NUMBER'] = params[:gl_account_number] || ''  #
  @PARAM_HASH[prefix + 'DIVISION_NUMBER'] = params[:division_number] || ''      #
  @PARAM_HASH[prefix + 'PO_LINE_NUMBER'] = params[:po_line_number] || ''        #
  @PARAM_HASH[prefix + 'LINE_ITEM_TOTAL'] = params[:line_item_total] || ''      #   *     
end

#add_string_protected_status(string) ⇒ Object

Adds optional protected values to a string. Must be used with generate_url.



502
503
504
505
506
507
508
# File 'lib/bluepay.rb', line 502

def add_string_protected_status(string)
  string.concat(@PARAM_HASH['AMOUNT']) if @PARAM_HASH['PROTECT_AMOUNT'] == 'Yes'
  string.concat([@PARAM_HASH['REBILLING'], @PARAM_HASH['REB_CYCLES'], @PARAM_HASH['REB_AMOUNT'], @PARAM_HASH['REB_EXPR'], @PARAM_HASH['REB_FIRST_DATE']].join('')) if @PARAM_HASH['REB_PROTECT'] == 'Yes'
  string.concat(@PARAM_HASH['CUSTOM_ID']) if @PARAM_HASH['PROTECT_CUSTOM_ID'] == 'Yes'
  string.concat(@PARAM_HASH['CUSTOM_ID2']) if @PARAM_HASH['PROTECT_CUSTOM_ID2'] == 'Yes'
  return string 
end

#amount_food=(amount_food) ⇒ Object

Set AMOUNT_FOOD field



167
168
169
# File 'lib/bluepay.rb', line 167

def amount_food=(amount_food)
  @PARAM_HASH['AMOUNT_FOOD'] = amount_food
end

#amount_misc=(amount_misc) ⇒ Object

Set AMOUNT_MISC field



172
173
174
# File 'lib/bluepay.rb', line 172

def amount_misc=(amount_misc)
  @PARAM_HASH['AMOUNT_MISC'] = amount_misc
end

#amount_tax=(amount_tax) ⇒ Object

Set AMOUNT_TAX field



162
163
164
# File 'lib/bluepay.rb', line 162

def amount_tax=(amount_tax)
  @PARAM_HASH['AMOUNT_TAX'] = amount_tax
end

#amount_tip=(amount_tip) ⇒ Object

Set AMOUNT_TIP field



157
158
159
# File 'lib/bluepay.rb', line 157

def amount_tip=(amount_tip)
  @PARAM_HASH['AMOUNT_TIP'] = amount_tip
end

#auth(params = {}) ⇒ Object

Set up an Auth



54
55
56
57
58
59
# File 'lib/bluepay.rb', line 54

def auth(params ={})
  @PARAM_HASH['TRANSACTION_TYPE'] = 'AUTH'
  @PARAM_HASH['AMOUNT'] = params[:amount]
  @PARAM_HASH['RRNO'] = params[:trans_id] || ''
  @api = "bp10emu"
end

#calc_rebill_tpsObject

Sets TAMPER_PROOF_SEAL in @PARAM_HASH for rebadmin API



45
46
47
48
49
50
51
52
# File 'lib/api_request.rb', line 45

def calc_rebill_tps
  @PARAM_HASH["TAMPER_PROOF_SEAL"] = create_tps_hash(
    @ACCOUNT_ID +
    @PARAM_HASH["TRANS_TYPE"] + 
    @PARAM_HASH["REBILL_ID"], 
    @PARAM_HASH['TPS_HASH_TYPE']
  )
end

#calc_report_tpsObject

Sets TAMPER_PROOF_SEAL in @PARAM_HASH for bpdailyreport2 API



55
56
57
58
59
60
61
62
# File 'lib/api_request.rb', line 55

def calc_report_tps
  @PARAM_HASH["TAMPER_PROOF_SEAL"] = create_tps_hash(
    @ACCOUNT_ID + 
    @PARAM_HASH["REPORT_START_DATE"] + 
    @PARAM_HASH["REPORT_END_DATE"],
    @PARAM_HASH['TPS_HASH_TYPE']
    )
end

#calc_tpsObject

Sets TAMPER_PROOF_SEAL in @PARAM_HASH



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/api_request.rb', line 28

def calc_tps
  @PARAM_HASH["TAMPER_PROOF_SEAL"] = create_tps_hash(
      @ACCOUNT_ID + 
      (@PARAM_HASH["TRANSACTION_TYPE"] || '') + 
      @PARAM_HASH["AMOUNT"] + 
      (@PARAM_HASH["REBILLING"] || '') + 
      (@PARAM_HASH["REB_FIRST_DATE"] || '') + 
      (@PARAM_HASH["REB_EXPR"] || '') + 
      (@PARAM_HASH["REB_CYCLES"] || '') + 
      (@PARAM_HASH["REB_AMOUNT"] || '') + 
      (@PARAM_HASH["RRNO"] || '') + 
      @PARAM_HASH["MODE"], 
      @PARAM_HASH['TPS_HASH_TYPE']
    )
end

#calc_url_responseObject

Generates the final url for the Simple Hosted Payment Form. Must be used with generate_url.



526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
# File 'lib/bluepay.rb', line 526

def calc_url_response
  'https://secure.bluepay.com/interfaces/shpf?'                                     +
  'SHPF_FORM_ID='       .concat(url_encode    (@PARAM_HASH['SHPF_FORM_ID'])       ) +
  '&SHPF_ACCOUNT_ID='   .concat(url_encode    (@ACCOUNT_ID)                       ) +
  '&SHPF_TPS_DEF='      .concat(url_encode    (@shpf_tps_def)                     ) +
  '&SHPF_TPS_HASH_TYPE='.concat(url_encode    (@PARAM_HASH['SHPF_TPS_HASH_TYPE']) ) +
  '&SHPF_TPS='          .concat(url_encode    (@shpf_tamper_proof_seal)           ) +
  '&MODE='              .concat(url_encode    (@PARAM_HASH['MODE'])               ) +
  '&TRANSACTION_TYPE='  .concat(url_encode    (@PARAM_HASH['TRANSACTION_TYPE'])   ) +
  '&DBA='               .concat(url_encode    (@PARAM_HASH['DBA'])                ) +
  '&AMOUNT='            .concat(url_encode    (@PARAM_HASH['AMOUNT'])             ) +
  '&TAMPER_PROOF_SEAL=' .concat(url_encode    (@bp10emu_tamper_proof_seal)        ) +
  '&CUSTOM_ID='         .concat(url_encode    (@PARAM_HASH['CUSTOM_ID'])          ) +
  '&CUSTOM_ID2='        .concat(url_encode    (@PARAM_HASH['CUSTOM_ID2'])         ) +
  '&REBILLING='         .concat(url_encode    (@PARAM_HASH['REBILLING'])          ) +
  '&REB_CYCLES='        .concat(url_encode    (@PARAM_HASH['REB_CYCLES'])         ) +
  '&REB_AMOUNT='        .concat(url_encode    (@PARAM_HASH['REB_AMOUNT'])         ) +
  '&REB_EXPR='          .concat(url_encode    (@PARAM_HASH['REB_EXPR'])           ) +
  '&REB_FIRST_DATE='    .concat(url_encode    (@PARAM_HASH['REB_FIRST_DATE'])     ) +
  '&AMEX_IMAGE='        .concat(url_encode    (@PARAM_HASH['AMEX_IMAGE'])         ) +
  '&DISCOVER_IMAGE='    .concat(url_encode    (@PARAM_HASH['DISCOVER_IMAGE'])     ) +
  '&REDIRECT_URL='      .concat(url_encode    (@receipt_url)                      ) +
  '&TPS_DEF='           .concat(url_encode    (@bp10emu_tps_def)                  ) +
  '&TPS_HASH_TYPE='     .concat(url_encode    (@PARAM_HASH['TPS_HASH_TYPE'])      ) +
  '&CARD_TYPES='        .concat(url_encode    (@card_types)                       )
end

#calc_url_tps(tps_type) ⇒ Object

Generates a Tamperproof Seal for a url. Must be used with generate_url.



521
522
523
# File 'lib/bluepay.rb', line 521

def calc_url_tps(tps_type)
  Digest::MD5.hexdigest(tps_type)
end

#cancel_rebilling_cycle(rebill_id) ⇒ Object

Set fields to cancel an existing rebilling cycle



264
265
266
267
268
269
# File 'lib/bluepay.rb', line 264

def cancel_rebilling_cycle(rebill_id)
  @PARAM_HASH["TRANS_TYPE"] = "SET"
  @PARAM_HASH["STATUS"] = "stopped"
  @PARAM_HASH["REBILL_ID"] = rebill_id
  @api = "bp20rebadmin"
end

#capture(trans_id, amount = '') ⇒ Object

Capture an Auth



62
63
64
65
66
67
# File 'lib/bluepay.rb', line 62

def capture(trans_id, amount='')
  @PARAM_HASH['TRANSACTION_TYPE'] = 'CAPTURE'
  @PARAM_HASH['AMOUNT'] = amount
  @PARAM_HASH['RRNO'] = trans_id
  @api = "bp10emu"
end

#company_name=(company_name) ⇒ Object

Set COMPANY_NAME field



127
128
129
# File 'lib/bluepay.rb', line 127

def company_name=(company_name)
  @PARAM_HASH['COMPANY_NAME'] = company_name
end

#create_tps_hash(data, hash_type) ⇒ Object

Generates TPS hash based on given hash type



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/api_request.rb', line 12

def create_tps_hash(data, hash_type)
  case hash_type   
  when 'HMAC_SHA256'
    OpenSSL::HMAC.hexdigest('sha256', @SECRET_KEY, data)
  when 'SHA512'
    Digest::SHA512.hexdigest(@SECRET_KEY + data)
  when 'SHA256'
    Digest::SHA256.hexdigest(@SECRET_KEY + data)
  when 'MD5'
    Digest::MD5.hexdigest(@SECRET_KEY + data)
  else
    OpenSSL::HMAC.hexdigest('sha512', @SECRET_KEY, data)
  end
end

#custom_id1=(custom_id1) ⇒ Object

Set CUSTOM_ID field



137
138
139
# File 'lib/bluepay.rb', line 137

def custom_id1=(custom_id1)
  @PARAM_HASH['CUSTOM_ID'] = custom_id1
end

#custom_id2=(custom_id2) ⇒ Object

Set CUSTOM_ID2 field



142
143
144
# File 'lib/bluepay.rb', line 142

def custom_id2=(custom_id2)
  @PARAM_HASH['CUSTOM_ID2'] = custom_id2
end

#email=(email) ⇒ Object

Set customer E-mail address



122
123
124
# File 'lib/bluepay.rb', line 122

def email=(email)
  @PARAM_HASH['EMAIL'] = email
end

#generate_url(params = {}) ⇒ Object

Optional arguments for generate_url: reb_protect: Yes/No – Should the rebilling fields be protected by the tamperproof seal? reb_amount: Amount that will be charged when a recurring transaction occurs. reb_cycles: Number of times that the recurring transaction should occur. Not set if recurring transactions should continue until canceled. reb_start_date: Date (yyyy-mm-dd) or period (x units) until the first recurring transaction should occur. Possible units are DAY, DAYS, WEEK, WEEKS, MONTH, MONTHS, YEAR or YEARS. (ex. 2016-04-01 or 1 MONTH) reb_frequency: How often the recurring transaction should occur. Format is ‘X UNITS’. Possible units are DAY, DAYS, WEEK, WEEKS, MONTH, MONTHS, YEAR or YEARS. (ex. 1 MONTH) custom_id: A merchant defined custom ID value. protect_custom_id: Yes/No – Should the Custom ID value be protected from change using the tamperproof seal? custom_id2: A merchant defined custom ID 2 value. protect_custom_id2: Yes/No – Should the Custom ID 2 value be protected from change using the tamperproof seal?



383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
# File 'lib/bluepay.rb', line 383

def generate_url(params={})
  @PARAM_HASH['DBA'] = params[:merchant_name] 
  @PARAM_HASH['RETURN_URL'] = params[:return_url]  
  @PARAM_HASH['TRANSACTION_TYPE'] = params[:transaction_type]  
  @PARAM_HASH['DISCOVER_IMAGE'] = params[:accept_discover].start_with?("y","Y") ? "discvr.gif" : "spacer.gif"
  @PARAM_HASH['AMEX_IMAGE'] = params[:accept_amex].start_with?("y","Y") ? "amex.gif" : "spacer.gif"
  @PARAM_HASH['AMOUNT'] = params[:amount] || '' 
  @PARAM_HASH['PROTECT_AMOUNT'] = params[:protect_amount] || "No" 
  @PARAM_HASH['REBILLING'] = params[:rebilling].start_with?("y","Y") ? "1" : "0"
  @PARAM_HASH['REB_PROTECT'] = params[:reb_protect] || 'Yes' 
  @PARAM_HASH['REB_AMOUNT'] = params[:reb_amount] || '' 
  @PARAM_HASH['REB_CYCLES'] = params[:reb_cycles] || '' 
  @PARAM_HASH['REB_FIRST_DATE'] = params[:reb_start_date] || ''  
  @PARAM_HASH['REB_EXPR'] = params[:reb_frequency] || '' 
  @PARAM_HASH['CUSTOM_ID'] = params[:custom_id] || ''  
  @PARAM_HASH['PROTECT_CUSTOM_ID'] = params[:protect_custom_id] || "No"
  @PARAM_HASH['CUSTOM_ID2'] = params[:custom_id2] || ''  
  @PARAM_HASH['PROTECT_CUSTOM_ID2'] = params[:protect_custom_id2] || "No" 
  @PARAM_HASH['SHPF_FORM_ID'] = params[:payment_template] || "mobileform01"
  @PARAM_HASH['RECEIPT_FORM_ID'] = params[:receipt_template] || "mobileresult01"
  @PARAM_HASH['REMOTE_URL'] = params[:receipt_temp_remote_url] || ''
  @PARAM_HASH['SHPF_TPS_HASH_TYPE'] = "HMAC_SHA512"
  @PARAM_HASH['RECEIPT_TPS_HASH_TYPE'] = @PARAM_HASH['SHPF_TPS_HASH_TYPE']
  @PARAM_HASH['TPS_HASH_TYPE'] = set_hash_type(params[:tps_hash_type] || '')
  @card_types = set_card_types
  @receipt_tps_def = 'SHPF_ACCOUNT_ID SHPF_FORM_ID RETURN_URL DBA AMEX_IMAGE DISCOVER_IMAGE SHPF_TPS_DEF SHPF_TPS_HASH_TYPE'
  @receipt_tps_string = set_receipt_tps_string
  @receipt_tamper_proof_seal = create_tps_hash(@receipt_tps_string, @PARAM_HASH['RECEIPT_TPS_HASH_TYPE'])
  @receipt_url = set_receipt_url
  @bp10emu_tps_def = add_def_protected_status('MERCHANT APPROVED_URL DECLINED_URL MISSING_URL MODE TRANSACTION_TYPE TPS_DEF TPS_HASH_TYPE')
  @bp10emu_tps_string = set_bp10emu_tps_string
  @bp10emu_tamper_proof_seal = create_tps_hash(@bp10emu_tps_string, @PARAM_HASH['TPS_HASH_TYPE'])
  @shpf_tps_def = add_def_protected_status('SHPF_FORM_ID SHPF_ACCOUNT_ID DBA TAMPER_PROOF_SEAL AMEX_IMAGE DISCOVER_IMAGE TPS_DEF TPS_HASH_TYPE SHPF_TPS_DEF SHPF_TPS_HASH_TYPE')
  @shpf_tps_string = set_shpf_tps_string
  @shpf_tamper_proof_seal = create_tps_hash(@shpf_tps_string, @PARAM_HASH['SHPF_TPS_HASH_TYPE'])
  return calc_url_response
end

#get_amountObject

Amount associated with the transaction



161
162
163
# File 'lib/api_response.rb', line 161

def get_amount
  @RESPONSE_HASH['amount']
end

#get_auth_codeObject

In the case of an approved transaction, contains the 6-character authorization code from the processing network. In the case of a decline or error, the contents may be junk.



56
57
58
# File 'lib/api_response.rb', line 56

def get_auth_code
  @RESPONSE_HASH['AUTH_CODE']
end

#get_avs_codeObject

Returns the single-character AVS response from the Card Issuing Bank



44
45
46
# File 'lib/api_response.rb', line 44

def get_avs_code
  @RESPONSE_HASH['AVS']
end

#get_bank_nameObject

Bank account used in transaction



81
82
83
# File 'lib/api_response.rb', line 81

def get_bank_name
  @RESPONSE_HASH['BANK_NAME']
end

#get_bp_stampObject

Returns the BP_STAMP used to authenticate response



28
29
30
# File 'lib/api_response.rb', line 28

def get_bp_stamp
  @RESPONSE_HASH['BP_STAMP']
end

#get_bp_stamp_defObject

Returns the fields used to calculate the BP_STAMP



33
34
35
# File 'lib/api_response.rb', line 33

def get_bp_stamp_def
  @RESPONSE_HASH['BP_STAMP_DEF']
end

#get_card_typeObject

Card type used in transaction



76
77
78
# File 'lib/api_response.rb', line 76

def get_card_type
  @RESPONSE_HASH['CARD_TYPE']
end

#get_creation_dateObject

Creation date of rebilling



101
102
103
# File 'lib/api_response.rb', line 101

def get_creation_date
  @RESPONSE_HASH['creation_date']
end

#get_cvv2_codeObject

Same as avs_code, but for CVV2



49
50
51
# File 'lib/api_response.rb', line 49

def get_cvv2_code
  @RESPONSE_HASH['CVV2']
end

#get_cycles_remainingObject

Number of cycles remaining on rebilling



121
122
123
# File 'lib/api_response.rb', line 121

def get_cycles_remaining
  @RESPONSE_HASH['cycles_remain']
end

#get_hash_typeObject

Returns hash function used for transaction



38
39
40
# File 'lib/api_response.rb', line 38

def get_hash_type
  @RESPONSE_HASH['TPS_HASH_TYPE']
end

#get_idObject

Transaction ID used with stq API



136
137
138
# File 'lib/api_response.rb', line 136

def get_id
  @RESPONSE_HASH['id']
end

#get_last_dateObject

Last date that the rebilling fired off on



111
112
113
# File 'lib/api_response.rb', line 111

def get_last_date
  @RESPONSE_HASH['last_date']
end

#get_masked_accountObject

Masked credit card or ACH account



71
72
73
# File 'lib/api_response.rb', line 71

def 
  @RESPONSE_HASH['PAYMENT_ACCOUNT']
end

#get_messageObject

Returns the human-readable response from Bluepay. Or a nasty error.



18
19
20
21
22
23
24
25
# File 'lib/api_response.rb', line 18

def get_message
  m = @RESPONSE_HASH['MESSAGE']
  if m == nil or m == ""
    "ERROR - NO MESSAGE FROM BLUEPAY"
  else
    m
  end
end

#get_name1Object

First name associated with the transaction



141
142
143
# File 'lib/api_response.rb', line 141

def get_name1
  @RESPONSE_HASH['name1']
end

#get_name2Object

Last name associated with the transaction



146
147
148
# File 'lib/api_response.rb', line 146

def get_name2
  @RESPONSE_HASH['name2']
end

#get_next_amountObject

Next amount to charge when rebilling fires off



131
132
133
# File 'lib/api_response.rb', line 131

def get_next_amount
  @RESPONSE_HASH['next_amount']
end

#get_next_dateObject

Next date that the rebilling is set to fire off on



106
107
108
# File 'lib/api_response.rb', line 106

def get_next_date
  @RESPONSE_HASH['next_date']
end

#get_payment_typeObject

Payment type associated with the transaction



151
152
153
# File 'lib/api_response.rb', line 151

def get_payment_type
  @RESPONSE_HASH['payment_type']
end

#get_reb_idObject

Rebill ID from bprebadmin API



86
87
88
# File 'lib/api_response.rb', line 86

def get_reb_id
  @RESPONSE_HASH['rebill_id']
end

#get_rebill_amountObject

Amount to charge when rebilling fires off



126
127
128
# File 'lib/api_response.rb', line 126

def get_rebill_amount
  @RESPONSE_HASH['reb_amount']
end

#get_rebill_idObject

If you set up a rebilling, this’ll get its ID.



66
67
68
# File 'lib/api_response.rb', line 66

def get_rebill_id
  @RESPONSE_HASH['REBID']
end

#get_rebill_statusObject

Status of rebilling



96
97
98
# File 'lib/api_response.rb', line 96

def get_rebill_status
  @RESPONSE_HASH['status']
end

#get_rebilling_cycle_status(rebill_id) ⇒ Object

Set fields to get the status of an existing rebilling cycle



272
273
274
275
276
# File 'lib/bluepay.rb', line 272

def get_rebilling_cycle_status(rebill_id)
  @PARAM_HASH["TRANS_TYPE"] = "GET"
  @PARAM_HASH["REBILL_ID"] = rebill_id
  @api = "bp20rebadmin"
end

#get_responseObject



2
3
4
# File 'lib/api_response.rb', line 2

def get_response
  @RESPONSE_HASH
end

#get_sched_expressionObject

Rebilling expression



116
117
118
# File 'lib/api_response.rb', line 116

def get_sched_expression
  @RESPONSE_HASH['sched_expr']
end

#get_settled_transaction_report(params = {}) ⇒ Object

Gets a report on all settled transactions within a specified date range



295
296
297
298
299
300
301
302
303
# File 'lib/bluepay.rb', line 295

def get_settled_transaction_report(params = {})
  @PARAM_HASH["QUERY_BY_SETTLEMENT"] = '1'
  @PARAM_HASH["REPORT_START_DATE"] = params[:report_start_date]
  @PARAM_HASH["REPORT_END_DATE"] = params[:report_end_date]
  @PARAM_HASH["QUERY_BY_HIERARCHY"] = params[:query_by_hierarchy]
  @PARAM_HASH["DO_NOT_ESCAPE"] = params[:do_not_escape] || ''
  @PARAM_HASH["EXCLUDE_ERRORS"] = params[:exclude_errors] || ''
  @api = "bpdailyreport2"
end

#get_single_transaction_query(params = {}) ⇒ Object

Gets data on a specific transaction



306
307
308
309
310
311
312
# File 'lib/bluepay.rb', line 306

def get_single_transaction_query(params = {})
  @PARAM_HASH["REPORT_START_DATE"] = params[:report_start_date]
  @PARAM_HASH["REPORT_END_DATE"] = params[:report_end_date]
  @PARAM_HASH["id"] = params[:transaction_id]
  @PARAM_HASH["EXCLUDE_ERRORS"] = params[:exclude_errors] || ''
  @api = "stq"    
end

#get_statusObject

Returns E for Error, 1 for Approved, 0 for Decline



12
13
14
# File 'lib/api_response.rb', line 12

def get_status
  @RESPONSE_HASH['Result']
end

#get_template_idObject

Template ID of rebilling



91
92
93
# File 'lib/api_response.rb', line 91

def get_template_id
  @RESPONSE_HASH['template_id']
end

#get_trans_idObject

The all-important transaction ID.



61
62
63
# File 'lib/api_response.rb', line 61

def get_trans_id
  @RESPONSE_HASH['RRNO']
end

#get_trans_typeObject

Transaction type associated with the transaction



156
157
158
# File 'lib/api_response.rb', line 156

def get_trans_type
  @RESPONSE_HASH['trans_type']
end

#get_transaction_report(params = {}) ⇒ Object

Gets a report on all transactions within a specified date range



284
285
286
287
288
289
290
291
292
# File 'lib/bluepay.rb', line 284

def get_transaction_report(params = {})
  @PARAM_HASH["QUERY_BY_SETTLEMENT"] = '0'
  @PARAM_HASH["REPORT_START_DATE"] = params[:report_start_date]
  @PARAM_HASH["REPORT_END_DATE"] = params[:report_end_date]
  @PARAM_HASH["QUERY_BY_HIERARCHY"] = params[:query_by_hierarchy]
  @PARAM_HASH["DO_NOT_ESCAPE"] = params[:do_not_escape] || ''
  @PARAM_HASH["EXCLUDE_ERRORS"] = params[:exclude_errors] || ''
  @api = "bpdailyreport2"
end

#invoice_id=(invoice_id) ⇒ Object

Set INVOICE_ID field



147
148
149
# File 'lib/bluepay.rb', line 147

def invoice_id=(invoice_id)
  @PARAM_HASH['INVOICE_ID'] = invoice_id
end

#memo=(memo) ⇒ Object

Set MEMO field



132
133
134
# File 'lib/bluepay.rb', line 132

def memo=(memo)
  @PARAM_HASH['COMMENT'] = memo
end

#order_id=(order_id) ⇒ Object

Set ORDER_ID field



152
153
154
# File 'lib/bluepay.rb', line 152

def order_id=(order_id)
  @PARAM_HASH['ORDER_ID'] = order_id
end

#phone=(number) ⇒ Object

Set customer Phone



117
118
119
# File 'lib/bluepay.rb', line 117

def phone=(number)
  @PARAM_HASH['PHONE'] = number
end

#processObject

sends HTTPS POST to BluePay gateway for processing



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/api_request.rb', line 65

def process
  
  ua = Net::HTTP.new(SERVER, 443)
  ua.use_ssl = true
  
  # Set default hash function to HMAC SHA-512
  @PARAM_HASH['TPS_HASH_TYPE'] = 'HMAC_SHA512'

  # Checks presence of CA certificate
  if File.directory?(RootCA)
    ua.ca_path = RootCA
    ua.verify_mode = OpenSSL::SSL::VERIFY_PEER
    ua.verify_depth = 3
  else
    puts "Invalid CA certificates directory. Exiting..."
    exit
  end
  
  # Sets REMOTE_IP parameter
  begin
  	@PARAM_HASH["REMOTE_IP"] = request.env['REMOTE_ADDR']
    rescue Exception
  end

  # Response version to be returned
  @PARAM_HASH["RESPONSEVERSION"] = '5'

  # Generate the query string and headers.  Chooses which API to make request to.
  case @api
  when "bpdailyreport2"
    calc_report_tps
    path = "/interfaces/bpdailyreport2"
    query = "ACCOUNT_ID=#{@ACCOUNT_ID}&" + uri_query(@PARAM_HASH)
  when "stq"
    calc_report_tps
    path = "/interfaces/stq"
    query = "ACCOUNT_ID=#{@ACCOUNT_ID}&" + uri_query(@PARAM_HASH)
  when "bp10emu"
    calc_tps
    path = "/interfaces/bp10emu"
    query = "MERCHANT=#{@ACCOUNT_ID}&" + uri_query(@PARAM_HASH)
    # puts "****"; puts uri_query(@PARAM_HASH).inspect
  when "bp20rebadmin"
    calc_rebill_tps
    path = "/interfaces/bp20rebadmin"
    query = "ACCOUNT_ID=#{@ACCOUNT_ID}&" + uri_query(@PARAM_HASH)
  end
  queryheaders = {
    'User-Agent' => 'Bluepay Ruby Client',
    'Content-Type' => 'application/x-www-form-urlencoded'
  }
  # Post parameters to BluePay gateway
  # Resuce SSL error and retry with ca_file absolute path.
  begin
    headers, body = ua.post(path, query, queryheaders)
  rescue OpenSSL::SSL::SSLError
    ua.ca_file = File.expand_path(File.dirname(__FILE__)) + "/" + RootCAFile
    headers, body = ua.post(path, query, queryheaders)
  end
  
  # Split the response into the response hash.
  @RESPONSE_HASH = {}
  if path == "/interfaces/bp10emu"
    response = headers["Location"].split("?")[1]
  else
    response = headers.body
  end
  if path == "/interfaces/bpdailyreport2"
    response
  else
    response.split("&").each do |pair| 
      (key, val) = pair.split("=")
      val = "" if val == nil
      @RESPONSE_HASH[URI.unescape(key)] = URI.unescape(val) 
    end
  end
end

#query_by_amount(amount) ⇒ Object

Queries by a specific Transaction Amount. To be used with get_single_trans_query



330
331
332
# File 'lib/bluepay.rb', line 330

def query_by_amount(amount)
  @PARAM_HASH["amount"] = amount
end

#query_by_name1(name1) ⇒ Object

Queries by a specific First Name. To be used with get_single_trans_query



335
336
337
# File 'lib/bluepay.rb', line 335

def query_by_name1(name1)
  @PARAM_HASH["name1"] = name1
end

#query_by_name2(name2) ⇒ Object

Queries by a specific Last Name. To be used with get_single_trans_query



340
341
342
# File 'lib/bluepay.rb', line 340

def query_by_name2(name2) 
  @PARAM_HASH["name2"] = name2
end

#query_by_payment_type(pay_type) ⇒ Object

Queries by a specific Payment Type. To be used with get_single_trans_query



320
321
322
# File 'lib/bluepay.rb', line 320

def query_by_payment_type(pay_type)
  @PARAM_HASH["payment_type"] = payment_type
end

#query_by_trans_type(trans_type) ⇒ Object

Queries by a specific Transaction Type. To be used with get_single_trans_query



325
326
327
# File 'lib/bluepay.rb', line 325

def query_by_trans_type(trans_type)
  @PARAM_HASH["trans_type"] = trans_type
end

#query_by_transaction_id(trans_id) ⇒ Object

Queries by a specific Transaction ID. To be used with get_single_trans_query



315
316
317
# File 'lib/bluepay.rb', line 315

def query_by_transaction_id(trans_id)
  @PARAM_HASH["id"] = trans_id
end

#refund(params = {}) ⇒ Object

Refund



70
71
72
73
74
75
# File 'lib/bluepay.rb', line 70

def refund(params = {})
  @PARAM_HASH['TRANSACTION_TYPE'] = 'REFUND'
  @PARAM_HASH['RRNO'] = params[:trans_id]
  @PARAM_HASH['AMOUNT'] = params[:amount] || ''
  @api = "bp10emu"
end

#sale(params = {}) ⇒ Object

Set up a sale



46
47
48
49
50
51
# File 'lib/bluepay.rb', line 46

def sale(params = {})
  @PARAM_HASH['TRANSACTION_TYPE'] = 'SALE'
  @PARAM_HASH['AMOUNT'] = params[:amount]
  @PARAM_HASH['RRNO'] = params[:trans_id] || ''
  @api = "bp10emu"
end

#set_ach_information(params = {}) ⇒ Object

Set up an ACH transaction. Expects: acc_type: C for Checking, S for Savings routing: Bank routing number account: Customer’s checking or savings account number doc_type: WEB, TEL, ARC, etc – see docs. Optional. REMEMBER: Ach requires some other fields, such as address and phone



37
38
39
40
41
42
43
# File 'lib/bluepay.rb', line 37

def set_ach_information(params = {})
  @PARAM_HASH['PAYMENT_TYPE'] = 'ACH'
  @PARAM_HASH['ACH_ROUTING'] = params[:ach_routing]
  @PARAM_HASH['ACH_ACCOUNT'] = params[:ach_account]
  @PARAM_HASH['ACH_ACCOUNT_TYPE'] = params[:ach_account_type]
  @PARAM_HASH['DOC_TYPE'] = params[:doc_type] || ''
end

#set_bp10emu_tps_stringObject

Sets the bp10emu string that will be used to create a Tamperproof Seal. Must be used with generate_url.



447
448
449
450
451
452
453
454
455
456
457
458
# File 'lib/bluepay.rb', line 447

def set_bp10emu_tps_string
  bp10emu = [
  @ACCOUNT_ID,
  @receipt_url,
  @receipt_url,
  @receipt_url,
  @PARAM_HASH['MODE'],
  @PARAM_HASH['TRANSACTION_TYPE'],
  @bp10emu_tps_def,
  @PARAM_HASH['TPS_HASH_TYPE']].join('')
  return add_string_protected_status(bp10emu)
end

#set_card_typesObject

Sets the types of credit card images to use on the Simple Hosted Payment Form. Must be used with generate_url.



427
428
429
430
431
432
# File 'lib/bluepay.rb', line 427

def set_card_types
  credit_cards = 'vi-mc'
  credit_cards.concat('-di') if @PARAM_HASH['DISCOVER_IMAGE'] == 'discvr.gif'
  credit_cards.concat('-am') if @PARAM_HASH['AMEX_IMAGE'] == 'amex.gif'
  return credit_cards 
end

#set_cc_information(params = {}) ⇒ Object

Set up a credit card payment.



23
24
25
26
27
28
# File 'lib/bluepay.rb', line 23

def set_cc_information(params={})
  @PARAM_HASH['PAYMENT_TYPE'] = 'CREDIT'
  @PARAM_HASH['CC_NUM'] = params[:cc_number] || ''
  @PARAM_HASH['CC_EXPIRES'] = params[:cc_expiration] || ''
  @PARAM_HASH['CVCVV2'] = params[:cvv2] || ''
end

#set_customer_information(params = {}) ⇒ Object

Sets customer information for the transaction



102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/bluepay.rb', line 102

def set_customer_information(params={})
  @PARAM_HASH['NAME1'] = params[:first_name]
  @PARAM_HASH['NAME2'] = params[:last_name]
  @PARAM_HASH['ADDR1'] = params[:address1]
  @PARAM_HASH['ADDR2'] = params[:address2]
  @PARAM_HASH['CITY'] = params[:city]
  @PARAM_HASH['STATE'] = params[:state]
  @PARAM_HASH['ZIPCODE'] = params[:zip_code]
  @PARAM_HASH['COUNTRY'] = params[:country]
  @PARAM_HASH['PHONE'] = params[:phone]
  @PARAM_HASH['EMAIL'] = params[:email]
  @PARAM_HASH['COMPANY_NAME'] = params[:company_name] || ''
end

#set_hash_type(chosen_hash) ⇒ Object



421
422
423
424
# File 'lib/bluepay.rb', line 421

def set_hash_type(chosen_hash)
  default_hash = "HMAC_SHA512"
  ["MD5", "SHA256", "SHA512", "HMAC_SHA256"].include?(chosen_hash.upcase) ? chosen_hash.upcase : default_hash
end

#set_receipt_tps_stringObject

Sets the receipt Tamperproof Seal string. Must be used with generate_url.



435
436
437
438
439
440
441
442
443
444
# File 'lib/bluepay.rb', line 435

def set_receipt_tps_string
  [@ACCOUNT_ID, 
  @PARAM_HASH['RECEIPT_FORM_ID'], 
  @PARAM_HASH['RETURN_URL'], 
  @PARAM_HASH['DBA'], 
  @PARAM_HASH['AMEX_IMAGE'], 
  @PARAM_HASH['DISCOVER_IMAGE'], 
  @receipt_tps_def,
  @PARAM_HASH['RECEIPT_TPS_HASH_TYPE']].join('')
end

#set_receipt_urlObject

Sets the receipt url or uses the remote url provided. Must be used with generate_url.



476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
# File 'lib/bluepay.rb', line 476

def set_receipt_url
  if @PARAM_HASH['RECEIPT_FORM_ID']== 'remote_url'
    return @PARAM_HASH['REMOTE_URL']
  else
    return 'https://secure.bluepay.com/interfaces/shpf?SHPF_FORM_ID=' + @PARAM_HASH['RECEIPT_FORM_ID'] + 
    '&SHPF_ACCOUNT_ID='     + @ACCOUNT_ID + 
    '&SHPF_TPS_DEF='        + url_encode(@receipt_tps_def) + 
    '&SHPF_TPS_HASH_TYPE='  + url_encode(@PARAM_HASH['RECEIPT_TPS_HASH_TYPE']) +
    '&SHPF_TPS='            + url_encode(@receipt_tamper_proof_seal) + 
    '&RETURN_URL='          + url_encode(@PARAM_HASH['RETURN_URL']) + 
    '&DBA='                 + url_encode(@PARAM_HASH['DBA']) + 
    '&AMEX_IMAGE='          + url_encode(@PARAM_HASH['AMEX_IMAGE']) + 
    '&DISCOVER_IMAGE='      + url_encode(@PARAM_HASH['DISCOVER_IMAGE'])
  end
end

#set_recurring_payment(params = {}) ⇒ Object

Set fields for a recurring payment



242
243
244
245
246
247
248
# File 'lib/bluepay.rb', line 242

def set_recurring_payment(params = {})
  @PARAM_HASH['REBILLING'] = '1'
  @PARAM_HASH['REB_FIRST_DATE'] = params[:reb_first_date]
  @PARAM_HASH['REB_EXPR'] = params[:reb_expr]
  @PARAM_HASH['REB_CYCLES'] = params[:reb_cycles]
  @PARAM_HASH['REB_AMOUNT'] = params[:reb_amount]
end

#set_shpf_tps_stringObject

Sets the Simple Hosted Payment Form string that will be used to create a Tamperproof Seal. Must be used with generate_url.



461
462
463
464
465
466
467
468
469
470
471
472
473
# File 'lib/bluepay.rb', line 461

def set_shpf_tps_string 
  shpf = ([@PARAM_HASH['SHPF_FORM_ID'], 
  @ACCOUNT_ID, 
  @PARAM_HASH['DBA'], 
  @bp10emu_tamper_proof_seal, 
  @PARAM_HASH['AMEX_IMAGE'], 
  @PARAM_HASH['DISCOVER_IMAGE'], 
  @bp10emu_tps_def,
  @PARAM_HASH['TPS_HASH_TYPE'], 
  @shpf_tps_def,
  @PARAM_HASH['SHPF_TPS_HASH_TYPE']].join(''))
  return add_string_protected_status(shpf)
end

#successful_transaction?Boolean

Returns true if response status is approved and not a duplicate, else returns false

Returns:

  • (Boolean)


7
8
9
# File 'lib/api_response.rb', line 7

def successful_transaction?
  self.get_status == "APPROVED" && self.get_message != "DUPLICATE"
end

#swipe(track_data) ⇒ Object

Sets payment information for a swiped credit card transaction



94
95
96
97
98
99
# File 'lib/bluepay.rb', line 94

def swipe(track_data)
  @PARAM_HASH['SWIPE'] = track_data
  #  Regex matchers 
    # track1_and_track2 = /(%B)\d{0,19}\^([\w\s]*)\/([\w\s]*)([\s]*)\^\d{7}\w*\?;\d{0,19}=\d{7}\w*\?/.match(track_data).to_s
    # track2 = /;\d{0,19}=\d{7}\w*\?/.match(track_data).to_s
end

#update(params = {}) ⇒ Object

Update



78
79
80
81
82
83
# File 'lib/bluepay.rb', line 78

def update(params = {})
  @PARAM_HASH['TRANSACTION_TYPE'] = 'UPDATE'
  @PARAM_HASH['RRNO'] = params[:trans_id]
  @PARAM_HASH['AMOUNT'] = params[:amount] || ''
  @api = "bp10emu"
end

#update_rebill(params = {}) ⇒ Object

Set fields to do an update on an existing rebilling cycle



251
252
253
254
255
256
257
258
259
260
261
# File 'lib/bluepay.rb', line 251

def update_rebill(params = {})
  @PARAM_HASH['TRANS_TYPE'] = "SET"
  @PARAM_HASH['REBILL_ID'] = params[:rebill_id]
  @PARAM_HASH['NEXT_DATE'] = params[:next_date] || ''
  @PARAM_HASH['REB_EXPR'] = params[:reb_expr] || ''
  @PARAM_HASH['REB_CYCLES'] = params[:reb_cycles] || ''
  @PARAM_HASH['REB_AMOUNT'] = params[:reb_amount] || ''
  @PARAM_HASH['NEXT_AMOUNT'] = params[:next_amount] || ''
  @PARAM_HASH["TEMPLATE_ID"] = params[:template_id] || ''
  @api = "bp20rebadmin"
end

#update_rebilling_payment_information(template_id) ⇒ Object

Updates an existing rebilling cycle’s payment information.



279
280
281
# File 'lib/bluepay.rb', line 279

def update_rebilling_payment_information(template_id)
  @PARAM_HASH["TEMPLATE_ID"] = template_id
end

#uri_query(param_hash) ⇒ Object

Turns a hash into a nvp style string



4
5
6
7
8
9
# File 'lib/api_request.rb', line 4

def uri_query(param_hash)
  array = []
  param_hash.each_pair {|key, val| array << (URI.escape(key) + "=" + URI.escape(val))}
  uri_query_string = array.join("&")
  return uri_query_string
end

#url_encode(string) ⇒ Object

Encodes a string into a URL. Must be used with generate_url.



511
512
513
514
515
516
517
518
# File 'lib/bluepay.rb', line 511

def url_encode(string) 
  encoded_string = ''
  string.each_char do |char|
    char = ("%%%02X" % char.ord) if char.match(/[A-Za-z0-9]/) == nil
    encoded_string << char
  end
 return encoded_string
end

#void(trans_id) ⇒ Object

Void



86
87
88
89
90
91
# File 'lib/bluepay.rb', line 86

def void(trans_id)
  @PARAM_HASH['TRANSACTION_TYPE'] = 'VOID'
  @PARAM_HASH['AMOUNT'] = ''
  @PARAM_HASH['RRNO'] = trans_id
  @api = "bp10emu"
end