在 Flutter 流程中接受 Stripe 支付

您可以在 Flow & Paywall Builder 中创建流程,并通过该流程销售 Stripe 订阅。流程会展示您的 Stripe 价格,其中的按钮会在流程上层打开 Stripe 的 PaymentSheet。支付完成后,Stripe 会通知 Adapty。Adapty 随即向用户授予访问等级,并将收入归因到该流程、其版位及 A/B 测试实验变体。此方案适合销售用户在应用外使用的服务订阅,例如线下活动会员资格、课程通票或定期配送服务。如果您同时将某项实体服务以 App Store 产品的形式出售,也可以在同一流程中添加 Stripe,作为另一种支付方式。

Important

App Store 要求针对数字内容和功能使用应用内购买(准则 3.1.1),Google Play 也要求针对此类内容使用其计费系统(付款政策)。通过 Stripe 进行的应用内支付适用于实体商品,以及用户在应用外消费的服务(准则 3.1.3(e))。Google Play 不允许对此类购买(如健身房会员资格和现场活动门票)使用其计费系统。

工作原理

  1. 您的应用从后端获取 Stripe 价格,通过自定义标签将其传递给流程,并显示该流程。
  2. 用户点击流程中的按钮,该按钮触发自定义操作,您的应用接收到操作 ID。
  3. 您的应用请求后端创建 Stripe 订阅,后端将用户 ID 和流程的实验变体 ID 添加到订阅的元数据中。
  4. 您的应用在流程上方打开 PaymentSheet,用户完成首次订阅账单的支付。
  5. Stripe 向 Adapty 发送 webhook,Adapty 为该用户 ID 对应的用户画像授予访问等级,并将购买归因到相应的流程实验变体。
  6. 您的应用关闭流程,等待用户画像获得相应的访问等级。

开始之前

确保你已经:

  1. Stripe 已连接到您的 Adapty 应用:分别在测试模式和正式模式下按照将 Stripe 连接到 Adapty 进行操作。将 Profile creation behavior 保持设置为 Use customer_user_id from metadata (default)。

  2. 每个套餐对应一个 Stripe 产品和价格:在 Stripe 上创建产品,并设置定期付款价格,例如按月或按年收费。

  3. 每个 Stripe 价格对应一个 Adapty 产品:将 Stripe 产品 ID 和价格 ID 添加到 Adapty 产品中,并分配该套餐解锁的访问等级。访问等级代表对服务的使用权(例如有效会员资格),而非应用内的数字功能。若没有 Adapty 产品,Adapty 将不会记录该购买。

  4. Adapty Flutter SDK 4.0.0 或更高版本:使用已连接到 Stripe 的 Adapty 应用密钥激活 SDK。Adapty 仅接收该应用的 Stripe Webhook。通过 customer user ID 识别用户,并仅向已登录且已识别的用户展示此流程。Adapty 使用该 ID 查找并授予相应访问等级的用户画像。

    从 SDK 4.4 开始,流程需要 iOS 16 或更高版本。在 iOS 15 上,AdaptyUI().createFlowView() 和 AdaptyUIFlowPlatformView 会返回 AdaptyErrorCode.platformNotSupported 错误。当应用收到此错误时,请改为展示自定义内容,例如自定义付费墙。

  5. 应用中集成的 flutter_stripe 包,并按照其 README 完成 Android 和 iOS 的配置。在 Android 上,flutter_stripe 需要一个继承自 FlutterFragmentActivity 的 MainActivity,且主题须派生自 Theme.AppCompat。

  6. 一个能够调用 Stripe API 的后端服务,使用你的 Stripe 密钥,或者一个你自己生成的、具有创建 Customers 和 Subscriptions 写入权限的受限密钥。不要复用你为 Adapty 生成的受限密钥:那是 Adapty 专用的密钥,不具备你后端所需的写入权限。请将密钥保管在服务器端。

在流程中展示 Stripe 价格

流程通过自定义标签展示 Stripe 价格。自定义标签是应用在加载流程时传入的文本值。Adapty 不会对自定义标签的值进行格式化,因此请按照用户实际看到的形式传入价格,例如”$29.00”。

  1. 在 Flow & Paywall Builder 中,为每个价格创建一个 String 变量,例如 stripe_monthly_price 和 stripe_annual_price,并选择 Value comes from outside the app。将每个变量的 Initial value 设置为当前价格。如果应用无法加载价格,用户将看到初始值,因此请确保初始值与您的 Stripe 价格保持一致。
  2. 将每个标签插入文本元素,例如套餐按钮的标签。
  3. 在应用中,在加载流程之前先从后端获取价格。
  4. 在 AdaptyUIFlowPlatformView 的 customTags 参数中传入价格。

