Skip to content

feat: add gddy payments add command#64

Open
sswaminathan-godaddy wants to merge 2 commits into
godaddy:rust-portfrom
sswaminathan-godaddy:payments-stuff-rust-port
Open

feat: add gddy payments add command#64
sswaminathan-godaddy wants to merge 2 commits into
godaddy:rust-portfrom
sswaminathan-godaddy:payments-stuff-rust-port

Conversation

@sswaminathan-godaddy

Copy link
Copy Markdown
Collaborator

Summary

  • Adds gddy payments add — opens the system default browser to the GoDaddy payment methods management page
  • URL is environment-aware: prodaccount.godaddy.com, others → account.{env}-godaddy.com
  • No CLI auth required; user authenticates in the browser if needed
  • JSON output includes an info field confirming the browser was opened and noting that only credit card or Good-as-Gold can be used for domain purchases
  • Extended --help text surfaces the same constraint for discoverability

Test plan

  • cargo test payments:: — 4 unit tests covering URL derivation for prod/ote/dev/test
  • cargo clippy -- -D warnings — clean
  • cargo run -- payments add --help — shows long description with CC/GAG note
  • cargo run -- payments add — opens browser to prod payment methods page
  • cargo run -- payments add --env ote — opens browser to ote payment methods page

🤖 Generated with Claude Code

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>
Comment thread rust/Cargo.lock
Comment thread rust/src/payments/mod.rs Outdated
|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}")))?;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jbrooks2-godaddy jbrooks2-godaddy Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@sswaminathan-godaddy sswaminathan-godaddy Jun 16, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, agree. Will update

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm chasing a risk call placement for this payment API. I guess we will acknowledge the gap for MVP

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread rust/src/payments/mod.rs Outdated
)
}

fn account_url_for_env(env: &str) -> String {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will check

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

3 participants