prismpay 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/prismpay.rb +127 -74
- data/spec/prismpay_spec.rb +27 -19
- metadata +1 -1
data/lib/prismpay.rb
CHANGED
@@ -13,6 +13,9 @@ module PrismPay
|
|
13
13
|
# WSDL = "https://trans.myprismpay.com/MPWeb/services/TransactionService?wsdl"
|
14
14
|
WSDL = File.expand_path("../TransactionService.xml", __FILE__)
|
15
15
|
|
16
|
+
ACH_CHECK_ACCT_TYPE = {"checking" => 1, "savings" => 2}
|
17
|
+
ACH_SEC_CODES = %w(POP, ARC, TEL, PPD, ICL, RCK, BOC)
|
18
|
+
|
16
19
|
attr_accessor :acctid, :password
|
17
20
|
attr_reader :client
|
18
21
|
|
@@ -29,6 +32,130 @@ module PrismPay
|
|
29
32
|
|
30
33
|
end
|
31
34
|
|
35
|
+
|
36
|
+
############################################################
|
37
|
+
# CreditCard SOAP methods:
|
38
|
+
# ###########################################################
|
39
|
+
# TODO: the profile methods should be refactored to be either for
|
40
|
+
# credit cards or for ACH transactions
|
41
|
+
############################################################
|
42
|
+
|
43
|
+
def profile_sale(amount, profile_id, last_four, options = {})
|
44
|
+
response = @client.request :process_profile_sale do
|
45
|
+
http.auth.ssl.verify_mode :none
|
46
|
+
soap.body &build_profile_sale(amount, profile_id, last_four, options)
|
47
|
+
end
|
48
|
+
PrismCreditResponse.new(response)
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
def profile_retrieve(options = {})
|
53
|
+
# process a profile retrieve request
|
54
|
+
response = @client.request :process_profile_retrieve do
|
55
|
+
http.auth.ssl.verify_mode :none
|
56
|
+
soap.body &build_profile_retrieve(options)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
def cc_purchase(amount, creditcard, options ={})
|
62
|
+
# process a credit card sale and right now return the savon response
|
63
|
+
# The savon response needs to be mapped back into the proper response
|
64
|
+
# fields
|
65
|
+
|
66
|
+
# need to merge the gateway instance options with the options
|
67
|
+
|
68
|
+
response = @client.request :process_cc_sale do
|
69
|
+
http.auth.ssl.verify_mode :none
|
70
|
+
soap.body &build_cc_sale_auth(amount, creditcard, options)
|
71
|
+
end
|
72
|
+
|
73
|
+
PrismCreditResponse.new(response)
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
def cc_authorize(amount, creditcard, options = {})
|
79
|
+
# reserve funds for future captures
|
80
|
+
response = @client.request :process_cc_auth do
|
81
|
+
http.auth.ssl.verify_mode :none
|
82
|
+
soap.body &build_cc_sale_auth(amount, creditcard, options)
|
83
|
+
end
|
84
|
+
|
85
|
+
PrismCreditResponse.new(response)
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
def cc_capture(amount, authorization, pp_txn_id, options = {})
|
90
|
+
# Captures reservered funds from previous auths
|
91
|
+
# need to put some validation into these methods before
|
92
|
+
# making the call to the build methods
|
93
|
+
|
94
|
+
response = @client.request :process_cc_post do
|
95
|
+
http.auth.ssl.verify_mode :none
|
96
|
+
soap.body &build_cc_capture(amount, authorization, pp_txn_id, options)
|
97
|
+
end
|
98
|
+
|
99
|
+
PrismCreditResponse.new(response)
|
100
|
+
end
|
101
|
+
|
102
|
+
|
103
|
+
def cc_void(amount, identification, pp_txn_id, options = {})
|
104
|
+
# voids previous transactions
|
105
|
+
response = @client.request :process_cc_void do
|
106
|
+
http.auth.ssl.verify_mode :none
|
107
|
+
soap.body &build_cc_void(amount, identification, pp_txn_id, options)
|
108
|
+
end
|
109
|
+
|
110
|
+
PrismCreditResponse.new(response)
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
def credit(amount, identification, pp_txn_id, options = {})
|
115
|
+
# applies credit back against previous transaction
|
116
|
+
response = @client.request :process_credit do
|
117
|
+
http.auth.ssl.verify_mode :none
|
118
|
+
soap.body &build_credit(amount, identification, pp_txn_id, options)
|
119
|
+
end
|
120
|
+
|
121
|
+
PrismCreditResponse.new(response)
|
122
|
+
end
|
123
|
+
|
124
|
+
############################################################
|
125
|
+
# ACH Methods
|
126
|
+
############################################################
|
127
|
+
# These should be for normal ACH transactions ie: transactions
|
128
|
+
# coming from a client into a prismpay vendor.
|
129
|
+
############################################################
|
130
|
+
|
131
|
+
def ach_sale
|
132
|
+
end
|
133
|
+
|
134
|
+
def ach_credit
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
############################################################
|
139
|
+
# ACH Ext Check Sale
|
140
|
+
############################################################
|
141
|
+
# These will be used for checks coming in which will have
|
142
|
+
# disbursments to a third party as well
|
143
|
+
############################################################
|
144
|
+
|
145
|
+
def ext_ach_sale()
|
146
|
+
end
|
147
|
+
|
148
|
+
def ext_ach_void
|
149
|
+
end
|
150
|
+
|
151
|
+
def ext_ach_refund
|
152
|
+
end
|
153
|
+
|
154
|
+
def ext_ach_consumer_disbursement
|
155
|
+
end
|
156
|
+
|
157
|
+
private
|
158
|
+
|
32
159
|
def build_address(addr, type= "bill")
|
33
160
|
# receives a hash that contains the keys for active_merchant
|
34
161
|
# address and type which should be 'bill' or 'ship'
|
@@ -253,80 +380,6 @@ module PrismPay
|
|
253
380
|
return xml_block
|
254
381
|
end
|
255
382
|
|
256
|
-
|
257
|
-
def profile_sale(amount, profile_id, last_four, options = {})
|
258
|
-
response = @client.request :process_profile_sale do
|
259
|
-
soap.body &build_profile_sale(amount, profile_id, last_four, options)
|
260
|
-
end
|
261
|
-
PrismCreditResponse.new(response)
|
262
|
-
end
|
263
|
-
|
264
|
-
|
265
|
-
def profile_retrieve(options = {})
|
266
|
-
# process a profile retrieve request
|
267
|
-
response = @client.request :process_profile_retrieve do
|
268
|
-
soap.body &build_profile_retrieve(options)
|
269
|
-
end
|
270
|
-
end
|
271
|
-
|
272
|
-
|
273
|
-
def cc_purchase(amount, creditcard, options ={})
|
274
|
-
# process a credit card sale and right now return the savon response
|
275
|
-
# The savon response needs to be mapped back into the proper response
|
276
|
-
# fields
|
277
|
-
|
278
|
-
# need to merge the gateway instance options with the options
|
279
|
-
|
280
|
-
response = @client.request :process_cc_sale do
|
281
|
-
soap.body &build_cc_sale_auth(amount, creditcard, options)
|
282
|
-
end
|
283
|
-
|
284
|
-
PrismCreditResponse.new(response)
|
285
|
-
|
286
|
-
end
|
287
|
-
|
288
|
-
|
289
|
-
def cc_authorize(amount, creditcard, options = {})
|
290
|
-
# reserve funds for future captures
|
291
|
-
response = @client.request :process_cc_auth do
|
292
|
-
soap.body &build_cc_sale_auth(amount, creditcard, options)
|
293
|
-
end
|
294
|
-
|
295
|
-
PrismCreditResponse.new(response)
|
296
|
-
end
|
297
|
-
|
298
|
-
|
299
|
-
def cc_capture(amount, authorization, pp_txn_id, options = {})
|
300
|
-
# Captures reservered funds from previous auths
|
301
|
-
# need to put some validation into these methods before
|
302
|
-
# making the call to the build methods
|
303
|
-
|
304
|
-
response = @client.request :process_cc_post do
|
305
|
-
soap.body &build_cc_capture(amount, authorization, pp_txn_id, options)
|
306
|
-
end
|
307
|
-
|
308
|
-
PrismCreditResponse.new(response)
|
309
|
-
end
|
310
|
-
|
311
|
-
|
312
|
-
def cc_void(amount, identification, pp_txn_id, options = {})
|
313
|
-
# voids previous transactions
|
314
|
-
response = @client.request :process_cc_void do
|
315
|
-
soap.body &build_cc_void(identification, options)
|
316
|
-
end
|
317
|
-
|
318
|
-
PrismCreditResponse.new(response)
|
319
|
-
end
|
320
|
-
|
321
|
-
|
322
|
-
def credit(amount, identification, pp_txn_id, options = {})
|
323
|
-
# applies credit back against previous transaction
|
324
|
-
response = @client.request :process_credit do
|
325
|
-
soap.body &build_credit(amount, identification, pp_txn_id, options)
|
326
|
-
end
|
327
|
-
|
328
|
-
PrismCreditResponse.new(response)
|
329
|
-
end
|
330
383
|
|
331
384
|
end # class PrismPay
|
332
385
|
|
data/spec/prismpay_spec.rb
CHANGED
@@ -166,18 +166,20 @@ describe PrismPay::PrismPay, "#build_address" do
|
|
166
166
|
|
167
167
|
gw = PrismPay::PrismPay.new(addr1)
|
168
168
|
|
169
|
+
private_method = gw.method(:build_address)
|
170
|
+
|
169
171
|
it "should return string" do
|
170
|
-
|
172
|
+
private_method.call(addr1).class.should eq(String)
|
171
173
|
end
|
172
174
|
|
173
175
|
it "should return bill block for bad type" do
|
174
|
-
|
175
|
-
|
176
|
-
|
176
|
+
private_method.call(addr1).should =~ /billaddress/
|
177
|
+
private_method.call(addr1, {}).should =~ /billaddress/
|
178
|
+
private_method.call(addr1, "junk").should =~ /billaddress/
|
177
179
|
end
|
178
180
|
|
179
181
|
it "should return ship string for ship type" do
|
180
|
-
|
182
|
+
private_method.call(addr1, "ship").should =~ /shipaddress/
|
181
183
|
end
|
182
184
|
|
183
185
|
end
|
@@ -210,18 +212,21 @@ describe PrismPay::PrismPay, "#build_cc_sale_auth" do
|
|
210
212
|
|
211
213
|
it "should return xml builder block for sale/auth" do
|
212
214
|
gw = PrismPay::PrismPay.new(options)
|
213
|
-
|
215
|
+
private_method = gw.method(:build_cc_sale_auth)
|
216
|
+
private_method.call(amount, cc, options).class.should eq(Proc)
|
214
217
|
end
|
215
218
|
|
216
219
|
it "should take 1 arg" do
|
217
220
|
gw = PrismPay::PrismPay.new(options)
|
218
|
-
|
221
|
+
private_method = gw.method(:build_cc_sale_auth)
|
222
|
+
myproc = private_method.call(amount, cc, options)
|
219
223
|
myproc.arity.should > 0
|
220
224
|
end
|
221
225
|
|
222
226
|
it "should create xml object when passed to builder" do
|
223
227
|
gw = PrismPay::PrismPay.new(options)
|
224
|
-
|
228
|
+
private_method = gw.method(:build_cc_sale_auth)
|
229
|
+
myproc = private_method.call(amount, cc, options)
|
225
230
|
str = builder_wrapper(&myproc)
|
226
231
|
str.should =~ /^<ccinfo[^&]*<\/ccinfo>$/ #match the object
|
227
232
|
end
|
@@ -231,7 +236,8 @@ end
|
|
231
236
|
describe PrismPay::PrismPay, "build_cc_void" do
|
232
237
|
it "should return xml builder block for void" do
|
233
238
|
gw = PrismPay::PrismPay.new({})
|
234
|
-
gw.build_cc_void
|
239
|
+
priv_method = gw.method(:build_cc_void)
|
240
|
+
priv_method.call("", "", "",{}).class.should eq(Proc)
|
235
241
|
end
|
236
242
|
|
237
243
|
end
|
@@ -239,14 +245,16 @@ end
|
|
239
245
|
describe PrismPay::PrismPay, "build_cc_capture" do
|
240
246
|
it "should return xml builder block for capture" do
|
241
247
|
gw = PrismPay::PrismPay.new({})
|
242
|
-
|
248
|
+
priv_method = gw.method(:build_cc_capture)
|
249
|
+
priv_method.call("", "", "",{}).class.should eq(Proc)
|
243
250
|
end
|
244
251
|
end
|
245
252
|
|
246
253
|
describe PrismPay::PrismPay, "build_credit" do
|
247
254
|
it "should return xml builder block for refund" do
|
248
255
|
gw = PrismPay::PrismPay.new({})
|
249
|
-
|
256
|
+
priv_method = gw.method(:build_credit)
|
257
|
+
priv_method.call("", "", "", {}).class.should eq(Proc)
|
250
258
|
end
|
251
259
|
end
|
252
260
|
|
@@ -255,18 +263,18 @@ describe PrismPay::PrismPay, "cc_capture" do
|
|
255
263
|
options = { }
|
256
264
|
values = get_last_trans("./data~")
|
257
265
|
options[:login] = "TEST0"
|
258
|
-
|
266
|
+
orderid = values[:order_id]
|
259
267
|
authcode = values[:historyid]
|
260
268
|
amount = values[:amount]
|
261
269
|
|
262
270
|
gw = PrismPay::PrismPay.new(options)
|
263
271
|
|
264
|
-
response = gw.cc_capture(amount, authcode, options).soap_response
|
272
|
+
response = gw.cc_capture(amount, authcode, orderid, options).soap_response
|
265
273
|
|
266
274
|
response.body[:multi_ref][:status].should =~ /Approved/
|
267
275
|
|
268
276
|
if response.body[:multi_ref][:status] =~ /Approved/
|
269
|
-
processed_trans "#{
|
277
|
+
processed_trans "#{orderid}:#{authcode}:#{amount}\n", "./data~"
|
270
278
|
end
|
271
279
|
end
|
272
280
|
end
|
@@ -276,19 +284,19 @@ describe PrismPay::PrismPay, "cc_void" do
|
|
276
284
|
options = { }
|
277
285
|
values = get_last_trans("./void~")
|
278
286
|
options[:login] = "TEST0"
|
279
|
-
|
287
|
+
orderid = values[:order_id]
|
280
288
|
authcode = values[:historyid]
|
281
|
-
|
282
|
-
|
289
|
+
amount = values[:amount]
|
290
|
+
|
283
291
|
|
284
292
|
gw = PrismPay::PrismPay.new(options)
|
285
293
|
|
286
|
-
response = gw.cc_void(authcode, options).soap_response
|
294
|
+
response = gw.cc_void(amount ,authcode, orderid, options).soap_response
|
287
295
|
|
288
296
|
response.body[:multi_ref][:status].should =~ /Approved/
|
289
297
|
|
290
298
|
if response.body[:multi_ref][:status] =~ /Approved/
|
291
|
-
processed_trans "#{
|
299
|
+
processed_trans "#{orderid}:#{authcode}:#{amount}\n", "./void~"
|
292
300
|
end
|
293
301
|
end
|
294
302
|
end
|