以下函数用于加载流程,并使用您的 Stripe 价格构建其自定义标签。它同时返回流程,因为您的后端会将流程的 variationId 写入 Stripe 订阅中。您可以在从流程打开 PaymentSheet 中查看如何展示该流程。


typedef StripeFlow = ({AdaptyFlow flow, Map<String, String> customTags});

Future<StripeFlow> loadStripeFlow() async {
  // If the prices fail to load, the flow shows the tags' initial values
  final prices = await Backend.fetchPrices().catchError((Object _) => <String, String>{});

  final flow = await Adapty().getFlow(placementId: 'YOUR_PLACEMENT_ID');
  return (
    flow: flow,
    customTags: {
      'stripe_monthly_price': ?prices['monthly'],
      'stripe_annual_price': ?prices['annual'],
    },
  );
}

Backend 是您后端接口的客户端,来自在您的后端创建订阅。

添加打开 PaymentSheet 的按钮

每个销售 Stripe 方案的按钮都会触发一个自定义操作。您的应用收到操作 ID 后,会为该方案打开 PaymentSheet。

  1. 在 Flow & Paywall Builder 中,为每个 Stripe 方案添加一个按钮。
  2. 为每个按钮分配 Custom Action 操作,并输入操作 ID,例如 buy_stripe_monthly 和 buy_stripe_annual。
  3. 发布流程,并将其添加到版位。

您的应用将每个操作 ID 映射到对应的方案。流程不会随操作发送任何数据,因此操作 ID 必须能够标识对应方案。

将 Stripe 作为 App Store 产品的另一种支付方式

此设置仅适用于用户在应用外消费的实体商品或服务(指南 3.1.3(e)),例如线下活动会员资格。对于数字内容或功能,请通过 网页付费墙 提供其他支付方式。

此设置仅适用于 iOS。Google Play 的支付政策不允许使用其计费系统销售实物商品和服务(支付政策),因此在 Android 上,请仅通过 Stripe 销售这些套餐。

该流程会像往常一样展示你的 App Store 产品,而”以其他方式付款”等链接则会打开 PaymentSheet。App Store 的购买按钮无需任何更改,仍可正常使用。

  1. 将 Custom Action 动作分配给该链接,并指定一个动作 ID,例如 pay_with_stripe。
  2. 为流程中每个 App Store 产品创建对应方案的 Stripe 价格。
  3. 在您的应用中,将每个 App Store 产品 ID 映射到其对应的 Stripe 方案。
  4. 存储用户选择的产品。流程会通过 AdaptyUIFlowPlatformView 的 onDidSelectProduct 回调上报每次选择操作。由流程与付费墙编辑工具构建的流程默认不会上报已选中的产品,因此请以您在编辑工具中设置为默认选中的产品作为初始值。如果 A/B 测试的各实验变体选中了不同的产品,请为每个变体分别存储其默认产品。
  5. 当 onDidPerformAction 收到 pay_with_stripe 时,使用已存储产品对应的 Stripe 方案调用从流程中打开 PaymentSheet 中的 _payAndClose。

流程会显示这些产品在 App Store 中的价格,该价格因店面而异。PaymentSheet 收取的是 Stripe 价格。若要在用户点击前显示 Stripe 价格,请将其作为自定义标签传入,并在每个方案的卡片中展示,例如”或每月 $29.00(银行卡支付)“。自定义标签的值在流程打开后不会改变,因此一个链接无法显示所选方案的价格。

在后端创建订阅

PaymentSheet 用于支付后端创建的 Stripe 对象。在本指南中,后端创建 Stripe 订阅,PaymentSheet 支付该订阅的首张发票。后端在订阅的元数据中设置两个键:

  • customer_user_id:用户在 Adapty 中的 customer user ID。Adapty 将访问等级授予具有此 ID 的用户画像。
  • variation_id:流程的实验变体 ID,由你的应用发送至后端。Adapty 将收入归因于该流程实验变体、其版位及其 A/B 测试。
Warning

对于你单独创建的 PaymentIntent(不关联任何订阅或发票),Adapty 不会记录付款。用户完成支付后,不会获得访问等级。

