flowcommerce_spree 0.0.8 → 0.0.9
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f47f9a9debf77ea1ca7d10d8a2661a4abac350f3602b98a50686919476038187
|
4
|
+
data.tar.gz: '04964f886f5dab774f4e1631a5ab9c0bda612e35599ad4c639dc7dcee8d7396b'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc5929eff62c6c11b58eed26b580d0cc34c3c51e5a4a81869773a115e5210ac9808e740fb00112de84f5fcc6afc63db404bd97960398bf09d021d588f2624520
|
7
|
+
data.tar.gz: 9311543f7e2b18e55326f1826d7240b6315efed2ac7f81c94c60d4c8236f5d4e5381cbb5e7e956880723d76384cf89b23e8306ac8026c14af36ad16344b8bd56
|
@@ -21,7 +21,7 @@ module Spree
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def payment_profiles_supported?
|
24
|
-
|
24
|
+
false
|
25
25
|
end
|
26
26
|
|
27
27
|
def method_type
|
@@ -43,14 +43,18 @@ module Spree
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def refund(payment, amount, _options = {})
|
46
|
-
request_refund_store_result(payment.order, amount)
|
46
|
+
response = request_refund_store_result(payment.order, amount)
|
47
|
+
map_refund_to_payment(response, payment.order) if response.success?
|
48
|
+
response
|
47
49
|
rescue StandardError => e
|
48
50
|
ActiveMerchant::Billing::Response.new(false, e.to_s, {}, {})
|
49
51
|
end
|
50
52
|
|
51
53
|
def cancel(authorization)
|
52
54
|
original_payment = Spree::Payment.find_by(response_code: authorization)
|
53
|
-
request_refund_store_result(original_payment.order, original_payment.amount)
|
55
|
+
response = request_refund_store_result(original_payment.order, original_payment.amount)
|
56
|
+
map_refund_to_payment(response, original_payment.order) if response.success?
|
57
|
+
response
|
54
58
|
rescue StandardError => e
|
55
59
|
ActiveMerchant::Billing::Response.new(false, e.to_s, {}, {})
|
56
60
|
end
|
@@ -72,6 +76,12 @@ module Spree
|
|
72
76
|
create_flow_cc_profile!
|
73
77
|
end
|
74
78
|
|
79
|
+
def credit(payment, credit_amount)
|
80
|
+
request_refund_store_result(payment.order, credit_amount)
|
81
|
+
rescue StandardError => e
|
82
|
+
ActiveMerchant::Billing::Response.new(false, e.to_s, {}, {})
|
83
|
+
end
|
84
|
+
|
75
85
|
private
|
76
86
|
|
77
87
|
def request_refund_store_result(order, amount)
|
@@ -82,8 +92,10 @@ module Spree
|
|
82
92
|
response_status = response.status.value
|
83
93
|
if response_status == REFUND_SUCCESS
|
84
94
|
add_refund_to_order(response, order)
|
85
|
-
|
86
|
-
|
95
|
+
ActiveMerchant::Billing::Response.new(true,
|
96
|
+
REFUND_SUCCESS,
|
97
|
+
response.to_hash,
|
98
|
+
authorization: response.authorization.id)
|
87
99
|
else
|
88
100
|
msg = "Partial refund fail. Details: #{response_status}"
|
89
101
|
ActiveMerchant::Billing::Response.new(false, msg, {}, {})
|
@@ -100,18 +112,17 @@ module Spree
|
|
100
112
|
end
|
101
113
|
|
102
114
|
def map_refund_to_payment(response, order)
|
103
|
-
original_payment = Spree::Payment.find_by(response_code: response.authorization
|
115
|
+
original_payment = Spree::Payment.find_by(response_code: response.authorization)
|
104
116
|
payment = order.payments.create!(state: 'completed',
|
105
|
-
response_code: response.authorization
|
117
|
+
response_code: response.authorization,
|
106
118
|
payment_method_id: original_payment&.payment_method_id,
|
107
|
-
amount: - response.amount,
|
108
|
-
|
109
|
-
source_type: original_payment&.source_type)
|
119
|
+
amount: - response.params['amount'].to_f,
|
120
|
+
source: original_payment)
|
110
121
|
|
111
122
|
# For now this additional update is overwriting the generated identifier with flow.io payment identifier.
|
112
123
|
# TODO: Check and possibly refactor in Spree 3.0, where the `before_create :set_unique_identifier`
|
113
124
|
# has been removed.
|
114
|
-
payment.update_column(:identifier, response.id)
|
125
|
+
payment.update_column(:identifier, response.params['id'])
|
115
126
|
end
|
116
127
|
|
117
128
|
# hard inject Flow as payment method unless defined
|
@@ -124,7 +124,7 @@ module FlowcommerceSpree
|
|
124
124
|
{ center: FLOW_CENTER,
|
125
125
|
number: variant.sku,
|
126
126
|
quantity: line_item.quantity,
|
127
|
-
price: { amount: price_root['amount'] || variant.
|
127
|
+
price: { amount: price_root['amount'] || variant.price,
|
128
128
|
currency: price_root['currency'] || variant.cost_currency } }
|
129
129
|
end
|
130
130
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flowcommerce_spree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aurel Branzeanu
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-06-
|
12
|
+
date: 2021-06-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: active_model_serializers
|