spree_komoju 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +16 -1
  3. data/app/assets/javascripts/spree/backend/spree_komoju.js +0 -2
  4. data/app/assets/javascripts/spree/frontend/spree_komoju.js +0 -2
  5. data/app/assets/stylesheets/spree/frontend/spree_komoju.css +23 -0
  6. data/app/controllers/spree/admin/payments_controller_decorator.rb +3 -0
  7. data/app/controllers/spree/checkout_controller_decorator.rb +1 -16
  8. data/app/controllers/spree/komoju_controller.rb +34 -0
  9. data/app/models/spree/bank_transfer.rb +1 -10
  10. data/app/models/spree/gateway/komoju_bank_transfer.rb +4 -0
  11. data/app/models/spree/gateway/komoju_konbini.rb +4 -0
  12. data/app/models/spree/gateway/komoju_pay_easy.rb +28 -0
  13. data/app/models/spree/gateway/komoju_web_money.rb +57 -0
  14. data/app/models/spree/konbini.rb +1 -10
  15. data/app/models/spree/pay_easy.rb +18 -0
  16. data/app/models/spree/web_money.rb +21 -0
  17. data/app/models/spree/web_money_decorator.rb +15 -0
  18. data/app/views/spree/admin/payments/source_forms/_komoju_bank_transfer.html.erb +1 -0
  19. data/app/views/spree/admin/payments/source_forms/_komoju_credit_card.html.erb +1 -0
  20. data/app/views/spree/admin/payments/source_forms/_komoju_konbini.html.erb +1 -0
  21. data/app/views/spree/admin/payments/source_forms/_komoju_pay_easy.html.erb +1 -0
  22. data/app/views/spree/admin/payments/source_forms/_komoju_web_money.html.erb +1 -0
  23. data/app/views/spree/admin/payments/source_views/_komoju_bank_transfer.html.erb +13 -0
  24. data/app/views/spree/admin/payments/source_views/_komoju_pay_easy.html.erb +21 -0
  25. data/app/views/spree/admin/payments/source_views/_komoju_web_money.html.erb +13 -0
  26. data/app/views/spree/checkout/payment/_komoju_pay_easy.html.erb +36 -0
  27. data/app/views/spree/checkout/payment/_komoju_web_money.html.erb +74 -0
  28. data/app/views/spree/orders/_pay_easy.html.erb +24 -0
  29. data/bin/rails +6 -1
  30. data/config/locales/en.yml +32 -4
  31. data/config/locales/ja.yml +24 -0
  32. data/config/routes.rb +1 -0
  33. data/db/migrate/20150402013829_create_spree_pay_easies.rb +24 -0
  34. data/db/migrate/20151209053401_create_spree_web_moneys.rb +17 -0
  35. data/lib/active_merchant/billing/gateways/komoju.rb +9 -4
  36. data/lib/ext/activemerchant/connection.rb +47 -0
  37. data/lib/generators/spree_komoju/install/images/pay-easy.png +0 -0
  38. data/lib/generators/spree_komoju/install/images/webmoney.png +0 -0
  39. data/lib/spree_komoju/controller_helpers.rb +29 -0
  40. data/lib/spree_komoju/engine.rb +3 -0
  41. data/lib/spree_komoju/errors.rb +5 -0
  42. data/lib/spree_komoju.rb +8 -0
  43. data/spec/controllers/spree/checkout_controller_spec.rb +1 -1
  44. data/spec/controllers/spree/komoju_controller_spec.rb +82 -0
  45. data/spec/models/spree/bank_transfer_spec.rb +1 -57
  46. data/spec/models/spree/gateway/komoju_pay_easy_spec.rb +92 -0
  47. data/spec/models/spree/gateway/komoju_web_money_spec.rb +108 -0
  48. data/spec/models/spree/konbini_spec.rb +1 -57
  49. data/spec/models/spree/pay_easy_spec.rb +13 -0
  50. data/spec/models/spree/web_money_decorator_spec.rb +24 -0
  51. data/spec/models/spree/web_money_spec.rb +13 -0
  52. data/spree_komoju.gemspec +1 -1
  53. metadata +40 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fab6019e2802d287ff898d2d70594e9f46a6fac3
