effective_orders 1.8.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +150 -60
  4. data/Rakefile +0 -3
  5. data/active_admin/effective_orders.rb +14 -9
  6. data/app/assets/javascripts/effective_orders.js +2 -0
  7. data/app/assets/javascripts/effective_orders/{stripe_charges.js.coffee → providers/stripe_charges.js.coffee} +1 -1
  8. data/app/assets/javascripts/effective_orders/{stripe_subscriptions.js.coffee → providers/stripe_subscriptions.js.coffee} +1 -1
  9. data/app/assets/stylesheets/effective_orders/_order.scss +9 -3
  10. data/app/controllers/admin/orders_controller.rb +87 -3
  11. data/app/controllers/concerns/acts_as_active_admin_controller.rb +2 -1
  12. data/app/controllers/effective/carts_controller.rb +4 -2
  13. data/app/controllers/effective/orders_controller.rb +101 -60
  14. data/app/controllers/effective/providers/app_checkout.rb +10 -2
  15. data/app/controllers/effective/providers/ccbill.rb +34 -0
  16. data/app/controllers/effective/providers/cheque.rb +30 -0
  17. data/app/controllers/effective/providers/moneris.rb +7 -7
  18. data/app/controllers/effective/providers/paypal.rb +7 -5
  19. data/app/controllers/effective/providers/pretend.rb +22 -0
  20. data/app/controllers/effective/providers/stripe.rb +26 -24
  21. data/app/controllers/effective/webhooks_controller.rb +1 -1
  22. data/app/helpers/effective_carts_helper.rb +59 -29
  23. data/app/helpers/effective_ccbill_helper.rb +25 -0
  24. data/app/helpers/effective_orders_helper.rb +50 -41
  25. data/app/helpers/effective_paypal_helper.rb +11 -11
  26. data/app/mailers/effective/orders_mailer.rb +95 -20
  27. data/app/models/concerns/acts_as_purchasable.rb +14 -22
  28. data/app/models/effective/cart.rb +9 -15
  29. data/app/models/effective/cart_item.rb +15 -13
  30. data/app/models/effective/customer.rb +9 -9
  31. data/app/models/effective/datatables/order_items.rb +14 -8
  32. data/app/models/effective/datatables/orders.rb +56 -69
  33. data/app/models/effective/order.rb +250 -139
  34. data/app/models/effective/order_item.rb +23 -16
  35. data/app/models/effective/product.rb +23 -0
  36. data/app/models/effective/providers/ccbill_postback.rb +85 -0
  37. data/app/models/effective/{stripe_charge.rb → providers/stripe_charge.rb} +1 -1
  38. data/app/models/effective/subscription.rb +16 -12
  39. data/app/models/effective/tax_rate_calculator.rb +45 -0
  40. data/app/views/admin/customers/index.html.haml +2 -5
  41. data/app/views/admin/order_items/index.html.haml +2 -5
  42. data/app/views/admin/orders/_actions.html.haml +2 -0
  43. data/app/views/admin/orders/_form.html.haml +28 -0
  44. data/app/views/admin/orders/_order_item_fields.html.haml +9 -0
  45. data/app/views/admin/orders/index.html.haml +9 -5
  46. data/app/views/admin/orders/new.html.haml +3 -0
  47. data/app/views/effective/carts/_cart.html.haml +3 -12
  48. data/app/views/effective/carts/_cart_actions.html.haml +4 -0
  49. data/app/views/effective/carts/show.html.haml +10 -12
  50. data/app/views/effective/orders/_checkout_step1.html.haml +46 -0
  51. data/app/views/effective/orders/_checkout_step2.html.haml +33 -0
  52. data/app/views/effective/orders/_order.html.haml +2 -0
  53. data/app/views/effective/orders/_order_actions.html.haml +10 -5
  54. data/app/views/effective/orders/_order_footer.html.haml +1 -0
  55. data/app/views/effective/orders/_order_items.html.haml +11 -9
  56. data/app/views/effective/orders/_order_note.html.haml +8 -0
  57. data/app/views/effective/orders/_order_note_fields.html.haml +5 -0
  58. data/app/views/effective/orders/_order_shipping.html.haml +4 -4
  59. data/app/views/effective/orders/_order_user_fields.html.haml +1 -0
  60. data/app/views/effective/orders/_orders_table.html.haml +27 -0
  61. data/app/views/effective/orders/ccbill/_form.html.haml +24 -0
  62. data/app/views/effective/orders/checkout_step1.html.haml +3 -0
  63. data/app/views/effective/orders/checkout_step2.html.haml +3 -0
  64. data/app/views/effective/orders/cheque/_form.html.haml +2 -0
  65. data/app/views/effective/orders/cheque/pay_by_cheque.html.haml +9 -0
  66. data/app/views/effective/orders/declined.html.haml +4 -2
  67. data/app/views/effective/orders/my_purchases.html.haml +1 -1
  68. data/app/views/effective/orders/my_sales.html.haml +1 -1
  69. data/app/views/effective/orders/purchased.html.haml +3 -2
  70. data/app/views/effective/orders/show.html.haml +1 -1
  71. data/app/views/effective/orders/stripe/_form.html.haml +5 -5
  72. data/app/views/effective/orders_mailer/order_error.html.haml +11 -0
  73. data/app/views/effective/orders_mailer/payment_request_to_buyer.html.haml +13 -0
  74. data/app/views/effective/orders_mailer/pending_order_invoice_to_buyer.html.haml +13 -0
  75. data/app/views/layouts/effective_orders_mailer_layout.html.haml +7 -7
  76. data/config/routes.rb +39 -24
  77. data/db/migrate/01_create_effective_orders.rb.erb +20 -1
  78. data/db/upgrade/03_upgrade_effective_orders_from1x.rb.erb +95 -0
  79. data/lib/effective_orders.rb +67 -9
  80. data/lib/effective_orders/app_checkout_service.rb +1 -2
  81. data/lib/effective_orders/engine.rb +46 -14
  82. data/lib/effective_orders/version.rb +1 -1
  83. data/lib/generators/effective_orders/install_generator.rb +1 -0
  84. data/lib/generators/effective_orders/upgrade_from03x_generator.rb +1 -0
  85. data/lib/generators/effective_orders/upgrade_from1x_generator.rb +31 -0
  86. data/lib/generators/templates/effective_orders.rb +131 -66
  87. data/lib/generators/templates/effective_orders_mailer_preview.rb +28 -13
  88. data/spec/controllers/admin/orders_controller_spec.rb +242 -0
  89. data/spec/controllers/ccbill_orders_controller_spec.rb +103 -0
  90. data/spec/controllers/moneris_orders_controller_spec.rb +23 -23
  91. data/spec/controllers/orders_controller_spec.rb +167 -79
  92. data/spec/controllers/stripe_orders_controller_spec.rb +7 -7
  93. data/spec/dummy/app/models/product.rb +0 -8
  94. data/spec/dummy/app/models/product_with_float_price.rb +0 -8
  95. data/spec/dummy/app/models/user.rb +2 -19
  96. data/spec/dummy/config/application.rb +2 -1
  97. data/spec/dummy/config/environments/test.rb +1 -0
  98. data/spec/dummy/config/initializers/effective_orders.rb +109 -64
  99. data/spec/dummy/db/schema.rb +15 -2
  100. data/spec/dummy/db/test.sqlite3 +0 -0
  101. data/spec/dummy/log/test.log +0 -258
  102. data/spec/models/acts_as_purchasable_spec.rb +8 -6
  103. data/spec/models/factories_spec.rb +7 -1
  104. data/spec/models/order_item_spec.rb +1 -1
  105. data/spec/models/order_spec.rb +165 -46
  106. data/spec/models/stripe_charge_spec.rb +5 -5
  107. data/spec/spec_helper.rb +2 -0
  108. data/spec/support/factories.rb +49 -33
  109. metadata +47 -64
  110. data/app/views/effective/orders/_checkout_step_1.html.haml +0 -43
  111. data/app/views/effective/orders/_checkout_step_2.html.haml +0 -25
  112. data/app/views/effective/orders/_my_purchases.html.haml +0 -17
  113. data/app/views/effective/orders/checkout.html.haml +0 -3
  114. data/app/views/effective/orders/new.html.haml +0 -4
  115. data/spec/dummy/log/development.log +0 -82
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e1c32ade8d8bebb1a9228624548b1ab9702e193d
4
- data.tar.gz: a3b35b62b2b44f30ca4475af4e130ae7dc5d9775
3
+ metadata.gz: 491804404e9833c139b5f3c4d90c190e09ad2fba
4
+ data.tar.gz: 1d3773f087028234c8c04d784ebec0fcb290efc5
5
5
  SHA512:
6
- metadata.gz: 8a573c500321453ec640db547d37096c27f74da1de0d79ed1f4dc805c2a97b4d982f0f570e9e03ea75e510390d706f1bfe6e79f2e280e2bc081d56ecba08c2d2
7
- data.tar.gz: 87cdd2c31a3a701caf49ad1e6d69c06747c63689ac92ae5a036265229df4d7b98e86c8c7460d5ce632c644fe48f742eb0261fd2573a000d6adc860f8afbaf413
6
+ metadata.gz: e906c27c833ce87d77450b7d99ed5ac8a94c6d1f72e1be9bbd3efeb16ea7d59403947755c567c0e3f73334f15dff060779b2760b9272dceabfc0c6d5f570d70e
7
+ data.tar.gz: a3727d9a492c1512fe2f22b4ff540f2c02536454f43fbc239da67ca0b99d955e4604fc947565f571573416c4849b9b3fd087b088010f3e89182f7d6f13b0c71d
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2014 Code and Effect Inc.
1
+ Copyright 2016 Code and Effect Inc.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 2.0 Branch
2
+
3
+ This is a work in progress branch. Don't use this yet!
4
+
1
5
  # Effective Orders
2
6
 
3
7
  Carts, Orders, and collecting payment via Stripe, PayPal and Moneris.
