mundipagg 1.2.4 → 1.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/lib/mundipagg/gateway.rb +342 -333
- data/lib/mundipagg/version.rb +1 -1
- data/tests/features/step_definitions/boleto_steps.rb +2 -1
- data/tests/features/step_definitions/credit_card_steps.rb +1 -0
- data/tests/features/step_definitions/post_notification.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6164f0165ed7ffc42595b2e174eea3773e8811c9
|
4
|
+
data.tar.gz: d6bf8662ec2df1030bd51af3ffbbaba30ff95935
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f77d0b720f5bfecf788737522c610d7e0ad73aafa5c5496719c42bdd4a180ee57f2419fcc8738bb0723d46baf7dbb860104a9ed24538d3fe6c3a4070f79da04
|
7
|
+
data.tar.gz: 37b5fb0c7ae9bc365b0a437314e50ef12cceab8a3c6499dac591afc9aa5d951f248e952201e91a195f0f29c63b80d20f03c44a409253c6b94492cf095ca7c158
|
data/README.md
CHANGED
@@ -16,6 +16,14 @@ Unit tests made with [Cucumber](https://github.com/cucumber/cucumber) and [RSpec
|
|
16
16
|
* [RubyDoc](http://rubydoc.info/github/mundipagg/mundipagg-ruby-api/)
|
17
17
|
|
18
18
|
|
19
|
+
## Tests
|
20
|
+
After get your _MerchantKey_ you can run the unit tests in our simulator environment, all you need to do is put your _MerchantKey_ in the [TestConfiguration.rb file](https://github.com/mundipagg/mundipagg-ruby-api/blob/master/tests/test_configuration.rb) and execute cucumber tests with the command below:
|
21
|
+
|
22
|
+
```sh
|
23
|
+
$ bundle exec rake integration
|
24
|
+
```
|
25
|
+
|
26
|
+
|
19
27
|
## Usage
|
20
28
|
Below a simple exemple of an order with one credit card transaction.
|
21
29
|
|
data/lib/mundipagg/gateway.rb
CHANGED
@@ -1,335 +1,344 @@
|
|
1
1
|
module Mundipagg
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
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
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
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
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
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
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
2
|
+
# Class that handles all webservice calls
|
3
|
+
class Gateway
|
4
|
+
|
5
|
+
# Sets the soap request log level.
|
6
|
+
# Can be: { :debug, :info, :warn, :error or :none }
|
7
|
+
# Use :debug only to inspect the Xml sent and received to the service.
|
8
|
+
# Default in test environment => :debug
|
9
|
+
# Default in production environment => :none
|
10
|
+
attr_accessor :log_level
|
11
|
+
|
12
|
+
# @return [Nori] Nori class who handle the conversion of base XML to a hash collection
|
13
|
+
# @see https://github.com/savonrb/nori
|
14
|
+
attr_reader :parser
|
15
|
+
|
16
|
+
# <i>:test</i> = Simulator enviroment, fake transaction approval;
|
17
|
+
# <i>:production</i> = Real transaction, needs real credit card.
|
18
|
+
# @return [Symbol] Webservice environment.
|
19
|
+
attr_accessor :environment
|
20
|
+
|
21
|
+
# @return [String] URL that points to the simulator WSDL
|
22
|
+
@@WEBSERVICE_TEST_URL = 'https://transaction.mundipaggone.com/MundiPaggService.svc?wsdl'
|
23
|
+
|
24
|
+
# @return [String] URL that points to the production WSDL
|
25
|
+
@@WEBSERVICE_PRODUCTION_URL = 'https://transaction.mundipaggone.com/MundiPaggService.svc?wsdl'
|
26
|
+
|
27
|
+
# Initialize a class with an environment
|
28
|
+
#
|
29
|
+
# @param environment [Symbol] Sets the MundiPagg environment will be used by the client.
|
30
|
+
def initialize(environment=:test)
|
31
|
+
@parser = Nori.new(:convert_tags_to => lambda { |tag| tag })
|
32
|
+
@environment = environment
|
33
|
+
|
34
|
+
if environment == :test
|
35
|
+
@log_level = :debug
|
36
|
+
else
|
37
|
+
@log_level = :error
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
# This method makes requests to the webservice method ManageOrder.
|
44
|
+
#
|
45
|
+
# @param request [CreateOrderRequest] A ManagerOrderRequest instance containing information to capture or void a transaction or order.
|
46
|
+
# @return [Hash<Symbol, Object>] A hash collection containing the response data
|
47
|
+
def ManageOrder(request)
|
48
|
+
|
49
|
+
hash = @parser.parse('<tns:manageOrderRequest>
|
50
|
+
<mun:ManageCreditCardTransactionCollection>
|
51
|
+
</mun:ManageCreditCardTransactionCollection>
|
52
|
+
<mun:ManageOrderOperationEnum>?</mun:ManageOrderOperationEnum>
|
53
|
+
<mun:MerchantKey>?</mun:MerchantKey>
|
54
|
+
<mun:OrderKey>?</mun:OrderKey>
|
55
|
+
<mun:OrderReference>?</mun:OrderReference>
|
56
|
+
<mun:RequestKey>?</mun:RequestKey>
|
57
|
+
</tns:manageOrderRequest>')
|
58
|
+
|
59
|
+
xml_hash = hash['tns:manageOrderRequest'];
|
60
|
+
|
61
|
+
xml_hash['mun:ManageCreditCardTransactionCollection'] = {'mun:ManageCreditCardTransactionRequest'=>Array.new}
|
62
|
+
|
63
|
+
if request.transactionCollection.nil? == false and request.transactionCollection.count > 0
|
64
|
+
|
65
|
+
request.transactionCollection.each do |transaction|
|
66
|
+
|
67
|
+
xml_hash['mun:ManageCreditCardTransactionCollection']['mun:ManageCreditCardTransactionRequest'] << {
|
68
|
+
'mun:AmountInCents' => transaction.amountInCents,
|
69
|
+
'mun:TransactionKey' => transaction.transactionKey,
|
70
|
+
'mun:TransactionReference' => transaction.transactionReference
|
71
|
+
}
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
xml_hash['mun:ManageOrderOperationEnum'] = request.manageOrderOperationEnum
|
76
|
+
xml_hash['mun:MerchantKey'] = request.merchantKey
|
77
|
+
xml_hash['mun:OrderKey'] = request.orderKey
|
78
|
+
xml_hash['mun:OrderReference'] = request.orderReference
|
79
|
+
xml_hash['mun:RequestKey'] = request.requestKey
|
80
|
+
|
81
|
+
response = SendToService(hash, :manage_order)
|
82
|
+
|
83
|
+
return response
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
# This method makes requests to the webservice method QueryOrder.
|
88
|
+
#
|
89
|
+
# @param request [QueryOrderRequest] A QueryOrderRequest instance containing information to request more information about an order or transaction.
|
90
|
+
# @return [Hash<Symbol, Object>]
|
91
|
+
def QueryOrder(request)
|
92
|
+
|
93
|
+
hash = @parser.parse('<tns:queryOrderRequest>
|
94
|
+
<mun:MerchantKey>?</mun:MerchantKey>
|
95
|
+
<mun:OrderKey>?</mun:OrderKey>
|
96
|
+
<mun:OrderReference>?</mun:OrderReference>
|
97
|
+
<mun:RequestKey>?</mun:RequestKey>
|
98
|
+
</tns:queryOrderRequest>')
|
99
|
+
|
100
|
+
xml_hash = hash['tns:queryOrderRequest'];
|
101
|
+
|
102
|
+
xml_hash['mun:MerchantKey'] = request.merchantKey
|
103
|
+
xml_hash['mun:OrderKey'] = request.orderKey
|
104
|
+
xml_hash['mun:OrderReference'] = request.orderReference
|
105
|
+
xml_hash['mun:RequestKey'] = request.requestKey
|
106
|
+
|
107
|
+
response = SendToService(hash, :query_order)
|
108
|
+
|
109
|
+
return response
|
110
|
+
end
|
111
|
+
|
112
|
+
# This method makes requests to the webservice method CreateOrder.
|
113
|
+
#
|
114
|
+
# @param request [CreateOrderRequest] A CreateOrderRequest instance containing information to create a order.
|
115
|
+
# @return [Hash<Symbol, Object>] A hash collection containing the response data
|
116
|
+
def CreateOrder(request)
|
117
|
+
|
118
|
+
hash = @parser.parse('
|
119
|
+
<tns:createOrderRequest>
|
120
|
+
<mun:AmountInCents>?</mun:AmountInCents>
|
121
|
+
<mun:AmountInCentsToConsiderPaid>?</mun:AmountInCentsToConsiderPaid>
|
122
|
+
<mun:CurrencyIsoEnum>?</mun:CurrencyIsoEnum>
|
123
|
+
<mun:MerchantKey>?</mun:MerchantKey>
|
124
|
+
<mun:OrderReference>?</mun:OrderReference>
|
125
|
+
<mun:RequestKey>?</mun:RequestKey>
|
126
|
+
<mun:Buyer>
|
127
|
+
</mun:Buyer>
|
128
|
+
<mun:CreditCardTransactionCollection>
|
129
|
+
</mun:CreditCardTransactionCollection>
|
130
|
+
<mun:BoletoTransactionCollection>
|
131
|
+
</mun:BoletoTransactionCollection>
|
132
|
+
</tns:createOrderRequest>')
|
133
|
+
|
134
|
+
xml_hash = hash['tns:createOrderRequest'];
|
135
|
+
|
136
|
+
xml_hash['mun:AmountInCents'] = request.amountInCents
|
137
|
+
xml_hash['mun:AmountInCentsToConsiderPaid'] = request.amountInCentsToConsiderPaid
|
138
|
+
xml_hash['mun:CurrencyIsoEnum'] = request.currencyIsoEnum
|
139
|
+
xml_hash['mun:MerchantKey'] = request.merchantKey
|
140
|
+
xml_hash['mun:OrderReference'] = request.orderReference
|
141
|
+
xml_hash['mun:RequestKey'] = request.requestKey
|
142
|
+
|
143
|
+
if request.buyer.nil? == false
|
144
|
+
xml_hash['mun:Buyer'] = CreateBuyer(request)
|
145
|
+
end
|
146
|
+
|
147
|
+
if not request.creditCardTransactionCollection.nil? and request.creditCardTransactionCollection.count > 0
|
148
|
+
#Create credit card transaction array and assing to the contract hash
|
149
|
+
creditCardTransactionCollection = CreateCreditCardTransaction(request)
|
150
|
+
xml_hash['mun:CreditCardTransactionCollection'] = creditCardTransactionCollection
|
151
|
+
else
|
152
|
+
xml_hash['mun:CreditCardTransactionCollection'] = nil
|
153
|
+
end
|
154
|
+
|
155
|
+
if request.boletoTransactionCollection.nil? == false and request.boletoTransactionCollection.count > 0
|
156
|
+
#Create boleto transaction array and assing to the contract hash
|
157
|
+
boletoTransactionCollection = CreateBoletoTransactionRequest(request);
|
158
|
+
xml_hash['mun:BoletoTransactionCollection'] = boletoTransactionCollection
|
159
|
+
end
|
160
|
+
|
161
|
+
response = SendToService(hash, :create_order)
|
162
|
+
|
163
|
+
|
164
|
+
return response
|
165
|
+
|
166
|
+
end
|
167
|
+
|
168
|
+
|
169
|
+
# This method create a hash collection with all buyer information.
|
170
|
+
# The hash collection is a part of the data send to the webservice.
|
171
|
+
#
|
172
|
+
# @param request [CreateOrderRequest]
|
173
|
+
# @return [Hash<Symbol, Object>] Hash collection with buyer information.
|
174
|
+
# @!visibility private
|
175
|
+
def CreateBuyer(request)
|
176
|
+
|
177
|
+
buyer = {
|
178
|
+
'mun:BuyerKey' => request.buyer.buyerKey,
|
179
|
+
'mun:BuyerReference' => request.buyer.buyerReference,
|
180
|
+
'mun:Email' => request.buyer.email,
|
181
|
+
'mun:GenderEnum' => request.buyer.genderEnum,
|
182
|
+
'mun:FacebookId' => request.buyer.facebookId,
|
183
|
+
'mun:GenderEnum' => request.buyer.genderEnum,
|
184
|
+
'mun:HomePhone' => request.buyer.homePhone,
|
185
|
+
'mun:IpAddress' => request.buyer.ipAddress,
|
186
|
+
'mun:MobilePhone' => request.buyer.mobilePhone,
|
187
|
+
'mun:Name' => request.buyer.name,
|
188
|
+
'mun:PersonTypeEnum' => request.buyer.personTypeEnum,
|
189
|
+
'mun:TaxDocumentNumber' => request.buyer.taxDocumentNumber,
|
190
|
+
'mun:TaxDocumentNumberTypeEnum' => request.buyer.taxDocumentTypeEnum,
|
191
|
+
'mun:TwitterId' => request.buyer.twitterId,
|
192
|
+
'mun:WorkPhone' => request.buyer.workPhone,
|
193
|
+
'mun:BuyerAddressCollection' => nil
|
194
|
+
|
195
|
+
}
|
196
|
+
|
197
|
+
if request.buyer.addressCollection.count > 0
|
198
|
+
|
199
|
+
buyer['mun:BuyerAddressCollection'] = {'mun:BuyerAddress'=>Array.new}
|
200
|
+
|
201
|
+
request.buyer.addressCollection.each do |address|
|
202
|
+
|
203
|
+
buyer['mun:BuyerAddressCollection']['mun:BuyerAddress'] << {
|
204
|
+
'mun:AddressTypeEnum' => address.addressTypeEnum,
|
205
|
+
'mun:City' => address.city,
|
206
|
+
'mun:Complement' => address.complement,
|
207
|
+
'mun:CountryEnum' => address.countryEnum,
|
208
|
+
'mun:District' => address.district,
|
209
|
+
'mun:Number' => address.number,
|
210
|
+
'mun:State' => address.state,
|
211
|
+
'mun:Street' => address.street,
|
212
|
+
'mun:ZipCode' => address.zipCode
|
213
|
+
}
|
214
|
+
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
return buyer
|
219
|
+
end
|
220
|
+
|
221
|
+
# This method create a hash collection with all boleto transactions information.
|
222
|
+
# The hash collection is a part of the data send to the webservice.
|
223
|
+
#
|
224
|
+
# @param boletoRequest [Array<BoletoTransaction>] CreateOrderRequest instance
|
225
|
+
# @return [Hash<Symbol, Object>] Hash collection with one or more boleto transactions.
|
226
|
+
# @!visibility private
|
227
|
+
def CreateBoletoTransactionRequest(boletoRequest)
|
228
|
+
|
229
|
+
transactionCollection = {'mun:BoletoTransaction' => Array.new}
|
230
|
+
|
231
|
+
boletoRequest.boletoTransactionCollection.each do |boleto|
|
232
|
+
|
233
|
+
transactionCollection['mun:BoletoTransaction'] << {
|
234
|
+
'mun:AmountInCents' => boleto.amountInCents,
|
235
|
+
'mun:BankNumber' => boleto.bankNumber,
|
236
|
+
'mun:DaysToAddInBoletoExpirationDate' => boleto.daysToAddInBoletoExpirationDate,
|
237
|
+
'mun:Instructions' => boleto.instructions,
|
238
|
+
'mun:NossoNumero' => boleto.nossoNumero,
|
239
|
+
'mun:TransactionReference' => boleto.transactionReference,
|
240
|
+
|
241
|
+
}
|
242
|
+
|
243
|
+
end
|
244
|
+
|
245
|
+
return transactionCollection
|
246
|
+
end
|
247
|
+
|
248
|
+
# This method create a hash collection with all credit card transactions information.
|
249
|
+
# The hash collection is a part of the data send to the webservice.
|
250
|
+
#
|
251
|
+
# @param creditCardRequest [Array<CreditCardTransaction>] CreateOrderRequest instance
|
252
|
+
# @return [Hash<Symbol, Object>] Hash collection with one or more credit card transactions.
|
253
|
+
# @!visibility private
|
254
|
+
def CreateCreditCardTransaction(creditCardRequest)
|
255
|
+
|
256
|
+
transactionCollection = {'mun:CreditCardTransaction' => Array.new}
|
257
|
+
|
258
|
+
creditCardRequest.creditCardTransactionCollection.each do |transaction|
|
259
|
+
|
260
|
+
if environment == :test
|
261
|
+
transaction.paymentMethodCode = 1 # Simulator payment code
|
262
|
+
end
|
263
|
+
|
264
|
+
transaction_hash = {
|
265
|
+
'mun:AmountInCents' => transaction.amountInCents,
|
266
|
+
'mun:CreditCardBrandEnum' => transaction.creditCardBrandEnum.to_s,
|
267
|
+
'mun:CreditCardNumber' => transaction.creditCardNumber,
|
268
|
+
'mun:CreditCardOperationEnum' => transaction.creditCardOperationEnum.to_s,
|
269
|
+
'mun:ExpMonth' => transaction.expirationMonth,
|
270
|
+
'mun:ExpYear' => transaction.expirationYear,
|
271
|
+
'mun:HolderName' => transaction.holderName,
|
272
|
+
'mun:InstallmentCount' => transaction.installmentCount,
|
273
|
+
'mun:PaymentMethodCode' => transaction.paymentMethodCode,
|
274
|
+
'mun:SecurityCode' => transaction.securityCode,
|
275
|
+
'mun:TransactionReference' => transaction.transactionReference
|
276
|
+
}
|
277
|
+
|
278
|
+
if transaction.recurrency.nil? == false
|
279
|
+
|
280
|
+
transaction_hash['mun:Recurrency'] = {
|
281
|
+
'mun:DateToStartBilling' => transaction.recurrency.dateToStartBilling,
|
282
|
+
'mun:FrequencyEnum' => transaction.recurrency.frequencyEnum,
|
283
|
+
'mun:Interval' => transaction.recurrency.interval,
|
284
|
+
'mun:OneDollarAuth' => transaction.recurrency.oneDollarAuth,
|
285
|
+
'mun:Recurrences' => transaction.recurrency.recurrences
|
286
|
+
}
|
287
|
+
end
|
288
|
+
|
289
|
+
transactionCollection['mun:CreditCardTransaction'] << transaction_hash
|
290
|
+
end
|
291
|
+
|
292
|
+
return transactionCollection
|
293
|
+
end
|
294
|
+
|
295
|
+
|
296
|
+
# This method send the hash collectin created in this client and send it to the webservice.
|
297
|
+
#
|
298
|
+
# == Parameters:
|
299
|
+
# @param hash [Hash<Symbol, Object] Hash collection generated by Nori using the base SOAP XML.
|
300
|
+
# @param service_method [Symbol] A Symbol declaring the method that will be called. Can be <i>:create_order</i>, <i>:manage_order<i/> or <i>:query_order</i>.
|
301
|
+
# @return [Hash<Symbol, Object>] A hash collection with the service method response.
|
302
|
+
# @!visibility private
|
303
|
+
def SendToService(hash, service_method)
|
304
|
+
|
305
|
+
url = nil
|
306
|
+
|
307
|
+
if @environment == :production
|
308
|
+
url = @@WEBSERVICE_PRODUCTION_URL
|
309
|
+
else
|
310
|
+
url = @@WEBSERVICE_TEST_URL
|
311
|
+
end
|
312
|
+
savon_levels = { :none => -1, :debug => 0, :info => 1, :warn => 2, :error => 3 }
|
313
|
+
|
314
|
+
if not savon_levels.include? @log_level
|
315
|
+
@log_level = :none
|
316
|
+
end
|
317
|
+
|
318
|
+
level = :debug
|
319
|
+
enable_log = true
|
320
|
+
|
321
|
+
|
322
|
+
if @log_level == :none
|
323
|
+
enable_log = false
|
324
|
+
level = :error
|
325
|
+
end
|
326
|
+
|
327
|
+
|
328
|
+
client = Savon.client do
|
329
|
+
wsdl url
|
330
|
+
log enable_log
|
331
|
+
log_level level
|
332
|
+
namespaces 'xmlns:mun' => 'http://schemas.datacontract.org/2004/07/MundiPagg.One.Service.DataContracts'
|
333
|
+
end
|
334
|
+
|
335
|
+
response = client.call(service_method) do
|
336
|
+
message hash
|
337
|
+
end
|
338
|
+
|
339
|
+
return response.to_hash
|
340
|
+
end
|
341
|
+
|
342
|
+
private :CreateBoletoTransactionRequest, :CreateCreditCardTransaction, :CreateBuyer, :SendToService, :parser
|
343
|
+
end
|
335
344
|
end
|
data/lib/mundipagg/version.rb
CHANGED
@@ -2,11 +2,12 @@
|
|
2
2
|
|
3
3
|
Before do
|
4
4
|
@client = Mundipagg::Gateway.new :test
|
5
|
+
@client.log_level = :none
|
5
6
|
@order = Mundipagg::CreateOrderRequest.new
|
6
7
|
@boleto = Mundipagg::BoletoTransaction.new
|
7
8
|
@response = Hash.new
|
8
9
|
@order.merchantKey = TestConfiguration::Merchant::MerchantKey
|
9
|
-
|
10
|
+
$world = self
|
10
11
|
end
|
11
12
|
|
12
13
|
|
@@ -1,9 +1,8 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
|
3
2
|
Before do
|
4
3
|
|
5
4
|
@client = Mundipagg::Gateway.new :test
|
6
|
-
@client.log_level = :
|
5
|
+
@client.log_level = :none
|
7
6
|
|
8
7
|
@order = Mundipagg::CreateOrderRequest.new
|
9
8
|
@manage_order = Mundipagg::ManageOrderRequest.new
|
@@ -79,6 +78,7 @@ Then(/^I will receive a POST notification telling my transaction has been (\w+)$
|
|
79
78
|
xml = TestHelper.CreateFakePostNotification(@response, @response_manage)
|
80
79
|
|
81
80
|
@notification_hash = Mundipagg::PostNotification.ParseNotification(xml)
|
81
|
+
pp @notification_hash, :indent => true
|
82
82
|
|
83
83
|
@notification_hash.should_not == nil
|
84
84
|
@notification_hash.count.should > 0
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mundipagg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MundiPagg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: savon
|
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
74
|
version: '0'
|
75
75
|
requirements: []
|
76
76
|
rubyforge_project:
|
77
|
-
rubygems_version: 2.
|
77
|
+
rubygems_version: 2.1.10
|
78
78
|
signing_key:
|
79
79
|
specification_version: 4
|
80
80
|
summary: MundiPagg Ruby Client Library
|