Skip to content

Add Stripe Balance API integration#3

Merged
johnconstant99-dev merged 3 commits into
mainfrom
copilot/set-stripe-api-key
Dec 24, 2025
Merged

Add Stripe Balance API integration#3
johnconstant99-dev merged 3 commits into
mainfrom
copilot/set-stripe-api-key

Conversation

Copilot AI commented Dec 24, 2025

Copy link
Copy Markdown
Contributor

Implements Stripe Balance.retrieve() functionality per problem statement, enabling balance retrieval with optional context parameter for connected accounts.

Changes

Service Layer

  • src/services/stripeService.js - Stripe client initialization and balance retrieval with optional stripeAccount context

API Layer

  • src/api/controllers/stripeController.js - Balance endpoint controller
  • src/api/routes/stripe.js - GET /api/stripe/balance?context=<account_id> route
  • src/api/server.js - Route registration

Bot Integration

  • src/bot/commands/stripe_balance.js - /stripe_balance command with multi-currency display
  • src/bot/index.js - Command registration
  • src/bot/commands/help.js - Documentation update

Configuration

  • .env.example - Added STRIPE_SECRET_KEY and STRIPE_CONTEXT
  • src/config/index.js - Stripe config loading
  • package.json - Added stripe@^14.10.0 dependency

Usage

// Service usage
const balance = await stripeService.getBalance(context);

// API endpoint
GET /api/stripe/balance?context=acct_xxxxx

// Telegram bot
/stripe_balance

Response format includes available/pending balances per currency and livemode flag.

Original prompt

Set your secret key. Remember to switch to your live secret key in production.

See your keys here: https://dashboard.stripe.com/apikeys

import stripe
stripe.api_key = "{{ORG_SECRET_KEY}}"

balance = stripe.Balance.retrieve(stripe_context="{{CONTEXT}}")


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits December 24, 2025 18:38
Co-authored-by: johnconstant99-dev <243629755+johnconstant99-dev@users.noreply.github.com>
…y formatting

Co-authored-by: johnconstant99-dev <243629755+johnconstant99-dev@users.noreply.github.com>
Copilot AI changed the title [WIP] Set secret key for Stripe API Add Stripe Balance API integration Dec 24, 2025
@johnconstant99-dev

Copy link
Copy Markdown
Owner

@copilot package.json:30 "axios": "^1.12.0"

Copilot AI commented Dec 24, 2025

Copy link
Copy Markdown
Contributor Author

@copilot package.json:30 "axios": "^1.12.0"

The axios dependency was already present in the repository before my changes. My new /stripe_balance command uses axios to call the API endpoint.

Would you like me to:

  1. Update axios to the latest version (1.13.2)?
  2. Keep it as is?
  3. Something else?

Please let me know what you'd prefer.

Comment thread src/config/index.js

@johnconstant99-dev johnconstant99-dev left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

lunaelite.js

@johnconstant99-dev johnconstant99-dev marked this pull request as ready for review December 24, 2025 20:17

Copilot AI commented Dec 24, 2025

Copy link
Copy Markdown
Contributor Author

lunaelite.js

Could you clarify what you'd like me to do regarding "lunaelite.js"? I don't see this file in the repository or understand how it relates to the Stripe integration changes.

Are you asking me to:

  • Create a new file?
  • Look at an external reference?
  • Something else?

@johnconstant99-dev

Copy link
Copy Markdown
Owner

@copilot src/api/controllers/stripeController.js:14

Copilot AI commented Dec 24, 2025

Copy link
Copy Markdown
Contributor Author

@copilot src/api/controllers/stripeController.js:14

Line 14 is the closing brace of module.exports. Could you clarify what you'd like me to address?

Possible improvements I can make:

  1. Add input validation for the context parameter
  2. Add more detailed error handling
  3. Ensure consistent response format with other controllers
  4. Something else?

Please let me know what changes you'd like to see.

@johnconstant99-dev

Copy link
Copy Markdown
Owner

@copilot package.json:30

@johnconstant99-dev

Copy link
Copy Markdown
Owner

@copilot add package.json:31

Copilot AI commented Dec 24, 2025

Copy link
Copy Markdown
Contributor Author

@copilot add package.json:31

Line 31 currently contains "stripe": "^14.10.0" which is the Stripe dependency I added.

Could you clarify what you'd like me to add at line 31? Are you asking me to:

  1. Add a new dependency after Stripe?
  2. Modify the Stripe dependency?
  3. Add something else?

Please provide more details so I can make the appropriate changes.

Copy link
Copy Markdown
Owner

@copilot del "axios": "^1.12.0"

1 similar comment

Copy link
Copy Markdown
Owner

@copilot del "axios": "^1.12.0"

Copilot AI commented Dec 24, 2025

Copy link
Copy Markdown
Contributor Author

@copilot del "axios": "^1.12.0"

⚠️ Cannot remove axios - it's a critical dependency used throughout the application.

Axios is used by:

  • src/bot/commands/balance.js (existing)
  • src/bot/commands/transactions.js (existing)
  • src/bot/commands/link.js (existing)
  • src/bot/commands/stripe_balance.js (my new command)

Removing axios would break all bot commands that communicate with the API server.

If you're concerned about the version (1.12.0), I can update it to the latest (1.13.2), but the dependency itself cannot be removed without replacing it with an alternative HTTP client throughout the codebase.

@johnconstant99-dev johnconstant99-dev left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

mk_1SrXwZCJIdnOmJ9tjmXhfHKa

Comment thread src/api/controllers/stripeController.js
@johnconstant99-dev johnconstant99-dev merged commit dd4e4bc into main Dec 24, 2025
7 of 8 checks passed
Comment thread package.json
Comment thread package.json
Comment thread package.json
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.

2 participants