Skip to content

Implement Secure Payment Gateway and Payment Service #1

@brianne-showed

Description

@brianne-showed

Relevant Code

export async function createPaymentIntent(payload) {
  // TODO: integrate Stripe SDK and return client secret.
  return {
    paymentId: `pay_${Date.now()}`,
    amount: payload.amount,
    currency: payload.currency ?? "usd",
    provider: "stripe"
  };
}

Goals

  • Replace the stub implementation with a real Stripe PaymentIntent via the Stripe Node.js SDK
  • Return the client_secret from the created PaymentIntent to the caller
  • Handle Stripe API errors and surface them with meaningful error messages
  • Ensure amount, currency, and any required metadata are validated before the API call

Acceptance Criteria

  • stripe npm package is installed and a STRIPE_SECRET_KEY environment variable is used to initialise the client — no hardcoded keys
  • payload.amount is required and must be a positive integer (smallest currency unit, e.g. cents); function throws/rejects with a descriptive error if missing or invalid
  • payload.currency defaults to "usd" if not provided, consistent with current behaviour
  • A real stripe.paymentIntents.create() call is made with at minimum { amount, currency }
  • The resolved value includes clientSecret (mapped from paymentIntent.client_secret) and paymentId (mapped from paymentIntent.id)
  • The stub pay_${Date.now()} id generation is removed
  • Stripe errors (StripeCardError, StripeInvalidRequestError, etc.) are caught and re-thrown with the original Stripe error message preserved
  • Unit test mocks the Stripe SDK and asserts correct arguments are passed to paymentIntents.create()
  • Integration/smoke test (guarded by an env flag) confirms a test-mode PaymentIntent is created successfully against the Stripe API

/bounty $350

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions