banco-alimentar / alimentestaideia.pt

Site doações alimente esta ideia
http://alimentestaideia.pt
Other
10 stars 0 forks source link

Donation.PaymentStatus is not updated if multiple payment tries happens #584

Open guerrerotook opened 2 years ago

guerrerotook commented 2 years ago

If the user make multiples attempts of paying with multiple payment methods, the filed Donation.PaymentStatus is not updated.

guerrerotook commented 2 years ago

Tiago so far, I found that for whaever reason when the easypay notification is being sent and trying to update the donation what happen is that donation can't be found and that is why is not being updated. So, I'm adding more telemetry here to see if we can understand why. For now, 'm going to do a PR that will land eventually in master and I'm going to let this issue open.

tiagonmas commented 2 years ago

To check this

SELECT        dbo.Payments.DonationId, dbo.Payments.Id AS PaymentId, dbo.Donations.Id AS DonID, dbo.Donations.PaymentStatus, dbo.Donations.ConfirmedPaymentId, dbo.Donations.DonationDate, dbo.Donations.DonationAmount, 
                         dbo.Payments.Created, dbo.Payments.Discriminator, dbo.Payments.Completed
FROM            dbo.Payments RIGHT OUTER JOIN
                         dbo.Donations ON dbo.Payments.DonationId = dbo.Donations.Id
WHERE        (dbo.Donations.PaymentStatus = 4) AND (NOT (dbo.Donations.ConfirmedPaymentId IS NULL))
Order by dbo.Donations.Id  desc
tiagonmas commented 2 years ago

While looking at the query above, I noticed that a specific donation has 2 successful payments with 2 different amounts. Checked easypay backoffice, and confirmed that one payment was not completed but 2 were. How can we have 2 payments for the same donation, especially with different amounts ? @guerrerotook

SELECT        TOP (100) PERCENT dbo.Donations.PublicId, dbo.Donations.DonationDate, dbo.Donations.DonationAmount, dbo.Donations.PaymentStatus, dbo.Donations.ConfirmedPaymentId, dbo.Payments.Id AS [Payment.id], 
                         dbo.Payments.Created, dbo.Payments.Status, dbo.Payments.Discriminator, dbo.Payments.TransactionKey, dbo.Payments.EasyPayPaymentId, dbo.Payments.Requested, dbo.Payments.Paid, dbo.Payments.Message, 
                         dbo.Payments.Completed, dbo.Payments.DonationId, dbo.AspNetUsers.FullName, dbo.AspNetUsers.Email, dbo.AspNetUsers.PhoneNumber
FROM            dbo.AspNetUsers INNER JOIN
                         dbo.Donations ON dbo.AspNetUsers.Id = dbo.Donations.UserId LEFT OUTER JOIN
                         dbo.Payments ON dbo.Donations.Id = dbo.Payments.DonationId
WHERE        (dbo.Payments.DonationId = 9058)
ORDER BY dbo.Donations.Id DESC
image
tiagonmas commented 2 years ago

There seem to be 5 cases (donation ids 9058, 8615, 5346, 7727, 6693) where we had more than one completed payment for a single transaction:

SELECT        TOP (100) dbo.Donations.Id, COUNT(dbo.Donations.ConfirmedPaymentId) AS TotalConfirmedPayment, COUNT(Completed) TotalCompleted
FROM            dbo.Donations LEFT OUTER JOIN
                         dbo.Payments ON dbo.Donations.Id = dbo.Payments.DonationId
GROUP BY dbo.Donations.Id
HAVING COUNT(Completed) > 1
ORDER BY TotalConfirmedPayment DESC
image
tiagonmas commented 2 years ago

The details of the donations with multiple completed payments:

