shoppe-stripe 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module Shoppe
2
2
  module Stripe
3
- VERSION = '1.0.1'
3
+ VERSION = '1.0.2'
4
4
  end
5
5
  end
@@ -0,0 +1,23 @@
1
+ $ ->
2
+ $('form.stripeForm').on 'submit', ->
3
+ # The form
4
+ form = $(this)
5
+
6
+ # Build a hash of params which will be sent to Stripe
7
+ stripeCardParams = {}
8
+ $.each ['number', 'exp_month', 'exp_year', 'cvc', 'name', 'address_line1', 'address_line2', 'address_city', 'address_state', 'address_zip', 'address_country'], (i,f)->
9
+ stripeCardParams[f] = $("[data-stripe='#{f}']").val()
10
+
11
+ # Send the data to Stripe and define a method to be executed when the response
12
+ # comes back from Stripe.
13
+ Stripe.card.createToken stripeCardParams, (status, response)->
14
+ if response.error
15
+ $('p.stripeError', form).remove()
16
+ $("<p class='stripeError'>#{response.error.message}</p>").prependTo(form)
17
+ $('input[type=submit]', form).removeClass('disabled').prop('disabled', false)
18
+ else
19
+ $('[data-stripe=token]').val(response['id'])
20
+ form.get(0).submit()
21
+
22
+ # Return false to ensure that the form doesn't submit on first click
23
+ false
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shoppe-stripe
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-16 00:00:00.000000000 Z
12
+ date: 2013-10-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: shoppe
@@ -71,6 +71,7 @@ files:
71
71
  - lib/shoppe/stripe/version.rb
72
72
  - lib/shoppe/stripe/view_helpers.rb
73
73
  - lib/shoppe/stripe.rb
74
+ - vendor/assets/javascripts/shoppe/stripe/form_handler.coffee
74
75
  - MIT-LICENSE
75
76
  homepage: http://tryshoppe.com
76
77
  licenses: []