diff --git a/test/remote/gateways/remote_stripe_test.rb b/test/remote/gateways/remote_stripe_test.rb index 603386caaef..d42d0e4296b 100644 --- a/test/remote/gateways/remote_stripe_test.rb +++ b/test/remote/gateways/remote_stripe_test.rb @@ -93,6 +93,25 @@ def test_successful_store assert_equal @credit_card.last_digits, first_card["last4"] end + def test_successful_store_with_existing_customer + assert response = @gateway.store(@credit_card, {:currency => @currency, :description => "Active Merchant Test Customer"}) + assert_success response + + assert response = @gateway.store(@new_credit_card, {:customer => response.params['id'], :currency => @currency, :description => "Active Merchant Test Customer", :email => "email@example.com"}) + assert_success response + assert_equal 2, response.responses.size + + card_response = response.responses[0] + assert_equal "card", card_response.params["object"] + assert_equal @new_credit_card.last_digits, card_response.params["last4"] + + customer_response = response.responses[1] + assert_equal "customer", customer_response.params["object"] + assert_equal "Active Merchant Test Customer", customer_response.params["description"] + assert_equal "email@example.com", customer_response.params["email"] + assert_equal 2, customer_response.params["cards"]["count"] + end + def test_successful_update creation = @gateway.store(@credit_card, {:description => "Active Merchant Update Customer"}) assert response = @gateway.update(creation.params['id'], @new_credit_card) diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb index bda7fcbf655..c41b18fffec 100644 --- a/test/unit/gateways/stripe_test.rb +++ b/test/unit/gateways/stripe_test.rb @@ -30,7 +30,7 @@ def test_successful_new_customer_with_card def test_successful_new_card @gateway.expects(:ssl_request).returns(successful_new_card_response) - assert response = @gateway.store(@credit_card, @options.merge(:customer => 'cus_3sgheFxeBgTQ3M')) + assert response = @gateway.store(@credit_card, :customer => 'cus_3sgheFxeBgTQ3M') assert_instance_of MultiResponse, response assert_success response @@ -38,6 +38,20 @@ def test_successful_new_card assert response.test? end + def test_successful_new_card_and_customer_update + @gateway.expects(:ssl_request).twice.returns(successful_new_card_response, successful_new_customer_response) + + assert response = @gateway.store(@credit_card, :customer => 'cus_3sgheFxeBgTQ3M', :email => 'test@test.com') + assert_instance_of MultiResponse, response + assert_success response + + assert_equal 'card_483etw4er9fg4vF3sQdrt3FG', response.authorization + assert_equal 2, response.responses.size + assert_equal 'card_483etw4er9fg4vF3sQdrt3FG', response.responses[0].authorization + assert_equal 'cus_3sgheFxeBgTQ3M', response.responses[1].authorization + assert response.test? + end + def test_successful_new_default_card @gateway.expects(:ssl_request).twice.returns(successful_new_card_response, successful_new_customer_response)