spec/api/payment_service_spec.rb in adyen-1.4.1 vs spec/api/payment_service_spec.rb in adyen-1.5.0

- old
+ new

@@ -21,20 +21,31 @@ text('./payment:shopperReference').should == 'user-id' text('./payment:shopperEmail').should == 's.hopper@example.com' text('./payment:shopperIP').should == '61.294.12.12' text('./payment:shopperStatement').should == 'invoice number 123456' end - + it "includes the fraud offset" do text('./payment:fraudOffset').should == '30' end - + it "does not include the fraud offset if none is given" do @payment.params.delete(:fraud_offset) xpath('./payment:fraudOffset').should be_empty end + it "includes the given amount of `installments'" do + xpath('./payment:installments') do |amount| + amount.text('./common:value').should == '6' + end + end + + it "does not include the installments amount if none is given" do + @payment.params.delete(:installments) + xpath('./payment:installments').should be_empty + end + it "only includes shopper details for given parameters" do # TODO pretty lame, but for now it will do unless @method == "authorise_one_click_payment_request_body" || @method == "authorise_recurring_payment_request_body" @payment.params[:shopper].delete(:reference) xpath('./payment:shopperReference').should be_empty @@ -93,10 +104,13 @@ # Maestro UK/Solo only #:issue_number => , #:start_month => , #:start_year => , }, + :installments => { + :value => 6 + }, :recurring_detail_reference => 'RecurringDetailReference1', :fraud_offset => 30 } @payment = @object = Adyen::API::PaymentService.new(@params) end @@ -111,11 +125,11 @@ it_should_validate_request_param(:shopper) do @payment.params[:recurring] = true @payment.params[:shopper] = nil end - + it_should_validate_request_param(:fraud_offset) do @payment.params[:fraud_offset] = '' end [:reference, :email].each do |attr| @@ -126,11 +140,11 @@ end it "includes the creditcard details" do xpath('./payment:card') do |card| # there's no reason why Nokogiri should escape these characters, but as long as they're correct - card.text('./payment:holderName').should == 'Simon わくわく Hopper' + card.text('./payment:holderName').should == 'Simon わくわく Hopper' card.text('./payment:number').should == '4444333322221111' card.text('./payment:cvc').should == '737' card.text('./payment:expiryMonth').should == '12' card.text('./payment:expiryYear').should == '2012' end @@ -151,10 +165,11 @@ describe_response_from :authorise_payment, AUTHORISE_RESPONSE do it_should_return_params_for_each_xml_backend({ :psp_reference => '9876543210987654', :result_code => 'Authorised', :auth_code => '1234', + :additional_data => { "cardSummary" => "1111" }, :refusal_reason => '' }) describe "with a authorized response" do it "returns that the request was authorised" do @@ -224,12 +239,13 @@ response_with_fault_message(message).error.should == [:base, message] end it "prepends the error attribute with the given prefix, except for :base" do [ - ["validation 101 Invalid card number", [:card_number, 'is not a valid creditcard number']], - ["validation 130 Reference Missing", [:base, "validation 130 Reference Missing"]], + ["validation 101 Invalid card number", [:card_number, 'is not a valid creditcard number']], + ["validation 130 Reference Missing", [:base, "validation 130 Reference Missing"]], + ["validation 152 Invalid number of installments", [:base, "validation 152 Invalid number of installments"]], ].each do |message, error| response_with_fault_message(message).error(:card).should == error end end @@ -272,10 +288,11 @@ describe_response_from :authorise_recurring_payment, AUTHORISE_RESPONSE do it_should_return_params_for_each_xml_backend({ :psp_reference => '9876543210987654', :result_code => 'Authorised', :auth_code => '1234', + :additional_data => { "cardSummary" => "1111" }, :refusal_reason => '' }) end describe_request_body_of :authorise_one_click_payment do @@ -312,9 +329,10 @@ describe_response_from :authorise_one_click_payment, AUTHORISE_RESPONSE do it_should_return_params_for_each_xml_backend({ :psp_reference => '9876543210987654', :result_code => 'Authorised', :auth_code => '1234', + :additional_data => { "cardSummary" => "1111" }, :refusal_reason => '' }) end describe_modification_request_body_of :capture do