Immutable solution version
KeyError 'exchange_rate' when parsing Paddle Transaction webhook data (use Notifications entity)
Complete solution
What caused "KeyError 'exchange_rate' when parsing Paddle Transaction webhook data (use Notifications entity)" and the fix that actually worked. Distilled from the thread where it was verified.
KeyError 'exchange_rate' when parsing Paddle Transaction webhook data (use Notifications entity)
What was going on
Parsing transaction webhook data with Transaction.fromdict(data) threw KeyError: 'exchangerate' because the exchangerate key is missing from the TransactionPayoutTotalsAdjusted section of webhook payloads. The strict API-response Transaction entity expected the key to always be present. The strict entity is meant for API responses, where exchangerate is always present, so it never hit this on the API path.
The fix that worked
Use the notification-specific entity paddlebilling.Notifications.Entities.Transaction (not the API-response Transaction) for webhook payloads, since it parses the adjusted totals leniently. Paddle also rolled out a fix so webhooks now include exchangerate, so current payloads parse either way. The maintainer's first response pointed at the notification-specific entity before the webhook payload fix rolled out.
Where this came from
https://github.com/PaddleHQ/paddle-python-sdk/issues/160
Evidence
Someone asked: Parsing transaction webhook data with Transaction.fromdict(data) threw KeyError: 'exchangerate' because the exchangerate key is missing from the TransactionPayoutTotalsAdjusted section of webhook payloads. The strict API-response Transaction entity expected the key to always be present. The strict entity is meant for API responses, where exchangerate is always present, so it never hit this on the API path. The verified resolution: Use the notification-specific entity paddlebilling.Notifications.Entities.Transaction (not the API-response Transaction) for webhook payloads, since it parses the adjusted totals leniently. Paddle also rolled out a fix so webhooks now include exchangerate, so current payloads parse either way. The maintainer's first response pointed at the notification-specific entity before the webhook payload fix rolled out. Thread: https://vectle.com/threads/thr_NqOxXGWfQF-fghBl6PJLkg
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_RtYjuI_Xr1R82U_Gr41Xfg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">KeyError 'exchange_rate' when parsing Paddle Transaction webhook data (use Notifications entity) <span>— Vectle</span></a>