payola-payments 1.4.0 → 1.5.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +200 -0
- data/LICENSE +6 -0
- data/README.md +80 -0
- data/Rakefile +5 -4
- data/app/assets/javascripts/payola/application.js +3 -3
- data/app/assets/javascripts/payola/checkout_button.js +29 -19
- data/app/assets/javascripts/payola/subscription_checkout_button.js +7 -1
- data/app/assets/javascripts/payola/subscription_form_onestep.js +27 -0
- data/app/assets/stylesheets/payola/application.css +4 -4
- data/app/controllers/concerns/payola/affiliate_behavior.rb +1 -1
- data/app/controllers/concerns/payola/status_behavior.rb +1 -1
- data/app/controllers/payola/application_controller.rb +8 -0
- data/app/controllers/payola/cards_controller.rb +14 -14
- data/app/controllers/payola/customers_controller.rb +11 -12
- data/app/controllers/payola/subscriptions_controller.rb +16 -8
- data/app/controllers/payola/transactions_controller.rb +1 -1
- data/app/models/concerns/payola/plan.rb +2 -1
- data/app/models/payola/subscription.rb +5 -0
- data/app/services/payola/cancel_subscription.rb +6 -5
- data/app/services/payola/change_subscription_plan.rb +3 -1
- data/app/services/payola/change_subscription_quantity.rb +1 -1
- data/app/services/payola/create_sale.rb +12 -2
- data/app/services/payola/create_subscription.rb +1 -1
- data/app/services/payola/start_subscription.rb +9 -1
- data/app/services/payola/update_customer.rb +1 -1
- data/app/views/payola/subscriptions/_change_plan.html.erb +2 -0
- data/app/views/payola/subscriptions/_checkout.html.erb +1 -1
- data/app/views/payola/transactions/_checkout.html.erb +4 -2
- data/config/locales/en.yml +17 -0
- data/db/migrate/20151205004838_change_tax_percent_format_in_payola_subscriptions.rb +9 -0
- data/lib/payola.rb +6 -0
- data/lib/payola/version.rb +1 -1
- data/spec/concerns/plan_spec.rb +16 -4
- data/spec/controllers/payola/cards_controller_spec.rb +92 -8
- data/spec/controllers/payola/customers_controller_spec.rb +47 -4
- data/spec/controllers/payola/subscriptions_controller_spec.rb +59 -46
- data/spec/controllers/payola/transactions_controller_spec.rb +33 -30
- data/spec/dummy/Rakefile +1 -1
- data/spec/dummy/app/assets/javascripts/application.js +3 -3
- data/spec/dummy/app/assets/stylesheets/application.css +4 -4
- data/spec/dummy/app/controllers/application_controller.rb +4 -0
- data/spec/dummy/app/views/layouts/application.html.erb +27 -11
- data/spec/dummy/bin/rails +1 -1
- data/spec/dummy/config.ru +2 -1
- data/spec/dummy/config/application.rb +1 -2
- data/spec/dummy/config/boot.rb +2 -2
- data/spec/dummy/config/environment.rb +1 -1
- data/spec/dummy/config/environments/development.rb +1 -37
- data/spec/dummy/config/environments/production.rb +1 -82
- data/spec/dummy/config/environments/rails_4/development.rb +37 -0
- data/spec/dummy/config/environments/rails_4/production.rb +82 -0
- data/spec/dummy/config/environments/rails_4/test.rb +45 -0
- data/spec/dummy/config/environments/rails_5/development.rb +54 -0
- data/spec/dummy/config/environments/rails_5/production.rb +86 -0
- data/spec/dummy/config/environments/rails_5/test.rb +44 -0
- data/spec/dummy/config/environments/test.rb +1 -45
- data/spec/dummy/config/initializers/assets.rb +3 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -1
- data/spec/dummy/config/initializers/new_framework_defaults.rb +26 -0
- data/spec/dummy/config/secrets.yml +1 -1
- data/spec/dummy/config/spring.rb +8 -0
- data/spec/dummy/db/schema.rb +9 -12
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +134732 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/models/payola/env_wrapper_spec.rb +13 -0
- data/spec/models/payola/sale_spec.rb +7 -7
- data/spec/models/payola/subscription_spec.rb +8 -3
- data/spec/payola_spec.rb +8 -8
- data/spec/services/payola/cancel_subscription_spec.rb +20 -4
- data/spec/services/payola/change_subscription_plan_spec.rb +2 -1
- data/spec/services/payola/change_subscription_quantity_spec.rb +23 -7
- data/spec/services/payola/charge_card_spec.rb +30 -25
- data/spec/services/payola/invoice_failed_spec.rb +1 -0
- data/spec/services/payola/invoice_paid_spec.rb +1 -0
- data/spec/services/payola/start_subscription_spec.rb +15 -0
- data/spec/spec_helper.rb +4 -2
- data/spec/support/http_methods_with_keyword_args.rb +21 -0
- data/spec/support/params_helper.rb +9 -0
- data/spec/worker_spec.rb +2 -2
- metadata +41 -13
- data/config/database.yml.ci +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23ef9ea875996e25766aa0560f06183bd084aeea
|
4
|
+
data.tar.gz: 735177781079c4dc153e9373ebfd8c6c1751dc8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81f1013db2d2ee0593cba32fdcc170ab0f35b5e849bdb815260b25c3811cfd5537a3654ee4e21ed879d44a11c24fbcd5a1ff7c83aa1cadea1de53867aaa4a8c9
|
7
|
+
data.tar.gz: 52d25e3d2ad2ffb3b44226dfc77ab92caaa1783d4657ebd48d994c11760998bed702c7a758e2c89c613bafe572f98855857980787d6b641be70cf2bae70b14fd
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,200 @@
|
|
1
|
+
# Payola Changelog
|
2
|
+
|
3
|
+
Payola adheres to [Semantic Versioning](http://semver.org/).
|
4
|
+
|
5
|
+
All notable changes to Payola will be documented in this file.
|
6
|
+
|
7
|
+
## v1.5.0 - 2016-10-27
|
8
|
+
[Full Changelog](https://github.com/peterkeen/payola/compare/v1.4.0...v1.5.0)
|
9
|
+
|
10
|
+
### Security
|
11
|
+
- Raise error if `payola_can_modify_customer/subscription?` unimplemented. #246
|
12
|
+
|
13
|
+
### Enhancements
|
14
|
+
- Unpegged Stripe gem and stripe-ruby-mock. #255
|
15
|
+
- Take optional `stripe_customer_id` when creating a sale. #183
|
16
|
+
- Clean up error target HTML attributes. #198
|
17
|
+
- Update `cancel_at_period_end` in `CancelSubscription` service. #200
|
18
|
+
- Synchronize subscription amount and currency fields with Stripe. #202
|
19
|
+
- Send the `plan_id` along with the form submission. #206
|
20
|
+
- Set a customer's payment source if nil. #210
|
21
|
+
- Maintain the active coupon code on a subscription. #211
|
22
|
+
- Disallow deleting a plan if it has any related subscriptions. #221
|
23
|
+
- Flash message i18n. #229
|
24
|
+
- Rails 5.0 support. #232
|
25
|
+
- Add client side validation to subscription_form_onestep.js. #262
|
26
|
+
|
27
|
+
### Bug Fixes
|
28
|
+
- Stop setting `Stripe.api_key` directly in `CancelSubscription` service. #201
|
29
|
+
- Convert tax_percent from integer to decimal (at most two decimal places). #189
|
30
|
+
- Submit all subscription options for existing stripe customers. #207
|
31
|
+
- Update subscription quantity when a subscription is changed. #218
|
32
|
+
- Fix flash message typo 'Successfully'. #228
|
33
|
+
- Make tax percentage migration reversible. #242
|
34
|
+
- Call `instrument_quantity_changed` from `ChangeSubscriptionQuantity`. #250
|
35
|
+
- Fix api_key String spec errors with stripe-ruby-mock 2.3.1. #261
|
36
|
+
- Ensure ENV keys are seen as Strings by recent stripe-ruby versions. #265
|
37
|
+
|
38
|
+
## v1.4.0 - 2016-01-28
|
39
|
+
[Full Changelog](https://github.com/peterkeen/payola/compare/v1.3.2...v1.4.0)
|
40
|
+
|
41
|
+
### Enhancements
|
42
|
+
- Add a wrapper for the error function to pass xhr.responseJSON to checkout
|
43
|
+
buttons.
|
44
|
+
- Support free trials and plans by allowing subscription creation without
|
45
|
+
credit card. #144, #145
|
46
|
+
- Support cancelling subscription at period end. #146
|
47
|
+
- Trigger `error` event on Payola HTML elements when an error occurs. #147
|
48
|
+
- Allows coupon to be applied to changing subscription, and turns off prorating
|
49
|
+
in that scenario per Stripe instructions. #150
|
50
|
+
- Support for subscription creation with trial_end and optional stripeToken. #151
|
51
|
+
- Add config option to determine whether to create plans in Stripe. #156
|
52
|
+
- Allow `Plan#trial_period_days` attribute to remain optional. #160
|
53
|
+
- Accept tax percentage for subscriptions. #167
|
54
|
+
- Functionality to manage multiple cards and update customer attributes. Includes optional authorization check `payola_can_modify_customer?`. #168
|
55
|
+
- Optionally include checkout.stripe.com assets with `include_stripe_checkout_assets`. #169
|
56
|
+
- Improve support for subscription `at_period_end`. #165
|
57
|
+
- Support reusing existing Stripe customer for subscriptions. #170
|
58
|
+
- Listen for customer.subscription.deleted webhooks and cancel the associated subscription. #172
|
59
|
+
- Show plan interval in description instead of hardcoding to 'month'. #176
|
60
|
+
- Support coupons in `subscriptions/_checkout` partial. #179
|
61
|
+
- Allow sales to be refunded on the client side. #181
|
62
|
+
- Introduce `return_to` to support custom return paths after customer/card actions. #180
|
63
|
+
- `StartSubscription` no longer requires Stripe token for free plans. #190
|
64
|
+
- Turbolinks compatibility. #191
|
65
|
+
|
66
|
+
### Bug Fixes
|
67
|
+
- Disable only Payola-related submit button(s) on page. #113
|
68
|
+
- Fix jQuery XHR JSON error handling. #159
|
69
|
+
- Ensure Payola.create_stripe_plans global gets set back to true. #164
|
70
|
+
- Registration form no longer uses hardcoded `/users` path. #171
|
71
|
+
- Remove debugging output in javascripts. #177
|
72
|
+
- Remove weird copy of StartSubscription service specs. #178
|
73
|
+
- Only cancel subscription in `SubscriptionDeleted` if it can be canceled. #186
|
74
|
+
|
75
|
+
## v1.3.2 - 2015-05-18
|
76
|
+
[Full Changelog](https://github.com/peterkeen/payola/compare/v1.3.1...v1.3.2)
|
77
|
+
|
78
|
+
- Lock stripe-ruby-mock to v2.1.0 to work around test issues
|
79
|
+
- Properly bubble subscription errors up to the user
|
80
|
+
- Handle card declines
|
81
|
+
- Add bitcoin option to checkout button
|
82
|
+
- Move the Payola Pro message out of initializers
|
83
|
+
|
84
|
+
## v1.3.1 - 2015-03-18
|
85
|
+
[Full Changelog](https://github.com/peterkeen/payola/compare/v1.3.0...v1.3.1)
|
86
|
+
|
87
|
+
- Fix a problem when creating subscription invoice payments
|
88
|
+
- Peg Stripe gem at 1.20.1 pending a fix to rebelidealist/stripe-ruby-mock#203
|
89
|
+
|
90
|
+
## v1.3.0 - 2015-02-28
|
91
|
+
[Full Changelog](https://github.com/peterkeen/payola/compare/v1.2.7...v1.3.0)
|
92
|
+
|
93
|
+
- Support Stripe API version 2015-02-18
|
94
|
+
|
95
|
+
## v1.2.7 - 2015-02-28
|
96
|
+
[Full Changelog](https://github.com/peterkeen/payola/compare/v1.2.6...v1.2.7)
|
97
|
+
|
98
|
+
- Fix Javascript error handling for one-step subscriptions
|
99
|
+
- Add some docs about events and turbolinks incompatibility
|
100
|
+
- Support namespaced models for plans
|
101
|
+
|
102
|
+
## v1.2.6 - 2015-01-26
|
103
|
+
[Full Changelog](https://github.com/peterkeen/payola/compare/v1.2.5...v1.2.6)
|
104
|
+
|
105
|
+
- Fix Javascript error handling for subscriptions
|
106
|
+
|
107
|
+
## v1.2.5 - 2015-01-25
|
108
|
+
[Full Changelog](https://github.com/peterkeen/payola/compare/v1.2.4...v1.2.5)
|
109
|
+
|
110
|
+
- Capure all attributes from Stripe when starting a subscription
|
111
|
+
- Allow for use of Checkout for Subscriptions
|
112
|
+
- Only re-use active or canceled subscriptions
|
113
|
+
- Make plan creation idempotent
|
114
|
+
|
115
|
+
## v1.2.4 - 2015-01-06
|
116
|
+
[Full Changelog](https://github.com/peterkeen/payola/compare/v1.2.3...v1.2.4)
|
117
|
+
|
118
|
+
- Fix regressions in v1.2.3
|
119
|
+
|
120
|
+
## v1.2.3 - 2015-01-03
|
121
|
+
[Full Changelog](https://github.com/peterkeen/payola/compare/v1.2.2...v1.2.3)
|
122
|
+
|
123
|
+
- Add support for Rails 4.2
|
124
|
+
- Re-use customers and create invoice items for setup fees
|
125
|
+
- Add an active flag on `Payola::Coupon`
|
126
|
+
- Fix load-order problems
|
127
|
+
- Add support for subscription quantities
|
128
|
+
- Properly handle form errors
|
129
|
+
|
130
|
+
## v1.2.2 - 2014-11-29
|
131
|
+
[Full Changelog](https://github.com/peterkeen/payola/compare/v1.2.1...v1.2.2)
|
132
|
+
|
133
|
+
- Optionally invert subscription controller flow
|
134
|
+
- Fix the CSRF token behavior
|
135
|
+
|
136
|
+
## v1.2.1 - 2014-11-20
|
137
|
+
[Full Changelog](https://github.com/peterkeen/payola/compare/v1.2.0...v1.2.1)
|
138
|
+
|
139
|
+
- Make guid generator overrideable
|
140
|
+
- Bumped minimum version of AASM to 4.0
|
141
|
+
- Fixed a bug with the auto emails not working for webhook events
|
142
|
+
- Code cleanup
|
143
|
+
- Test coverage improvements
|
144
|
+
|
145
|
+
## v1.2.0 - 2014-11-17
|
146
|
+
[Full Changelog](https://github.com/peterkeen/payola/compare/v1.1.4...v1.2.0)
|
147
|
+
|
148
|
+
- Subscriptions
|
149
|
+
|
150
|
+
## v1.1.4 - 2014-11-07
|
151
|
+
[Full Changelog](https://github.com/peterkeen/payola/compare/v1.1.3...v1.1.4)
|
152
|
+
|
153
|
+
- Pass the created customer to `additional_charge_attributes`
|
154
|
+
- Add Payola Pro license
|
155
|
+
|
156
|
+
## v1.1.3 - 2014-11-07
|
157
|
+
[Full Changelog](https://github.com/peterkeen/payola/compare/v1.1.2...v1.1.3)
|
158
|
+
|
159
|
+
- Add options for requesting billing and shipping addresses via Checkout
|
160
|
+
- Add a callable to add additional attributes to a Stripe::Charge
|
161
|
+
- Only talk about PDFs if PDFs are enabled
|
162
|
+
|
163
|
+
## v1.1.2 - 2014-11-06
|
164
|
+
[Full Changelog](https://github.com/peterkeen/payola/compare/v1.1.1...v1.1.2)
|
165
|
+
|
166
|
+
- Default the `From` address on receipt emails to `Payola.support_email`
|
167
|
+
|
168
|
+
## v1.1.1 - 2014-11-03
|
169
|
+
[Full Changelog](https://github.com/peterkeen/payola/compare/v1.1.0...v1.1.1)
|
170
|
+
|
171
|
+
- ActiveJob can't serialize a class or a symbol so we have to `to_s` them
|
172
|
+
|
173
|
+
## v1.1.0 - 2014-11-03
|
174
|
+
[Full Changelog](https://github.com/peterkeen/payola/compare/v1.0.8...v1.1.0)
|
175
|
+
|
176
|
+
- Add customizable mailers
|
177
|
+
- Pass currency through properly and add a `default_currency` config option
|
178
|
+
- Use data attributes to set up the checkout button instead of a JS snippet
|
179
|
+
- Add a polymorphic `owner` association on `Payola::Sale`.
|
180
|
+
- Allow the price to be overridden on the Checkout form
|
181
|
+
|
182
|
+
## v1.0.8 - 2014-10-27
|
183
|
+
[Full Changelog](https://github.com/peterkeen/payola/compare/v1.0.7...v1.0.8)
|
184
|
+
|
185
|
+
- Add basic support for custom forms
|
186
|
+
- Allow passing signed data from checkout button into the charge verifier
|
187
|
+
- Correctly pass the price into the Checkout button, which allows the `{{amount}}` macro to work properly
|
188
|
+
- I18n the formatted_price helper
|
189
|
+
|
190
|
+
## v1.0.7 - 2014-10-21
|
191
|
+
[Full Changelog](https://github.com/peterkeen/payola/compare/v1.0.6...v1.0.7)
|
192
|
+
|
193
|
+
- Add support for ActiveJob workers
|
194
|
+
- Document how to set Stripe keys
|
195
|
+
- Add a callback to fetch the publishable key
|
196
|
+
- Unpin the Rails version to allow anything >= 4.1
|
197
|
+
- Allow Payola to be mounted anywhere, as long as it has 'as: :payola' in the mount spec
|
198
|
+
|
199
|
+
## v1.0.6 - 2014-10-19
|
200
|
+
- First public release
|
data/LICENSE
ADDED
data/README.md
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
# Payola
|
2
|
+
|
3
|
+
[](http://badge.fury.io/rb/payola-payments) [](https://circleci.com/gh/peterkeen/payola) [](https://codeclimate.com/github/peterkeen/payola) [](https://codeclimate.com/github/peterkeen/payola) [](https://gemnasium.com/peterkeen/payola)
|
4
|
+
|
5
|
+
Payments with Stripe for your Rails application.
|
6
|
+
|
7
|
+
## What does this do?
|
8
|
+
|
9
|
+
Payola is a drop-in Rails engine that lets you sell one or more products by just including a module in your models. It includes:
|
10
|
+
|
11
|
+
* An easy to embed, easy to customize, async Stripe Checkout button
|
12
|
+
* Asynchronous payments, usable with any background processing system
|
13
|
+
* Full webhook integration
|
14
|
+
* Easy extension hooks for adding your own functionality
|
15
|
+
* Customizable emails
|
16
|
+
|
17
|
+
To see Payola in action, check out the site for [Mastering Modern Payments: Using Stripe with Rails](https://www.masteringmodernpayments.com). Read the book to find out the whys behind Payola's design.
|
18
|
+
|
19
|
+
## Installation
|
20
|
+
|
21
|
+
Add Payola to your Gemfile:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
gem 'payola-payments'
|
25
|
+
```
|
26
|
+
|
27
|
+
Run the installer:
|
28
|
+
|
29
|
+
```bash
|
30
|
+
$ rails g payola:install
|
31
|
+
$ rake db:migrate
|
32
|
+
```
|
33
|
+
|
34
|
+
(**Note**: do not run `rake payola:install:migrations`. Payola's migrations live inside the gem and do not get copied into your application.)
|
35
|
+
|
36
|
+
Optionally, tell Stripe about your application. Add this as a webhook in your [Stripe dashboard](https://dashboard.stripe.com/account/webhooks):
|
37
|
+
|
38
|
+
```
|
39
|
+
https://your.website.example.com/payola/events
|
40
|
+
```
|
41
|
+
|
42
|
+
### Disable Turbolinks
|
43
|
+
|
44
|
+
Payola does not currently play nice with turbolinks. Disable it by removing the turbolinks include in your `application.js`.
|
45
|
+
|
46
|
+
## Additional Setup Resources
|
47
|
+
|
48
|
+
|
49
|
+
[One-time payments](https://github.com/peterkeen/payola/wiki/One-time-payments)
|
50
|
+
|
51
|
+
[Configuration options](https://github.com/peterkeen/payola/wiki/Configuration-options)
|
52
|
+
|
53
|
+
[Subscriptions](https://github.com/peterkeen/payola/wiki/Subscriptions)
|
54
|
+
|
55
|
+
## TODO
|
56
|
+
|
57
|
+
* Multiple subscriptions per customer
|
58
|
+
* Affiliate tracking
|
59
|
+
* Easy metered billing
|
60
|
+
|
61
|
+
## License
|
62
|
+
|
63
|
+
Please see the LICENSE file for licensing details.
|
64
|
+
|
65
|
+
## Changelog
|
66
|
+
|
67
|
+
Please see [CHANGELOG.md](CHANGELOG.md).
|
68
|
+
|
69
|
+
## Contributing
|
70
|
+
|
71
|
+
1. Fork the project
|
72
|
+
2. Make your changes, including tests that exercise the code
|
73
|
+
3. Summarize your changes in [CHANGELOG.md](CHANGELOG.md)
|
74
|
+
4. Make a pull request
|
75
|
+
|
76
|
+
Version announcements happen on the [Payola Payments Google group](https://groups.google.com/forum/#!forum/payola-payments) and [@payolapayments](https://twitter.com/payolapayments).
|
77
|
+
|
78
|
+
## Author
|
79
|
+
|
80
|
+
Pete Keen, [@zrail](https://twitter.com/zrail), [https://www.petekeen.net](https://www.petekeen.net)
|
data/Rakefile
CHANGED
@@ -10,14 +10,15 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
10
10
|
rdoc.rdoc_dir = 'rdoc'
|
11
11
|
rdoc.title = 'Payola'
|
12
12
|
rdoc.options << '--line-numbers'
|
13
|
-
rdoc.rdoc_files.include('README.
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
14
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
15
|
end
|
16
16
|
|
17
17
|
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
18
18
|
load 'rails/tasks/engine.rake'
|
19
19
|
|
20
|
-
|
20
|
+
load 'rails/tasks/statistics.rake'
|
21
|
+
require 'bundler/gem_tasks'
|
21
22
|
|
22
23
|
Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
|
23
24
|
|
@@ -25,6 +26,6 @@ require 'rspec/core'
|
|
25
26
|
require 'rspec/core/rake_task'
|
26
27
|
|
27
28
|
desc "Run all specs in spec directory (excluding plugin specs)"
|
28
|
-
RSpec::Core::RakeTask.new(:
|
29
|
+
RSpec::Core::RakeTask.new(spec: 'app:db:test:prepare')
|
29
30
|
|
30
|
-
task :
|
31
|
+
task default: :spec
|
@@ -2,12 +2,12 @@
|
|
2
2
|
// listed below.
|
3
3
|
//
|
4
4
|
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
-
// or vendor/assets/javascripts
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
6
|
//
|
7
7
|
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
-
// compiled file.
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
9
|
//
|
10
|
-
// Read Sprockets README (https://github.com/
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
11
|
// about supported directives.
|
12
12
|
//
|
13
13
|
//= require_tree .
|
@@ -10,24 +10,30 @@ var PayolaCheckout = {
|
|
10
10
|
var form = button.parent('form');
|
11
11
|
var options = form.data();
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
13
|
+
if (options.stripe_customer_id) {
|
14
|
+
// If an existing Stripe customer id is specified, don't open the Stripe Checkout - just AJAX submit the form
|
15
|
+
PayolaCheckout.submitForm(form.attr('action'), { stripe_customer_id: options.stripe_customer_id }, options);
|
16
|
+
} else {
|
17
|
+
// Open a Stripe Checkout to collect the customer's billing details
|
18
|
+
var handler = StripeCheckout.configure({
|
19
|
+
key: options.publishable_key,
|
20
|
+
image: options.product_image_path,
|
21
|
+
token: function(token) { PayolaCheckout.tokenHandler(token, options); },
|
22
|
+
name: options.name,
|
23
|
+
description: options.description,
|
24
|
+
amount: options.price,
|
25
|
+
panelLabel: options.panel_label,
|
26
|
+
allowRememberMe: options.allow_remember_me,
|
27
|
+
zipCode: options.verify_zip_code,
|
28
|
+
billingAddress: options.billing_address,
|
29
|
+
shippingAddress: options.shipping_address,
|
30
|
+
currency: options.currency,
|
31
|
+
bitcoin: options.bitcoin,
|
32
|
+
email: options.email || undefined
|
33
|
+
});
|
29
34
|
|
30
|
-
|
35
|
+
handler.open();
|
36
|
+
}
|
31
37
|
},
|
32
38
|
|
33
39
|
tokenHandler: function(token, options) {
|
@@ -38,13 +44,17 @@ var PayolaCheckout = {
|
|
38
44
|
form.append($('<input type="hidden" name="signed_custom_fields">').val(options.signed_custom_fields));
|
39
45
|
}
|
40
46
|
|
47
|
+
PayolaCheckout.submitForm(form.attr('action'), form.serialize(), options);
|
48
|
+
},
|
49
|
+
|
50
|
+
submitForm: function(url, data, options) {
|
41
51
|
$(".payola-checkout-button").prop("disabled", true);
|
42
52
|
$(".payola-checkout-button-text").hide();
|
43
53
|
$(".payola-checkout-button-spinner").show();
|
44
54
|
$.ajax({
|
45
55
|
type: "POST",
|
46
|
-
url:
|
47
|
-
data:
|
56
|
+
url: url,
|
57
|
+
data: data,
|
48
58
|
success: function(data) { PayolaCheckout.poll(data.guid, 60, options); },
|
49
59
|
error: function(data) { PayolaCheckout.showError(jQuery.parseJSON(data.responseText).error, options); }
|
50
60
|
});
|
@@ -12,7 +12,12 @@ var PayolaSubscriptionCheckout = {
|
|
12
12
|
|
13
13
|
if (options.stripe_customer_id) {
|
14
14
|
// If an existing Stripe customer id is specified, don't open the Stripe Checkout - just AJAX submit the form
|
15
|
-
PayolaSubscriptionCheckout.submitForm(form.attr('action'), {
|
15
|
+
PayolaSubscriptionCheckout.submitForm(form.attr('action'), {
|
16
|
+
stripe_customer_id: options.stripe_customer_id,
|
17
|
+
coupon: options.coupon,
|
18
|
+
tax_percent: options.tax_percent,
|
19
|
+
signed_custom_fields: options.signed_custom_fields || undefined
|
20
|
+
}, options);
|
16
21
|
} else {
|
17
22
|
// Open a Stripe Checkout to collect the customer's billing details
|
18
23
|
var handler = StripeCheckout.configure({
|
@@ -39,6 +44,7 @@ var PayolaSubscriptionCheckout = {
|
|
39
44
|
var form = $("#" + options.form_id);
|
40
45
|
form.append($('<input type="hidden" name="stripeToken">').val(token.id));
|
41
46
|
form.append($('<input type="hidden" name="stripeEmail">').val(token.email));
|
47
|
+
form.append($('<input type="hidden" name="plan_id">').val(options.plan_id));
|
42
48
|
form.append($('<input type="hidden" name="quantity">').val(options.quantity));
|
43
49
|
form.append($('<input type="hidden" name="coupon">').val(options.coupon));
|
44
50
|
form.append($('<input type="hidden" name="tax_percent">').val(options.tax_percent));
|
@@ -6,6 +6,10 @@ var PayolaOnestepSubscriptionForm = {
|
|
6
6
|
},
|
7
7
|
|
8
8
|
handleSubmit: function(form) {
|
9
|
+
if (!PayolaOnestepSubscriptionForm.validateForm(form)) {
|
10
|
+
return false;
|
11
|
+
}
|
12
|
+
|
9
13
|
$(form).find(':submit').prop('disabled', true);
|
10
14
|
$('.payola-spinner').show();
|
11
15
|
Stripe.card.createToken(form, function(status, response) {
|
@@ -14,6 +18,29 @@ var PayolaOnestepSubscriptionForm = {
|
|
14
18
|
return false;
|
15
19
|
},
|
16
20
|
|
21
|
+
validateForm: function(form) {
|
22
|
+
var cardNumber = $( "input[data-stripe='number']" ).val();
|
23
|
+
if (!Stripe.card.validateCardNumber(cardNumber)) {
|
24
|
+
PayolaOnestepSubscriptionForm.showError(form, 'The card number is not a valid credit card number.');
|
25
|
+
return false;
|
26
|
+
}
|
27
|
+
|
28
|
+
var expMonth = $("[data-stripe='exp_month']").val();
|
29
|
+
var expYear = $("[data-stripe='exp_year']").val();
|
30
|
+
if (!Stripe.card.validateExpiry(expMonth, expYear)) {
|
31
|
+
PayolaOnestepSubscriptionForm.showError(form, "Your card's expiration month/year is invalid.");
|
32
|
+
return false;
|
33
|
+
}
|
34
|
+
|
35
|
+
var cvc = $( "input[data-stripe='cvc']" ).val();
|
36
|
+
if(!Stripe.card.validateCVC(cvc)) {
|
37
|
+
PayolaOnestepSubscriptionForm.showError(form, "Your card's security code is invalid.");
|
38
|
+
return false;
|
39
|
+
}
|
40
|
+
|
41
|
+
return true;
|
42
|
+
},
|
43
|
+
|
17
44
|
stripeResponseHandler: function(form, status, response) {
|
18
45
|
if (response.error) {
|
19
46
|
PayolaOnestepSubscriptionForm.showError(form, response.error.message);
|