创建两个端点。第一个返回自定义标签的格式化价格。第二个创建订阅并返回 PaymentSheet 所需的值。在创建订阅之前,第二个端点会验证用户是否已有有效订阅,从而防止用户为同一套餐重复付款。

本示例使用 Node.js 的 ES 模块(package.json 中设置 "type": "module")、Express 以及 18 或更高版本的 stripe 库。请将 db 替换为你自己的数据库:


const app = express();
app.use(express.json());

const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);

const prices = {
  monthly: 'price_...', // your Stripe price IDs
  annual: 'price_...',
};

// Prices for the custom tags, such as { "monthly": "$29.00", "annual": "$249.00" }.
// You can cache the response.
app.get('/prices', async (req, res) => {
  try {
    const result = {};
    for (const [plan, priceId] of Object.entries(prices)) {
      const price = await stripe.prices.retrieve(priceId);
      // Assumes a currency with two decimal places. Format for your users' locale.
      result[plan] = new Intl.NumberFormat('en-US', {
        style: 'currency',
        currency: price.currency.toUpperCase(),
      }).format(price.unit_amount / 100);
    }
    res.json(result);
  } catch (error) {
    console.error(error);
    res.status(500).json({ error: 'Could not load prices' });
  }
});

app.post('/subscriptions', async (req, res) => {
  // req.user comes from your authentication middleware. Its ID is the same
  // customer user ID that your app passes to Adapty.identify().
  const customerUserId = req.user.id;
  // variationId affects only attribution, so the backend doesn't need to trust it
  const { plan, variationId } = req.body;
  if (!prices[plan]) {
    return res.status(400).json({ error: 'Unknown plan' });
  }

  try {
    // One Stripe customer per user, stored in your database
    let customerId = await db.getStripeCustomerId(customerUserId);
    if (!customerId) {
      const customer = await stripe.customers.create({ metadata: { customer_user_id: customerUserId } });
      customerId = customer.id;
      await db.saveStripeCustomerId(customerUserId, customerId);
    }

    // Don't sell a second subscription to a user who already has one
    for (const status of ['active', 'trialing', 'past_due']) {
      const existing = await stripe.subscriptions.list({ customer: customerId, status, limit: 1 });
      if (existing.data.length > 0) {
        return res.status(409).json({ error: 'You already have a subscription' });
      }
    }

    const subscription = await stripe.subscriptions.create({
      customer: customerId,
      items: [{ price: prices[plan] }],
      payment_behavior: 'default_incomplete',
      payment_settings: { save_default_payment_method: 'on_subscription' },
      metadata: {
        customer_user_id: customerUserId,
        variation_id: variationId,
      },
      expand: ['latest_invoice.confirmation_secret'],
    });

    res.json({
      subscriptionId: subscription.id,
      clientSecret: subscription.latest_invoice.confirmation_secret.client_secret,
      publishableKey: process.env.STRIPE_PUBLISHABLE_KEY,
    });
  } catch (error) {
    console.error(error);
    res.status(500).json({ error: 'Could not create the subscription' });
  }
});

app.listen(process.env.PORT ?? 3000);

使用 payment_behavior: 'default_incomplete' 时,订阅会等待首次付款。用户在 PaymentSheet 中完成支付后,Stripe 会激活该订阅。如果用户关闭 PaymentSheet 而未付款,Stripe 将在约 23 小时后使该订阅过期,Adapty 不会记录此次订阅。有关 Stripe 完整配置,请参阅 Stripe 文档中的 Build a subscriptions integration。

代码从 latest_invoice.confirmation_secret 读取客户端密钥,这需要 Stripe API 版本 2025-03-31.basil 或更高版本。stripe 库从版本 18 开始使用此版本。如果不通过库直接调用 Stripe API,请设置 Stripe-Version 请求头。在更早的 API 版本中,请展开 latest_invoice.payment_intent 并改为读取 payment_intent.client_secret。

在你的应用中,调用这两个端点。每次请求都需携带用户的身份验证信息,具体格式取决于你的后端要求。以下示例使用 http 包:



class Subscription {
  const Subscription({
    required this.subscriptionId,
    required this.clientSecret,
    required this.publishableKey,
  });

  factory Subscription.fromJson(Map<String, dynamic> json) => Subscription(
        subscriptionId: json['subscriptionId'] as String,
        clientSecret: json['clientSecret'] as String,
        publishableKey: json['publishableKey'] as String,
      );

  final String subscriptionId;
  final String clientSecret;
  final String publishableKey;
}