4
- data.tar.gz: 1ed0ae676b5a76cc97f46ae004f0ffaa56ea7789
3
+ metadata.gz: fb49e7926e73b422ef5265abb5fff354a2a9c4aa
4
+ data.tar.gz: cc33f0b3f7852687708ada96fb1d7c42fd8363f9
5
5
  SHA512:
6
- metadata.gz: d7a6d1fc42a4bbd4aaee6824aa6fc2ba2a4e8ccc9f1331cdc4f420886ab4034e4c8c9f3570cb9b112fcd3804e983a97e8a44c3b7eb6a2c911ea5e5a01be8613d
7
- data.tar.gz: 61c9167f7503d82ebad69619ad138af3a90728320e07628d82ca5ac3dcad350e1a4d17f2c32c375ba8229a244243840f7ced248e22418b33db6b85004fa68c58
6
+ metadata.gz: c9a991202fbd2c1c0ab2de087d2f9bb64d1fcf4acafd02850e552d0247328d9cc4f8b310f1dce7ea09a1213bd07b57c706510ac6756d5b2e919c49af53a3e090
7
+ data.tar.gz: b170a98fe37a3dad419ab1c058b13fc1ccc5e045e585a53cca48f0497bb33c496227dc8217ecbf9e4d3d6995c7bc70654f68106ac1f6b326560b441e0df93f0d
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  SpreeKomoju
2
2
  ===========
3
3
 
4
- SpreeKomoju provides a comprehensive integration for all [Komoju](https://docs.komoju.com) payment methods with a single gem, including Credit Card, Konbini and Bank Transfer.
4
+ SpreeKomoju provides a comprehensive integration for all [Komoju](https://docs.komoju.com) payment methods with a single gem, including Credit Card, Konbini, PayEasy, and Bank Transfer.
5
5
 
6
6
  Installation
7
7
  ------------
@@ -19,6 +19,21 @@ bundle
19
19
  bundle exec rails g spree_komoju:install
20
20
  ```
21
21
 
22
+ Webhooks
23
+ --------
24
+
25
+ You will need to [setup a webhook](https://docs.komoju.com/api/webhooks) to complete non credit card
26
+ payments options. This is because payment options like Konbini, Bank Transfer, etc. are completed offline.
27
+
28
+ Adding spree_komoju will expose a new route `http://localhost:3000/komoju/callback` which expects
29
+ a `payment.captured` webhook. You can configure a [secret token](https://docs.komoju.com/api/webhooks#secret_token)
30
+ for your callback endpoint using the following configuration code:
31
+
32
+ ```ruby
33
+ # config/initializers/spree_komoju.rb
34
+ SpreeKomoju.komoju_webhook_secret_token = 'MY WEBHOOK SECRET'
35
+ ```
36
+
22
37
  Testing
23
38
  -------
24
39
 
@@ -1,2 +0,0 @@
1
- // Placeholder manifest file.
2
- // the installer will append this file to the app vendored assets here: vendor/assets/javascripts/spree/backend/all.js'
@@ -1,2 +0,0 @@
1
- // Placeholder manifest file.
2
- // the installer will append this file to the app vendored assets here: vendor/assets/javascripts/spree/frontend/all.js'
@@ -2,3 +2,26 @@
2
2
  Placeholder manifest file.
3
3
  the installer will append this file to the app vendored assets here: 'vendor/assets/stylesheets/spree/frontend/all.css'
4
4
  */
5
+
6
+ .webmoney .multicard {
7
+ margin-top: 20px;
8
+ font-family: monospace;
9
+ font-size: 14px;
10
+ }
11
+
12
+ .webmoney .multicard th {
13
+ width: 200px;
14
+ font-weight: normal;
15
+ }
16
+
17
+ .webmoney .form-inline .form-control,
18
+ .webmoney .form-inline .form-group {
19
+ display: inline;
20
+ width: auto;
21
+ }
22
+
23
+ @media screen and (max-width: 460px){
24
+ .webmoney .multicard span.points {
25
+ display: none;
26
+ }
27
+ }
@@ -0,0 +1,3 @@
1
+ Spree::Admin::PaymentsController.class_eval do
2
+ include SpreeKomoju::ControllerHelpers
3
+ end
@@ -1,18 +1,3 @@
1
1
  Spree::CheckoutController.class_eval do
2
- def permitted_source_attributes
3
- super.push(permitted_komoju_konbini_attributes)
4
- super.push(permitted_komoju_banktransfer_attributes)
5
- super.flatten
6
- end
7
-
8
- private
9
-
10
- def permitted_komoju_konbini_attributes
11
- :convenience
12
- end
13
-
14
- def permitted_komoju_banktransfer_attributes
15
- [:email, :phone, :family_name, :given_name, :family_name_kana, :given_name_kana]
16
- end
2
+ include SpreeKomoju::ControllerHelpers
17
3
  end
18
-
@@ -0,0 +1,34 @@
1
+ module Spree
2
+ class KomojuController < ApplicationController
3
+ protect_from_forgery except: :callback
4
+
5
+ def callback
6
+ return head :unauthorized unless callback_verified?
7
+
8
+ case params[:type]
9
+ when "ping"
10
+ # do nothing
11
+ when "payment.captured"
12
+ order_number = extract_payment_number(params[:data][:external_order_num])
13
+ payment = Spree::Payment.find_by_number!(order_number)
14
+ payment.complete! unless payment.completed?
15
+ else
16
+ return head :unauthorized
17
+ end
18
+
19
+ head 200
20
+ end
21
+
22
+ private
23
+
24
+ def extract_payment_number(external_order_num)
25
+ external_order_num.split('-').try(:last)
26
+ end
27
+
28
+ def callback_verified?
29
+ request_body = request.body.read
30
+ signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), SpreeKomoju.komoju_webhook_secret_token.to_s, request_body)
31
+ Rack::Utils.secure_compare(signature, request.env["HTTP_X_KOMOJU_SIGNATURE"].to_s)
32
+ end
33
+ end
34
+ end
@@ -7,16 +7,7 @@ module Spree
7
7
  validates :email, :given_name, :family_name, :given_name_kana, :family_name_kana, presence: true
8
8
 
9
9
  def actions
10
- %w{capture void}
11
- end
12
-
13
- def can_capture?(payment)
14
- return false unless ['checkout', 'pending'].include?(payment.state)
15
- payment.source.expires_at && (payment.source.expires_at > DateTime.current)
16
- end
17
-
18
- def can_void?(payment)
19
- payment.state != 'void'
10
+ %w{}
20
11
  end
21
12
 
22
13
  def instructions_partial_path
@@ -22,5 +22,9 @@ module Spree
22
22
  ) if response.success?
