Skip to content

fix(account): refresh stored provider credentials on re-registration; stop logging them at INFO - #37

Merged
fupelaqu merged 1 commit into
mainfrom
fix/provider-credentials-refresh
Nov 20, 2026
Merged

fupelaqu merged 1 commit into
mainfrom
fix/provider-credentials-refresh

Conversation

@fupelaqu

Copy link
Copy Markdown
Contributor

Summary

Two fixes around the payment provider credentials:

  • re-registering a provider now refreshes the credentials stored on its account;
  • the startup log no longer prints the provider API key.

Version 0.9.13.

Re-registration refreshes the provider credentials

At every start, the configured providers are registered on their accounts (RegisterAccountWithProvider). When the account already held a client for that provider, the handler only refreshed the client API key, which is a hash of the provider key. It kept the stored provider, and with it the provider API key that every provider call uses. After a key rotation (same provider id, new key), every provider call therefore kept using the old key, while the refreshed client API key suggested the rotation had been applied.

The existing client now takes the provider of the registration and keeps its own settings: name, contact emails, address and access token. Its clientId is unchanged, so account keys and webhook hashes don't move.

The rule lives in SoftPayClientRegistration.registeredClient, a pure function the behavior calls, so it can be unit-tested without an actor system.

The startup log no longer prints the provider API key

PaymentGuardian.registerProvidersAccount logged the whole registered account at INFO (Registered provider account for <id>: $account). The account's toString includes each client's provider, and therefore the provider API key, in clear, at every start. The line now logs only the client id.

The persistence library still logs every command and event at DEBUG, and these include the provider. Keep DEBUG off for the account entities in production.

Release note

Versions up to 0.9.12 logged the provider API keys at INFO on every start, so retained logs may contain them. Rotate the provider keys after upgrading to 0.9.13. The first fix above is what makes a rotated key take effect.

Test plan

  • New SoftPayClientRegistrationSpec (3 tests):
    • an existing client takes the new provider key;
    • it keeps its identity and settings, access token included;
    • an account without a client for the provider gets the new client as is.
  • scalafmtSbtCheck scalafmtCheck Test/scalafmtCheck: clean.
  • + Test/compile: compiles on Scala 2.12 and 2.13.

🤖 Generated with Claude Code

… stop logging them at INFO

At every start, the configured providers are registered on their accounts
(`RegisterAccountWithProvider`). For an account that already had a client for
the provider, only the client API key (a hash of the provider key) was
updated: the stored provider, and with it the provider API key that every
provider call uses, was kept. A rotated provider key therefore never reached
the provider calls, while the refreshed client API key suggested it had.

The existing client now takes the provider of the registration and keeps its
own settings (name, contact emails, address, access token). The rule lives in
`SoftPayClientRegistration.registeredClient`, covered by a unit test.

`PaymentGuardian.registerProvidersAccount` also logged the whole registered
account at INFO, whose `toString` prints each client's provider API key in
clear at every start. It now logs only the client id.

Version 0.9.13.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 40.85%. Comparing base (65334ce) to head (5ab0402).

Files with missing lines Patch % Lines
...ent/persistence/typed/SoftPayAccountBehavior.scala 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #37      +/-   ##
==========================================
+ Coverage   40.82%   40.85%   +0.02%     
==========================================
  Files         155      155              
  Lines       10924    10925       +1     
  Branches     1660     1789     +129     
==========================================
+ Hits         4460     4463       +3     
+ Misses       6464     6462       -2     
Flag Coverage Δ
unittests 40.85% <75.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@fupelaqu
fupelaqu merged commit fb0a745 into main Nov 20, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant