Skip to content

Instantly share code, notes, and snippets.

@theCrab
Last active December 15, 2015 12:59
Show Gist options
  • Save theCrab/5264511 to your computer and use it in GitHub Desktop.
Save theCrab/5264511 to your computer and use it in GitHub Desktop.
At every 4th line (where the integer is) I want to create a new CSV line The Integer is the first field in the row. NOTE: Some of the lines are blank " ", and ENCODING is funny Text lines to CSV in ruby
# Verifone Error codes. There are 215 codes and they are [-1...-189] and [-999...-1014]. Just take the important ones :=(
error_codes = [
[ code: "-0", description: "Unspecified error", action: "Contact VeriFone" ],
[ code: "-1", description: "Invalid transaction type", action: " Use alternative method for transaction type" ],
[ code: "-2", description: " ", action: "" ],
[ code: "-3", description: " ", action: "" ],
[ code: "-4", description: " ", action: "" ],
[ code: "-5", description: " ", action: "" ],
[ code: "-6", description: " ", action: "" ],
[ code: "-7", description: " ", action: "" ],
[ code: "-8", description: " ", action: "" ],
[ code: "-9", description: " ", action: "" ],
[ code: "-10", description: " ", action: "" ],
]
1
Unspecified error
Contact VeriFone
2
Invalid transaction type
An example of this could be a Refund being passed when the site are not set up to do so. A trace of what was passed will be in the system log.
Use alternative method for transaction type.
3
Invalid card / invalid Track2
General card error. Track2 must either be ;PAN=YYMMsssÖÖ?x or just the PAN.
Re-enter card number or re-swipe card
4
Card scheme not recognised
The card Issuer Identification Number (IIN) has not been located in the IIN table. The IIN is typically the first 4 to 6 digits of the card number.
Prompt for alternate method of payment
5
Card scheme not accepted
"The card has been identified, but the card scheme is not accepted at the given site."
Reject Transaction
6
Invalid card number (lcd)
The LUHN check digit is incorrect (the card has been mis-keyed or mis-swiped).
Re-enter card number or re-swipe card
7
Invalid card number length
The length of the PAN is incorrect for the given card scheme.
Re-enter card number or re-swipe card
8
Invalid card number (pcd)
The pen-ultimate check digit is invalid.
Re-enter card number or re-swipe card
@GeekOnCoffee
Copy link

irb(main):070:0> str.split("\n").each_slice(4) do |a|
irb(main):071:1* p a
irb(main):072:1> end

@theCrab
Copy link
Author

theCrab commented Mar 28, 2013

error code, description, technical description, action
'-1', 'Unspecified error', ' ', 'Contact VeriFone'
'-2', 'Invalid transaction type', 'An example of this could be..', 'Use alternative method for txn...'

@mbj this is the format. The HEADERS are in bold

@GeekOnCoffee
Copy link

arr = []
str.split("\n").each_slice(4) do |a|
arr << {:code => a[0], :description => a[1], :action => a[2]}
end

@theCrab
Copy link
Author

theCrab commented Mar 28, 2013

err = File.open('VerifoneErrorCodes.txt', 'r').lines.each_slice(4).map { |code, description, tech_description, action| {code: code, description: description, tech_description: tech_description, action: action}}

Write errto file

out = File.new('all_erros.js', 'w')
err.each_slice(4) { |c| out.puts c}
out.close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment