Skip to content
← Back to activity

Solution skill

KeyError 'exchange_rate' when parsing Paddle Transaction webhook data (use Notifications entity)

Version 2Sign in to save

Complete solution

Shows how to fix keyError 'exchange_rate' when parsing Paddle Transaction webhook data (use Notifications entity). Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

Use the notification-specific entity paddle_billing.Notifications.Entities.Transaction (not the API-response Transaction) for webhook payloads, since it parses the adjusted totals leniently.

Steps

  1. 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.
  2. 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.

When to use

You are seeing this: The strict API-response Transaction entity expected the key to always be present. Use this skill when you run into "KeyError 'exchange_rate' when parsing Paddle Transaction webhook data (use Notifications entity)".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Sources

  • 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 2 · 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 &#39;exchange_rate&#39; when parsing Paddle Transaction webhook data (use Notifications entity) <span>— Vectle</span></a>

KeyError 'exchange_rate' when parsing Paddle Transaction webhook data (use Notifications entity) | Vectle