Class: BluePay
- Inherits:
-
Object
- Object
- BluePay
- 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 For testing purposes, this gem comes with a CA bundle.
"."
Class Method Summary collapse
-
.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) ⇒ Object
Calculates TAMPER_PROOF_SEAL to be used with Trans Notify API.
Instance Method Summary collapse
-
#amount_food=(amount_food) ⇒ Object
Set AMOUNT_FOOD field.
-
#amount_misc=(amount_misc) ⇒ Object
Set AMOUNT_MISC field.
-
#amount_tax=(amount_tax) ⇒ Object
Set AMOUNT_TAX field.
-
#amount_tip=(amount_tip) ⇒ Object
Set AMOUNT_TIP field.
-
#auth(params = {}) ⇒ Object
Set up an Auth.
-
#calc_rebill_tps ⇒ Object
Sets TAMPER_PROOF_SEAL in @PARAM_HASH for rebadmin API.
-
#calc_report_tps ⇒ Object
Sets TAMPER_PROOF_SEAL in @PARAM_HASH for bpdailyreport2 API.
-
#calc_tps ⇒ Object
Sets TAMPER_PROOF_SEAL in @PARAM_HASH.
-
#cancel_rebilling_cycle(rebill_id) ⇒ Object
Set fields to cancel an existing rebilling cycle.
-
#capture(trans_id, amount = '') ⇒ Object
Capture an Auth.
-
#custom_id1=(custom_id1) ⇒ Object
Set CUSTOM_ID field.
-
#custom_id2=(custom_id2) ⇒ Object
Set CUSTOM_ID2 field.
-
#email=(email) ⇒ Object
Set customer E-mail address.
-
#get_amount ⇒ Object
Amount associated with the transaction.
-
#get_auth_code ⇒ Object
In the case of an approved transaction, contains the 6-character authorization code from the processing network.
-
#get_avs_code ⇒ Object
Returns the single-character AVS response from the Card Issuing Bank.
-
#get_bank_name ⇒ Object
Bank account used in transaction.
-
#get_card_type ⇒ Object
Card type used in transaction.
-
#get_creation_date ⇒ Object
Creation date of rebilling.
-
#get_cvv2_code ⇒ Object
Same as avs_code, but for CVV2.
-
#get_cycles_remaining ⇒ Object
Number of cycles remaining on rebilling.
-
#get_id ⇒ Object
Transaction ID used with stq API.
-
#get_last_date ⇒ Object
Last date that the rebilling fired off on.
-
#get_masked_account ⇒ Object
Masked credit card or ACH account.
-
#get_message ⇒ Object
Returns the human-readable response from Bluepay.
-
#get_name1 ⇒ Object
First name associated with the transaction.
-
#get_name2 ⇒ Object
Last name associated with the transaction.
-
#get_next_amount ⇒ Object
Next amount to charge when rebilling fires off.
-
#get_next_date ⇒ Object
Next date that the rebilling is set to fire off on.
-
#get_payment_type ⇒ Object
Payment type associated with the transaction.
-
#get_reb_id ⇒ Object
Rebill ID from bprebadmin API.
-
#get_rebill_amount ⇒ Object
Amount to charge when rebilling fires off.
-
#get_rebill_id ⇒ Object
If you set up a rebilling, this’ll get its ID.
-
#get_rebill_status ⇒ Object
Status of rebilling.
-
#get_rebilling_cycle_status(rebill_id) ⇒ Object
Set fields to get the status of an existing rebilling cycle.
- #get_response ⇒ Object
-
#get_sched_expression ⇒ Object
Rebilling expression.
-
#get_settled_transaction_report(params = {}) ⇒ Object
Gets a report on all settled transactions within a specified date range.
-
#get_single_transaction_query(params = {}) ⇒ Object
Gets data on a specific transaction.
-
#get_status ⇒ Object
Returns E for Error, 1 for Approved, 0 for Decline.
-
#get_template_id ⇒ Object
Template ID of rebilling.
-
#get_trans_id ⇒ Object
The all-important transaction ID.
-
#get_trans_type ⇒ Object
Transaction type associated with the transaction.
-
#get_transaction_report(params = {}) ⇒ Object
Gets a report on all transactions within a specified date range.
-
#initialize(params = {}) ⇒ BluePay
constructor
A new instance of BluePay.
-
#invoice_id=(invoice_id) ⇒ Object
Set INVOICE_ID field.
-
#memo=(memo) ⇒ Object
Set MEMO field.
-
#order_id=(order_id) ⇒ Object
Set ORDER_ID field.
-
#phone=(number) ⇒ Object
Set customer Phone.
-
#process ⇒ Object
sends HTTPS POST to BluePay gateway for processing.
-
#query_by_amount(amount) ⇒ Object
Queries by a specific Transaction Amount.
-
#query_by_name1(name1) ⇒ Object
Queries by a specific First Name.
-
#query_by_name2(name2) ⇒ Object
Queries by a specific Last Name.
-
#query_by_payment_type(pay_type) ⇒ Object
Queries by a specific Payment Type.
-
#query_by_trans_type(trans_type) ⇒ Object
Queries by a specific Transaction Type.
-
#refund(params = {}) ⇒ Object
Refund.
-
#sale(params = {}) ⇒ Object
Set up a sale.
-
#set_ach_information(params = {}) ⇒ Object
Set up an ACH transaction.
-
#set_cc_information(params = {}) ⇒ Object
Set up a credit card payment.
-
#set_customer_information(params = {}) ⇒ Object
Sets customer information for the transaction.
-
#set_recurring_payment(params = {}) ⇒ Object
Set fields for a recurring payment.
-
#successful_response? ⇒ Boolean
Returns true if response status is approved and not a duplicate, else returns false.
-
#update_rebill(params = {}) ⇒ Object
Set fields to do an update on an existing rebilling cycle.
-
#update_rebilling_payment_information(template_id) ⇒ Object
Updates an existing rebilling cycle’s payment information.
-
#uri_query(param_hash) ⇒ Object
Turns a hash into a nvp style string.
-
#void(trans_id) ⇒ Object
Void.
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 |
Class Method Details
.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) ⇒ Object
Calculates TAMPER_PROOF_SEAL to be used with Trans Notify API
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/api_request.rb', line 48 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) Digest::MD5.hexdigest( 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 ) end |
Instance Method Details
#amount_food=(amount_food) ⇒ Object
Set AMOUNT_FOOD field
143 144 145 |
# File 'lib/bluepay.rb', line 143 def amount_food=(amount_food) @PARAM_HASH['AMOUNT_FOOD'] = amount_food end |
#amount_misc=(amount_misc) ⇒ Object
Set AMOUNT_MISC field
148 149 150 |
# File 'lib/bluepay.rb', line 148 def amount_misc=(amount_misc) @PARAM_HASH['AMOUNT_MISC'] = amount_misc end |
#amount_tax=(amount_tax) ⇒ Object
Set AMOUNT_TAX field
138 139 140 |
# File 'lib/bluepay.rb', line 138 def amount_tax=(amount_tax) @PARAM_HASH['AMOUNT_TAX'] = amount_tax end |
#amount_tip=(amount_tip) ⇒ Object
Set AMOUNT_TIP field
133 134 135 |
# File 'lib/bluepay.rb', line 133 def amount_tip=(amount_tip) @PARAM_HASH['AMOUNT_TIP'] = amount_tip end |
#auth(params = {}) ⇒ Object
Set up an Auth
52 53 54 55 56 57 |
# File 'lib/bluepay.rb', line 52 def auth(params ={}) @PARAM_HASH['TRANSACTION_TYPE'] = 'AUTH' @PARAM_HASH['AMOUNT'] = params[:amount] @PARAM_HASH['RRNO'] = params[:trans_id] || '' @api = "bp10emu" end |
#calc_rebill_tps ⇒ Object
Sets TAMPER_PROOF_SEAL in @PARAM_HASH for rebadmin API
28 29 30 31 32 33 34 35 |
# File 'lib/api_request.rb', line 28 def calc_rebill_tps @PARAM_HASH["TAMPER_PROOF_SEAL"] = Digest::MD5.hexdigest( @SECRET_KEY + @ACCOUNT_ID + @PARAM_HASH["TRANS_TYPE"] + @PARAM_HASH["REBILL_ID"] ) end |
#calc_report_tps ⇒ Object
Sets TAMPER_PROOF_SEAL in @PARAM_HASH for bpdailyreport2 API
38 39 40 41 42 43 44 45 |
# File 'lib/api_request.rb', line 38 def calc_report_tps @PARAM_HASH["TAMPER_PROOF_SEAL"] = Digest::MD5.hexdigest( @SECRET_KEY + @ACCOUNT_ID + @PARAM_HASH["REPORT_START_DATE"] + @PARAM_HASH["REPORT_END_DATE"] ) end |
#calc_tps ⇒ Object
Sets TAMPER_PROOF_SEAL in @PARAM_HASH
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/api_request.rb', line 11 def calc_tps @PARAM_HASH["TAMPER_PROOF_SEAL"] = Digest::MD5.hexdigest( @SECRET_KEY + @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"] ) end |
#cancel_rebilling_cycle(rebill_id) ⇒ Object
Set fields to cancel an existing rebilling cycle
176 177 178 179 180 181 |
# File 'lib/bluepay.rb', line 176 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
60 61 62 63 64 65 |
# File 'lib/bluepay.rb', line 60 def capture(trans_id, amount='') @PARAM_HASH['TRANSACTION_TYPE'] = 'CAPTURE' @PARAM_HASH['AMOUNT'] = amount @PARAM_HASH['RRNO'] = trans_id @api = "bp10emu" end |
#custom_id1=(custom_id1) ⇒ Object
Set CUSTOM_ID field
113 114 115 |
# File 'lib/bluepay.rb', line 113 def custom_id1=(custom_id1) @PARAM_HASH['CUSTOM_ID'] = custom_id1 end |
#custom_id2=(custom_id2) ⇒ Object
Set CUSTOM_ID2 field
118 119 120 |
# File 'lib/bluepay.rb', line 118 def custom_id2=(custom_id2) @PARAM_HASH['CUSTOM_ID2'] = custom_id2 end |
#email=(email) ⇒ Object
Set customer E-mail address
103 104 105 |
# File 'lib/bluepay.rb', line 103 def email=(email) @PARAM_HASH['EMAIL'] = email end |
#get_amount ⇒ Object
Amount associated with the transaction
146 147 148 |
# File 'lib/api_response.rb', line 146 def get_amount @RESPONSE_HASH['amount'] end |
#get_auth_code ⇒ Object
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.
41 42 43 |
# File 'lib/api_response.rb', line 41 def get_auth_code @RESPONSE_HASH['AUTH_CODE'] end |
#get_avs_code ⇒ Object
Returns the single-character AVS response from the Card Issuing Bank
29 30 31 |
# File 'lib/api_response.rb', line 29 def get_avs_code @RESPONSE_HASH['AVS'] end |
#get_bank_name ⇒ Object
Bank account used in transaction
66 67 68 |
# File 'lib/api_response.rb', line 66 def get_bank_name @RESPONSE_HASH['BANK_NAME'] end |
#get_card_type ⇒ Object
Card type used in transaction
61 62 63 |
# File 'lib/api_response.rb', line 61 def get_card_type @RESPONSE_HASH['CARD_TYPE'] end |
#get_creation_date ⇒ Object
Creation date of rebilling
86 87 88 |
# File 'lib/api_response.rb', line 86 def get_creation_date @RESPONSE_HASH['creation_date'] end |
#get_cvv2_code ⇒ Object
Same as avs_code, but for CVV2
34 35 36 |
# File 'lib/api_response.rb', line 34 def get_cvv2_code @RESPONSE_HASH['CVV2'] end |
#get_cycles_remaining ⇒ Object
Number of cycles remaining on rebilling
106 107 108 |
# File 'lib/api_response.rb', line 106 def get_cycles_remaining @RESPONSE_HASH['cycles_remain'] end |
#get_id ⇒ Object
Transaction ID used with stq API
121 122 123 |
# File 'lib/api_response.rb', line 121 def get_id @RESPONSE_HASH['id'] end |
#get_last_date ⇒ Object
Last date that the rebilling fired off on
96 97 98 |
# File 'lib/api_response.rb', line 96 def get_last_date @RESPONSE_HASH['last_date'] end |
#get_masked_account ⇒ Object
Masked credit card or ACH account
56 57 58 |
# File 'lib/api_response.rb', line 56 def get_masked_account @RESPONSE_HASH['PAYMENT_ACCOUNT'] end |
#get_message ⇒ Object
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 m = @RESPONSE_HASH['MESSAGE'] if m == nil or m == "" "ERROR - NO MESSAGE FROM BLUEPAY" else m end end |
#get_name1 ⇒ Object
First name associated with the transaction
126 127 128 |
# File 'lib/api_response.rb', line 126 def get_name1 @RESPONSE_HASH['name1'] end |
#get_name2 ⇒ Object
Last name associated with the transaction
131 132 133 |
# File 'lib/api_response.rb', line 131 def get_name2 @RESPONSE_HASH['name2'] end |
#get_next_amount ⇒ Object
Next amount to charge when rebilling fires off
116 117 118 |
# File 'lib/api_response.rb', line 116 def get_next_amount @RESPONSE_HASH['next_amount'] end |
#get_next_date ⇒ Object
Next date that the rebilling is set to fire off on
91 92 93 |
# File 'lib/api_response.rb', line 91 def get_next_date @RESPONSE_HASH['next_date'] end |
#get_payment_type ⇒ Object
Payment type associated with the transaction
136 137 138 |
# File 'lib/api_response.rb', line 136 def get_payment_type @RESPONSE_HASH['payment_type'] end |
#get_reb_id ⇒ Object
Rebill ID from bprebadmin API
71 72 73 |
# File 'lib/api_response.rb', line 71 def get_reb_id @RESPONSE_HASH['rebill_id'] end |
#get_rebill_amount ⇒ Object
Amount to charge when rebilling fires off
111 112 113 |
# File 'lib/api_response.rb', line 111 def get_rebill_amount @RESPONSE_HASH['reb_amount'] end |
#get_rebill_id ⇒ Object
If you set up a rebilling, this’ll get its ID.
51 52 53 |
# File 'lib/api_response.rb', line 51 def get_rebill_id @RESPONSE_HASH['REBID'] end |
#get_rebill_status ⇒ Object
Status of rebilling
81 82 83 |
# File 'lib/api_response.rb', line 81 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
184 185 186 187 188 |
# File 'lib/bluepay.rb', line 184 def get_rebilling_cycle_status(rebill_id) @PARAM_HASH["TRANS_TYPE"] = "GET" @PARAM_HASH["REBILL_ID"] = rebill_id @api = "bp20rebadmin" end |
#get_response ⇒ Object
2 3 4 |
# File 'lib/api_response.rb', line 2 def get_response @RESPONSE_HASH end |
#get_sched_expression ⇒ Object
Rebilling expression
101 102 103 |
# File 'lib/api_response.rb', line 101 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
207 208 209 210 211 212 213 214 215 |
# File 'lib/bluepay.rb', line 207 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
218 219 220 221 222 223 224 |
# File 'lib/bluepay.rb', line 218 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_status ⇒ Object
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_id ⇒ Object
Template ID of rebilling
76 77 78 |
# File 'lib/api_response.rb', line 76 def get_template_id @RESPONSE_HASH['template_id'] end |
#get_trans_id ⇒ Object
The all-important transaction ID.
46 47 48 |
# File 'lib/api_response.rb', line 46 def get_trans_id @RESPONSE_HASH['RRNO'] end |
#get_trans_type ⇒ Object
Transaction type associated with the transaction
141 142 143 |
# File 'lib/api_response.rb', line 141 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
196 197 198 199 200 201 202 203 204 |
# File 'lib/bluepay.rb', line 196 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
123 124 125 |
# File 'lib/bluepay.rb', line 123 def invoice_id=(invoice_id) @PARAM_HASH['INVOICE_ID'] = invoice_id end |
#memo=(memo) ⇒ Object
Set MEMO field
108 109 110 |
# File 'lib/bluepay.rb', line 108 def memo=(memo) @PARAM_HASH['COMMENT'] = memo end |
#order_id=(order_id) ⇒ Object
Set ORDER_ID field
128 129 130 |
# File 'lib/bluepay.rb', line 128 def order_id=(order_id) @PARAM_HASH['ORDER_ID'] = order_id end |
#phone=(number) ⇒ Object
Set customer Phone
98 99 100 |
# File 'lib/bluepay.rb', line 98 def phone=(number) @PARAM_HASH['PHONE'] = number end |
#process ⇒ Object
sends HTTPS POST to BluePay gateway for processing
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 |
# File 'lib/api_request.rb', line 67 def process ua = Net::HTTP.new(SERVER, 443) ua.use_ssl = true 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 begin @PARAM_HASH["REMOTE_IP"] = request.env['REMOTE_ADDR'] rescue Exception end # 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 Library/1.0.4', 'Content-Type' => 'application/x-www-form-urlencoded' } # Response version to be returned @PARAM_HASH["VERSION"] = '3' # Post parameters to BluePay gateway headers, body = ua.post(path, query, queryheaders) # Split the response into the response hash. @RESPONSE_HASH = {} if path == "/interfaces/bp10emu" response = headers["Location"].split("?")[1] else response = headers.body end response.split("&").each do |pair| (key, val) = pair.split("=") val = "" if val == nil @RESPONSE_HASH[URI.unescape(key)] = URI.unescape(val) end end |
#query_by_amount(amount) ⇒ Object
Queries by a specific Transaction Amount. To be used with get_single_trans_query
237 238 239 |
# File 'lib/bluepay.rb', line 237 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
242 243 244 |
# File 'lib/bluepay.rb', line 242 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
247 248 249 |
# File 'lib/bluepay.rb', line 247 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
227 228 229 |
# File 'lib/bluepay.rb', line 227 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
232 233 234 |
# File 'lib/bluepay.rb', line 232 def query_by_trans_type(trans_type) @PARAM_HASH["trans_type"] = trans_type end |
#refund(params = {}) ⇒ Object
Refund
68 69 70 71 72 73 |
# File 'lib/bluepay.rb', line 68 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
44 45 46 47 48 49 |
# File 'lib/bluepay.rb', line 44 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.
35 36 37 38 39 40 41 |
# File 'lib/bluepay.rb', line 35 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_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
84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/bluepay.rb', line 84 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] end |
#set_recurring_payment(params = {}) ⇒ Object
Set fields for a recurring payment
153 154 155 156 157 158 159 160 |
# File 'lib/bluepay.rb', line 153 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] # @api = "bp10emu" end |
#successful_response? ⇒ Boolean
Returns true if response status is approved and not a duplicate, else returns false
7 8 9 |
# File 'lib/api_response.rb', line 7 def successful_response? self.get_status == "APPROVED" && self. != "DUPLICATE" end |
#update_rebill(params = {}) ⇒ Object
Set fields to do an update on an existing rebilling cycle
163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/bluepay.rb', line 163 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.
191 192 193 |
# File 'lib/bluepay.rb', line 191 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 |
# 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))} array.join("&") end |
#void(trans_id) ⇒ Object
Void
76 77 78 79 80 81 |
# File 'lib/bluepay.rb', line 76 def void(trans_id) @PARAM_HASH['TRANSACTION_TYPE'] = 'VOID' @PARAM_HASH['AMOUNT'] = '' @PARAM_HASH['RRNO'] = trans_id @api = "bp10emu" end |