class BackendException implements Exception {
  const BackendException(this.message);

  final String message;

  @override
  String toString() => message;
}

abstract final class Backend {
  static const baseUrl = 'https://YOUR_BACKEND';

  static Future<Map<String, String>> fetchPrices() async {
    final json = await _send(http.get(Uri.parse('$baseUrl/prices')));
    return (json as Map<String, dynamic>).cast<String, String>();
  }

  static Future<Subscription> createSubscription({
    required String plan,
    required String variationId,
  }) async {
    final json = await _send(http.post(
      Uri.parse('$baseUrl/subscriptions'),
      headers: {
        'Content-Type': 'application/json',
        // add your authentication header
      },
      body: jsonEncode({'plan': plan, 'variationId': variationId}),
    ));
    return Subscription.fromJson(json as Map<String, dynamic>);
  }

  static Future<Object?> _send(Future<http.Response> request) async {
    final response = await request;
    if (response.statusCode != 200) {
      // Use the backend's message when the response has one
      String? message;
      try {
        message = (jsonDecode(response.body) as Map<String, dynamic>)['error'] as String?;
      } catch (_) {}
      throw BackendException(message ?? 'The server returned HTTP ${response.statusCode}.');
    }
    return jsonDecode(response.body);
  }
}

从流程中打开 PaymentSheet

当流程中的按钮触发自定义操作时,你的应用会打开 PaymentSheet,并在支付成功后关闭流程:

  1. 将自定义操作 ID 映射到对应方案。在应用等待后端响应或显示 PaymentSheet 期间,忽略点击操作、流程关闭按钮及其链接。这样每次点击只会创建一笔订阅。
  2. 向后端请求订阅,并传入方案和流程的 variationId。
  3. 在流程上方展示 PaymentSheet,并处理其结果:
    • Completed:关闭流程。关闭后,等待访问等级生效。
    • Canceled:不做任何处理。用户停留在流程中,可以选择其他方案。
    • Failed:通过 Flutter dialog 显示错误,该 dialog 会覆盖在嵌入式流程上方。view.showDialog 不适用于嵌入式流程。用户停留在流程中,可以重试。
  4. 处理流程的关闭和打开 URL 操作,以及 Android 系统的返回按钮。设置 onDidPerformAction 后,SDK 不会为该流程自动打开 URL。如需关闭流程,请移除对应 widget:view.dismiss() 不适用于嵌入式流程。

This guide puts steps 2 and 3 in one class:


class StripeCheckout {
  // Custom action IDs from the flow, mapped to your backend's plan keys
  static const plans = {
    'buy_stripe_monthly': 'monthly',
    'buy_stripe_annual': 'annual',
  };

  bool _isPaying = false;
  bool get isPaying => _isPaying;

  /// Opens PaymentSheet for a plan over the flow. Returns `true` when the user paid.
  Future<bool> pay(
    String plan,
    AdaptyUIFlowView view, {
    required Future<void> Function(String message) showError,
  }) async {
    if (_isPaying) return false;
    _isPaying = true;

    try {
      final subscription = await Backend.createSubscription(
        plan: plan,
        variationId: view.variationId,
      );

      Stripe.publishableKey = subscription.publishableKey;
      // The URL scheme that you register in your iOS app
      Stripe.urlScheme = 'your-app';
      await Stripe.instance.initPaymentSheet(
        paymentSheetParameters: SetupPaymentSheetParameters(
          paymentIntentClientSecret: subscription.clientSecret,
          merchantDisplayName: 'YOUR_BUSINESS_NAME',
          // For payment methods that redirect to another app, such as bank apps
          returnURL: 'your-app://stripe-redirect',
        ),
      );
      await Stripe.instance.presentPaymentSheet();
      return true;
    } on StripeException catch (e) {
      if (e.error.code == FailureCode.Canceled) return false; // the user stays on the flow
      await showError(e.error.localizedMessage ?? e.error.message ?? 'Unknown error');
      return false;
    } catch (e) {
      await showError(e.toString());
      return false;
    } finally {
      _isPaying = false;
    }
  }
}

在 iOS 上,PaymentSheet 在处理需要跳转至其他应用的支付方式后,会通过返回 URL 回到你的应用。请按照 Stripe 文档中设置返回 URL 的说明,在 ios/Runner/Info.plist 中注册 URL Scheme,并在 Stripe.urlScheme 和 returnURL 中使用相同的 scheme。当 iOS 通过该 URL 打开你的应用时,flutter_stripe 会将该 URL 传递给 Stripe。如果你的应用在 Info.plist 中将 FlutterDeepLinkingEnabled 设为 true,请在深度链接处理器中将该 URL 传递给 Stripe:


