effective_orders 6.13.1 → 6.13.3

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
2
  SHA256:
3
- metadata.gz: 4499fc477da7ba7d00a8550057e754772594ca4622fdfc498ec6ff054b19eb30
4
- data.tar.gz: f8c09cce9f19c1e872ae4e1d27e3928d1be8ee0a29dc42d421c0a058bb8e0840
3
+ metadata.gz: a7823c5fb7e1f5de56c962426e8ac2f19dcf21eb3ee562652a086db304b1da18
4
+ data.tar.gz: f9487dfd15d7088bb70c96a865b8ef06e16fe67c986e25df209234e0f40344e8
5
5
  SHA512:
6
- metadata.gz: 8bd284864d14aedf394014d9cbea8fca1309a8856564c6f03f5dfe606d3cf123184cbda1d6a61fbfe0b2fdbe0e23be04c9d5979d0d3e371c43e3765e4f614264
7
- data.tar.gz: df32798cf7ebd2b0614e28befadef7f1ab391ffd0124c0748b74139f579cdcc6b8919c35c0307c47ed5fdade567a48cb54008cf765ebae39680baca5cd1874f2
6
+ metadata.gz: c5385f2d84ac47da6a90f54dce6a7abde305a85637f1fa9c15686c5fee5e27f36f9ac20c65355c4e92225a02496cb26e7f009a09bc00a6ba8e3c0bd7423a5619
7
+ data.tar.gz: fca2f157ed9f4d30b716382b6161653c42867e4d229f14707b6e2f11edbd49eec1d2677ac7ed381d527f025817d1c050dcc27ff8a2127899a330f34abffdbbbf
@@ -86,6 +86,17 @@ module Effective
86
86
  true
87
87
  end
88
88
 
89
+ def purchase_free!(order)
90
+ raise('expected a free order') unless order.free?
91
+
92
+ self.purchase_response = nil
93
+ payment = { card: "none", details: "free order. no payment required."}
94
+ self.purchase_response = payment
95
+
96
+ # Free is always valid
97
+ true
98
+ end
99
+
89
100
  # Create Payment
90
101
  def create_payment(order, payment_intent)
91
102
  response = post('/payments', params: create_payment_params(order, payment_intent))
@@ -128,10 +139,17 @@ module Effective
128
139
 
129
140
  order.update_columns(delayed_payment_purchase_ran_at: now, delayed_payment_purchase_result: nil)
130
141
 
131
- purchased = purchase!(order, order.delayed_payment_intent)
132
- provider = order.payment_provider
142
+ purchased = if order.total.to_i > 0
143
+ purchase!(order, order.delayed_payment_intent)
144
+ elsif order.free?
145
+ purchase_free!(order)
146
+ else
147
+ raise("Unexpected order amount: #{order.total}")
148
+ end
149
+
150
+ provider = (order.free? ? 'free' : order.payment_provider)
133
151
  payment = self.payment()
134
- card = payment["card"]
152
+ card = payment["card"] || payment[:card]
135
153
 
136
154
  if purchased
137
155
  order.assign_attributes(delayed_payment_purchase_result: "success")
@@ -152,6 +170,8 @@ module Effective
152
170
  ExceptionNotifier.notify_exception(e, data: { order_id: order.id }) if defined?(ExceptionNotifier)
153
171
 
154
172
  puts "Error purchasing #{order.id}: #{e.message}"
173
+
174
+ raise(e) if Rails.env.development? || Rails.env.test?
155
175
  end
156
176
  end
157
177
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '6.13.1'.freeze
2
+ VERSION = '6.13.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_orders
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.13.1
4
+ version: 6.13.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-10 00:00:00.000000000 Z
11
+ date: 2024-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails