invoicing_payments_processing 1.1.1 → 1.1.7
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 +4 -4
- data/lib/bufferpaypalnotification.rb +32 -13
- data/lib/invoice.rb +1 -1
- data/lib/paypalsubscription.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2298e3b97644c58f77f1bcd072ef70c9d463cd8
|
4
|
+
data.tar.gz: f62b410eae86e45eba4ea590161646c8813519a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aaf6c4b4dd7757ae41975b855340c475538cc2dfa14bc33eaebbb2ae0cc8e1a8f7e48d5aa10a9b0bcb321084ad384954cb2f221db9805eb0889daa99118de1d1
|
7
|
+
data.tar.gz: 35a72098421599217e33bb54b80f35e474cf40819890b6557d786d8750497fd9c6e392cfb5c5dbed1c40a984f875ac9e79d319829ab69a68bdecb11344267c23
|
@@ -43,13 +43,19 @@ module BlackStack
|
|
43
43
|
def get_client()
|
44
44
|
# obtengo el cliente que machea con este perfil
|
45
45
|
c = nil
|
46
|
-
if
|
46
|
+
if c.nil?
|
47
|
+
if self.invoice.guid?
|
48
|
+
i = BlackStack::Invoice.where(:id=>self.invoice).first
|
49
|
+
c = i.client if !i.nil?
|
50
|
+
end
|
51
|
+
end
|
52
|
+
if c.nil?
|
47
53
|
cid = self.invoice.split(".").first.to_s
|
48
54
|
if cid.guid?
|
49
55
|
c = BlackStack::Client.where(:id=>cid).first
|
50
56
|
end
|
51
57
|
end
|
52
|
-
if
|
58
|
+
if c.nil?
|
53
59
|
c = BlackStack::Client.where(:paypal_email=>self.payer_email).first
|
54
60
|
if (c == nil)
|
55
61
|
u = User.where(:email=>self.payer_email).first
|
@@ -58,13 +64,13 @@ module BlackStack
|
|
58
64
|
end
|
59
65
|
end
|
60
66
|
end
|
61
|
-
if
|
67
|
+
if c.nil?
|
62
68
|
s = BlackStack::PayPalSubscription.where(:payer_email=>self.payer_email).first
|
63
69
|
if (s!=nil)
|
64
70
|
c = s.client
|
65
71
|
end
|
66
72
|
end
|
67
|
-
if
|
73
|
+
if c.nil?
|
68
74
|
# obtengo el cliente - poco elegante
|
69
75
|
q =
|
70
76
|
"SELECT TOP 1 i.id_client AS cid " +
|
@@ -230,8 +236,8 @@ module BlackStack
|
|
230
236
|
def self.process(params)
|
231
237
|
DB.transaction do
|
232
238
|
# verifico que no existe ya una notificacion
|
233
|
-
b = BlackStack::BufferPayPalNotification.where(:id=>params[
|
234
|
-
if
|
239
|
+
b = BlackStack::BufferPayPalNotification.where(:id=>params['id']).first
|
240
|
+
if b.nil?
|
235
241
|
# proceso la notificacion
|
236
242
|
b = BlackStack::BufferPayPalNotification.create(params)
|
237
243
|
# inserto la notificacion en la base de datos
|
@@ -246,7 +252,7 @@ module BlackStack
|
|
246
252
|
|
247
253
|
# varifico que el cliente exista
|
248
254
|
c = b.get_client
|
249
|
-
if
|
255
|
+
if c.nil?
|
250
256
|
raise "Client not found (payer_email=#{b.payer_email.to_s})."
|
251
257
|
end
|
252
258
|
|
@@ -260,12 +266,12 @@ module BlackStack
|
|
260
266
|
# reviso si la factura ya estaba creada.
|
261
267
|
# la primer factura se por adelantado cuando el cliente hace signup, y antes de que se suscriba a paypal, y se le pone un ID igual a primer GUID del campo invoice del IPN
|
262
268
|
i = BlackStack::Invoice.where(:id=>iid, :status=>BlackStack::Invoice::STATUS_UNPAID).order(:billing_period_from).first
|
263
|
-
if
|
269
|
+
if i.nil?
|
264
270
|
i = BlackStack::Invoice.where(:id=>iid, :status=>nil).order(:billing_period_from).first
|
265
271
|
end
|
266
272
|
|
267
273
|
# de la segunda factura en adelante, se generan con un ID diferente, pero se le guarda a subscr_id para identificar cuado llegue el pago de esa factura
|
268
|
-
if
|
274
|
+
if i.nil?
|
269
275
|
# busco una factura en estado UNPAID que este vinculada a esta suscripcion
|
270
276
|
q =
|
271
277
|
"SELECT TOP 1 i.id AS iid " +
|
@@ -331,10 +337,10 @@ module BlackStack
|
|
331
337
|
#b.txn_type == BlackStack::BufferPayPalNotification::TXN_TYPE_SUBSCRIPTION_SUSPEND || # estos IPN traen el campo subscr_id en blanco
|
332
338
|
#b.txn_type == BlackStack::BufferPayPalNotification::TXN_TYPE_SUBSCRIPTION_SUSPEND_DUE_MAX_FAILURES # estos IPN traen el campo subscr_id en blanco
|
333
339
|
)
|
334
|
-
s = BlackStack::PayPalSubscription.load(b)
|
335
|
-
if s
|
340
|
+
s = BlackStack::PayPalSubscription.load(b.to_hash)
|
341
|
+
if s.nil?
|
336
342
|
# mensaje de error
|
337
|
-
raise
|
343
|
+
raise "Subscription (#{b.subscr_id}) Not Found."
|
338
344
|
else
|
339
345
|
# registro la suscripcion en la base de datos
|
340
346
|
s.active = false
|
@@ -363,6 +369,19 @@ module BlackStack
|
|
363
369
|
raise 'Invoice already exists.'
|
364
370
|
end
|
365
371
|
|
372
|
+
# obtengo la ultima factura pagada, vinculada a un IPN con el mismo codigo invoice
|
373
|
+
row = DB[
|
374
|
+
"SELECT TOP 1 i.id " +
|
375
|
+
"FROM buffer_paypal_notification b " +
|
376
|
+
"JOIN invoice i ON ( b.id=i.id_buffer_paypal_notification AND i.status=#{BlackStack::Invoice::STATUS_PAID.to_s} ) " +
|
377
|
+
"WHERE b.invoice='#{b.invoice}' " +
|
378
|
+
"ORDER BY i.create_time DESC "
|
379
|
+
].first
|
380
|
+
if row.nil?
|
381
|
+
raise 'Previous Paid Invoice not found.'
|
382
|
+
end
|
383
|
+
k = BlackStack::Invoice.where(:id=>row[:id]).first
|
384
|
+
|
366
385
|
# creo la factura por el reembolso
|
367
386
|
i = BlackStack::Invoice.new()
|
368
387
|
i.id = guid()
|
@@ -378,7 +397,7 @@ module BlackStack
|
|
378
397
|
i.save()
|
379
398
|
|
380
399
|
# parseo el reeembolso - creo el registro contable
|
381
|
-
i.setup_refund(payment_gross,
|
400
|
+
i.setup_refund(payment_gross, k.id)
|
382
401
|
|
383
402
|
end
|
384
403
|
else
|
data/lib/invoice.rb
CHANGED
@@ -536,7 +536,7 @@ module BlackStack
|
|
536
536
|
matched_items = i.items.select { |o| o.amount.to_f == -payment_gross.to_f }
|
537
537
|
|
538
538
|
if total < -payment_gross
|
539
|
-
raise "The refund is higher than the invoice amount"
|
539
|
+
raise "The refund is higher than the invoice amount (invoice #{id_invoice}, #{total.to_s}, #{payment_gross.to_s})"
|
540
540
|
|
541
541
|
# Si el monto del reembolso es igual al total de la factura, se hace un reembolso total de todos los items. Y termina la funcion.
|
542
542
|
# Si el monto de la factura es distinto al moneto del reembolso, entonces se levanta una excepcion.
|
data/lib/paypalsubscription.rb
CHANGED
@@ -25,7 +25,7 @@ module BlackStack
|
|
25
25
|
s.last_name = params['last_name'].to_s
|
26
26
|
s.residence_country = params['residence_country'].to_s
|
27
27
|
s.mc_currency = params['mc_currency'].to_s
|
28
|
-
s.item_name = params['item_name'].to_s
|
28
|
+
#s.item_name = params['item_name'].to_s
|
29
29
|
s.amount1 = params['amount1'].to_s
|
30
30
|
s.business = params['business'].to_s
|
31
31
|
s.amount3 = params['amount3'].to_s
|
@@ -39,7 +39,7 @@ module BlackStack
|
|
39
39
|
s.payer_id = params['payer_id'].to_s
|
40
40
|
s.invoice = params['invoice'].to_s
|
41
41
|
s.reattempt = params['reattempt'].to_s
|
42
|
-
s.item_number = params['item_number'].to_s
|
42
|
+
#s.item_number = params['item_number'].to_s
|
43
43
|
s.subscr_date = params['subscr_date'].to_s
|
44
44
|
s.charset = params['charset'].to_s
|
45
45
|
s.notify_version = params['notify_version'].to_s
|
@@ -69,7 +69,7 @@ module BlackStack
|
|
69
69
|
ret['last_name'] = self.last_name
|
70
70
|
ret['residence_country'] = self.residence_country
|
71
71
|
ret['mc_currency'] = self.mc_currency
|
72
|
-
ret['item_name'] = self.item_name
|
72
|
+
#ret['item_name'] = self.item_name
|
73
73
|
ret['amount1'] = self.amount1
|
74
74
|
ret['business'] = self.business
|
75
75
|
ret['amount3'] = self.amount3
|
@@ -83,7 +83,7 @@ module BlackStack
|
|
83
83
|
ret['payer_id'] = self.payer_id
|
84
84
|
ret['invoice'] = self.invoice
|
85
85
|
ret['reattempt'] = self.reattempt
|
86
|
-
ret['item_number'] = self.item_number
|
86
|
+
#ret['item_number'] = self.item_number
|
87
87
|
ret['subscr_date'] = self.subscr_date
|
88
88
|
ret['charset'] = self.charset
|
89
89
|
ret['notify_version'] = self.notify_version
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: invoicing_payments_processing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leandro Daniel Sardi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: websocket
|