23
23
  response
24
24
  end
25
+
26
+ def reusable_sources(*args)
27
+ []
28
+ end
25
29
  end
26
30
  end
@@ -19,5 +19,9 @@ module Spree
19
19
  ) if response.success?
20
20
  response
21
21
  end
22
+
23
+ def reusable_sources(*args)
24
+ []
25
+ end
22
26
  end
23
27
  end
@@ -0,0 +1,28 @@
1
+ module Spree
2
+ class Gateway::KomojuPayEasy < KomojuGateway
3
+ def authorize(money, source, options)
4
+ details = {
5
+ type: "pay_easy",
6
+ email: source.email,
7
+ phone: source.phone,
8
+ given_name: source.given_name,
9
+ family_name: source.family_name,
10
+ given_name_kana: source.given_name_kana,
11
+ family_name_kana: source.family_name_kana
12
+ }
13
+ options = change_options_to_dollar(options) if options[:currency] == "JPY"
14
+
15
+ response = provider.purchase(money - options[:tax], details, options)
16
+
17
+ source.update!(
18
+ expires_at: response.params["payment_deadline"].to_time,
19
+ bank_id: response.params["payment_details"]["bank_id"],
20
+ customer_id: response.params["payment_details"]["customer_id"],
21
+ confirmation_id: response.params["payment_details"]["confirmation_id"],
22
+ instructions_url: response.params["payment_details"]["instructions_url"]
23
+ ) if response.success?
24
+
25
+ response
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,57 @@
1
+ module Spree
2
+ class Gateway::KomojuWebMoney < KomojuGateway
3
+ def auto_capture?
4
+ true
5
+ end
6
+
7
+ def purchase(money, source, options)
8
+ raise SpreeKomoju::Errors::UnsupportedCurrency if options[:currency] != "JPY"
9
+
10
+ details = {
11
+ type: "web_money",
12
+ email: source.email,
13
+ prepaid_number: source.prepaid_number
14
+ }
15
+ options = change_options_to_dollar(options)
16
+
17
+ if uuid = continue_uuid(options[:order_id])
18
+ response = provider.continue(uuid, details)
19
+ else
20
+ response = provider.purchase(money - options[:tax], details, options)
21
+ end
22
+
23
+ source.update!(
24
+ prepaid_cards: response.params["payment_details"]["prepaid_cards"],
25
+ short_amount: response.params["payment_details"]["short_amount"]
26
+ ) if response.success?
27
+
28
+ if response.params["status"] == "pending"
29
+ source.update!(payment_uuid: response.params["id"])
30
+ response = multi_card_response(response)
31
+ end
32
+
33
+ response
34
+ end
35
+
36
+ def reusable_sources(*args)
37
+ []
38
+ end
39
+
40
+ private
41
+
42
+ def multi_card_response(response)
43
+ response.instance_variable_set(:@success, false)
44
+ response.instance_variable_set(:@message, I18n.t('spree.komoju.web_money.insufficient_funds'))
45
+ response
46
+ end
47
+
48
+ def continue_uuid(current_order_id)
49
+ order = Spree::Order.find_by_number(current_order_id.split('-').first)
50
+
51
+ # NOTE: Since the current payment is this payment, find the payment before
52
+ # and see if it was for a webmoney transaction. If it was check if it has a payment UUID
53
+ # to continue the transaction.
54
+ order.payments.last(2).first.try(:source).try(:payment_uuid)
55
+ end
56
+ end
57
+ end
@@ -9,16 +9,7 @@ module Spree
9
9
  validates :convenience, presence: true
