stone_ecommerce 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +202 -202
- data/README.md +58 -58
- data/lib/gateway/Address/billing_address.rb +33 -33
- data/lib/gateway/Address/buyer_address.rb +38 -38
- data/lib/gateway/Address/delivery_address.rb +34 -34
- data/lib/gateway/BoletoTransaction/boleto_transaction.rb +40 -40
- data/lib/gateway/BoletoTransaction/boleto_transaction_options.rb +16 -16
- data/lib/gateway/BoletoTransaction/boleto_transaction_report_file.rb +22 -22
- data/lib/gateway/CreditCardTransaction/credit_card.rb +30 -30
- data/lib/gateway/CreditCardTransaction/credit_card_transaction.rb +33 -33
- data/lib/gateway/CreditCardTransaction/credit_card_transaction_options.rb +28 -28
- data/lib/gateway/CreditCardTransaction/credit_card_transaction_report_file.rb +31 -31
- data/lib/gateway/CreditCardTransaction/manage_credit_card_transaction.rb +14 -14
- data/lib/gateway/CreditCardTransaction/retry_sale_credit_card_transaction.rb +14 -14
- data/lib/gateway/Gateway.rb +621 -621
- data/lib/gateway/InstantBuyData/create_instant_buy_data_request.rb +30 -30
- data/lib/gateway/InstantBuyData/update_instant_buy_data_request.rb +10 -10
- data/lib/gateway/Merchant/merchant.rb +12 -12
- data/lib/gateway/OnlineDebit/online_debit_transaction_report_file.rb +21 -21
- data/lib/gateway/Order/order.rb +13 -13
- data/lib/gateway/Order/order_transaction_report_file.rb +8 -8
- data/lib/gateway/Parsers/boleto_transaction_parser.rb +33 -33
- data/lib/gateway/Parsers/credit_card_transaction_parser.rb +42 -42
- data/lib/gateway/Parsers/header_parser.rb +16 -16
- data/lib/gateway/Parsers/online_debit_transaction_parser.rb +32 -32
- data/lib/gateway/Parsers/trailer_parser.rb +16 -16
- data/lib/gateway/Person/buyer.rb +32 -32
- data/lib/gateway/Person/create_buyer_request.rb +22 -22
- data/lib/gateway/Person/person.rb +48 -48
- data/lib/gateway/Recurrency/recurrency.rb +24 -24
- data/lib/gateway/Sale/create_sale_request.rb +37 -37
- data/lib/gateway/Sale/manage_sale_request.rb +18 -18
- data/lib/gateway/Sale/query_sale_request.rb +37 -37
- data/lib/gateway/Sale/request_data.rb +21 -21
- data/lib/gateway/Sale/retry_sale_options.rb +15 -15
- data/lib/gateway/Sale/retry_sale_request.rb +23 -23
- data/lib/gateway/Sale/sale_data.rb +30 -30
- data/lib/gateway/Sale/sale_order_data.rb +18 -18
- data/lib/gateway/SalesOption.rb +18 -18
- data/lib/gateway/ShoppingCart/shopping_cart.rb +27 -27
- data/lib/gateway/ShoppingCart/shopping_cart_item.rb +24 -24
- data/lib/gateway/Trailer.rb +8 -8
- data/lib/gateway/header.rb +7 -7
- data/lib/gateway/post_notification.rb +31 -31
- data/lib/gateway/transaction_report_file.rb +47 -47
- data/lib/stone_ecommerce.rb +61 -62
- data/spec/integration/gateway_spec.rb +1024 -1024
- data/spec/integration/test_helper.rb +68 -68
- data/stone_ecommerce.gemspec +20 -19
- metadata +27 -24
@@ -1,1024 +1,1024 @@
|
|
1
|
-
require_relative '../../lib/stone_ecommerce'
|
2
|
-
require_relative 'test_helper'
|
3
|
-
|
4
|
-
merchant_key = '8A2DD57F-1ED9-4153-B4CE-69683EFADAD5'
|
5
|
-
|
6
|
-
gateway = Gateway::Gateway.new(:production, merchant_key)
|
7
|
-
|
8
|
-
RSpec.describe Gateway do
|
9
|
-
it 'should create a sale with boleto' do
|
10
|
-
createSaleRequest = Gateway::CreateSaleRequest.new
|
11
|
-
|
12
|
-
boletoTransaction = Gateway::BoletoTransaction.new
|
13
|
-
boletoTransaction.AmountInCents = 100
|
14
|
-
boletoTransaction.BankNumber = '237'
|
15
|
-
boletoTransaction.DocumentNumber = '12345678901'
|
16
|
-
boletoTransaction.Instructions = 'Pagar antes do vencimento'
|
17
|
-
boletoTransaction.TransactionReference = 'BoletoTest#Ruby01'
|
18
|
-
boletoTransaction.Options.CurrencyIso = 'BRL'
|
19
|
-
boletoTransaction.Options.DaysToAddInBoletoExpirationDate = 5
|
20
|
-
|
21
|
-
createSaleRequest.BoletoTransactionCollection << boletoTransaction
|
22
|
-
|
23
|
-
response = gateway.CreateSale(createSaleRequest)
|
24
|
-
|
25
|
-
expect(response[:ErrorReport]).to eq nil
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'should create a sale with credit card' do
|
29
|
-
createSaleRequest = Gateway::CreateSaleRequest.new
|
30
|
-
|
31
|
-
buyerAddress = Gateway::BuyerAddress.new
|
32
|
-
buyerAddress.AddressType = 'Residential'
|
33
|
-
buyerAddress.City = 'Rio de Janeiro'
|
34
|
-
buyerAddress.Complement = '10 Andar'
|
35
|
-
buyerAddress.Country = 'Brazil'
|
36
|
-
buyerAddress.District = 'Centro'
|
37
|
-
buyerAddress.Number = '199'
|
38
|
-
buyerAddress.State = 'RJ'
|
39
|
-
buyerAddress.Street = 'Rua da Quitanda'
|
40
|
-
buyerAddress.ZipCode = '20091005'
|
41
|
-
|
42
|
-
creditCardTransaction = Gateway::CreditCardTransaction.new
|
43
|
-
creditCardTransaction.AmountInCents = 100
|
44
|
-
creditCardTransaction.InstallmentCount = 1
|
45
|
-
creditCardTransaction.TransactionReference = 'CreditCard One RubySDK Test'
|
46
|
-
creditCardTransaction.Options.PaymentMethodCode = 1
|
47
|
-
creditCardTransaction.Options.SoftDescriptorText = 'My Store Name'
|
48
|
-
creditCardTransaction.CreditCard.CreditCardNumber = '5453010000066167'
|
49
|
-
creditCardTransaction.CreditCard.ExpMonth = 5
|
50
|
-
creditCardTransaction.CreditCard.ExpYear = 18
|
51
|
-
creditCardTransaction.CreditCard.HolderName = 'Maria do Carmo'
|
52
|
-
creditCardTransaction.CreditCard.SecurityCode = '123'
|
53
|
-
creditCardTransaction.CreditCard.CreditCardBrand = 'Mastercard'
|
54
|
-
creditCardTransaction.CreditCard.BillingAddress.City = 'Rio de Janeiro'
|
55
|
-
creditCardTransaction.CreditCard.BillingAddress.Complement = '10 Andar'
|
56
|
-
creditCardTransaction.CreditCard.BillingAddress.Country = 'Brazil'
|
57
|
-
creditCardTransaction.CreditCard.BillingAddress.District = 'Centro'
|
58
|
-
creditCardTransaction.CreditCard.BillingAddress.Number = '199'
|
59
|
-
creditCardTransaction.CreditCard.BillingAddress.State = 'RJ'
|
60
|
-
creditCardTransaction.CreditCard.BillingAddress.Street = 'Rua da Quitanda'
|
61
|
-
creditCardTransaction.CreditCard.BillingAddress.ZipCode = '20091005'
|
62
|
-
|
63
|
-
createSaleRequest.CreditCardTransactionCollection << creditCardTransaction
|
64
|
-
createSaleRequest.Buyer.Birthdate = Date.new(2001, 9, 26).strftime("%Y-%m-%dT%H:%M:%S")
|
65
|
-
createSaleRequest.Buyer.BuyerCategory = 'Normal'
|
66
|
-
createSaleRequest.Buyer.Email = 'mundiBuyer@mundi.com.br'
|
67
|
-
createSaleRequest.Buyer.EmailType = 'Personal'
|
68
|
-
createSaleRequest.Buyer.Gender = 'M'
|
69
|
-
createSaleRequest.Buyer.HomePhone = '22222222'
|
70
|
-
createSaleRequest.Buyer.MobilePhone = '988888888'
|
71
|
-
createSaleRequest.Buyer.WorkPhone = '25555555'
|
72
|
-
createSaleRequest.Buyer.CreateDateInMerchant = (Date.parse(Time.now.to_s)).strftime("%Y-%m-%dT%H:%M:%S")
|
73
|
-
createSaleRequest.Buyer.LastBuyerUpdateInMerchant = (Date.parse(Time.now.to_s)).strftime("%Y-%m-%dT%H:%M:%S")
|
74
|
-
createSaleRequest.Buyer.DocumentNumber = '51212382749'
|
75
|
-
createSaleRequest.Buyer.DocumentType = 'CPF'
|
76
|
-
createSaleRequest.Buyer.Name = 'Jose da Silva Ramos'
|
77
|
-
createSaleRequest.Buyer.PersonType = 'Person'
|
78
|
-
createSaleRequest.Buyer.AddressCollection << buyerAddress
|
79
|
-
|
80
|
-
response = gateway.CreateSale(createSaleRequest)
|
81
|
-
|
82
|
-
expect(response[:ErrorReport]).to eq nil
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
it 'should create a sale with all types of transactions and all fields filled' do
|
87
|
-
# creates boleto transaction object
|
88
|
-
boletoTransaction = Gateway::BoletoTransaction.new
|
89
|
-
|
90
|
-
# 100 reais in cents
|
91
|
-
boletoTransaction.AmountInCents = 10000
|
92
|
-
boletoTransaction.BankNumber = '237'
|
93
|
-
boletoTransaction.BillingAddress.City = 'Tatooine'
|
94
|
-
boletoTransaction.BillingAddress.Complement = ''
|
95
|
-
boletoTransaction.BillingAddress.Country = 'Brazil'
|
96
|
-
boletoTransaction.BillingAddress.District = 'Mos Eisley'
|
97
|
-
boletoTransaction.BillingAddress.Number = '123'
|
98
|
-
boletoTransaction.BillingAddress.State = 'RJ'
|
99
|
-
boletoTransaction.BillingAddress.Street = 'Mos Eisley Cantina'
|
100
|
-
boletoTransaction.BillingAddress.ZipCode = '20001000'
|
101
|
-
boletoTransaction.DocumentNumber = '12345678901'
|
102
|
-
boletoTransaction.Instructions = 'Pagar antes do vencimento'
|
103
|
-
boletoTransaction.Options.CurrencyIso = 'BRL'
|
104
|
-
boletoTransaction.Options.DaysToAddInBoletoExpirationDate = 5
|
105
|
-
boletoTransaction.TransactionReference = 'NumeroDaTransacao'
|
106
|
-
|
107
|
-
|
108
|
-
# create credit card transaction object
|
109
|
-
creditCardTransaction = Gateway::CreditCardTransaction.new
|
110
|
-
|
111
|
-
# 100 reais in cents
|
112
|
-
creditCardTransaction.AmountInCents = 10000
|
113
|
-
creditCardTransaction.CreditCard.BillingAddress.City = 'Tatooine'
|
114
|
-
creditCardTransaction.CreditCard.BillingAddress.Complement = ''
|
115
|
-
creditCardTransaction.CreditCard.BillingAddress.Country = 'Brazil'
|
116
|
-
creditCardTransaction.CreditCard.BillingAddress.District = 'Mos Eisley'
|
117
|
-
creditCardTransaction.CreditCard.BillingAddress.Number = '123'
|
118
|
-
creditCardTransaction.CreditCard.BillingAddress.State = 'RJ'
|
119
|
-
creditCardTransaction.CreditCard.BillingAddress.Street = 'Mos Eisley Cantina'
|
120
|
-
creditCardTransaction.CreditCard.BillingAddress.ZipCode = '20001000'
|
121
|
-
creditCardTransaction.CreditCard.CreditCardBrand = 'Visa'
|
122
|
-
creditCardTransaction.CreditCard.CreditCardNumber = '4111111111111111'
|
123
|
-
creditCardTransaction.CreditCard.ExpMonth = 10
|
124
|
-
creditCardTransaction.CreditCard.ExpYear = 22
|
125
|
-
creditCardTransaction.CreditCard.HolderName = 'LUKE SKYWALKER'
|
126
|
-
creditCardTransaction.CreditCard.SecurityCode = '123'
|
127
|
-
creditCardTransaction.CreditCardOperation = 'AuthOnly'
|
128
|
-
creditCardTransaction.InstallmentCount = 1
|
129
|
-
creditCardTransaction.Options.CurrencyIso = 'BRL'
|
130
|
-
creditCardTransaction.Options.PaymentMethodCode = 1
|
131
|
-
creditCardTransaction.Options.SoftDescriptorText = 'Jedi Mega Store'
|
132
|
-
|
133
|
-
shoppingCartItem = Gateway::ShoppingCartItemCollection.new
|
134
|
-
shoppingCartItem.Description = 'Red Lightsaber'
|
135
|
-
shoppingCartItem.DiscountAmountInCents = 0
|
136
|
-
shoppingCartItem.ItemReference = 'NumeroDoProduto'
|
137
|
-
shoppingCartItem.Name = 'Lightsaber'
|
138
|
-
shoppingCartItem.Quantity = 1
|
139
|
-
shoppingCartItem.TotalCostInCents = 18000
|
140
|
-
shoppingCartItem.UnitCostInCents = 18000
|
141
|
-
|
142
|
-
shoppingCartCollection = Gateway::ShoppingCartCollection.new
|
143
|
-
shoppingCartCollection.DeliveryAddress.City = 'Galaxy far far away'
|
144
|
-
shoppingCartCollection.DeliveryAddress.Complement = 'Bridge'
|
145
|
-
shoppingCartCollection.DeliveryAddress.Country = 'Brazil'
|
146
|
-
shoppingCartCollection.DeliveryAddress.District = 'Command Room'
|
147
|
-
shoppingCartCollection.DeliveryAddress.Number = '321'
|
148
|
-
shoppingCartCollection.DeliveryAddress.State = 'RJ'
|
149
|
-
shoppingCartCollection.DeliveryAddress.Street = 'Death Star'
|
150
|
-
shoppingCartCollection.DeliveryAddress.ZipCode = '10002000'
|
151
|
-
shoppingCartCollection.DeliveryDeadline = DateTime.new(2015, 12, 14, 18, 36, 45).strftime("%Y-%m-%dT%H:%M:%S")
|
152
|
-
shoppingCartCollection.EstimatedDeliveryDate = DateTime.new(2015, 12, 14, 18, 36, 45).strftime("%Y-%m-%dT%H:%M:%S")
|
153
|
-
shoppingCartCollection.FreighCostInCents = 2000
|
154
|
-
shoppingCartCollection.ShippingCompany = 'Empire'
|
155
|
-
shoppingCartCollection.ShoppingCartItemCollection << shoppingCartItem
|
156
|
-
|
157
|
-
# creates request object for transaction creation
|
158
|
-
createSaleRequest = Gateway::CreateSaleRequest.new
|
159
|
-
|
160
|
-
# adds to the boleto transaction collection
|
161
|
-
createSaleRequest.BoletoTransactionCollection << boletoTransaction
|
162
|
-
|
163
|
-
buyerAddress = Gateway::BuyerAddress.new
|
164
|
-
buyerAddress.AddressType = 'Residential'
|
165
|
-
buyerAddress.City = 'Tatooine'
|
166
|
-
buyerAddress.Complement = ''
|
167
|
-
buyerAddress.Country = 'Brazil'
|
168
|
-
buyerAddress.District = 'Mos Eisley'
|
169
|
-
buyerAddress.Number = '123'
|
170
|
-
buyerAddress.State = 'RJ'
|
171
|
-
buyerAddress.Street = 'Mos Eisley Cantina'
|
172
|
-
buyerAddress.ZipCode = '20001000'
|
173
|
-
|
174
|
-
createSaleRequest.Buyer.AddressCollection << buyerAddress
|
175
|
-
createSaleRequest.Buyer.Birthdate = DateTime.new(1990,8,20,0,0,0).strftime("%Y-%m-%dT%H:%M:%S")
|
176
|
-
createSaleRequest.Buyer.BuyerCategory = 'Normal'
|
177
|
-
createSaleRequest.Buyer.BuyerReference = 'C3PO'
|
178
|
-
createSaleRequest.Buyer.CreateDateInMerchant = DateTime.new(2015,12,11,18,36,45).strftime("%Y-%m-%dT%H:%M:%S")
|
179
|
-
createSaleRequest.Buyer.DocumentNumber = '12345678901'
|
180
|
-
createSaleRequest.Buyer.DocumentType = 'CPF'
|
181
|
-
createSaleRequest.Buyer.Email = 'lskywalker@r2d2.com'
|
182
|
-
createSaleRequest.Buyer.EmailType = 'Personal'
|
183
|
-
createSaleRequest.Buyer.FacebookId = 'lukeskywalker8917'
|
184
|
-
createSaleRequest.Buyer.Gender = 'M'
|
185
|
-
createSaleRequest.Buyer.HomePhone = '(21)123456789'
|
186
|
-
createSaleRequest.Buyer.MobilePhone = '(21)987654321'
|
187
|
-
createSaleRequest.Buyer.Name = 'Luke Skywalker'
|
188
|
-
createSaleRequest.Buyer.PersonType = 'Person'
|
189
|
-
createSaleRequest.Buyer.TwitterId = '@lukeskywalker8917'
|
190
|
-
createSaleRequest.Buyer.WorkPhone = '(21)28467902'
|
191
|
-
|
192
|
-
# adds to the credit card transaction collection
|
193
|
-
createSaleRequest.CreditCardTransactionCollection << creditCardTransaction
|
194
|
-
createSaleRequest.Merchant.MerchantReference = 'IdDaLojaPlataforma'
|
195
|
-
createSaleRequest.Options.AntiFraudServiceCode = 0
|
196
|
-
createSaleRequest.Options.CurrencyIso = 'BRL'
|
197
|
-
createSaleRequest.Options.IsAntiFraudEnabled = true
|
198
|
-
createSaleRequest.Options.Retries = 1
|
199
|
-
createSaleRequest.Order.OrderReference = 'NumeroDoPedido'
|
200
|
-
createSaleRequest.RequestData.EcommerceCategory = 'B2C'
|
201
|
-
createSaleRequest.RequestData.IpAddress = '127.0.0.1'
|
202
|
-
createSaleRequest.RequestData.Origin = 'SiteDeCompra'
|
203
|
-
createSaleRequest.RequestData.SessionId = 'IdSesssaoNoSite'
|
204
|
-
|
205
|
-
# adds shopping cart collection in the request
|
206
|
-
createSaleRequest.ShoppingCartCollection << shoppingCartCollection
|
207
|
-
|
208
|
-
# make the request and returns a response hash
|
209
|
-
response = gateway.CreateSale(createSaleRequest)
|
210
|
-
|
211
|
-
expect(response[:ErrorReport]).to eq nil
|
212
|
-
end
|
213
|
-
|
214
|
-
it 'should create an anti fraud transaction' do
|
215
|
-
# create credit card transaction object
|
216
|
-
creditCardTransaction = Gateway::CreditCardTransaction.new
|
217
|
-
|
218
|
-
# 100 reais in cents
|
219
|
-
creditCardTransaction.AmountInCents = 10000
|
220
|
-
creditCardTransaction.CreditCard.BillingAddress.City = 'Tatooine'
|
221
|
-
creditCardTransaction.CreditCard.BillingAddress.Complement = ''
|
222
|
-
creditCardTransaction.CreditCard.BillingAddress.Country = 'Brazil'
|
223
|
-
creditCardTransaction.CreditCard.BillingAddress.District = 'Mos Eisley'
|
224
|
-
creditCardTransaction.CreditCard.BillingAddress.Number = '123'
|
225
|
-
creditCardTransaction.CreditCard.BillingAddress.State = 'RJ'
|
226
|
-
creditCardTransaction.CreditCard.BillingAddress.Street = 'Mos Eisley Cantina'
|
227
|
-
creditCardTransaction.CreditCard.BillingAddress.ZipCode = '20001000'
|
228
|
-
creditCardTransaction.CreditCard.CreditCardBrand = 'Visa'
|
229
|
-
creditCardTransaction.CreditCard.CreditCardNumber = '4111111111111111'
|
230
|
-
creditCardTransaction.CreditCard.ExpMonth = 10
|
231
|
-
creditCardTransaction.CreditCard.ExpYear = 22
|
232
|
-
creditCardTransaction.CreditCard.HolderName = 'LUKE SKYWALKER'
|
233
|
-
creditCardTransaction.CreditCard.SecurityCode = '123'
|
234
|
-
creditCardTransaction.InstallmentCount = 1
|
235
|
-
|
236
|
-
shoppingCartItem = Gateway::ShoppingCartItemCollection.new
|
237
|
-
shoppingCartItem.Description = 'Red Lightsaber'
|
238
|
-
shoppingCartItem.DiscountAmountInCents = 0
|
239
|
-
shoppingCartItem.ItemReference = 'NumeroDoProduto'
|
240
|
-
shoppingCartItem.Name = 'Lightsaber'
|
241
|
-
shoppingCartItem.Quantity = 1
|
242
|
-
shoppingCartItem.TotalCostInCents = 18000
|
243
|
-
shoppingCartItem.UnitCostInCents = 0
|
244
|
-
|
245
|
-
shoppingCartCollection = Gateway::ShoppingCartCollection.new
|
246
|
-
shoppingCartCollection.DeliveryAddress.City = 'Galaxy far far away'
|
247
|
-
shoppingCartCollection.DeliveryAddress.Complement = 'Bridge'
|
248
|
-
shoppingCartCollection.DeliveryAddress.Country = 'Brazil'
|
249
|
-
shoppingCartCollection.DeliveryAddress.District = 'Command Room'
|
250
|
-
shoppingCartCollection.DeliveryAddress.Number = '321'
|
251
|
-
shoppingCartCollection.DeliveryAddress.State = 'RJ'
|
252
|
-
shoppingCartCollection.DeliveryAddress.Street = 'Death Star'
|
253
|
-
shoppingCartCollection.DeliveryAddress.ZipCode = '10002000'
|
254
|
-
shoppingCartCollection.FreighCostInCents = 2000
|
255
|
-
shoppingCartCollection.ShoppingCartItemCollection << shoppingCartItem
|
256
|
-
|
257
|
-
# creates request object for transaction creation
|
258
|
-
createSaleRequest = Gateway::CreateSaleRequest.new
|
259
|
-
|
260
|
-
buyerAddress = Gateway::BuyerAddress.new
|
261
|
-
buyerAddress.AddressType = 'Residential'
|
262
|
-
buyerAddress.City = 'Tatooine'
|
263
|
-
buyerAddress.Complement = ''
|
264
|
-
buyerAddress.Country = 'Brazil'
|
265
|
-
buyerAddress.District = 'Mos Eisley'
|
266
|
-
buyerAddress.Number = '123'
|
267
|
-
buyerAddress.State = 'RJ'
|
268
|
-
buyerAddress.Street = 'Mos Eisley Cantina'
|
269
|
-
buyerAddress.ZipCode = '20001000'
|
270
|
-
|
271
|
-
createSaleRequest.Buyer.AddressCollection << buyerAddress
|
272
|
-
createSaleRequest.Buyer.Birthdate = DateTime.new(1990,8,20,0,0,0).strftime("%Y-%m-%dT%H:%M:%S")
|
273
|
-
createSaleRequest.Buyer.BuyerReference = 'C3PO'
|
274
|
-
createSaleRequest.Buyer.DocumentNumber = '12345678901'
|
275
|
-
createSaleRequest.Buyer.DocumentType = 'CPF'
|
276
|
-
createSaleRequest.Buyer.Email = 'lskywalker@r2d2.com'
|
277
|
-
createSaleRequest.Buyer.EmailType = 'Personal'
|
278
|
-
createSaleRequest.Buyer.Gender = 'M'
|
279
|
-
createSaleRequest.Buyer.HomePhone = '(21)123456789'
|
280
|
-
createSaleRequest.Buyer.MobilePhone = '(21)987654321'
|
281
|
-
createSaleRequest.Buyer.Name = 'Luke Skywalker'
|
282
|
-
createSaleRequest.Buyer.PersonType = 'Person'
|
283
|
-
createSaleRequest.Buyer.WorkPhone = '(21)28467902'
|
284
|
-
|
285
|
-
# adds to the credit card transaction collection
|
286
|
-
createSaleRequest.CreditCardTransactionCollection << creditCardTransaction
|
287
|
-
createSaleRequest.Options.IsAntiFraudEnabled = true
|
288
|
-
createSaleRequest.Order.OrderReference = 'NumeroDoPedido'
|
289
|
-
|
290
|
-
# adds shopping cart collection in the request
|
291
|
-
createSaleRequest.ShoppingCartCollection << shoppingCartCollection
|
292
|
-
|
293
|
-
# make the request and returns a response hash
|
294
|
-
response = gateway.CreateSale(createSaleRequest)
|
295
|
-
|
296
|
-
expect(response[:ErrorReport]).to eq nil
|
297
|
-
end
|
298
|
-
|
299
|
-
it 'should consult the order with order key' do
|
300
|
-
querySaleRequest = Gateway::QuerySaleRequest.new
|
301
|
-
createSaleRequest = Gateway::CreateSaleRequest.new
|
302
|
-
|
303
|
-
boletoTransaction = Gateway::BoletoTransaction.new
|
304
|
-
boletoTransaction.AmountInCents = 100
|
305
|
-
boletoTransaction.BankNumber = '237'
|
306
|
-
boletoTransaction.DocumentNumber = '12345678901'
|
307
|
-
boletoTransaction.Instructions = 'Pagar antes do vencimento'
|
308
|
-
boletoTransaction.TransactionReference = 'BoletoTest#Ruby01'
|
309
|
-
boletoTransaction.Options.CurrencyIso = 'BRL'
|
310
|
-
boletoTransaction.Options.DaysToAddInBoletoExpirationDate = 5
|
311
|
-
|
312
|
-
createSaleRequest.BoletoTransactionCollection << boletoTransaction
|
313
|
-
|
314
|
-
boleto_response = gateway.CreateSale(createSaleRequest)
|
315
|
-
|
316
|
-
querySaleRequest.OrderKey = boleto_response['OrderResult']['OrderKey']
|
317
|
-
responseQuery = gateway.Query(Gateway::QuerySaleRequest.QuerySaleRequestEnum[:OrderKey], querySaleRequest.OrderKey)
|
318
|
-
|
319
|
-
orderKey = responseQuery["SaleDataCollection"][0]["OrderData"]["OrderKey"]
|
320
|
-
|
321
|
-
expect(orderKey).to eq querySaleRequest.OrderKey
|
322
|
-
end
|
323
|
-
|
324
|
-
it 'should consult the order with order reference' do
|
325
|
-
querySaleRequest = Gateway::QuerySaleRequest.new
|
326
|
-
createSaleRequest = Gateway::CreateSaleRequest.new
|
327
|
-
|
328
|
-
boletoTransaction = Gateway::BoletoTransaction.new
|
329
|
-
boletoTransaction.AmountInCents = 100
|
330
|
-
boletoTransaction.BankNumber = '237'
|
331
|
-
boletoTransaction.DocumentNumber = '12345678901'
|
332
|
-
boletoTransaction.Instructions = 'Pagar antes do vencimento'
|
333
|
-
boletoTransaction.TransactionReference = 'BoletoTest#Ruby01'
|
334
|
-
boletoTransaction.Options.CurrencyIso = 'BRL'
|
335
|
-
boletoTransaction.Options.DaysToAddInBoletoExpirationDate = 5
|
336
|
-
|
337
|
-
createSaleRequest.Order.OrderReference = 'RubyOrderReferenceUnitTest'
|
338
|
-
createSaleRequest.BoletoTransactionCollection << boletoTransaction
|
339
|
-
|
340
|
-
boleto_response = gateway.CreateSale(createSaleRequest)
|
341
|
-
|
342
|
-
querySaleRequest.OrderReference = boleto_response['OrderResult']['OrderReference']
|
343
|
-
responseQuery = gateway.Query(Gateway::QuerySaleRequest.QuerySaleRequestEnum[:OrderReference], querySaleRequest.OrderReference)
|
344
|
-
|
345
|
-
orderReference = responseQuery["SaleDataCollection"][0]["OrderData"]["OrderReference"]
|
346
|
-
|
347
|
-
expect(orderReference).to eq querySaleRequest.OrderReference
|
348
|
-
end
|
349
|
-
|
350
|
-
it 'should do a retry method' do
|
351
|
-
retrySaleRequest = Gateway::RetrySaleRequest.new
|
352
|
-
retrySaleCreditCardTransactionItem = Gateway::RetrySaleCreditCardTransaction.new
|
353
|
-
|
354
|
-
createSaleRequest = Gateway::CreateSaleRequest.new
|
355
|
-
creditCardTransactionItem = Gateway::CreditCardTransaction.new
|
356
|
-
creditCardTransactionItem.AmountInCents = 100
|
357
|
-
creditCardTransactionItem.CreditCard.CreditCardBrand = 'Visa'
|
358
|
-
creditCardTransactionItem.CreditCard.CreditCardNumber = '41111111111111'
|
359
|
-
creditCardTransactionItem.CreditCard.ExpMonth = 10
|
360
|
-
creditCardTransactionItem.CreditCard.ExpYear = 19
|
361
|
-
creditCardTransactionItem.CreditCard.HolderName = 'Maria do Carmo'
|
362
|
-
creditCardTransactionItem.CreditCard.SecurityCode = '123'
|
363
|
-
creditCardTransactionItem.CreditCardOperation = 'AuthAndCapture'
|
364
|
-
creditCardTransactionItem.InstallmentCount = 1
|
365
|
-
creditCardTransactionItem.Options.CurrencyIso = 'BRL'
|
366
|
-
creditCardTransactionItem.Options.PaymentMethodCode = 1
|
367
|
-
creditCardTransactionItem.TransactionReference = 'RubySDK-RetryTest'
|
368
|
-
|
369
|
-
createSaleRequest.CreditCardTransactionCollection << creditCardTransactionItem
|
370
|
-
createSaleRequest.Order.OrderReference = 'RubySDK-RetryTest'
|
371
|
-
|
372
|
-
# cria o pedido que sera usado para retentativa
|
373
|
-
responseCreate = gateway.CreateSale(createSaleRequest)
|
374
|
-
|
375
|
-
# pega o orderkey e o transaction key da resposta que sao necessarios para fazer a retentativa
|
376
|
-
orderKey = responseCreate["OrderResult"]["OrderKey"]
|
377
|
-
transactionKey = responseCreate['CreditCardTransactionResultCollection'][0]['TransactionKey']
|
378
|
-
|
379
|
-
# monta o objeto de retentativa
|
380
|
-
retrySaleCreditCardTransactionItem.SecurityCode = '123'
|
381
|
-
retrySaleCreditCardTransactionItem.TransactionKey = transactionKey
|
382
|
-
retrySaleRequest.OrderKey = orderKey
|
383
|
-
retrySaleRequest.RetrySaleCreditCardTransactionCollection << retrySaleCreditCardTransactionItem
|
384
|
-
|
385
|
-
# faz a requisicao de retentativa
|
386
|
-
response = gateway.Retry(retrySaleRequest)
|
387
|
-
|
388
|
-
# espera que o transaction key seja igual, significa que foi tudo ok no teste
|
389
|
-
responseTransactionKey = response['CreditCardTransactionResultCollection'][0]['TransactionKey']
|
390
|
-
|
391
|
-
expect(responseTransactionKey).to eq transactionKey
|
392
|
-
|
393
|
-
end
|
394
|
-
|
395
|
-
it 'should do a retry method with only order key' do
|
396
|
-
createSaleRequest = Gateway::CreateSaleRequest.new
|
397
|
-
creditCardTransactionItem = Gateway::CreditCardTransaction.new
|
398
|
-
creditCardTransactionItem.AmountInCents = 100
|
399
|
-
creditCardTransactionItem.CreditCard.CreditCardBrand = 'Visa'
|
400
|
-
creditCardTransactionItem.CreditCard.CreditCardNumber = '41111111111111'
|
401
|
-
creditCardTransactionItem.CreditCard.ExpMonth = 10
|
402
|
-
creditCardTransactionItem.CreditCard.ExpYear = 22
|
403
|
-
creditCardTransactionItem.CreditCard.HolderName = 'Maria do Carmo'
|
404
|
-
creditCardTransactionItem.CreditCard.SecurityCode = '123'
|
405
|
-
creditCardTransactionItem.CreditCardOperation = 'AuthAndCapture'
|
406
|
-
creditCardTransactionItem.TransactionReference = 'RubySDK-RetryTest'
|
407
|
-
|
408
|
-
createSaleRequest.CreditCardTransactionCollection << creditCardTransactionItem
|
409
|
-
createSaleRequest.Order.OrderReference = 'RubySDK-RetryTest'
|
410
|
-
|
411
|
-
# cria o pedido que sera usado para retentativa
|
412
|
-
responseCreate = gateway.CreateSale(createSaleRequest)
|
413
|
-
|
414
|
-
# pega o orderkey e o transaction key da resposta que sao necessarios para fazer a retentativa
|
415
|
-
orderKey = responseCreate["OrderResult"]["OrderKey"]
|
416
|
-
transactionKey = responseCreate['CreditCardTransactionResultCollection'][0]['TransactionKey']
|
417
|
-
|
418
|
-
retrySaleRequest = Gateway::RetrySaleRequest.new
|
419
|
-
|
420
|
-
# monta o objeto de retentativa
|
421
|
-
retrySaleRequest.OrderKey = orderKey
|
422
|
-
|
423
|
-
# faz a requisicao de retentativa
|
424
|
-
response = gateway.Retry(retrySaleRequest)
|
425
|
-
|
426
|
-
expect(response['ErrorReport']).to eq nil
|
427
|
-
|
428
|
-
end
|
429
|
-
|
430
|
-
it 'should cancel a transaction' do
|
431
|
-
createSaleRequest = Gateway::CreateSaleRequest.new
|
432
|
-
creditCardTransactionItem = Gateway::CreditCardTransaction.new
|
433
|
-
creditCardTransactionItem.AmountInCents = 100
|
434
|
-
creditCardTransactionItem.CreditCard.CreditCardBrand = 'Visa'
|
435
|
-
creditCardTransactionItem.CreditCard.CreditCardNumber = '41111111111111'
|
436
|
-
creditCardTransactionItem.CreditCard.ExpMonth = 10
|
437
|
-
creditCardTransactionItem.CreditCard.ExpYear = 19
|
438
|
-
creditCardTransactionItem.CreditCard.HolderName = 'Maria do Carmo'
|
439
|
-
creditCardTransactionItem.CreditCard.SecurityCode = '123'
|
440
|
-
creditCardTransactionItem.CreditCardOperation = 'AuthAndCapture'
|
441
|
-
creditCardTransactionItem.InstallmentCount = 1
|
442
|
-
creditCardTransactionItem.Options.CurrencyIso = 'BRL'
|
443
|
-
creditCardTransactionItem.Options.PaymentMethodCode = 1
|
444
|
-
creditCardTransactionItem.TransactionReference = 'RubySDK-CancelTest'
|
445
|
-
|
446
|
-
createSaleRequest.CreditCardTransactionCollection << creditCardTransactionItem
|
447
|
-
createSaleRequest.Order.OrderReference = 'RubySDK-CancelTest'
|
448
|
-
|
449
|
-
# cria o pedido que sera usado para cancelamento
|
450
|
-
responseCreate = gateway.CreateSale(createSaleRequest)
|
451
|
-
|
452
|
-
# pega o orderkey e o transaction key da resposta que sao necessarios para fazer o cancelamento
|
453
|
-
orderKey = responseCreate["OrderResult"]["OrderKey"]
|
454
|
-
transactionKey = responseCreate['CreditCardTransactionResultCollection'][0]['TransactionKey']
|
455
|
-
|
456
|
-
# itens necessarios para cancelamento da transacao de cartao de credito
|
457
|
-
cancelCreditCardTransactionItem = Gateway::ManageCreditCardTransaction.new
|
458
|
-
cancelCreditCardTransactionItem.AmountInCents = 100
|
459
|
-
cancelCreditCardTransactionItem.TransactionKey = transactionKey
|
460
|
-
cancelCreditCardTransactionItem.TransactionReference = 'RubySDK-CancelTest'
|
461
|
-
|
462
|
-
# monta o objeto para cancelamento de transacao
|
463
|
-
cancelSaleRequest = Gateway::ManageSaleRequest.new
|
464
|
-
cancelSaleRequest.OrderKey = orderKey
|
465
|
-
cancelSaleRequest.CreditCardTransactionCollection << cancelCreditCardTransactionItem
|
466
|
-
|
467
|
-
response = gateway.Cancel(cancelSaleRequest)
|
468
|
-
|
469
|
-
expect(response[:ErrorReport]).to eq nil
|
470
|
-
end
|
471
|
-
|
472
|
-
it 'should capture a transaction' do
|
473
|
-
createSaleRequest = Gateway::CreateSaleRequest.new
|
474
|
-
creditCardTransactionItem = Gateway::CreditCardTransaction.new
|
475
|
-
creditCardTransactionItem.AmountInCents = 100
|
476
|
-
creditCardTransactionItem.CreditCard.CreditCardBrand = 'Visa'
|
477
|
-
creditCardTransactionItem.CreditCard.CreditCardNumber = '41111111111111'
|
478
|
-
creditCardTransactionItem.CreditCard.ExpMonth = 10
|
479
|
-
creditCardTransactionItem.CreditCard.ExpYear = 19
|
480
|
-
creditCardTransactionItem.CreditCard.HolderName = 'Maria do Carmo'
|
481
|
-
creditCardTransactionItem.CreditCard.SecurityCode = '123'
|
482
|
-
creditCardTransactionItem.CreditCardOperation = 'AuthAndCapture'
|
483
|
-
creditCardTransactionItem.InstallmentCount = 1
|
484
|
-
creditCardTransactionItem.Options.CurrencyIso = 'BRL'
|
485
|
-
creditCardTransactionItem.Options.PaymentMethodCode = 1
|
486
|
-
creditCardTransactionItem.TransactionReference = 'RubySDK-CaptureTest'
|
487
|
-
|
488
|
-
createSaleRequest.CreditCardTransactionCollection << creditCardTransactionItem
|
489
|
-
createSaleRequest.Order.OrderReference = 'RubySDK-CaptureTest'
|
490
|
-
|
491
|
-
# cria o pedido que sera usado para captura
|
492
|
-
responseCreate = gateway.CreateSale(createSaleRequest)
|
493
|
-
|
494
|
-
# pega o orderkey e o transaction key da resposta que sao necessarios para fazer a captura
|
495
|
-
orderKey = responseCreate["OrderResult"]["OrderKey"]
|
496
|
-
transactionKey = responseCreate['CreditCardTransactionResultCollection'][0]['TransactionKey']
|
497
|
-
|
498
|
-
# itens necessarios para captura da transacao de cartao de credito
|
499
|
-
captureCreditCardTransactionItem = Gateway::ManageCreditCardTransaction.new
|
500
|
-
captureCreditCardTransactionItem.AmountInCents = 100
|
501
|
-
captureCreditCardTransactionItem.TransactionKey = transactionKey
|
502
|
-
captureCreditCardTransactionItem.TransactionReference = 'RubySDK-CaptureTest'
|
503
|
-
|
504
|
-
# monta o objeto para cancelamento de transacao
|
505
|
-
captureSaleRequest = Gateway::ManageSaleRequest.new
|
506
|
-
captureSaleRequest.OrderKey = orderKey
|
507
|
-
captureSaleRequest.CreditCardTransactionCollection << captureCreditCardTransactionItem
|
508
|
-
|
509
|
-
response = gateway.Capture(captureSaleRequest)
|
510
|
-
|
511
|
-
# espera que o ErrorReport seja nulo, significa que foi tudo ok na transação
|
512
|
-
expect(response['ErrorReport']).to eq nil
|
513
|
-
end
|
514
|
-
|
515
|
-
it 'should do a parse xml to notification interpretation' do
|
516
|
-
creditCardTransactionItem = Gateway::CreditCardTransaction.new
|
517
|
-
creditCardTransactionItem.AmountInCents = 100
|
518
|
-
creditCardTransactionItem.TransactionReference = 'Ruby PostNotification Test'
|
519
|
-
creditCardTransactionItem.InstallmentCount = 1
|
520
|
-
creditCardTransactionItem.CreditCardOperation = 'AuthAndCapture'
|
521
|
-
creditCardTransactionItem.CreditCard.CreditCardBrand = 'Visa'
|
522
|
-
creditCardTransactionItem.CreditCard.CreditCardNumber = '4111111111111111'
|
523
|
-
creditCardTransactionItem.CreditCard.HolderName = 'Bruce Wayne'
|
524
|
-
creditCardTransactionItem.CreditCard.SecurityCode = '123'
|
525
|
-
creditCardTransactionItem.CreditCard.ExpMonth = 5
|
526
|
-
creditCardTransactionItem.CreditCard.ExpYear = 20
|
527
|
-
creditCardTransactionItem.Options.PaymentMethodCode = 1
|
528
|
-
|
529
|
-
createSaleRequest = Gateway::CreateSaleRequest.new
|
530
|
-
createSaleRequest.CreditCardTransactionCollection << creditCardTransactionItem
|
531
|
-
|
532
|
-
response_hash = gateway.CreateSale(createSaleRequest)
|
533
|
-
|
534
|
-
credit_card_result = response_hash['CreditCardTransactionResultCollection'][0]
|
535
|
-
|
536
|
-
expect(credit_card_result['Success']).to eq true
|
537
|
-
# expect(credit_card_result['CreditCardOperation']).to eq 'AuthOnly'
|
538
|
-
# expect(credit_card_result['CreditCardTransactionStatus']).to eq 'AuthorizedPendingCapture'
|
539
|
-
|
540
|
-
captureCreditCardTransactionItem = Gateway::ManageCreditCardTransaction.new
|
541
|
-
captureCreditCardTransactionItem.AmountInCents = creditCardTransactionItem.AmountInCents
|
542
|
-
captureCreditCardTransactionItem.TransactionKey = credit_card_result['TransactionKey']
|
543
|
-
captureCreditCardTransactionItem.TransactionReference = creditCardTransactionItem.TransactionReference
|
544
|
-
|
545
|
-
captureSale = Gateway::ManageSaleRequest.new
|
546
|
-
captureSale.OrderKey = response_hash['OrderResult']['OrderKey']
|
547
|
-
captureSale.CreditCardTransactionCollection << captureCreditCardTransactionItem
|
548
|
-
|
549
|
-
captureResponse = gateway.Capture(captureSale)
|
550
|
-
|
551
|
-
expect(captureResponse['ErrorReport']).to eq nil
|
552
|
-
|
553
|
-
|
554
|
-
xml = TestHelper.CreateFakePostNotification(response_hash, captureResponse)
|
555
|
-
|
556
|
-
response = gateway.ParseXmlToNotification(xml)
|
557
|
-
|
558
|
-
expect(response.nil?).to eq false
|
559
|
-
end
|
560
|
-
|
561
|
-
it 'should do a parse on online debit xml' do
|
562
|
-
xml = '<StatusNotification xmlns="http://schemas.datacontract.org/2004/07/Gateway.NotificationService.DataContract"
|
563
|
-
xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
|
564
|
-
i:schemaLocation="http://schemas.datacontract.org/2004/07/Gateway.NotificationService.DataContract StatusNotificationXmlSchema.xsd">
|
565
|
-
<AmountInCents>500</AmountInCents>
|
566
|
-
<AmountPaidInCents>0</AmountPaidInCents>
|
567
|
-
<BoletoTransaction>
|
568
|
-
<AmountInCents>500</AmountInCents>
|
569
|
-
<AmountPaidInCents>0</AmountPaidInCents>
|
570
|
-
<BoletoExpirationDate>2013-02-08T00:00:00</BoletoExpirationDate>
|
571
|
-
<NossoNumero>0123456789</NossoNumero>
|
572
|
-
<StatusChangedDate>2012-11-06T08:55:49.753</StatusChangedDate>
|
573
|
-
<TransactionKey>4111D523-9A83-4BE3-94D2-160F1BC9C4BD</TransactionKey>
|
574
|
-
<TransactionReference>B2E32108</TransactionReference>
|
575
|
-
<PreviousBoletoTransactionStatus>Generated</PreviousBoletoTransactionStatus>
|
576
|
-
<BoletoTransactionStatus>Paid</BoletoTransactionStatus>
|
577
|
-
</BoletoTransaction>
|
578
|
-
<CreditCardTransaction>
|
579
|
-
<Acquirer>Simulator</Acquirer>
|
580
|
-
<AmountInCents>2000</AmountInCents>
|
581
|
-
<AuthorizedAmountInCents>2000</AuthorizedAmountInCents>
|
582
|
-
<CapturedAmountInCents>2000</CapturedAmountInCents>
|
583
|
-
<CreditCardBrand>Visa</CreditCardBrand>
|
584
|
-
<RefundedAmountInCents i:nil="true"/>
|
585
|
-
<StatusChangedDate>2012-11-06T10:52:55.93</StatusChangedDate>
|
586
|
-
<TransactionIdentifier>123456</TransactionIdentifier>
|
587
|
-
<TransactionKey>351FC96A-7F42-4269-AF3C-1E3C179C1CD0</TransactionKey>
|
588
|
-
<TransactionReference>24de0432</TransactionReference>
|
589
|
-
<UniqueSequentialNumber>123456</UniqueSequentialNumber>
|
590
|
-
<VoidedAmountInCents i:nil="true"/>
|
591
|
-
<PreviousCreditCardTransactionStatus>AuthorizedPendingCapture</PreviousCreditCardTransactionStatus>
|
592
|
-
<CreditCardTransactionStatus>Captured</CreditCardTransactionStatus>
|
593
|
-
</CreditCardTransaction>
|
594
|
-
|
595
|
-
<OnlineDebitTransaction>
|
596
|
-
<AmountInCents>100</AmountInCents>
|
597
|
-
<AmountPaidInCents>0</AmountPaidInCents>
|
598
|
-
<StatusChangedDate>2013-06-27T19:46:46.87</StatusChangedDate>
|
599
|
-
<TransactionKey>fb3f158a-0309-4ae3-b8ef-3c5ac2d603d2</TransactionKey>
|
600
|
-
<TransactionReference>30bfee13-c908-4e3b-9f70-1f84dbe79fbf</TransactionReference>
|
601
|
-
<PreviousOnlineDebitTransactionStatus>OpenedPendingPayment</PreviousOnlineDebitTransactionStatus>
|
602
|
-
<OnlineDebitTransactionStatus>NotPaid</OnlineDebitTransactionStatus>
|
603
|
-
</OnlineDebitTransaction>
|
604
|
-
|
605
|
-
<MerchantKey>B1B1092C-8681-40C2-A734-500F22683D9B</MerchantKey>
|
606
|
-
<OrderKey>18471F05-9F6D-4497-9C24-D60D5BBB6BBE</OrderKey>
|
607
|
-
<OrderReference>64a85875</OrderReference>
|
608
|
-
<OrderStatus>Paid</OrderStatus>
|
609
|
-
</StatusNotification>'
|
610
|
-
|
611
|
-
response = gateway.ParseXmlToNotification(xml)
|
612
|
-
|
613
|
-
expect(response.nil?).to eq false
|
614
|
-
end
|
615
|
-
|
616
|
-
=begin
|
617
|
-
it 'should bring the transaction report file' do
|
618
|
-
date = Date.new(2015, 9, 19)
|
619
|
-
result = gateway.TransactionReportFile(date)
|
620
|
-
split_commas = result.split(',')
|
621
|
-
|
622
|
-
expect(split_commas[1]).to eq '20150919'
|
623
|
-
end
|
624
|
-
|
625
|
-
it 'should parse the transaction report file received' do
|
626
|
-
date = Date.new(2015, 9, 19)
|
627
|
-
request_to_parse = gateway.TransactionReportFile(date)
|
628
|
-
result = gateway.TransactionReportFileParser(request_to_parse)
|
629
|
-
|
630
|
-
expect(result['Header'].TransactionProcessedDate).to eq '20150919'
|
631
|
-
end
|
632
|
-
|
633
|
-
it 'should save the transaction report file at selected path' do
|
634
|
-
date = Date.new(2015, 9, 19)
|
635
|
-
|
636
|
-
file = Tempfile.new('Test')
|
637
|
-
gateway.TransactionReportFileDownloader(date, 'Test', file.path)
|
638
|
-
|
639
|
-
file_path = file.path.to_s + 'Test.txt'
|
640
|
-
file_exist = File.exist?(file_path)
|
641
|
-
|
642
|
-
file.close
|
643
|
-
file.unlink
|
644
|
-
|
645
|
-
expect(file_exist).to eq true
|
646
|
-
end
|
647
|
-
=end
|
648
|
-
|
649
|
-
it 'should get credit card instant buy key deprecated' do
|
650
|
-
credit_card_transaction = Gateway::CreditCardTransaction.new
|
651
|
-
credit_card_transaction.CreditCard.CreditCardNumber = '4111111111111111'
|
652
|
-
credit_card_transaction.CreditCard.CreditCardBrand = 'Visa'
|
653
|
-
credit_card_transaction.CreditCard.ExpMonth = 10
|
654
|
-
credit_card_transaction.CreditCard.ExpYear = 2018
|
655
|
-
credit_card_transaction.CreditCard.SecurityCode = '123'
|
656
|
-
credit_card_transaction.CreditCard.HolderName = 'Luke Skywalker'
|
657
|
-
credit_card_transaction.AmountInCents = 100
|
658
|
-
|
659
|
-
sale_request = Gateway::CreateSaleRequest.new
|
660
|
-
sale_request.CreditCardTransactionCollection << credit_card_transaction
|
661
|
-
|
662
|
-
sale_response = gateway.CreateSale(sale_request)
|
663
|
-
|
664
|
-
expect(sale_response['ErrorReport']).to eq nil
|
665
|
-
|
666
|
-
instant_buy_key = sale_response['CreditCardTransactionResultCollection'][0]['CreditCard']['InstantBuyKey']
|
667
|
-
|
668
|
-
response = gateway.InstantBuyKey(instant_buy_key)
|
669
|
-
|
670
|
-
expect(response['ErrorReport']).to eq nil
|
671
|
-
end
|
672
|
-
|
673
|
-
it 'should get credit card instant buy key' do
|
674
|
-
credit_card_transaction = Gateway::CreditCardTransaction.new
|
675
|
-
credit_card_transaction.CreditCard.CreditCardNumber = '4111111111111111'
|
676
|
-
credit_card_transaction.CreditCard.CreditCardBrand = 'Visa'
|
677
|
-
credit_card_transaction.CreditCard.ExpMonth = 10
|
678
|
-
credit_card_transaction.CreditCard.ExpYear = 2018
|
679
|
-
credit_card_transaction.CreditCard.SecurityCode = '123'
|
680
|
-
credit_card_transaction.CreditCard.HolderName = 'Luke Skywalker'
|
681
|
-
credit_card_transaction.AmountInCents = 100
|
682
|
-
|
683
|
-
sale_request = Gateway::CreateSaleRequest.new
|
684
|
-
sale_request.CreditCardTransactionCollection << credit_card_transaction
|
685
|
-
|
686
|
-
sale_response = gateway.CreateSale(sale_request)
|
687
|
-
|
688
|
-
expect(sale_response['ErrorReport']).to eq nil
|
689
|
-
|
690
|
-
instant_buy_key = sale_response['CreditCardTransactionResultCollection'][0]['CreditCard']['InstantBuyKey']
|
691
|
-
|
692
|
-
response = gateway.GetCreditCard(instant_buy_key)
|
693
|
-
|
694
|
-
expect(response['ErrorReport']).to eq nil
|
695
|
-
end
|
696
|
-
|
697
|
-
it 'should delete credit card instant buy key' do
|
698
|
-
credit_card_transaction = Gateway::CreditCardTransaction.new
|
699
|
-
credit_card_transaction.CreditCard.CreditCardNumber = '4111111111111111'
|
700
|
-
credit_card_transaction.CreditCard.CreditCardBrand = 'Visa'
|
701
|
-
credit_card_transaction.CreditCard.ExpMonth = 10
|
702
|
-
credit_card_transaction.CreditCard.ExpYear = 2018
|
703
|
-
credit_card_transaction.CreditCard.SecurityCode = '123'
|
704
|
-
credit_card_transaction.CreditCard.HolderName = 'Luke Skywalker'
|
705
|
-
credit_card_transaction.AmountInCents = 100
|
706
|
-
|
707
|
-
sale_request = Gateway::CreateSaleRequest.new
|
708
|
-
sale_request.CreditCardTransactionCollection << credit_card_transaction
|
709
|
-
|
710
|
-
sale_response = gateway.CreateSale(sale_request)
|
711
|
-
|
712
|
-
expect(sale_response['ErrorReport']).to eq nil
|
713
|
-
|
714
|
-
instant_buy_key = sale_response['CreditCardTransactionResultCollection'][0]['CreditCard']['InstantBuyKey']
|
715
|
-
|
716
|
-
response = gateway.DeleteCreditCard(instant_buy_key)
|
717
|
-
|
718
|
-
expect(response['Success']).to eq true
|
719
|
-
end
|
720
|
-
|
721
|
-
it 'should consult get credit card with buyer key deprecated' do
|
722
|
-
|
723
|
-
credit_card_transaction = Gateway::CreditCardTransaction.new
|
724
|
-
credit_card_transaction.CreditCard.CreditCardNumber = '4111111111111111'
|
725
|
-
credit_card_transaction.CreditCard.CreditCardBrand = 'Visa'
|
726
|
-
credit_card_transaction.CreditCard.ExpMonth = 10
|
727
|
-
credit_card_transaction.CreditCard.ExpYear = 2018
|
728
|
-
credit_card_transaction.CreditCard.SecurityCode = '123'
|
729
|
-
credit_card_transaction.CreditCard.HolderName = 'Luke Skywalker'
|
730
|
-
credit_card_transaction.AmountInCents = 100
|
731
|
-
|
732
|
-
sale_request = Gateway::CreateSaleRequest.new
|
733
|
-
sale_request.Buyer.Name = 'Anakin Skywalker'
|
734
|
-
sale_request.Buyer.Birthdate = Date.new(1994, 9, 26).strftime("%Y-%m-%dT%H:%M:%S")
|
735
|
-
sale_request.Buyer.DocumentNumber = '12345678901'
|
736
|
-
sale_request.Buyer.DocumentType = 'CPF'
|
737
|
-
sale_request.Buyer.PersonType = 'Person'
|
738
|
-
sale_request.Buyer.Gender = 'M'
|
739
|
-
sale_request.CreditCardTransactionCollection << credit_card_transaction
|
740
|
-
|
741
|
-
sale_response = gateway.CreateSale(sale_request)
|
742
|
-
|
743
|
-
expect(sale_response['ErrorReport']).to eq nil
|
744
|
-
|
745
|
-
response = gateway.BuyerKey(sale_response['BuyerKey'])
|
746
|
-
|
747
|
-
expect(response['ErrorReport']).to eq nil
|
748
|
-
end
|
749
|
-
|
750
|
-
it 'should consult get credit card with buyer key' do
|
751
|
-
|
752
|
-
credit_card_transaction = Gateway::CreditCardTransaction.new
|
753
|
-
credit_card_transaction.CreditCard.CreditCardNumber = '4111111111111111'
|
754
|
-
credit_card_transaction.CreditCard.CreditCardBrand = 'Visa'
|
755
|
-
credit_card_transaction.CreditCard.ExpMonth = 10
|
756
|
-
credit_card_transaction.CreditCard.ExpYear = 2018
|
757
|
-
credit_card_transaction.CreditCard.SecurityCode = '123'
|
758
|
-
credit_card_transaction.CreditCard.HolderName = 'Luke Skywalker'
|
759
|
-
credit_card_transaction.AmountInCents = 100
|
760
|
-
|
761
|
-
sale_request = Gateway::CreateSaleRequest.new
|
762
|
-
sale_request.Buyer.Name = 'Anakin Skywalker'
|
763
|
-
sale_request.Buyer.Birthdate = Date.new(1994, 9, 26).strftime("%Y-%m-%dT%H:%M:%S")
|
764
|
-
sale_request.Buyer.DocumentNumber = '12345678901'
|
765
|
-
sale_request.Buyer.DocumentType = 'CPF'
|
766
|
-
sale_request.Buyer.PersonType = 'Person'
|
767
|
-
sale_request.Buyer.Gender = 'M'
|
768
|
-
sale_request.CreditCardTransactionCollection << credit_card_transaction
|
769
|
-
|
770
|
-
sale_response = gateway.CreateSale(sale_request)
|
771
|
-
|
772
|
-
expect(sale_response['ErrorReport']).to eq nil
|
773
|
-
|
774
|
-
response = gateway.GetCreditCardWithBuyerKey(sale_response['BuyerKey'])
|
775
|
-
|
776
|
-
expect(response['ErrorReport']).to eq nil
|
777
|
-
end
|
778
|
-
|
779
|
-
it 'should create a credit card' do
|
780
|
-
create_instant_buy_data = Gateway::CreateInstantBuyDataRequest.new
|
781
|
-
create_instant_buy_data.CreditCardNumber = '4111111111111111'
|
782
|
-
create_instant_buy_data.ExpMonth = 10
|
783
|
-
create_instant_buy_data.ExpYear = 2018
|
784
|
-
create_instant_buy_data.SecurityCode = '123'
|
785
|
-
create_instant_buy_data.HolderName = 'Luke Skywalker'
|
786
|
-
create_instant_buy_data.CreditCardBrand = 'Visa'
|
787
|
-
create_instant_buy_data.IsOneDollarAuthEnabled = false
|
788
|
-
create_instant_buy_data.BillingAddress.City = 'Rio de Janeiro'
|
789
|
-
create_instant_buy_data.BillingAddress.Complement = 'Em frente ao Aeroporto'
|
790
|
-
create_instant_buy_data.BillingAddress.Country = 'Brazil'
|
791
|
-
create_instant_buy_data.BillingAddress.District = 'Centro'
|
792
|
-
create_instant_buy_data.BillingAddress.Number = '123'
|
793
|
-
create_instant_buy_data.BillingAddress.State = 'RJ'
|
794
|
-
create_instant_buy_data.BillingAddress.Street = 'Av. General Justo'
|
795
|
-
create_instant_buy_data.BillingAddress.ZipCode = '20270004'
|
796
|
-
|
797
|
-
response = gateway.CreateCreditCard(create_instant_buy_data)
|
798
|
-
|
799
|
-
expect(response['ErrorReport']).to eq nil
|
800
|
-
end
|
801
|
-
|
802
|
-
it 'should create credit card with buyerkey in it' do
|
803
|
-
address = Gateway::BuyerAddress.new
|
804
|
-
address.AddressType = 'Residential'
|
805
|
-
address.City = 'Tatooine'
|
806
|
-
address.Complement = ''
|
807
|
-
address.Country = 'Brazil'
|
808
|
-
address.District = 'Mos Eisley'
|
809
|
-
address.Number = '123'
|
810
|
-
address.State = 'RJ'
|
811
|
-
address.Street = 'Mos Eisley Cantina'
|
812
|
-
address.ZipCode = '20001000'
|
813
|
-
|
814
|
-
buyer_request = Gateway::CreateBuyerRequest.new
|
815
|
-
buyer_request.AddressCollection << address
|
816
|
-
buyer_request.Birthdate = DateTime.new(1990,8,20,0,0,0).strftime("%Y-%m-%dT%H:%M:%S")
|
817
|
-
buyer_request.BuyerCategory = 'Normal'
|
818
|
-
buyer_request.BuyerReference = 'C3PO'
|
819
|
-
buyer_request.CreateDateInMerchant = DateTime.new(2015,12,11,18,36,45).strftime("%Y-%m-%dT%H:%M:%S")
|
820
|
-
buyer_request.DocumentNumber = '12345678901'
|
821
|
-
buyer_request.DocumentType = 'CPF'
|
822
|
-
buyer_request.Email = 'lskywalker@r2d2.com'
|
823
|
-
buyer_request.EmailType = 'Personal'
|
824
|
-
buyer_request.FacebookId = 'lukeskywalker8917'
|
825
|
-
buyer_request.Gender = 'M'
|
826
|
-
buyer_request.HomePhone = '(21)123456789'
|
827
|
-
buyer_request.LastBuyerUpdateInMerchant = DateTime.now.strftime("%Y-%m-%dT%H:%M:%S")
|
828
|
-
buyer_request.MobilePhone = '(21)987654321'
|
829
|
-
buyer_request.Name = 'Luke Skywalker'
|
830
|
-
buyer_request.PersonType = 'Person'
|
831
|
-
buyer_request.TwitterId = '@lukeskywalker8917'
|
832
|
-
buyer_request.WorkPhone = '(21)28467902'
|
833
|
-
|
834
|
-
new_buyer_response = gateway.CreateBuyer(buyer_request)
|
835
|
-
buyer_key = new_buyer_response['BuyerKey']
|
836
|
-
|
837
|
-
create_instant_buy_data = Gateway::CreateInstantBuyDataRequest.new
|
838
|
-
create_instant_buy_data.CreditCardNumber = '4111111111111111'
|
839
|
-
create_instant_buy_data.ExpMonth = 10
|
840
|
-
create_instant_buy_data.ExpYear = 2018
|
841
|
-
create_instant_buy_data.SecurityCode = '123'
|
842
|
-
create_instant_buy_data.HolderName = 'Luke Skywalker'
|
843
|
-
create_instant_buy_data.CreditCardBrand = 'Visa'
|
844
|
-
create_instant_buy_data.IsOneDollarAuthEnabled = false
|
845
|
-
create_instant_buy_data.BuyerKey = buyer_key
|
846
|
-
create_instant_buy_data.BillingAddress.City = 'Rio de Janeiro'
|
847
|
-
create_instant_buy_data.BillingAddress.Complement = 'Em frente ao Aeroporto'
|
848
|
-
create_instant_buy_data.BillingAddress.Country = 'Brazil'
|
849
|
-
create_instant_buy_data.BillingAddress.District = 'Centro'
|
850
|
-
create_instant_buy_data.BillingAddress.Number = '123'
|
851
|
-
create_instant_buy_data.BillingAddress.State = 'RJ'
|
852
|
-
create_instant_buy_data.BillingAddress.Street = 'Av. General Justo'
|
853
|
-
create_instant_buy_data.BillingAddress.ZipCode = '20270004'
|
854
|
-
|
855
|
-
response = gateway.CreateCreditCard(create_instant_buy_data)
|
856
|
-
|
857
|
-
expect(response['Success']).to eq true
|
858
|
-
end
|
859
|
-
|
860
|
-
it 'should create a credit card without billing address' do
|
861
|
-
create_instant_buy_data = Gateway::CreateInstantBuyDataRequest.new
|
862
|
-
create_instant_buy_data.CreditCardNumber = '4111111111111111'
|
863
|
-
create_instant_buy_data.ExpMonth = 10
|
864
|
-
create_instant_buy_data.ExpYear = 2018
|
865
|
-
create_instant_buy_data.SecurityCode = '123'
|
866
|
-
create_instant_buy_data.HolderName = 'Luke Skywalker'
|
867
|
-
create_instant_buy_data.CreditCardBrand = 'Visa'
|
868
|
-
|
869
|
-
response = gateway.CreateCreditCard(create_instant_buy_data)
|
870
|
-
|
871
|
-
expect(response['ErrorReport']).to eq nil
|
872
|
-
end
|
873
|
-
|
874
|
-
it 'should update the credit card' do
|
875
|
-
create_instant_buy_data = Gateway::CreateInstantBuyDataRequest.new
|
876
|
-
create_instant_buy_data.CreditCardNumber = '4111111111111111'
|
877
|
-
create_instant_buy_data.ExpMonth = 10
|
878
|
-
create_instant_buy_data.ExpYear = 2018
|
879
|
-
create_instant_buy_data.SecurityCode = '123'
|
880
|
-
create_instant_buy_data.HolderName = 'Luke Skywalker'
|
881
|
-
create_instant_buy_data.CreditCardBrand = 'Visa'
|
882
|
-
create_instant_buy_data.IsOneDollarAuthEnabled = false
|
883
|
-
create_instant_buy_data.BillingAddress.City = 'Rio de Janeiro'
|
884
|
-
create_instant_buy_data.BillingAddress.Complement = 'Em frente ao Aeroporto'
|
885
|
-
create_instant_buy_data.BillingAddress.Country = 'Brazil'
|
886
|
-
create_instant_buy_data.BillingAddress.District = 'Centro'
|
887
|
-
create_instant_buy_data.BillingAddress.Number = '123'
|
888
|
-
create_instant_buy_data.BillingAddress.State = 'RJ'
|
889
|
-
create_instant_buy_data.BillingAddress.Street = 'Av. General Justo'
|
890
|
-
create_instant_buy_data.BillingAddress.ZipCode = '20270004'
|
891
|
-
|
892
|
-
create_credit_card = gateway.CreateCreditCard(create_instant_buy_data)
|
893
|
-
|
894
|
-
credit_card_transaction = Gateway::CreditCardTransaction.new
|
895
|
-
credit_card_transaction.CreditCard.CreditCardNumber = '4111111111111111'
|
896
|
-
credit_card_transaction.CreditCard.CreditCardBrand = 'Visa'
|
897
|
-
credit_card_transaction.CreditCard.ExpMonth = 10
|
898
|
-
credit_card_transaction.CreditCard.ExpYear = 2018
|
899
|
-
credit_card_transaction.CreditCard.SecurityCode = '123'
|
900
|
-
credit_card_transaction.CreditCard.HolderName = 'Luke Skywalker'
|
901
|
-
credit_card_transaction.AmountInCents = 100
|
902
|
-
|
903
|
-
sale_request = Gateway::CreateSaleRequest.new
|
904
|
-
sale_request.Buyer.Name = 'Anakin Skywalker'
|
905
|
-
sale_request.Buyer.Birthdate = Date.new(1994, 9, 26).strftime("%Y-%m-%dT%H:%M:%S")
|
906
|
-
sale_request.Buyer.DocumentNumber = '12345678901'
|
907
|
-
sale_request.Buyer.DocumentType = 'CPF'
|
908
|
-
sale_request.Buyer.PersonType = 'Person'
|
909
|
-
sale_request.Buyer.Gender = 'M'
|
910
|
-
sale_request.CreditCardTransactionCollection << credit_card_transaction
|
911
|
-
|
912
|
-
sale_response = gateway.CreateSale(sale_request)
|
913
|
-
|
914
|
-
instant_buy_key = create_credit_card['InstantBuyKey']
|
915
|
-
|
916
|
-
buyer_key = sale_response['BuyerKey']
|
917
|
-
|
918
|
-
update_instant_buy_data_request = Gateway::UpdateInstantBuyDataRequest.new
|
919
|
-
update_instant_buy_data_request.BuyerKey = buyer_key
|
920
|
-
|
921
|
-
response = gateway.UpdateCreditCard(instant_buy_key, update_instant_buy_data_request)
|
922
|
-
|
923
|
-
expect(response['Success']).to eq true
|
924
|
-
end
|
925
|
-
|
926
|
-
it 'should do a credit card transaction with instant buy key' do
|
927
|
-
credit_card_transaction = Gateway::CreditCardTransaction.new
|
928
|
-
credit_card_transaction.CreditCard.CreditCardNumber = '4111111111111111'
|
929
|
-
credit_card_transaction.CreditCard.CreditCardBrand = 'Visa'
|
930
|
-
credit_card_transaction.CreditCard.ExpMonth = 10
|
931
|
-
credit_card_transaction.CreditCard.ExpYear = 2018
|
932
|
-
credit_card_transaction.CreditCard.SecurityCode = '123'
|
933
|
-
credit_card_transaction.CreditCard.HolderName = 'Luke Skywalker'
|
934
|
-
credit_card_transaction.AmountInCents = 100
|
935
|
-
|
936
|
-
sale_request = Gateway::CreateSaleRequest.new
|
937
|
-
sale_request.CreditCardTransactionCollection << credit_card_transaction
|
938
|
-
|
939
|
-
sale_response = gateway.CreateSale(sale_request)
|
940
|
-
|
941
|
-
expect(sale_response['ErrorReport']).to eq nil
|
942
|
-
|
943
|
-
instant_buy_key = sale_response['CreditCardTransactionResultCollection'][0]['CreditCard']['InstantBuyKey']
|
944
|
-
|
945
|
-
# coleta dados do cartao
|
946
|
-
creditCardTransaction = Gateway::CreditCardTransaction.new
|
947
|
-
creditCardTransaction.AmountInCents = 100
|
948
|
-
creditCardTransaction.CreditCard.InstantBuyKey = instant_buy_key
|
949
|
-
|
950
|
-
# cria a transacao
|
951
|
-
createSaleRequest = Gateway::CreateSaleRequest.new
|
952
|
-
createSaleRequest.CreditCardTransactionCollection << creditCardTransaction
|
953
|
-
|
954
|
-
# faz a requisicao de criação de transacao, retorna um hash com a resposta
|
955
|
-
response = gateway.CreateSale(createSaleRequest)
|
956
|
-
|
957
|
-
expect(response['ErrorReport']).to eq nil
|
958
|
-
end
|
959
|
-
|
960
|
-
it 'should get the buyer with buyer key' do
|
961
|
-
credit_card_transaction = Gateway::CreditCardTransaction.new
|
962
|
-
credit_card_transaction.CreditCard.CreditCardNumber = '4111111111111111'
|
963
|
-
credit_card_transaction.CreditCard.CreditCardBrand = 'Visa'
|
964
|
-
credit_card_transaction.CreditCard.ExpMonth = 10
|
965
|
-
credit_card_transaction.CreditCard.ExpYear = 2018
|
966
|
-
credit_card_transaction.CreditCard.SecurityCode = '123'
|
967
|
-
credit_card_transaction.CreditCard.HolderName = 'Luke Skywalker'
|
968
|
-
credit_card_transaction.AmountInCents = 100
|
969
|
-
|
970
|
-
sale_request = Gateway::CreateSaleRequest.new
|
971
|
-
sale_request.Buyer.Name = 'Anakin Skywalker'
|
972
|
-
sale_request.Buyer.Birthdate = Date.new(1994, 9, 26).strftime("%Y-%m-%dT%H:%M:%S")
|
973
|
-
sale_request.Buyer.DocumentNumber = '12345678901'
|
974
|
-
sale_request.Buyer.DocumentType = 'CPF'
|
975
|
-
sale_request.Buyer.PersonType = 'Person'
|
976
|
-
sale_request.Buyer.Gender = 'M'
|
977
|
-
sale_request.CreditCardTransactionCollection << credit_card_transaction
|
978
|
-
|
979
|
-
sale_response = gateway.CreateSale(sale_request)
|
980
|
-
|
981
|
-
expect(sale_response['ErrorReport']).to eq nil
|
982
|
-
|
983
|
-
response = gateway.GetBuyer(sale_response['BuyerKey'])
|
984
|
-
|
985
|
-
expect(response['ErrorReport']).to eq nil
|
986
|
-
end
|
987
|
-
|
988
|
-
it 'should create buyer with buyer request' do
|
989
|
-
address = Gateway::BuyerAddress.new
|
990
|
-
address.AddressType = 'Residential'
|
991
|
-
address.City = 'Tatooine'
|
992
|
-
address.Complement = ''
|
993
|
-
address.Country = 'Brazil'
|
994
|
-
address.District = 'Mos Eisley'
|
995
|
-
address.Number = '123'
|
996
|
-
address.State = 'RJ'
|
997
|
-
address.Street = 'Mos Eisley Cantina'
|
998
|
-
address.ZipCode = '20001000'
|
999
|
-
|
1000
|
-
buyer_request = Gateway::CreateBuyerRequest.new
|
1001
|
-
buyer_request.AddressCollection << address
|
1002
|
-
buyer_request.Birthdate = DateTime.new(1990,8,20,0,0,0).strftime("%Y-%m-%dT%H:%M:%S")
|
1003
|
-
buyer_request.BuyerCategory = 'Normal'
|
1004
|
-
buyer_request.BuyerReference = 'C3PO'
|
1005
|
-
buyer_request.CreateDateInMerchant = DateTime.new(2015,12,11,18,36,45).strftime("%Y-%m-%dT%H:%M:%S")
|
1006
|
-
buyer_request.DocumentNumber = '12345678901'
|
1007
|
-
buyer_request.DocumentType = 'CPF'
|
1008
|
-
buyer_request.Email = 'lskywalker@r2d2.com'
|
1009
|
-
buyer_request.EmailType = 'Personal'
|
1010
|
-
buyer_request.FacebookId = 'lukeskywalker8917'
|
1011
|
-
buyer_request.Gender = 'M'
|
1012
|
-
buyer_request.HomePhone = '(21)123456789'
|
1013
|
-
buyer_request.LastBuyerUpdateInMerchant = DateTime.now.strftime("%Y-%m-%dT%H:%M:%S")
|
1014
|
-
buyer_request.MobilePhone = '(21)987654321'
|
1015
|
-
buyer_request.Name = 'Luke Skywalker'
|
1016
|
-
buyer_request.PersonType = 'Person'
|
1017
|
-
buyer_request.TwitterId = '@lukeskywalker8917'
|
1018
|
-
buyer_request.WorkPhone = '(21)28467902'
|
1019
|
-
|
1020
|
-
response = gateway.CreateBuyer(buyer_request)
|
1021
|
-
|
1022
|
-
expect(response['Success']).to eq true
|
1023
|
-
end
|
1024
|
-
end
|
1
|
+
require_relative '../../lib/stone_ecommerce'
|
2
|
+
require_relative 'test_helper'
|
3
|
+
|
4
|
+
merchant_key = '8A2DD57F-1ED9-4153-B4CE-69683EFADAD5'
|
5
|
+
|
6
|
+
gateway = Gateway::Gateway.new(:production, merchant_key)
|
7
|
+
|
8
|
+
RSpec.describe Gateway do
|
9
|
+
it 'should create a sale with boleto' do
|
10
|
+
createSaleRequest = Gateway::CreateSaleRequest.new
|
11
|
+
|
12
|
+
boletoTransaction = Gateway::BoletoTransaction.new
|
13
|
+
boletoTransaction.AmountInCents = 100
|
14
|
+
boletoTransaction.BankNumber = '237'
|
15
|
+
boletoTransaction.DocumentNumber = '12345678901'
|
16
|
+
boletoTransaction.Instructions = 'Pagar antes do vencimento'
|
17
|
+
boletoTransaction.TransactionReference = 'BoletoTest#Ruby01'
|
18
|
+
boletoTransaction.Options.CurrencyIso = 'BRL'
|
19
|
+
boletoTransaction.Options.DaysToAddInBoletoExpirationDate = 5
|
20
|
+
|
21
|
+
createSaleRequest.BoletoTransactionCollection << boletoTransaction
|
22
|
+
|
23
|
+
response = gateway.CreateSale(createSaleRequest)
|
24
|
+
|
25
|
+
expect(response[:ErrorReport]).to eq nil
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should create a sale with credit card' do
|
29
|
+
createSaleRequest = Gateway::CreateSaleRequest.new
|
30
|
+
|
31
|
+
buyerAddress = Gateway::BuyerAddress.new
|
32
|
+
buyerAddress.AddressType = 'Residential'
|
33
|
+
buyerAddress.City = 'Rio de Janeiro'
|
34
|
+
buyerAddress.Complement = '10 Andar'
|
35
|
+
buyerAddress.Country = 'Brazil'
|
36
|
+
buyerAddress.District = 'Centro'
|
37
|
+
buyerAddress.Number = '199'
|
38
|
+
buyerAddress.State = 'RJ'
|
39
|
+
buyerAddress.Street = 'Rua da Quitanda'
|
40
|
+
buyerAddress.ZipCode = '20091005'
|
41
|
+
|
42
|
+
creditCardTransaction = Gateway::CreditCardTransaction.new
|
43
|
+
creditCardTransaction.AmountInCents = 100
|
44
|
+
creditCardTransaction.InstallmentCount = 1
|
45
|
+
creditCardTransaction.TransactionReference = 'CreditCard One RubySDK Test'
|
46
|
+
creditCardTransaction.Options.PaymentMethodCode = 1
|
47
|
+
creditCardTransaction.Options.SoftDescriptorText = 'My Store Name'
|
48
|
+
creditCardTransaction.CreditCard.CreditCardNumber = '5453010000066167'
|
49
|
+
creditCardTransaction.CreditCard.ExpMonth = 5
|
50
|
+
creditCardTransaction.CreditCard.ExpYear = 18
|
51
|
+
creditCardTransaction.CreditCard.HolderName = 'Maria do Carmo'
|
52
|
+
creditCardTransaction.CreditCard.SecurityCode = '123'
|
53
|
+
creditCardTransaction.CreditCard.CreditCardBrand = 'Mastercard'
|
54
|
+
creditCardTransaction.CreditCard.BillingAddress.City = 'Rio de Janeiro'
|
55
|
+
creditCardTransaction.CreditCard.BillingAddress.Complement = '10 Andar'
|
56
|
+
creditCardTransaction.CreditCard.BillingAddress.Country = 'Brazil'
|
57
|
+
creditCardTransaction.CreditCard.BillingAddress.District = 'Centro'
|
58
|
+
creditCardTransaction.CreditCard.BillingAddress.Number = '199'
|
59
|
+
creditCardTransaction.CreditCard.BillingAddress.State = 'RJ'
|
60
|
+
creditCardTransaction.CreditCard.BillingAddress.Street = 'Rua da Quitanda'
|
61
|
+
creditCardTransaction.CreditCard.BillingAddress.ZipCode = '20091005'
|
62
|
+
|
63
|
+
createSaleRequest.CreditCardTransactionCollection << creditCardTransaction
|
64
|
+
createSaleRequest.Buyer.Birthdate = Date.new(2001, 9, 26).strftime("%Y-%m-%dT%H:%M:%S")
|
65
|
+
createSaleRequest.Buyer.BuyerCategory = 'Normal'
|
66
|
+
createSaleRequest.Buyer.Email = 'mundiBuyer@mundi.com.br'
|
67
|
+
createSaleRequest.Buyer.EmailType = 'Personal'
|
68
|
+
createSaleRequest.Buyer.Gender = 'M'
|
69
|
+
createSaleRequest.Buyer.HomePhone = '22222222'
|
70
|
+
createSaleRequest.Buyer.MobilePhone = '988888888'
|
71
|
+
createSaleRequest.Buyer.WorkPhone = '25555555'
|
72
|
+
createSaleRequest.Buyer.CreateDateInMerchant = (Date.parse(Time.now.to_s)).strftime("%Y-%m-%dT%H:%M:%S")
|
73
|
+
createSaleRequest.Buyer.LastBuyerUpdateInMerchant = (Date.parse(Time.now.to_s)).strftime("%Y-%m-%dT%H:%M:%S")
|
74
|
+
createSaleRequest.Buyer.DocumentNumber = '51212382749'
|
75
|
+
createSaleRequest.Buyer.DocumentType = 'CPF'
|
76
|
+
createSaleRequest.Buyer.Name = 'Jose da Silva Ramos'
|
77
|
+
createSaleRequest.Buyer.PersonType = 'Person'
|
78
|
+
createSaleRequest.Buyer.AddressCollection << buyerAddress
|
79
|
+
|
80
|
+
response = gateway.CreateSale(createSaleRequest)
|
81
|
+
|
82
|
+
expect(response[:ErrorReport]).to eq nil
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should create a sale with all types of transactions and all fields filled' do
|
87
|
+
# creates boleto transaction object
|
88
|
+
boletoTransaction = Gateway::BoletoTransaction.new
|
89
|
+
|
90
|
+
# 100 reais in cents
|
91
|
+
boletoTransaction.AmountInCents = 10000
|
92
|
+
boletoTransaction.BankNumber = '237'
|
93
|
+
boletoTransaction.BillingAddress.City = 'Tatooine'
|
94
|
+
boletoTransaction.BillingAddress.Complement = ''
|
95
|
+
boletoTransaction.BillingAddress.Country = 'Brazil'
|
96
|
+
boletoTransaction.BillingAddress.District = 'Mos Eisley'
|
97
|
+
boletoTransaction.BillingAddress.Number = '123'
|
98
|
+
boletoTransaction.BillingAddress.State = 'RJ'
|
99
|
+
boletoTransaction.BillingAddress.Street = 'Mos Eisley Cantina'
|
100
|
+
boletoTransaction.BillingAddress.ZipCode = '20001000'
|
101
|
+
boletoTransaction.DocumentNumber = '12345678901'
|
102
|
+
boletoTransaction.Instructions = 'Pagar antes do vencimento'
|
103
|
+
boletoTransaction.Options.CurrencyIso = 'BRL'
|
104
|
+
boletoTransaction.Options.DaysToAddInBoletoExpirationDate = 5
|
105
|
+
boletoTransaction.TransactionReference = 'NumeroDaTransacao'
|
106
|
+
|
107
|
+
|
108
|
+
# create credit card transaction object
|
109
|
+
creditCardTransaction = Gateway::CreditCardTransaction.new
|
110
|
+
|
111
|
+
# 100 reais in cents
|
112
|
+
creditCardTransaction.AmountInCents = 10000
|
113
|
+
creditCardTransaction.CreditCard.BillingAddress.City = 'Tatooine'
|
114
|
+
creditCardTransaction.CreditCard.BillingAddress.Complement = ''
|
115
|
+
creditCardTransaction.CreditCard.BillingAddress.Country = 'Brazil'
|
116
|
+
creditCardTransaction.CreditCard.BillingAddress.District = 'Mos Eisley'
|
117
|
+
creditCardTransaction.CreditCard.BillingAddress.Number = '123'
|
118
|
+
creditCardTransaction.CreditCard.BillingAddress.State = 'RJ'
|
119
|
+
creditCardTransaction.CreditCard.BillingAddress.Street = 'Mos Eisley Cantina'
|
120
|
+
creditCardTransaction.CreditCard.BillingAddress.ZipCode = '20001000'
|
121
|
+
creditCardTransaction.CreditCard.CreditCardBrand = 'Visa'
|
122
|
+
creditCardTransaction.CreditCard.CreditCardNumber = '4111111111111111'
|
123
|
+
creditCardTransaction.CreditCard.ExpMonth = 10
|
124
|
+
creditCardTransaction.CreditCard.ExpYear = 22
|
125
|
+
creditCardTransaction.CreditCard.HolderName = 'LUKE SKYWALKER'
|
126
|
+
creditCardTransaction.CreditCard.SecurityCode = '123'
|
127
|
+
creditCardTransaction.CreditCardOperation = 'AuthOnly'
|
128
|
+
creditCardTransaction.InstallmentCount = 1
|
129
|
+
creditCardTransaction.Options.CurrencyIso = 'BRL'
|
130
|
+
creditCardTransaction.Options.PaymentMethodCode = 1
|
131
|
+
creditCardTransaction.Options.SoftDescriptorText = 'Jedi Mega Store'
|
132
|
+
|
133
|
+
shoppingCartItem = Gateway::ShoppingCartItemCollection.new
|
134
|
+
shoppingCartItem.Description = 'Red Lightsaber'
|
135
|
+
shoppingCartItem.DiscountAmountInCents = 0
|
136
|
+
shoppingCartItem.ItemReference = 'NumeroDoProduto'
|
137
|
+
shoppingCartItem.Name = 'Lightsaber'
|
138
|
+
shoppingCartItem.Quantity = 1
|
139
|
+
shoppingCartItem.TotalCostInCents = 18000
|
140
|
+
shoppingCartItem.UnitCostInCents = 18000
|
141
|
+
|
142
|
+
shoppingCartCollection = Gateway::ShoppingCartCollection.new
|
143
|
+
shoppingCartCollection.DeliveryAddress.City = 'Galaxy far far away'
|
144
|
+
shoppingCartCollection.DeliveryAddress.Complement = 'Bridge'
|
145
|
+
shoppingCartCollection.DeliveryAddress.Country = 'Brazil'
|
146
|
+
shoppingCartCollection.DeliveryAddress.District = 'Command Room'
|
147
|
+
shoppingCartCollection.DeliveryAddress.Number = '321'
|
148
|
+
shoppingCartCollection.DeliveryAddress.State = 'RJ'
|
149
|
+
shoppingCartCollection.DeliveryAddress.Street = 'Death Star'
|
150
|
+
shoppingCartCollection.DeliveryAddress.ZipCode = '10002000'
|
151
|
+
shoppingCartCollection.DeliveryDeadline = DateTime.new(2015, 12, 14, 18, 36, 45).strftime("%Y-%m-%dT%H:%M:%S")
|
152
|
+
shoppingCartCollection.EstimatedDeliveryDate = DateTime.new(2015, 12, 14, 18, 36, 45).strftime("%Y-%m-%dT%H:%M:%S")
|
153
|
+
shoppingCartCollection.FreighCostInCents = 2000
|
154
|
+
shoppingCartCollection.ShippingCompany = 'Empire'
|
155
|
+
shoppingCartCollection.ShoppingCartItemCollection << shoppingCartItem
|
156
|
+
|
157
|
+
# creates request object for transaction creation
|
158
|
+
createSaleRequest = Gateway::CreateSaleRequest.new
|
159
|
+
|
160
|
+
# adds to the boleto transaction collection
|
161
|
+
createSaleRequest.BoletoTransactionCollection << boletoTransaction
|
162
|
+
|
163
|
+
buyerAddress = Gateway::BuyerAddress.new
|
164
|
+
buyerAddress.AddressType = 'Residential'
|
165
|
+
buyerAddress.City = 'Tatooine'
|
166
|
+
buyerAddress.Complement = ''
|
167
|
+
buyerAddress.Country = 'Brazil'
|
168
|
+
buyerAddress.District = 'Mos Eisley'
|
169
|
+
buyerAddress.Number = '123'
|
170
|
+
buyerAddress.State = 'RJ'
|
171
|
+
buyerAddress.Street = 'Mos Eisley Cantina'
|
172
|
+
buyerAddress.ZipCode = '20001000'
|
173
|
+
|
174
|
+
createSaleRequest.Buyer.AddressCollection << buyerAddress
|
175
|
+
createSaleRequest.Buyer.Birthdate = DateTime.new(1990,8,20,0,0,0).strftime("%Y-%m-%dT%H:%M:%S")
|
176
|
+
createSaleRequest.Buyer.BuyerCategory = 'Normal'
|
177
|
+
createSaleRequest.Buyer.BuyerReference = 'C3PO'
|
178
|
+
createSaleRequest.Buyer.CreateDateInMerchant = DateTime.new(2015,12,11,18,36,45).strftime("%Y-%m-%dT%H:%M:%S")
|
179
|
+
createSaleRequest.Buyer.DocumentNumber = '12345678901'
|
180
|
+
createSaleRequest.Buyer.DocumentType = 'CPF'
|
181
|
+
createSaleRequest.Buyer.Email = 'lskywalker@r2d2.com'
|
182
|
+
createSaleRequest.Buyer.EmailType = 'Personal'
|
183
|
+
createSaleRequest.Buyer.FacebookId = 'lukeskywalker8917'
|
184
|
+
createSaleRequest.Buyer.Gender = 'M'
|
185
|
+
createSaleRequest.Buyer.HomePhone = '(21)123456789'
|
186
|
+
createSaleRequest.Buyer.MobilePhone = '(21)987654321'
|
187
|
+
createSaleRequest.Buyer.Name = 'Luke Skywalker'
|
188
|
+
createSaleRequest.Buyer.PersonType = 'Person'
|
189
|
+
createSaleRequest.Buyer.TwitterId = '@lukeskywalker8917'
|
190
|
+
createSaleRequest.Buyer.WorkPhone = '(21)28467902'
|
191
|
+
|
192
|
+
# adds to the credit card transaction collection
|
193
|
+
createSaleRequest.CreditCardTransactionCollection << creditCardTransaction
|
194
|
+
createSaleRequest.Merchant.MerchantReference = 'IdDaLojaPlataforma'
|
195
|
+
createSaleRequest.Options.AntiFraudServiceCode = 0
|
196
|
+
createSaleRequest.Options.CurrencyIso = 'BRL'
|
197
|
+
createSaleRequest.Options.IsAntiFraudEnabled = true
|
198
|
+
createSaleRequest.Options.Retries = 1
|
199
|
+
createSaleRequest.Order.OrderReference = 'NumeroDoPedido'
|
200
|
+
createSaleRequest.RequestData.EcommerceCategory = 'B2C'
|
201
|
+
createSaleRequest.RequestData.IpAddress = '127.0.0.1'
|
202
|
+
createSaleRequest.RequestData.Origin = 'SiteDeCompra'
|
203
|
+
createSaleRequest.RequestData.SessionId = 'IdSesssaoNoSite'
|
204
|
+
|
205
|
+
# adds shopping cart collection in the request
|
206
|
+
createSaleRequest.ShoppingCartCollection << shoppingCartCollection
|
207
|
+
|
208
|
+
# make the request and returns a response hash
|
209
|
+
response = gateway.CreateSale(createSaleRequest)
|
210
|
+
|
211
|
+
expect(response[:ErrorReport]).to eq nil
|
212
|
+
end
|
213
|
+
|
214
|
+
it 'should create an anti fraud transaction' do
|
215
|
+
# create credit card transaction object
|
216
|
+
creditCardTransaction = Gateway::CreditCardTransaction.new
|
217
|
+
|
218
|
+
# 100 reais in cents
|
219
|
+
creditCardTransaction.AmountInCents = 10000
|
220
|
+
creditCardTransaction.CreditCard.BillingAddress.City = 'Tatooine'
|
221
|
+
creditCardTransaction.CreditCard.BillingAddress.Complement = ''
|
222
|
+
creditCardTransaction.CreditCard.BillingAddress.Country = 'Brazil'
|
223
|
+
creditCardTransaction.CreditCard.BillingAddress.District = 'Mos Eisley'
|
224
|
+
creditCardTransaction.CreditCard.BillingAddress.Number = '123'
|
225
|
+
creditCardTransaction.CreditCard.BillingAddress.State = 'RJ'
|
226
|
+
creditCardTransaction.CreditCard.BillingAddress.Street = 'Mos Eisley Cantina'
|
227
|
+
creditCardTransaction.CreditCard.BillingAddress.ZipCode = '20001000'
|
228
|
+
creditCardTransaction.CreditCard.CreditCardBrand = 'Visa'
|
229
|
+
creditCardTransaction.CreditCard.CreditCardNumber = '4111111111111111'
|
230
|
+
creditCardTransaction.CreditCard.ExpMonth = 10
|
231
|
+
creditCardTransaction.CreditCard.ExpYear = 22
|
232
|
+
creditCardTransaction.CreditCard.HolderName = 'LUKE SKYWALKER'
|
233
|
+
creditCardTransaction.CreditCard.SecurityCode = '123'
|
234
|
+
creditCardTransaction.InstallmentCount = 1
|
235
|
+
|
236
|
+
shoppingCartItem = Gateway::ShoppingCartItemCollection.new
|
237
|
+
shoppingCartItem.Description = 'Red Lightsaber'
|
238
|
+
shoppingCartItem.DiscountAmountInCents = 0
|
239
|
+
shoppingCartItem.ItemReference = 'NumeroDoProduto'
|
240
|
+
shoppingCartItem.Name = 'Lightsaber'
|
241
|
+
shoppingCartItem.Quantity = 1
|
242
|
+
shoppingCartItem.TotalCostInCents = 18000
|
243
|
+
shoppingCartItem.UnitCostInCents = 0
|
244
|
+
|
245
|
+
shoppingCartCollection = Gateway::ShoppingCartCollection.new
|
246
|
+
shoppingCartCollection.DeliveryAddress.City = 'Galaxy far far away'
|
247
|
+
shoppingCartCollection.DeliveryAddress.Complement = 'Bridge'
|
248
|
+
shoppingCartCollection.DeliveryAddress.Country = 'Brazil'
|
249
|
+
shoppingCartCollection.DeliveryAddress.District = 'Command Room'
|
250
|
+
shoppingCartCollection.DeliveryAddress.Number = '321'
|
251
|
+
shoppingCartCollection.DeliveryAddress.State = 'RJ'
|
252
|
+
shoppingCartCollection.DeliveryAddress.Street = 'Death Star'
|
253
|
+
shoppingCartCollection.DeliveryAddress.ZipCode = '10002000'
|
254
|
+
shoppingCartCollection.FreighCostInCents = 2000
|
255
|
+
shoppingCartCollection.ShoppingCartItemCollection << shoppingCartItem
|
256
|
+
|
257
|
+
# creates request object for transaction creation
|
258
|
+
createSaleRequest = Gateway::CreateSaleRequest.new
|
259
|
+
|
260
|
+
buyerAddress = Gateway::BuyerAddress.new
|
261
|
+
buyerAddress.AddressType = 'Residential'
|
262
|
+
buyerAddress.City = 'Tatooine'
|
263
|
+
buyerAddress.Complement = ''
|
264
|
+
buyerAddress.Country = 'Brazil'
|
265
|
+
buyerAddress.District = 'Mos Eisley'
|
266
|
+
buyerAddress.Number = '123'
|
267
|
+
buyerAddress.State = 'RJ'
|
268
|
+
buyerAddress.Street = 'Mos Eisley Cantina'
|
269
|
+
buyerAddress.ZipCode = '20001000'
|
270
|
+
|
271
|
+
createSaleRequest.Buyer.AddressCollection << buyerAddress
|
272
|
+
createSaleRequest.Buyer.Birthdate = DateTime.new(1990,8,20,0,0,0).strftime("%Y-%m-%dT%H:%M:%S")
|
273
|
+
createSaleRequest.Buyer.BuyerReference = 'C3PO'
|
274
|
+
createSaleRequest.Buyer.DocumentNumber = '12345678901'
|
275
|
+
createSaleRequest.Buyer.DocumentType = 'CPF'
|
276
|
+
createSaleRequest.Buyer.Email = 'lskywalker@r2d2.com'
|
277
|
+
createSaleRequest.Buyer.EmailType = 'Personal'
|
278
|
+
createSaleRequest.Buyer.Gender = 'M'
|
279
|
+
createSaleRequest.Buyer.HomePhone = '(21)123456789'
|
280
|
+
createSaleRequest.Buyer.MobilePhone = '(21)987654321'
|
281
|
+
createSaleRequest.Buyer.Name = 'Luke Skywalker'
|
282
|
+
createSaleRequest.Buyer.PersonType = 'Person'
|
283
|
+
createSaleRequest.Buyer.WorkPhone = '(21)28467902'
|
284
|
+
|
285
|
+
# adds to the credit card transaction collection
|
286
|
+
createSaleRequest.CreditCardTransactionCollection << creditCardTransaction
|
287
|
+
createSaleRequest.Options.IsAntiFraudEnabled = true
|
288
|
+
createSaleRequest.Order.OrderReference = 'NumeroDoPedido'
|
289
|
+
|
290
|
+
# adds shopping cart collection in the request
|
291
|
+
createSaleRequest.ShoppingCartCollection << shoppingCartCollection
|
292
|
+
|
293
|
+
# make the request and returns a response hash
|
294
|
+
response = gateway.CreateSale(createSaleRequest)
|
295
|
+
|
296
|
+
expect(response[:ErrorReport]).to eq nil
|
297
|
+
end
|
298
|
+
|
299
|
+
it 'should consult the order with order key' do
|
300
|
+
querySaleRequest = Gateway::QuerySaleRequest.new
|
301
|
+
createSaleRequest = Gateway::CreateSaleRequest.new
|
302
|
+
|
303
|
+
boletoTransaction = Gateway::BoletoTransaction.new
|
304
|
+
boletoTransaction.AmountInCents = 100
|
305
|
+
boletoTransaction.BankNumber = '237'
|
306
|
+
boletoTransaction.DocumentNumber = '12345678901'
|
307
|
+
boletoTransaction.Instructions = 'Pagar antes do vencimento'
|
308
|
+
boletoTransaction.TransactionReference = 'BoletoTest#Ruby01'
|
309
|
+
boletoTransaction.Options.CurrencyIso = 'BRL'
|
310
|
+
boletoTransaction.Options.DaysToAddInBoletoExpirationDate = 5
|
311
|
+
|
312
|
+
createSaleRequest.BoletoTransactionCollection << boletoTransaction
|
313
|
+
|
314
|
+
boleto_response = gateway.CreateSale(createSaleRequest)
|
315
|
+
|
316
|
+
querySaleRequest.OrderKey = boleto_response['OrderResult']['OrderKey']
|
317
|
+
responseQuery = gateway.Query(Gateway::QuerySaleRequest.QuerySaleRequestEnum[:OrderKey], querySaleRequest.OrderKey)
|
318
|
+
|
319
|
+
orderKey = responseQuery["SaleDataCollection"][0]["OrderData"]["OrderKey"]
|
320
|
+
|
321
|
+
expect(orderKey).to eq querySaleRequest.OrderKey
|
322
|
+
end
|
323
|
+
|
324
|
+
it 'should consult the order with order reference' do
|
325
|
+
querySaleRequest = Gateway::QuerySaleRequest.new
|
326
|
+
createSaleRequest = Gateway::CreateSaleRequest.new
|
327
|
+
|
328
|
+
boletoTransaction = Gateway::BoletoTransaction.new
|
329
|
+
boletoTransaction.AmountInCents = 100
|
330
|
+
boletoTransaction.BankNumber = '237'
|
331
|
+
boletoTransaction.DocumentNumber = '12345678901'
|
332
|
+
boletoTransaction.Instructions = 'Pagar antes do vencimento'
|
333
|
+
boletoTransaction.TransactionReference = 'BoletoTest#Ruby01'
|
334
|
+
boletoTransaction.Options.CurrencyIso = 'BRL'
|
335
|
+
boletoTransaction.Options.DaysToAddInBoletoExpirationDate = 5
|
336
|
+
|
337
|
+
createSaleRequest.Order.OrderReference = 'RubyOrderReferenceUnitTest'
|
338
|
+
createSaleRequest.BoletoTransactionCollection << boletoTransaction
|
339
|
+
|
340
|
+
boleto_response = gateway.CreateSale(createSaleRequest)
|
341
|
+
|
342
|
+
querySaleRequest.OrderReference = boleto_response['OrderResult']['OrderReference']
|
343
|
+
responseQuery = gateway.Query(Gateway::QuerySaleRequest.QuerySaleRequestEnum[:OrderReference], querySaleRequest.OrderReference)
|
344
|
+
|
345
|
+
orderReference = responseQuery["SaleDataCollection"][0]["OrderData"]["OrderReference"]
|
346
|
+
|
347
|
+
expect(orderReference).to eq querySaleRequest.OrderReference
|
348
|
+
end
|
349
|
+
|
350
|
+
it 'should do a retry method' do
|
351
|
+
retrySaleRequest = Gateway::RetrySaleRequest.new
|
352
|
+
retrySaleCreditCardTransactionItem = Gateway::RetrySaleCreditCardTransaction.new
|
353
|
+
|
354
|
+
createSaleRequest = Gateway::CreateSaleRequest.new
|
355
|
+
creditCardTransactionItem = Gateway::CreditCardTransaction.new
|
356
|
+
creditCardTransactionItem.AmountInCents = 100
|
357
|
+
creditCardTransactionItem.CreditCard.CreditCardBrand = 'Visa'
|
358
|
+
creditCardTransactionItem.CreditCard.CreditCardNumber = '41111111111111'
|
359
|
+
creditCardTransactionItem.CreditCard.ExpMonth = 10
|
360
|
+
creditCardTransactionItem.CreditCard.ExpYear = 19
|
361
|
+
creditCardTransactionItem.CreditCard.HolderName = 'Maria do Carmo'
|
362
|
+
creditCardTransactionItem.CreditCard.SecurityCode = '123'
|
363
|
+
creditCardTransactionItem.CreditCardOperation = 'AuthAndCapture'
|
364
|
+
creditCardTransactionItem.InstallmentCount = 1
|
365
|
+
creditCardTransactionItem.Options.CurrencyIso = 'BRL'
|
366
|
+
creditCardTransactionItem.Options.PaymentMethodCode = 1
|
367
|
+
creditCardTransactionItem.TransactionReference = 'RubySDK-RetryTest'
|
368
|
+
|
369
|
+
createSaleRequest.CreditCardTransactionCollection << creditCardTransactionItem
|
370
|
+
createSaleRequest.Order.OrderReference = 'RubySDK-RetryTest'
|
371
|
+
|
372
|
+
# cria o pedido que sera usado para retentativa
|
373
|
+
responseCreate = gateway.CreateSale(createSaleRequest)
|
374
|
+
|
375
|
+
# pega o orderkey e o transaction key da resposta que sao necessarios para fazer a retentativa
|
376
|
+
orderKey = responseCreate["OrderResult"]["OrderKey"]
|
377
|
+
transactionKey = responseCreate['CreditCardTransactionResultCollection'][0]['TransactionKey']
|
378
|
+
|
379
|
+
# monta o objeto de retentativa
|
380
|
+
retrySaleCreditCardTransactionItem.SecurityCode = '123'
|
381
|
+
retrySaleCreditCardTransactionItem.TransactionKey = transactionKey
|
382
|
+
retrySaleRequest.OrderKey = orderKey
|
383
|
+
retrySaleRequest.RetrySaleCreditCardTransactionCollection << retrySaleCreditCardTransactionItem
|
384
|
+
|
385
|
+
# faz a requisicao de retentativa
|
386
|
+
response = gateway.Retry(retrySaleRequest)
|
387
|
+
|
388
|
+
# espera que o transaction key seja igual, significa que foi tudo ok no teste
|
389
|
+
responseTransactionKey = response['CreditCardTransactionResultCollection'][0]['TransactionKey']
|
390
|
+
|
391
|
+
expect(responseTransactionKey).to eq transactionKey
|
392
|
+
|
393
|
+
end
|
394
|
+
|
395
|
+
it 'should do a retry method with only order key' do
|
396
|
+
createSaleRequest = Gateway::CreateSaleRequest.new
|
397
|
+
creditCardTransactionItem = Gateway::CreditCardTransaction.new
|
398
|
+
creditCardTransactionItem.AmountInCents = 100
|
399
|
+
creditCardTransactionItem.CreditCard.CreditCardBrand = 'Visa'
|
400
|
+
creditCardTransactionItem.CreditCard.CreditCardNumber = '41111111111111'
|
401
|
+
creditCardTransactionItem.CreditCard.ExpMonth = 10
|
402
|
+
creditCardTransactionItem.CreditCard.ExpYear = 22
|
403
|
+
creditCardTransactionItem.CreditCard.HolderName = 'Maria do Carmo'
|
404
|
+
creditCardTransactionItem.CreditCard.SecurityCode = '123'
|
405
|
+
creditCardTransactionItem.CreditCardOperation = 'AuthAndCapture'
|
406
|
+
creditCardTransactionItem.TransactionReference = 'RubySDK-RetryTest'
|
407
|
+
|
408
|
+
createSaleRequest.CreditCardTransactionCollection << creditCardTransactionItem
|
409
|
+
createSaleRequest.Order.OrderReference = 'RubySDK-RetryTest'
|
410
|
+
|
411
|
+
# cria o pedido que sera usado para retentativa
|
412
|
+
responseCreate = gateway.CreateSale(createSaleRequest)
|
413
|
+
|
414
|
+
# pega o orderkey e o transaction key da resposta que sao necessarios para fazer a retentativa
|
415
|
+
orderKey = responseCreate["OrderResult"]["OrderKey"]
|
416
|
+
transactionKey = responseCreate['CreditCardTransactionResultCollection'][0]['TransactionKey']
|
417
|
+
|
418
|
+
retrySaleRequest = Gateway::RetrySaleRequest.new
|
419
|
+
|
420
|
+
# monta o objeto de retentativa
|
421
|
+
retrySaleRequest.OrderKey = orderKey
|
422
|
+
|
423
|
+
# faz a requisicao de retentativa
|
424
|
+
response = gateway.Retry(retrySaleRequest)
|
425
|
+
|
426
|
+
expect(response['ErrorReport']).to eq nil
|
427
|
+
|
428
|
+
end
|
429
|
+
|
430
|
+
it 'should cancel a transaction' do
|
431
|
+
createSaleRequest = Gateway::CreateSaleRequest.new
|
432
|
+
creditCardTransactionItem = Gateway::CreditCardTransaction.new
|
433
|
+
creditCardTransactionItem.AmountInCents = 100
|
434
|
+
creditCardTransactionItem.CreditCard.CreditCardBrand = 'Visa'
|
435
|
+
creditCardTransactionItem.CreditCard.CreditCardNumber = '41111111111111'
|
436
|
+
creditCardTransactionItem.CreditCard.ExpMonth = 10
|
437
|
+
creditCardTransactionItem.CreditCard.ExpYear = 19
|
438
|
+
creditCardTransactionItem.CreditCard.HolderName = 'Maria do Carmo'
|
439
|
+
creditCardTransactionItem.CreditCard.SecurityCode = '123'
|
440
|
+
creditCardTransactionItem.CreditCardOperation = 'AuthAndCapture'
|
441
|
+
creditCardTransactionItem.InstallmentCount = 1
|
442
|
+
creditCardTransactionItem.Options.CurrencyIso = 'BRL'
|
443
|
+
creditCardTransactionItem.Options.PaymentMethodCode = 1
|
444
|
+
creditCardTransactionItem.TransactionReference = 'RubySDK-CancelTest'
|
445
|
+
|
446
|
+
createSaleRequest.CreditCardTransactionCollection << creditCardTransactionItem
|
447
|
+
createSaleRequest.Order.OrderReference = 'RubySDK-CancelTest'
|
448
|
+
|
449
|
+
# cria o pedido que sera usado para cancelamento
|
450
|
+
responseCreate = gateway.CreateSale(createSaleRequest)
|
451
|
+
|
452
|
+
# pega o orderkey e o transaction key da resposta que sao necessarios para fazer o cancelamento
|
453
|
+
orderKey = responseCreate["OrderResult"]["OrderKey"]
|
454
|
+
transactionKey = responseCreate['CreditCardTransactionResultCollection'][0]['TransactionKey']
|
455
|
+
|
456
|
+
# itens necessarios para cancelamento da transacao de cartao de credito
|
457
|
+
cancelCreditCardTransactionItem = Gateway::ManageCreditCardTransaction.new
|
458
|
+
cancelCreditCardTransactionItem.AmountInCents = 100
|
459
|
+
cancelCreditCardTransactionItem.TransactionKey = transactionKey
|
460
|
+
cancelCreditCardTransactionItem.TransactionReference = 'RubySDK-CancelTest'
|
461
|
+
|
462
|
+
# monta o objeto para cancelamento de transacao
|
463
|
+
cancelSaleRequest = Gateway::ManageSaleRequest.new
|
464
|
+
cancelSaleRequest.OrderKey = orderKey
|
465
|
+
cancelSaleRequest.CreditCardTransactionCollection << cancelCreditCardTransactionItem
|
466
|
+
|
467
|
+
response = gateway.Cancel(cancelSaleRequest)
|
468
|
+
|
469
|
+
expect(response[:ErrorReport]).to eq nil
|
470
|
+
end
|
471
|
+
|
472
|
+
it 'should capture a transaction' do
|
473
|
+
createSaleRequest = Gateway::CreateSaleRequest.new
|
474
|
+
creditCardTransactionItem = Gateway::CreditCardTransaction.new
|
475
|
+
creditCardTransactionItem.AmountInCents = 100
|
476
|
+
creditCardTransactionItem.CreditCard.CreditCardBrand = 'Visa'
|
477
|
+
creditCardTransactionItem.CreditCard.CreditCardNumber = '41111111111111'
|
478
|
+
creditCardTransactionItem.CreditCard.ExpMonth = 10
|
479
|
+
creditCardTransactionItem.CreditCard.ExpYear = 19
|
480
|
+
creditCardTransactionItem.CreditCard.HolderName = 'Maria do Carmo'
|
481
|
+
creditCardTransactionItem.CreditCard.SecurityCode = '123'
|
482
|
+
creditCardTransactionItem.CreditCardOperation = 'AuthAndCapture'
|
483
|
+
creditCardTransactionItem.InstallmentCount = 1
|
484
|
+
creditCardTransactionItem.Options.CurrencyIso = 'BRL'
|
485
|
+
creditCardTransactionItem.Options.PaymentMethodCode = 1
|
486
|
+
creditCardTransactionItem.TransactionReference = 'RubySDK-CaptureTest'
|
487
|
+
|
488
|
+
createSaleRequest.CreditCardTransactionCollection << creditCardTransactionItem
|
489
|
+
createSaleRequest.Order.OrderReference = 'RubySDK-CaptureTest'
|
490
|
+
|
491
|
+
# cria o pedido que sera usado para captura
|
492
|
+
responseCreate = gateway.CreateSale(createSaleRequest)
|
493
|
+
|
494
|
+
# pega o orderkey e o transaction key da resposta que sao necessarios para fazer a captura
|
495
|
+
orderKey = responseCreate["OrderResult"]["OrderKey"]
|
496
|
+
transactionKey = responseCreate['CreditCardTransactionResultCollection'][0]['TransactionKey']
|
497
|
+
|
498
|
+
# itens necessarios para captura da transacao de cartao de credito
|
499
|
+
captureCreditCardTransactionItem = Gateway::ManageCreditCardTransaction.new
|
500
|
+
captureCreditCardTransactionItem.AmountInCents = 100
|
501
|
+
captureCreditCardTransactionItem.TransactionKey = transactionKey
|
502
|
+
captureCreditCardTransactionItem.TransactionReference = 'RubySDK-CaptureTest'
|
503
|
+
|
504
|
+
# monta o objeto para cancelamento de transacao
|
505
|
+
captureSaleRequest = Gateway::ManageSaleRequest.new
|
506
|
+
captureSaleRequest.OrderKey = orderKey
|
507
|
+
captureSaleRequest.CreditCardTransactionCollection << captureCreditCardTransactionItem
|
508
|
+
|
509
|
+
response = gateway.Capture(captureSaleRequest)
|
510
|
+
|
511
|
+
# espera que o ErrorReport seja nulo, significa que foi tudo ok na transação
|
512
|
+
expect(response['ErrorReport']).to eq nil
|
513
|
+
end
|
514
|
+
|
515
|
+
it 'should do a parse xml to notification interpretation' do
|
516
|
+
creditCardTransactionItem = Gateway::CreditCardTransaction.new
|
517
|
+
creditCardTransactionItem.AmountInCents = 100
|
518
|
+
creditCardTransactionItem.TransactionReference = 'Ruby PostNotification Test'
|
519
|
+
creditCardTransactionItem.InstallmentCount = 1
|
520
|
+
creditCardTransactionItem.CreditCardOperation = 'AuthAndCapture'
|
521
|
+
creditCardTransactionItem.CreditCard.CreditCardBrand = 'Visa'
|
522
|
+
creditCardTransactionItem.CreditCard.CreditCardNumber = '4111111111111111'
|
523
|
+
creditCardTransactionItem.CreditCard.HolderName = 'Bruce Wayne'
|
524
|
+
creditCardTransactionItem.CreditCard.SecurityCode = '123'
|
525
|
+
creditCardTransactionItem.CreditCard.ExpMonth = 5
|
526
|
+
creditCardTransactionItem.CreditCard.ExpYear = 20
|
527
|
+
creditCardTransactionItem.Options.PaymentMethodCode = 1
|
528
|
+
|
529
|
+
createSaleRequest = Gateway::CreateSaleRequest.new
|
530
|
+
createSaleRequest.CreditCardTransactionCollection << creditCardTransactionItem
|
531
|
+
|
532
|
+
response_hash = gateway.CreateSale(createSaleRequest)
|
533
|
+
|
534
|
+
credit_card_result = response_hash['CreditCardTransactionResultCollection'][0]
|
535
|
+
|
536
|
+
expect(credit_card_result['Success']).to eq true
|
537
|
+
# expect(credit_card_result['CreditCardOperation']).to eq 'AuthOnly'
|
538
|
+
# expect(credit_card_result['CreditCardTransactionStatus']).to eq 'AuthorizedPendingCapture'
|
539
|
+
|
540
|
+
captureCreditCardTransactionItem = Gateway::ManageCreditCardTransaction.new
|
541
|
+
captureCreditCardTransactionItem.AmountInCents = creditCardTransactionItem.AmountInCents
|
542
|
+
captureCreditCardTransactionItem.TransactionKey = credit_card_result['TransactionKey']
|
543
|
+
captureCreditCardTransactionItem.TransactionReference = creditCardTransactionItem.TransactionReference
|
544
|
+
|
545
|
+
captureSale = Gateway::ManageSaleRequest.new
|
546
|
+
captureSale.OrderKey = response_hash['OrderResult']['OrderKey']
|
547
|
+
captureSale.CreditCardTransactionCollection << captureCreditCardTransactionItem
|
548
|
+
|
549
|
+
captureResponse = gateway.Capture(captureSale)
|
550
|
+
|
551
|
+
expect(captureResponse['ErrorReport']).to eq nil
|
552
|
+
|
553
|
+
|
554
|
+
xml = TestHelper.CreateFakePostNotification(response_hash, captureResponse)
|
555
|
+
|
556
|
+
response = gateway.ParseXmlToNotification(xml)
|
557
|
+
|
558
|
+
expect(response.nil?).to eq false
|
559
|
+
end
|
560
|
+
|
561
|
+
it 'should do a parse on online debit xml' do
|
562
|
+
xml = '<StatusNotification xmlns="http://schemas.datacontract.org/2004/07/Gateway.NotificationService.DataContract"
|
563
|
+
xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
|
564
|
+
i:schemaLocation="http://schemas.datacontract.org/2004/07/Gateway.NotificationService.DataContract StatusNotificationXmlSchema.xsd">
|
565
|
+
<AmountInCents>500</AmountInCents>
|
566
|
+
<AmountPaidInCents>0</AmountPaidInCents>
|
567
|
+
<BoletoTransaction>
|
568
|
+
<AmountInCents>500</AmountInCents>
|
569
|
+
<AmountPaidInCents>0</AmountPaidInCents>
|
570
|
+
<BoletoExpirationDate>2013-02-08T00:00:00</BoletoExpirationDate>
|
571
|
+
<NossoNumero>0123456789</NossoNumero>
|
572
|
+
<StatusChangedDate>2012-11-06T08:55:49.753</StatusChangedDate>
|
573
|
+
<TransactionKey>4111D523-9A83-4BE3-94D2-160F1BC9C4BD</TransactionKey>
|
574
|
+
<TransactionReference>B2E32108</TransactionReference>
|
575
|
+
<PreviousBoletoTransactionStatus>Generated</PreviousBoletoTransactionStatus>
|
576
|
+
<BoletoTransactionStatus>Paid</BoletoTransactionStatus>
|
577
|
+
</BoletoTransaction>
|
578
|
+
<CreditCardTransaction>
|
579
|
+
<Acquirer>Simulator</Acquirer>
|
580
|
+
<AmountInCents>2000</AmountInCents>
|
581
|
+
<AuthorizedAmountInCents>2000</AuthorizedAmountInCents>
|
582
|
+
<CapturedAmountInCents>2000</CapturedAmountInCents>
|
583
|
+
<CreditCardBrand>Visa</CreditCardBrand>
|
584
|
+
<RefundedAmountInCents i:nil="true"/>
|
585
|
+
<StatusChangedDate>2012-11-06T10:52:55.93</StatusChangedDate>
|
586
|
+
<TransactionIdentifier>123456</TransactionIdentifier>
|
587
|
+
<TransactionKey>351FC96A-7F42-4269-AF3C-1E3C179C1CD0</TransactionKey>
|
588
|
+
<TransactionReference>24de0432</TransactionReference>
|
589
|
+
<UniqueSequentialNumber>123456</UniqueSequentialNumber>
|
590
|
+
<VoidedAmountInCents i:nil="true"/>
|
591
|
+
<PreviousCreditCardTransactionStatus>AuthorizedPendingCapture</PreviousCreditCardTransactionStatus>
|
592
|
+
<CreditCardTransactionStatus>Captured</CreditCardTransactionStatus>
|
593
|
+
</CreditCardTransaction>
|
594
|
+
|
595
|
+
<OnlineDebitTransaction>
|
596
|
+
<AmountInCents>100</AmountInCents>
|
597
|
+
<AmountPaidInCents>0</AmountPaidInCents>
|
598
|
+
<StatusChangedDate>2013-06-27T19:46:46.87</StatusChangedDate>
|
599
|
+
<TransactionKey>fb3f158a-0309-4ae3-b8ef-3c5ac2d603d2</TransactionKey>
|
600
|
+
<TransactionReference>30bfee13-c908-4e3b-9f70-1f84dbe79fbf</TransactionReference>
|
601
|
+
<PreviousOnlineDebitTransactionStatus>OpenedPendingPayment</PreviousOnlineDebitTransactionStatus>
|
602
|
+
<OnlineDebitTransactionStatus>NotPaid</OnlineDebitTransactionStatus>
|
603
|
+
</OnlineDebitTransaction>
|
604
|
+
|
605
|
+
<MerchantKey>B1B1092C-8681-40C2-A734-500F22683D9B</MerchantKey>
|
606
|
+
<OrderKey>18471F05-9F6D-4497-9C24-D60D5BBB6BBE</OrderKey>
|
607
|
+
<OrderReference>64a85875</OrderReference>
|
608
|
+
<OrderStatus>Paid</OrderStatus>
|
609
|
+
</StatusNotification>'
|
610
|
+
|
611
|
+
response = gateway.ParseXmlToNotification(xml)
|
612
|
+
|
613
|
+
expect(response.nil?).to eq false
|
614
|
+
end
|
615
|
+
|
616
|
+
=begin
|
617
|
+
it 'should bring the transaction report file' do
|
618
|
+
date = Date.new(2015, 9, 19)
|
619
|
+
result = gateway.TransactionReportFile(date)
|
620
|
+
split_commas = result.split(',')
|
621
|
+
|
622
|
+
expect(split_commas[1]).to eq '20150919'
|
623
|
+
end
|
624
|
+
|
625
|
+
it 'should parse the transaction report file received' do
|
626
|
+
date = Date.new(2015, 9, 19)
|
627
|
+
request_to_parse = gateway.TransactionReportFile(date)
|
628
|
+
result = gateway.TransactionReportFileParser(request_to_parse)
|
629
|
+
|
630
|
+
expect(result['Header'].TransactionProcessedDate).to eq '20150919'
|
631
|
+
end
|
632
|
+
|
633
|
+
it 'should save the transaction report file at selected path' do
|
634
|
+
date = Date.new(2015, 9, 19)
|
635
|
+
|
636
|
+
file = Tempfile.new('Test')
|
637
|
+
gateway.TransactionReportFileDownloader(date, 'Test', file.path)
|
638
|
+
|
639
|
+
file_path = file.path.to_s + 'Test.txt'
|
640
|
+
file_exist = File.exist?(file_path)
|
641
|
+
|
642
|
+
file.close
|
643
|
+
file.unlink
|
644
|
+
|
645
|
+
expect(file_exist).to eq true
|
646
|
+
end
|
647
|
+
=end
|
648
|
+
|
649
|
+
it 'should get credit card instant buy key deprecated' do
|
650
|
+
credit_card_transaction = Gateway::CreditCardTransaction.new
|
651
|
+
credit_card_transaction.CreditCard.CreditCardNumber = '4111111111111111'
|
652
|
+
credit_card_transaction.CreditCard.CreditCardBrand = 'Visa'
|
653
|
+
credit_card_transaction.CreditCard.ExpMonth = 10
|
654
|
+
credit_card_transaction.CreditCard.ExpYear = 2018
|
655
|
+
credit_card_transaction.CreditCard.SecurityCode = '123'
|
656
|
+
credit_card_transaction.CreditCard.HolderName = 'Luke Skywalker'
|
657
|
+
credit_card_transaction.AmountInCents = 100
|
658
|
+
|
659
|
+
sale_request = Gateway::CreateSaleRequest.new
|
660
|
+
sale_request.CreditCardTransactionCollection << credit_card_transaction
|
661
|
+
|
662
|
+
sale_response = gateway.CreateSale(sale_request)
|
663
|
+
|
664
|
+
expect(sale_response['ErrorReport']).to eq nil
|
665
|
+
|
666
|
+
instant_buy_key = sale_response['CreditCardTransactionResultCollection'][0]['CreditCard']['InstantBuyKey']
|
667
|
+
|
668
|
+
response = gateway.InstantBuyKey(instant_buy_key)
|
669
|
+
|
670
|
+
expect(response['ErrorReport']).to eq nil
|
671
|
+
end
|
672
|
+
|
673
|
+
it 'should get credit card instant buy key' do
|
674
|
+
credit_card_transaction = Gateway::CreditCardTransaction.new
|
675
|
+
credit_card_transaction.CreditCard.CreditCardNumber = '4111111111111111'
|
676
|
+
credit_card_transaction.CreditCard.CreditCardBrand = 'Visa'
|
677
|
+
credit_card_transaction.CreditCard.ExpMonth = 10
|
678
|
+
credit_card_transaction.CreditCard.ExpYear = 2018
|
679
|
+
credit_card_transaction.CreditCard.SecurityCode = '123'
|
680
|
+
credit_card_transaction.CreditCard.HolderName = 'Luke Skywalker'
|
681
|
+
credit_card_transaction.AmountInCents = 100
|
682
|
+
|
683
|
+
sale_request = Gateway::CreateSaleRequest.new
|
684
|
+
sale_request.CreditCardTransactionCollection << credit_card_transaction
|
685
|
+
|
686
|
+
sale_response = gateway.CreateSale(sale_request)
|
687
|
+
|
688
|
+
expect(sale_response['ErrorReport']).to eq nil
|
689
|
+
|
690
|
+
instant_buy_key = sale_response['CreditCardTransactionResultCollection'][0]['CreditCard']['InstantBuyKey']
|
691
|
+
|
692
|
+
response = gateway.GetCreditCard(instant_buy_key)
|
693
|
+
|
694
|
+
expect(response['ErrorReport']).to eq nil
|
695
|
+
end
|
696
|
+
|
697
|
+
it 'should delete credit card instant buy key' do
|
698
|
+
credit_card_transaction = Gateway::CreditCardTransaction.new
|
699
|
+
credit_card_transaction.CreditCard.CreditCardNumber = '4111111111111111'
|
700
|
+
credit_card_transaction.CreditCard.CreditCardBrand = 'Visa'
|
701
|
+
credit_card_transaction.CreditCard.ExpMonth = 10
|
702
|
+
credit_card_transaction.CreditCard.ExpYear = 2018
|
703
|
+
credit_card_transaction.CreditCard.SecurityCode = '123'
|
704
|
+
credit_card_transaction.CreditCard.HolderName = 'Luke Skywalker'
|
705
|
+
credit_card_transaction.AmountInCents = 100
|
706
|
+
|
707
|
+
sale_request = Gateway::CreateSaleRequest.new
|
708
|
+
sale_request.CreditCardTransactionCollection << credit_card_transaction
|
709
|
+
|
710
|
+
sale_response = gateway.CreateSale(sale_request)
|
711
|
+
|
712
|
+
expect(sale_response['ErrorReport']).to eq nil
|
713
|
+
|
714
|
+
instant_buy_key = sale_response['CreditCardTransactionResultCollection'][0]['CreditCard']['InstantBuyKey']
|
715
|
+
|
716
|
+
response = gateway.DeleteCreditCard(instant_buy_key)
|
717
|
+
|
718
|
+
expect(response['Success']).to eq true
|
719
|
+
end
|
720
|
+
|
721
|
+
it 'should consult get credit card with buyer key deprecated' do
|
722
|
+
|
723
|
+
credit_card_transaction = Gateway::CreditCardTransaction.new
|
724
|
+
credit_card_transaction.CreditCard.CreditCardNumber = '4111111111111111'
|
725
|
+
credit_card_transaction.CreditCard.CreditCardBrand = 'Visa'
|
726
|
+
credit_card_transaction.CreditCard.ExpMonth = 10
|
727
|
+
credit_card_transaction.CreditCard.ExpYear = 2018
|
728
|
+
credit_card_transaction.CreditCard.SecurityCode = '123'
|
729
|
+
credit_card_transaction.CreditCard.HolderName = 'Luke Skywalker'
|
730
|
+
credit_card_transaction.AmountInCents = 100
|
731
|
+
|
732
|
+
sale_request = Gateway::CreateSaleRequest.new
|
733
|
+
sale_request.Buyer.Name = 'Anakin Skywalker'
|
734
|
+
sale_request.Buyer.Birthdate = Date.new(1994, 9, 26).strftime("%Y-%m-%dT%H:%M:%S")
|
735
|
+
sale_request.Buyer.DocumentNumber = '12345678901'
|
736
|
+
sale_request.Buyer.DocumentType = 'CPF'
|
737
|
+
sale_request.Buyer.PersonType = 'Person'
|
738
|
+
sale_request.Buyer.Gender = 'M'
|
739
|
+
sale_request.CreditCardTransactionCollection << credit_card_transaction
|
740
|
+
|
741
|
+
sale_response = gateway.CreateSale(sale_request)
|
742
|
+
|
743
|
+
expect(sale_response['ErrorReport']).to eq nil
|
744
|
+
|
745
|
+
response = gateway.BuyerKey(sale_response['BuyerKey'])
|
746
|
+
|
747
|
+
expect(response['ErrorReport']).to eq nil
|
748
|
+
end
|
749
|
+
|
750
|
+
it 'should consult get credit card with buyer key' do
|
751
|
+
|
752
|
+
credit_card_transaction = Gateway::CreditCardTransaction.new
|
753
|
+
credit_card_transaction.CreditCard.CreditCardNumber = '4111111111111111'
|
754
|
+
credit_card_transaction.CreditCard.CreditCardBrand = 'Visa'
|
755
|
+
credit_card_transaction.CreditCard.ExpMonth = 10
|
756
|
+
credit_card_transaction.CreditCard.ExpYear = 2018
|
757
|
+
credit_card_transaction.CreditCard.SecurityCode = '123'
|
758
|
+
credit_card_transaction.CreditCard.HolderName = 'Luke Skywalker'
|
759
|
+
credit_card_transaction.AmountInCents = 100
|
760
|
+
|
761
|
+
sale_request = Gateway::CreateSaleRequest.new
|
762
|
+
sale_request.Buyer.Name = 'Anakin Skywalker'
|
763
|
+
sale_request.Buyer.Birthdate = Date.new(1994, 9, 26).strftime("%Y-%m-%dT%H:%M:%S")
|
764
|
+
sale_request.Buyer.DocumentNumber = '12345678901'
|
765
|
+
sale_request.Buyer.DocumentType = 'CPF'
|
766
|
+
sale_request.Buyer.PersonType = 'Person'
|
767
|
+
sale_request.Buyer.Gender = 'M'
|
768
|
+
sale_request.CreditCardTransactionCollection << credit_card_transaction
|
769
|
+
|
770
|
+
sale_response = gateway.CreateSale(sale_request)
|
771
|
+
|
772
|
+
expect(sale_response['ErrorReport']).to eq nil
|
773
|
+
|
774
|
+
response = gateway.GetCreditCardWithBuyerKey(sale_response['BuyerKey'])
|
775
|
+
|
776
|
+
expect(response['ErrorReport']).to eq nil
|
777
|
+
end
|
778
|
+
|
779
|
+
it 'should create a credit card' do
|
780
|
+
create_instant_buy_data = Gateway::CreateInstantBuyDataRequest.new
|
781
|
+
create_instant_buy_data.CreditCardNumber = '4111111111111111'
|
782
|
+
create_instant_buy_data.ExpMonth = 10
|
783
|
+
create_instant_buy_data.ExpYear = 2018
|
784
|
+
create_instant_buy_data.SecurityCode = '123'
|
785
|
+
create_instant_buy_data.HolderName = 'Luke Skywalker'
|
786
|
+
create_instant_buy_data.CreditCardBrand = 'Visa'
|
787
|
+
create_instant_buy_data.IsOneDollarAuthEnabled = false
|
788
|
+
create_instant_buy_data.BillingAddress.City = 'Rio de Janeiro'
|
789
|
+
create_instant_buy_data.BillingAddress.Complement = 'Em frente ao Aeroporto'
|
790
|
+
create_instant_buy_data.BillingAddress.Country = 'Brazil'
|
791
|
+
create_instant_buy_data.BillingAddress.District = 'Centro'
|
792
|
+
create_instant_buy_data.BillingAddress.Number = '123'
|
793
|
+
create_instant_buy_data.BillingAddress.State = 'RJ'
|
794
|
+
create_instant_buy_data.BillingAddress.Street = 'Av. General Justo'
|
795
|
+
create_instant_buy_data.BillingAddress.ZipCode = '20270004'
|
796
|
+
|
797
|
+
response = gateway.CreateCreditCard(create_instant_buy_data)
|
798
|
+
|
799
|
+
expect(response['ErrorReport']).to eq nil
|
800
|
+
end
|
801
|
+
|
802
|
+
it 'should create credit card with buyerkey in it' do
|
803
|
+
address = Gateway::BuyerAddress.new
|
804
|
+
address.AddressType = 'Residential'
|
805
|
+
address.City = 'Tatooine'
|
806
|
+
address.Complement = ''
|
807
|
+
address.Country = 'Brazil'
|
808
|
+
address.District = 'Mos Eisley'
|
809
|
+
address.Number = '123'
|
810
|
+
address.State = 'RJ'
|
811
|
+
address.Street = 'Mos Eisley Cantina'
|
812
|
+
address.ZipCode = '20001000'
|
813
|
+
|
814
|
+
buyer_request = Gateway::CreateBuyerRequest.new
|
815
|
+
buyer_request.AddressCollection << address
|
816
|
+
buyer_request.Birthdate = DateTime.new(1990,8,20,0,0,0).strftime("%Y-%m-%dT%H:%M:%S")
|
817
|
+
buyer_request.BuyerCategory = 'Normal'
|
818
|
+
buyer_request.BuyerReference = 'C3PO'
|
819
|
+
buyer_request.CreateDateInMerchant = DateTime.new(2015,12,11,18,36,45).strftime("%Y-%m-%dT%H:%M:%S")
|
820
|
+
buyer_request.DocumentNumber = '12345678901'
|
821
|
+
buyer_request.DocumentType = 'CPF'
|
822
|
+
buyer_request.Email = 'lskywalker@r2d2.com'
|
823
|
+
buyer_request.EmailType = 'Personal'
|
824
|
+
buyer_request.FacebookId = 'lukeskywalker8917'
|
825
|
+
buyer_request.Gender = 'M'
|
826
|
+
buyer_request.HomePhone = '(21)123456789'
|
827
|
+
buyer_request.LastBuyerUpdateInMerchant = DateTime.now.strftime("%Y-%m-%dT%H:%M:%S")
|
828
|
+
buyer_request.MobilePhone = '(21)987654321'
|
829
|
+
buyer_request.Name = 'Luke Skywalker'
|
830
|
+
buyer_request.PersonType = 'Person'
|
831
|
+
buyer_request.TwitterId = '@lukeskywalker8917'
|
832
|
+
buyer_request.WorkPhone = '(21)28467902'
|
833
|
+
|
834
|
+
new_buyer_response = gateway.CreateBuyer(buyer_request)
|
835
|
+
buyer_key = new_buyer_response['BuyerKey']
|
836
|
+
|
837
|
+
create_instant_buy_data = Gateway::CreateInstantBuyDataRequest.new
|
838
|
+
create_instant_buy_data.CreditCardNumber = '4111111111111111'
|
839
|
+
create_instant_buy_data.ExpMonth = 10
|
840
|
+
create_instant_buy_data.ExpYear = 2018
|
841
|
+
create_instant_buy_data.SecurityCode = '123'
|
842
|
+
create_instant_buy_data.HolderName = 'Luke Skywalker'
|
843
|
+
create_instant_buy_data.CreditCardBrand = 'Visa'
|
844
|
+
create_instant_buy_data.IsOneDollarAuthEnabled = false
|
845
|
+
create_instant_buy_data.BuyerKey = buyer_key
|
846
|
+
create_instant_buy_data.BillingAddress.City = 'Rio de Janeiro'
|
847
|
+
create_instant_buy_data.BillingAddress.Complement = 'Em frente ao Aeroporto'
|
848
|
+
create_instant_buy_data.BillingAddress.Country = 'Brazil'
|
849
|
+
create_instant_buy_data.BillingAddress.District = 'Centro'
|
850
|
+
create_instant_buy_data.BillingAddress.Number = '123'
|
851
|
+
create_instant_buy_data.BillingAddress.State = 'RJ'
|
852
|
+
create_instant_buy_data.BillingAddress.Street = 'Av. General Justo'
|
853
|
+
create_instant_buy_data.BillingAddress.ZipCode = '20270004'
|
854
|
+
|
855
|
+
response = gateway.CreateCreditCard(create_instant_buy_data)
|
856
|
+
|
857
|
+
expect(response['Success']).to eq true
|
858
|
+
end
|
859
|
+
|
860
|
+
it 'should create a credit card without billing address' do
|
861
|
+
create_instant_buy_data = Gateway::CreateInstantBuyDataRequest.new
|
862
|
+
create_instant_buy_data.CreditCardNumber = '4111111111111111'
|
863
|
+
create_instant_buy_data.ExpMonth = 10
|
864
|
+
create_instant_buy_data.ExpYear = 2018
|
865
|
+
create_instant_buy_data.SecurityCode = '123'
|
866
|
+
create_instant_buy_data.HolderName = 'Luke Skywalker'
|
867
|
+
create_instant_buy_data.CreditCardBrand = 'Visa'
|
868
|
+
|
869
|
+
response = gateway.CreateCreditCard(create_instant_buy_data)
|
870
|
+
|
871
|
+
expect(response['ErrorReport']).to eq nil
|
872
|
+
end
|
873
|
+
|
874
|
+
it 'should update the credit card' do
|
875
|
+
create_instant_buy_data = Gateway::CreateInstantBuyDataRequest.new
|
876
|
+
create_instant_buy_data.CreditCardNumber = '4111111111111111'
|
877
|
+
create_instant_buy_data.ExpMonth = 10
|
878
|
+
create_instant_buy_data.ExpYear = 2018
|
879
|
+
create_instant_buy_data.SecurityCode = '123'
|
880
|
+
create_instant_buy_data.HolderName = 'Luke Skywalker'
|
881
|
+
create_instant_buy_data.CreditCardBrand = 'Visa'
|
882
|
+
create_instant_buy_data.IsOneDollarAuthEnabled = false
|
883
|
+
create_instant_buy_data.BillingAddress.City = 'Rio de Janeiro'
|
884
|
+
create_instant_buy_data.BillingAddress.Complement = 'Em frente ao Aeroporto'
|
885
|
+
create_instant_buy_data.BillingAddress.Country = 'Brazil'
|
886
|
+
create_instant_buy_data.BillingAddress.District = 'Centro'
|
887
|
+
create_instant_buy_data.BillingAddress.Number = '123'
|
888
|
+
create_instant_buy_data.BillingAddress.State = 'RJ'
|
889
|
+
create_instant_buy_data.BillingAddress.Street = 'Av. General Justo'
|
890
|
+
create_instant_buy_data.BillingAddress.ZipCode = '20270004'
|
891
|
+
|
892
|
+
create_credit_card = gateway.CreateCreditCard(create_instant_buy_data)
|
893
|
+
|
894
|
+
credit_card_transaction = Gateway::CreditCardTransaction.new
|
895
|
+
credit_card_transaction.CreditCard.CreditCardNumber = '4111111111111111'
|
896
|
+
credit_card_transaction.CreditCard.CreditCardBrand = 'Visa'
|
897
|
+
credit_card_transaction.CreditCard.ExpMonth = 10
|
898
|
+
credit_card_transaction.CreditCard.ExpYear = 2018
|
899
|
+
credit_card_transaction.CreditCard.SecurityCode = '123'
|
900
|
+
credit_card_transaction.CreditCard.HolderName = 'Luke Skywalker'
|
901
|
+
credit_card_transaction.AmountInCents = 100
|
902
|
+
|
903
|
+
sale_request = Gateway::CreateSaleRequest.new
|
904
|
+
sale_request.Buyer.Name = 'Anakin Skywalker'
|
905
|
+
sale_request.Buyer.Birthdate = Date.new(1994, 9, 26).strftime("%Y-%m-%dT%H:%M:%S")
|
906
|
+
sale_request.Buyer.DocumentNumber = '12345678901'
|
907
|
+
sale_request.Buyer.DocumentType = 'CPF'
|
908
|
+
sale_request.Buyer.PersonType = 'Person'
|
909
|
+
sale_request.Buyer.Gender = 'M'
|
910
|
+
sale_request.CreditCardTransactionCollection << credit_card_transaction
|
911
|
+
|
912
|
+
sale_response = gateway.CreateSale(sale_request)
|
913
|
+
|
914
|
+
instant_buy_key = create_credit_card['InstantBuyKey']
|
915
|
+
|
916
|
+
buyer_key = sale_response['BuyerKey']
|
917
|
+
|
918
|
+
update_instant_buy_data_request = Gateway::UpdateInstantBuyDataRequest.new
|
919
|
+
update_instant_buy_data_request.BuyerKey = buyer_key
|
920
|
+
|
921
|
+
response = gateway.UpdateCreditCard(instant_buy_key, update_instant_buy_data_request)
|
922
|
+
|
923
|
+
expect(response['Success']).to eq true
|
924
|
+
end
|
925
|
+
|
926
|
+
it 'should do a credit card transaction with instant buy key' do
|
927
|
+
credit_card_transaction = Gateway::CreditCardTransaction.new
|
928
|
+
credit_card_transaction.CreditCard.CreditCardNumber = '4111111111111111'
|
929
|
+
credit_card_transaction.CreditCard.CreditCardBrand = 'Visa'
|
930
|
+
credit_card_transaction.CreditCard.ExpMonth = 10
|
931
|
+
credit_card_transaction.CreditCard.ExpYear = 2018
|
932
|
+
credit_card_transaction.CreditCard.SecurityCode = '123'
|
933
|
+
credit_card_transaction.CreditCard.HolderName = 'Luke Skywalker'
|
934
|
+
credit_card_transaction.AmountInCents = 100
|
935
|
+
|
936
|
+
sale_request = Gateway::CreateSaleRequest.new
|
937
|
+
sale_request.CreditCardTransactionCollection << credit_card_transaction
|
938
|
+
|
939
|
+
sale_response = gateway.CreateSale(sale_request)
|
940
|
+
|
941
|
+
expect(sale_response['ErrorReport']).to eq nil
|
942
|
+
|
943
|
+
instant_buy_key = sale_response['CreditCardTransactionResultCollection'][0]['CreditCard']['InstantBuyKey']
|
944
|
+
|
945
|
+
# coleta dados do cartao
|
946
|
+
creditCardTransaction = Gateway::CreditCardTransaction.new
|
947
|
+
creditCardTransaction.AmountInCents = 100
|
948
|
+
creditCardTransaction.CreditCard.InstantBuyKey = instant_buy_key
|
949
|
+
|
950
|
+
# cria a transacao
|
951
|
+
createSaleRequest = Gateway::CreateSaleRequest.new
|
952
|
+
createSaleRequest.CreditCardTransactionCollection << creditCardTransaction
|
953
|
+
|
954
|
+
# faz a requisicao de criação de transacao, retorna um hash com a resposta
|
955
|
+
response = gateway.CreateSale(createSaleRequest)
|
956
|
+
|
957
|
+
expect(response['ErrorReport']).to eq nil
|
958
|
+
end
|
959
|
+
|
960
|
+
it 'should get the buyer with buyer key' do
|
961
|
+
credit_card_transaction = Gateway::CreditCardTransaction.new
|
962
|
+
credit_card_transaction.CreditCard.CreditCardNumber = '4111111111111111'
|
963
|
+
credit_card_transaction.CreditCard.CreditCardBrand = 'Visa'
|
964
|
+
credit_card_transaction.CreditCard.ExpMonth = 10
|
965
|
+
credit_card_transaction.CreditCard.ExpYear = 2018
|
966
|
+
credit_card_transaction.CreditCard.SecurityCode = '123'
|
967
|
+
credit_card_transaction.CreditCard.HolderName = 'Luke Skywalker'
|
968
|
+
credit_card_transaction.AmountInCents = 100
|
969
|
+
|
970
|
+
sale_request = Gateway::CreateSaleRequest.new
|
971
|
+
sale_request.Buyer.Name = 'Anakin Skywalker'
|
972
|
+
sale_request.Buyer.Birthdate = Date.new(1994, 9, 26).strftime("%Y-%m-%dT%H:%M:%S")
|
973
|
+
sale_request.Buyer.DocumentNumber = '12345678901'
|
974
|
+
sale_request.Buyer.DocumentType = 'CPF'
|
975
|
+
sale_request.Buyer.PersonType = 'Person'
|
976
|
+
sale_request.Buyer.Gender = 'M'
|
977
|
+
sale_request.CreditCardTransactionCollection << credit_card_transaction
|
978
|
+
|
979
|
+
sale_response = gateway.CreateSale(sale_request)
|
980
|
+
|
981
|
+
expect(sale_response['ErrorReport']).to eq nil
|
982
|
+
|
983
|
+
response = gateway.GetBuyer(sale_response['BuyerKey'])
|
984
|
+
|
985
|
+
expect(response['ErrorReport']).to eq nil
|
986
|
+
end
|
987
|
+
|
988
|
+
it 'should create buyer with buyer request' do
|
989
|
+
address = Gateway::BuyerAddress.new
|
990
|
+
address.AddressType = 'Residential'
|
991
|
+
address.City = 'Tatooine'
|
992
|
+
address.Complement = ''
|
993
|
+
address.Country = 'Brazil'
|
994
|
+
address.District = 'Mos Eisley'
|
995
|
+
address.Number = '123'
|
996
|
+
address.State = 'RJ'
|
997
|
+
address.Street = 'Mos Eisley Cantina'
|
998
|
+
address.ZipCode = '20001000'
|
999
|
+
|
1000
|
+
buyer_request = Gateway::CreateBuyerRequest.new
|
1001
|
+
buyer_request.AddressCollection << address
|
1002
|
+
buyer_request.Birthdate = DateTime.new(1990,8,20,0,0,0).strftime("%Y-%m-%dT%H:%M:%S")
|
1003
|
+
buyer_request.BuyerCategory = 'Normal'
|
1004
|
+
buyer_request.BuyerReference = 'C3PO'
|
1005
|
+
buyer_request.CreateDateInMerchant = DateTime.new(2015,12,11,18,36,45).strftime("%Y-%m-%dT%H:%M:%S")
|
1006
|
+
buyer_request.DocumentNumber = '12345678901'
|
1007
|
+
buyer_request.DocumentType = 'CPF'
|
1008
|
+
buyer_request.Email = 'lskywalker@r2d2.com'
|
1009
|
+
buyer_request.EmailType = 'Personal'
|
1010
|
+
buyer_request.FacebookId = 'lukeskywalker8917'
|
1011
|
+
buyer_request.Gender = 'M'
|
1012
|
+
buyer_request.HomePhone = '(21)123456789'
|
1013
|
+
buyer_request.LastBuyerUpdateInMerchant = DateTime.now.strftime("%Y-%m-%dT%H:%M:%S")
|
1014
|
+
buyer_request.MobilePhone = '(21)987654321'
|
1015
|
+
buyer_request.Name = 'Luke Skywalker'
|
1016
|
+
buyer_request.PersonType = 'Person'
|
1017
|
+
buyer_request.TwitterId = '@lukeskywalker8917'
|
1018
|
+
buyer_request.WorkPhone = '(21)28467902'
|
1019
|
+
|
1020
|
+
response = gateway.CreateBuyer(buyer_request)
|
1021
|
+
|
1022
|
+
expect(response['Success']).to eq true
|
1023
|
+
end
|
1024
|
+
end
|