bluepay 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README +1 -1
- data/bluepay.gemspec +3 -3
- data/lib/api_request.rb +33 -32
- data/lib/api_response.rb +16 -1
- data/lib/bluepay.rb +109 -30
- data/lib/cacert.pem +0 -0
- data/test/Get_Data/Retrieve_Settlement_Data.rb +1 -1
- data/test/Get_Data/{retrieve_transaction_data.rb → Retrieve_Transaction_Data.rb} +1 -1
- data/test/Get_Data/Single_Transaction_Query.rb +1 -1
- data/test/Get_Data/Transaction_Notification.rb +15 -22
- data/test/Get_Data/Validate_BP_Stamp.rb +46 -0
- data/test/Rebill/Cancel_Recurring_Payment.rb +2 -2
- data/test/Rebill/Create_Recurring_Payment_ACH.rb +1 -1
- data/test/Rebill/Create_Recurring_Payment_CC.rb +2 -2
- data/test/Rebill/Get_Recurring_Payment_Status.rb +1 -1
- data/test/Rebill/Update_Recurring_Payment.rb +2 -2
- data/test/Transactions/Cancel_Transaction.rb +2 -2
- data/test/Transactions/Charge_Customer_ACH.rb +1 -1
- data/test/Transactions/{CHarge_Customer_CC.rb → Charge_Customer_CC.rb} +3 -3
- data/test/Transactions/Charge_Customer_CC_Lvl2_Lvl3.rb +91 -0
- data/test/Transactions/Check_Customer_Credit.rb +2 -2
- data/test/Transactions/Customer_Defined_Data.rb +2 -2
- data/test/Transactions/How_To_Use_Token.rb +1 -1
- data/test/Transactions/Return_Funds.rb +2 -2
- data/test/Transactions/Store_Payment_Information.rb +2 -2
- data/test/Transactions/Swipe.rb +1 -1
- data/test/Transactions/Update_Transaction.rb +77 -0
- metadata +14 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 040ef1ecd2c2ec89c955c6c038f503ba582097d9
|
4
|
+
data.tar.gz: bc51b336d7c58b48912d2573ab44b64a5fd2f3fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf3ae0dfafa78afc6cf497199e96300d2ae115e1d61a5909f4405ed16446220b1f2ffb81eccda3a2bb96bbb27dd84e33583b99b95dbc6b4b07abd96b6ec6744a
|
7
|
+
data.tar.gz: e405a6db7afad4b1e8a15663ba0d1665b54804bb14b30b65e170b43b87513a11fd09cf710b14d7fc97f6d7547dc07e1e14b34eb9742ed3366e117549a26b64bc
|
data/README
CHANGED
data/bluepay.gemspec
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'bluepay'
|
3
|
-
s.version = '1.0.
|
4
|
-
s.date = '
|
3
|
+
s.version = '1.0.7'
|
4
|
+
s.date = '2018-02-16'
|
5
5
|
s.summary = "BluePay gateway rubygem"
|
6
6
|
s.description = "This gem is intended to be used along with a BluePay gateway account to process credit card and ACH transactions"
|
7
|
-
s.authors = ["Justin Slingerland, Susan Schmidt"]
|
7
|
+
s.authors = ["Justin Slingerland, Susan Schmidt, Eric Margules"]
|
8
8
|
s.email = 'jslingerland@bluepay.com'
|
9
9
|
s.has_rdoc = true
|
10
10
|
s.files = Dir.glob("{lib,test,doc}/**/*") + %w(bluepay.gemspec Rakefile README)
|
data/lib/api_request.rb
CHANGED
@@ -8,10 +8,25 @@ class BluePay
|
|
8
8
|
return uri_query_string
|
9
9
|
end
|
10
10
|
|
11
|
+
# Generates TPS hash based on given hash type
|
12
|
+
def create_tps_hash(data, hash_type)
|
13
|
+
case hash_type
|
14
|
+
when 'HMAC_SHA256'
|
15
|
+
OpenSSL::HMAC.hexdigest('sha256', @SECRET_KEY, data)
|
16
|
+
when 'SHA512'
|
17
|
+
Digest::SHA512.hexdigest(@SECRET_KEY + data)
|
18
|
+
when 'SHA256'
|
19
|
+
Digest::SHA256.hexdigest(@SECRET_KEY + data)
|
20
|
+
when 'MD5'
|
21
|
+
Digest::MD5.hexdigest(@SECRET_KEY + data)
|
22
|
+
else
|
23
|
+
OpenSSL::HMAC.hexdigest('sha512', @SECRET_KEY, data)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
11
27
|
# Sets TAMPER_PROOF_SEAL in @PARAM_HASH
|
12
28
|
def calc_tps
|
13
|
-
@PARAM_HASH["TAMPER_PROOF_SEAL"] =
|
14
|
-
@SECRET_KEY +
|
29
|
+
@PARAM_HASH["TAMPER_PROOF_SEAL"] = create_tps_hash(
|
15
30
|
@ACCOUNT_ID +
|
16
31
|
(@PARAM_HASH["TRANSACTION_TYPE"] || '') +
|
17
32
|
@PARAM_HASH["AMOUNT"] +
|
@@ -21,55 +36,40 @@ class BluePay
|
|
21
36
|
(@PARAM_HASH["REB_CYCLES"] || '') +
|
22
37
|
(@PARAM_HASH["REB_AMOUNT"] || '') +
|
23
38
|
(@PARAM_HASH["RRNO"] || '') +
|
24
|
-
@PARAM_HASH["MODE"]
|
39
|
+
@PARAM_HASH["MODE"],
|
40
|
+
@PARAM_HASH['TPS_HASH_TYPE']
|
25
41
|
)
|
26
42
|
end
|
27
43
|
|
28
44
|
# Sets TAMPER_PROOF_SEAL in @PARAM_HASH for rebadmin API
|
29
45
|
def calc_rebill_tps
|
30
|
-
@PARAM_HASH["TAMPER_PROOF_SEAL"] =
|
31
|
-
@SECRET_KEY +
|
46
|
+
@PARAM_HASH["TAMPER_PROOF_SEAL"] = create_tps_hash(
|
32
47
|
@ACCOUNT_ID +
|
33
48
|
@PARAM_HASH["TRANS_TYPE"] +
|
34
|
-
@PARAM_HASH["REBILL_ID"]
|
49
|
+
@PARAM_HASH["REBILL_ID"],
|
50
|
+
@PARAM_HASH['TPS_HASH_TYPE']
|
35
51
|
)
|
36
52
|
end
|
37
53
|
|
38
54
|
# Sets TAMPER_PROOF_SEAL in @PARAM_HASH for bpdailyreport2 API
|
39
55
|
def calc_report_tps
|
40
|
-
@PARAM_HASH["TAMPER_PROOF_SEAL"] =
|
41
|
-
@SECRET_KEY +
|
56
|
+
@PARAM_HASH["TAMPER_PROOF_SEAL"] = create_tps_hash(
|
42
57
|
@ACCOUNT_ID +
|
43
58
|
@PARAM_HASH["REPORT_START_DATE"] +
|
44
|
-
@PARAM_HASH["REPORT_END_DATE"]
|
59
|
+
@PARAM_HASH["REPORT_END_DATE"],
|
60
|
+
@PARAM_HASH['TPS_HASH_TYPE']
|
45
61
|
)
|
46
62
|
end
|
47
63
|
|
48
|
-
# Calculates TAMPER_PROOF_SEAL to be used with Trans Notify API
|
49
|
-
def self.calc_trans_notify_tps(secret_key, trans_id, trans_status, trans_type, amount, batch_id, batch_status, total_count, total_amount, batch_upload_id, rebill_id, rebill_amount, rebill_status)
|
50
|
-
Digest::MD5.hexdigest(
|
51
|
-
@SECRET_KEY +
|
52
|
-
trans_id +
|
53
|
-
trans_status +
|
54
|
-
transtype +
|
55
|
-
amount +
|
56
|
-
batch_id +
|
57
|
-
batch_status +
|
58
|
-
total_count +
|
59
|
-
total_amount +
|
60
|
-
batch_upload_id +
|
61
|
-
rebill_id +
|
62
|
-
rebill_amount +
|
63
|
-
rebill_status
|
64
|
-
)
|
65
|
-
end
|
66
|
-
|
67
64
|
# sends HTTPS POST to BluePay gateway for processing
|
68
65
|
def process
|
69
66
|
|
70
67
|
ua = Net::HTTP.new(SERVER, 443)
|
71
68
|
ua.use_ssl = true
|
72
69
|
|
70
|
+
# Set default hash function to HMAC SHA-512
|
71
|
+
@PARAM_HASH['TPS_HASH_TYPE'] = 'HMAC_SHA512'
|
72
|
+
|
73
73
|
# Checks presence of CA certificate
|
74
74
|
if File.directory?(RootCA)
|
75
75
|
ua.ca_path = RootCA
|
@@ -86,6 +86,9 @@ class BluePay
|
|
86
86
|
rescue Exception
|
87
87
|
end
|
88
88
|
|
89
|
+
# Response version to be returned
|
90
|
+
@PARAM_HASH["RESPONSEVERSION"] = '5'
|
91
|
+
|
89
92
|
# Generate the query string and headers. Chooses which API to make request to.
|
90
93
|
case @api
|
91
94
|
when "bpdailyreport2"
|
@@ -99,7 +102,7 @@ class BluePay
|
|
99
102
|
when "bp10emu"
|
100
103
|
calc_tps
|
101
104
|
path = "/interfaces/bp10emu"
|
102
|
-
query = "MERCHANT=#{@ACCOUNT_ID}&" + uri_query(@PARAM_HASH)
|
105
|
+
query = "MERCHANT=#{@ACCOUNT_ID}&" + uri_query(@PARAM_HASH)
|
103
106
|
# puts "****"; puts uri_query(@PARAM_HASH).inspect
|
104
107
|
when "bp20rebadmin"
|
105
108
|
calc_rebill_tps
|
@@ -110,8 +113,6 @@ class BluePay
|
|
110
113
|
'User-Agent' => 'Bluepay Ruby Client',
|
111
114
|
'Content-Type' => 'application/x-www-form-urlencoded'
|
112
115
|
}
|
113
|
-
# Response version to be returned
|
114
|
-
@PARAM_HASH["VERSION"] = '3'
|
115
116
|
# Post parameters to BluePay gateway
|
116
117
|
headers, body = ua.post(path, query, queryheaders)
|
117
118
|
# Split the response into the response hash.
|
@@ -131,4 +132,4 @@ class BluePay
|
|
131
132
|
end
|
132
133
|
end
|
133
134
|
end
|
134
|
-
end
|
135
|
+
end
|
data/lib/api_response.rb
CHANGED
@@ -2,7 +2,7 @@ class BluePay
|
|
2
2
|
def get_response
|
3
3
|
@RESPONSE_HASH
|
4
4
|
end
|
5
|
-
|
5
|
+
|
6
6
|
# Returns true if response status is approved and not a duplicate, else returns false
|
7
7
|
def successful_transaction?
|
8
8
|
self.get_status == "APPROVED" && self.get_message != "DUPLICATE"
|
@@ -24,6 +24,21 @@ class BluePay
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
# Returns the BP_STAMP used to authenticate response
|
28
|
+
def get_bp_stamp
|
29
|
+
@RESPONSE_HASH['BP_STAMP']
|
30
|
+
end
|
31
|
+
|
32
|
+
# Returns the fields used to calculate the BP_STAMP
|
33
|
+
def get_bp_stamp_def
|
34
|
+
@RESPONSE_HASH['BP_STAMP_DEF']
|
35
|
+
end
|
36
|
+
|
37
|
+
# Returns hash function used for transaction
|
38
|
+
def get_hash_type
|
39
|
+
@RESPONSE_HASH['TPS_HASH_TYPE']
|
40
|
+
end
|
41
|
+
|
27
42
|
# Returns the single-character AVS response from the
|
28
43
|
# Card Issuing Bank
|
29
44
|
def get_avs_code
|
data/lib/bluepay.rb
CHANGED
@@ -2,7 +2,6 @@ require "net/http"
|
|
2
2
|
require "net/https"
|
3
3
|
require "uri"
|
4
4
|
require "digest/sha2"
|
5
|
-
require "digest/md5"
|
6
5
|
|
7
6
|
# Files
|
8
7
|
require_relative "api_request"
|
@@ -74,6 +73,14 @@ class BluePay
|
|
74
73
|
@api = "bp10emu"
|
75
74
|
end
|
76
75
|
|
76
|
+
# Update
|
77
|
+
def update(params = {})
|
78
|
+
@PARAM_HASH['TRANSACTION_TYPE'] = 'UPDATE'
|
79
|
+
@PARAM_HASH['RRNO'] = params[:trans_id]
|
80
|
+
@PARAM_HASH['AMOUNT'] = params[:amount] || ''
|
81
|
+
@api = "bp10emu"
|
82
|
+
end
|
83
|
+
|
77
84
|
# Void
|
78
85
|
def void(trans_id)
|
79
86
|
@PARAM_HASH['TRANSACTION_TYPE'] = 'VOID'
|
@@ -159,6 +166,71 @@ class BluePay
|
|
159
166
|
@PARAM_HASH['AMOUNT_MISC'] = amount_misc
|
160
167
|
end
|
161
168
|
|
169
|
+
# Adds information required for level 2 processing.
|
170
|
+
def add_level2_information(params)
|
171
|
+
@PARAM_HASH['LV2_ITEM_TAX_RATE'] = params[:tax_rate] || ''
|
172
|
+
@PARAM_HASH['LV2_ITEM_GOODS_TAX_RATE'] = params[:goods_tax_rate] || ''
|
173
|
+
@PARAM_HASH['LV2_ITEM_GOODS_TAX_AMOUNT'] = params[:goods_tax_amount] || ''
|
174
|
+
@PARAM_HASH['LV2_ITEM_SHIPPING_AMOUNT'] = params[:shipping_amount] || ''
|
175
|
+
@PARAM_HASH['LV2_ITEM_DISCOUNT_AMOUNT'] = params[:discount_amount] || ''
|
176
|
+
@PARAM_HASH['LV2_ITEM_CUST_PO'] = params[:cust_po] || ''
|
177
|
+
@PARAM_HASH['LV2_ITEM_GOODS_TAX_ID'] = params[:goods_tax_id] || ''
|
178
|
+
@PARAM_HASH['LV2_ITEM_TAX_ID'] = params[:tax_id] || ''
|
179
|
+
@PARAM_HASH['LV2_ITEM_CUSTOMER_TAX_ID'] = params[:customer_tax_id] || ''
|
180
|
+
@PARAM_HASH['LV2_ITEM_DUTY_AMOUNT'] = params[:duty_amount] || ''
|
181
|
+
@PARAM_HASH['LV2_ITEM_SUPPLEMENTAL_DATA'] = params[:supplemental_data] || ''
|
182
|
+
@PARAM_HASH['LV2_ITEM_CITY_TAX_RATE'] = params[:city_tax_rate] || ''
|
183
|
+
@PARAM_HASH['LV2_ITEM_CITY_TAX_AMOUNT'] = params[:city_tax_amount] || ''
|
184
|
+
@PARAM_HASH['LV2_ITEM_COUNTY_TAX_RATE'] = params[:county_tax_rate] || ''
|
185
|
+
@PARAM_HASH['LV2_ITEM_COUNTY_TAX_AMOUNT'] = params[:county_tax_amount] || ''
|
186
|
+
@PARAM_HASH['LV2_ITEM_STATE_TAX_RATE'] = params[:state_tax_rate] || ''
|
187
|
+
@PARAM_HASH['LV2_ITEM_STATE_TAX_AMOUNT'] = params[:state_tax_amount] || ''
|
188
|
+
@PARAM_HASH['LV2_ITEM_BUYER_NAME'] = params[:buyer_name] || ''
|
189
|
+
@PARAM_HASH['LV2_ITEM_CUSTOMER_REFERENCE'] = params[:customer_reference] || ''
|
190
|
+
@PARAM_HASH['LV2_ITEM_CUSTOMER_NUMBER'] = params[:customer_number] || ''
|
191
|
+
@PARAM_HASH['LV2_ITEM_SHIP_NAME'] = params[:ship_name] || ''
|
192
|
+
@PARAM_HASH['LV2_ITEM_SHIP_ADDR1'] = params[:ship_addr1] || ''
|
193
|
+
@PARAM_HASH['LV2_ITEM_SHIP_ADDR2'] = params[:ship_addr2] || ''
|
194
|
+
@PARAM_HASH['LV2_ITEM_SHIP_CITY'] = params[:ship_city] || ''
|
195
|
+
@PARAM_HASH['LV2_ITEM_SHIP_STATE'] = params[:ship_state] || ''
|
196
|
+
@PARAM_HASH['LV2_ITEM_SHIP_ZIP'] = params[:ship_zip] || ''
|
197
|
+
@PARAM_HASH['LV2_ITEM_SHIP_COUNTRY'] = params[:ship_country] || ''
|
198
|
+
end
|
199
|
+
|
200
|
+
# Adds a line item for level 3 processing. Repeat method for each item up to 99 items.
|
201
|
+
# For Canadian and AMEX processors, ensure required Level 2 information is present.
|
202
|
+
def add_line_item(params)
|
203
|
+
# Creates line items counter necessary for prefix.
|
204
|
+
@LINE_ITEMS = 0 if !@LINE_ITEMS
|
205
|
+
@LINE_ITEMS += 1 # VALUE REQUIRED IN:
|
206
|
+
prefix = "LV3_ITEM#{@LINE_ITEMS}_" # USA | CANADA
|
207
|
+
@PARAM_HASH[prefix + 'UNIT_COST'] = params[:unit_cost] # * *
|
208
|
+
@PARAM_HASH[prefix + 'QUANTITY'] = params[:quantity] # * *
|
209
|
+
@PARAM_HASH[prefix + 'ITEM_SKU'] = params[:item_sku] || '' # *
|
210
|
+
@PARAM_HASH[prefix + 'ITEM_DESCRIPTOR'] = params[:descriptor] || '' # * *
|
211
|
+
@PARAM_HASH[prefix + 'COMMODITY_CODE'] = params[:commodity_code] || '' # * *
|
212
|
+
@PARAM_HASH[prefix + 'PRODUCT_CODE'] = params[:product_code] || '' # *
|
213
|
+
@PARAM_HASH[prefix + 'MEASURE_UNITS'] = params[:measure_units] || '' # * *
|
214
|
+
@PARAM_HASH[prefix + 'ITEM_DISCOUNT'] = params[:item_discount] || '' # *
|
215
|
+
@PARAM_HASH[prefix + 'TAX_RATE'] = params[:tax_rate] || '' # *
|
216
|
+
@PARAM_HASH[prefix + 'GOODS_TAX_RATE'] = params[:goods_tax_rate] || '' # *
|
217
|
+
@PARAM_HASH[prefix + 'TAX_AMOUNT'] = params[:tax_amount] || '' # *
|
218
|
+
@PARAM_HASH[prefix + 'GOODS_TAX_AMOUNT'] = params[:goods_tax_amount] || '' # *
|
219
|
+
@PARAM_HASH[prefix + 'CITY_TAX_RATE'] = params[:city_tax_rate] || '' #
|
220
|
+
@PARAM_HASH[prefix + 'CITY_TAX_AMOUNT'] = params[:city_tax_amount] || '' #
|
221
|
+
@PARAM_HASH[prefix + 'COUNTY_TAX_RATE'] = params[:county_tax_rate] || '' #
|
222
|
+
@PARAM_HASH[prefix + 'COUNTY_TAX_AMOUNT'] = params[:county_tax_amount] || '' #
|
223
|
+
@PARAM_HASH[prefix + 'STATE_TAX_RATE'] = params[:state_tax_rate] || '' #
|
224
|
+
@PARAM_HASH[prefix + 'STATE_TAX_AMOUNT'] = params[:state_tax_amount] || '' #
|
225
|
+
@PARAM_HASH[prefix + 'CUST_SKU'] = params[:cust_sku] || '' #
|
226
|
+
@PARAM_HASH[prefix + 'CUST_PO'] = params[:cust_po] || '' #
|
227
|
+
@PARAM_HASH[prefix + 'SUPPLEMENTAL_DATA'] = params[:supplemental_data] || '' #
|
228
|
+
@PARAM_HASH[prefix + 'GL_ACCOUNT_NUMBER'] = params[:gl_account_number] || '' #
|
229
|
+
@PARAM_HASH[prefix + 'DIVISION_NUMBER'] = params[:division_number] || '' #
|
230
|
+
@PARAM_HASH[prefix + 'PO_LINE_NUMBER'] = params[:po_line_number] || '' #
|
231
|
+
@PARAM_HASH[prefix + 'LINE_ITEM_TOTAL'] = params[:line_item_total] || '' # *
|
232
|
+
end
|
233
|
+
|
162
234
|
# Set fields for a recurring payment
|
163
235
|
def set_recurring_payment(params = {})
|
164
236
|
@PARAM_HASH['REBILLING'] = '1'
|
@@ -321,21 +393,29 @@ class BluePay
|
|
321
393
|
@PARAM_HASH['PROTECT_CUSTOM_ID2'] = params[:protect_custom_id2] || "No"
|
322
394
|
@PARAM_HASH['SHPF_FORM_ID'] = params[:payment_template] || "mobileform01"
|
323
395
|
@PARAM_HASH['RECEIPT_FORM_ID'] = params[:receipt_template] || "mobileresult01"
|
324
|
-
@PARAM_HASH['REMOTE_URL'] = params[:receipt_temp_remote_url] || ''
|
396
|
+
@PARAM_HASH['REMOTE_URL'] = params[:receipt_temp_remote_url] || ''
|
397
|
+
@PARAM_HASH['SHPF_TPS_HASH_TYPE'] = "HMAC_SHA512"
|
398
|
+
@PARAM_HASH['RECEIPT_TPS_HASH_TYPE'] = @PARAM_HASH['SHPF_TPS_HASH_TYPE']
|
399
|
+
@PARAM_HASH['TPS_HASH_TYPE'] = set_hash_type(params[:tps_hash_type] || '')
|
325
400
|
@card_types = set_card_types
|
326
|
-
@receipt_tps_def = 'SHPF_ACCOUNT_ID SHPF_FORM_ID RETURN_URL DBA AMEX_IMAGE DISCOVER_IMAGE SHPF_TPS_DEF'
|
401
|
+
@receipt_tps_def = 'SHPF_ACCOUNT_ID SHPF_FORM_ID RETURN_URL DBA AMEX_IMAGE DISCOVER_IMAGE SHPF_TPS_DEF SHPF_TPS_HASH_TYPE'
|
327
402
|
@receipt_tps_string = set_receipt_tps_string
|
328
|
-
@receipt_tamper_proof_seal =
|
403
|
+
@receipt_tamper_proof_seal = create_tps_hash(@receipt_tps_string, @PARAM_HASH['RECEIPT_TPS_HASH_TYPE'])
|
329
404
|
@receipt_url = set_receipt_url
|
330
|
-
@bp10emu_tps_def = add_def_protected_status('MERCHANT APPROVED_URL DECLINED_URL MISSING_URL MODE TRANSACTION_TYPE TPS_DEF')
|
405
|
+
@bp10emu_tps_def = add_def_protected_status('MERCHANT APPROVED_URL DECLINED_URL MISSING_URL MODE TRANSACTION_TYPE TPS_DEF TPS_HASH_TYPE')
|
331
406
|
@bp10emu_tps_string = set_bp10emu_tps_string
|
332
|
-
@bp10emu_tamper_proof_seal =
|
333
|
-
@shpf_tps_def = add_def_protected_status('SHPF_FORM_ID SHPF_ACCOUNT_ID DBA TAMPER_PROOF_SEAL AMEX_IMAGE DISCOVER_IMAGE TPS_DEF SHPF_TPS_DEF')
|
407
|
+
@bp10emu_tamper_proof_seal = create_tps_hash(@bp10emu_tps_string, @PARAM_HASH['TPS_HASH_TYPE'])
|
408
|
+
@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')
|
334
409
|
@shpf_tps_string = set_shpf_tps_string
|
335
|
-
@shpf_tamper_proof_seal =
|
410
|
+
@shpf_tamper_proof_seal = create_tps_hash(@shpf_tps_string, @PARAM_HASH['SHPF_TPS_HASH_TYPE'])
|
336
411
|
return calc_url_response
|
337
412
|
end
|
338
413
|
|
414
|
+
def set_hash_type(chosen_hash)
|
415
|
+
default_hash = "HMAC_SHA512"
|
416
|
+
["MD5", "SHA256", "SHA512", "HMAC_SHA256"].include?(chosen_hash.upcase) ? chosen_hash.upcase : default_hash
|
417
|
+
end
|
418
|
+
|
339
419
|
# Sets the types of credit card images to use on the Simple Hosted Payment Form. Must be used with generate_url.
|
340
420
|
def set_card_types
|
341
421
|
credit_cards = 'vi-mc'
|
@@ -346,41 +426,42 @@ class BluePay
|
|
346
426
|
|
347
427
|
# Sets the receipt Tamperproof Seal string. Must be used with generate_url.
|
348
428
|
def set_receipt_tps_string
|
349
|
-
[@
|
350
|
-
@ACCOUNT_ID,
|
429
|
+
[@ACCOUNT_ID,
|
351
430
|
@PARAM_HASH['RECEIPT_FORM_ID'],
|
352
431
|
@PARAM_HASH['RETURN_URL'],
|
353
432
|
@PARAM_HASH['DBA'],
|
354
433
|
@PARAM_HASH['AMEX_IMAGE'],
|
355
434
|
@PARAM_HASH['DISCOVER_IMAGE'],
|
356
|
-
@receipt_tps_def
|
435
|
+
@receipt_tps_def,
|
436
|
+
@PARAM_HASH['RECEIPT_TPS_HASH_TYPE']].join('')
|
357
437
|
end
|
358
438
|
|
359
439
|
# Sets the bp10emu string that will be used to create a Tamperproof Seal. Must be used with generate_url.
|
360
440
|
def set_bp10emu_tps_string
|
361
441
|
bp10emu = [
|
362
|
-
@SECRET_KEY,
|
363
442
|
@ACCOUNT_ID,
|
364
443
|
@receipt_url,
|
365
444
|
@receipt_url,
|
366
445
|
@receipt_url,
|
367
446
|
@PARAM_HASH['MODE'],
|
368
447
|
@PARAM_HASH['TRANSACTION_TYPE'],
|
369
|
-
@bp10emu_tps_def
|
448
|
+
@bp10emu_tps_def,
|
449
|
+
@PARAM_HASH['TPS_HASH_TYPE']].join('')
|
370
450
|
return add_string_protected_status(bp10emu)
|
371
451
|
end
|
372
452
|
|
373
453
|
# Sets the Simple Hosted Payment Form string that will be used to create a Tamperproof Seal. Must be used with generate_url.
|
374
454
|
def set_shpf_tps_string
|
375
|
-
shpf = ([@
|
376
|
-
@PARAM_HASH['SHPF_FORM_ID'],
|
455
|
+
shpf = ([@PARAM_HASH['SHPF_FORM_ID'],
|
377
456
|
@ACCOUNT_ID,
|
378
457
|
@PARAM_HASH['DBA'],
|
379
458
|
@bp10emu_tamper_proof_seal,
|
380
459
|
@PARAM_HASH['AMEX_IMAGE'],
|
381
460
|
@PARAM_HASH['DISCOVER_IMAGE'],
|
382
|
-
@bp10emu_tps_def,
|
383
|
-
@
|
461
|
+
@bp10emu_tps_def,
|
462
|
+
@PARAM_HASH['TPS_HASH_TYPE'],
|
463
|
+
@shpf_tps_def,
|
464
|
+
@PARAM_HASH['SHPF_TPS_HASH_TYPE']].join(''))
|
384
465
|
return add_string_protected_status(shpf)
|
385
466
|
end
|
386
467
|
|
@@ -390,13 +471,14 @@ class BluePay
|
|
390
471
|
return @PARAM_HASH['REMOTE_URL']
|
391
472
|
else
|
392
473
|
return 'https://secure.bluepay.com/interfaces/shpf?SHPF_FORM_ID=' + @PARAM_HASH['RECEIPT_FORM_ID'] +
|
393
|
-
'&SHPF_ACCOUNT_ID='
|
394
|
-
'&SHPF_TPS_DEF='
|
395
|
-
'&
|
396
|
-
'&
|
397
|
-
'&
|
398
|
-
'&
|
399
|
-
'&
|
474
|
+
'&SHPF_ACCOUNT_ID=' + @ACCOUNT_ID +
|
475
|
+
'&SHPF_TPS_DEF=' + url_encode(@receipt_tps_def) +
|
476
|
+
'&SHPF_TPS_HASH_TYPE=' + url_encode(@PARAM_HASH['RECEIPT_TPS_HASH_TYPE']) +
|
477
|
+
'&SHPF_TPS=' + url_encode(@receipt_tamper_proof_seal) +
|
478
|
+
'&RETURN_URL=' + url_encode(@PARAM_HASH['RETURN_URL']) +
|
479
|
+
'&DBA=' + url_encode(@PARAM_HASH['DBA']) +
|
480
|
+
'&AMEX_IMAGE=' + url_encode(@PARAM_HASH['AMEX_IMAGE']) +
|
481
|
+
'&DISCOVER_IMAGE=' + url_encode(@PARAM_HASH['DISCOVER_IMAGE'])
|
400
482
|
end
|
401
483
|
end
|
402
484
|
|
@@ -428,17 +510,13 @@ class BluePay
|
|
428
510
|
return encoded_string
|
429
511
|
end
|
430
512
|
|
431
|
-
# Generates a Tamperproof Seal for a url. Must be used with generate_url.
|
432
|
-
def calc_url_tps(tps_type)
|
433
|
-
Digest::MD5.hexdigest(tps_type)
|
434
|
-
end
|
435
|
-
|
436
513
|
# Generates the final url for the Simple Hosted Payment Form. Must be used with generate_url.
|
437
514
|
def calc_url_response
|
438
515
|
'https://secure.bluepay.com/interfaces/shpf?' +
|
439
516
|
'SHPF_FORM_ID=' .concat(url_encode (@PARAM_HASH['SHPF_FORM_ID']) ) +
|
440
517
|
'&SHPF_ACCOUNT_ID=' .concat(url_encode (@ACCOUNT_ID) ) +
|
441
518
|
'&SHPF_TPS_DEF=' .concat(url_encode (@shpf_tps_def) ) +
|
519
|
+
'&SHPF_TPS_HASH_TYPE='.concat(url_encode (@PARAM_HASH['SHPF_TPS_HASH_TYPE']) ) +
|
442
520
|
'&SHPF_TPS=' .concat(url_encode (@shpf_tamper_proof_seal) ) +
|
443
521
|
'&MODE=' .concat(url_encode (@PARAM_HASH['MODE']) ) +
|
444
522
|
'&TRANSACTION_TYPE=' .concat(url_encode (@PARAM_HASH['TRANSACTION_TYPE']) ) +
|
@@ -456,6 +534,7 @@ class BluePay
|
|
456
534
|
'&DISCOVER_IMAGE=' .concat(url_encode (@PARAM_HASH['DISCOVER_IMAGE']) ) +
|
457
535
|
'&REDIRECT_URL=' .concat(url_encode (@receipt_url) ) +
|
458
536
|
'&TPS_DEF=' .concat(url_encode (@bp10emu_tps_def) ) +
|
537
|
+
'&TPS_HASH_TYPE=' .concat(url_encode (@PARAM_HASH['TPS_HASH_TYPE']) ) +
|
459
538
|
'&CARD_TYPES=' .concat(url_encode (@card_types) )
|
460
539
|
end
|
461
|
-
end
|
540
|
+
end
|
data/lib/cacert.pem
CHANGED
File without changes
|
@@ -10,9 +10,13 @@
|
|
10
10
|
require_relative "../../lib/bluepay.rb"
|
11
11
|
require "cgi"
|
12
12
|
|
13
|
-
|
13
|
+
ACCOUNT_ID = "Merchant's Account ID Here"
|
14
|
+
SECRET_KEY = "Merchant's Secret Key Here"
|
15
|
+
MODE = "TEST"
|
16
|
+
|
17
|
+
tps = BluePay.new(account_id: ACCOUNT_ID, secret_key: SECRET_KEY, mode: MODE)
|
14
18
|
|
15
|
-
|
19
|
+
vars = CGI.new
|
16
20
|
|
17
21
|
# Assign values
|
18
22
|
trans_id = vars["trans_id"]
|
@@ -20,33 +24,22 @@ trans_status = vars["trans_status"]
|
|
20
24
|
trans_type = vars["trans_type"]
|
21
25
|
amount = vars["amount"]
|
22
26
|
batch_id = vars["batch_id"]
|
23
|
-
batch_status = vars["batch_status"]
|
24
|
-
total_count = vars["total_count"]
|
25
|
-
total_amount = vars["total_amount"]
|
26
|
-
batch_upload_id = vars["batch_upload_id"]
|
27
27
|
rebill_id = vars["rebill_id"]
|
28
28
|
rebill_amount = vars["reb_amount"]
|
29
29
|
rebill_status = vars["status"]
|
30
|
+
tps_hash_type = vars["TPS_HASH_TYPE"]
|
31
|
+
bp_stamp = vars["BP_STAMP"]
|
32
|
+
bp_stamp_def = vars["BP_STAMP_DEF"]
|
30
33
|
|
31
34
|
# Calculate expected bp_stamp
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
amount,
|
38
|
-
batch_id,
|
39
|
-
batch_status,
|
40
|
-
total_count,
|
41
|
-
total_amount,
|
42
|
-
batch_upload_id,
|
43
|
-
rebill_id,
|
44
|
-
rebill_amount,
|
45
|
-
rebill_status
|
46
|
-
)
|
35
|
+
bp_stamp_string = ''
|
36
|
+
bp_stamp_def.split(' ').each do |field|
|
37
|
+
bp_stamp_string += vars[field]
|
38
|
+
end
|
39
|
+
expected_stamp = tps.create_tps_hash(bp_stamp_string, tps_hash_type).upcase
|
47
40
|
|
48
41
|
# check if expected bp_stamp = actual bp_stamp
|
49
|
-
if
|
42
|
+
if expected_stamp == vars["BP_STAMP"]
|
50
43
|
|
51
44
|
# Reads the response from BluePay
|
52
45
|
puts 'Transaction ID: ' + trans_id
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
##
|
4
|
+
# BluePay Ruby Sample code.
|
5
|
+
#
|
6
|
+
# This code sample reads the values from a BP10emu redirect
|
7
|
+
# and authenticates the message using the the BP_STAMP
|
8
|
+
# provided in the response. Point the REDIRECT_URL of your
|
9
|
+
# BP10emu request to the location of this script on your server.
|
10
|
+
##
|
11
|
+
|
12
|
+
print "Content-type:text/html\r\n\r\n"
|
13
|
+
print "<html><head></head><body>"
|
14
|
+
|
15
|
+
require_relative "bluepay.rb"
|
16
|
+
require "cgi"
|
17
|
+
|
18
|
+
ACCOUNT_ID = "Merchant's Account ID Here"
|
19
|
+
SECRET_KEY = "Merchant's Secret Key Here"
|
20
|
+
MODE = "TEST"
|
21
|
+
|
22
|
+
response = CGI.new
|
23
|
+
|
24
|
+
if response["BP_STAMP"] # Check whether BP_STAMP is provided
|
25
|
+
|
26
|
+
bp = BluePay.new(account_id: ACCOUNT_ID, secret_key: SECRET_KEY, mode: MODE)
|
27
|
+
|
28
|
+
bp_stamp_string = ''
|
29
|
+
response["BP_STAMP_DEF"].split(' ').each do |field| # Split BP_STAMP_DEF on whitespace
|
30
|
+
bp_stamp_string += response[field] # Concatenate values used to calculate expected BP_STAMP
|
31
|
+
end
|
32
|
+
expected_stamp = bp.create_tps_hash(bp_stamp_string, response["TPS_HASH_TYPE"]).upcase # Calculate expected BP_STAMP using hash function specified in response
|
33
|
+
|
34
|
+
if expected_stamp == response["BP_STAMP"] # Compare expected BP_STAMP with received BP_STAMP
|
35
|
+
# Validate BP_STAMP and reads the response results
|
36
|
+
print "VALID BP_STAMP: TRUE<br/>"
|
37
|
+
response.params.each{|k,v| print "#{k}: #{v[0]}<br/>"}
|
38
|
+
else
|
39
|
+
print "ERROR: BP_STAMP VALUES DO NOT MATCH<br/>"
|
40
|
+
end
|
41
|
+
|
42
|
+
else
|
43
|
+
print "ERROR: BP_STAMP NOT FOUND. CHECK MESSAGE & RESPONSEVERSION<br/>"
|
44
|
+
end
|
45
|
+
|
46
|
+
print "</body></html>"
|
@@ -35,7 +35,7 @@ rebill.set_customer_information(
|
|
35
35
|
|
36
36
|
rebill.set_cc_information(
|
37
37
|
cc_number: "4111111111111111", # Customer Credit Card Number
|
38
|
-
cc_expiration: "
|
38
|
+
cc_expiration: "1225", # Card Expiration Date: MMYY
|
39
39
|
cvv2: "123" # Card CVV2
|
40
40
|
)
|
41
41
|
|
@@ -78,4 +78,4 @@ if rebill.successful_transaction?
|
|
78
78
|
puts "REBILL NEXT AMOUNT: " + rebill_cancel.get_next_amount
|
79
79
|
else
|
80
80
|
puts rebill.get_message
|
81
|
-
end
|
81
|
+
end
|
@@ -31,7 +31,7 @@ rebill.set_customer_information(
|
|
31
31
|
|
32
32
|
rebill.set_cc_information(
|
33
33
|
cc_number: "4111111111111111", # Customer Credit Card Number
|
34
|
-
cc_expiration: "
|
34
|
+
cc_expiration: "1225", # Card Expiration Date: MMYY
|
35
35
|
cvv2: "123" # Card CVV2
|
36
36
|
)
|
37
37
|
|
@@ -61,4 +61,4 @@ if rebill.successful_transaction?
|
|
61
61
|
puts "AUTH CODE: " + rebill.get_auth_code
|
62
62
|
else
|
63
63
|
puts rebill.get_message
|
64
|
-
end
|
64
|
+
end
|
@@ -36,7 +36,7 @@ rebill.set_customer_information(
|
|
36
36
|
|
37
37
|
rebill.set_cc_information(
|
38
38
|
cc_number: "4111111111111111", # Customer Credit Card Number
|
39
|
-
cc_expiration: "
|
39
|
+
cc_expiration: "1225", # Card Expiration Date: MMYY
|
40
40
|
cvv2: "123" # Card CVV2
|
41
41
|
)
|
42
42
|
|
@@ -36,7 +36,7 @@ rebill.set_customer_information(
|
|
36
36
|
|
37
37
|
rebill.set_cc_information(
|
38
38
|
cc_number: "4111111111111111", # Customer Credit Card Number
|
39
|
-
cc_expiration: "
|
39
|
+
cc_expiration: "1225", # Card Expiration Date: MMYY
|
40
40
|
cvv2: "123" # Card CVV2
|
41
41
|
)
|
42
42
|
|
@@ -64,7 +64,7 @@ if rebill.successful_transaction?
|
|
64
64
|
|
65
65
|
# Sets an updated credit card expiration date
|
66
66
|
payment_information_update.set_cc_information(
|
67
|
-
cc_expiration: "
|
67
|
+
cc_expiration: "1229" # Card Expiration
|
68
68
|
)
|
69
69
|
|
70
70
|
# Stores new card expiration date
|
@@ -35,7 +35,7 @@ payment.set_customer_information(
|
|
35
35
|
|
36
36
|
payment.set_cc_information(
|
37
37
|
cc_number: "4111111111111111", # Customer Credit Card Number
|
38
|
-
cc_expiration: "
|
38
|
+
cc_expiration: "1225", # Card Expiration Date: MMYY
|
39
39
|
cvv2: "123" # Card CVV2
|
40
40
|
)
|
41
41
|
|
@@ -71,4 +71,4 @@ if payment.successful_transaction?
|
|
71
71
|
puts "AUTH CODE: " + payment_void.get_auth_code
|
72
72
|
else
|
73
73
|
puts payment.get_message
|
74
|
-
end
|
74
|
+
end
|
@@ -9,8 +9,8 @@
|
|
9
9
|
|
10
10
|
require_relative "../../lib/bluepay.rb"
|
11
11
|
|
12
|
-
ACCOUNT_ID = "Merchant's Account ID
|
13
|
-
SECRET_KEY = "Merchant's Secret Key
|
12
|
+
ACCOUNT_ID = "Merchant's Account ID here"
|
13
|
+
SECRET_KEY = "Merchant's Secret Key here"
|
14
14
|
MODE = "TEST"
|
15
15
|
|
16
16
|
payment = BluePay.new(
|
@@ -34,7 +34,7 @@ payment.set_customer_information(
|
|
34
34
|
|
35
35
|
payment.set_cc_information(
|
36
36
|
cc_number: "4111111111111111", # Customer Credit Card Number
|
37
|
-
cc_expiration: "
|
37
|
+
cc_expiration: "1225", # Card Expiration Date: MMYY
|
38
38
|
cvv2: "123" # Card CVV2
|
39
39
|
)
|
40
40
|
|
@@ -0,0 +1,91 @@
|
|
1
|
+
##
|
2
|
+
# BluePay Ruby Sample code.
|
3
|
+
#
|
4
|
+
# This code sample runs a Credit Card sales transaction,
|
5
|
+
# including sample Level 2 and 3 processing information,
|
6
|
+
# against a customer using test payment information.
|
7
|
+
# If using TEST mode, odd dollar amounts will return
|
8
|
+
# an approval and even dollar amounts will return a decline.
|
9
|
+
##
|
10
|
+
|
11
|
+
require_relative "../../lib/bluepay.rb"
|
12
|
+
|
13
|
+
ACCOUNT_ID = "Merchant's Account ID here"
|
14
|
+
SECRET_KEY = "Merchant's Secret Key here"
|
15
|
+
MODE = "TEST"
|
16
|
+
|
17
|
+
payment = BluePay.new(
|
18
|
+
account_id: ACCOUNT_ID,
|
19
|
+
secret_key: SECRET_KEY,
|
20
|
+
mode: MODE
|
21
|
+
)
|
22
|
+
|
23
|
+
payment.set_customer_information(
|
24
|
+
first_name: "Bob",
|
25
|
+
last_name: "Tester",
|
26
|
+
address1: "123 Test St.",
|
27
|
+
address2: "Apt #500",
|
28
|
+
city: "Testville",
|
29
|
+
state: "IL",
|
30
|
+
zip_code: "54321",
|
31
|
+
country: "USA",
|
32
|
+
phone: "123-123-1234",
|
33
|
+
email: "test@bluepay.com"
|
34
|
+
)
|
35
|
+
|
36
|
+
payment.set_cc_information(
|
37
|
+
cc_number: "4111111111111111", # Customer Credit Card Number
|
38
|
+
cc_expiration: "1225", # Card Expiration Date: MMYY
|
39
|
+
cvv2: "123" # Card CVV2
|
40
|
+
)
|
41
|
+
|
42
|
+
# Set Level 2 Information
|
43
|
+
payment.invoice_id = "123456789"
|
44
|
+
payment.amount_tax = "0.91"
|
45
|
+
|
46
|
+
# Set Level 3 line item information. Repeat for each item up to 99.
|
47
|
+
payment.add_line_item(
|
48
|
+
quantity: "1", # The number of units of item. Max: 5 digits
|
49
|
+
unit_cost: "3.00", # The cost per unit of item. Max: 9 digits decimal
|
50
|
+
descriptor: "test1", # Description of the item purchased. Max: 26 character
|
51
|
+
commodity_code: "123412341234", # Commodity Codes can be found at http://www.census.gov/svsd/www/cfsdat/2002data/cfs021200.pdf. Max: 12 characters
|
52
|
+
product_code: "432143214321", # Merchant-defined code for the product or service being purchased. Max: 12 characters
|
53
|
+
measure_units: "EA", # The unit of measure of the item purchase. Normally EA. Max: 3 characters
|
54
|
+
tax_rate: "7%", # Tax rate for the item. Max: 4 digits
|
55
|
+
tax_amount: "0.21", # Tax amount for the item. unit_cost * quantity * tax_rate = tax_amount. Max: 9 digits.
|
56
|
+
item_discount: "0.00", # The amount of any discounts on the item. Max: 12 digits.
|
57
|
+
line_item_total: "3.21" # The total amount for the item including taxes and discounts.
|
58
|
+
)
|
59
|
+
|
60
|
+
payment.add_line_item(
|
61
|
+
quantity: "2",
|
62
|
+
unit_cost: "5.00",
|
63
|
+
descriptor: "test2",
|
64
|
+
commodity_code: "123412341234",
|
65
|
+
product_code: "098709870987",
|
66
|
+
measure_units: "EA",
|
67
|
+
tax_rate: "7%",
|
68
|
+
tax_amount: "0.70",
|
69
|
+
item_discount: "0.00",
|
70
|
+
line_item_total: "10.70"
|
71
|
+
)
|
72
|
+
|
73
|
+
payment.sale(amount: "13.91") # Sale Amount: $13.91
|
74
|
+
|
75
|
+
# Makes the API Request with BluePay
|
76
|
+
payment.process
|
77
|
+
|
78
|
+
# If transaction was successful reads the responses from BluePay
|
79
|
+
if payment.successful_transaction?
|
80
|
+
puts "TRANSACTION STATUS: " + payment.get_status
|
81
|
+
puts "TRANSACTION MESSAGE: " + payment.get_message
|
82
|
+
puts "TRANSACTION ID: " + payment.get_trans_id
|
83
|
+
puts "AVS RESPONSE: " + payment.get_avs_code
|
84
|
+
puts "CVV2 RESPONSE: " + payment.get_cvv2_code
|
85
|
+
puts "MASKED PAYMENT ACCOUNT: " + payment.get_masked_account
|
86
|
+
puts "CARD TYPE: " + payment.get_card_type
|
87
|
+
puts "AUTH CODE: " + payment.get_auth_code
|
88
|
+
else
|
89
|
+
puts payment.get_message
|
90
|
+
end
|
91
|
+
|
@@ -33,7 +33,7 @@ payment.set_customer_information(
|
|
33
33
|
|
34
34
|
payment.set_cc_information(
|
35
35
|
cc_number: "4111111111111111", # Customer Credit Card Number
|
36
|
-
cc_expiration: "
|
36
|
+
cc_expiration: "1225", # Card Expiration Date: MMYY
|
37
37
|
cvv2: "123" # Card CVV2
|
38
38
|
)
|
39
39
|
|
@@ -54,4 +54,4 @@ if payment.successful_transaction?
|
|
54
54
|
puts "AUTH CODE: " + payment.get_auth_code
|
55
55
|
else
|
56
56
|
puts payment.get_message
|
57
|
-
end
|
57
|
+
end
|
@@ -35,7 +35,7 @@ payment.set_customer_information(
|
|
35
35
|
|
36
36
|
payment.set_cc_information(
|
37
37
|
cc_number: "4111111111111111", # Customer Credit Card Number
|
38
|
-
cc_expiration: "
|
38
|
+
cc_expiration: "1225", # Card Expiration Date: MMYY
|
39
39
|
cvv2: "123" # Card CVV2
|
40
40
|
)
|
41
41
|
|
@@ -67,4 +67,4 @@ if payment.successful_transaction?
|
|
67
67
|
puts "AUTH CODE: " + payment.get_auth_code
|
68
68
|
else
|
69
69
|
puts payment.get_message
|
70
|
-
end
|
70
|
+
end
|
@@ -36,7 +36,7 @@ payment.set_customer_information(
|
|
36
36
|
|
37
37
|
payment.set_cc_information(
|
38
38
|
cc_number: "4111111111111111", # Customer Credit Card Number
|
39
|
-
cc_expiration: "
|
39
|
+
cc_expiration: "1225", # Card Expiration Date: MMYY
|
40
40
|
cvv2: "123" # Card CVV2
|
41
41
|
)
|
42
42
|
|
@@ -74,4 +74,4 @@ if payment.successful_transaction?
|
|
74
74
|
puts "AUTH CODE: " + payment_return.get_auth_code
|
75
75
|
else
|
76
76
|
puts payment_return.get_message
|
77
|
-
end
|
77
|
+
end
|
@@ -33,7 +33,7 @@ payment.set_customer_information(
|
|
33
33
|
|
34
34
|
payment.set_cc_information(
|
35
35
|
cc_number: "4111111111111111", # Customer Credit Card Number
|
36
|
-
cc_expiration: "
|
36
|
+
cc_expiration: "1225", # Card Expiration Date: MMYY
|
37
37
|
cvv2: "123" # Card CVV2
|
38
38
|
)
|
39
39
|
|
@@ -54,4 +54,4 @@ if payment.successful_transaction?
|
|
54
54
|
puts "AUTH CODE: " + payment.get_auth_code
|
55
55
|
else
|
56
56
|
puts payment.get_message
|
57
|
-
end
|
57
|
+
end
|
data/test/Transactions/Swipe.rb
CHANGED
@@ -30,7 +30,7 @@ payment.set_customer_information(
|
|
30
30
|
)
|
31
31
|
|
32
32
|
# Set payment information for a swiped credit card transaction
|
33
|
-
payment.swipe("%B4111111111111111^TEST/BLUEPAY^
|
33
|
+
payment.swipe("%B4111111111111111^TEST/BLUEPAY^2511101100001100000000667000000?;4111111111111111=251110110000667?")
|
34
34
|
|
35
35
|
payment.sale(amount: "3.00") # Sale Amount: $3.00
|
36
36
|
|
@@ -0,0 +1,77 @@
|
|
1
|
+
##
|
2
|
+
# BluePay Ruby Sample code.
|
3
|
+
#
|
4
|
+
# This code sample runs a $3.00 Credit Card Sale transaction
|
5
|
+
# against a customer using test payment information. If
|
6
|
+
# approved, a 2nd transaction is run to update the first transaction
|
7
|
+
# to $5.75, $2.75 more than the original $3.00.
|
8
|
+
# If using TEST mode, odd dollar amounts will return
|
9
|
+
# an approval and even dollar amounts will return a decline.
|
10
|
+
##
|
11
|
+
|
12
|
+
require_relative "../../lib/bluepay.rb"
|
13
|
+
|
14
|
+
ACCOUNT_ID = "Merchant's Account ID"
|
15
|
+
SECRET_KEY = "Merchant's Secret Key"
|
16
|
+
MODE = "TEST"
|
17
|
+
|
18
|
+
payment = BluePay.new(
|
19
|
+
account_id: ACCOUNT_ID,
|
20
|
+
secret_key: SECRET_KEY,
|
21
|
+
mode: MODE
|
22
|
+
)
|
23
|
+
|
24
|
+
payment.set_customer_information(
|
25
|
+
first_name: "Bob",
|
26
|
+
last_name: "Tester",
|
27
|
+
address1: "123 Test St.",
|
28
|
+
address2: "Apt #500",
|
29
|
+
city: "Testville",
|
30
|
+
state: "IL",
|
31
|
+
zip_code: "54321",
|
32
|
+
country: "USA",
|
33
|
+
phone: "123-123-1234",
|
34
|
+
email: "test@bluepay.com"
|
35
|
+
)
|
36
|
+
|
37
|
+
payment.set_cc_information(
|
38
|
+
cc_number: "4111111111111111", # Customer Credit Card Number
|
39
|
+
cc_expiration: "1225", # Card Expiration Date: MMYY
|
40
|
+
cvv2: "123" # Card CVV2
|
41
|
+
)
|
42
|
+
|
43
|
+
payment.sale(amount: "3.00") # Sale Amount: $3.00
|
44
|
+
|
45
|
+
# Makes the API Request for processing the sale
|
46
|
+
payment.process
|
47
|
+
|
48
|
+
# If transaction was approved..
|
49
|
+
if payment.successful_transaction?
|
50
|
+
|
51
|
+
payment_update = BluePay.new(
|
52
|
+
account_id: ACCOUNT_ID,
|
53
|
+
secret_key: SECRET_KEY,
|
54
|
+
mode: MODE
|
55
|
+
)
|
56
|
+
|
57
|
+
# Creates an update transaction against previous sale
|
58
|
+
payment_update.update(
|
59
|
+
trans_id: payment.get_trans_id, # id of previous transaction to update
|
60
|
+
amount: "5.75" # add $2.75 to previous amount
|
61
|
+
)
|
62
|
+
|
63
|
+
# Makes the API Request to process update
|
64
|
+
payment_update.process
|
65
|
+
|
66
|
+
# Reads the response from BluePay
|
67
|
+
puts "TRANSACTION STATUS: " + payment_update.get_status
|
68
|
+
puts "TRANSACTION MESSAGE: " + payment_update.get_message
|
69
|
+
puts "TRANSACTION ID: " + payment_update.get_trans_id
|
70
|
+
puts "AVS RESPONSE: " + payment_update.get_avs_code
|
71
|
+
puts "CVV2 RESPONSE: " + payment_update.get_cvv2_code
|
72
|
+
puts "MASKED PAYMENT ACCOUNT: " + payment_update.get_masked_account
|
73
|
+
puts "CARD TYPE: " + payment_update.get_card_type
|
74
|
+
puts "AUTH CODE: " + payment_update.get_auth_code
|
75
|
+
else
|
76
|
+
puts payment_update.get_message
|
77
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bluepay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Justin Slingerland, Susan Schmidt
|
7
|
+
- Justin Slingerland, Susan Schmidt, Eric Margules
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This gem is intended to be used along with a BluePay gateway account
|
14
14
|
to process credit card and ACH transactions
|
@@ -17,14 +17,18 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
+
- README
|
21
|
+
- Rakefile
|
22
|
+
- bluepay.gemspec
|
20
23
|
- lib/api_request.rb
|
21
24
|
- lib/api_response.rb
|
22
25
|
- lib/bluepay.rb
|
23
26
|
- lib/cacert.pem
|
24
27
|
- test/Get_Data/Retrieve_Settlement_Data.rb
|
25
|
-
- test/Get_Data/
|
28
|
+
- test/Get_Data/Retrieve_Transaction_Data.rb
|
26
29
|
- test/Get_Data/Single_Transaction_Query.rb
|
27
30
|
- test/Get_Data/Transaction_Notification.rb
|
31
|
+
- test/Get_Data/Validate_BP_Stamp.rb
|
28
32
|
- test/Rebill/Cancel_Recurring_Payment.rb
|
29
33
|
- test/Rebill/Create_Recurring_Payment_ACH.rb
|
30
34
|
- test/Rebill/Create_Recurring_Payment_CC.rb
|
@@ -32,16 +36,15 @@ files:
|
|
32
36
|
- test/Rebill/Update_Recurring_Payment.rb
|
33
37
|
- test/Transactions/Cancel_Transaction.rb
|
34
38
|
- test/Transactions/Charge_Customer_ACH.rb
|
35
|
-
- test/Transactions/
|
39
|
+
- test/Transactions/Charge_Customer_CC.rb
|
40
|
+
- test/Transactions/Charge_Customer_CC_Lvl2_Lvl3.rb
|
36
41
|
- test/Transactions/Check_Customer_Credit.rb
|
37
42
|
- test/Transactions/Customer_Defined_Data.rb
|
38
43
|
- test/Transactions/How_To_Use_Token.rb
|
39
44
|
- test/Transactions/Return_Funds.rb
|
40
45
|
- test/Transactions/Store_Payment_Information.rb
|
41
46
|
- test/Transactions/Swipe.rb
|
42
|
-
-
|
43
|
-
- Rakefile
|
44
|
-
- README
|
47
|
+
- test/Transactions/Update_Transaction.rb
|
45
48
|
homepage: http://www.bluepay.com
|
46
49
|
licenses:
|
47
50
|
- GPL
|
@@ -52,17 +55,17 @@ require_paths:
|
|
52
55
|
- lib
|
53
56
|
required_ruby_version: !ruby/object:Gem::Requirement
|
54
57
|
requirements:
|
55
|
-
- -
|
58
|
+
- - ">="
|
56
59
|
- !ruby/object:Gem::Version
|
57
60
|
version: '0'
|
58
61
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
62
|
requirements:
|
60
|
-
- -
|
63
|
+
- - ">="
|
61
64
|
- !ruby/object:Gem::Version
|
62
65
|
version: '0'
|
63
66
|
requirements: []
|
64
67
|
rubyforge_project:
|
65
|
-
rubygems_version: 2.
|
68
|
+
rubygems_version: 2.6.14
|
66
69
|
signing_key:
|
67
70
|
specification_version: 4
|
68
71
|
summary: BluePay gateway rubygem
|