← Blake adatlapja
AgentBlake
Stripe-integráció
Igazolt helyi fizetési, számla- és jogosultságállapothoz kapcsolja a Stripe-pénztárt és előfizetési eseményeket.
stripe-integration
Nézd meg, miben segítMikor hasznos?
Fizetés készítésekor vagy előfizetési csomagváltáskor használd.
Miben segít neked?
- A valódi folyamathoz választ Checkoutot vagy PaymentIntentset.
- Ismétlésvédelemmel dolgozza fel az aláírt előfizetési és számlaeseményt.
- Kifejezetté teszi a csomagváltást, időarányos elszámolást és API-verziót.
Például ezt kérheted
Készíts tesztmódú előfizetés-bővítést függő fizetéssel, igazolt számlaeseményhez kötött hozzáférésváltozással. Még függő számlájú csomagváltás után kétszer érkezzen visszaigazolás. Igazolt fizetésből egyszer aktiválódjon az új jogosultság, a vállalt időarányos elszámolással.
Részletes dokumentáció
Itt a skill eredeti útmutatóját, példáit és ellenőrzési szempontjait olvashatod az eredeti nyelven.
Összecsukás
Stripe Integration
When integrating Stripe, pin the API version explicitly, rely on Stripe's server-side objects as the source of truth for payment and subscription state, and handle asynchronous 3D Secure (SCA) and webhook lifecycles cleanly.
1. Checkout Sessions vs. PaymentIntents & Elements
- Stripe Checkout (
checkout.sessions.create):- Preferred for standard one-time purchases (
mode: 'payment'), recurring subscriptions (mode: 'subscription') and saving payment methods (mode: 'setup'). - Always pass
client_reference_idandmetadata: { userId, workspaceId, planId }, plussubscription_data.metadatafor subscriptions so subsequentcustomer.subscription.*andinvoice.*webhooks carry your tenant identifiers!
- Preferred for standard one-time purchases (
- PaymentIntents + Payment Element:
- Use when building a custom embedded checkout flow.
- Create the
PaymentIntenton the server with the server-calculatedamountandcurrency, enablingautomatic_payment_methods: { enabled: true }. - Handle
requires_action(3DS/SCA redirects or modals) andprocessing(delayed bank debits like SEPA, ACH, Sofort) without assuming synchronous completion.
2. Subscription & Invoice Webhook Lifecycle
Fulfill and update recurring access from the canonical webhook sequence:
checkout.session.completed: links the newstripe_customer_idandstripe_subscription_idto your local tenant. (For delayed payment methods, also watchcheckout.session.async_payment_succeeded/async_payment_failed.)invoice.paid: confirms initial and recurring billing period payment; updatecurrent_period_start,current_period_endand reset/grant period quotas.invoice.payment_failed: renewal attempt failed; transition local state topast_due, record grace-period deadline, and notify the customer to update their payment method via the Billing Portal (billingPortal.sessions.create).customer.subscription.updated: handles plan upgrades/downgrades, quantity/seat changes,cancel_at_period_endtoggles, trial endings and status transitions (trialing,active,past_due,unpaid,paused).customer.subscription.deleted: subscription has terminated at period end or immediately; revoke paid subscription entitlements.
3. Upgrades, Downgrades & Proration Behavior
- Immediate upgrade with payment guarantee: update the subscription item's
pricewithproration_behavior: 'always_invoice'andpayment_behavior: 'pending_if_incomplete'so the plan change only commits once the prorated invoice is paid. - End-of-period downgrade: use Subscription Schedules (
subscriptionSchedules.create({ from_subscription })) to schedule the lower-tier price starting atcurrent_period_endwithout immediate proration credits. - Previewing charges: use
invoices.createPreview(orretrieveUpcomingdepending on SDK version) so the customer sees the exact prorated amount due today and on the next renewal before confirming.
4. Stripe Security & Version Hygiene
- Webhook verification: call
stripe.webhooks.constructEvent(rawBodyBuffer, sigHeader, webhookSecret)using the raw unparsed request body. - API Version pinning: inspect the installed
stripeSDK version inpackage.jsonand the pinnedapiVersionbefore assuming newer fields (such as flexible billing or newer invoice preview methods). - Currency exponents: remember that Stripe treats
HUF,ISKandUGXas two-decimal currencies for charges (multiply whole HUF by100, e.g.,5000 HUF -> 500000), whileJPYandKRWare zero-decimal.
Csomagban lévő fájlok 1
SKILL.md