@@ -12,6 +16,12 @@ Has Order History, My Purchases, My Sales and Admin screens.
12
16
 
13
17
  ## Getting Started
14
18
 
19
+ Check your ruby version. As of the 2.0 branch, effective_orders requires a minimum ruby version of `2.1`:
20
+
21
+ ```console
22
+ ruby -v
23
+ ```
24
+
15
25
  Add to your Gemfile:
16
26
 
17
27
  ```ruby
@@ -52,28 +62,27 @@ Require the stylesheet on the asset pipeline by adding the following to your app
52
62
  *= require effective_orders
53
63
  ```
54
64
 
55
- ### Upgrading from 0.3.x
65
+ ### Upgrading to 2.0.x
56
66
 
57
- In the 0.3.x versions of this gem, prices were internally represented as Decimals
67
+ The `tax_rate_method` configuration option has been removed and renamed to `order_tax_rate_method`.
68
+ Changing this in `/config/initializers/effective_orders.rb` is the first step.
58
69
 
59
- This has been changed in 0.4.x to properly be Integer columns
60
-
61
- If you're running a 0.3.x or earlier version, please upgrade to 0.4.x with this one command:
70
+ The default implementation assigns the tax rate based on the order's billing_address (see the [Tax section](#tax)):
62
71
 
63
72
  ```ruby
64
- rails generate effective_orders:upgrade_from03x
73
+ config.order_tax_rate_method = Proc.new { |order| Effective::TaxRateCalculator.new(order: order).tax_rate }
65
74
  ```
66
75
 
67
- the above command will upgrade the order_items and subscriptions tables.
68
-
69
- If you have additional (products or whatever..) tables with a column `price` represented as a Decimal, they should also be upgraded.
76
+ There are numerous database changes in the 2.0.0 line of effective_orders.
70
77
 
71
- To upgrade, use this generator to create a migration on table `products` with column `price`:
78
+ if you are running a 1.x version, please upgrade your database with this command:
72
79
 
73
80
  ```ruby
74
- bundle exec rails generate effective_orders:upgrade_price_column products price
81
+ rails generate effective_orders:upgrade_from1x
75
82
  ```
76
83
 
84
+ the above command will add `products` table to you DB.
85
+
77
86
  ## High Level Overview
78
87
 
79
88
  Your rails app creates and displays a list of `acts_as_purchsable` objects, each with a `link_to_add_to_cart(object)`.
@@ -133,22 +142,22 @@ class Product < ActiveRecord::Base
133
142
  structure do
134
143
  title :string
135
144
 
136
- price :integer, :default => 0
137
- tax_exempt :boolean, :default => false
145
+ price :integer, default: 0
146
+ tax_exempt :boolean, default: false
138
147
 
139
- archived :boolean, :default => false
148
+ archived :boolean, default: false
140
149
 
141
150
  timestamps
