feat: add gddy payments add command#64
Conversation
Adds a `gddy payments add` command that opens the system's default
browser to the GoDaddy payment methods management page, with
environment-aware URL derivation (prod → account.godaddy.com,
others → account.{env}-godaddy.com).
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
| |ctx| async move { | ||
| let url = account_url_for_env(&ctx.middleware.env); | ||
| open::that(&url) | ||
| .map_err(|e| CliCoreError::message(format!("failed to open browser: {e}")))?; |
There was a problem hiding this comment.
In case opening the browser is not working, perhaps we should print out the URL so the user can manually follow the URL. Or maybe that URL can be in the result message.
There was a problem hiding this comment.
Maybe follow the same shape as what oauth/pkce now does, and always emit? https://github.com/godaddy/cli-engine/blob/main/src/auth/pkce.rs#L652-L659
There was a problem hiding this comment.
I was hoping to not reveal the url in the result - do we expect failure in opening the browser?
I'll check https://github.com/godaddy/cli-engine/blob/main/src/auth/pkce.rs#L652-L659
There was a problem hiding this comment.
Yes, for anyone trying out the cli in a headless environment the browser-open would fail. We will eventually add the device-code flow for auth to make that work without the localhost callback; for this it's helpful to show the url so that they can browse there on a different device if needed.
There was a problem hiding this comment.
I'm moderately concerned about exposing the URL that would allow brand new customers to add cards without going through a typical purchase, especially to llms. The information does get out if someone observes what it's opening on a browser. Headless environment feels like an edge case.
Let me know if you think we should still add it in the error response and I will update the pr
There was a problem hiding this comment.
I don't think that this exposes much more. It's already -
- In the source code here, on the public github
- In the browser that gets opened
I expect that we're going to make some reference to this on the docs pages too: "You need to have a credit card payment method set up to purchase domains via API, go here to set it up". Outputting to stderr doesn't feel like much of a lift from those three.
This is going to be out there, we'll need to spend the time protecting it regardless.
There was a problem hiding this comment.
Yeah, agree. Will update
There was a problem hiding this comment.
I'm chasing a risk call placement for this payment API. I guess we will acknowledge the gap for MVP
There was a problem hiding this comment.
Done — on browser-open failure we now emit the URL to stderr (mirroring the pkce pattern: drop(writeln!(stderr, ...))) and return an error. On success the URL stays out of the output.
There was a problem hiding this comment.
Followed the pkce pattern — on failure we lock stderr and drop(writeln!) the URL before returning the error. Emitting only on failure rather than always since opening a browser without prompting is already a surprise; the URL showing up only when it fails keeps the happy path clean.
| ) | ||
| } | ||
|
|
||
| fn account_url_for_env(env: &str) -> String { |
There was a problem hiding this comment.
Should this use the same environment mechanics as the auth/domains base urls? https://github.com/godaddy/cli/blob/rust-port/rust/src/environments/mod.rs#L67-L83
There was a problem hiding this comment.
will check
There was a problem hiding this comment.
Done — account_url is now a field on ResolvedEnv, following the domains_api_url pattern exactly. Derives to account.godaddy.com for prod and account.{env}-godaddy.com for others; overridable via <ENV>_ACCOUNT_URL env var or local environments.toml. The payments command now calls environments::resolve() instead of a hardcoded helper.
…rowser failure - Move account URL derivation into environments::ResolvedEnv as account_url, following the domains_api_url pattern. Overridable via <ENV>_ACCOUNT_URL env var or local environments.toml config entry. - On browser-open failure, emit the URL to stderr so headless environments can navigate manually (mirrors cli-engine pkce pattern). - Remove hardcoded account_url_for_env from payments module. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Summary
gddy payments add— opens the system default browser to the GoDaddy payment methods management pageprod→account.godaddy.com, others →account.{env}-godaddy.cominfofield confirming the browser was opened and noting that only credit card or Good-as-Gold can be used for domain purchases--helptext surfaces the same constraint for discoverabilityTest plan
cargo test payments::— 4 unit tests covering URL derivation for prod/ote/dev/testcargo clippy -- -D warnings— cleancargo run -- payments add --help— shows long description with CC/GAG notecargo run -- payments add— opens browser to prod payment methods pagecargo run -- payments add --env ote— opens browser to ote payment methods page🤖 Generated with Claude Code