spree_affirm 0.2.22 → 0.2.30

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 153e47d647bb78a846fd510c6159b9481d95a734
4
- data.tar.gz: 91930c356c9b1464fcadea6f792308d17cab4043
2
+ SHA256:
3
+ metadata.gz: 65cad531f525308a5dc67e738afc77b388e2a611e15890ea215e9854772f1c45
4
+ data.tar.gz: ac0b662dddaf01d3bc79041001bf2809212a54f5a68b41f31827f10a2e748f70
5
5
  SHA512:
6
- metadata.gz: 23120efffeaa8e5b7e9feb01308aae629236a3339728b79ed136325ca9fae365014f3e910b5567107e8ea13d6f780587353ce5c7037349b1cf63b3aa29e93733
7
- data.tar.gz: 5834541f7179d62e0151aa3eeeddc52764da026f2fe0b7def043d11f74f24163c90130491a7e83d61c9f3cd8596316b4ea6f0fc3fcb7981bdd4d577174b9702b
6
+ metadata.gz: 5545ba5abc61022425b0831401417630cfc0a62a0bef664a240a2824babd4e380852c91f37dd7c53c012c0b41713716491e149203d81489764ea04c0041c05d3
7
+ data.tar.gz: 220c681e146b9861c7aed937b7c834a76e7727688671faee3c90656d5a21f09a1fcc9ed1620c1c0cc099c723866aea60162ee25406f6d6b3c557190e8ad69c97
data/Gemfile CHANGED
@@ -1,13 +1,13 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'spree', github: 'spree/spree', branch: '2-3-stable'
4
- gem 'spree_gateway', github: 'spree/spree_gateway', branch: '2-3-stable'
5
- gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '2-3-stable'
3
+ gem 'spree', github: 'spree/spree', tag: 'v0.2.25'
4
+ gem 'spree_gateway', github: 'spree/spree_gateway', tag: 'v0.2.25'
5
+ gem 'spree_auth_devise', github: 'spree/spree_auth_devise', tag: 'v0.2.25'
6
6
 
7
7
  group :test do
8
8
  gem 'coffee-rails'
9
9
  gem 'sass-rails', '~> 4.0.3'
10
- gem 'money', '6.0.1'
10
+ gem 'money', '6.5.1'
11
11
  gem 'rspec-rails', '~> 2.10'
12
12
  gem 'shoulda-matchers', '2.2.0'
13
13
  gem 'simplecov', :require => false
data/LICENSE CHANGED
@@ -1,26 +1,29 @@
1
- Copyright (c) 2014 [name of plugin creator]
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2019, Affirm
2
4
  All rights reserved.
3
5
 
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.
6
15
 
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.
15
19
 
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.
data/README.md CHANGED
@@ -18,6 +18,10 @@ Installation
18
18
 
19
19
  4. Restart your server
20
20
 
21
+ Documentation
22
+ ------------------
23
+ https://docs.affirm.com/Spree
24
+
21
25
  ## Contributing
22
26
 
23
27
  1. Fork it
@@ -37,11 +41,11 @@ bundle exec rake test_app
37
41
  bundle exec rspec spec
38
42
  ```
39
43
 
40
- When testing your applications integration with this extension you may use it's factories.
44
+ When testing your applications integration with this extension you may use its factories.
41
45
  Simply add this require statement to your spec_helper:
42
46
 
43
47
  ```ruby
44
48
  require 'spree_affirm/factories'