142
151
  end
143
152
 
144
153
  validates_presence_of :title
145
- validates_numericality_of :price, :greater_than_or_equal_to => 0
154
+ validates_numericality_of :price, greater_than_or_equal_to: 0
146
155
 
147
- scope :products, -> { where(:archived => false) }
156
+ scope :products, -> { where(archived: false) }
148
157
 
149
158
  # This archives Products instead of deleting them
150
159
  def destroy
151
- update_attributes(:archived => true)
160
+ update_attributes(archived: true)
152
161
  end
153
162
 
154
163
  end
@@ -189,7 +198,7 @@ This is available for simple_form, formtastic and Rails default FormBuilder.
189
198
  = simple_form_for(@product) do |f|
190
199
  = f.input :title
191
200
  = f.input :tax_exempt
192
- = f.input :price, :as => :price
201
+ = f.input :price, as: :price
193
202
  = f.button :submit
194
203
  ```
195
204
 
@@ -197,7 +206,7 @@ or
197
206
 
198
207
  ```ruby
199
208
  = semantic_form_for(@product) do |f|
200
- = f.input :price, :as => :price
209
+ = f.input :price, as: :price
201
210
  ```
202
211
 
203
212
  or
@@ -207,16 +216,16 @@ or
207
216
  = f.price_field :price
208
217
  ```
209
218
 
210
- The `:as => :price` will work interchangeably with SimpleForm or Formtastic, as long as only one of these gems is present in your application
219
+ The `as: :price` will work interchangeably with SimpleForm or Formtastic, as long as only one of these gems is present in your application
211
220
 
212
221
  If you use both SimpleForm and Formtastic, you will need to call price input differently:
213
222
 
214
223
  ```ruby
215
224
  = simple_form_for(@product) do |f|
216
- = f.input :price, :as => :price_simple_form
225
+ = f.input :price, as: :price_simple_form
217
226
 
218
227
  = semantic_form_for @user do |f|
219
- = f.input :price, :as => :price_formtastic
228
+ = f.input :price, as: :price_formtastic
220
229
  ```
221
230
 
222
231
  ### Products#show
@@ -226,7 +235,7 @@ So back on the Product#show page, we will render the product with an Add To Cart
226
235
  ```haml
227
236
  %h4= @product.title
228
237
  %p= price_to_currency(@product.price)
229
- %p= link_to_add_to_cart(@product, :class => 'btn btn-primary', :label => 'Add To My Shopping Cart')
238
+ %p= link_to_add_to_cart(@product, class: 'btn btn-primary', label: 'Add To My Shopping Cart')
230
239
  ```
231
240
 
232
241
  Please take note of the `price_to_currency` helper above.
@@ -246,7 +255,7 @@ We still need to create a link to the Shopping Cart page so that the user can vi
246
255
  or
247
256
 
248
257
  ```ruby
249
- = link_to_current_cart(:label => 'Shopping Cart', :class => 'btn btn-prmary') # To display Shopping Cart (3) when there are 3 items
258
+ = link_to_current_cart(label: 'Shopping Cart', class: 'btn btn-prmary') # To display Shopping Cart (3) when there are 3 items
250
259
  ```
251
260
 
252
261
  or
@@ -266,13 +275,13 @@ The checkout screen can be reached through the My Cart page, or linked to direct
266
275
  or
267
276
 
268
277
  ```ruby
269
- = link_to_checkout(:label => 'Continue to Checkout', :class => 'btn btn-primary')
278
+ = link_to_checkout(label: 'Continue to Checkout', class: 'btn btn-primary')
270
279
  ```
271
280
 
272
281
  or
273
282
 
274
283
  ```ruby
275
- = link_to 'Go Checkout Already', effective_orders.new_order_path
284
+ = link_to 'Continue to Checkout', effective_orders.new_order_path
276
285
  ```
277
286
 
278
287
  From here, the effective_orders engine takes over, walks the user through billing and shipping details screens, then finally collects payment through one of the configured payment processors.
@@ -325,17 +334,43 @@ Of course, there's no mechanism here to prevent someone from just copy&pasting t
325
334
  If you're interested in that kind of restricted-download functionality, please check out [effective_assets](https://github.com/code-and-effect/effective_assets) and the authenticated-read temporary URLs.
326
335
 
327
336
 