SELECT        TOP (100) PERCENT dbo.Donations.Id,dbo.Donations.DonationDate, dbo.Donations.DonationAmount, dbo.Donations.PaymentStatus, dbo.Donations.ConfirmedPaymentId, dbo.Payments.Id AS [Payment.id], 
                         dbo.Payments.Created, dbo.Payments.Status, dbo.Payments.Discriminator, dbo.Payments.TransactionKey,dbo.Payments.Paid, 
                         dbo.Payments.Completed, dbo.Payments.DonationId, dbo.AspNetUsers.PhoneNumber
FROM            dbo.AspNetUsers INNER JOIN
                         dbo.Donations ON dbo.AspNetUsers.Id = dbo.Donations.UserId LEFT OUTER JOIN
                         dbo.Payments ON dbo.Donations.Id = dbo.Payments.DonationId
WHERE        (dbo.Payments.DonationId in (9058, 8615, 5346, 7727, 6693))
ORDER BY dbo.Donations.Id DESC
image
tiagonmas commented 2 years ago

commit b255bdd254feda4de55b9af9f746b2d604e1371a solves a part of this issue

tiagonmas commented 2 years ago

Updated donations that had PaymentStatus=4 but had a a Complete payment

UPDATE dbo.Donations 
   SET dbo.Donations.PaymentStatus = 1
     WHERE dbo.Donations.Id IN 
        (
            SELECT        distinct(dbo.Payments.DonationId)
                FROM            dbo.Payments RIGHT OUTER JOIN dbo.Donations ON dbo.Payments.DonationId = dbo.Donations.Id
                WHERE (dbo.Donations.PaymentStatus = 4) AND (NOT (dbo.Donations.ConfirmedPaymentId IS NULL))
        )

For reference, here are the donations that were incorrectly set with PaymentStatus =4

