Skip to content

Commit 69d80f1

Browse files
author
Dipti Bele
authored
Merge pull request #8 from Affirm/0-2-4-stable
0.2.4 stable
2 parents 6144102 + 48ecbdf commit 69d80f1

File tree

11 files changed

+49
-78
lines changed

11 files changed

+49
-78
lines changed

Gemfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
source 'https://rubygems.org'
22

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

77
group :test do
88
gem 'coffee-rails'

LICENSE

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
1-
Copyright (c) 2014 [name of plugin creator]
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2018, Affirm
24
All rights reserved.
35

4-
Redistribution and use in source and binary forms, with or without modification,
5-
are permitted provided that the following conditions are met:
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
* Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
615

7-
* Redistributions of source code must retain the above copyright notice,
8-
this list of conditions and the following disclaimer.
9-
* Redistributions in binary form must reproduce the above copyright notice,
10-
this list of conditions and the following disclaimer in the documentation
11-
and/or other materials provided with the distribution.
12-
* Neither the name Spree nor the names of its contributors may be used to
13-
endorse or promote products derived from this software without specific
14-
prior written permission.
16+
* Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
1519

16-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20-
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21-
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22-
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23-
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26-
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ Installation
1818

1919
4. Restart your server
2020

21+
Documentation
22+
------------------
23+
https://docs.affirm.com/Spree
24+
2125
## Contributing
2226

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

47-
Copyright (c) 2015 Affirm, released under the New BSD License
51+
Copyright (c) 2018 Affirm, released under the New BSD License

app/models/spree/affirm_checkout.rb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ def validate_checkout_matches_order
2222
check_matching_shipping_address
2323
check_matching_billing_address
2424
check_matching_billing_email
25-
check_matching_product_key
2625
end
2726

2827
def check_valid_products
@@ -74,12 +73,6 @@ def check_matching_billing_email
7473
end
7574
end
7675

77-
def check_matching_product_key
78-
if details["config"]["financial_product_key"] != payment_method.preferred_product_key
79-
errors.add :financial_product_key, "Product key mismatch"
80-
end
81-
end
82-
8376
def actions
8477
%w{capture void credit}
8578
end

app/models/spree/gateway/affirm.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ module Spree
22
class Gateway::Affirm < Gateway
33
preference :api_key, :string
44
preference :secret_key, :string
5-
preference :server, :string, default: 'www.affirm.com'
6-
preference :product_key, :string
5+
preference :test_mode, :boolean, default: true
6+
preference :server, :string, default: 'sandbox.affirm.com'
77

88
def provider_class
99
ActiveMerchant::Billing::Affirm

app/views/spree/checkout/payment/_affirm.html.erb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
\*****************************************************/
1313
var _affirm_config = {
1414
public_api_key: "<%= payment_method.preferred_api_key %>",
15-
script: "https://<%= payment_method.preferred_server %>/js/v2/affirm.js"
15+
script: "https://<%= payment_method.preferences[:test_mode] ? 'cdn1-sandbox.affirm.com' : 'cdn1.affirm.com' %>/js/v2/affirm.js"
1616
};
1717
(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");
1818

@@ -23,7 +23,7 @@
2323
total: <%= (@order.total * 100).to_i %>,
2424
currency: "USD",
2525
tax_amount: <%= (@order.additional_tax_total * 100).to_i %>,
26-
checkout_id: "<%= @order.number %>",
26+
order_id: "<%= @order.number %>",
2727
discount_code: "<%= @order.coupon_code %>",
2828
shipping_type: "<%= @order.shipments.first.shipping_method.name if @order.shipments.exists? %>",
2929
shipping_amount: <%= (@order.shipment_total * 100).to_i %>,
@@ -58,10 +58,14 @@
5858
},
5959

6060

