Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
Improve error message for missing store item (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidme-stripe authored Nov 25, 2019
1 parent 90db3d4 commit cffb54a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion web.rb
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,17 @@ def generate_payment_response(payment_intent)
"👚" => 2500,
}

def price_lookup(product)
price = EMOJI_STORE[product]
raise "Can't find price for %s (%s)" % [product, product.ord.to_s(16)] if price.nil?
return price
end

def calculate_price(products, shipping)
amount = 1099 # Default amount.

if products
amount = products.reduce(0) { | sum, product | sum + EMOJI_STORE[product] }
amount = products.reduce(0) { | sum, product | sum + price_lookup(product) }
end

if shipping
Expand Down

0 comments on commit cffb54a

Please sign in to comment.