By Developers, For Developers

Historical errata for Take My Money

PDF PgPaper PgTypeDescriptionFixed onComments
7TYPO

Fifth line from top of page. Capybara config file not embedded. Missing closing quote on filename?

2016-08-28
119TYPO

There is a space between remote_id: and string in this command. There shouldn’t be :).

rails generate model subscription user:references \\
plan:references start_date:date end_date:date \\
status:integer payment_method:string remote_id: string

2016-08-28
117SUGGEST

1.send(interval).from_now(date)

Love how you did end_date_from. I have 1 idea for an improvement.

I think it would be helpful to include `interval_count` in the model. Then could be used here instead of `1`.

This method is currently only accurate if the count is 1.

:)

2016-08-28Yeah, let me take that as a something to fix in the text or at least call out as a limitation.
32TYPO

Contains the line “and the cost if it the found out by some miscreant…” in the second full paragraph

2016-08-28
187TYPO

Rogue question mark in first sentence of second paragraph of “Keeping Data Secure” : “Not only do our administrators? have the ability to set a price…”

2016-09-13
127SUGGEST

Love the webhooks chapter.

While implementing on my own, 1 thing I added is http basic auth. Maybe useful to add in the chapter/controller example as well.

I added this to the controller:
http_basic_authenticate_with name: Rails.configuration.stripe[:webhook_username], password: Rails.configuration.stripe[:webhook_password]

3TYPO

The gem we’re adding to our gemfile is called money-rails:
github.com/RubyMoney/money-rails

31TYPO

In the generated create_payments migration file (server_charge/01/db/migrate/20160721043026_create_payments.rb), the line that adds the index should read-
add_index :payments, :reference

112ERROR

Project: code/failure/01
Failed examples:

rspec ./spec/workflows/purchases_cart_via_stripe_spec.rb:70 # PurchasesCartViaStripe an unsuccessful credit card purchase updates the ticket status
rspec ./spec/workflows/purchases_cart_via_stripe_spec.rb:46 # PurchasesCartViaStripe successful credit card purchase updates the ticket status

###############################################
% rspec spec/workflows/purchases_cart_via_stripe_spec.rb

Randomized with seed 36256

PurchasesCartViaStripe
an unsuccessful credit card purchase
updates the ticket status (FAILED - 1)
successful credit card purchase
updates the ticket status (FAILED - 2)
pre-flight fails
expected tickets
does not trigger payment if the expected tickets are incorrect
database failure
does not trigger payment if the database fails
expected price
does not payment if the expected price is incorrect

Failures:

1) PurchasesCartViaStripe an unsuccessful credit card purchase updates the ticket status
Got 1 failure and 1 other error:

1.1) Failure/Error: self.payment = Payment.create!(payment_attributes)

#<Payment(id: integer, user_id: integer, price_cents: integer, price_currency: string, status: integer, reference: string, payment_method: string, response_id: string, full_response: json, created_at: datetime, updated_at: datetime) (class)> received :create! with unexpected arguments
expected: ({:user_id=>5, :price_cents=>3000, :reference=>a truthy value, :status=>“created”})
got: ({:user_id=>5, :price_cents=>3000, :status=>“created”, :reference=>“43fab842caa8670ae6e4”, :payment_method=>“stripe”})
Diff:
@@ –1,5 +1,6 @@
[{:user_id=>5,
:price_cents=>3000,
- :reference=>a truthy value,
- :status=>“created”}]
+ :status=>“created”,
+ :reference=>“43fab842caa8670ae6e4”,
+ :payment_method=>“stripe”}]

Please stub a default value first if message might be received with other args as well.
# ./app/workflows/purchases_cart.rb:62:in `create_payment’
# ./app/workflows/purchases_cart.rb:53:in `pre_purchase’
# ./app/workflows/purchases_cart.rb:26:in `block in run’
# ./app/workflows/purchases_cart.rb:25:in `run’
# ./spec/workflows/purchases_cart_via_stripe_spec.rb:67:in `block (3 levels) in <top (required)>’

1.2) Failure/Error: payment.create_line_items(tickets)

NoMethodError:
undefined method `create_line_items’ for #
# ./app/workflows/purchases_cart.rb:63:in `create_payment’
# ./app/workflows/purchases_cart.rb:53:in `pre_purchase’
# ./app/workflows/purchases_cart.rb:26:in `block in run’
# ./app/workflows/purchases_cart.rb:25:in `run’
# ./spec/workflows/purchases_cart_via_stripe_spec.rb:67:in `block (3 levels) in <top (required)>’

2) PurchasesCartViaStripe successful credit card purchase updates the ticket status
Got 1 failure and 1 other error:

2.1) Failure/Error: self.payment = Payment.create!(payment_attributes)

#<Payment(id: integer, user_id: integer, price_cents: integer, price_currency: string, status: integer, reference: string, payment_method: string, response_id: string, full_response: json, created_at: datetime, updated_at: datetime) (class)> received :create! with unexpected arguments
expected: ({:user_id=>5, :price_cents=>3000, :reference=>a truthy value, :status=>“created”})
got: ({:user_id=>5, :price_cents=>3000, :status=>“created”, :reference=>“3817fd5be15acf387930”, :payment_method=>“stripe”})
Diff:
@@ –1,5 +1,6 @@
[{:user_id=>5,
:price_cents=>3000,
- :reference=>a truthy value,
- :status=>“created”}]
+ :status=>“created”,
+ :reference=>“3817fd5be15acf387930”,
+ :payment_method=>“stripe”}]

Please stub a default value first if message might be received with other args as well.
# ./app/workflows/purchases_cart.rb:62:in `create_payment’
# ./app/workflows/purchases_cart.rb:53:in `pre_purchase’
# ./app/workflows/purchases_cart.rb:26:in `block in run’
# ./app/workflows/purchases_cart.rb:25:in `run’
# ./spec/workflows/purchases_cart_via_stripe_spec.rb:43:in `block (3 levels) in <top (required)>’

2.2) Failure/Error: payment.create_line_items(tickets)

NoMethodError:
undefined method `create_line_items’ for #
# ./app/workflows/purchases_cart.rb:63:in `create_payment’
# ./app/workflows/purchases_cart.rb:53:in `pre_purchase’
# ./app/workflows/purchases_cart.rb:26:in `block in run’
# ./app/workflows/purchases_cart.rb:25:in `run’
# ./spec/workflows/purchases_cart_via_stripe_spec.rb:43:in `block (3 levels) in <top (required)>’

Finished in 0.27931 seconds (files took 2.69 seconds to load)
5 examples, 2 failures

Failed examples:

rspec ./spec/workflows/purchases_cart_via_stripe_spec.rb:70 # PurchasesCartViaStripe an unsuccessful credit card purchase updates the ticket status
rspec ./spec/workflows/purchases_cart_via_stripe_spec.rb:46 # PurchasesCartViaStripe successful credit card purchase updates the ticket status

Randomized with seed 36256

30ERROR

The text says : “will need both a database table and a resources :purchase line in the
routes.rb file.”

shouldn’t it be : “will need both a database table and a resources :payment line in the
routes.rb file.” ?

15SUGGEST

There seems to be an extraneous link in the shopping_cart.rb code example in the tickets_by_performance method - t.performance.id is a link and shouldn’t be; I clicked on it by accident :P

Categories: