Skip to content

Commit

Permalink
Merge pull request #8 from Affirm/0-2-4-stable
Browse files Browse the repository at this point in the history
0.2.4 stable
  • Loading branch information
Dipti Bele authored Mar 13, 2018
2 parents 6144102 + 48ecbdf commit 69d80f1
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 78 deletions.
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
source 'https://rubygems.org'

gem 'spree', github: 'spree/spree', branch: '2-4-stable'
gem 'spree_gateway', github: 'spree/spree_gateway', branch: '2-4-stable'
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '2-4-stable'
gem 'spree', github: 'spree/spree', tag: 'v0.2.24'
gem 'spree_gateway', github: 'spree/spree_gateway', tag: 'v0.2.24'
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', tag: 'v0.2.24'

group :test do
gem 'coffee-rails'
Expand Down
47 changes: 25 additions & 22 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
Copyright (c) 2014 [name of plugin creator]
BSD 3-Clause License

Copyright (c) 2018, Affirm
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name Spree nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ Installation

4. Restart your server

Documentation
------------------
https://docs.affirm.com/Spree

## Contributing

1. Fork it
Expand All @@ -44,4 +48,4 @@ Simply add this require statement to your spec_helper:
require 'spree_affirm/factories'
```

Copyright (c) 2015 Affirm, released under the New BSD License
Copyright (c) 2018 Affirm, released under the New BSD License
7 changes: 0 additions & 7 deletions app/models/spree/affirm_checkout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def validate_checkout_matches_order
check_matching_shipping_address
check_matching_billing_address
check_matching_billing_email
check_matching_product_key
end

def check_valid_products
Expand Down Expand Up @@ -74,12 +73,6 @@ def check_matching_billing_email
end
end

def check_matching_product_key
if details["config"]["financial_product_key"] != payment_method.preferred_product_key
errors.add :financial_product_key, "Product key mismatch"
end
end

def actions
%w{capture void credit}
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/spree/gateway/affirm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ module Spree
class Gateway::Affirm < Gateway
preference :api_key, :string
preference :secret_key, :string
preference :server, :string, default: 'www.affirm.com'
preference :product_key, :string
preference :test_mode, :boolean, default: true
preference :server, :string, default: 'sandbox.affirm.com'

def provider_class
ActiveMerchant::Billing::Affirm
Expand Down
16 changes: 9 additions & 7 deletions app/views/spree/checkout/payment/_affirm.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
\*****************************************************/
var _affirm_config = {
public_api_key: "<%= payment_method.preferred_api_key %>",
script: "https://<%= payment_method.preferred_server %>/js/v2/affirm.js"
script: "https://<%= payment_method.preferences[:test_mode] ? 'cdn1-sandbox.affirm.com' : 'cdn1.affirm.com' %>/js/v2/affirm.js"
};
(function(l,g,m,e,a,f,b){var d,c=l[m]||{},h=document.createElement(f),n=document.getElementsByTagName(f)[0],k=function(a,b,c){return function(){a[b]._.push([c,arguments])}};c[e]=k(c,e,"set");d=c[e];c[a]={};c[a]._=[];d._=[];c[a][b]=k(c,a,b);a=0;for(b="set add save post open empty reset on off trigger ready setProduct".split(" ");a<b.length;a++)d[b[a]]=k(c,e,b[a]);a=0;for(b=["get","token","url","items"];a<b.length;a++)d[b[a]]=function(){};h.async=!0;h.src=g[f];n.parentNode.insertBefore(h,n);delete g[f];d(g);l[m]=c})(window,_affirm_config,"affirm","checkout","ui","script","ready");

Expand All @@ -23,7 +23,7 @@
total: <%= (@order.total * 100).to_i %>,
currency: "USD",
tax_amount: <%= (@order.additional_tax_total * 100).to_i %>,
checkout_id: "<%= @order.number %>",
order_id: "<%= @order.number %>",
discount_code: "<%= @order.coupon_code %>",
shipping_type: "<%= @order.shipments.first.shipping_method.name if @order.shipments.exists? %>",
shipping_amount: <%= (@order.shipment_total * 100).to_i %>,
Expand Down Expand Up @@ -58,10 +58,14 @@
},


metadata: {
"platform_type": "Spree Commerce",
"platform_version": "<%= Spree.version %>",
"platform_affirm": "<%= Spree::Gateway::Affirm.version %>",
},

meta: {
source: {
client_name: "spree_affirm",
version: "<%= Spree::Gateway::Affirm.version %>",
data: {
<% if spree_current_user %>
order_count: "<%= spree_current_user.orders.complete.count %>",
Expand All @@ -73,7 +77,6 @@

<% end %>
is_logged_in: <%= !!spree_current_user %>,
spree_version: "<%= Spree.version %>"
}
}
},
Expand Down Expand Up @@ -182,8 +185,7 @@
clicked
\*****************************************************/
window.AffirmPaymentMethods["<%= payment_method.id %>"] = {
public_api_key: "<%= payment_method.preferred_api_key %>",
financial_product_key: "<%= payment_method.preferred_product_key %>"
public_api_key: "<%= payment_method.preferred_api_key %>"
};

}());
Expand Down
2 changes: 0 additions & 2 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ en:
"Quantity mismatch": "Quantity mismatch"
"Price mismatch": "Price mismatch"
"Billing email mismatch": "Billing email mismatch"
"Product key mismatch": "Product key mismatch"
"city mismatch": "city mismatch"
"street1 mismatch": "street1 mismatch"
"street2 mismatch": "street2 mismatch"
Expand All @@ -27,5 +26,4 @@ en:
billing_address: "billing address"
shipping_address: "shipping address"
billing_email: "email"
financial_product_key: "Affirm Financial Product"

8 changes: 0 additions & 8 deletions lib/spree_affirm/factories/affirm_checkout_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ def BASE_CHECKOUT_DETAILS
"misc_fee_amount"=> 0,
"shipping_type"=> "Free National UPS",
"config"=> {
"financial_product_key"=> "XXXXXXXXXXXXXXX",
"financial_product_type"=> "splitpay",
"required_billing_fields"=> [
"name",
"address",
Expand All @@ -84,7 +82,6 @@ def BASE_CHECKOUT_DETAILS

transient do
stub_details true
product_key_mismatch false
shipping_address_mismatch false
billing_address_mismatch false
alternate_billing_address_format false
Expand All @@ -101,11 +98,6 @@ def BASE_CHECKOUT_DETAILS

_details = BASE_CHECKOUT_DETAILS()

# product keys
unless evaluator.product_key_mismatch
_details['config']['financial_product_key'] = checkout.payment_method.preferred_product_key
end

# case mismatch
unless evaluator.full_name_case_mismatch
_details['billing']['name'] = {
Expand Down
2 changes: 1 addition & 1 deletion lib/spree_affirm/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module SpreeAffirm
VERSION = "0.2.23"
VERSION = "0.2.24"
end
21 changes: 0 additions & 21 deletions spec/models/spree_affirm_checkout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,27 +180,6 @@
end
end


describe "check_matching_product_key" do
context "with a matching product key" do
it "does not set an error for the financial_product_key" do
valid_checkout.check_matching_product_key
expect(valid_checkout.errors[:financial_product_key]).to be_empty
end
end


context "with a mistmatched product key" do
it "adds an error for financial_product_key" do
_checkout = FactoryGirl.build(:affirm_checkout, product_key_mismatch: true)
_checkout.check_matching_product_key
expect(_checkout.errors[:financial_product_key]).not_to be_empty
end
end
end



describe "actions" do

describe "#actions" do
Expand Down
8 changes: 4 additions & 4 deletions spree_affirm.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ Gem::Specification.new do |s|
s.name = 'spree_affirm'
s.version = SpreeAffirm::VERSION
s.summary = 'Affirm Spree Payment Gateway'
s.description = 'Affirm payment Gateway for spree'
s.description = 'Affirm payment Gateway for Spree'
s.required_ruby_version = '>= 1.9.3'

s.author = 'Yu Pan'
s.email = 'yu.pan@affirm.com'
s.homepage = 'http://www.spreecommerce.com'
s.author = 'Affirm'
s.email = 'mts@affirm.com'
s.homepage = 'http://www.affirm.com'

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
Expand Down

0 comments on commit 69d80f1

Please sign in to comment.