spreedly-core-ruby 0.1.9 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +29 -78
- data/lib/spreedly-core-ruby/version.rb +1 -1
- data/test/configuration_test.rb +3 -1
- data/test/spreedly_core_test.rb +34 -34
- metadata +66 -109
    
        data/README.md
    CHANGED
    
    | @@ -2,7 +2,7 @@ SpreedlyCore | |
| 2 2 | 
             
            ======
         | 
| 3 3 | 
             
            spreedly-core-ruby is a Ruby library for accessing the [Spreedly Core API](https://spreedlycore.com/). Spreedly Core is a Software-as-a-Service billing solution that serves two major functions for companies and developers.
         | 
| 4 4 |  | 
| 5 | 
            -
            * First, it removes your [PCI Compliance](https://www.pcisecuritystandards.org/) requirement by pushing the card data handling and storage outside of your application. This is possible by having your customers POST their credit card info to the Spreedly Core service while embedding a transparent redirect URL back to your application (see "Submit payment form" on [the quick start guide](https://spreedlycore.com/manual/quickstart)). | 
| 5 | 
            +
            * First, it removes your [PCI Compliance](https://www.pcisecuritystandards.org/) requirement by pushing the card data handling and storage outside of your application. This is possible by having your customers POST their credit card info to the Spreedly Core service while embedding a transparent redirect URL back to your application (see "Submit payment form" on [the quick start guide](https://spreedlycore.com/manual/quickstart)).
         | 
| 6 6 | 
             
            * Second, it removes any possibility of your gateway locking you in by owning your customer billing data (yes, this happens). By allowing you to charge any card against whatever gateways you as a company have signed up for, you retain all of your customer data and can switch between gateways as you please. Also, expanding internationally won't require an additional technical integration with yet another gateway.
         | 
| 7 7 |  | 
| 8 8 | 
             
            Credit where credit is due: our friends over at [403 Labs](http://www.403labs.com/) carried most of the weight in cutting the initial version of this gem, and we can't thank them enough for their work.
         | 
| @@ -34,20 +34,20 @@ Now that you have a test gateway set up, we'll need to set up your payment form | |
| 34 34 | 
             
            	        <input name="api_login" type="hidden" value="Ll6fAtoVSTyVMlJEmtpoJV8Shw5" />
         | 
| 35 35 | 
             
            	        <label for="credit_card_first_name">First name</label>
         | 
| 36 36 | 
             
            	        <input id="credit_card_first_name" name="credit_card[first_name]" type="text" />
         | 
| 37 | 
            -
             | 
| 37 | 
            +
             | 
| 38 38 | 
             
            	        <label for="credit_card_last_name">Last name</label>
         | 
| 39 39 | 
             
            	        <input id="credit_card_last_name" name="credit_card[last_name]" type="text" />
         | 
| 40 | 
            -
             | 
| 40 | 
            +
             | 
| 41 41 | 
             
            	        <label for="credit_card_number">Card Number</label>
         | 
| 42 42 | 
             
            	        <input id="credit_card_number" name="credit_card[number]" type="text" />
         | 
| 43 | 
            -
             | 
| 43 | 
            +
             | 
| 44 44 | 
             
            	        <label for="credit_card_verification_value">Security Code</label>
         | 
| 45 45 | 
             
            	        <input id="credit_card_verification_value" name="credit_card[verification_value]" type="text" />
         | 
| 46 | 
            -
             | 
| 46 | 
            +
             | 
| 47 47 | 
             
            	        <label for="credit_card_month">Expires on</label>
         | 
| 48 48 | 
             
            	        <input id="credit_card_month" name="credit_card[month]" type="text" />
         | 
| 49 49 | 
             
            	        <input id="credit_card_year" name="credit_card[year]" type="text" />
         | 
| 50 | 
            -
             | 
| 50 | 
            +
             | 
| 51 51 | 
             
            	        <button type='submit'>Submit Payment</button>
         | 
| 52 52 | 
             
            	    </fieldset>
         | 
| 53 53 | 
             
            	</form>
         | 
| @@ -56,25 +56,10 @@ Take special note of the **api_login** and **redirect_url** params hidden in the | |
| 56 56 |  | 
| 57 57 | 
             
            A note about test card data
         | 
| 58 58 | 
             
            ----------------
         | 
| 59 | 
            -
            If you've just signed up and have not entered your billing information (or selected a Heroku paid plan), you will only be permitted to deal with test credit card data. | 
| 60 | 
            -
             | 
| 61 | 
            -
            DO NOT USE REAL CREDIT CARD DATA UNTIL YOUR APPLICATION IS LIVE.
         | 
| 62 | 
            -
             | 
| 63 | 
            -
            * **Visa**
         | 
| 64 | 
            -
            	* Good Card - 4111111111111111
         | 
| 65 | 
            -
            	* Failed Card - 4012888888881881
         | 
| 66 | 
            -
            * **MasterCard**
         | 
| 67 | 
            -
            	* Good Card - 5555555555554444
         | 
| 68 | 
            -
            	* Failed Card - 5105105105105100
         | 
| 69 | 
            -
            * **American Express**
         | 
| 70 | 
            -
            	* Good Card - 378282246310005
         | 
| 71 | 
            -
            	* Failed Card - 371449635398431
         | 
| 72 | 
            -
            * **Discover**
         | 
| 73 | 
            -
            	* Failed Card - 6011111111111117
         | 
| 74 | 
            -
            	* Failed Card - 6011000990139424
         | 
| 59 | 
            +
            If you've just signed up and have not entered your billing information (or selected a Heroku paid plan), you will only be permitted to deal with [test credit card data](https://spreedlycore.com/manual/test-data).
         | 
| 75 60 |  | 
| 76 61 | 
             
            Once you've created your web form and submitted one of the test cards above, you should be returned to your app with a token identifier by which to identify your newly created payment method. Let's go ahead and look up that payment method by the token returned to your app, and we'll charge $5.50 to it.
         | 
| 77 | 
            -
             | 
| 62 | 
            +
             | 
| 78 63 | 
             
                payment_token = 'abc123' # extracted from the URL params
         | 
| 79 64 | 
             
                payment_method = SpreedlyCore::PaymentMethod.find(payment_token)
         | 
| 80 65 | 
             
                if payment_method.valid?
         | 
| @@ -83,8 +68,6 @@ Once you've created your web form and submitted one of the test cards above, you | |
| 83 68 | 
             
                else
         | 
| 84 69 | 
             
                  flash[:notice] = "Woops!\n" + payment_method.errors.join("\n")
         | 
| 85 70 | 
             
                end
         | 
| 86 | 
            -
                
         | 
| 87 | 
            -
            One final point to take note of is that Spreedly Core does no validation of the information passed in by the customer. We simply return them back to your application, and it's up to you to check for any errors in the payment method before charging against it.
         | 
| 88 71 |  | 
| 89 72 | 
             
            Saving Payment Methods
         | 
| 90 73 | 
             
            ----------
         | 
| @@ -97,27 +80,20 @@ Spreedly Core allows you to retain payment methods provided by your customer for | |
| 97 80 | 
             
                  retain_transaction = payment_method.retain
         | 
| 98 81 | 
             
                  retain_transaction.succeeded? # true
         | 
| 99 82 | 
             
                end
         | 
| 100 | 
            -
             | 
| 101 | 
            -
            Payment methods that you no longer want to retain can be redacted from Spreedly Core.  | 
| 83 | 
            +
             | 
| 84 | 
            +
            Payment methods that you no longer want to retain can be redacted from Spreedly Core. A redacted payment method has its sensitive information removed.
         | 
| 102 85 |  | 
| 103 86 | 
             
                payment_token = 'abc123' # extracted from the URL params
         | 
| 104 87 | 
             
                payment_method = SpreedlyCore::PaymentMethod.find(payment_token)
         | 
| 105 88 | 
             
                redact_transaction = payment_method.redact
         | 
| 106 89 | 
             
                redact_transaction.succeeded? # true
         | 
| 107 | 
            -
             | 
| 90 | 
            +
             | 
| 108 91 | 
             
            Usage Overview
         | 
| 109 92 | 
             
            ----------
         | 
| 110 93 | 
             
            Make a purchase against a payment method
         | 
| 111 94 |  | 
| 112 95 | 
             
                purchase_transaction = payment_method.purchase(1245)
         | 
| 113 | 
            -
                
         | 
| 114 | 
            -
            Retain a payment method for future use
         | 
| 115 | 
            -
             | 
| 116 | 
            -
                redact_transaction = payment_method.retain
         | 
| 117 | 
            -
                
         | 
| 118 | 
            -
            Redact a previously retained payment method:
         | 
| 119 96 |  | 
| 120 | 
            -
                redact_transaction = payment_method.redact
         | 
| 121 97 |  | 
| 122 98 | 
             
            Make an authorize request against a payment method, then capture the payment
         | 
| 123 99 |  | 
| @@ -130,7 +106,7 @@ Make an authorize request against a payment method, then capture the payment | |
| 130 106 | 
             
                authorize.succeeded? # true
         | 
| 131 107 | 
             
                authorized.capture # Capture the full amount
         | 
| 132 108 | 
             
                capture.succeeded? # true
         | 
| 133 | 
            -
             | 
| 109 | 
            +
             | 
| 134 110 | 
             
            Void a previous purchase:
         | 
| 135 111 |  | 
| 136 112 | 
             
                purchase_transaction.void # void the purchase
         | 
| @@ -139,24 +115,24 @@ Credit (refund) a previous purchase: | |
| 139 115 |  | 
| 140 116 | 
             
                purchase_transaction = payment_method.purchase(100) # make a purchase
         | 
| 141 117 | 
             
                purchase_transaction.credit
         | 
| 142 | 
            -
                purchase_transaction.succeeded? # true | 
| 118 | 
            +
                purchase_transaction.succeeded? # true
         | 
| 143 119 |  | 
| 144 120 | 
             
            Credit part of a previous purchase:
         | 
| 145 121 |  | 
| 146 122 | 
             
                purchase_transaction = payment_method.purchase(100) # make a purchase
         | 
| 147 123 | 
             
                purchase_transaction.credit(50) # provide a partial credit
         | 
| 148 | 
            -
                purchase_transaction.succeeded? # true | 
| 124 | 
            +
                purchase_transaction.succeeded? # true
         | 
| 149 125 |  | 
| 150 126 |  | 
| 151 127 | 
             
            Handling Exceptions
         | 
| 152 128 | 
             
            --------
         | 
| 153 129 | 
             
            There are 3 types of exceptions which can be raised by the library:
         | 
| 154 130 |  | 
| 155 | 
            -
            1. SpreedlyCore::TimeOutError is raised if communication with Spreedly Core takes longer than 10 seconds | 
| 131 | 
            +
            1. SpreedlyCore::TimeOutError is raised if communication with Spreedly Core takes longer than 10 seconds
         | 
| 156 132 | 
             
            2. SpreedlyCore::InvalidResponse is raised when the response code is unexpected (I.E. we expect a HTTP response code of 200 bunt instead got a 500) or if the response does not contain an expected attribute. For example, the response from retaining a payment method should contain an XML attribute of "transaction". If this is not found (for example a HTTP response 404 or 500 is returned), then an InvalidResponse is raised.
         | 
| 157 133 | 
             
            3. SpreedlyCore::UnprocessableRequest is raised when the response code is 422. This denotes a validation error where one or more of the data fields submitted were not valid, or the whole record was unable to be saved/updated. Inspection of the exception message will give an explanation of the issue.
         | 
| 158 134 |  | 
| 159 | 
            -
             | 
| 135 | 
            +
             | 
| 160 136 | 
             
            Each of TimeOutError, InvalidResponse, and UnprocessableRequest subclass SpreedlyCore::Error.
         | 
| 161 137 |  | 
| 162 138 | 
             
            For example, let's look up a payment method that does not exist:
         | 
| @@ -164,35 +140,10 @@ For example, let's look up a payment method that does not exist: | |
| 164 140 | 
             
                begin
         | 
| 165 141 | 
             
                  payment_method = SpreedlyCore::PaymentMethod.find("NOT-FOUND")
         | 
| 166 142 | 
             
                rescue SpreedlyCore::InvalidResponse => e
         | 
| 167 | 
            -
                  puts "Record does not exist"
         | 
| 168 143 | 
             
                  puts e.inspect
         | 
| 169 | 
            -
                end | 
| 144 | 
            +
                end
         | 
| 170 145 |  | 
| 171 | 
            -
               
         | 
| 172 | 
            -
            Additional Field Validation
         | 
| 173 | 
            -
            ----------
         | 
| 174 | 
            -
            The Spreely Core API provides validation of the credit card number, security code, and
         | 
| 175 | 
            -
            first and last name. In most cases this is enough; however, sometimes you may want to
         | 
| 176 | 
            -
            enforce the full billing information as well. The following example illustrates how this can be accomplished.
         | 
| 177 146 |  | 
| 178 | 
            -
                SpreedlyCore.configure
         | 
| 179 | 
            -
                SpreedlyCore::PaymentMethod.additional_required_cc_fields :address1, :city, :state, :zip
         | 
| 180 | 
            -
                
         | 
| 181 | 
            -
                master_card_data = SpreedlyCore::TestHelper.cc_data(:master)
         | 
| 182 | 
            -
                token = SpreedlyCore::PaymentMethod.create_test_token(master_card_data)
         | 
| 183 | 
            -
                
         | 
| 184 | 
            -
                payment_method = SpreedlyCore::PaymentMethod.find(token)
         | 
| 185 | 
            -
                payment_method.valid? # false
         | 
| 186 | 
            -
                payment_method.errors # ["Address1 can't be blank", "City can't be blank", "State can't be blank", "Zip can't be blank"]
         | 
| 187 | 
            -
                
         | 
| 188 | 
            -
                master_card_data = SpreedlyCore::TestHelper.cc_data(:master, :credit_card => {:address1 => "742 Evergreen Terrace", :city => "Springfield", :state => "IL", 62701})
         | 
| 189 | 
            -
                token = SpreedlyCore::PaymentMethod.create_test_token(master_card_data)
         | 
| 190 | 
            -
                
         | 
| 191 | 
            -
                payment_method = SpreedlyCore::PaymentMethod.find(token)
         | 
| 192 | 
            -
                payment_method.valid? # returns true
         | 
| 193 | 
            -
                payment_method.errors # []
         | 
| 194 | 
            -
             | 
| 195 | 
            -
               
         | 
| 196 147 | 
             
            Configuring SpreedlyCore for Use in Production (Rails example)
         | 
| 197 148 | 
             
            ----------
         | 
| 198 149 | 
             
            When you're ready for primetime, you'll need to complete a couple more steps to start processing real transactions.
         | 
| @@ -203,38 +154,38 @@ When you're ready for primetime, you'll need to complete a couple more steps to | |
| 203 154 | 
             
            For this example, I will be using an Authorize.net account that only has a login and password credential.
         | 
| 204 155 |  | 
| 205 156 | 
             
                SpreedlyCore.configure
         | 
| 206 | 
            -
             | 
| 157 | 
            +
             | 
| 207 158 | 
             
                gateway = SpreedlyCore::Gateway.create(:login => 'my_authorize_login', :password => 'my_authorize_password', :gateway_type => 'authorize_net')
         | 
| 208 159 | 
             
                gateway.use!
         | 
| 209 | 
            -
             | 
| 160 | 
            +
             | 
| 210 161 | 
             
                puts "Authorize.net gateway token is #{gateway.token}"
         | 
| 211 | 
            -
             | 
| 162 | 
            +
             | 
| 212 163 | 
             
            For most users, you will start off using only one gateway token, and as such can configure it as an environment variable to hold your gateway token. In addition to the previous environment variables, the `SpreedlyCore.configure` method will also look for a SPREEDLYCORE_GATEWAY_TOKEN environment value.
         | 
| 213 164 |  | 
| 214 165 | 
             
            	# create an initializer at config/initializers/spreedly_core.rb
         | 
| 215 166 | 
             
                # values already set for ENV['SPREEDLYCORE_API_LOGIN'], ENV['SPREEDLYCORE_API_SECRET'], and ENV['SPREEDLYCORE_GATEWAY_TOKEN']
         | 
| 216 167 | 
             
                SpreedlyCore.configure
         | 
| 217 | 
            -
             | 
| 168 | 
            +
             | 
| 218 169 | 
             
            If you wish to require additional credit card fields, the initializer is the best place to set this up.
         | 
| 219 170 |  | 
| 220 171 | 
             
                SpreedlyCore.configure
         | 
| 221 172 | 
             
                SpreedlyCore::PaymentMethod.additional_required_cc_fields :address1, :city, :state, :zip
         | 
| 222 | 
            -
             | 
| 173 | 
            +
             | 
| 223 174 | 
             
            Using Multiple Gateways
         | 
| 224 175 | 
             
            ------------
         | 
| 225 176 | 
             
            For those using multiple gateway tokens, there is a class variable that holds the active gateway token. Before running any sort of transaction against a payment method, you'll need to set the gateway token that you wish to charge against.
         | 
| 226 177 |  | 
| 227 178 | 
             
                SpreedlyCore.configure
         | 
| 228 | 
            -
             | 
| 179 | 
            +
             | 
| 229 180 | 
             
                SpreedlyCore.gateway_token(paypal_gateway_token)
         | 
| 230 181 | 
             
                SpreedlyCore::PaymentMethod.find(pm_token).purchase(550)
         | 
| 231 | 
            -
             | 
| 182 | 
            +
             | 
| 232 183 | 
             
                SpreedlyCore.gateway_token(authorize_gateway_token)
         | 
| 233 184 | 
             
                SpreedlyCore::PaymentMethod.find(pm_token).purchase(2885)
         | 
| 234 | 
            -
             | 
| 185 | 
            +
             | 
| 235 186 | 
             
                SpreedlyCore.gateway_token(braintree_gateway_token)
         | 
| 236 187 | 
             
                SpreedlyCore::PaymentMethod.find(pm_token).credit(150)
         | 
| 237 | 
            -
             | 
| 188 | 
            +
             | 
| 238 189 | 
             
            Creating Payment Types Programatically
         | 
| 239 190 | 
             
            ------------
         | 
| 240 191 | 
             
            **Please note that this practice requires you to be PCI compliant!**
         | 
| @@ -248,14 +199,14 @@ In special cases, you may want to create payment types programmatically and will | |
| 248 199 | 
             
            The example below illustrates both a successful payment method creation, and how to handle one with errors.
         | 
| 249 200 |  | 
| 250 201 | 
             
            	SpreedlyCore.configure
         | 
| 251 | 
            -
             | 
| 202 | 
            +
             | 
| 252 203 | 
             
            	pm_transaction = SpreedlyCore::PaymentMethod.create(:credit_card => good_card_hash)
         | 
| 253 204 | 
             
            	pm_token = pm_transaction.payment_method.token
         | 
| 254 205 | 
             
            	puts "Payment method token is #{pm_token}"
         | 
| 255 | 
            -
             | 
| 206 | 
            +
             | 
| 256 207 | 
             
            	retain_transaction = pm_transaction.payment_method.retain
         | 
| 257 208 | 
             
            	retain_transaction.succeeded? # true
         | 
| 258 | 
            -
             | 
| 209 | 
            +
             | 
| 259 210 | 
             
            	begin
         | 
| 260 211 | 
             
                  pm_transaction = SpreedlyCore::PaymentMethod.create(:credit_card => bad_card_hash)
         | 
| 261 212 | 
             
                rescue Exception => e
         | 
    
        data/test/configuration_test.rb
    CHANGED
    
    | @@ -25,13 +25,15 @@ module SpreedlyCore | |
| 25 25 |  | 
| 26 26 | 
             
                  ENV['SPREEDLYCORE_API_LOGIN'] = old_api_login
         | 
| 27 27 | 
             
                  ENV['SPREEDLYCORE_API_SECRET'] = old_api_secret
         | 
| 28 | 
            -
                  ENV['SPREEDLYCORE_GATEWAY_TOKEN'] =  | 
| 28 | 
            +
                  ENV['SPREEDLYCORE_GATEWAY_TOKEN'] = 'any_value'
         | 
| 29 29 |  | 
| 30 30 | 
             
                  SpreedlyCore.gateway_token = nil
         | 
| 31 31 | 
             
                  assert_nothing_raised ArgumentError do
         | 
| 32 32 | 
             
                    SpreedlyCore.configure
         | 
| 33 33 | 
             
                  end
         | 
| 34 34 | 
             
                  assert_not_nil SpreedlyCore.gateway_token
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                  ENV['SPREEDLYCORE_GATEWAY_TOKEN'] = old_gateway_token
         | 
| 35 37 | 
             
                ensure
         | 
| 36 38 | 
             
                  $VERBOSE = old_verbose
         | 
| 37 39 | 
             
                end
         | 
    
        data/test/spreedly_core_test.rb
    CHANGED
    
    | @@ -28,22 +28,22 @@ module SpreedlyCore | |
| 28 28 | 
             
                  assert_equal 4, payment_method.month
         | 
| 29 29 | 
             
                  assert_equal 2015, payment_method.year
         | 
| 30 30 | 
             
                end
         | 
| 31 | 
            -
             | 
| 31 | 
            +
             | 
| 32 32 | 
             
                def test_can_find_payment_method
         | 
| 33 33 | 
             
                  payment_method = given_a_payment_method
         | 
| 34 34 | 
             
                  assert PaymentMethod.find(payment_method.token)
         | 
| 35 35 | 
             
                end
         | 
| 36 | 
            -
             | 
| 36 | 
            +
             | 
| 37 37 | 
             
                def test_not_found_payment_method
         | 
| 38 38 | 
             
                  assert_raises InvalidResponse do
         | 
| 39 39 | 
             
                    PaymentMethod.find("NOT-FOUND")
         | 
| 40 40 | 
             
                  end
         | 
| 41 41 | 
             
                end
         | 
| 42 | 
            -
             | 
| 42 | 
            +
             | 
| 43 43 | 
             
                def test_can_retain_payment_method
         | 
| 44 44 | 
             
                  given_a_retained_transaction
         | 
| 45 45 | 
             
                end
         | 
| 46 | 
            -
             | 
| 46 | 
            +
             | 
| 47 47 | 
             
                # Here we change the token to get an invalid response from spreedly core
         | 
| 48 48 | 
             
                def test_bad_response_on_retain
         | 
| 49 49 | 
             
                  payment_method = given_a_payment_method
         | 
| @@ -52,7 +52,7 @@ module SpreedlyCore | |
| 52 52 | 
             
                    payment_method.retain
         | 
| 53 53 | 
             
                  end
         | 
| 54 54 | 
             
                end
         | 
| 55 | 
            -
             | 
| 55 | 
            +
             | 
| 56 56 | 
             
                def test_can_not_retain_after_redact
         | 
| 57 57 | 
             
                  retained_transaction = given_a_retained_transaction
         | 
| 58 58 | 
             
                  payment_method = retained_transaction.payment_method
         | 
| @@ -61,11 +61,11 @@ module SpreedlyCore | |
| 61 61 | 
             
                  retained_transaction2 = payment_method.retain
         | 
| 62 62 | 
             
                  assert_false retained_transaction2.succeeded?
         | 
| 63 63 | 
             
                end
         | 
| 64 | 
            -
             | 
| 64 | 
            +
             | 
| 65 65 | 
             
                def test_can_redact_payment_method
         | 
| 66 66 | 
             
                  given_a_redacted_transaction
         | 
| 67 67 | 
             
                end
         | 
| 68 | 
            -
             | 
| 68 | 
            +
             | 
| 69 69 | 
             
                # Here we change the token to get an invalid response from spreedly core
         | 
| 70 70 | 
             
                def test_bad_response_on_redact
         | 
| 71 71 | 
             
                  payment_method = given_a_payment_method
         | 
| @@ -74,11 +74,11 @@ module SpreedlyCore | |
| 74 74 | 
             
                    payment_method.redact
         | 
| 75 75 | 
             
                  end
         | 
| 76 76 | 
             
                end
         | 
| 77 | 
            -
             | 
| 77 | 
            +
             | 
| 78 78 | 
             
                def test_can_make_purchase
         | 
| 79 79 | 
             
                  given_a_purchase
         | 
| 80 80 | 
             
                end
         | 
| 81 | 
            -
             | 
| 81 | 
            +
             | 
| 82 82 | 
             
                # Here we change the token to get an invalid response from spreedly core
         | 
| 83 83 | 
             
                def test_bad_response_on_purchase
         | 
| 84 84 | 
             
                  payment_method = given_a_payment_method
         | 
| @@ -87,11 +87,11 @@ module SpreedlyCore | |
| 87 87 | 
             
                    payment_method.purchase(20)
         | 
| 88 88 | 
             
                  end
         | 
| 89 89 | 
             
                end
         | 
| 90 | 
            -
             | 
| 90 | 
            +
             | 
| 91 91 | 
             
                def test_can_authorize
         | 
| 92 92 | 
             
                  given_an_authorized_transaction
         | 
| 93 93 | 
             
                end
         | 
| 94 | 
            -
             | 
| 94 | 
            +
             | 
| 95 95 | 
             
                # Here we change the token to get an invalid response from spreedly core
         | 
| 96 96 | 
             
                def test_bad_response_on_authorize
         | 
| 97 97 | 
             
                  payment_method = given_a_payment_method
         | 
| @@ -100,26 +100,26 @@ module SpreedlyCore | |
| 100 100 | 
             
                    payment_method.authorize(20)
         | 
| 101 101 | 
             
                  end
         | 
| 102 102 | 
             
                end
         | 
| 103 | 
            -
             | 
| 103 | 
            +
             | 
| 104 104 | 
             
                def test_payment_failed
         | 
| 105 105 | 
             
                  payment_method = given_a_payment_method(:master, :card_number => :failed)
         | 
| 106 | 
            -
             | 
| 106 | 
            +
             | 
| 107 107 | 
             
                  assert transaction = payment_method.purchase(100)
         | 
| 108 108 | 
             
                  assert !transaction.succeeded?
         | 
| 109 | 
            -
                  assert_equal("Unable to  | 
| 109 | 
            +
                  assert_equal("Unable to process the transaction.",
         | 
| 110 110 | 
             
                               transaction.message)
         | 
| 111 | 
            -
             | 
| 111 | 
            +
             | 
| 112 112 | 
             
                  assert_equal("Unable to process the transaction.", transaction.response.message)
         | 
| 113 113 | 
             
                end
         | 
| 114 | 
            -
             | 
| 114 | 
            +
             | 
| 115 115 | 
             
                def test_can_capture_after_authorize
         | 
| 116 116 | 
             
                  given_a_capture
         | 
| 117 117 | 
             
                end
         | 
| 118 | 
            -
             | 
| 118 | 
            +
             | 
| 119 119 | 
             
                def test_can_capture_partial_after_authorize
         | 
| 120 120 | 
             
                  given_a_capture 50
         | 
| 121 121 | 
             
                end
         | 
| 122 | 
            -
             | 
| 122 | 
            +
             | 
| 123 123 | 
             
                # Here we change the token to get an invalid response from spreedly core
         | 
| 124 124 | 
             
                def test_bad_response_on_capture_after_authorize
         | 
| 125 125 | 
             
                  transaction = given_an_authorized_transaction
         | 
| @@ -128,11 +128,11 @@ module SpreedlyCore | |
| 128 128 | 
             
                    transaction.capture
         | 
| 129 129 | 
             
                  end
         | 
| 130 130 | 
             
                end
         | 
| 131 | 
            -
             | 
| 131 | 
            +
             | 
| 132 132 | 
             
                def test_can_void_after_purchase
         | 
| 133 133 | 
             
                  given_a_purchase_void
         | 
| 134 134 | 
             
                end
         | 
| 135 | 
            -
             | 
| 135 | 
            +
             | 
| 136 136 | 
             
                # Here we change the token to get an invalid response from spreedly core
         | 
| 137 137 | 
             
                def test_bad_response_on_void
         | 
| 138 138 | 
             
                  purchase = given_a_purchase
         | 
| @@ -141,15 +141,15 @@ module SpreedlyCore | |
| 141 141 | 
             
                    purchase.void
         | 
| 142 142 | 
             
                  end
         | 
| 143 143 | 
             
                end
         | 
| 144 | 
            -
             | 
| 144 | 
            +
             | 
| 145 145 | 
             
                def test_can_void_after_capture
         | 
| 146 146 | 
             
                  given_a_capture_void
         | 
| 147 147 | 
             
                end
         | 
| 148 | 
            -
             | 
| 148 | 
            +
             | 
| 149 149 | 
             
                def test_can_credit_after_purchase
         | 
| 150 150 | 
             
                  given_a_purchase_credit
         | 
| 151 151 | 
             
                end
         | 
| 152 | 
            -
             | 
| 152 | 
            +
             | 
| 153 153 | 
             
                # Here we change the token to get an invalid response from spreedly core
         | 
| 154 154 | 
             
                def test_bad_response_on_credit
         | 
| 155 155 | 
             
                  purchase = given_a_purchase
         | 
| @@ -158,38 +158,38 @@ module SpreedlyCore | |
| 158 158 | 
             
                    purchase.credit
         | 
| 159 159 | 
             
                  end
         | 
| 160 160 | 
             
                end
         | 
| 161 | 
            -
             | 
| 161 | 
            +
             | 
| 162 162 | 
             
                def test_can_credit_partial_after_purchase
         | 
| 163 163 | 
             
                  given_a_purchase_credit(100, 50)
         | 
| 164 164 | 
             
                end
         | 
| 165 | 
            -
             | 
| 165 | 
            +
             | 
| 166 166 | 
             
                def test_can_credit_after_capture
         | 
| 167 167 | 
             
                  given_a_capture_credit
         | 
| 168 168 | 
             
                end
         | 
| 169 | 
            -
             | 
| 169 | 
            +
             | 
| 170 170 | 
             
                def test_can_credit_partial_after_capture
         | 
| 171 171 | 
             
                  given_a_capture_credit(50, 25)
         | 
| 172 172 | 
             
                end
         | 
| 173 | 
            -
             | 
| 174 | 
            -
             | 
| 173 | 
            +
             | 
| 174 | 
            +
             | 
| 175 175 | 
             
                def test_can_enforce_additional_payment_method_validations
         | 
| 176 176 | 
             
                  PaymentMethod.additional_required_cc_fields :state
         | 
| 177 | 
            -
             | 
| 177 | 
            +
             | 
| 178 178 | 
             
                  token = PaymentMethod.create_test_token(cc_data(:master))
         | 
| 179 179 | 
             
                  assert payment_method = PaymentMethod.find(token)
         | 
| 180 180 | 
             
                  assert !payment_method.valid?
         | 
| 181 181 | 
             
                  assert_equal 1, payment_method.errors.size
         | 
| 182 | 
            -
             | 
| 182 | 
            +
             | 
| 183 183 | 
             
                  assert_equal "State can't be blank", payment_method.errors.first
         | 
| 184 | 
            -
             | 
| 184 | 
            +
             | 
| 185 185 | 
             
                  token =  PaymentMethod.
         | 
| 186 186 | 
             
                    create_test_token(cc_data(:master, :credit_card => {:state => "IL"}))
         | 
| 187 | 
            -
             | 
| 187 | 
            +
             | 
| 188 188 | 
             
                  assert payment_method = PaymentMethod.find(token)
         | 
| 189 | 
            -
             | 
| 189 | 
            +
             | 
| 190 190 | 
             
                  assert payment_method.valid?
         | 
| 191 191 | 
             
                end
         | 
| 192 | 
            -
             | 
| 192 | 
            +
             | 
| 193 193 | 
             
                def test_can_list_supported_gateways
         | 
| 194 194 | 
             
                  assert Gateway.supported_gateways.any?
         | 
| 195 195 | 
             
                end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,124 +1,91 @@ | |
| 1 | 
            -
            --- !ruby/object:Gem::Specification | 
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: spreedly-core-ruby
         | 
| 3 | 
            -
            version: !ruby/object:Gem::Version | 
| 4 | 
            -
               | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.2.0
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 | 
            -
              segments: 
         | 
| 7 | 
            -
              - 0
         | 
| 8 | 
            -
              - 1
         | 
| 9 | 
            -
              - 9
         | 
| 10 | 
            -
              version: 0.1.9
         | 
| 11 6 | 
             
            platform: ruby
         | 
| 12 | 
            -
            authors: | 
| 7 | 
            +
            authors:
         | 
| 13 8 | 
             
            - Spreedly
         | 
| 14 9 | 
             
            - 403 Labs
         | 
| 15 10 | 
             
            autorequire: 
         | 
| 16 11 | 
             
            bindir: bin
         | 
| 17 12 | 
             
            cert_chain: []
         | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
            - !ruby/object:Gem::Dependency 
         | 
| 13 | 
            +
            date: 2012-09-26 00:00:00.000000000 Z
         | 
| 14 | 
            +
            dependencies:
         | 
| 15 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 22 16 | 
             
              name: httparty
         | 
| 23 | 
            -
               | 
| 24 | 
            -
              requirement: &id001 !ruby/object:Gem::Requirement 
         | 
| 17 | 
            +
              requirement: &70095372683980 !ruby/object:Gem::Requirement
         | 
| 25 18 | 
             
                none: false
         | 
| 26 | 
            -
                requirements: | 
| 27 | 
            -
                - -  | 
| 28 | 
            -
                  - !ruby/object:Gem::Version | 
| 29 | 
            -
                     | 
| 30 | 
            -
                    segments: 
         | 
| 31 | 
            -
                    - 0
         | 
| 32 | 
            -
                    - 7
         | 
| 33 | 
            -
                    - 7
         | 
| 34 | 
            -
                    version: 0.7.7
         | 
| 19 | 
            +
                requirements:
         | 
| 20 | 
            +
                - - ~>
         | 
| 21 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 22 | 
            +
                    version: '0.0'
         | 
| 35 23 | 
             
              type: :runtime
         | 
| 36 | 
            -
              version_requirements: *id001
         | 
| 37 | 
            -
            - !ruby/object:Gem::Dependency 
         | 
| 38 | 
            -
              name: activesupport
         | 
| 39 24 | 
             
              prerelease: false
         | 
| 40 | 
            -
               | 
| 25 | 
            +
              version_requirements: *70095372683980
         | 
| 26 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 27 | 
            +
              name: activesupport
         | 
| 28 | 
            +
              requirement: &70095372705660 !ruby/object:Gem::Requirement
         | 
| 41 29 | 
             
                none: false
         | 
| 42 | 
            -
                requirements: | 
| 30 | 
            +
                requirements:
         | 
| 43 31 | 
             
                - - ~>
         | 
| 44 | 
            -
                  - !ruby/object:Gem::Version | 
| 45 | 
            -
                     | 
| 46 | 
            -
                    segments: 
         | 
| 47 | 
            -
                    - 3
         | 
| 48 | 
            -
                    - 0
         | 
| 49 | 
            -
                    - 0
         | 
| 50 | 
            -
                    version: 3.0.0
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '3.0'
         | 
| 51 34 | 
             
              type: :runtime
         | 
| 52 | 
            -
              version_requirements: *id002
         | 
| 53 | 
            -
            - !ruby/object:Gem::Dependency 
         | 
| 54 | 
            -
              name: builder
         | 
| 55 35 | 
             
              prerelease: false
         | 
| 56 | 
            -
               | 
| 36 | 
            +
              version_requirements: *70095372705660
         | 
| 37 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 38 | 
            +
              name: builder
         | 
| 39 | 
            +
              requirement: &70095372702860 !ruby/object:Gem::Requirement
         | 
| 57 40 | 
             
                none: false
         | 
| 58 | 
            -
                requirements: | 
| 59 | 
            -
                - -  | 
| 60 | 
            -
                  - !ruby/object:Gem::Version | 
| 61 | 
            -
                     | 
| 62 | 
            -
                    segments: 
         | 
| 63 | 
            -
                    - 0
         | 
| 64 | 
            -
                    version: "0"
         | 
| 41 | 
            +
                requirements:
         | 
| 42 | 
            +
                - - ! '>='
         | 
| 43 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 44 | 
            +
                    version: '0'
         | 
| 65 45 | 
             
              type: :runtime
         | 
| 66 | 
            -
              version_requirements: *id003
         | 
| 67 | 
            -
            - !ruby/object:Gem::Dependency 
         | 
| 68 | 
            -
              name: ruby-debug
         | 
| 69 46 | 
             
              prerelease: false
         | 
| 70 | 
            -
               | 
| 47 | 
            +
              version_requirements: *70095372702860
         | 
| 48 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 49 | 
            +
              name: ruby-debug19
         | 
| 50 | 
            +
              requirement: &70095372715820 !ruby/object:Gem::Requirement
         | 
| 71 51 | 
             
                none: false
         | 
| 72 | 
            -
                requirements: | 
| 73 | 
            -
                - -  | 
| 74 | 
            -
                  - !ruby/object:Gem::Version | 
| 75 | 
            -
                     | 
| 76 | 
            -
                    segments: 
         | 
| 77 | 
            -
                    - 0
         | 
| 78 | 
            -
                    version: "0"
         | 
| 52 | 
            +
                requirements:
         | 
| 53 | 
            +
                - - ! '>='
         | 
| 54 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 55 | 
            +
                    version: '0'
         | 
| 79 56 | 
             
              type: :development
         | 
| 80 | 
            -
              version_requirements: *id004
         | 
| 81 | 
            -
            - !ruby/object:Gem::Dependency 
         | 
| 82 | 
            -
              name: rake
         | 
| 83 57 | 
             
              prerelease: false
         | 
| 84 | 
            -
               | 
| 58 | 
            +
              version_requirements: *70095372715820
         | 
| 59 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 60 | 
            +
              name: rake
         | 
| 61 | 
            +
              requirement: &70095372761540 !ruby/object:Gem::Requirement
         | 
| 85 62 | 
             
                none: false
         | 
| 86 | 
            -
                requirements: | 
| 87 | 
            -
                - -  | 
| 88 | 
            -
                  - !ruby/object:Gem::Version | 
| 89 | 
            -
                    hash: 49
         | 
| 90 | 
            -
                    segments: 
         | 
| 91 | 
            -
                    - 0
         | 
| 92 | 
            -
                    - 8
         | 
| 93 | 
            -
                    - 7
         | 
| 63 | 
            +
                requirements:
         | 
| 64 | 
            +
                - - =
         | 
| 65 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 94 66 | 
             
                    version: 0.8.7
         | 
| 95 67 | 
             
              type: :development
         | 
| 96 | 
            -
              version_requirements: *id005
         | 
| 97 | 
            -
            - !ruby/object:Gem::Dependency 
         | 
| 98 | 
            -
              name: webmock
         | 
| 99 68 | 
             
              prerelease: false
         | 
| 100 | 
            -
               | 
| 69 | 
            +
              version_requirements: *70095372761540
         | 
| 70 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 71 | 
            +
              name: webmock
         | 
| 72 | 
            +
              requirement: &70095372768840 !ruby/object:Gem::Requirement
         | 
| 101 73 | 
             
                none: false
         | 
| 102 | 
            -
                requirements: | 
| 74 | 
            +
                requirements:
         | 
| 103 75 | 
             
                - - ~>
         | 
| 104 | 
            -
                  - !ruby/object:Gem::Version | 
| 105 | 
            -
                    hash: 11
         | 
| 106 | 
            -
                    segments: 
         | 
| 107 | 
            -
                    - 1
         | 
| 108 | 
            -
                    - 6
         | 
| 109 | 
            -
                    - 2
         | 
| 76 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 110 77 | 
             
                    version: 1.6.2
         | 
| 111 78 | 
             
              type: :development
         | 
| 112 | 
            -
               | 
| 113 | 
            -
             | 
| 79 | 
            +
              prerelease: false
         | 
| 80 | 
            +
              version_requirements: *70095372768840
         | 
| 81 | 
            +
            description: Spreedly Core is a cloud service that allows you to store credit cards
         | 
| 82 | 
            +
              and run transactions against them, enabling you to accept payments on your website
         | 
| 83 | 
            +
              while avoiding all liability and PCI compliance requirements.
         | 
| 114 84 | 
             
            email: support@spreedly.com
         | 
| 115 85 | 
             
            executables: []
         | 
| 116 | 
            -
             | 
| 117 86 | 
             
            extensions: []
         | 
| 118 | 
            -
             | 
| 119 87 | 
             
            extra_rdoc_files: []
         | 
| 120 | 
            -
             | 
| 121 | 
            -
            files: 
         | 
| 88 | 
            +
            files:
         | 
| 122 89 | 
             
            - README.md
         | 
| 123 90 | 
             
            - Rakefile
         | 
| 124 91 | 
             
            - LICENSE
         | 
| @@ -140,36 +107,26 @@ files: | |
| 140 107 | 
             
            - test/transaction_test.rb
         | 
| 141 108 | 
             
            homepage: http://github.com/spreedly/spreedly-core-ruby
         | 
| 142 109 | 
             
            licenses: []
         | 
| 143 | 
            -
             | 
| 144 110 | 
             
            post_install_message: 
         | 
| 145 111 | 
             
            rdoc_options: []
         | 
| 146 | 
            -
             | 
| 147 | 
            -
            require_paths: 
         | 
| 112 | 
            +
            require_paths:
         | 
| 148 113 | 
             
            - lib
         | 
| 149 | 
            -
            required_ruby_version: !ruby/object:Gem::Requirement | 
| 114 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 150 115 | 
             
              none: false
         | 
| 151 | 
            -
              requirements: | 
| 152 | 
            -
              - -  | 
| 153 | 
            -
                - !ruby/object:Gem::Version | 
| 154 | 
            -
                   | 
| 155 | 
            -
             | 
| 156 | 
            -
                  - 0
         | 
| 157 | 
            -
                  version: "0"
         | 
| 158 | 
            -
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 116 | 
            +
              requirements:
         | 
| 117 | 
            +
              - - ! '>='
         | 
| 118 | 
            +
                - !ruby/object:Gem::Version
         | 
| 119 | 
            +
                  version: '0'
         | 
| 120 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 159 121 | 
             
              none: false
         | 
| 160 | 
            -
              requirements: | 
| 161 | 
            -
              - -  | 
| 162 | 
            -
                - !ruby/object:Gem::Version | 
| 163 | 
            -
                   | 
| 164 | 
            -
                  segments: 
         | 
| 165 | 
            -
                  - 0
         | 
| 166 | 
            -
                  version: "0"
         | 
| 122 | 
            +
              requirements:
         | 
| 123 | 
            +
              - - ! '>='
         | 
| 124 | 
            +
                - !ruby/object:Gem::Version
         | 
| 125 | 
            +
                  version: '0'
         | 
| 167 126 | 
             
            requirements: []
         | 
| 168 | 
            -
             | 
| 169 127 | 
             
            rubyforge_project: 
         | 
| 170 | 
            -
            rubygems_version: 1.8. | 
| 128 | 
            +
            rubygems_version: 1.8.11
         | 
| 171 129 | 
             
            signing_key: 
         | 
| 172 130 | 
             
            specification_version: 3
         | 
| 173 131 | 
             
            summary: Ruby interface for Spreedly Core
         | 
| 174 132 | 
             
            test_files: []
         | 
| 175 | 
            -
             |