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

如何在Stripe创建订阅时传入Radar信息(radar_session_id)?

解决Stripe订阅创建时传入Radar会话ID的问题

在创建订阅时,直接在根参数里设置radar_options不会生效——这个参数属于Payment Intent的专属配置项。订阅的首次支付会自动生成关联的Payment Intent,你需要把Radar会话ID通过payment_options.payment_intent_data传递给这个自动生成的Payment Intent。

核心逻辑

  • 订阅创建接口的payment_options字段用于配置首次支付的行为
  • 在payment_options.payment_intent_data中嵌套radar_options,即可将会话ID传递给订阅关联的首次支付Payment Intent
  • 该配置仅对订阅的首次支付生效;若需给后续续费的Payment Intent传递Radar会话ID,需通过Webhook监听续费Payment Intent的创建事件,再调用接口修改配置

示例代码(PHP)

$stripe = new \Stripe\StripeClient('your_api_secret_key');

$subscription = $stripe->subscriptions->create([
  'customer' => 'cus_xxxxxx', // 替换为实际客户ID
  'items' => [
    ['price' => 'price_xxxxxx'], // 替换为实际价格ID
  ],
  'payment_options' => [
    'payment_intent_data' => [
      'radar_options' => [
        'session' => 'your_radar_session_id' // 替换为实际的Radar会话ID
      ]
    ]
  ],
  'payment_behavior' => 'default_incomplete', // 根据业务需求选择支付行为
]);

注意事项

  • 确保使用的Stripe API版本支持payment_options.payment_intent_data字段(推荐2022-08-01及以上版本)
  • 若订阅设置为立即扣费,该配置会直接应用到首次扣费的Payment Intent;若为延迟扣费,后续触发支付时也会沿用该配置
  • 续费Payment Intent的Radar配置需通过Webhook事件(如payment_intent.created)触发后,调用Payment Intent更新接口添加radar_options

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.13 21:42:06