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
/bounty $350
Relevant Code
Goals
PaymentIntentvia the Stripe Node.js SDKclient_secretfrom the createdPaymentIntentto the calleramount,currency, and any required metadata are validated before the API callAcceptance Criteria
stripenpm package is installed and aSTRIPE_SECRET_KEYenvironment variable is used to initialise the client — no hardcoded keyspayload.amountis required and must be a positive integer (smallest currency unit, e.g. cents); function throws/rejects with a descriptive error if missing or invalidpayload.currencydefaults to"usd"if not provided, consistent with current behaviourstripe.paymentIntents.create()call is made with at minimum{ amount, currency }clientSecret(mapped frompaymentIntent.client_secret) andpaymentId(mapped frompaymentIntent.id)pay_${Date.now()}id generation is removedStripeCardError,StripeInvalidRequestError, etc.) are caught and re-thrown with the original Stripe error message preservedpaymentIntents.create()PaymentIntentis created successfully against the Stripe API/bounty $350