You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Stripe SCA订阅自动扣费异常及confirmation_method参数疑问

Stripe SCA Migration: Issues & Solutions

Hey there, let's tackle your two questions based on the code and test scenarios you shared:


1. How to make the first installment charge immediately in pre-production?

Looking at your setup, the first installment isn't charging right away because of a few missing configurations and unhandled edge cases. Here's what you need to adjust:

Key Problems Identified

  • Payment Method Not Attached to Customer: Your code uses a payment_method_id to create the PaymentIntent but doesn't attach this payment method to the corresponding Stripe Customer. Subscriptions can only use payment methods owned by the customer to auto-charge.
  • Unprocessed SCA for First Subscription Charge: Even after completing the initial PaymentIntent's SCA flow, the subscription's first invoice might still require explicit validation to trigger the charge.
  • Missing Payment Behavior Configuration: Your subscription schedule isn't configured to enforce immediate charge attempts, leading to draft invoices instead of automatic billing.

Step-by-Step Fixes

a. Attach Payment Method to Customer First

Before creating the PaymentIntent, link the payment method to your Stripe Customer:

// Attach the payment method to the customer first
\Stripe\PaymentMethod::attach(
    $requestData['payment_method_id'],
    ['customer' => $customer->id]
);

// Now create the PaymentIntent with the customer association
$intent = \Stripe\PaymentIntent::create([ 
    'payment_method' => $requestData['payment_method_id'], 
    'amount' => $requestData->amount, 
    'currency' => $requestData->currencyIso, 
    'payment_method_types' => ['card'], 
    'confirmation_method' => "manual", 
    'confirm' => true, 
    'setup_future_usage'=>"off_session", 
    'customer' => $customer->id, // Tie the intent to the customer
]); 
return $intent;

b. Adjust Subscription Schedule for Immediate Charging

Update your SubscriptionSchedule creation to include payment settings that enforce automatic billing:

$schedule = SubscriptionSchedule::create([ 
    'customer' => $customer->id, 
    'start_date' => 'now', 
    'end_behavior' => 'cancel',
    'payment_settings' => [
        'payment_method_types' => ['card'],
        'save_default_payment_method' => 'on_subscription',
    ],
    'phases' => [ 
        [ 
            'items' => [ 
                [ 'plan' => $plan->id, ], 
            ], 
            'collection_method'=>'charge_automatically',
            'payment_behavior' => 'default_incomplete', // Handle incomplete payments properly
            'iterations'=>$plan_length 
        ], 
    ], 
    // ... your existing metadata
]); 

c. Handle SCA for the First Subscription Charge

After creating the subscription, check if the latest invoice's PaymentIntent requires action, and trigger the SCA flow if needed:

// Retrieve the subscription and its latest invoice
$subscription = \Stripe\Subscription::retrieve($schedule->subscription);
$invoice = \Stripe\Invoice::retrieve($subscription->latest_invoice);

// If the payment intent needs action, send the client secret to the frontend
if ($invoice->payment_intent && $invoice->payment_intent->status === 'requires_action') {
    return json_encode([
        'requires_action' => true,
        'payment_intent_client_secret' => $invoice->payment_intent->client_secret
    ]);
}

On the frontend, use your existing handleServerResponse function to call stripe.handleCardAction with this client secret. Once validated, Stripe will automatically process the first installment charge.


2. What does confirmation_method => "manual" mean and what's its purpose?

Let's break down this parameter clearly:

Core Definition

confirmation_method: "manual" changes how Stripe processes the PaymentIntent confirmation. By default, Stripe uses automatic confirmation, which immediately attempts to finalize the payment when you set confirm: true. With manual confirmation:

  • Stripe initializes the PaymentIntent but does not automatically complete the final confirmation even if confirm: true is set.
  • You must explicitly call $intent->confirm() (usually after the user completes SCA validation) to finish the payment flow.

Key Use Cases

  • SCA Compliance: It’s ideal for flows where you need to collect user input for 3D Secure or other authentication before finalizing the payment. This ensures you only confirm the payment once the user has passed validation.
  • Off-Session Payment Setup: When using setup_future_usage: "off_session" (like your subscription scenario), manual confirmation lets you first validate the payment method for future auto-charges, then complete the initial payment in the same flow.
  • Conditional Payment Approval: If you need to run business logic checks (e.g., order verification) after initializing the PaymentIntent but before charging the card, manual confirmation gives you that flexibility.

In your code, this parameter works alongside setup_future_usage to ensure the payment method is marked valid for off-session subscription charges once the user completes SCA.


内容的提问来源于stack exchange,提问作者jones

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 08:08:50