Skip to content
This repository was archived by the owner on Apr 11, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ gem 'solidus_gateway'
gem 'solidus_auth_devise'

group :test do
gem 'test-unit'
gem 'coffee-rails'
gem 'sass-rails', '~> 4.0.3'
gem 'money', '6.5.1'
gem 'rspec-rails', '~> 2.10'
gem 'rspec-rails', '~> 3.0'
gem 'shoulda-matchers', '2.2.0'
gem 'simplecov', :require => false
gem 'simplecov-rcov'
Expand Down
5 changes: 0 additions & 5 deletions Versionfile

This file was deleted.

4 changes: 4 additions & 0 deletions app/models/spree/affirm_checkout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ def name
"Affirm Checkout"
end

def reusable?
false
end

def details
@details ||= payment_method.provider.get_checkout token
end
Expand Down
34 changes: 20 additions & 14 deletions app/views/spree/checkout/payment/_affirm.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@
tax_amount: <%= (@order.additional_tax_total * 100).to_i %>,
checkout_id: "<%= @order.number %>",
discount_code: "<%= @order.coupon_code %>",
shipping_type: "<%= @order.shipments.first.shipping_method.name if @order.shipments %>",
shipping_type: "<%= j @order.shipments.first.shipping_method.name if @order.shipments %>",
shipping_amount: <%= (@order.shipment_total * 100).to_i %>,

shipping: {
name: {
full: "<%= @order.ship_address.full_name %>",
full: "<%= j @order.ship_address.full_name %>",
},
address: {
line1: "<%= @order.ship_address.address1 %>",
line2: "<%= @order.ship_address.address2 %>",
line1: "<%= j @order.ship_address.address1 %>",
line2: "<%= j @order.ship_address.address2 %>",
city: "<%= @order.ship_address.city %>",
state: "<%= @order.ship_address.state_text %>",
country: "<%= @order.ship_address.country.iso %>",
Expand All @@ -45,11 +45,11 @@
billing: {
email: "<%= @order.email %>",
name: {
full: "<%= @order.bill_address.full_name %>"
full: "<%= j @order.bill_address.full_name %>"
},
address: {
line1: "<%= @order.bill_address.address1 %>",
line2: "<%= @order.bill_address.address2 %>",
line1: "<%= j @order.bill_address.address1 %>",
line2: "<%= j @order.bill_address.address2 %>",
city: "<%= @order.bill_address.city %>",
state: "<%= @order.bill_address.state_text %>",
country: "<%= @order.bill_address.country.iso %>",
Expand All @@ -73,7 +73,7 @@

<% end %>
is_logged_in: <%= !!spree_current_user %>,
spree_version: "<%= Spree.version %>"
spree_version: "<%= Spree.solidus_version %>"
}
}
},
Expand All @@ -91,9 +91,9 @@
<% if @order.promotions.any? %>
discounts: {
<% @order.adjustments.promotion.each do |adjustment| %>
"<%= adjustment.label %>": {
"<%= j adjustment.label %>": {
discount_amount: <%= (0-adjustment.amount*100).to_i %>,
discount_display_name: "<%= adjustment.label %>"
discount_display_name: "<%= j adjustment.label %>"
},
<% end %>
},
Expand All @@ -112,7 +112,7 @@
sku: "<%= item.variant.sku %>",
item_url: "<%= product_url(item.product) %>",
unit_price: <%= item.price * 100 %>,
display_name: "<%= raw(item.variant.product.name) %>"
display_name: "<%= j raw(item.variant.product.name) %>"
},
<% end %>
]
Expand Down Expand Up @@ -149,13 +149,19 @@
handle continue button clicks with .open()
\*****************************************************/
$('#checkout_form_payment').submit(function(e){
var checkedPaymentMethod = $('div[data-hook="checkout_payment_step"] input[type="radio"]:checked').val();
var selectedPaymentMethod = $('input[name="order[payments_attributes][][payment_method_id]"]');
var type = selectedPaymentMethod.attr("type");
if (type && type.toLowerCase() == 'radio') {
selectedPaymentMethod = selectedPaymentMethod.filter(":checked").val();
} else {
selectedPaymentMethod = selectedPaymentMethod.val();
}

if (window.AffirmPaymentMethods[checkedPaymentMethod]) {
if (window.AffirmPaymentMethods[selectedPaymentMethod]) {
var $submit_button = $(this).find("input[type='submit']");

// update with checkout method details
affirm.checkout(window.AffirmPaymentMethods[checkedPaymentMethod]);
affirm.checkout(window.AffirmPaymentMethods[selectedPaymentMethod]);

// show the loading message
$submit_button.trigger("loading");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
factory :affirm_payment_method, class: Spree::Gateway::Affirm do
name "Staging Affirm Split Pay"
active true
environment "test"
auto_capture false
end
end
4 changes: 2 additions & 2 deletions spec/controllers/affirm_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

describe Spree::AffirmController do
describe Spree::AffirmController, type: :controller do
let(:user) { FactoryGirl.create(:user) }
let(:checkout) { FactoryGirl.build(:affirm_checkout) }
let(:bad_billing_checkout) { FactoryGirl.build(:affirm_checkout, billing_address_mismatch: true) }
Expand Down Expand Up @@ -135,4 +135,4 @@ def post_request(token, payment_id)
end
end
end
end
end
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# current_path.should eql(spree.products_path)
config.include Spree::TestingSupport::UrlHelpers
config.include Spree::TestingSupport::Preferences
config.include Spree::TestingSupport::ControllerRequests
config.include Spree::TestingSupport::ControllerRequests, type: :controller
config.include Spree::TestingSupport::Flash


Expand Down Expand Up @@ -84,7 +84,7 @@
end

# Before each spec check if it is a Javascript test and switch between using database transactions or not where necessary.
config.before :each do
config.before :each do |example|
DatabaseCleaner.strategy = example.metadata[:js] ? :truncation : :transaction
DatabaseCleaner.start
end
Expand Down
6 changes: 3 additions & 3 deletions spree_affirm.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ Gem::Specification.new do |s|

s.add_dependency 'solidus'

s.add_development_dependency 'factory_girl', '~> 4.2'
s.add_development_dependency 'ffaker', '~> 1.16'
s.add_development_dependency 'rspec-rails', '~> 2.13'
s.add_development_dependency 'factory_girl'
s.add_development_dependency 'ffaker'
s.add_development_dependency 'rspec-rails'
s.add_development_dependency 'simplecov', '~> 0.9'
s.add_development_dependency 'simplecov-rcov', '~> 0.2'
s.add_development_dependency 'sqlite3', '~> 1.3'
Expand Down