[go: up one dir, main page]

Page MenuHomePhabricator

gross value coming in as string for some paypal messages
Open, HighPublic

Description

Two damage queue items both failed due to an Invalid Field Type.

The first one appears to have happened due to a rounding error, which I updated to 1.4 and pushed back through. We probably need a ticket for a fix for that.

The second one is weirder. The gross value seems to come through as a string and not a float.

197742821.13 - failed due to rounding error on gross, which is a float

DonationQueueConsumer array {
  "contact_id": 6340019,
  "financial_type_id": 32,
  "payment_instrument_id": 15,
  "invoice_id": "197742821.13",
  "gateway": "adyen",
  "gross": 1.3999999999999999,
  "currency": "GBP",
  "gateway_txn_id": "W67236FV3VKC42B9",
  "payment_method": "cc",
...
}
Nov 28 05:29:02 civi1002 SmashPig: donations | Error processing message, moving to damaged store. |#0 /srv/org.wikimedia.civicrm/drupal/sites/all/modules/civicrm/Civi/Schema/EntityMetadataBase.php(217): CRM_Core_BAO_CustomValueTable::fieldToSQLType('FLOAT', 255)

222899426.1 - gross value is a string (double-quoted)

DonationQueueConsumer array {
  "gateway_txn_id": "5TR94981J9233404U",
  "response": false,
  "gateway_account": "prod",
  "fee": 0,
  "gross": "20.80",
  "contribution_tracking_id": "222899426",
  "country": "GB",
  "currency": "GBP",
  "email": "s***@btinternet.com",
  "first_name": "I*****",
  "gateway": "paypal_ec",
  "gateway_session_id": "EC-21979249V11081029",
...
}

2024-11-28 05:32:02,789 ERROR   Stack Trace: #0 /srv/org.wikimedia.civicrm/drupal/sites/all/modules/civicrm/Civi/Schema/EntityMetadataBase.php(217): CRM_Core_BAO_CustomValueTable::fieldToSQLType('FLOAT', 255)

Event Timeline

AKanji-WMF moved this task from Triage to DRI Backlog on the Fundraising-Backlog board.

I take a look for the log, seems like almost all of our gross is double quote, so just need to convert the gross to number_format((float)$number, 2, '.', '') then we will see the number fine.

Change #1100881 had a related patch set uploaded (by Wfan; author: Wfan):

[wikimedia/fundraising/crm@master] Make sure gross in DonationQueue is rounded to curreny's decimal

https://gerrit.wikimedia.org/r/1100881

I believe this only happened 2 times in 11/28/2024, and nothing in the future, (plus all 197742821 13 previous for this donations) also confirmed that our code did have gross normalized during import, so it feels like something wrong in 11/28 for a short time, we can possibly close this ticket.