Skip to content
Browse files

now the gem accepts the amounts as decimal and converts it

  • Loading branch information...
1 parent 47175ee commit e6e5842b58a8df4dbb9b8377ea2841b5c1faa26a @BrunoGrasselli BrunoGrasselli committed Nov 14, 2012
View
2 lib/rbraspag/credit_card.rb
@@ -85,7 +85,7 @@ def self.partial_capture(order_id, amount)
data = {
MAPPING[:order_id] => order_id,
MAPPING[:merchant_id] => merchant_id,
- "captureAmount" => amount
+ "captureAmount" => Utils.convert_decimal_to_string(amount)
}
response = Braspag::Poster.new(self.partial_capture_url).do_post(:partial_capture, data)
View
2 lib/rbraspag/protected_credit_card.rb
@@ -86,6 +86,8 @@ def self.just_click_shop(params = {})
case k
when :payment_method
data['justClickShopRequestWS'][v] = Braspag::Connection.instance.homologation? ? PAYMENT_METHODS[:braspag] : PAYMENT_METHODS[params[:payment_method]]
+ when :amount
+ data['justClickShopRequestWS'][v] = ("%.2f" % params[k].to_f).gsub('.', '')
else
data['justClickShopRequestWS'][v] = params[k] || ""
end
View
2 spec/credit_card_spec.rb
@@ -226,7 +226,7 @@
it "should post capture info" do
Braspag::CreditCard.partial_capture("order id qualquer", 10.0)
- request.body.should == {"orderId"=>"order id qualquer", "captureAmount"=>10.0, "merchantId"=>"um id qualquer"}
+ request.body.should == {"orderId"=>"order id qualquer", "captureAmount"=>"10,00", "merchantId"=>"um id qualquer"}
end
end
end
View
2 spec/protected_credit_card_spec.rb
@@ -256,7 +256,7 @@ def soap
it "should have Amount" do
described_class.just_click_shop(params)
- @savon_client_test.soap.body['justClickShopRequestWS']['Amount'].should eq 10.50
+ @savon_client_test.soap.body['justClickShopRequestWS']['Amount'].should eq "1050"
end
it "should have PaymentMethod" do

0 comments on commit e6e5842

Please sign in to comment.
Something went wrong with that request. Please try again.