spree_bitpay 1.0.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. metadata +44 -1243
  3. data/.gitignore +0 -26
  4. data/.rspec +0 -1
  5. data/.travis.yml +0 -18
  6. data/Gemfile +0 -7
  7. data/LICENSE.txt +0 -22
  8. data/README.md +0 -79
  9. data/Rakefile +0 -21
  10. data/app/assets/images/BC_nBG_64px.png +0 -0
  11. data/app/assets/images/bitcoin.png +0 -0
  12. data/app/assets/javascripts/easyModal.js-master/.gitignore +0 -1
  13. data/app/assets/javascripts/easyModal.js-master/README.md +0 -3
  14. data/app/assets/javascripts/easyModal.js-master/bower.json +0 -20
  15. data/app/assets/javascripts/easyModal.js-master/jquery.easyModal.js +0 -161
  16. data/app/assets/javascripts/spree/backend/spree_bitpay.js +0 -3
  17. data/app/assets/javascripts/spree/frontend/spree_bitpay.js +0 -86
  18. data/app/assets/stylesheets/spree/backend/spree_bitpay.css +0 -3
  19. data/app/assets/stylesheets/spree/frontend/spree_bitpay.css +0 -58
  20. data/app/controllers/spree/bitpay_controller.rb +0 -243
  21. data/app/models/order_decorator.rb +0 -17
  22. data/app/models/spree/bitpay_invoice.rb +0 -23
  23. data/app/models/spree/payment_method/bitpay.rb +0 -64
  24. data/app/overrides/spree/payments/_payment/bitpay_payment_params.html.erb.deface +0 -55
  25. data/app/views/spree/admin/payments/source_views/_bitpay.html.erb +0 -23
  26. data/app/views/spree/checkout/payment/_bitpay.html.erb +0 -4
  27. data/bin/rails +0 -7
  28. data/config/locales/en.yml +0 -16
  29. data/config/routes.rb +0 -9
  30. data/db/migrate/20140720052959_create_spree_bitpay_invoices.rb +0 -8
  31. data/db/migrate/20140725200946_add_fields_to_spree_bitpay_invoice.rb +0 -14
  32. data/db/migrate/20140729192827_add_index_to_spree_payments.rb +0 -5
  33. data/lib/generators/spree_bitpay/install/install_generator.rb +0 -32
  34. data/lib/spree_bitpay.rb +0 -3
  35. data/lib/spree_bitpay/engine.rb +0 -28
  36. data/lib/spree_bitpay/factories.rb +0 -6
  37. data/lib/spree_bitpay/version.rb +0 -3
  38. data/script/rails +0 -7
  39. data/spec/factories/bitpay_test_factories.rb +0 -58
  40. data/spec/features/bitpay_plugin_spec.rb +0 -75
  41. data/spec/fixtures/valid_confirmed_callback.json +0 -27
  42. data/spec/fixtures/valid_confirmed_invoice.json +0 -15
  43. data/spec/fixtures/valid_expired_invoice.json +0 -16
  44. data/spec/fixtures/valid_invalid_callback.json +0 -27
  45. data/spec/fixtures/valid_invalid_invoice.json +0 -15
  46. data/spec/fixtures/valid_new_invoice.json +0 -15
  47. data/spec/fixtures/valid_overpaid_callback.json +0 -27
  48. data/spec/fixtures/valid_overpaid_invoice.json +0 -15
  49. data/spec/fixtures/valid_paid_callback.json +0 -27
  50. data/spec/fixtures/valid_paid_invoice.json +0 -15
  51. data/spec/models/spree/order_spec.rb +0 -41
  52. data/spec/models/spree/payment_method/bitpay.rb +0 -26
  53. data/spec/requests/notifications_spec.rb +0 -218
  54. data/spec/spec_helper.rb +0 -131
  55. data/spree_bitpay.gemspec +0 -40
  56. data/testapp.sh +0 -6
