<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -19,8 +19,6 @@ module RSpreedly
       begin
         create!
       rescue RSpreedly::Error::Base
-        # gulp those errors down
-        # TODO - set self.errors or something?
         nil
       end      
     end
@@ -54,9 +52,18 @@ module RSpreedly
     # Pay an Invoice (more)
     # PUT /api/v4/[short site name]/invoices/[invoice token]/pay.xml
     def pay(payment)
+      begin
+        pay!(payment)
+      rescue RSpreedly::Error::Base
+        nil
+      end
+    end
+    
+    def pay!(payment)
       result = api_request(:put, &quot;/invoices/#{self.token}/pay.xml&quot;, :body =&gt; payment.to_xml(:outer =&gt; 'payment'))
       self.attributes = result[&quot;invoice&quot;]
-      true
+      true      
     end
+    
   end
 end
\ No newline at end of file</diff>
      <filename>lib/rspreedly/invoice.rb</filename>
    </modified>
    <modified>
      <diff>@@ -80,7 +80,7 @@ describe RSpreedly::Invoice do
   
   
   describe &quot;#pay&quot; do
-    
+
     before(:each) do
       @invoice = RSpreedly::Invoice.new(:token =&gt; &quot;5b1f186651dd988865c6573921ec87fa4bec23b8&quot;)
       @payment = RSpreedly::PaymentMethod::CreditCard.new(:number     =&gt; &quot;4222222222222&quot;, 
@@ -97,39 +97,64 @@ describe RSpreedly::Invoice do
       @invoice.pay(@payment).should be_true
     end   
       
+    it &quot;should return nil if not successful&quot; do
+      stub_http_with_fixture(&quot;payment_not_found.xml&quot;, 404)    
+      @invoice.pay(@payment).should be_nil
+    end
+    
+  end
+  
+  describe &quot;#pay!&quot; do
+    
+    before(:each) do
+      @invoice = RSpreedly::Invoice.new(:token =&gt; &quot;5b1f186651dd988865c6573921ec87fa4bec23b8&quot;)
+      @payment = RSpreedly::PaymentMethod::CreditCard.new(:number     =&gt; &quot;4222222222222&quot;, 
+                                                          :card_type  =&gt; &quot;visa&quot;, 
+                                                          :verification_value =&gt; &quot;234&quot;, 
+                                                          :month      =&gt; 1, 
+                                                          :year       =&gt; 2011, 
+                                                          :first_name =&gt; &quot;Joe&quot;, 
+                                                          :last_name  =&gt; &quot;Bob&quot;)
+    end 
+   
+    it &quot;should return true if successful&quot; do
+      stub_http_with_fixture(&quot;payment_success.xml&quot;, 200)    
+      @invoice.pay!(@payment).should be_true
+    end   
+      
     it &quot;should update the Invoice if successful&quot; do
       stub_http_with_fixture(&quot;payment_success.xml&quot;, 200)    
       
       lambda{
-        @invoice.pay(@payment)
+        @invoice.pay!(@payment)
       }.should change(@invoice, :closed).to(true)
     end
     
     it &quot;should raise NotFound if the invoice doesn't exist&quot; do
       stub_http_with_fixture(&quot;payment_not_found.xml&quot;, 404)    
       lambda{
-        @invoice.pay(@payment)
+        @invoice.pay!(@payment)
       }.should raise_error(RSpreedly::Error::NotFound)      
     end
     
     it &quot;should raise GatewayTimeout if the payment gateway times out&quot; do
       stub_http_with_code(504)    
       lambda{
-        @invoice.pay(@payment)
+        @invoice.pay!(@payment)
       }.should raise_error(RSpreedly::Error::GatewayTimeout)
     end
     
     it &quot;should raise BadRequest if the payment method is invalid&quot; do
       stub_http_with_fixture(&quot;payment_invalid.xml&quot;, 422)      
       lambda{
-        @invoice.pay(@payment)
+        @invoice.pay!(@payment)
       }.should raise_error(RSpreedly::Error::BadRequest)
     end
       
       it &quot;should raise Forbidden if the invoice is already paid&quot; do
         stub_http_with_fixture(&quot;payment_already_paid.xml&quot;, 403)            
         lambda{
-          @invoice.pay(@payment)
+          @invoice.pay!(@payment)
         }.should raise_error(RSpreedly::Error::Forbidden)      
       end    
   end</diff>
      <filename>spec/invoice_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>73ffe76504a9a885b2a63a28f27a899e075615a1</id>
    </parent>
  </parents>
  <author>
    <name>Richard Livsey</name>
    <email>richard@livsey.org</email>
  </author>
  <url>http://github.com/rlivsey/rspreedly/commit/5d5fe8d0450571fd104075da93f1eb41b6c66c4c</url>
  <id>5d5fe8d0450571fd104075da93f1eb41b6c66c4c</id>
  <committed-date>2009-11-03T16:38:58-08:00</committed-date>
  <authored-date>2009-11-03T16:38:58-08:00</authored-date>
  <message>add Invoice#pay! for raising exceptions and use Invoice#pay for safe version</message>
  <tree>05e9c2aa25874a0435daf220ba737f711311e41b</tree>
  <committer>
    <name>Richard Livsey</name>
    <email>richard@livsey.org</email>
  </committer>
</commit>
