forked from vinsol-spree-contrib/spree_bank_transfer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update for spree 4.1.x, based on pull vinsol-spree-contrib#39 of vins…
…ol-spree-contrib's spree_bank_transfer
- Loading branch information
Showing
21 changed files
with
152 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
source 'https://rubygems.org' | ||
|
||
# Provides basic authentication functionality for testing parts of your engine | ||
version = '3-1-stable' | ||
gem 'spree', github: 'spree/spree', branch: version | ||
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: version | ||
spree_version = 'master' | ||
gem 'spree', github: 'spree/spree', branch: spree_version | ||
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: spree_version | ||
|
||
gem 'coffee-rails', ' ~> 4.0.1' | ||
gem 'sass-rails', '~> 5.0.1' | ||
gem 'coffee-rails', ' ~> 5.0.0' | ||
gem 'sass-rails', '~> 6.0.0' | ||
|
||
group :test do | ||
gem 'minitest' | ||
gem 'rspec-rails', '~> 3.4.0' | ||
gem 'shoulda-matchers', '~> 3.1.1' | ||
gem 'rspec-activemodel-mocks', '~> 1.0.3' | ||
gem 'rspec-rails', '~> 4.0.0' | ||
gem 'shoulda-matchers', '~> 4.3.0' | ||
gem 'rspec-activemodel-mocks', '~> 1.1.0' | ||
gem 'simplecov', require: false | ||
gem 'database_cleaner' | ||
end | ||
gemspec | ||
|
||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/assets/javascripts/spree/frontend/spree_bank_transfer.js.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
Spree::ContentController.class_eval do | ||
def bank_transfer | ||
render layout: false | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,28 @@ | ||
Spree::Payment.class_eval do | ||
attr_accessor :validate_bank_details | ||
validates :bank_name, :account_no, :transaction_reference_no, :deposited_on, presence: true, if: :validate_bank_details | ||
|
||
has_one_attached :receipt | ||
belongs_to :order | ||
validates :bank_name, :deposited_on, :receipt, presence: true, if: :validate_bank_details | ||
|
||
before_save :update_source_type, if: :validate_bank_details | ||
after_save :update_order_state, if: :validate_bank_details | ||
|
||
scope :from_bank_transfer, -> { joins(:payment_method).where(spree_payment_methods: { type: 'Spree::PaymentMethod::BankTransfer' }) } | ||
|
||
self.whitelisted_ransackable_attributes = %w( transaction_reference_no state ) | ||
self.whitelisted_ransackable_attributes = %w( bank_name state ) | ||
|
||
def details_submitted? | ||
transaction_reference_no? | ||
bank_name? | ||
end | ||
|
||
private | ||
|
||
def update_source_type | ||
self.source_type = "Spree::PaymentMethod::BankTransfer" | ||
end | ||
|
||
def update_order_state | ||
order.update(payment_state: :paid) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,40 @@ | ||
<h4>HOW BANK TRANSFER WORKS</h4> | ||
<b>Steps:</b> | ||
<ol> | ||
<li>Deposit order total in one of the below mentioned bank accounts. After this payment a payment reference number will be provided by the bank. | ||
<% if (banks = Spree::Bank.active).any? %> | ||
<div style="padding:20px 0"> | ||
<table border="1" align='center' width="80%"> | ||
<tr> | ||
<th><%= Spree.t(:bank_name) %></th> | ||
<th><%= Spree.t(:account_no) %></th> | ||
<th><%= Spree.t(:additional_details) %></th> | ||
</tr> | ||
<% banks.each do |bank| %> | ||
<tr> | ||
<td><center><%= bank.name %></center></td> | ||
<td><center><%= bank.account_no %></center></td> | ||
<td><center><%= bank.additional_details %></center></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
</div> | ||
<% end %> | ||
</li> | ||
<li>Enter this payment reference number on Order Details page by following steps: | ||
<ol style="padding:10px 0 0 20px" type='a'> | ||
<li>Go to "My Account" page.</li> | ||
<li>Select Order for which you want to provide details.</li> | ||
<li>Click on "Add Details" link visible in "Payment Information" column.</li> | ||
<li>Provide payment details and Submit.</li> | ||
<br><br> | ||
<%= image_tag 'payment_details.png' %> | ||
</ol> | ||
</li> | ||
</ol> | ||
<div class="container mt-4 pb-3"> | ||
<h4>HOW BANK TRANSFER WORKS</h4> | ||
<b>Steps:</b> | ||
<ol> | ||
<li>Deposit order total in one of the below mentioned bank accounts. After this payment a payment reference number will be provided by the bank. | ||
<% if (banks = Spree::Bank.active).any? %> | ||
<div class="w-75"> | ||
<table class="table table-bordered"> | ||
<tr class="table-active"> | ||
<th><%= Spree.t(:bank_name) %></th> | ||
<th><%= Spree.t(:account_no) %></th> | ||
<th><%= Spree.t(:additional_details) %></th> | ||
</tr> | ||
<% banks.each do |bank| %> | ||
<tr> | ||
<td><center><%= bank.name %></center></td> | ||
<td><center><%= bank.account_no %></center></td> | ||
<td><center><%= bank.additional_details %></center></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
</div> | ||
<% end %> | ||
</li> | ||
<li>Enter this payment reference number on Order Details page by following steps: | ||
<ol style="padding:10px 0 0 20px" type='a'> | ||
<li>Go to "My Account" page.</li> | ||
<li>Select Order for which you want to provide details.</li> | ||
<li>Click on "Add Details" link visible in "Payment Information" column.</li> | ||
<li>Provide payment details and Submit.</li> | ||
<br><br> | ||
<%= image_tag 'payment_details.png' %> | ||
</ol> | ||
</li> | ||
</ol> | ||
|
||
<div class="w-100"> | ||
<%= image_tag 'payment_details.png', class: "w-75 img-thumbnail" %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,40 @@ | ||
<% if bank_transfer_payment = @order.payments.from_bank_transfer.first %> | ||
<% bank_transfer_payment = @order.payments.from_bank_transfer.first %> | ||
<% if bank_transfer_payment.present? %> | ||
<% unless bank_transfer_payment.details_submitted? %> | ||
<br> | ||
<%= link_to Spree.t(:add_details), "javascript:void(0);", class: 'button add_bt_details' %> | ||
<% end %> | ||
<%= form_for bank_transfer_payment, html: { class: "bt_payment_form", style: "#{bank_transfer_payment.details_submitted? ? '' : 'display:none;'}" } do |f| %> | ||
<table> | ||
<tr> | ||
<td><%= Spree.t(:deposited_on) %></td><td><%= f.text_field :deposited_on, disabled: bank_transfer_payment.details_submitted?, class: 'required_field', 'field-name' => 'Deposited on' %></td> | ||
</tr> | ||
<tr> | ||
<td><%= Spree.t(:bank_name) %></td><td><%= f.text_field :bank_name, disabled: bank_transfer_payment.details_submitted?, class: 'required_field', 'field-name' => 'Bank name' %></td> | ||
</tr> | ||
<tr> | ||
<td><%= Spree.t(:account_no) %></td><td><%= f.text_field :account_no, disabled: bank_transfer_payment.details_submitted?, class: 'required_field', 'field-name' => 'Account No.' %></td> | ||
</tr> | ||
<tr> | ||
<td><%= Spree.t(:transaction_reference_no) %></td><td><%= f.text_field :transaction_reference_no, disabled: bank_transfer_payment.details_submitted?, class: 'required_field', 'field-name' => 'Transaction Reference No.' %></td> | ||
</tr> | ||
</table> | ||
<br> | ||
<% unless bank_transfer_payment.details_submitted? %> | ||
<%= f.submit "Submit", confirm: Spree.t(:confirm_details_submit) %> | ||
<%= form_for bank_transfer_payment, html: { class: "bt_payment_form", style: "#{bank_transfer_payment.details_submitted? ? '' : 'display:none;'}" } do |f| %> | ||
<div class="row mx-0 my-3"> | ||
<div class="form-group col-12 px-0"> | ||
<%= f.label Spree.t(:deposited_on), class: 'mb-0' %> | ||
<%= f.text_field :deposited_on, disabled: bank_transfer_payment.details_submitted?, class: 'required_field form-control form-control-sm' %> | ||
</div> | ||
<br> | ||
<div class="form-group col-12 px-0"> | ||
<%= f.label Spree.t(:bank_name), class: 'mb-0' %> | ||
<%= f.select :bank_name, options_for_select(Spree::Bank.pluck(:name)), {}, {disabled: bank_transfer_payment.details_submitted?, class: 'required_field form-control form-control-sm'} %> | ||
</div> | ||
<br> | ||
<div class="form-group col-12 px-0"> | ||
<%= f.label Spree.t(:receipt), class: 'mb-0' %> | ||
<%= f.file_field :receipt, disabled: bank_transfer_payment.details_submitted?, class: 'required_field form-control-file' %> | ||
</div> | ||
<br> | ||
<div class="col-12 px-0"> | ||
<% unless bank_transfer_payment.details_submitted? %> | ||
<%= f.submit "Submit", confirm: Spree.t(:confirm_details_submit), class: "btn btn-success btn-block btn-sm" %> | ||
<% end %> | ||
</div> | ||
</div> | ||
<% end %> | ||
<% else %> | ||
<div class="my-3"> | ||
<p class="text-success font-weight-bold mb-0"> | ||
<i class="fas fa-check-circle"></i> <%= Spree.t(:bank_transfer_completed) %> | ||
</p> | ||
<p class="mb-0"><%= Spree.t(:deposited_on) %>: <%= bank_transfer_payment.deposited_on.strftime("%d/%m/%Y") %></p> | ||
<p class="mb-0"><%= Spree.t(:bank_name) %>: <%= bank_transfer_payment.bank_name %></p> | ||
<a href="<%= main_app.url_for(bank_transfer_payment.receipt) %>" target="_blank"><%= Spree.t(:view_receipt) %></a> | ||
</div> | ||
<% end %> | ||
<% end %> | ||
<% if I18n.locale != :en %> | ||
<%= javascript_include_tag "jquery-ui/datepicker-#{I18n.locale}" %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...140519125402_add_bank_name_account_number_and_transaction_reference_number_to_payments.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
db/migrate/20140530055151_add_column_deposited_on_to_spree_payments.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
db/migrate/20140612131656_add_col_additional_details_to_banks.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
require 'spree_core' | ||
require 'rails/generators' | ||
require 'spree_bank_transfer/engine' | ||
require 'spree_bank_transfer/version' | ||
require 'spree_extension' | ||
require 'deface' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.