spec/integration/gateway_spec.rb in stone_ecommerce-1.0.3 vs spec/integration/gateway_spec.rb in stone_ecommerce-1.2.3
- old
+ new
@@ -1,16 +1,17 @@
require_relative '../../lib/stone_ecommerce'
require_relative 'test_helper'
merchant_key = '8A2DD57F-1ED9-4153-B4CE-69683EFADAD5'
-gateway = Gateway.new(:production, merchant_key)
+gateway = Gateway::Gateway.new(:production, merchant_key)
+
RSpec.describe Gateway do
it 'should create a sale with boleto' do
- createSaleRequest = CreateSaleRequest.new
+ createSaleRequest = Gateway::CreateSaleRequest.new
- boletoTransaction = BoletoTransaction.new
+ boletoTransaction = Gateway::BoletoTransaction.new
boletoTransaction.AmountInCents = 100
boletoTransaction.BankNumber = '237'
boletoTransaction.DocumentNumber = '12345678901'
boletoTransaction.Instructions = 'Pagar antes do vencimento'
boletoTransaction.TransactionReference = 'BoletoTest#Ruby01'
@@ -23,24 +24,24 @@
expect(response[:ErrorReport]).to eq nil
end
it 'should create a sale with credit card' do
- createSaleRequest = CreateSaleRequest.new
+ createSaleRequest = Gateway::CreateSaleRequest.new
- buyerAddress = BuyerAddress.new
+ buyerAddress = Gateway::BuyerAddress.new
buyerAddress.AddressType = 'Residential'
buyerAddress.City = 'Rio de Janeiro'
buyerAddress.Complement = '10 Andar'
buyerAddress.Country = 'Brazil'
buyerAddress.District = 'Centro'
buyerAddress.Number = '199'
buyerAddress.State = 'RJ'
buyerAddress.Street = 'Rua da Quitanda'
buyerAddress.ZipCode = '20091005'
- creditCardTransaction = CreditCardTransaction.new
+ creditCardTransaction = Gateway::CreditCardTransaction.new
creditCardTransaction.AmountInCents = 100
creditCardTransaction.InstallmentCount = 1
creditCardTransaction.TransactionReference = 'CreditCard One RubySDK Test'
creditCardTransaction.Options.PaymentMethodCode = 1
creditCardTransaction.Options.SoftDescriptorText = 'My Store Name'
@@ -82,11 +83,11 @@
end
it 'should create a sale with all types of transactions and all fields filled' do
# creates boleto transaction object
- boletoTransaction = BoletoTransaction.new
+ boletoTransaction = Gateway::BoletoTransaction.new
# 100 reais in cents
boletoTransaction.AmountInCents = 10000
boletoTransaction.BankNumber = '237'
boletoTransaction.BillingAddress.City = 'Tatooine'
@@ -103,11 +104,11 @@
boletoTransaction.Options.DaysToAddInBoletoExpirationDate = 5
boletoTransaction.TransactionReference = 'NumeroDaTransacao'
# create credit card transaction object
- creditCardTransaction = CreditCardTransaction.new
+ creditCardTransaction = Gateway::CreditCardTransaction.new
# 100 reais in cents
creditCardTransaction.AmountInCents = 10000
creditCardTransaction.CreditCard.BillingAddress.City = 'Tatooine'
creditCardTransaction.CreditCard.BillingAddress.Complement = ''
@@ -127,20 +128,20 @@
creditCardTransaction.InstallmentCount = 1
creditCardTransaction.Options.CurrencyIso = 'BRL'
creditCardTransaction.Options.PaymentMethodCode = 1
creditCardTransaction.Options.SoftDescriptorText = 'Jedi Mega Store'
- shoppingCartItem = ShoppingCartItemCollection.new
+ shoppingCartItem = Gateway::ShoppingCartItemCollection.new
shoppingCartItem.Description = 'Red Lightsaber'
shoppingCartItem.DiscountAmountInCents = 0
shoppingCartItem.ItemReference = 'NumeroDoProduto'
shoppingCartItem.Name = 'Lightsaber'
shoppingCartItem.Quantity = 1
shoppingCartItem.TotalCostInCents = 18000
shoppingCartItem.UnitCostInCents = 18000
- shoppingCartCollection = ShoppingCartCollection.new
+ shoppingCartCollection = Gateway::ShoppingCartCollection.new
shoppingCartCollection.DeliveryAddress.City = 'Galaxy far far away'
shoppingCartCollection.DeliveryAddress.Complement = 'Bridge'
shoppingCartCollection.DeliveryAddress.Country = 'Brazil'
shoppingCartCollection.DeliveryAddress.District = 'Command Room'
shoppingCartCollection.DeliveryAddress.Number = '321'
@@ -152,16 +153,16 @@
shoppingCartCollection.FreighCostInCents = 2000
shoppingCartCollection.ShippingCompany = 'Empire'
shoppingCartCollection.ShoppingCartItemCollection << shoppingCartItem
# creates request object for transaction creation
- createSaleRequest = CreateSaleRequest.new
+ createSaleRequest = Gateway::CreateSaleRequest.new
# adds to the boleto transaction collection
createSaleRequest.BoletoTransactionCollection << boletoTransaction
- buyerAddress = BuyerAddress.new
+ buyerAddress = Gateway::BuyerAddress.new
buyerAddress.AddressType = 'Residential'
buyerAddress.City = 'Tatooine'
buyerAddress.Complement = ''
buyerAddress.Country = 'Brazil'
buyerAddress.District = 'Mos Eisley'
@@ -210,11 +211,11 @@
expect(response[:ErrorReport]).to eq nil
end
it 'should create an anti fraud transaction' do
# create credit card transaction object
- creditCardTransaction = CreditCardTransaction.new
+ creditCardTransaction = Gateway::CreditCardTransaction.new
# 100 reais in cents
creditCardTransaction.AmountInCents = 10000
creditCardTransaction.CreditCard.BillingAddress.City = 'Tatooine'
creditCardTransaction.CreditCard.BillingAddress.Complement = ''
@@ -230,20 +231,20 @@
creditCardTransaction.CreditCard.ExpYear = 22
creditCardTransaction.CreditCard.HolderName = 'LUKE SKYWALKER'
creditCardTransaction.CreditCard.SecurityCode = '123'
creditCardTransaction.InstallmentCount = 1
- shoppingCartItem = ShoppingCartItemCollection.new
+ shoppingCartItem = Gateway::ShoppingCartItemCollection.new
shoppingCartItem.Description = 'Red Lightsaber'
shoppingCartItem.DiscountAmountInCents = 0
shoppingCartItem.ItemReference = 'NumeroDoProduto'
shoppingCartItem.Name = 'Lightsaber'
shoppingCartItem.Quantity = 1
shoppingCartItem.TotalCostInCents = 18000
shoppingCartItem.UnitCostInCents = 0
- shoppingCartCollection = ShoppingCartCollection.new
+ shoppingCartCollection = Gateway::ShoppingCartCollection.new
shoppingCartCollection.DeliveryAddress.City = 'Galaxy far far away'
shoppingCartCollection.DeliveryAddress.Complement = 'Bridge'
shoppingCartCollection.DeliveryAddress.Country = 'Brazil'
shoppingCartCollection.DeliveryAddress.District = 'Command Room'
shoppingCartCollection.DeliveryAddress.Number = '321'
@@ -252,13 +253,13 @@
shoppingCartCollection.DeliveryAddress.ZipCode = '10002000'
shoppingCartCollection.FreighCostInCents = 2000
shoppingCartCollection.ShoppingCartItemCollection << shoppingCartItem
# creates request object for transaction creation
- createSaleRequest = CreateSaleRequest.new
+ createSaleRequest = Gateway::CreateSaleRequest.new
- buyerAddress = BuyerAddress.new
+ buyerAddress = Gateway::BuyerAddress.new
buyerAddress.AddressType = 'Residential'
buyerAddress.City = 'Tatooine'
buyerAddress.Complement = ''
buyerAddress.Country = 'Brazil'
buyerAddress.District = 'Mos Eisley'
@@ -294,14 +295,14 @@
expect(response[:ErrorReport]).to eq nil
end
it 'should consult the order with order key' do
- querySaleRequest = QuerySaleRequest.new
- createSaleRequest = CreateSaleRequest.new
+ querySaleRequest = Gateway::QuerySaleRequest.new
+ createSaleRequest = Gateway::CreateSaleRequest.new
- boletoTransaction = BoletoTransaction.new
+ boletoTransaction = Gateway::BoletoTransaction.new
boletoTransaction.AmountInCents = 100
boletoTransaction.BankNumber = '237'
boletoTransaction.DocumentNumber = '12345678901'
boletoTransaction.Instructions = 'Pagar antes do vencimento'
boletoTransaction.TransactionReference = 'BoletoTest#Ruby01'
@@ -311,22 +312,22 @@
createSaleRequest.BoletoTransactionCollection << boletoTransaction
boleto_response = gateway.CreateSale(createSaleRequest)
querySaleRequest.OrderKey = boleto_response['OrderResult']['OrderKey']
- responseQuery = gateway.Query(QuerySaleRequest.QuerySaleRequestEnum[:OrderKey], querySaleRequest.OrderKey)
+ responseQuery = gateway.Query(Gateway::QuerySaleRequest.QuerySaleRequestEnum[:OrderKey], querySaleRequest.OrderKey)
orderKey = responseQuery["SaleDataCollection"][0]["OrderData"]["OrderKey"]
expect(orderKey).to eq querySaleRequest.OrderKey
end
it 'should consult the order with order reference' do
- querySaleRequest = QuerySaleRequest.new
- createSaleRequest = CreateSaleRequest.new
+ querySaleRequest = Gateway::QuerySaleRequest.new
+ createSaleRequest = Gateway::CreateSaleRequest.new
- boletoTransaction = BoletoTransaction.new
+ boletoTransaction = Gateway::BoletoTransaction.new
boletoTransaction.AmountInCents = 100
boletoTransaction.BankNumber = '237'
boletoTransaction.DocumentNumber = '12345678901'
boletoTransaction.Instructions = 'Pagar antes do vencimento'
boletoTransaction.TransactionReference = 'BoletoTest#Ruby01'
@@ -337,23 +338,23 @@
createSaleRequest.BoletoTransactionCollection << boletoTransaction
boleto_response = gateway.CreateSale(createSaleRequest)
querySaleRequest.OrderReference = boleto_response['OrderResult']['OrderReference']
- responseQuery = gateway.Query(QuerySaleRequest.QuerySaleRequestEnum[:OrderReference], querySaleRequest.OrderReference)
+ responseQuery = gateway.Query(Gateway::QuerySaleRequest.QuerySaleRequestEnum[:OrderReference], querySaleRequest.OrderReference)
orderReference = responseQuery["SaleDataCollection"][0]["OrderData"]["OrderReference"]
expect(orderReference).to eq querySaleRequest.OrderReference
end
it 'should do a retry method' do
- retrySaleRequest = RetrySaleRequest.new
- retrySaleCreditCardTransactionItem = RetrySaleCreditCardTransaction.new
+ retrySaleRequest = Gateway::RetrySaleRequest.new
+ retrySaleCreditCardTransactionItem = Gateway::RetrySaleCreditCardTransaction.new
- createSaleRequest = CreateSaleRequest.new
- creditCardTransactionItem = CreditCardTransaction.new
+ createSaleRequest = Gateway::CreateSaleRequest.new
+ creditCardTransactionItem = Gateway::CreditCardTransaction.new
creditCardTransactionItem.AmountInCents = 100
creditCardTransactionItem.CreditCard.CreditCardBrand = 'Visa'
creditCardTransactionItem.CreditCard.CreditCardNumber = '41111111111111'
creditCardTransactionItem.CreditCard.ExpMonth = 10
creditCardTransactionItem.CreditCard.ExpYear = 19
@@ -390,12 +391,12 @@
expect(responseTransactionKey).to eq transactionKey
end
it 'should do a retry method with only order key' do
- createSaleRequest = CreateSaleRequest.new
- creditCardTransactionItem = CreditCardTransaction.new
+ createSaleRequest = Gateway::CreateSaleRequest.new
+ creditCardTransactionItem = Gateway::CreditCardTransaction.new
creditCardTransactionItem.AmountInCents = 100
creditCardTransactionItem.CreditCard.CreditCardBrand = 'Visa'
creditCardTransactionItem.CreditCard.CreditCardNumber = '41111111111111'
creditCardTransactionItem.CreditCard.ExpMonth = 10
creditCardTransactionItem.CreditCard.ExpYear = 22
@@ -412,11 +413,11 @@
# pega o orderkey e o transaction key da resposta que sao necessarios para fazer a retentativa
orderKey = responseCreate["OrderResult"]["OrderKey"]
transactionKey = responseCreate['CreditCardTransactionResultCollection'][0]['TransactionKey']
- retrySaleRequest = RetrySaleRequest.new
+ retrySaleRequest = Gateway::RetrySaleRequest.new
# monta o objeto de retentativa
retrySaleRequest.OrderKey = orderKey
# faz a requisicao de retentativa
@@ -425,12 +426,12 @@
expect(response['ErrorReport']).to eq nil
end
it 'should cancel a transaction' do
- createSaleRequest = CreateSaleRequest.new
- creditCardTransactionItem = CreditCardTransaction.new
+ createSaleRequest = Gateway::CreateSaleRequest.new
+ creditCardTransactionItem = Gateway::CreditCardTransaction.new
creditCardTransactionItem.AmountInCents = 100
creditCardTransactionItem.CreditCard.CreditCardBrand = 'Visa'
creditCardTransactionItem.CreditCard.CreditCardNumber = '41111111111111'
creditCardTransactionItem.CreditCard.ExpMonth = 10
creditCardTransactionItem.CreditCard.ExpYear = 19
@@ -451,28 +452,28 @@
# pega o orderkey e o transaction key da resposta que sao necessarios para fazer o cancelamento
orderKey = responseCreate["OrderResult"]["OrderKey"]
transactionKey = responseCreate['CreditCardTransactionResultCollection'][0]['TransactionKey']
# itens necessarios para cancelamento da transacao de cartao de credito
- cancelCreditCardTransactionItem = ManageCreditCardTransaction.new
+ cancelCreditCardTransactionItem = Gateway::ManageCreditCardTransaction.new
cancelCreditCardTransactionItem.AmountInCents = 100
cancelCreditCardTransactionItem.TransactionKey = transactionKey
cancelCreditCardTransactionItem.TransactionReference = 'RubySDK-CancelTest'
# monta o objeto para cancelamento de transacao
- cancelSaleRequest = ManageSaleRequest.new
+ cancelSaleRequest = Gateway::ManageSaleRequest.new
cancelSaleRequest.OrderKey = orderKey
cancelSaleRequest.CreditCardTransactionCollection << cancelCreditCardTransactionItem
response = gateway.Cancel(cancelSaleRequest)
expect(response[:ErrorReport]).to eq nil
end
it 'should capture a transaction' do
- createSaleRequest = CreateSaleRequest.new
- creditCardTransactionItem = CreditCardTransaction.new
+ createSaleRequest = Gateway::CreateSaleRequest.new
+ creditCardTransactionItem = Gateway::CreditCardTransaction.new
creditCardTransactionItem.AmountInCents = 100
creditCardTransactionItem.CreditCard.CreditCardBrand = 'Visa'
creditCardTransactionItem.CreditCard.CreditCardNumber = '41111111111111'
creditCardTransactionItem.CreditCard.ExpMonth = 10
creditCardTransactionItem.CreditCard.ExpYear = 19
@@ -493,28 +494,28 @@
# pega o orderkey e o transaction key da resposta que sao necessarios para fazer a captura
orderKey = responseCreate["OrderResult"]["OrderKey"]
transactionKey = responseCreate['CreditCardTransactionResultCollection'][0]['TransactionKey']
# itens necessarios para captura da transacao de cartao de credito
- captureCreditCardTransactionItem = ManageCreditCardTransaction.new
+ captureCreditCardTransactionItem = Gateway::ManageCreditCardTransaction.new
captureCreditCardTransactionItem.AmountInCents = 100
captureCreditCardTransactionItem.TransactionKey = transactionKey
captureCreditCardTransactionItem.TransactionReference = 'RubySDK-CaptureTest'
# monta o objeto para cancelamento de transacao
- captureSaleRequest = ManageSaleRequest.new
+ captureSaleRequest = Gateway::ManageSaleRequest.new
captureSaleRequest.OrderKey = orderKey
captureSaleRequest.CreditCardTransactionCollection << captureCreditCardTransactionItem
response = gateway.Capture(captureSaleRequest)
# espera que o ErrorReport seja nulo, significa que foi tudo ok na transação
expect(response['ErrorReport']).to eq nil
end
it 'should do a parse xml to notification interpretation' do
- creditCardTransactionItem = CreditCardTransaction.new
+ creditCardTransactionItem = Gateway::CreditCardTransaction.new
creditCardTransactionItem.AmountInCents = 100
creditCardTransactionItem.TransactionReference = 'Ruby PostNotification Test'
creditCardTransactionItem.InstallmentCount = 1
creditCardTransactionItem.CreditCardOperation = 'AuthAndCapture'
creditCardTransactionItem.CreditCard.CreditCardBrand = 'Visa'
@@ -523,27 +524,27 @@
creditCardTransactionItem.CreditCard.SecurityCode = '123'
creditCardTransactionItem.CreditCard.ExpMonth = 5
creditCardTransactionItem.CreditCard.ExpYear = 20
creditCardTransactionItem.Options.PaymentMethodCode = 1
- createSaleRequest = CreateSaleRequest.new
+ createSaleRequest = Gateway::CreateSaleRequest.new
createSaleRequest.CreditCardTransactionCollection << creditCardTransactionItem
response_hash = gateway.CreateSale(createSaleRequest)
credit_card_result = response_hash['CreditCardTransactionResultCollection'][0]
expect(credit_card_result['Success']).to eq true
# expect(credit_card_result['CreditCardOperation']).to eq 'AuthOnly'
# expect(credit_card_result['CreditCardTransactionStatus']).to eq 'AuthorizedPendingCapture'
- captureCreditCardTransactionItem = ManageCreditCardTransaction.new
+ captureCreditCardTransactionItem = Gateway::ManageCreditCardTransaction.new
captureCreditCardTransactionItem.AmountInCents = creditCardTransactionItem.AmountInCents
captureCreditCardTransactionItem.TransactionKey = credit_card_result['TransactionKey']
captureCreditCardTransactionItem.TransactionReference = creditCardTransactionItem.TransactionReference
- captureSale = ManageSaleRequest.new
+ captureSale = Gateway::ManageSaleRequest.new
captureSale.OrderKey = response_hash['OrderResult']['OrderKey']
captureSale.CreditCardTransactionCollection << captureCreditCardTransactionItem
captureResponse = gateway.Capture(captureSale)
@@ -610,52 +611,54 @@
response = gateway.ParseXmlToNotification(xml)
expect(response.nil?).to eq false
end
- # it 'should bring the transaction report file' do
- # date = Date.new(2015, 9, 19)
- # result = gateway.TransactionReportFile(date)
- # split_commas = result.split(',')
- #
- # expect(split_commas[1]).to eq '20150919'
- # end
- #
- # it 'should parse the transaction report file received' do
- # date = Date.new(2015, 9, 19)
- # request_to_parse = gateway.TransactionReportFile(date)
- # result = gateway.TransactionReportFileParser(request_to_parse)
- #
- # expect(result['Header'].TransactionProcessedDate).to eq '20150919'
- # end
- #
- # it 'should save the transaction report file at selected path' do
- # date = Date.new(2015, 9, 19)
- #
- # file = Tempfile.new('Test')
- # gateway.TransactionReportFileDownloader(date, 'Test', file.path)
- #
- # file_path = file.path.to_s + 'Test.txt'
- # file_exist = File.exist?(file_path)
- #
- # file.close
- # file.unlink
- #
- # expect(file_exist).to eq true
- # end
+=begin
+ it 'should bring the transaction report file' do
+ date = Date.new(2015, 9, 19)
+ result = gateway.TransactionReportFile(date)
+ split_commas = result.split(',')
- it 'should consult transaction with instant buy key' do
- credit_card_transaction = CreditCardTransaction.new
+ expect(split_commas[1]).to eq '20150919'
+ end
+
+ it 'should parse the transaction report file received' do
+ date = Date.new(2015, 9, 19)
+ request_to_parse = gateway.TransactionReportFile(date)
+ result = gateway.TransactionReportFileParser(request_to_parse)
+
+ expect(result['Header'].TransactionProcessedDate).to eq '20150919'
+ end
+
+ it 'should save the transaction report file at selected path' do
+ date = Date.new(2015, 9, 19)
+
+ file = Tempfile.new('Test')
+ gateway.TransactionReportFileDownloader(date, 'Test', file.path)
+
+ file_path = file.path.to_s + 'Test.txt'
+ file_exist = File.exist?(file_path)
+
+ file.close
+ file.unlink
+
+ expect(file_exist).to eq true
+ end
+=end
+
+ it 'should get credit card instant buy key deprecated' do
+ credit_card_transaction = Gateway::CreditCardTransaction.new
credit_card_transaction.CreditCard.CreditCardNumber = '4111111111111111'
credit_card_transaction.CreditCard.CreditCardBrand = 'Visa'
credit_card_transaction.CreditCard.ExpMonth = 10
credit_card_transaction.CreditCard.ExpYear = 2018
credit_card_transaction.CreditCard.SecurityCode = '123'
credit_card_transaction.CreditCard.HolderName = 'Luke Skywalker'
credit_card_transaction.AmountInCents = 100
- sale_request = CreateSaleRequest.new
+ sale_request = Gateway::CreateSaleRequest.new
sale_request.CreditCardTransactionCollection << credit_card_transaction
sale_response = gateway.CreateSale(sale_request)
expect(sale_response['ErrorReport']).to eq nil
@@ -665,22 +668,70 @@
response = gateway.InstantBuyKey(instant_buy_key)
expect(response['ErrorReport']).to eq nil
end
- it 'should consult transaction with buyer key' do
+ it 'should get credit card instant buy key' do
+ credit_card_transaction = Gateway::CreditCardTransaction.new
+ credit_card_transaction.CreditCard.CreditCardNumber = '4111111111111111'
+ credit_card_transaction.CreditCard.CreditCardBrand = 'Visa'
+ credit_card_transaction.CreditCard.ExpMonth = 10
+ credit_card_transaction.CreditCard.ExpYear = 2018
+ credit_card_transaction.CreditCard.SecurityCode = '123'
+ credit_card_transaction.CreditCard.HolderName = 'Luke Skywalker'
+ credit_card_transaction.AmountInCents = 100
- credit_card_transaction = CreditCardTransaction.new
+ sale_request = Gateway::CreateSaleRequest.new
+ sale_request.CreditCardTransactionCollection << credit_card_transaction
+
+ sale_response = gateway.CreateSale(sale_request)
+
+ expect(sale_response['ErrorReport']).to eq nil
+
+ instant_buy_key = sale_response['CreditCardTransactionResultCollection'][0]['CreditCard']['InstantBuyKey']
+
+ response = gateway.GetCreditCard(instant_buy_key)
+
+ expect(response['ErrorReport']).to eq nil
+ end
+
+ it 'should delete credit card instant buy key' do
+ credit_card_transaction = Gateway::CreditCardTransaction.new
credit_card_transaction.CreditCard.CreditCardNumber = '4111111111111111'
credit_card_transaction.CreditCard.CreditCardBrand = 'Visa'
credit_card_transaction.CreditCard.ExpMonth = 10
credit_card_transaction.CreditCard.ExpYear = 2018
credit_card_transaction.CreditCard.SecurityCode = '123'
credit_card_transaction.CreditCard.HolderName = 'Luke Skywalker'
credit_card_transaction.AmountInCents = 100
- sale_request = CreateSaleRequest.new
+ sale_request = Gateway::CreateSaleRequest.new
+ sale_request.CreditCardTransactionCollection << credit_card_transaction
+
+ sale_response = gateway.CreateSale(sale_request)
+
+ expect(sale_response['ErrorReport']).to eq nil
+
+ instant_buy_key = sale_response['CreditCardTransactionResultCollection'][0]['CreditCard']['InstantBuyKey']
+
+ response = gateway.DeleteCreditCard(instant_buy_key)
+
+ expect(response['Success']).to eq true
+ end
+
+ it 'should consult get credit card with buyer key deprecated' do
+
+ credit_card_transaction = Gateway::CreditCardTransaction.new
+ credit_card_transaction.CreditCard.CreditCardNumber = '4111111111111111'
+ credit_card_transaction.CreditCard.CreditCardBrand = 'Visa'
+ credit_card_transaction.CreditCard.ExpMonth = 10
+ credit_card_transaction.CreditCard.ExpYear = 2018
+ credit_card_transaction.CreditCard.SecurityCode = '123'
+ credit_card_transaction.CreditCard.HolderName = 'Luke Skywalker'
+ credit_card_transaction.AmountInCents = 100
+
+ sale_request = Gateway::CreateSaleRequest.new
sale_request.Buyer.Name = 'Anakin Skywalker'
sale_request.Buyer.Birthdate = Date.new(1994, 9, 26).strftime("%Y-%m-%dT%H:%M:%S")
sale_request.Buyer.DocumentNumber = '12345678901'
sale_request.Buyer.DocumentType = 'CPF'
sale_request.Buyer.PersonType = 'Person'
@@ -694,40 +745,280 @@
response = gateway.BuyerKey(sale_response['BuyerKey'])
expect(response['ErrorReport']).to eq nil
end
+ it 'should consult get credit card with buyer key' do
+
+ credit_card_transaction = Gateway::CreditCardTransaction.new
+ credit_card_transaction.CreditCard.CreditCardNumber = '4111111111111111'
+ credit_card_transaction.CreditCard.CreditCardBrand = 'Visa'
+ credit_card_transaction.CreditCard.ExpMonth = 10
+ credit_card_transaction.CreditCard.ExpYear = 2018
+ credit_card_transaction.CreditCard.SecurityCode = '123'
+ credit_card_transaction.CreditCard.HolderName = 'Luke Skywalker'
+ credit_card_transaction.AmountInCents = 100
+
+ sale_request = Gateway::CreateSaleRequest.new
+ sale_request.Buyer.Name = 'Anakin Skywalker'
+ sale_request.Buyer.Birthdate = Date.new(1994, 9, 26).strftime("%Y-%m-%dT%H:%M:%S")
+ sale_request.Buyer.DocumentNumber = '12345678901'
+ sale_request.Buyer.DocumentType = 'CPF'
+ sale_request.Buyer.PersonType = 'Person'
+ sale_request.Buyer.Gender = 'M'
+ sale_request.CreditCardTransactionCollection << credit_card_transaction
+
+ sale_response = gateway.CreateSale(sale_request)
+
+ expect(sale_response['ErrorReport']).to eq nil
+
+ response = gateway.GetCreditCardWithBuyerKey(sale_response['BuyerKey'])
+
+ expect(response['ErrorReport']).to eq nil
+ end
+
+ it 'should create a credit card' do
+ create_instant_buy_data = Gateway::CreateInstantBuyDataRequest.new
+ create_instant_buy_data.CreditCardNumber = '4111111111111111'
+ create_instant_buy_data.ExpMonth = 10
+ create_instant_buy_data.ExpYear = 2018
+ create_instant_buy_data.SecurityCode = '123'
+ create_instant_buy_data.HolderName = 'Luke Skywalker'
+ create_instant_buy_data.CreditCardBrand = 'Visa'
+ create_instant_buy_data.IsOneDollarAuthEnabled = false
+ create_instant_buy_data.BillingAddress.City = 'Rio de Janeiro'
+ create_instant_buy_data.BillingAddress.Complement = 'Em frente ao Aeroporto'
+ create_instant_buy_data.BillingAddress.Country = 'Brazil'
+ create_instant_buy_data.BillingAddress.District = 'Centro'
+ create_instant_buy_data.BillingAddress.Number = '123'
+ create_instant_buy_data.BillingAddress.State = 'RJ'
+ create_instant_buy_data.BillingAddress.Street = 'Av. General Justo'
+ create_instant_buy_data.BillingAddress.ZipCode = '20270004'
+
+ response = gateway.CreateCreditCard(create_instant_buy_data)
+
+ expect(response['ErrorReport']).to eq nil
+ end
+
+ it 'should create credit card with buyerkey in it' do
+ address = Gateway::BuyerAddress.new
+ address.AddressType = 'Residential'
+ address.City = 'Tatooine'
+ address.Complement = ''
+ address.Country = 'Brazil'
+ address.District = 'Mos Eisley'
+ address.Number = '123'
+ address.State = 'RJ'
+ address.Street = 'Mos Eisley Cantina'
+ address.ZipCode = '20001000'
+
+ buyer_request = Gateway::CreateBuyerRequest.new
+ buyer_request.AddressCollection << address
+ buyer_request.Birthdate = DateTime.new(1990,8,20,0,0,0).strftime("%Y-%m-%dT%H:%M:%S")
+ buyer_request.BuyerCategory = 'Normal'
+ buyer_request.BuyerReference = 'C3PO'
+ buyer_request.CreateDateInMerchant = DateTime.new(2015,12,11,18,36,45).strftime("%Y-%m-%dT%H:%M:%S")
+ buyer_request.DocumentNumber = '12345678901'
+ buyer_request.DocumentType = 'CPF'
+ buyer_request.Email = 'lskywalker@r2d2.com'
+ buyer_request.EmailType = 'Personal'
+ buyer_request.FacebookId = 'lukeskywalker8917'
+ buyer_request.Gender = 'M'
+ buyer_request.HomePhone = '(21)123456789'
+ buyer_request.LastBuyerUpdateInMerchant = DateTime.now.strftime("%Y-%m-%dT%H:%M:%S")
+ buyer_request.MobilePhone = '(21)987654321'
+ buyer_request.Name = 'Luke Skywalker'
+ buyer_request.PersonType = 'Person'
+ buyer_request.TwitterId = '@lukeskywalker8917'
+ buyer_request.WorkPhone = '(21)28467902'
+
+ new_buyer_response = gateway.CreateBuyer(buyer_request)
+ buyer_key = new_buyer_response['BuyerKey']
+
+ create_instant_buy_data = Gateway::CreateInstantBuyDataRequest.new
+ create_instant_buy_data.CreditCardNumber = '4111111111111111'
+ create_instant_buy_data.ExpMonth = 10
+ create_instant_buy_data.ExpYear = 2018
+ create_instant_buy_data.SecurityCode = '123'
+ create_instant_buy_data.HolderName = 'Luke Skywalker'
+ create_instant_buy_data.CreditCardBrand = 'Visa'
+ create_instant_buy_data.IsOneDollarAuthEnabled = false
+ create_instant_buy_data.BuyerKey = buyer_key
+ create_instant_buy_data.BillingAddress.City = 'Rio de Janeiro'
+ create_instant_buy_data.BillingAddress.Complement = 'Em frente ao Aeroporto'
+ create_instant_buy_data.BillingAddress.Country = 'Brazil'
+ create_instant_buy_data.BillingAddress.District = 'Centro'
+ create_instant_buy_data.BillingAddress.Number = '123'
+ create_instant_buy_data.BillingAddress.State = 'RJ'
+ create_instant_buy_data.BillingAddress.Street = 'Av. General Justo'
+ create_instant_buy_data.BillingAddress.ZipCode = '20270004'
+
+ response = gateway.CreateCreditCard(create_instant_buy_data)
+
+ expect(response['Success']).to eq true
+ end
+
+ it 'should create a credit card without billing address' do
+ create_instant_buy_data = Gateway::CreateInstantBuyDataRequest.new
+ create_instant_buy_data.CreditCardNumber = '4111111111111111'
+ create_instant_buy_data.ExpMonth = 10
+ create_instant_buy_data.ExpYear = 2018
+ create_instant_buy_data.SecurityCode = '123'
+ create_instant_buy_data.HolderName = 'Luke Skywalker'
+ create_instant_buy_data.CreditCardBrand = 'Visa'
+
+ response = gateway.CreateCreditCard(create_instant_buy_data)
+
+ expect(response['ErrorReport']).to eq nil
+ end
+
+ it 'should update the credit card' do
+ create_instant_buy_data = Gateway::CreateInstantBuyDataRequest.new
+ create_instant_buy_data.CreditCardNumber = '4111111111111111'
+ create_instant_buy_data.ExpMonth = 10
+ create_instant_buy_data.ExpYear = 2018
+ create_instant_buy_data.SecurityCode = '123'
+ create_instant_buy_data.HolderName = 'Luke Skywalker'
+ create_instant_buy_data.CreditCardBrand = 'Visa'
+ create_instant_buy_data.IsOneDollarAuthEnabled = false
+ create_instant_buy_data.BillingAddress.City = 'Rio de Janeiro'
+ create_instant_buy_data.BillingAddress.Complement = 'Em frente ao Aeroporto'
+ create_instant_buy_data.BillingAddress.Country = 'Brazil'
+ create_instant_buy_data.BillingAddress.District = 'Centro'
+ create_instant_buy_data.BillingAddress.Number = '123'
+ create_instant_buy_data.BillingAddress.State = 'RJ'
+ create_instant_buy_data.BillingAddress.Street = 'Av. General Justo'
+ create_instant_buy_data.BillingAddress.ZipCode = '20270004'
+
+ create_credit_card = gateway.CreateCreditCard(create_instant_buy_data)
+
+ credit_card_transaction = Gateway::CreditCardTransaction.new
+ credit_card_transaction.CreditCard.CreditCardNumber = '4111111111111111'
+ credit_card_transaction.CreditCard.CreditCardBrand = 'Visa'
+ credit_card_transaction.CreditCard.ExpMonth = 10
+ credit_card_transaction.CreditCard.ExpYear = 2018
+ credit_card_transaction.CreditCard.SecurityCode = '123'
+ credit_card_transaction.CreditCard.HolderName = 'Luke Skywalker'
+ credit_card_transaction.AmountInCents = 100
+
+ sale_request = Gateway::CreateSaleRequest.new
+ sale_request.Buyer.Name = 'Anakin Skywalker'
+ sale_request.Buyer.Birthdate = Date.new(1994, 9, 26).strftime("%Y-%m-%dT%H:%M:%S")
+ sale_request.Buyer.DocumentNumber = '12345678901'
+ sale_request.Buyer.DocumentType = 'CPF'
+ sale_request.Buyer.PersonType = 'Person'
+ sale_request.Buyer.Gender = 'M'
+ sale_request.CreditCardTransactionCollection << credit_card_transaction
+
+ sale_response = gateway.CreateSale(sale_request)
+
+ instant_buy_key = create_credit_card['InstantBuyKey']
+
+ buyer_key = sale_response['BuyerKey']
+
+ update_instant_buy_data_request = Gateway::UpdateInstantBuyDataRequest.new
+ update_instant_buy_data_request.BuyerKey = buyer_key
+
+ response = gateway.UpdateCreditCard(instant_buy_key, update_instant_buy_data_request)
+
+ expect(response['Success']).to eq true
+ end
+
it 'should do a credit card transaction with instant buy key' do
- credit_card_transaction = CreditCardTransaction.new
+ credit_card_transaction = Gateway::CreditCardTransaction.new
credit_card_transaction.CreditCard.CreditCardNumber = '4111111111111111'
credit_card_transaction.CreditCard.CreditCardBrand = 'Visa'
credit_card_transaction.CreditCard.ExpMonth = 10
credit_card_transaction.CreditCard.ExpYear = 2018
credit_card_transaction.CreditCard.SecurityCode = '123'
credit_card_transaction.CreditCard.HolderName = 'Luke Skywalker'
credit_card_transaction.AmountInCents = 100
- sale_request = CreateSaleRequest.new
+ sale_request = Gateway::CreateSaleRequest.new
sale_request.CreditCardTransactionCollection << credit_card_transaction
sale_response = gateway.CreateSale(sale_request)
expect(sale_response['ErrorReport']).to eq nil
instant_buy_key = sale_response['CreditCardTransactionResultCollection'][0]['CreditCard']['InstantBuyKey']
# coleta dados do cartao
- creditCardTransaction = CreditCardTransaction.new
+ creditCardTransaction = Gateway::CreditCardTransaction.new
creditCardTransaction.AmountInCents = 100
creditCardTransaction.CreditCard.InstantBuyKey = instant_buy_key
# cria a transacao
- createSaleRequest = CreateSaleRequest.new
+ createSaleRequest = Gateway::CreateSaleRequest.new
createSaleRequest.CreditCardTransactionCollection << creditCardTransaction
# faz a requisicao de criação de transacao, retorna um hash com a resposta
response = gateway.CreateSale(createSaleRequest)
expect(response['ErrorReport']).to eq nil
end
+ it 'should get the buyer with buyer key' do
+ credit_card_transaction = Gateway::CreditCardTransaction.new
+ credit_card_transaction.CreditCard.CreditCardNumber = '4111111111111111'
+ credit_card_transaction.CreditCard.CreditCardBrand = 'Visa'
+ credit_card_transaction.CreditCard.ExpMonth = 10
+ credit_card_transaction.CreditCard.ExpYear = 2018
+ credit_card_transaction.CreditCard.SecurityCode = '123'
+ credit_card_transaction.CreditCard.HolderName = 'Luke Skywalker'
+ credit_card_transaction.AmountInCents = 100
+
+ sale_request = Gateway::CreateSaleRequest.new
+ sale_request.Buyer.Name = 'Anakin Skywalker'
+ sale_request.Buyer.Birthdate = Date.new(1994, 9, 26).strftime("%Y-%m-%dT%H:%M:%S")
+ sale_request.Buyer.DocumentNumber = '12345678901'
+ sale_request.Buyer.DocumentType = 'CPF'
+ sale_request.Buyer.PersonType = 'Person'
+ sale_request.Buyer.Gender = 'M'
+ sale_request.CreditCardTransactionCollection << credit_card_transaction
+
+ sale_response = gateway.CreateSale(sale_request)
+
+ expect(sale_response['ErrorReport']).to eq nil
+
+ response = gateway.GetBuyer(sale_response['BuyerKey'])
+
+ expect(response['ErrorReport']).to eq nil
+ end
+
+ it 'should create buyer with buyer request' do
+ address = Gateway::BuyerAddress.new
+ address.AddressType = 'Residential'
+ address.City = 'Tatooine'
+ address.Complement = ''
+ address.Country = 'Brazil'
+ address.District = 'Mos Eisley'
+ address.Number = '123'
+ address.State = 'RJ'
+ address.Street = 'Mos Eisley Cantina'
+ address.ZipCode = '20001000'
+
+ buyer_request = Gateway::CreateBuyerRequest.new
+ buyer_request.AddressCollection << address
+ buyer_request.Birthdate = DateTime.new(1990,8,20,0,0,0).strftime("%Y-%m-%dT%H:%M:%S")
+ buyer_request.BuyerCategory = 'Normal'
+ buyer_request.BuyerReference = 'C3PO'
+ buyer_request.CreateDateInMerchant = DateTime.new(2015,12,11,18,36,45).strftime("%Y-%m-%dT%H:%M:%S")
+ buyer_request.DocumentNumber = '12345678901'
+ buyer_request.DocumentType = 'CPF'
+ buyer_request.Email = 'lskywalker@r2d2.com'
+ buyer_request.EmailType = 'Personal'
+ buyer_request.FacebookId = 'lukeskywalker8917'
+ buyer_request.Gender = 'M'
+ buyer_request.HomePhone = '(21)123456789'
+ buyer_request.LastBuyerUpdateInMerchant = DateTime.now.strftime("%Y-%m-%dT%H:%M:%S")
+ buyer_request.MobilePhone = '(21)987654321'
+ buyer_request.Name = 'Luke Skywalker'
+ buyer_request.PersonType = 'Person'
+ buyer_request.TwitterId = '@lukeskywalker8917'
+ buyer_request.WorkPhone = '(21)28467902'
+
+ response = gateway.CreateBuyer(buyer_request)
+
+ expect(response['Success']).to eq true
+ end
end