solidus_inter 3.0.1 → 3.1.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb213ef73a6677b7b49dcc1912667b3f45540d76f8cb80fb2120a261f18dff6f
|
4
|
+
data.tar.gz: c3a0928c11a41c3169aaae2698c601b18ef86a136f6fa027766161caa466457d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f85bd84e27ab2652e0d494d42ff30ed318a544ced05b11c766e65734b4433d1b5c0873483fa901e4e40f83caee259fbf65428ca03ccf2c011fb169eaaca5da41
|
7
|
+
data.tar.gz: 9fad7d8f8ef8904d9e0d8ed214d32d4b58aa014ccdcb6a72db0404eeb1093240fe385d6115cd2bf4bcf1dddb59a716f2531e4e4447c089ab11ee4d8e829e754c
|
@@ -3,9 +3,25 @@ module SolidusInter
|
|
3
3
|
def initialize(options)
|
4
4
|
end
|
5
5
|
|
6
|
-
def void(transaction_id,
|
7
|
-
# Respondendo
|
8
|
-
|
6
|
+
def void(transaction_id, options = {})
|
7
|
+
# Respondendo com falha pois atualmente todo pedido concluido ja teve seu pagamento processado
|
8
|
+
# e nesse caso o credit é mais adequado (Ao cancelar um pedido pela interface, o 'void' é chamado, se ele retornar falha o Solidus chama o 'credit')
|
9
|
+
failure_response("Pagamento já processado")
|
10
|
+
end
|
11
|
+
|
12
|
+
def credit(money, transaction_id, options = {})
|
13
|
+
payment = Spree::Payment.find_by(response_code: transaction_id)
|
14
|
+
payment_source = payment.source
|
15
|
+
refund = payment_source.refund!
|
16
|
+
if refund.status == "DEVOLVIDO"
|
17
|
+
response = successful_response("Pagamento reembolsado (#{refund.status})", transaction_id)
|
18
|
+
payment.log_entries.create(parsed_payment_response_details_with_fallback: response)
|
19
|
+
successful_response("Reembolso realizado", refund.id)
|
20
|
+
else
|
21
|
+
response = successful_response("Pagamento não reembolsado - #{refund.status} - #{refund.try(:motivo)}", transaction_id)
|
22
|
+
payment.log_entries.create(parsed_payment_response_details_with_fallback: response)
|
23
|
+
successful_response("Erro ao reembolsar", refund.id)
|
24
|
+
end
|
9
25
|
end
|
10
26
|
|
11
27
|
private
|
@@ -19,10 +35,12 @@ module SolidusInter
|
|
19
35
|
)
|
20
36
|
end
|
21
37
|
|
22
|
-
def failure_response(message)
|
38
|
+
def failure_response(message, transaction_id = nil)
|
23
39
|
ActiveMerchant::Billing::Response.new(
|
24
40
|
false,
|
25
|
-
message
|
41
|
+
message,
|
42
|
+
{},
|
43
|
+
authorization: transaction_id
|
26
44
|
)
|
27
45
|
end
|
28
46
|
end
|