328
- ### Tax
337
+ ### Tax Exempt
329
338
 
330
339
  All `acts_as_purchasable` objects will respond to the boolean method `tax_exempt`.
331
340
 
332
341
  By default, `tax_exempt` is false, meaning that tax must be applied to this item.
333
342
 
334
- The tax calculation is controlled by the config/initializers/effective_orders.rb `config.tax_rate_method` and may be set on an app wide basis.
335
-
336
343
  If `tax_exempt` returns true, it means that no tax will be applied to this item.
337
344
 
338
- Please see the initializer for more information.
345
+ ### Tax
346
+
347
+ The tax calculation applied to an order is controlled by the config/initializers/effective_orders.rb `config.order_tax_rate_method`
348
+
349
+ The default implementation assigns the tax rate based on the order's billing_address:
350
+
351
+ ```ruby
352
+ config.order_tax_rate_method = Proc.new { |order| Effective::TaxRateCalculator.new(order: order).tax_rate }
353
+ ```
354
+
355
+ Right now, the `Effective::TaxRateCalculator` only supports taxes for Canadian provinces.
356
+
357
+ US and international tax rates are not currently supported and are assigned 0% tax.
358
+
359
+ Instead of calculating based on the billing_address, a single static tax rate can be applied to all orders.
360
+
361
+ To apply 12.5% tax to all orders:
362
+
363
+ ```ruby
364
+ config.order_tax_rate_method = Proc.new { |order| 12.5 }
365
+ ```
366
+
367
+ Or to apply 0% tax:
368
+
369
+ ```ruby
370
+ config.order_tax_rate_method = Proc.new { |order| 0 }
371
+ ```
372
+
373
+ Please see the initializer file for more information.
339
374
 
340
375
 
341
376
  ### Callbacks
@@ -398,8 +433,8 @@ You can rescue from this exception by adding the following to your application_c
398
433
  ```ruby
399
434
  rescue_from Effective::AccessDenied do |exception|
400
435
  respond_to do |format|
401
- format.html { render 'static_pages/access_denied', :status => 403 }
402
- format.any { render :text => 'Access Denied', :status => 403 }
436
+ format.html { render 'static_pages/access_denied', status: 403 }
437
+ format.any { render text: 'Access Denied', status: 403 }
403
438
  end
404
439
  end
405
440
  ```
@@ -409,9 +444,9 @@ end
409
444
  The permissions you actually want to define for a regular user are as follows (using CanCan):
410
445
 
411
446
  ```ruby
412
- can [:manage], Effective::Cart, :user_id => user.id
413
- can [:manage], Effective::Order, :user_id => user.id # Orders cannot be deleted
414
- can [:manage], Effective::Subscription, :user_id => user.id
447
+ can [:manage], Effective::Cart, user_id: user.id
448
+ can [:manage], Effective::Order, user_id: user.id # Orders cannot be deleted
449
+ can [:manage], Effective::Subscription, user_id: user.id
415
450
  ```
416
451
 
417
452
  In addition to the above, the following permissions allow access to the `/admin` screens:
@@ -479,7 +514,7 @@ The Order has now been purchased.
479
514
  If you are using effective_orders to roll your own custom payment workflow, you should be aware of the following helpers:
480
515
 
481
516
  - `render_checkout(order)` to display the standard Checkout step inline.
482
- - `render_checkout(order, :purchased_redirect_url => '/', :declined_redirect_url => '/')` to display the Checkout step with custom redirect paths.
517
+ - `render_checkout(order, purchased_redirect_url: '/', declined_redirect_url: '/')` to display the Checkout step with custom redirect paths.
483
518
 
484
519
  - `render_purchasables(one_or_more_acts_as_purchasable_objects)` to display a list of purchasable items
485
520
 
@@ -503,7 +538,7 @@ The `acts_as_purchasable` `.purchased?` and `.purchased_by?(user)` methods only
503
538
  To programatically purchase one or more `acts_as_purchasable` objects:
504
539
 
505
540
  ```ruby
506
- Effective::Order.new([@product1, @product2], current_user).purchase!('from my rake task')
541
+ Effective::Order.new(@product1, @product2, user: current_user).purchase!(details: 'from my rake task')
507
542
  ```
508
543
 