@@ -1,23 +0,0 @@
1
- <% invoice = @payment.source.find_invoice %>
2
- <% if invoice %>
3
- <div class="bitpay_invoice_details">
4
- <h3>Bitpay Invoice Details</h3>
5
- <pre><%= JSON.pretty_generate(invoice) %></pre>
6
- </div>
7
-
8
- <%= link_to Spree.t(:bitpay_refresh_invoice), bitpay_refresh_url(payment: @payment), {id: "refresh_invoice", class: "button primary", title: Spree.t(:bitpay_refresh_invoice_description)} %>
9
-
10
- <div class="bitpay_invoice_details">
11
- <h3>Invoice</h3>
12
- <iframe id="bitpay_view_invoice_iframe"
13
- src="<%= j bitpay_view_invoice_url(source_id: @payment.source).html_safe %>"
14
- scrolling="no"
15
- allowtransparency="true"
16
- frameborder="0">
17
- </iframe>
18
- <br/>
19
- <%= link_to Spree.t(:bitpay_view_full_invoice), invoice["url"], {target: "_new"} %>
20
- </div>
21
- <% else %>
22
- <p>No BitPay Invoice Available</p>
23
- <% end %>
@@ -1,4 +0,0 @@
1
-
2
- <%= image_tag("BC_nBG_64px.png") %>
3
- <p><%= Spree.t(:bitpay_payment_method) %></p>
4
- <%= hidden_field_tag "payment_source[#{payment_method.id}][bogus]", 'bogus', :id => "bogus" %>
data/bin/rails DELETED
@@ -1,7 +0,0 @@
1
- # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
2
-
3
- ENGINE_ROOT = File.expand_path('../..', __FILE__)
4
- ENGINE_PATH = File.expand_path('../../lib/spree_bitpay/engine', __FILE__)
5
-
6
- require 'rails/all'
7
- require 'rails/engine/commands'
@@ -1,16 +0,0 @@
1
- en:
2
- spree:
3
- bitpay_cancel: "Choose another payment method"
4
- bitpay_checkout_error: "Error with Bitcoin checkout"
5
- bitpay_payment_completed: "Thank you for your payment."
6
- bitpay_invoice_expired: "The invoice has expired. Please re-select Bitcoin if you would like to retry."
7
- bitpay_payment_instructions: |
8
- Please pay the invoice above to continue.
9
- The page will automatically refresh in a few seconds when transaction is broadcast.
10
- bitpay_payment_method: "Payment will be requested following the confirmation."
11
- bitpay_view_invoice: "Continue to Invoice"
12
- bitpay_view_full_invoice: "View invoice at BitPay.com"
13
- bitpay_refresh_invoice: "Reprocess Invoice"
14
- bitpay_refresh_invoice_description: "Re-poll BitPay invoice and update order status"
15
- bitpay_payment_updated: "Payment status changed to: "
16
- bitpay_payment_not_updated: "No status change detected."
@@ -1,9 +0,0 @@
1
- Spree::Core::Engine.routes.draw do
2
- get '/spree_bitpay/invoice/new', :to => "bitpay#pay_now", :as => :bitpay_pay_now
3
- get '/spree_bitpay/invoice/view', :to => "bitpay#view_invoice", :as => :bitpay_view_invoice
4
- get '/spree_bitpay/payment_sent', :to => "bitpay#payment_sent", :as => :bitpay_payment_sent
5
- get '/spree_bitpay/cancel', :to => "bitpay#cancel", :as => :bitpay_cancel
6
- get '/spree_bitpay/refresh', :to => "bitpay#refresh", :as => :bitpay_refresh
7
- get '/spree_bitpay/check', :to => "bitpay#check_payment_state", :as => :bitpay_check
8
- post '/spree_bitpay/notification', :to => "bitpay#notification", :as => :bitpay_notification
9
- end
@@ -1,8 +0,0 @@
1
- class CreateSpreeBitpayInvoices < ActiveRecord::Migration
2
- def change
3
- create_table :spree_bitpay_invoices do |t|
4
- t.string :invoice_id
5
- t.timestamps
6
- end
7
- end
8
- end
@@ -1,14 +0,0 @@
1
- class AddFieldsToSpreeBitpayInvoice < ActiveRecord::Migration
2
- def change
3
-
4
- unless Spree::BitpayInvoice.column_names.include? "payment_method_id"
5
- add_column :spree_bitpay_invoices, :payment_method_id, :integer
6
- add_index :spree_bitpay_invoices, :payment_method_id
7
- end
8
-
9
- unless Spree::BitpayInvoice.column_names.include? "user_id"
10
- add_column :spree_bitpay_invoices, :user_id, :integer
11
- end
12
-
13
- end
14
- end
@@ -1,5 +0,0 @@
1
- class AddIndexToSpreePayments < ActiveRecord::Migration
2
- def change
3
- add_index :spree_payments, :identifier
4
- end
5
- end
@@ -1,32 +0,0 @@
1
- module SpreeBitpay
2
- module Generators
3
- class InstallGenerator < Rails::Generators::Base
4
-
5
- class_option :auto_run_migrations, :type => :boolean, :default => false
6
-
7
- def add_javascripts
8
- append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/spree_bitpay\n"
9
- append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require easyModal.js-master/jquery.easyModal\n"
10
- append_file 'vendor/assets/javascripts/spree/backend/all.js', "//= require spree/backend/spree_bitpay\n"
11
- end
12
-
13
- def add_stylesheets
14
- inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/spree_bitpay\n", :before => /\*\//, :verbose => true
15
- inject_into_file 'vendor/assets/stylesheets/spree/backend/all.css', " *= require spree/backend/spree_bitpay\n", :before => /\*\//, :verbose => true
16
- end
17
-
18
- def add_migrations
19
- run 'bundle exec rake railties:install:migrations FROM=spree_bitpay'
20
- end
21
-
22
- def run_migrations
23
- run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask 'Would you like to run the migrations now? [Y/n]')
24
- if run_migrations
25
- run 'bundle exec rake db:migrate'
26
- else
27
- puts 'Skipping rake db:migrate, don\'t forget to run it!'
28
- end
29
- end
30
- end
31
- end
32
- end
@@ -1,3 +0,0 @@
1
- require 'spree_core'
2
- require 'spree_bitpay/version'
3
- require 'spree_bitpay/engine'
@@ -1,28 +0,0 @@
1
- require 'bitpay'
2
-
3
- module SpreeBitpay
4
- class Engine < Rails::Engine
5
- require 'spree/core'
6
- isolate_namespace Spree
7
- engine_name 'spree_bitpay'
8
-
9
- # use rspec for tests
10
- config.generators do |g|
11
- g.test_framework :rspec
12
- end
13
-
14
- initializer "spree.bitpay.payment_methods", :after => "spree.register.payment_methods" do |app|
15
- app.config.spree.payment_methods << Spree::PaymentMethod::Bitpay
16
- end
17
-
18
- def self.activate
19
- Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
20
- Rails.configuration.cache_classes ? require(c) : load(c)
21
- end
22
- end
23
-
24
- config.to_prepare &method(:activate).to_proc
25
- end
26
- end
27
-
28
- Spree::PermittedAttributes.source_attributes.push(:bogus)
@@ -1,6 +0,0 @@
1
- FactoryGirl.define do
2
- # Define your Spree extensions Factories within this file to enable applications, and other extensions to use and override them.
3
- #
4
- # Example adding this to your spec_helper will load these Factories for use:
5
- # require 'spree_bitpay/factories'
6
- end
@@ -1,3 +0,0 @@
1
- module SpreeBitpay
2
- VERSION = "1.0.2"
3
- end
@@ -1,7 +0,0 @@
1
- # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
2
-
3
- ENGINE_ROOT = File.expand_path('../..', __FILE__)
4
- ENGINE_PATH = File.expand_path('../../lib/spree_bitpay/engine', __FILE__)
5
-
6
- require 'rails/all'
7
- require 'rails/engine/commands'
@@ -1,58 +0,0 @@
1
- ## Factories for setting up Spree BitPay inflight orders/payments
2
- #
3
- #
4
-
5
- # Easily recognizable dummy values
6
-
7
- PAYMENT_ID = "123PAYMENTID"
8
- ORDER_ID = "123ORDERID"
9
- INVOICE_ID = "123BitPayInvoiceID"
10
-
11
-
12
- FactoryGirl.define do
13
- ## Creates a payment in 'processing' state with associated order in 'confirm' state
14
- #
15
- factory :abstract_btc_payment, class: Spree::Payment do
16
- association :payment_method, factory: :bitcoin_payment_method
17
- association :source, factory: :bitcoin_invoice
18
- amount { order.total }
19
- response_code 'BTC'
20
- after(:create) do |payment|
21
- payment.identifier = PAYMENT_ID
22
- payment.save!
23
- payment.order.update!
24
- end
25
-
26
- factory :processing_payment_with_confirming_order do
27
- state 'processing'
28
- association :order, factory: :order_with_line_items, state: "confirm", number: ORDER_ID
29
- end
30
-
31
- factory :pending_payment_with_complete_order do
32
- state 'pending'
33
- association :order, factory: :order_with_line_items, state: "complete", number: ORDER_ID
34
- end
35
-
36
- factory :invalid_payment_with_confirming_order do
37
- state 'invalid'
38
- association :order, factory: :order_with_line_items, state: "confirm", number: ORDER_ID
39
- end
40
-
41
- factory :invalid_payment do
42
- state 'invalid'
43
- end
44
-
45
- end
46
-
47
- factory :bitcoin_payment_method, class: Spree::PaymentMethod::Bitpay do
48
- name 'Bitcoin Auto'
49
- environment 'test'
50
- end
51
-
52
- factory :bitcoin_invoice, class: Spree::BitpayInvoice do
53
- association :user
54
- invoice_id INVOICE_ID
55
- association :payment_method, factory: :bitcoin_payment_method
56
- end
57
-
58
- end
@@ -1,75 +0,0 @@
1
- require 'spec_helper'
2
-
3
- feature "Bitpay Plugin", js: true, type: :feature do
4
-
5
- # NOTE: Tests require a properly populated test DB as per testapp.sh.
6
- # Not all tests are idempotent - DB may require manual reset after test failure
7
-
8
- scenario "can be configured by admin" do
9
-
10
- admin = create(:admin_user, email: "test@bitpay.com")
11
-
12
- visit admin_login_path
13
- fill_in 'Email', with: admin.email
14
- fill_in 'Password', with: 'secret'
15
- click_button "Login"
16
- visit new_admin_payment_method_path
17
- # Should show up as a provider
18
- expect(page).to have_selector('#gtwy-type option[value="Spree::PaymentMethod::Bitpay"]'), "Not visible in drop down"
19
-
20
- fill_in "payment_method_name", with: "Bitcoin"
21
- fill_in "payment_method_description", with: "BitPay payment processing"
22
- select "Spree::PaymentMethod::Bitpay", from: "gtwy-type"
23
- # Should create a new PaymentMethod, redirect to edit page and flash success message
24
- expect { click_on "Create" }.to change(Spree::PaymentMethod, :count).by(1)
25
- #expect(response).to be_redirect
26
- expect(page).to have_selector('.success'), "No success message"
27
-
28
- # should have bitpay production address as default endpoint
29
- # (it does but somehow previous inputs get cached and take precedence??)
30
- # expect(page).to have_selector('#payment_method_bitpay_preferred_api_endpoint[value="https://bitpay.com/api"]')
31
-
32
- fill_in "payment_method_bitpay_preferred_api_endpoint", with: "https://test.bitpay.com/api"
33
- fill_in "payment_method_bitpay_preferred_api_key", with: ENV['BITPAYKEY']
34
- select "Test", from: "gtwy-env"
35
-
36
- click_on "Update"
37
- expect(page).to have_selector('.success'), "No success message"
38
- visit admin_logout_path
39
-
40
- end
41
-
42
- xscenario "can display invoice" do
43
- user = create(:user_with_addreses)
44
- shipping_method = create(:free_shipping_method, name: "Satoshi Post")
45
- product = create(:base_product, name: "BitPay T-Shirt")
46
- visit login_path
47
- fill_in 'Email', with: user.email
48
- fill_in 'Password', with: 'secret'
49
- click_button "Login"
50
-
51
- expect(current_path).to eq(root_path), "User Login failed"
52
- click_on "BitPay T-Shirt"
53
- click_button "Add To Cart"
54
- click_button "Checkout"
55
- click_button "Save and Continue" # Confirm Address
56
- click_button "Save and Continue" # Confirm Delivery Options
57
- choose "Bitcoin"
58
-
59
- #TODO expect image is visible
60
-
61
- expect { click_button "Save and Continue" }.to change(Spree::BitpayInvoice, :count).by(1) # Confirm Payment Options
62
- expect(current_path).to end_with "confirm"
63
-
64
- click_button "Place Order"
65
-
66
- page.within_frame 'bitpay_invoice_iframe' do
67
- expect(page).to have_content("Pay with Bitcoin")
68
- end
69
-
70
-
71
- #save_and_open_screenshot
72
-
73
- end
74
-
75
- end
@@ -1,27 +0,0 @@
1
- {"id":"123BitPayInvoiceID",
2
- "url":"https://localhost:8088/invoice?id=123BitPayInvoiceID",
3
- "posData":"{\"paymentID\":\"123PAYMENTID\",\"orderID\":\"123ORDERID\"}",
4
- "status":"confirmed",
5
- "btcPrice":"0.0512",
6
- "price":29.14,
7
- "currency":"USD",
8
- "invoiceTime":1407881291063,
9
- "expirationTime":1407882191063,
10
- "currentTime":1407882058099,
11
- "btcPaid":"0.0512",
12
- "rate":568.69,
13
- "exceptionStatus":false,
14
- "bitpay":
15
- {"id":"123BitPayInvoiceID",
16
- "url":"https://localhost:8088/invoice?id=123BitPayInvoiceID",
17
- "posData":"{\"paymentID\":\"123PAYMENTID\",\"orderID\":\"123ORDERID\"}",
18
- "status":"confirmed",
19
- "btcPrice":"0.0512",
20
- "price":29.14,
21
- "currency":"USD",
22
- "invoiceTime":1407881291063,
23
- "expirationTime":1407882191063,
24
- "currentTime":1407882058099,
25
- "btcPaid":"0.0512",
26
- "rate":568.69,
27
- "exceptionStatus":false}}
@@ -1,15 +0,0 @@
1
- {
2
- "id": "123BitPayInvoiceID",
3
- "url": "https://localhost:8088/invoice?id=123BitPayInvoiceID",
4
- "posData": "{\"paymentID\":\"123PAYMENTID\",\"orderID\":\"123ORDERID\"}",
5
- "status": "confirmed",
6
- "btcPrice": "0.0720",
7
- "price": 38.58,
8
- "currency": "USD",
9
- "invoiceTime": 1407988706154,
10
- "expirationTime": 1407989606154,
11
- "currentTime": 1407988785613,
12
- "btcPaid": "0.0720",
13
- "rate": 536.19,
14
- "exceptionStatus": false
15
- }
@@ -1,16 +0,0 @@
1
- {
2
- "id": "HA1CyVydbwLmB6LS35RNQE",
3
- "url": "https://paul.bp:8088/invoice?id=HA1CyVydbwLmB6LS35RNQE",
4
- "posData": "{\"paymentID\":\"EDY7PJWM\",\"orderID\":\"R337975673\"}",
5
- "status": "expired",
6
- "btcPrice": "0.0648",
7
- "price": 29.14,
8
- "currency": "USD",
9
- "invoiceTime": 1411008484489,
10
- "expirationTime": 1411009384489,
11
- "currentTime": 1411051760821,
12
- "btcPaid": "0.0000",
13
- "rate": 450,
14
- "exceptionStatus": false,
15
- "buyerFields": {}
16
- }
@@ -1,27 +0,0 @@
1
- {"id":"123BitPayInvoiceID",
2
- "url":"https://localhost:8088/invoice?id=123BitPayInvoiceID",
3
- "posData":"{\"paymentID\":\"123PAYMENTID\",\"orderID\":\"123ORDERID\"}",
4
- "status":"invalid",
5
- "btcPrice":"0.0512",
6
- "price":29.14,
7
- "currency":"USD",
8
- "invoiceTime":1407881291063,
9
- "expirationTime":1407882191063,
10
- "currentTime":1407882058099,
11
- "btcPaid":"0.0512",
12
- "rate":568.69,
13
- "exceptionStatus":false,
14
- "bitpay":
15
- {"id":"123BitPayInvoiceID",
16
- "url":"https://localhost:8088/invoice?id=123BitPayInvoiceID",
17
- "posData":"{\"paymentID\":\"123PAYMENTID\",\"orderID\":\"123ORDERID\"}",
18
- "status":"invalid",
19
- "btcPrice":"0.0512",
20
- "price":29.14,
21
- "currency":"USD",
22
- "invoiceTime":1407881291063,
23
- "expirationTime":1407882191063,
24
- "currentTime":1407882058099,
25
- "btcPaid":"0.0512",
26
- "rate":568.69,
27
- "exceptionStatus":false}}
@@ -1,15 +0,0 @@
1
- {
2
- "id": "123BitPayInvoiceID",
3
- "url": "https://localhost:8088/invoice?id=123BitPayInvoiceID",
4
- "posData": "{\"paymentID\":\"123PAYMENTID\",\"orderID\":\"123ORDERID\"}",
5
- "status": "invalid",
6
- "btcPrice": "0.0720",
7
- "price": 38.58,
8
- "currency": "USD",
9
- "invoiceTime": 1407988706154,
10
- "expirationTime": 1407989606154,
11
- "currentTime": 1407988785613,
12
- "btcPaid": "0.0720",
13
- "rate": 536.19,
14
- "exceptionStatus": false
15
- }
@@ -1,15 +0,0 @@
1
- {
2
- "id": "123BitPayInvoiceID",
3
- "url": "https://localhost:8088/invoice?id=123BitPayInvoiceID",
4
- "posData": "{\"paymentID\":\"123PAYMENTID\",\"orderID\":\"123ORDERID\"}",
5
- "status": "new",
6
- "btcPrice": "0.0720",
7
- "price": 38.58,
8
- "currency": "USD",
9
- "invoiceTime": 1407988706154,
10
- "expirationTime": 1407989606154,
11
- "currentTime": 1407988785613,
12
- "btcPaid": "0.0720",
13
- "rate": 536.19,
14
- "exceptionStatus": false
15
- }