45
49
  ```
46
50
 
47
- Copyright (c) 2014 [name of extension creator], released under the New BSD License
51
+ Copyright (c) 2019 Affirm, released under the New BSD License
@@ -24,31 +24,7 @@ module Spree
24
24
  payment_method: payment_method
25
25
  )
26
26
 
27
- # check if data needs to be updated
28
- unless _affirm_checkout.valid?
29
-
30
- _affirm_checkout.errors.each do |field, error|
31
- case field
32
- when :billing_address
33
- # FIXME(brian): pass the phone number to the |order| in a better place
34
- phone = order.bill_address.phone
35
- order.bill_address = generate_spree_address(_affirm_checkout.details['billing'])
36
- order.bill_address.phone = phone
37
-
38
- when :shipping_address
39
- # FIXME(brian): pass the phone number to the |order| in a better place
40
- phone = order.shipping_address.phone
41
- order.ship_address = generate_spree_address(_affirm_checkout.details['shipping'])
42
- order.ship_address.phone = phone
43
-
44
- when :billing_email
45
- order.email = _affirm_checkout.details["billing"]["email"]
46
-
47
- end
48
- end
49
-
50
- order.save
51
- end
27
+ order.save
52
28
 
53
29
  _affirm_checkout.save
54
30
 
@@ -59,7 +35,7 @@ module Spree
59
35
  })
60
36
 
61
37
  # transition to confirm or complete
62
- while order.next; end
38
+ order.next
63
39
 
64
40
  if order.completed?
65
41
  session[:order_id] = nil
@@ -88,40 +64,5 @@ module Spree
88
64
  def completion_route(order)
89
65
  spree.order_path(order)
90
66
  end
91
-
92
- def generate_spree_address(affirm_address)
93
- # find the state and country in spree
94
- _state = Spree::State.find_by_abbr(affirm_address["address"]["region1_code"]) or
95
- Spree::State.find_by_name(affirm_address["address"]["region1_code"])
96
- _country = Spree::Country.find_by_iso3(affirm_address["address"]["country_code"]) or
97
- Spree::Country.find_by_iso(affirm_address["address"]["country_code"])
98
-
99
- # try to get the name from first and last
100
- _firstname = affirm_address["name"]["first"] if affirm_address["name"]["first"].present?
101
- _lastname = affirm_address["name"]["last"] if affirm_address["name"]["last"].present?
102
-
103
- # fall back to using the full name if available
104
- if _firstname.nil? and _lastname.nil? and affirm_address["name"]["full"].present?
105
- _name_parts = affirm_address["name"]["full"].split " "
106
- _lastname = _name_parts.pop
107
- _firstname = _name_parts.join " "
108
- end
109
-
110
- # create new address
111
- _spree_address = Spree::Address.new(
112
- city: affirm_address["address"]["city"],
113
- phone: affirm_address["phone_number"],
114
- zipcode: affirm_address["address"]["postal_code"],
115
- address1: affirm_address["address"]["street1"],
116
- address2: affirm_address["address"]["street2"],
117
- state: _state,
118
- country: _country,
119
- lastname: _lastname,
120
- firstname: _firstname
121
- )
122
-
123
- _spree_address.save
124
- _spree_address
125
- end
126
67
  end
127
68
  end
@@ -3,8 +3,6 @@ module Spree
3
3
  belongs_to :payment_method
4
4
  belongs_to :order
5
5
 
6
- validate :validate_checkout_matches_order
7
-
8
6
  scope :with_payment_profile, -> { all }
9
7
 
10
8
  def name
@@ -15,71 +13,6 @@ module Spree
15
13
  @details ||= payment_method.provider.get_checkout token
16
14
  end
17
15
 
18
- def validate_checkout_matches_order
19
- return if self.id
20
-
21
- check_valid_products
22
- check_matching_shipping_address
23
- check_matching_billing_address
24
- check_matching_billing_email
25
- check_matching_product_key
26
- end
27
-
28
- def check_valid_products
29
- # ensure the number of line items matches
30
- if details["items"].size != order.line_items.size
31
- errors.add :line_items, "Order size mismatch"
32
- end
33
-
34
- # iterate through the line items of the checkout
35
- order.line_items.each do |line_item|
36
-
37
- # check that the line item sku exists in the affirm checkout
38
- if !(_item = details["items"][line_item.variant.sku])
39
- errors.add :line_items, "Line Item not in checkout details"
40
-
41
- # check quantity & price
42
- elsif _item["qty"].to_i != line_item.quantity.to_i
43
- errors.add :line_items, "Quantity mismatch"
44
-
45
- elsif _item["unit_price"].to_i != (line_item.price*100).to_i
46
- errors.add :line_items, "Price mismatch"
47
-
48
- end
49
- end
50
-
51
- # all products match
52
- true
53
- end
54
-
55
- def check_matching_billing_address
56
- # ensure we have a standardized address format
57
- details['billing']['address'] = normalize_affirm_address details['billing']['address']
58
-
59
- # validate address
60
- check_address_match details["billing"], order.bill_address, :billing_address
61
- end
62
-
63
- def check_matching_shipping_address
64
- # ensure we have a standardized address format
65
- details['shipping']['address'] = normalize_affirm_address details['shipping']['address']
66
-
67
- # validate address
68
- check_address_match details["shipping"], order.ship_address, :shipping_address
69
- end
70
-
71
- def check_matching_billing_email
72
- if details["billing"]["email"].present? and details["billing"]["email"].casecmp(order.email) != 0
73
- errors.add :billing_email, "Billing email mismatch"
74
- end
75
- end
76
-
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
-
83
16
  def actions
84
17
  %w{capture void credit}
85
18
  end
@@ -101,47 +34,5 @@ module Spree
101
34
  return false unless payment.order.payment_state == 'credit_owed'
102
35
  payment.credit_allowed > 0
103
36
  end
104
-
105
- private
106
-
107
-
108
- def normalize_affirm_address(affirm_address_details)
109
- Affirm::AddressValidator.normalize_affirm_address(affirm_address_details)
110
- end
111
-
112
- def check_address_match(affirm_address, spree_address, field)
113
- # mapping from affirm address keys to spree address values
114
- _key_mapping = {
115
- city: spree_address.city,
116
- street1: spree_address.address1,
117
- street2: spree_address.address2,
118
- postal_code: spree_address.zipcode,
119
- region1_code: spree_address.state.abbr
120
-
121
- # check that each value from affirm matches the spree address
122
- }.each do |affirm_key, spree_val|
123
- if affirm_address["address"][affirm_key.to_s].present? and
124
- affirm_address["address"][affirm_key.to_s] != spree_val
125
-
126
- errors.add field, "#{affirm_key.to_s} mismatch"
127
- end
128
- end
129
-
130
- # test affirm names with first and last
131
- if affirm_address["name"]["first"].present? and affirm_address["name"]["last"].present? and
132
- (affirm_address["name"]["first"].casecmp(spree_address.firstname) != 0 or
133
- affirm_address["name"]["last"].casecmp(spree_address.lastname) != 0)
134
-
135
- errors.add field, "First/Last name mismatch"
136
-
137
- # test affirm names with full name
138
- elsif affirm_address["name"]["full"].present? and
139
- !(affirm_address["name"]["full"].downcase.include?(spree_address.firstname.downcase) and
140
- affirm_address["name"]["full"].downcase.include?(spree_address.lastname.downcase))
141
-
142
- errors.add field, "Full name mismatch"
143
- end
144
- end
145
-
146
37
  end
147
38
  end
@@ -2,8 +2,8 @@ module Spree
2
2
  class Gateway::Affirm < Gateway
3
3
  preference :api_key, :string
4
4
  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'
7
7
 
8
8
  def provider_class
9
9
  ActiveMerchant::Billing::Affirm
@@ -36,22 +36,15 @@ module Spree
36
36
  def cancel(charge_ari)
37
37
  _payment = Spree::Payment.valid.where(
38
38
  response_code: charge_ari,
39
- source_type: "#{payment_source_class}"
39
+ source_type: payment_source_class.to_s
40
40
  ).first
41
41
 
42
42
  return if _payment.nil?
43
43
 
44
44
  if _payment.pending?
45
45
  _payment.void_transaction!
46
-
47
- elsif _payment.completed? and _payment.can_credit?
48
-
49
- # create adjustment
50
- _payment.order.adjustments.create label: "Refund - Canceled Order", amount: -_payment.credit_allowed.to_f
51
- _payment.order.update!
52
-
53
- _payment.credit!
54
-
46
+ elsif _payment.completed? && _payment.can_credit?
47
+ provider.refund(_payment.credit_allowed.to_money.cents, charge_ari)
55
48
  end
56
49
  end
57
50
  end
@@ -1,7 +1,3 @@
1
- <div class="affirm-learn-more-section">
2
- <%= render partial: 'spree/checkout/affirm/learn_more' %>
3
- </div>
4
-
5
1
  <script>
6
2
  (function(){
7
3
  /* only include this setup once */
@@ -12,7 +8,7 @@
12
8
  \*****************************************************/
13
9
  var _affirm_config = {
14
10
  public_api_key: "<%= payment_method.preferred_api_key %>",
15
- script: "https://<%= payment_method.preferred_server %>/js/v2/affirm.js"
11
+ script: "https://<%= payment_method.preferences[:test_mode] ? 'cdn1-sandbox.affirm.com' : 'cdn1.affirm.com' %>/js/v2/affirm.js"
16
12
  };
17
13
  (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");
18
14
 
@@ -23,9 +19,9 @@
23
19
  total: <%= (@order.total * 100).to_i %>,
24
20
  currency: "USD",
25
21
  tax_amount: <%= (@order.additional_tax_total * 100).to_i %>,
26
- checkout_id: "<%= @order.number %>",
22
+ order_id: "<%= @order.number %>",
27
23
  discount_code: "<%= @order.coupon_code %>",
28
- shipping_type: "<%= @order.shipments.first.shipping_method.name if @order.shipments %>",
24
+ shipping_type: "<%= @order.shipments.first.shipping_method.name if @order.shipments.exists? %>",
29
25
  shipping_amount: <%= (@order.shipment_total * 100).to_i %>,
30
26
 
31
27
  shipping: {
@@ -58,10 +54,14 @@
58
54
  },
59
55
 
60
56
 
57
+ metadata: {
58
+ "platform_type": "Spree Commerce",
59
+ "platform_version": "<%= Spree.version %>",
60
+ "platform_affirm": "<%= Spree::Gateway::Affirm.version %>",
61
+ },
62
+
61
63
  meta: {
62
64
  source: {
63
- client_name: "spree_affirm",
64
- version: "<%= Spree::Gateway::Affirm.version %>",
65
65
  data: {
66
66
  <% if spree_current_user %>
67
67
  order_count: "<%= spree_current_user.orders.complete.count %>",
@@ -73,7 +73,6 @@
73
73
 
74
74
  <% end %>
75
75
  is_logged_in: <%= !!spree_current_user %>,
76
- spree_version: "<%= Spree.version %>"
77
76
  }
78
77
  }
79
78
  },
@@ -123,28 +122,28 @@
123
122
  affirm.ui.ready(function(){
124
123
  $(function() {
125
124
 
125
+ /*****************************************************\
126
+ change the payment method name
127
+ \*****************************************************/
128
+
129
+ $( ".payment-option" ).each(function() {
130
+
131
+ if($( this )[0].innerText === "Affirm"){
132
+
133
+ $( this )[0].lastChild.data = "Affirm Monthly Payments";
134
+ }
135
+ });
136
+
126
137
  /*****************************************************\
127
138
  setup loading and cancel events for the form
128
139
  \*****************************************************/
140
+
129
141
  affirm.checkout.on("cancel", function(){
130
142
  $("#checkout_form_payment input.disabled")
131
143
  .attr("disabled", false)
132
144
  .removeClass("disabled");
133
145
  });
134
146
 
135
- var button_text = $("#checkout_form_payment input").val();
136
-
137
- $("#checkout_form_payment input[type='submit']").on("loading", function(){
138
- button_text = $(this).val();
139
- $(this).val("Loading...");
140
- })
141
-
142
- .on("done_loading", function(){
143
- $(this).val(button_text);
144
- });
145
-
146
-
147
-
148
147
  /*****************************************************\
149
148
  handle continue button clicks with .open()
150
149
  \*****************************************************/
@@ -152,14 +151,12 @@
152
151
  var checkedPaymentMethod = $('div[data-hook="checkout_payment_step"] input[type="radio"]:checked').val();
153
152
 
154
153
  if (window.AffirmPaymentMethods[checkedPaymentMethod]) {
154
+
155
155
  var $submit_button = $(this).find("input[type='submit']");
156
156
 
157
157
  // update with checkout method details
158
158
  affirm.checkout(window.AffirmPaymentMethods[checkedPaymentMethod]);
159
159
 
160
- // show the loading message
161
- $submit_button.trigger("loading");
162
-
163
160
  // submit the checkout
164
161
  affirm.checkout.open({
165
162
  target: $submit_button
@@ -170,6 +167,15 @@
170
167
  }
171
168
  });
172
169
  });
170
+
171
+ /*****************************************************\
172
+ remove the payment source empty box from UI
173
+ \*****************************************************/
174
+ $(document).on('click', '#checkout_form_payment'
175
+ , function (event) {
176
+ if($('div[data-hook="checkout_payment_step"] input[type="radio"]:checked')[0].parentNode.outerText === "Affirm Monthly Payments") $('.payment-sources').hide();
177
+ }
178
+ )
173
179
  });
174
180
 
175
181
  window.AffirmPaymentMethods = {};
@@ -182,9 +188,8 @@
182
188
  clicked
183
189
  \*****************************************************/
184
190
  window.AffirmPaymentMethods["<%= payment_method.id %>"] = {
185
- public_api_key: "<%= payment_method.preferred_api_key %>",
186
- financial_product_key: "<%= payment_method.preferred_product_key %>"
191
+ public_api_key: "<%= payment_method.preferred_api_key %>"
187
192
  };
188
-
189
193
  }());
194
+
190
195
  </script>
@@ -12,7 +12,6 @@ en:
12
12
  "Quantity mismatch": "Quantity mismatch"
13
13
  "Price mismatch": "Price mismatch"
14
14
  "Billing email mismatch": "Billing email mismatch"
15
- "Product key mismatch": "Product key mismatch"
16
15
  "city mismatch": "city mismatch"
17
16
  "street1 mismatch": "street1 mismatch"
18
17
  "street2 mismatch": "street2 mismatch"
@@ -27,5 +26,4 @@ en:
27
26
  billing_address: "billing address"
28
27
  shipping_address: "shipping address"
29
28
  billing_email: "email"
30
- financial_product_key: "Affirm Financial Product"
31
29
 
@@ -62,8 +62,6 @@ def BASE_CHECKOUT_DETAILS
62
62
  "misc_fee_amount"=> 0,
63
63
  "shipping_type"=> "Free National UPS",
64
64
  "config"=> {
65
- "financial_product_key"=> "XXXXXXXXXXXXXXX",
66
- "financial_product_type"=> "splitpay",
67
65
  "required_billing_fields"=> [
68
66
  "name",
69
67
  "address",
@@ -82,9 +80,8 @@ FactoryGirl.define do
82
80
  association(:order, factory: :order_with_line_items)
83
81
 
84
82
 
85
- ignore do
83
+ transient do
86
84
  stub_details true
87
- product_key_mismatch false
88
85
  shipping_address_mismatch false
89
86
  billing_address_mismatch false
90
87
  alternate_billing_address_format false
@@ -101,11 +98,6 @@ FactoryGirl.define do
101
98
 
102
99
  _details = BASE_CHECKOUT_DETAILS()
103
100
 
104
- # product keys
105
- unless evaluator.product_key_mismatch
106
- _details['config']['financial_product_key'] = checkout.payment_method.preferred_product_key
107
- end
108
-
109
101
  # case mismatch
110
102
  unless evaluator.full_name_case_mismatch
111
103
  _details['billing']['name'] = {
@@ -1,3 +1,3 @@
1
1
  module SpreeAffirm
2
- VERSION = "0.2.22"
2
+ VERSION = "0.2.30"
3
3
  end
@@ -180,27 +180,6 @@ describe Spree::AffirmCheckout do
180
180
  end
181
181
  end
182
182
 
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
-
204
183
  describe "actions" do
205
184
 
206
185
  describe "#actions" do
@@ -75,9 +75,6 @@ describe Spree::Gateway::Affirm do
75
75
  expect(affirm_payment).to receive(:credit!).and_return false
76
76
  _payment_amount = affirm_payment.credit_allowed
77
77
  affirm_payment.payment_method.cancel affirm_payment.response_code
78
-
79
- expect(affirm_payment.order.adjustments.count).to be > 0
80
- expect(affirm_payment.order.adjustments.last.amount).to eq(-_payment_amount)
81
78
  end
82
79
  end
83
80
 
@@ -7,19 +7,19 @@ Gem::Specification.new do |s|
7
7
  s.name = 'spree_affirm'
8
8
  s.version = SpreeAffirm::VERSION
9
9
  s.summary = 'Affirm Spree Payment Gateway'
10
- s.description = 'Affirm payment Gateway for spree'
10
+ s.description = 'Affirm payment Gateway for Spree'
11
11
  s.required_ruby_version = '>= 1.9.3'
12
12
 
13
- s.author = 'Yu Pan'
14
- s.email = 'yu.pan@affirm.com'
15
- s.homepage = 'http://www.spreecommerce.com'
13
+ s.author = 'Affirm'
14
+ s.email = 'mts@affirm.com'
15
+ s.homepage = 'http://www.affirm.com'
16
16
 
17
17
  s.files = `git ls-files`.split("\n")
18
18
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
19
  s.require_path = 'lib'
20
20
  s.requirements << 'none'
21
21
 
22
- s.add_dependency 'spree_core', '>= 2.2.0'
22
+ s.add_dependency 'spree_core', '~> 2.2', '>= 2.2.0'
23
23
 
24
24
  s.add_development_dependency 'factory_girl', '~> 4.2'
25
25
  s.add_development_dependency 'ffaker', '~> 1.16'
metadata CHANGED
@@ -1,120 +1,126 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_affirm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.22
4
+ version: 0.2.30
5
5
  platform: ruby
6
6
  authors:
7
- - Yu Pan
7
+ - Affirm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-15 00:00:00.000000000 Z
11
+ date: 2020-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: spree_core
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.2'
20
+ - - ">="
18
21
  - !ruby/object:Gem::Version
19
22
  version: 2.2.0
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - '>='
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '2.2'
30
+ - - ">="
25
31
  - !ruby/object:Gem::Version
26
32
  version: 2.2.0
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: factory_girl
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - ~>
37
+ - - "~>"
32
38
  - !ruby/object:Gem::Version
33
39
  version: '4.2'
34
40
  type: :development
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
- - - ~>
44
+ - - "~>"
39
45
  - !ruby/object:Gem::Version
40
46
  version: '4.2'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: ffaker
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - ~>
51
+ - - "~>"
46
52
  - !ruby/object:Gem::Version
47
53
  version: '1.16'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
- - - ~>
58
+ - - "~>"
53
59
  - !ruby/object:Gem::Version
54
60
  version: '1.16'
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: rspec-rails
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
- - - ~>
65
+ - - "~>"
60
66
  - !ruby/object:Gem::Version
61
67
  version: '2.13'
62
68
  type: :development
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
- - - ~>
72
+ - - "~>"
67
73
  - !ruby/object:Gem::Version
68
74
  version: '2.13'
69
75
  - !ruby/object:Gem::Dependency
70
76
  name: simplecov
71
77
  requirement: !ruby/object:Gem::Requirement
72
78
  requirements:
73
- - - ~>
79
+ - - "~>"
74
80
  - !ruby/object:Gem::Version
75
81
  version: '0.9'
76
82
  type: :development
77
83
  prerelease: false
78
84
  version_requirements: !ruby/object:Gem::Requirement
79
85
  requirements:
80
- - - ~>
86
+ - - "~>"
81
87
  - !ruby/object:Gem::Version
82
88
  version: '0.9'
83
89
  - !ruby/object:Gem::Dependency
84
90
  name: simplecov-rcov
85
91
  requirement: !ruby/object:Gem::Requirement
86
92
  requirements:
87
- - - ~>
93
+ - - "~>"
88
94
  - !ruby/object:Gem::Version
89
95
  version: '0.2'
90
96
  type: :development
91
97
  prerelease: false
92
98
  version_requirements: !ruby/object:Gem::Requirement
93
99
  requirements:
94
- - - ~>
100
+ - - "~>"
95
101
  - !ruby/object:Gem::Version
96
102
  version: '0.2'
97
103
  - !ruby/object:Gem::Dependency
98
104
  name: sqlite3
99
105
  requirement: !ruby/object:Gem::Requirement
100
106
  requirements:
101
- - - ~>
107
+ - - "~>"
102
108
  - !ruby/object:Gem::Version
103
109
  version: '1.3'
104
110
  type: :development
105
111
  prerelease: false
106
112
  version_requirements: !ruby/object:Gem::Requirement
107
113
  requirements:
108
- - - ~>
114
+ - - "~>"
109
115
  - !ruby/object:Gem::Version
110
116
  version: '1.3'
111
- description: Affirm payment Gateway for spree
112
- email: yu.pan@affirm.com
117
+ description: Affirm payment Gateway for Spree
118
+ email: mts@affirm.com
113
119
  executables: []
114
120
  extensions: []
115
121
  extra_rdoc_files: []
116
122
  files:
117
- - .gitignore
123
+ - ".gitignore"
118
124
  - Gemfile
119
125
  - LICENSE
120
126
  - README.md
@@ -125,14 +131,12 @@ files:
125
131
  - app/assets/stylesheets/spree/backend/spree_affirm.css
126
132
  - app/assets/stylesheets/spree/frontend/spree_affirm.css
127
133
  - app/controllers/spree/affirm_controller.rb
128
- - app/models/affirm/address_validator.rb
129
134
  - app/models/spree/affirm_checkout.rb
130
135
  - app/models/spree/gateway/affirm.rb
131
136
  - app/views/spree/admin/log_entries/_affirm.html.erb
132
137
  - app/views/spree/admin/log_entries/index.html.erb
133
138
  - app/views/spree/admin/payments/source_forms/_affirm.html.erb
134
139
  - app/views/spree/admin/payments/source_views/_affirm.html.erb
135
- - app/views/spree/checkout/affirm/_learn_more.html.erb
136
140
  - app/views/spree/checkout/payment/_affirm.html.erb
137
141
  - bin/rails
138
142
  - config/locales/en.yml
@@ -154,7 +158,7 @@ files:
154
158
  - spec/models/spree_gateway_affirm_spec.rb
155
159
  - spec/spec_helper.rb
156
160
  - spree_affirm.gemspec
157
- homepage: http://www.spreecommerce.com
161
+ homepage: http://www.affirm.com
158
162
  licenses: []
159
163
  metadata: {}
160
164
  post_install_message:
@@ -163,18 +167,17 @@ require_paths:
163
167
  - lib
164
168
  required_ruby_version: !ruby/object:Gem::Requirement
165
169
  requirements:
166
- - - '>='
170
+ - - ">="
167
171
  - !ruby/object:Gem::Version
168
172
  version: 1.9.3
169
173
  required_rubygems_version: !ruby/object:Gem::Requirement
170
174
  requirements:
171
- - - '>='
175
+ - - ">="
172
176
  - !ruby/object:Gem::Version
173
177
  version: '0'
174
178
  requirements:
175
179
  - none
176
- rubyforge_project:
177
- rubygems_version: 2.2.2
180
+ rubygems_version: 3.1.2
178
181
  signing_key:
179
182
  specification_version: 4
180
183
  summary: Affirm Spree Payment Gateway
@@ -1,25 +0,0 @@
1
- module Affirm
2
- class AddressValidator
3
- def self.normalize_affirm_address(affirm_address_details)
4
- _address_mapping = {
5
- "city" => 'city',
6
- "street1" => 'line1',
7
- "street2" => 'line2',
8
- "postal_code" => 'zipcode',
9
- "region1_code" => 'state',
10
- "country_code" => 'country'
11
- }
12
-
13
- _address_mapping.each do |key, mapped_key|
14
-
15
- unless affirm_address_details[key].present?
16
- affirm_address_details[key] = affirm_address_details[mapped_key]
17
- end
18
-
19
- end
20
-
21
- affirm_address_details
22
- end
23
-
24
- end
25
- end