solidus_inter 3.1.1 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7945a1c33983121e571fa69314994c382d32a2c854adbb4887151f02a8ce0dbf
4
- data.tar.gz: ec227a1f22c25815503283969a722a61d869f580d085c556d47758070cf1d803
3
+ metadata.gz: 737e834e20ce74075aeda1880bb594784747b70fcbea3d4f321336090fd203f1
4
+ data.tar.gz: 171834eeffdf8f87daa2c099bb3f762867a07e83888407f366c423caa33f4bda
5
5
  SHA512:
6
- metadata.gz: a0e71551936d9f397d94ed460356d61f44fd38c8edd5a8b67576ef0f5babd21df0eee27c8cd5fd5453df6a12c4a25ba7a691cdc3f56ccee37233777935e3d9c8
7
- data.tar.gz: 643b8f60728ff8c1811fb552e72c93ce3f99b7c158914859af8fdf02bf5d7d9f112264343f306ec66a25e9521537abd211f22a198d12e278376e747ae170a872
6
+ metadata.gz: d20b24744b083c2203c8c29ad4bae102ab8fd86d2e753cfe2672018cc70a7eb3f97192f6fc793f35a04c57a900de6868d3b30bc49f7e60f7f74e218c55814554
7
+ data.tar.gz: f90c181d39d26600bb088f493f50144d35647fc3badf1d127bdd57df7025e6857e2cce73911ad183dcd662cff698b1813f15dc23558b4b4b8836802285ee1285
@@ -12,7 +12,7 @@ module SolidusInter
12
12
  def credit(money, transaction_id, options = {})
13
13
  payment = Spree::Payment.find_by(response_code: transaction_id)
14
14
  payment_source = payment.source
15
- refund = payment_source.refund!
15
+ refund = payment_source.refund!(amount: converted_money(money))
16
16
  if refund.status == "DEVOLVIDO"
17
17
  response = successful_response("Pagamento reembolsado (#{refund.status})", transaction_id)
18
18
  payment.log_entries.create(parsed_payment_response_details_with_fallback: response)
@@ -26,6 +26,10 @@ module SolidusInter
26
26
 
27
27
  private
28
28
 
29
+ def converted_money(money)
30
+ money / 100.0
31
+ end
32
+
29
33
  def successful_response(message, transaction_id)
30
34
  ActiveMerchant::Billing::Response.new(
31
35
  true,
@@ -96,8 +96,9 @@ module SolidusInter
96
96
  payment.checkout?
97
97
  end
98
98
 
99
- def refund_payment(payment)
100
- inter_client.refund_payment(end_to_end_id: payment.source.e2e_id, amount: payment.source.paid_amount)
99
+ def refund_payment(payment, amount = nil)
100
+ amount = payment.source.paid_amount if amount.nil?
101
+ inter_client.refund_payment(end_to_end_id: payment.source.e2e_id, amount: amount)
101
102
  end
102
103
 
103
104
  private
@@ -20,8 +20,17 @@ module SolidusInter
20
20
  payment_method.invalidate_payment(payments.sole)
21
21
  end
22
22
 
23
- def refund!
24
- payment_method.refund_payment(payments.sole)
23
+ def refund!(amount: nil)
24
+ payment_method.refund_payment(payments.sole, amount)
25
+ end
26
+
27
+ # Definir para sempre false pois atualmente não implementados o void do Solidus
28
+ def can_void?(payment)
29
+ false
30
+ end
31
+
32
+ def can_credit?(payment)
33
+ payment.completed? && payment.credit_allowed > 0
25
34
  end
26
35
  end
27
36
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusInter
4
- VERSION = "3.1.1"
4
+ VERSION = "3.2.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_inter
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ulysses