// In your deep-link handler, for URLs with your scheme
Future<void> handleStripeRedirect(Uri uri) async {
  await Stripe.instance.handleURLCallback(uri.toString());
}

在 Android 上,PaymentSheet 无需返回 URL 即可返回您的应用。

然后展示流程,并将其操作传递给 StripeCheckout。使用 AdaptyUIFlowPlatformView 小部件在其自己的路由中渲染流程,并在 onDidPerformAction 中处理其操作。由于流程是 Flutter 路由中的一个小部件,PaymentSheet 的结果会在流程打开时到达您的应用。要关闭流程,弹出该路由:



class StripeFlowPage extends StatefulWidget {
  const StripeFlowPage({super.key, required this.stripeFlow});

  final StripeFlow stripeFlow;

  @override
  State<StripeFlowPage> createState() => _StripeFlowPageState();
}

class _StripeFlowPageState extends State<StripeFlowPage> {
  final _checkout = StripeCheckout();
  bool _hasAppeared = false;
  bool _isClosing = false; // the route closes after the payment

  bool get _isBusy => _checkout.isPaying || _isClosing;

  /// Pops the route. The screen receives `true` when the user paid.
  void _close({bool paid = false}) {
    if (_isClosing || !mounted) return;
    _isClosing = true;
    Navigator.of(context).pop(paid);
  }

  void _onAction(AdaptyUIFlowView view, AdaptyUIAction action) {
    switch (action) {
      case CloseAction():
      case AndroidSystemBackAction():
        if (_isBusy) return;
        _close();
      case OpenUrlAction(:final url, :final openIn):
        if (_isBusy) return;
        AdaptyUI().openUrl(url, openIn: openIn).ignore();
      case CustomAction(:final action):
        final plan = StripeCheckout.plans[action];
        if (plan == null || _isBusy) return;
        _payAndClose(plan, view);
    }
  }

  Future<void> _payAndClose(String plan, AdaptyUIFlowView view) async {
    if (await _checkout.pay(plan, view, showError: _showError)) _close(paid: true);
  }