10
10
 
11
11
  def actions
12
- %w{capture void}
13
- end
14
-
15
- def can_capture?(payment)
16
- return false unless ['checkout', 'pending'].include?(payment.state)
17
- payment.source.expires_at && (payment.source.expires_at > DateTime.current)
18
- end
19
-
20
- def can_void?(payment)
21
- payment.state != 'void'
12
+ %w{}
22
13
  end
23
14
 
24
15
  def instructions_partial_path
@@ -0,0 +1,18 @@
1
+ module Spree
2
+ class PayEasy < Spree::Base
3
+ belongs_to :payment_method
4
+ belongs_to :user, class_name: Spree.user_class, foreign_key: 'user_id'
5
+ has_many :payments, as: :source
6
+
7
+ validates :email, :given_name, :family_name, :given_name_kana, :family_name_kana, presence: true
8
+ validates :phone, numericality: true, allow_nil: true
9
+
10
+ def actions
11
+ %w{}
12
+ end
13
+
14
+ def instructions_partial_path
15
+ "spree/orders/pay_easy"
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,21 @@
1
+ module Spree
2
+ class WebMoney < Spree::Base
3
+ belongs_to :payment_method
4
+ belongs_to :user, class_name: Spree.user_class, foreign_key: 'user_id'
5
+ has_many :payments, as: :source
6
+
7
+ serialize :prepaid_cards, Array
8
+
9
+ attr_accessor :prepaid_number
10
+ validates :email, presence: true
11
+ validates :prepaid_number, presence: true, on: :create
12
+
13
+ def actions
14
+ %w{}
15
+ end
16
+
17
+ def instructions_partial_path
18
+ "spree/orders/web_money"
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,15 @@
1
+ module Spree
2
+ class WebMoneyDecorator
3
+ attr_reader :source
4
+ delegate :short_amount, :prepaid_cards, :payment_uuid, to: :source,
5
+ allow_nil: true
6
+
7
+ def initialize(source)
8
+ @source = if source.present? && source.brand == "web_moneys"
9
+ source
10
+ else
11
+ nil
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1 @@
1
+ <%= render partial: "spree/checkout/payment/komoju_bank_transfer", locals: { payment_method: payment_method } %>
@@ -0,0 +1 @@
1
+ <%= render :partial => "spree/admin/payments/source_forms/gateway", locals: { payment_method: payment_method, previous_cards: previous_cards } %>
@@ -0,0 +1 @@
1
+ <%= render partial: "spree/checkout/payment/komoju_konbini", locals: { payment_method: payment_method } %>
@@ -0,0 +1 @@
1
+ <%= render partial: "spree/checkout/payment/komoju_pay_easy", locals: { payment_method: payment_method } %>
@@ -0,0 +1 @@
1
+ <%= render partial: "spree/checkout/payment/komoju_web_money", locals: { payment_method: payment_method } %>
@@ -0,0 +1,13 @@
1
+ <fieldset data-hook="bank-transfer">
2
+ <legend><%= Spree.t(:bank_tansfer) %></legend>
3
+ <table class="table table-condensed table-bordered">
4
+ <tr>
5
+ <th width="20%"><%= Spree::BankTransfer.human_attribute_name(:order_id) %>:</th>
6
+ <td><%= payment.source.order_id %></td>
7
+ </tr>
8
+ <tr>
9
+ <th><%= Spree::BankTransfer.human_attribute_name(:expires_at) %>:</th>
10
+ <td><%= payment.source.expires_at %></td>
11
+ </tr>
12
+ </table>
13
+ </fieldset>
@@ -0,0 +1,21 @@
1
+ <fieldset data-hook="pay-easy">
2
+ <legend><%= Spree.t(:pay_easy) %></legend>
3
+ <table class="table table-condensed table-bordered">
4
+ <tr>
5
+ <th width="20%"><%= Spree::PayEasy.human_attribute_name(:bank_id) %>:</th>
6
+ <td><%= payment.source.bank_id %></td>
7
+ </tr>
8
+ <tr>
9
+ <th width="20%"><%= Spree::PayEasy.human_attribute_name(:customer_id) %>:</th>
10
+ <td><%= payment.source.customer_id %></td>
11
+ </tr>
12
+ <tr>
13
+ <th width="20%"><%= Spree::PayEasy.human_attribute_name(:confirmation_id) %>:</th>
14
+ <td><%= payment.source.confirmation_id %></td>
15
+ </tr>
16
+ <tr>
17
+ <th><%= Spree.t(:expires_at) %>:</th>
18
+ <td><%= payment.source.expires_at %></td>
19
+ </tr>
20
+ </table>
21
+ </fieldset>
@@ -0,0 +1,13 @@
1
+ <fieldset data-hook="web-money">
2
+ <legend><%= Spree.t(:web_money) %></legend>
3
+ <table class="table table-condensed table-bordered">
4
+ <tr>
5
+ <th width="20%"><%= Spree::WebMoney.human_attribute_name(:prepaid_number) %>:</th>
6
+ <td>
7
+ <% payment.source.prepaid_cards.each do |card| %>
8
+ **** **** **** <%= card["last_four_digits"] %> / <%= card["points"] %> points<br/>
9
+ <% end %>
10
+ </td>
11
+ </tr>
12
+ </table>
13
+ </fieldset>
@@ -0,0 +1,36 @@
1
+ <div class="well clearfix">
2
+ <p><%= image_tag 'pay-easy.png' %></p>
3
+ <% param_prefix = "payment_source[#{payment_method.id}]" %>
4
+
5
+ <p class="field">
6
+ <%= label_tag "email", Spree.t(:email) %><span class="required">*</span><br />
7
+ <%= text_field_tag "#{param_prefix}[email]", @order.email, { id: "email", class: 'form-control required'} %>
8
+ </p>
9
+
10
+ <p class="field">
11
+ <%= label_tag "phone", Spree.t(:phone) %><span class="required">*</span><br />
12
+ <%= text_field_tag "#{param_prefix}[phone]", @order.billing_address.phone, { id: "phone", class: 'form-control required'} %>
13
+ </p>
14
+
15
+ <div class="row">
16
+ <div class="col-md-6 field">
17
+ <%= label_tag "family_name", Spree.t(:family_name) %><span class="required">*</span><br />
18
+ <%= text_field_tag "#{param_prefix}[family_name]", @order.billing_lastname, { id: "family_name", class: 'form-control required'} %>
19
+ </div>
20
+ <div class="col-md-6 field">
21
+ <%= label_tag "given_name", Spree.t(:given_name) %><span class="required">*</span><br />
22
+ <%= text_field_tag "#{param_prefix}[given_name]", @order.billing_firstname, { id: "given_name", class: 'form-control required'} %>
23
+ </div>
24
+ </div>
25
+
26
+ <div class="row">
27
+ <div class="col-md-6 field">
28
+ <%= label_tag "family_name_kana", Spree.t(:family_name_kana) %><span class="required">*</span><br />
29
+ <%= text_field_tag "#{param_prefix}[family_name_kana]", "", { id: "family_name_kana", class: 'form-control required'} %>
30
+ </div>
31
+ <div class="col-md-6 field">
32
+ <%= label_tag "given_name_kana", Spree.t(:given_name_kana) %><span class="required">*</span><br />
33
+ <%= text_field_tag "#{param_prefix}[given_name_kana]", "", { id: "given_name_kana", class: 'form-control required'} %>
34
+ </div>
35
+ </div>
36
+ </div>
@@ -0,0 +1,74 @@
1
+ <% @webmoney = Spree::WebMoneyDecorator.new(@order.payments.last.try(:source)) %>
2
+
3
+ <div class="well webmoney clearfix">
4
+ <p><%= image_tag 'webmoney.png' %></p>
5
+ <% param_prefix = "payment_source[#{payment_method.id}]" %>
6
+
7
+ <p class="field">
8
+ <%= label_tag "email", Spree.t(:email) %><span class="required">*</span><br />
9
+ <%= text_field_tag "#{param_prefix}[email]", @order.email, { id: "email", class: 'form-control required'} %>
10
+ </p>
11
+
12
+ <%= hidden_field_tag "#{param_prefix}[prepaid_number]", "" %>
13
+
14
+ <div class="form-inline">
15
+ <%= label_tag "prepaid_number", Spree.t(:prepaid_number) %><span class="required">*</span><br />
16
+ <div class="form-group">
17
+ <%= text_field_tag nil, "", { id: "ppn1", class: 'form-control required webmoney_pin', size: 4, maxlength: 4 } %>
18
+ </div>
19
+ <div class="form-group">
20
+ <%= text_field_tag nil, "", { id: "ppn2", class: 'form-control required webmoney_pin', size: 4, maxlength: 4 } %>
21
+ </div>
22
+ <div class="form-group">
23
+ <%= text_field_tag nil, "", { id: "ppn3", class: 'form-control required webmoney_pin', size: 4, maxlength: 4 } %>
24
+ </div>
25
+ <div class="form-group">
26
+ <%= text_field_tag nil, "", { id: "ppn4", class: 'form-control required webmoney_pin', size: 4, maxlength: 4 } %>
27
+ </div>
28
+ </div>
29
+
30
+ <% if @webmoney.prepaid_cards.present? %>
31
+ <%= hidden_field_tag "#{param_prefix}[payment_uuid]", @webmoney.payment_uuid %>
32
+
33
+ <div class="well multicard">
34
+ <table>
35
+ <% @webmoney.prepaid_cards.each do |card| %>
36
+ <tr>
37
+ <th>**** **** **** <%= card["last_four_digits"] %></th>
38
+ <td><%= card["points"] %></td>
39
+ </tr>
40
+ <% end %>
41
+ <tr>
42
+ <th><%= t('spree.komoju.web_money.balance_remaining') %></th>
43
+ <td><%= @webmoney.short_amount %> <span class="points"><%= t('spree.komoju.web_money.points') %></td>
44
+ </tr>
45
+ </table>
46
+ </div>
47
+ <% end %>
48
+ </div>
49
+
50
+ <%=
51
+ javascript_tag <<-JS
52
+ SpreeKomoju = {
53
+ addWebMoneyListener: function() {
54
+ $(".webmoney input.webmoney_pin").keyup(function() {
55
+ var length = $(this).val().length;
56
+ if (length == 4) {
57
+ $nextInput = $('input.webmoney_pin:eq(' + ($('input.webmoney_pin').index(this) + 1) + ')');
58
+ $nextInput.focus();
59
+ }
60
+ });
61
+
62
+ $(".webmoney").parents('form').has("input.webmoney_pin").submit(function() {
63
+ var prepaid_number = $("#ppn1").val() + $("#ppn2").val() + $("#ppn3").val() + $("#ppn4").val();
64
+ $(this).find("input[name*=prepaid_number]").val(prepaid_number)
65
+ $(this).find("input.webmoney_pin").prop('disabled', true)
66
+ })
67
+ }
68
+ }
69
+
70
+ $(document).ready(function() {
71
+ SpreeKomoju.addWebMoneyListener();
72
+ })
73
+ JS
74
+ %>
@@ -0,0 +1,24 @@
1
+ <div>
2
+ <p>
3
+ Thank you for your order. Instructions have been sent to your e-mail address.<br/>
4
+ Please follow the link below to complete your purchase:
5
+ </p>
6
+
7
+ <%= link_to source.instructions_url do %>
8
+ How to pay with PayEasy
9
+ <% end %>
10
+ </div>
11
+ <br>
12
+
13
+ <div class='alert alert-info' role='alert'>
14
+ <dl>
15
+ <dt>Bank Number</dt>
16
+ <dd><%= source.bank_id %></dd>
17
+ <dt>Customer Number</dt>
18
+ <dd><%= source.customer_id %></dd>
19
+ <dt>Confirmation Number</dt>
20
+ <dd><%= source.confirmation_id %></dd>
21
+ <dt>Expiry Date</dt>
22
+ <dd><%= l source.expires_at.in_time_zone("Tokyo"), format: :short %></dd>
23
+ </dl>
24
+ </div>
data/bin/rails CHANGED
@@ -1,7 +1,12 @@
1
- # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
2
3
 
3
4
  ENGINE_ROOT = File.expand_path('../..', __FILE__)
4
5
  ENGINE_PATH = File.expand_path('../../lib/spree_komoju/engine', __FILE__)
5
6
 
7
+ # Set up gems listed in the Gemfile.
8
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
9
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
10
+
6
11
  require 'rails/all'
7
12
  require 'rails/engine/commands'
@@ -1,5 +1,8 @@
1
1
  en:
2
2
  spree:
3
+ pay_easy: Pay Easy
4
+ bank_transfer: Bank Transfer
5
+ web_money: WebMoney
3
6
  conveniences:
4
7
  lawson: Lawson
5
8
  family-mart: Family Mart
@@ -10,7 +13,32 @@ en:
10
13
  seven-eleven: Seven Eleven
11
14
  email: Email
12
15
  phone: Phone
13
- given_name: Given Name
14
- family_name: Family Name
15
- given_name_kana: Given Name Kana
16
- family_name_kana: Family Name Kana
16
+ given_name: First Name
17
+ family_name: Last Name
18
+ given_name_kana: First Name (Katakana)
19
+ family_name_kana: Last Name (Katakana)
20
+ prepaid_number: Prepaid Number
21
+ komoju:
22
+ attributes: &komoju-payment-details
23
+ email: Email
24
+ phone: Phone Number
25
+ given_name_kana: First Name (Katakana)
26
+ family_name_kana: Last Name (Katakana)
27
+ given_name: First Name
28
+ family_name: Last Name
29
+ instructions_url: Instructions URL
30
+ prepaid_number: Prepaid Number
31
+ order_id: Order ID
32
+ expires_at: Expiry Date
33
+ bank_id: Bank ID
34
+ customer_id: Customer ID
35
+ confirmation_id: Confirmation ID
36
+ web_money:
37
+ balance_remaining: "Balance Remaining"
38
+ points: "points"
39
+ insufficient_funds: Insufficient funds, please enter another card
40
+ activerecord:
41
+ attributes:
42
+ spree/pay_easy: *komoju-payment-details
43
+ spree/web_money: *komoju-payment-details
44
+ spree/bank_transfer: *komoju-payment-details
@@ -0,0 +1,24 @@
1
+ ja:
2
+ spree:
3
+ pay_easy: Pay Easy
4
+ conveniences:
5
+ lawson: ローソン
6
+ family-mart: ファミリーマート
7
+ sunkus: サンクス
8
+ circle-k: サークルK
9
+ ministop: ミニストップ
10
+ daily-yamazaki: デイリーヤマザキ
11
+ seven-eleven: セブンイレブン
12
+ email: メール
13
+ phone: 電話番号
14
+ given_name: 名
15
+ family_name: 姓
16
+ given_name_kana: 名 (カタカナ)
17
+ family_name_kana: 姓 (カタカナ)
18
+ activerecord:
19
+ attributes:
20
+ spree/pay_easy:
21
+ given_name_kana: 名 (カタカナ)
22
+ family_name_kana: 姓 (カタカナ)
23
+ given_name: 名
24
+ family_name: 姓
data/config/routes.rb CHANGED
@@ -1,2 +1,3 @@
1
1
  Spree::Core::Engine.routes.draw do
2
+ post "komoju/callback" => "komoju#callback"
2
3
  end