61+
metadata: {
62+
"platform_type": "Spree Commerce",
63+
"platform_version": "<%= Spree.version %>",
64+
"platform_affirm": "<%= Spree::Gateway::Affirm.version %>",
65+
},
66+
6167
meta: {
6268
source: {
63-
client_name: "spree_affirm",
64-
version: "<%= Spree::Gateway::Affirm.version %>",
6569
data: {
6670
<% if spree_current_user %>
6771
order_count: "<%= spree_current_user.orders.complete.count %>",
@@ -73,7 +77,6 @@
7377

7478
<% end %>
7579
is_logged_in: <%= !!spree_current_user %>,
76-
spree_version: "<%= Spree.version %>"
7780
}
7881
}
7982
},
@@ -182,8 +185,7 @@
182185
clicked
183186
\*****************************************************/
184187
window.AffirmPaymentMethods["<%= payment_method.id %>"] = {
185-
public_api_key: "<%= payment_method.preferred_api_key %>",
186-
financial_product_key: "<%= payment_method.preferred_product_key %>"
188+
public_api_key: "<%= payment_method.preferred_api_key %>"
187189
};
188190

189191
}());

config/locales/en.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ en:
1212
"Quantity mismatch": "Quantity mismatch"
1313
"Price mismatch": "Price mismatch"
1414
"Billing email mismatch": "Billing email mismatch"
15-
"Product key mismatch": "Product key mismatch"
1615
"city mismatch": "city mismatch"
1716
"street1 mismatch": "street1 mismatch"
1817
"street2 mismatch": "street2 mismatch"
@@ -27,5 +26,4 @@ en:
2726
billing_address: "billing address"
2827
shipping_address: "shipping address"
2928
billing_email: "email"
30-
financial_product_key: "Affirm Financial Product"
3129

lib/spree_affirm/factories/affirm_checkout_factory.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ def BASE_CHECKOUT_DETAILS
6262
"misc_fee_amount"=> 0,
6363
"shipping_type"=> "Free National UPS",
6464
"config"=> {
65-
"financial_product_key"=> "XXXXXXXXXXXXXXX",
66-
"financial_product_type"=> "splitpay",
6765
"required_billing_fields"=> [
6866
"name",
6967
"address",
@@ -84,7 +82,6 @@ def BASE_CHECKOUT_DETAILS
8482

8583
transient do
8684
stub_details true
87-
product_key_mismatch false
8885
shipping_address_mismatch false
8986
billing_address_mismatch false
9087
alternate_billing_address_format false
@@ -101,11 +98,6 @@ def BASE_CHECKOUT_DETAILS
10198

10299
_details = BASE_CHECKOUT_DETAILS()
103100

104-
# product keys
105-
unless evaluator.product_key_mismatch
106-
_details['config']['financial_product_key'] = checkout.payment_method.preferred_product_key
107-
end
108-
109101
# case mismatch
110102
unless evaluator.full_name_case_mismatch
111103
_details['billing']['name'] = {

lib/spree_affirm/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module SpreeAffirm
2-
VERSION = "0.2.23"
2+
VERSION = "0.2.24"
33
end

spec/models/spree_affirm_checkout_spec.rb

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -180,27 +180,6 @@
180180
end
181181
end
182182

183-
184-
describe "check_matching_product_key" do
185-
context "with a matching product key" do
186-
it "does not set an error for the financial_product_key" do
187-
valid_checkout.check_matching_product_key
188-
expect(valid_checkout.errors[:financial_product_key]).to be_empty
189-
end
190-
end
191-
192-
193-
context "with a mistmatched product key" do
194-
it "adds an error for financial_product_key" do
195-
_checkout = FactoryGirl.build(:affirm_checkout, product_key_mismatch: true)
196-
_checkout.check_matching_product_key
197-
expect(_checkout.errors[:financial_product_key]).not_to be_empty
198-
end
199-
end
200-
end
201-
202-
203-
204183
describe "actions" do
205184

206185
describe "#actions" do

0 commit comments

Comments
 (0)