  /// Shows the error over the flow
  Future<void> _showError(String message) async {
    if (!mounted) return;
    await showDialog<void>(
      context: context,
      builder: (context) => AlertDialog(
        title: const Text("The payment didn't go through"),
        content: Text(message),
        actions: [
          TextButton(
            onPressed: () => Navigator.of(context).pop(),
            child: const Text('OK'),
          ),
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    // Android's Back button can pop the route instead of reaching the flow
    return PopScope(
      canPop: false,
      onPopInvokedWithResult: (didPop, _) {
        if (!didPop && !_isBusy) _close();
      },
      child: Scaffold(
        // Keeps the flow's close button out of the Android status bar.
        // On iOS, the flow applies the safe area itself.
        body: SafeArea(
          top: Platform.isAndroid,
          bottom: Platform.isAndroid,
          child: AdaptyUIFlowPlatformView(
            flow: widget.stripeFlow.flow,
            customTags: widget.stripeFlow.customTags,
            onDidAppear: (_) => _hasAppeared = true,
            onDidPerformAction: _onAction,
            onDidReceiveError: (view, error) {
              debugPrint('Flow error: $error');
              // The widget stays empty when it can't show the flow.
              // The flow keeps working after other errors, so keep PaymentSheet open.
              if (!_hasAppeared && !_isBusy) _close();
            },
          ),
        ),
      ),
    );
  }
}

如果您的应用通过 AdaptyUI().setFlowsEventsObserver 设置了观察者,该观察者同样会接收此流程的事件。请仅在 onDidPerformAction 中处理 Stripe 操作。

在您的页面中,加载流程并推送其路由:


class MembershipScreen extends StatefulWidget {
  const MembershipScreen({super.key});

  @override
  State<MembershipScreen> createState() => _MembershipScreenState();
}

class _MembershipScreenState extends State<MembershipScreen> {
  bool _isLoadingFlow = false;

  Future<void> _showStripeFlow() async {
    if (_isLoadingFlow) return;
    _isLoadingFlow = true;

    try {
      final stripeFlow = await loadStripeFlow();
      if (!mounted) return;
      final paid = await Navigator.of(context).push<bool>(
        MaterialPageRoute(builder: (_) => StripeFlowPage(stripeFlow: stripeFlow)),
      );
      if (paid == true) await _unlockAfterPayment();
    } on AdaptyError catch (e) {
      // handle the error
    } catch (e) {
      // handle the error
    } finally {
      _isLoadingFlow = false;
    }
  }

  Future<void> _unlockAfterPayment() async {
    final hasAccess = await waitForAccess();
    if (!mounted) return;
    if (hasAccess) {
      // unlock the service
    } else {
      // tell the user that the payment is processing, and how to reach your support
    }
  }

  @override
  Widget build(BuildContext context) {
    return ElevatedButton(
      onPressed: _showStripeFlow,
      child: const Text('Become a member'),
    );
  }
}

如果你的流程还需要销售 App Store 或 Google Play 产品,请在 AdaptyUIFlowPlatformView 的购买回调中处理相关购买操作,具体方式请参阅处理流程事件。

付款后解锁访问权限

付款完成后,Adapty 会接收 Stripe 的 webhook 并在几秒内授予相应的访问等级。SDK 每分钟刷新一次用户画像,因此请持续请求用户画像,直到访问等级生效:


Future<bool> waitForAccess() async {
  for (var attempt = 0; attempt < 20; attempt++) {
    try {
      final profile = await Adapty().getProfile();
      if (profile.accessLevels['YOUR_ACCESS_LEVEL']?.isActive == true) return true;
    } catch (_) {
      // try again
    }
    await Future<void>.delayed(const Duration(seconds: 3));
  }
  return false;
}

访问等级通常会在几秒内激活。如果 60 秒后仍未激活,请在 Stripe 的 Webhook 设置中核查 Adapty Webhook 端点的投递情况。

如需在支付完成后显示确认页面(如欢迎界面),可在访问等级激活时于应用内展示。你也可以将该页面构建为第二个流程,添加到独立的版位,并在第一个流程关闭后呈现它。响应购买结果介绍了如何为此设置第二个流程。

让用户管理订阅

Stripe 订阅不会出现在用户的 App Store 或 Google Play 订阅列表中。若要让用户取消订阅或更改付款方式,请在应用中(例如账户页面)添加一个按钮,点击后跳转至 Stripe 用户门户。由你的后端为该用户的 Stripe 客户创建一个门户会话,并返回对应的 URL。

当用户取消订阅时,Stripe 会通知 Adapty,Adapty 随即更新访问等级。有关 Adapty 如何处理立即取消和到期取消的详细信息,请参阅取消。

测试集成

使用连接到你的 Adapty 应用的 Stripe 测试模式:

  1. 使用已连接 Stripe 的 Adapty 应用的 SDK 密钥运行您的应用。
  2. 打开流程。按钮应显示您的应用传入的价格,而非自定义标签的初始值。
  3. 点击 Stripe 方案按钮。在 PaymentSheet 中,使用 Stripe 测试卡 4242 4242 4242 4242 完成支付,填写任意未来的到期日期和任意 CVC。
  4. 确认流程已关闭,且用户画像的访问等级在几秒内变为活跃状态。
  5. 在 Adapty 看板中,打开 Event Feed。购买事件应包含 store: stripe、您流程的 flow_id 和 flow_name、等于您的应用发送的 variationId 的 flow_variation_id,以及 developer_id 中的版位 ID。对于 Stripe 购买,variation_id 与 flow_variation_id 的值相同。

测试模式下的购买记录环境为 Sandbox。这些记录会出现在 Event Feed 和用户画像中,但不会计入分析数据或流程的数据图表,因为这些指标仅统计正式生产环境中的购买行为。

如果购买记录未出现在 Adapty 中,请核查以下几点:您的应用是否使用了与 Stripe 关联的 Adapty 应用的 SDK 密钥、是否已为相应 Stripe 价格创建了 Adapty 产品,以及订阅的元数据中是否包含 customer_user_id。另请参阅 Stripe 集成指南中的故障排查部分。

限制

  • 流程无法获取 Stripe 支付结果:流程在 Stripe 支付成功、取消或失败后无法跳转到其他页面。您的应用需要关闭流程并自行决定后续展示的内容。
  • 自定义标签中的价格为文本形式:流程会按照应用传入的自定义标签值原样显示,不会据此计算其他值(如每周价格或折扣)。如需展示多个值,请分别传入对应的标签。
  • 流程打开期间自定义标签值保持不变:如需显示新价格,请重新加载流程。