DonationId  PaymentId   DonID   PaymentStatus   ConfirmedPaymentId  DonationDate    DonationAmount  Created Discriminator   Completed
9149    9694    9149    4   9695    2021-12-21 22:52:41.5207746 9.00    2021-12-21 22:53:29.6042246 MBWayPayment    NULL
9149    9695    9149    4   9695    2021-12-21 22:52:41.5207746 9.00    2021-12-21 22:57:02.6117744 MultiBankPayment    2021-12-21 22:59:04.7659780
9058    9609    9058    4   9610    2021-12-17 09:30:22.0336160 2.20    2021-12-17 09:23:48.8950225 MBWayPayment    2021-12-17 09:24:55.5242196
9058    9610    9058    4   9610    2021-12-17 09:30:22.0336160 2.20    2021-12-17 09:30:41.1417120 MBWayPayment    2021-12-17 09:31:20.4669975
9058    9611    9058    4   9610    2021-12-17 09:30:22.0336160 2.20    2021-12-17 09:30:45.0597012 MBWayPayment    NULL
9043    9594    9043    4   9595    2021-12-16 14:23:17.5847056 5.00    2021-12-16 14:23:37.3638915 MBWayPayment    NULL
9043    9595    9043    4   9595    2021-12-16 14:23:17.5847056 5.00    2021-12-16 14:27:44.3827069 MBWayPayment    2021-12-16 14:28:03.2685459
9027    9575    9027    4   9576    2021-12-16 09:39:41.2293433 10.00   2021-12-16 09:40:13.7691275 MBWayPayment    NULL
9027    9576    9027    4   9576    2021-12-16 09:39:41.2293433 10.00   2021-12-16 09:40:13.7783359 MBWayPayment    2021-12-16 09:40:33.4182950
9027    9577    9027    4   9576    2021-12-16 09:39:41.2293433 10.00   2021-12-16 09:40:13.8174563 MBWayPayment    NULL
8953    9502    8953    4   9502    2021-12-14 11:22:33.6500054 2.90    2021-12-14 11:22:53.1465664 MBWayPayment    2021-12-14 11:23:26.0650784
8953    9503    8953    4   9502    2021-12-14 11:22:33.6500054 2.90    2021-12-14 11:22:53.1474238 MBWayPayment    NULL
8790    9319    8790    4   9320    2021-12-09 14:44:20.4967646 10.30   2021-12-09 14:39:28.6039088 MBWayPayment    NULL
8790    9320    8790    4   9320    2021-12-09 14:44:20.4967646 10.30   2021-12-09 14:45:00.0607187 MBWayPayment    2021-12-09 14:46:04.1531251
8659    9170    8659    4   9172    2021-12-08 01:10:42.8938536 50.00   2021-12-08 01:11:17.6942238 MBWayPayment    NULL
8659    9171    8659    4   9172    2021-12-08 01:10:42.8938536 50.00   2021-12-08 01:11:53.5581774 MBWayPayment    NULL
8659    9172    8659    4   9172    2021-12-08 01:10:42.8938536 50.00   2021-12-08 01:12:13.1273649 MultiBankPayment    2021-12-08 01:15:03.6189859
8654    9160    8654    4   9161    2021-12-07 22:45:59.7550417 20.10   2021-12-07 22:46:49.6083934 MBWayPayment    NULL
8654    9161    8654    4   9161    2021-12-07 22:45:59.7550417 20.10   2021-12-07 22:46:49.8387850 MultiBankPayment    2021-12-07 22:50:04.2738776
8654    9162    8654    4   9161    2021-12-07 22:45:59.7550417 20.10   2021-12-07 22:46:49.8974447 MBWayPayment    NULL
8610    9103    8610    4   9104    2021-12-07 16:38:49.2433713 16.60   2021-12-07 16:39:09.3676246 MBWayPayment    NULL
8610    9104    8610    4   9104    2021-12-07 16:38:49.2433713 16.60   2021-12-07 16:39:10.6488598 MBWayPayment    2021-12-07 16:42:34.8073763
8501    8970    8501    4   8972    2021-12-07 00:55:43.6608420 35.00   2021-12-07 00:56:16.6960000 MBWayPayment    NULL
8501    8971    8501    4   8972    2021-12-07 00:55:43.6608420 35.00   2021-12-07 00:56:31.5061036 MBWayPayment    NULL
8501    8972    8501    4   8972    2021-12-07 00:55:43.6608420 35.00   2021-12-07 00:56:31.8286504 MBWayPayment    2021-12-07 00:57:27.0207869
8434    8903    8434    4   8904    2021-12-06 21:28:10.4577524 14.50   2021-12-06 21:28:33.6769745 MBWayPayment    NULL
8434    8904    8434    4   8904    2021-12-06 21:28:10.4577524 14.50   2021-12-06 21:29:39.9380597 MBWayPayment    2021-12-06 21:30:06.9745920
8426    8891    8426    4   8892    2021-12-06 20:46:11.2757630 100.00  2021-12-06 20:46:44.0033519 MBWayPayment    NULL
8426    8892    8426    4   8892    2021-12-06 20:46:11.2757630 100.00  2021-12-06 20:46:50.1336081 MBWayPayment    2021-12-06 20:47:15.0314356
8426    8893    8426    4   8892    2021-12-06 20:46:11.2757630 100.00  2021-12-06 20:46:50.1732655 MBWayPayment    NULL
8408    8873    8408    4   8875    2021-12-06 19:48:21.5939474 20.80   2021-12-06 19:41:40.8243044 MBWayPayment    NULL
8408    8875    8408    4   8875    2021-12-06 19:48:21.5939474 20.80   2021-12-06 19:48:28.3580642 MBWayPayment    2021-12-06 19:49:25.7185861
8181    8624    8181    4   8624    2021-12-06 14:55:43.1094731 109.20  2021-12-06 14:56:26.4446281 MBWayPayment    2021-12-06 14:57:15.4057400
8181    8625    8181    4   8624    2021-12-06 14:55:43.1094731 109.20  2021-12-06 14:56:26.5019437 MBWayPayment    NULL
8181    8626    8181    4   8624    2021-12-06 14:55:43.1094731 109.20  2021-12-06 14:56:26.5708639 MBWayPayment    NULL
8135    8581    8135    4   8583    2021-12-06 14:22:15.9820068 13.70   2021-12-06 14:23:45.8224627 MBWayPayment    NULL
8135    8582    8135    4   8583    2021-12-06 14:22:15.9820068 13.70   2021-12-06 14:23:54.2873660 MBWayPayment    NULL
8135    8583    8135    4   8583    2021-12-06 14:22:15.9820068 13.70   2021-12-06 14:23:54.6321359 MBWayPayment    2021-12-06 14:26:01.5113796
8111    8550    8111    4   8551    2021-12-06 13:59:39.0756975 5.20    2021-12-06 13:59:59.5688795 MBWayPayment    NULL
8111    8551    8111    4   8551    2021-12-06 13:59:39.0756975 5.20    2021-12-06 14:00:00.0706627 MBWayPayment    2021-12-06 14:00:29.3891455
8060    8495    8060    4   8497    2021-12-06 13:12:13.0219319 2.60    2021-12-06 13:12:28.1112897 MBWayPayment    NULL
8060    8496    8060    4   8497    2021-12-06 13:12:13.0219319 2.60    2021-12-06 13:12:28.2295051 MBWayPayment    NULL
8060    8497    8060    4   8497    2021-12-06 13:12:13.0219319 2.60    2021-12-06 13:12:29.4315798 MBWayPayment    2021-12-06 13:13:09.2346808
7966    8401    7966    4   8401    2021-12-05 22:35:56.4188350 4.80    2021-12-05 22:36:21.2149307 MBWayPayment    2021-12-05 22:36:41.3308969
7966    8402    7966    4   8401    2021-12-05 22:35:56.4188350 4.80    2021-12-05 22:36:21.4599079 MBWayPayment    NULL
7943    8375    7943    4   8376    2021-12-05 21:30:53.7968776 26.40   2021-12-05 21:31:23.7805823 MBWayPayment    NULL
7943    8376    7943    4   8376    2021-12-05 21:30:53.7968776 26.40   2021-12-05 21:31:23.7935835 MBWayPayment    2021-12-05 21:32:07.7572727
7901    8332    7901    4   8333    2021-12-05 18:40:10.9599770 9.90    2021-12-05 18:43:52.7855629 MBWayPayment    NULL
7901    8333    7901    4   8333    2021-12-05 18:40:10.9599770 9.90    2021-12-05 18:43:52.9125957 MBWayPayment    2021-12-05 18:44:26.8537764
7716    8120    7716    4   8120    2021-12-04 14:22:20.8944160 25.10   2021-12-04 14:22:53.8762844 MBWayPayment    2021-12-04 14:23:51.0275612
7716    8121    7716    4   8120    2021-12-04 14:22:20.8944160 25.10   2021-12-04 14:22:57.5010915 MBWayPayment    NULL
7707    8110    7707    4   8111    2021-12-04 12:10:03.0327151 35.00   2021-12-04 12:10:43.5350502 MBWayPayment    NULL
7707    8111    7707    4   8111    2021-12-04 12:10:03.0327151 35.00   2021-12-04 12:10:50.6466578 MBWayPayment    2021-12-04 12:11:21.9631163
7537    7919    7537    4   7919    2021-12-02 21:49:27.1652943 5.50    2021-12-02 21:49:41.2453651 MBWayPayment    2021-12-02 21:50:06.1377604
7537    7920    7537    4   7919    2021-12-02 21:49:27.1652943 5.50    2021-12-02 21:49:41.2446035 MBWayPayment    NULL
7256    7618    7256    4   7618    2021-12-01 15:05:47.9046953 9.10    2021-12-01 15:06:10.1867925 MBWayPayment    2021-12-01 15:06:22.3389533
7256    7619    7256    4   7618    2021-12-01 15:05:47.9046953 9.10    2021-12-01 15:06:11.4289493 MBWayPayment    NULL
7006    7353    7006    4   7354    2021-11-30 11:48:58.7038421 48.10   2021-11-30 11:49:13.4176743 MBWayPayment    NULL
7006    7354    7006    4   7354    2021-11-30 11:48:58.7038421 48.10   2021-11-30 11:49:13.4232587 MBWayPayment    2021-11-30 11:49:46.1994205
6823    7152    6823    4   7153    2021-11-29 18:04:48.6894555 99.90   2021-11-29 18:05:09.8168526 MBWayPayment    NULL
6823    7153    6823    4   7153    2021-11-29 18:04:48.6894555 99.90   2021-11-29 18:05:10.5432007 MBWayPayment    2021-11-29 18:05:26.8290630
6629    6951    6629    4   6957    2021-11-29 11:47:35.5056715 51.00   2021-11-29 11:48:16.9001353 MBWayPayment    NULL
6629    6957    6629    4   6957    2021-11-29 11:47:35.5056715 51.00   2021-11-29 11:54:26.5130124 MultiBankPayment    2021-11-29 11:57:05.1993324
6444    6753    6444    4   6754    2021-11-28 22:33:18.9390506 22.00   2021-11-28 22:33:42.8199152 MBWayPayment    NULL
6444    6754    6444    4   6754    2021-11-28 22:33:18.9390506 22.00   2021-11-28 22:34:04.6667554 MBWayPayment    2021-11-28 22:35:17.0698564
6444    6756    6444    4   6754    2021-11-28 22:33:18.9390506 22.00   2021-11-28 22:34:57.9409276 MBWayPayment    NULL
6381    6687    6381    4   6687    2021-11-28 20:58:57.6977671 7.00    2021-11-28 20:59:07.1440572 MBWayPayment    2021-11-28 20:59:52.8481667
6381    6688    6381    4   6687    2021-11-28 20:58:57.6977671 7.00    2021-11-28 20:59:09.3626393 MBWayPayment    NULL
6381    6689    6381    4   6687    2021-11-28 20:58:57.6977671 7.00    2021-11-28 20:59:25.1118102 MBWayPayment    NULL
6297    6604    6297    4   6605    2021-11-28 19:50:51.0202064 9.90    2021-11-28 19:51:05.8238805 MBWayPayment    NULL
6297    6605    6297    4   6605    2021-11-28 19:50:51.0202064 9.90    2021-11-28 19:51:06.9143115 MBWayPayment    2021-11-28 19:51:23.5598635
6164    6463    6164    4   6465    2021-11-28 15:37:08.4644433 49.30   2021-11-28 15:38:08.2539687 MBWayPayment    NULL
6164    6465    6164    4   6465    2021-11-28 15:37:08.4644433 49.30   2021-11-28 15:41:49.4896395 MultiBankPayment    2021-11-28 15:48:04.1746447
5993    6276    5993    4   6279    2021-11-28 10:39:35.6391028 20.00   2021-11-28 10:41:10.0826802 MBWayPayment    NULL
5993    6279    5993    4   6279    2021-11-28 10:39:35.6391028 20.00   2021-11-28 10:42:28.5035758 MultiBankPayment    2021-11-28 10:46:03.0713441
5906    6183    5906    4   6184    2021-11-27 23:10:10.7235639 20.10   2021-11-27 23:10:21.7851479 MBWayPayment    NULL
5906    6184    5906    4   6184    2021-11-27 23:10:10.7235639 20.10   2021-11-27 23:10:23.0600496 MBWayPayment    2021-11-27 23:10:42.0024865
5852    6127    5852    4   6137    2021-11-27 21:09:54.8670651 27.20   2021-11-27 21:06:41.2078913 MBWayPayment    NULL
5852    6137    5852    4   6137    2021-11-27 21:09:54.8670651 27.20   2021-11-27 21:10:12.8230089 MultiBankPayment    2021-11-27 21:13:03.4499241
5705    5972    5705    4   5973    2021-11-27 16:57:53.3700503 49.90   2021-11-27 16:58:33.9365965 MBWayPayment    NULL
5705    5973    5705    4   5973    2021-11-27 16:57:53.3700503 49.90   2021-11-27 16:59:25.2655520 MultiBankPayment    2021-11-27 17:02:03.5740403
5541    5795    5541    4   5795    2021-11-27 11:36:34.0162140 7.00    2021-11-27 11:36:52.4710348 MBWayPayment    2021-11-27 11:37:02.4831412
5541    5796    5541    4   5795    2021-11-27 11:36:34.0162140 7.00    2021-11-27 11:36:53.1718079 MBWayPayment    NULL
5420    5667    5420    4   5670    2021-11-26 22:41:27.6300356 25.10   2021-11-26 22:42:36.0376985 MBWayPayment    NULL
5420    5670    5420    4   5670    2021-11-26 22:41:27.6300356 25.10   2021-11-26 22:50:09.3581231 MultiBankPayment    2021-11-26 22:55:04.8806949
5094    5321    5094    4   5322    2021-11-26 14:08:10.5864342 9.60    2021-11-26 14:08:33.5133344 MBWayPayment    NULL
5094    5322    5094    4   5322    2021-11-26 14:08:10.5864342 9.60    2021-11-26 14:10:20.6121988 MBWayPayment    2021-11-26 14:10:37.5980298
5011    5239    5011    4   5240    2021-11-26 12:27:44.7254843 20.10   2021-11-26 12:27:58.9048890 MBWayPayment    NULL
5011    5240    5011    4   5240    2021-11-26 12:27:44.7254843 20.10   2021-11-26 12:28:00.1340138 MBWayPayment    2021-11-26 12:28:15.3283369
4859    5084    4859    4   5085    2021-11-26 08:30:28.6915513 18.10   2021-11-26 08:30:45.9488119 MBWayPayment    NULL
4859    5085    4859    4   5085    2021-11-26 08:30:28.6915513 18.10   2021-11-26 08:32:14.7429867 MultiBankPayment    2021-11-26 08:35:03.0302932
4847    5071    4847    4   5072    2021-11-26 00:49:37.0774573 7.00    2021-11-26 00:49:59.0242922 MBWayPayment    NULL
4847    5072    4847    4   5072    2021-11-26 00:49:37.0774573 7.00    2021-11-26 00:49:59.6515251 MBWayPayment    2021-11-26 00:50:16.1567699
4635    4850    4635    4   4853    2021-11-25 14:21:46.0561606 11.50   2021-11-25 14:22:06.3817320 MBWayPayment    NULL
4635    4853    4635    4   4853    2021-11-25 14:21:46.0561606 11.50   2021-11-25 14:27:18.8998351 MultiBankPayment    2021-11-25 14:32:03.7580012
4630    4843    4630    4   4845    2021-11-25 14:14:54.4200035 20.00   2021-11-25 14:13:02.8520600 MBWayPayment    NULL
4630    4845    4630    4   4845    2021-11-25 14:14:54.4200035 20.00   2021-11-25 14:14:59.6196157 MultiBankPayment    2021-11-25 14:18:04.8728127
4375    4588    4375    4   4589    2021-11-20 14:32:15.1562801 20.05   2021-11-20 14:26:56.8802846 MBWayPayment    NULL
4375    4589    4375    4   4589    2021-11-20 14:32:15.1562801 20.05   2021-11-20 14:33:56.4685263 MultiBankPayment    2021-11-20 14:39:03.9102058
4302    4515    4302    4   4515    2021-11-13 01:50:16.8090113 7.35    2021-11-13 01:50:28.8319363 MBWayPayment    2021-11-13 01:50:43.2783685
4302    4516    4302    4   4515    2021-11-13 01:50:16.8090113 7.35    2021-11-13 01:50:29.4179103 MBWayPayment    NULL
4203    4414    4203    4   4415    2021-10-25 12:55:40.2325003 0.70    2021-10-25 12:55:45.9733280 MBWayPayment    NULL
4203    4415    4203    4   4415    2021-10-25 12:55:40.2325003 0.70    2021-10-25 12:59:00.3106577 MBWayPayment    2021-10-25 12:59:14.9942789
4179    4391    4179    4   4392    2021-10-18 09:28:43.4500300 50.10   2021-10-18 09:29:30.4623248 MBWayPayment    NULL
4179    4392    4179    4   4392    2021-10-18 09:28:43.4500300 50.10   2021-10-18 09:30:10.9472640 MultiBankPayment    2021-10-18 09:35:03.6719994
4162    4377    4162    4   4378    2021-10-10 10:54:44.1131636 9.96    2021-10-10 10:56:17.7651512 MBWayPayment    NULL
4162    4378    4162    4   4378    2021-10-10 10:54:44.1131636 9.96    2021-10-10 10:58:27.3304909 MBWayPayment    2021-10-10 10:58:45.8238268
2442    2607    2442    4   2608    2021-06-04 13:10:07.9473377 10.50   2021-06-04 13:10:52.8116813 MBWayPayment    NULL
2442    2608    2442    4   2608    2021-06-04 13:10:07.9473377 10.50   2021-06-04 13:10:53.2852994 MBWayPayment    NULL
2442    2609    2442    4   2608    2021-06-04 13:10:07.9473377 10.50   2021-06-04 13:10:53.6736631 MBWayPayment    NULL
2442    2610    2442    4   2608    2021-06-04 13:10:07.9473377 10.50   2021-06-04 13:10:58.4882284 MBWayPayment    NULL
tiagonmas commented 1 year ago

