flowcommerce_spree 0.0.15 → 0.0.16

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: 8ed3330958e03459888c682dd28c10106da11922d09009f661d3e8d1a29d32a4
4
- data.tar.gz: ae942f91846355379eac2fb8a54b8ca6156c749b20732137250c35e3a2cc605f
3
+ metadata.gz: 5c9cb2032b50a1392231cb88c7ef6549e623ac604bcdcfecc8d8224e9f8558c4
4
+ data.tar.gz: 1564b9412b0be89b38ff6a7feb86397311ebe400614618c13c495c58c90059f4
5
5
  SHA512:
6
- metadata.gz: cc69d6f4e090cf11bdd80f95f7534451ae060b862f896ac0fbeff276f51b98a672cb7132245408fe97393c8cc118cba8917ee570f530d20534d0a375697e423e
7
- data.tar.gz: 73b06be7f5ef0d6db3532e992f7f3daba0eb71e9a65e3d72b25ba5a4044630213781979cc74e768689f1f729180f46064e41d581ff4ab50f3957100319ed6e32
6
+ metadata.gz: 88f39ac40b274fbcbf29de37a461b14b7aca12d0496d20c89ba27eeee63d3013c776631737cc1f5b154ffe2f67c812aed6aac850d49584853b4063ef81c85acb
7
+ data.tar.gz: f085428b7616287640093de5cb1635dd6a7e8d63b77b64991f88062fa8c2ef271dc0763a7bc21b5331b2348a822485f496716b4ce7f5db7e6147584f56c2735c
@@ -61,13 +61,17 @@ module Spree
61
61
  ActiveMerchant::Billing::Response.new(false, e.to_s, {}, {})
62
62
  end
63
63
 
64
- def void(authorization_id, _source, options = {})
64
+ def void(authorization_id, options = {})
65
65
  amount = (options[:subtotal] + options[:shipping]) * 0.01
66
- reversal_form = Io::Flow::V0::Models::ReversalForm.new(key: options[:order_id],
67
- authorization_id: authorization_id,
68
- amount: amount,
69
- currency: options[:currency])
70
- FlowcommerceSpree.client.reversals.post(FlowcommerceSpree::ORGANIZATION, reversal_form)
66
+ order = Spree::Order.find_by(number: options[:order_id].split('-').first)
67
+ refund_form = Io::Flow::V0::Models::RefundForm.new(order_number: order.number,
68
+ amount: amount,
69
+ currency: options[:currency],
70
+ authorization_id: authorization_id)
71
+ response = FlowcommerceSpree.client.refunds.post(FlowcommerceSpree::ORGANIZATION, refund_form)
72
+ validate_flow_refund_response(response, order)
73
+
74
+ ActiveMerchant::Billing::Response.new(true, 'flow-payment-void', {}, {})
71
75
  end
72
76
 
73
77
  def create_profile(payment)
@@ -91,6 +95,11 @@ module Spree
91
95
  amount: amount,
92
96
  currency: order.currency)
93
97
  response = FlowcommerceSpree.client.refunds.post(FlowcommerceSpree::ORGANIZATION, refund_form)
98
+ result = validate_flow_refund_response(response, order)
99
+ result
100
+ end
101
+
102
+ def validate_flow_refund_response(response, order)
94
103
  response_status = response.status.value
95
104
  if REFUND_VALID_STATES.include? response_status
96
105
  add_refund_to_order(response, order)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FlowcommerceSpree
4
- VERSION = '0.0.15'
4
+ VERSION = '0.0.16'
5
5
  end
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.15
4
+ version: 0.0.16
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-09-03 00:00:00.000000000 Z
12
+ date: 2021-09-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: active_model_serializers
@@ -285,7 +285,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
285
285
  - !ruby/object:Gem::Version
286
286
  version: '0'
287
287
  requirements: []
288
- rubygems_version: 3.0.8
288
+ rubygems_version: 3.0.3
289
289
  signing_key:
290
290
  specification_version: 4
291
291
  summary: Integration of Spree with Flow API