Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

removed unnec card fields

  • Loading branch information...
commit 3d3b29b87077deb840703618c95dd88df7f60e31 1 parent c0b8416
@akshayrawat authored
View
4 app/models/card.rb
@@ -1,8 +1,8 @@
class Card
include ActiveModel::Validations
- attr_accessor :number, :exp_month, :exp_year, :cvc, :name, :address_line1,
- :address_line2, :address_zip, :address_state, :address_country,
+ attr_accessor :name, :number, :cvc, :exp_month, :exp_year,
+ :address_line1, :address_zip, :address_country,
:attributes
validates_presence_of :number, :exp_month, :exp_year, :cvc, :name, :address_line1,
View
5 app/models/inr_to_usd.rb
@@ -3,12 +3,11 @@ class INRToUSD
base_uri "openexchangerates.org"
def self.to_usd amount_in_paisa
- puts "Current rate: #{current_rate}"
- ((amount_in_paisa.to_i * 100) / current_rate).ceil
+ (BigDecimal(amount_in_paisa) / current_rate).floor #a max deviation of INR -4 is ok
end
def self.current_rate
response = self.get "/latest.json"
- response.parsed_response['rates']['INR'] * 100
+ BigDecimal(response.parsed_response['rates']['INR'].to_s)
end
end
View
2  app/models/payment.rb
@@ -20,7 +20,7 @@ def charge
@payment_response = Stripe::Charge.create(
:amount=> INRToUSD.to_usd(self.amount),
:currency=> "usd",
- :description=> "Test charge made on #{Time.zone.now}",
+ :description=> "Charge made on #{Time.zone.now}",
:card=> self.card.attributes
)
rescue Stripe::CardError => e
View
6 app/views/payments/new.html.haml
@@ -14,10 +14,8 @@
= cf.input :exp_month
= cf.input :exp_year
= cf.input :address_line1
- = cf.input :address_line2
= cf.input :address_zip
- = cf.input :address_state
- = cf.input :address_country, :as=> :string
+ = cf.input :address_country, :as=> :string, :input_html=> { :value=> "IN" }
.centered
= link_to "Prefill", "#", :class=> 'btn prefill'
= f.submit "Pay", :class=> 'btn primary'
@@ -27,7 +25,7 @@
$(function(){
$('a.prefill').click(function(){
$('#payment_amount').val('3000');
- $('#payment_card_name, #payment_card_address_line1, #payment_card_address_line2, #payment_card_address_state, #payment_card_address_country').val('foobar');
+ $('#payment_card_name, #payment_card_address_line1, #payment_card_address_line2, #payment_card_address_state').val('foobar');
$('#payment_card_exp_year, #payment_card_address_zip').val("2020");
$('#payment_card_exp_month').val("12");
$('#payment_card_number').val("4242424242424242");
Please sign in to comment.
Something went wrong with that request. Please try again.