From 94d1aba17af098e91530eae037347821b7074e27 Mon Sep 17 00:00:00 2001 From: Seth Hobson Date: Thu, 19 Feb 2026 13:45:55 -0500 Subject: [PATCH] Add modernized Payment Intents pattern with Payment Element MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Restore Payment Intents flow removed by PR, updated for modern best practices - Use Payment Element instead of legacy Card Element - Use stripe.confirmPayment() instead of deprecated confirmCardPayment() - Use automatic_payment_methods instead of hardcoded payment_method_types - Split Python/JS into separate fenced code blocks for clarity - Add guidance on when to use Payment Intents vs Checkout Sessions - Renumber subsequent patterns (Subscription → 4, Customer Portal → 5) --- .../skills/stripe-integration/SKILL.md | 45 ++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/plugins/payment-processing/skills/stripe-integration/SKILL.md b/plugins/payment-processing/skills/stripe-integration/SKILL.md index d8abb23..b99314b 100644 --- a/plugins/payment-processing/skills/stripe-integration/SKILL.md +++ b/plugins/payment-processing/skills/stripe-integration/SKILL.md @@ -198,7 +198,48 @@ if (loadActionsResult.type === 'success') { """ ``` -### Pattern 3: Subscription Creation +### Pattern 3: Payment Intents with Payment Element (Bespoke Control) + +Use this when you need full control over the payment flow and cannot use Checkout Sessions +(e.g., you have your own tax, discount, or subscription calculation engine). + +```python +def create_payment_intent(amount, currency='usd', customer_id=None): + """Create a payment intent for bespoke checkout UI with Payment Element.""" + intent = stripe.PaymentIntent.create( + amount=amount, + currency=currency, + customer=customer_id, + automatic_payment_methods={ + 'enabled': True, + }, + ) + return intent.client_secret # Send to frontend +``` + +```javascript +// Frontend: Mount Payment Element and confirm via Payment Intents +const stripe = Stripe('pk_test_...'); +const elements = stripe.elements({clientSecret}); + +const paymentElement = elements.create('payment'); +paymentElement.mount('#payment-element'); + +document.getElementById('pay-button').addEventListener('click', async () => { + const {error} = await stripe.confirmPayment({ + elements, + confirmParams: { + return_url: 'https://yourdomain.com/complete', + }, + }); + + if (error) { + document.getElementById('errors').textContent = error.message; + } +}); +``` + +### Pattern 4: Subscription Creation ```python def create_subscription(customer_id, price_id): @@ -221,7 +262,7 @@ def create_subscription(customer_id, price_id): raise ``` -### Pattern 4: Customer Portal +### Pattern 5: Customer Portal ```python def create_customer_portal_session(customer_id):