509
544
  Here the `billing_address` and `shipping_address` are copied from the `current_user` object if the `current_user` responds_to `billing_address` / `shipping_address` as per [effective_addresses](https://github.com/code-and-effect/effective_addresses/).
@@ -517,7 +552,7 @@ order.billing_address = Effective::Address.new(...)
517
552
  order.shipping_address = Effective::Address.new(...)
518
553
  order.add(@product1)
519
554
  order.add(@product2)
520
- order.purchase!(:some => {:complicated => 'details', :in => 'a hash'})
555
+ order.purchase!(details: {complicated: 'details', in: 'a hash'})
521
556
  ```
522
557
 
523
558
  The one gotcha with the above two scenarios, is that when `purchase!` is called, the `Effective::Order` in question will run through its validations. These validations include:
@@ -526,13 +561,13 @@ The one gotcha with the above two scenarios, is that when `purchase!` is called,
526
561
  - `validates_presence_of :shipping_address` when configured to be required
527
562
  - `validates :user` which can be disabled via config initializer
528
563
 
529
- - `validates_numericality_of :total, :greater_than_or_equal_to => minimum_charge` where minimum_charge is the configured value, once again from the initializer
564
+ - `validates_numericality_of :total, greater_than_or_equal_to: minimum_charge` where minimum_charge is the configured value, once again from the initializer
530
565
  - `validates_presence_of :order_items` the Order must have at least one OrderItem
531
566
 
532
567
  You can skip validations with the following command, but be careful as this skips all validations:
533
568
 
534
569
  ```ruby
535
- Effective::Order.new(@product, @user).purchase!('no validations', :validate => false)
570
+ Effective::Order.new(@product, user: @user).purchase!(validate: false)
536
571
  ```
537
572
 
538
573
  The `@product` is now considered purchased.
@@ -554,7 +589,7 @@ This screen displays all past purchases made by the current user. You can add i
554
589
  or
555
590
 
556
591
  ```ruby
557
- = link_to_my_purchases(:label => 'Order History', :class => 'btn btn-primary')
592
+ = link_to_my_purchases(label: 'Order History', class: 'btn btn-primary')
558
593
  ```
559
594
 
560
595
  or
@@ -576,7 +611,7 @@ Totally optional, but another way of displaying the Order History is to use the
576
611
  In your controller:
577
612
 
578
613
  ```ruby
579
- @datatable = Effective::Datatables::Orders.new(:user_id => @user.id)
614
+ @datatable = Effective::Datatables::Orders.new(user_id: @user.id)
580
615
  ```
581
616
 
582
617
  and then in the view:
@@ -667,17 +702,17 @@ Copy these two values into the appropriate lines of config/effective_orders.rb i
667
702
 
668
703
  if Rails.env.production?
669
704
  config.moneris = {
670
- :ps_store_id => '',
671
- :hpp_key => '',
672
- :hpp_url => 'https://www3.moneris.com/HPPDP/index.php',
673
- :verify_url => 'https://www3.moneris.com/HPPDP/verifyTxn.php'
705
+ ps_store_id: '',
706
+ hpp_key: '',
707
+ hpp_url: 'https://www3.moneris.com/HPPDP/index.php',
708
+ verify_url: 'https://www3.moneris.com/HPPDP/verifyTxn.php'
674
709
  }
675
710
  else
676
711
  config.moneris = {
677
- :ps_store_id => 'VZ9BNtore1',
678
- :hpp_key => 'hp1Y5J35GVDM',
679
- :hpp_url => 'https://esqa.moneris.com/HPPDP/index.php',
680
- :verify_url => 'https://esqa.moneris.com/HPPDP/verifyTxn.php'
712
+ ps_store_id: 'VZ9BNtore1',
713
+ hpp_key: 'hp1Y5J35GVDM',
714
+ hpp_url: 'https://esqa.moneris.com/HPPDP/index.php',
715
+ verify_url: 'https://esqa.moneris.com/HPPDP/verifyTxn.php'
681
716
  }
682
717
  end
683
718
  ```
@@ -781,9 +816,9 @@ Then enable Stripe in the app/config/effective_orders.rb initializer and enter y
781
816
  config.stripe_enabled = true
782
817
 
783
818
  config.stripe = {
784
- :secret_key => 'sk_live_IKd6HDaYUfoRjflWQTXfFNfc',
785
- :publishable_key => 'pk_live_liEGn9f0mcxKmoSjoeNbbuE1',
786
- :currency => 'usd'
819
+ secret_key: 'sk_live_IKd6HDaYUfoRjflWQTXfFNfc',
820
+ publishable_key: 'pk_live_liEGn9f0mcxKmoSjoeNbbuE1',
821
+ currency: 'usd'
787
822
  }
788
823
  ```
789
824
 
@@ -814,10 +849,10 @@ And add these values to the app/config/effective_orders.rb initializer:
814
849
 
815
850
  ```ruby
816
851
  config.stripe = {
817
- :secret_key => 'sk_live_IKd6HDaYUfoRjflWQTXfFNfc',
818
- :publishable_key => 'pk_live_liEGn9f0mcxKmoSjoeNbbuE1',
819
- :currency => 'usd',
820
- :connect_client_id => 'ca_35jLok5G9kosyYF7quTOwcauJjTnUnud'
852
+ secret_key: 'sk_live_IKd6HDaYUfoRjflWQTXfFNfc',
853
+ publishable_key: 'pk_live_liEGn9f0mcxKmoSjoeNbbuE1',
854
+ currency: 'usd',
855
+ connect_client_id: 'ca_35jLok5G9kosyYF7quTOwcauJjTnUnud'
821
856
  }
822
857
  ```
823
858
 
@@ -933,6 +968,63 @@ The secret can be any string. Here's a good way to come up with a secret:
933
968
  This process should be very similar although you'll create and configure a seller account on paypal.com rather than the sandbox site.
934
969
  You should generate separate private and public certificates/keys for this and it is advisable to not keep production certificates/keys in version control.
935
970
 
971
+ ## Paying via CCBill
972
+
973
+ Effective Orders has implemented checkout with CCBill using their "Dynamic Pricing" API and does not
974
+ integrate with CCBill subscriptions. If you need to make payments for CCBill subscriptions, please help
975
+ by improving Effective Orders with this functionality.
976
+
977
+ ### CCBill Account Setup
978
+
979
+ You need a merchant account with CCBill so go sign up and login. To set up your account with Dynamic
980
+ Pricing, you'll need to go through some hoops with CCBill:
981
+
982
+ 1. Get approval to operate a merchant account from CCBill Merchant Services (they'll need to see your
983
+ site in action)
984
+ 2. Provide CCBill with two valid forms of ID and wait for them to approve your account
985
+ 3. Create two additional sub accounts for a staging server and your localhost
986
+ ("Account Info" > "Account Setup")
987
+ 4. Get each new sub account approved by Merchant Services (mention that they are for testing only)
988
+ 5. Ask CCBill tech support to set up all sub accounts with Dynamic Pricing
989
+ 6. Set the postback urls for each sub account to be `"#{ your_domain_name }/orders/ccbill_postback`
990
+ (Look for 'Approval Post URL' and 'Denial Post URL' in "Account Info" > "Sub Account Admin" > select sub account
991
+ \> "Advanced" > under 'Background Post Information')
992
+
993
+ ### Effective Orders Configuration
994
+
995
+ Get the following information and add it
996
+ to the Effective Orders initializer. CCBill live chat is generally quick and helpful. They can help you
997
+ find any of this information.
998
+
999
+ - Account number (`:client_accnum`)
1000
+ - Subaccount number (`:client_subacc`)
1001
+ - Checkout form id/name (`:form_name`)
1002
+ - Currency code (`:currency_code`)
1003
+ - Encryption key/salt (`:dynamic_pricing_salt`)("Account Info" > "Sub Account Admin" > select sub account
1004
+ \> "Advanced" > under 'Upgrade Security Setup Information' > 'Encryption key')
1005
+
1006
+ Effective Orders will authorize to make changes to the customer's order during CCBill's post back after
1007
+ the transaction. Since, this is not an action that the customer takes directly, please make sure
1008
+ that the Effective Orders authorization method returns `true` for the controller/action
1009
+ `'Effective::OrdersController#ccbill_postback'` with an `Effective::Order` resource.
1010
+
1011
+ ### Testing transactions with CCBill
1012
+
1013
+ To test payments with CCBill:
1014
+
1015
+ 1. Set up yourself as a user who is authorized to make test transactions
1016
+ ([See this guide](https://www.ccbill.com/cs/wiki/tiki-index.php?page=How+do+I+set+up+a+user+to+process+test+transactions%3F))
1017
+ 2. Use ngrok on localhost or a staging server to go through a normal payment (remember to configure the
1018
+ postback urls (see #6 of [CCBill Account Setup](#ccbill-account-setup))
1019
+ 3. Use one of the provided credit card numbers in the guide from step 1 for the associated response
1020
+
1021
+ ### Helpful CCBill Documentation
1022
+
1023
+ - [Dynamic Pricing](https://www.ccbill.com/cs/wiki/tiki-index.php?page=Dynamic+Pricing)
1024
+ - [Dynamic Pricing User Guide](https://www.ccbill.com/cs/wiki/tiki-index.php?page=Dynamic+Pricing+User+Guide)
1025
+ - [Background Post](https://www.ccbill.com/cs/wiki/tiki-index.php?page=Background+Post)
1026
+ - [Webhooks](https://www.ccbill.com/cs/wiki/tiki-index.php?page=Webhooks+User+Guide)
1027
+ - [How do I set up a user to process test transactions?](https://www.ccbill.com/cs/wiki/tiki-index.php?page=How+do+I+set+up+a+user+to+process+test+transactions%3F)
936
1028
 
937
1029
  ## Paying Using App Currency or Logic
938
1030
 
@@ -1016,12 +1108,10 @@ Code and Effect is the product arm of [AgileStyle](http://www.agilestyle.com/),
1016
1108
 
1017
1109
  ## Testing
1018
1110
 
1019
- The test suite for this gem is mostly complete.
1020
-
1021
1111
  Run tests by:
1022
1112
 
1023
1113
  ```ruby
1024
- guard
1114
+ rspec
1025
1115
  ```
1026
1116
 
1027
1117
 
data/Rakefile CHANGED
@@ -5,9 +5,6 @@ rescue LoadError
5
5
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
6
  end
7
7
 
8
- # Our tasks
9
- load 'lib/tasks/effective_orders_tasks.rake'
10
-
11
8
  # Testing tasks
12
9
  APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
13
10
  load 'rails/tasks/engine.rake'
@@ -19,6 +19,11 @@ if defined?(ActiveAdmin)
19
19
 
20
20
  def scoped_collection
21
21
  scoped = end_of_association_chain.includes(:user).includes(order_items: :purchasable)
22
+
23
+ if EffectiveOrders.orders_collection_scope.respond_to?(:call)
24
+ scoped = EffectiveOrders.orders_collection_scope.call(scoped)
25
+ end
26
+
22
27
  scoped = scoped.where(user: current_user) if !authorized?(:admin, :effective_orders)
23
28
  scoped
24
29
  end
@@ -55,12 +60,12 @@ if defined?(ActiveAdmin)
55
60
  price_to_currency(order.total)
56
61
  end
57
62
 
58
- column :payment_method do |order|
59
- order.payment_method
63
+ column :payment_provider do |order|
64
+ order.payment_provider
60
65
  end
61
66
 
62
- column :payment_card_type do |order|
63
- order.payment_card_type
67
+ column :payment_card do |order|
68
+ order.payment_card
64
69
  end
65
70
 
66
71
  column do |order|
@@ -80,8 +85,8 @@ if defined?(ActiveAdmin)
80
85
  col_headers << "Subtotal"
81
86
  col_headers << "Tax"
82
87
  col_headers << "Total"
83
- col_headers << 'Purchase method'
84
- col_headers << 'Card Type'
88
+ col_headers << 'Payment provider'
89
+ col_headers << 'Payment card'
85
90
 
86
91
  csv_string = CSV.generate do |csv|
87
92
  csv << col_headers
@@ -91,12 +96,12 @@ if defined?(ActiveAdmin)
91
96
  order.to_param,
92
97
  order.purchased_at.strftime("%Y-%m-%d %H:%M:%S %z"),
93
98
  order.user.try(:email),
94
- (order.billing_address.try(:full_name) || order.user.to_s),
99
+ (order.try(:billing_address).try(:full_name) || order.user.to_s),
95
100
  (order.subtotal / 100.0).round(2),
96
101
  (order.tax / 100.0).round(2),
97
102
  (order.total / 100.0).round(2),
98
- order.payment_method,
99
- order.payment_card_type
103
+ order.payment_provider,
104
+ order.payment_card
100
105
  ]
101
106
  end
102
107
  end