It seems this issue is still happening. In this campaign (past week), we have 3 donations that have more than one confirmed payment and completed:

SELECT        TOP (100) dbo.Donations.Id, COUNT(dbo.Donations.ConfirmedPaymentId) AS TotalConfirmedPayment, Max(DonationDate),COUNT(Completed) TotalCompleted
FROM            dbo.Donations LEFT OUTER JOIN
                         dbo.Payments ON dbo.Donations.Id = dbo.Payments.DonationId
GROUP BY dbo.Donations.Id
HAVING COUNT(Completed) > 1
ORDER BY Max(DonationDate) DESC

The Payments below, refer more than one sucessful payment for the same Donation

select * from [dbo].[Payments] where DonationId=16086
select * from [dbo].[Payments] where DonationId=16269
select * from [dbo].[Payments] where DonationId=18370
tiagonmas commented 1 year ago

This is still happening. Here are some transactions from current campaign that have more than one payment select * from [dbo].[Payments] where DonationId in (24050,23731,21713)

tiagonmas commented 1 year ago

@guerrerotook can you take a look at this when you have time ?

tiagonmas commented 9 months ago

Another way to check the records impacted by this:

SELECT (Select count(id) from Payments where DonationId=Donations.id) as NumPayments,dbo.Donations.Id, dbo.Donations.DonationDate, dbo.Donations.PaymentStatus, dbo.Donations.ConfirmedPaymentId
FROM  dbo.Donations 
WHERE (dbo.Donations.ConfirmedPaymentId IS NOT NULL) AND (dbo.Donations.PaymentStatus = 4)
Order by NumPayments asc
tiagonmas commented 9 months ago

seems to be the same issue as #735

tiagonmas commented 8 months ago

Updated database to fix the past 73 records that had this issue

(73 rows affected)

Completion time: 2023-10-19T18:15:47.1568801+01:00

UPDATE dbo.Donations 
   SET dbo.Donations.PaymentStatus = 1
     WHERE dbo.Donations.Id IN 
        (
            SELECT        distinct(dbo.Payments.DonationId)
                FROM            dbo.Payments RIGHT OUTER JOIN dbo.Donations ON dbo.Payments.DonationId = dbo.Donations.Id
                WHERE (dbo.Donations.PaymentStatus = 4) AND (NOT (dbo.Donations.ConfirmedPaymentId IS NULL))
        )