# A/B 测试支付方式

在管理平台中启动新支付方式的 A/B 测试。

A/B testing allows you to measure the impact of offering new payment methods to a percentage of customers before offering them to all of your customers. You can run A/B tests without writing any code.

使用 A/B 测试来：

- 在向所有客户引入之前，先向部分客户测试“先买后付”（Buy Now, Pay Later，BNPL）支付方式，如 Klarna、Affirm 和 Afterpay。
- 衡量定位规则的影响，例如为某些支付方式设置最低购买金额。
- 逐步向更多客户推出新的支付方式。

## Before you begin

To run an A/B test, your integration must use [dynamic payment methods](https://docs.stripe.com/payments/payment-methods/dynamic-payment-methods.md?payment-ui=payment-element#customization-features). A/B testing is available if you use either [Payment Element Web](https://docs.stripe.com/payments/payment-element.md) with the Payment Intents API or [Checkout](https://docs.stripe.com/payments/checkout.md) in payment mode. See [Supported payment methods](https://docs.stripe.com/payments/a-b-testing.md#supportability) for the list of payment methods you can test.

## 开始您的 A/B 试验
![在自定义配置页面上找到“创建试验”按钮](https://b.stripecdn.com/docs-statics-srv/assets/create-experiment.93f437615e14f46700ee3f66cfafb367.png)

1. 在 Stripe 管理平台中，打开[支付方式设置](https://dashboard.stripe.com/settings/payment_methods)，然后点击**创建试验**。
   - 您只能通过 Stripe 管理平台启动、停止和管理试验（没有 API 选项）。
   - 如果您有多种支付方式配置，请选择要运行试验的配置后再点击**创建试验**。每个配置一次只能运行一个试验。
2. 选择要包含在试验中的支付方式。
3. (Optional) Add custom [payment method rules](https://docs.stripe.com/payments/payment-method-rules.md), such as transaction amount or presentment currency, as additional filters to control when a payment method is eligible. You can also create custom rules using the standalone feature.
4. 为您的试验命名，并选择要包含在您的处理组中的流量百分比。
   - **流量分配**：我们的默认建议是 50%，以平衡快速接收结果（百分比越低，统计显著性结果需要的时间越长）和较差试验性能的风险管理。您可以根据风险承受能力和试验目标选择较小或较大的百分比。当处理组/对照组流量50/50 分配时，80,000 个样本量足以在 5% 的显著性水平下检测到 100 个基点的转化率变化。
   - **Experiment randomization**: Stripe randomizes customer sessions based on a unique identifier, which includes the [UserAgent](https://en.wikipedia.org/wiki/User-Agent_header), IP address, and date. As a result, an individual customer sees the same set of treatment or control payment method options for a particular day. To avoid instances of double counting, such as page refreshes, we aggregate sessions for each unique user on a daily basis.
5. Review and start your experiment. (You can save an experiment as a draft if you’re not ready to start it.)
   > When you begin an experiment, you can change the treatment group traffic allocation percentage but you can’t turn payment methods on or off for your control or treatment groups. To make any payment method settings changes after an experiment has started, you must end the experiment first.
6. (Recommended) If you’re testing Buy Now, Pay Later (BNPL) payment methods, we recommend that you install the [Payment Method Messaging Element](https://docs.stripe.com/elements/payment-method-messaging.md). This embeddable UI component allows your customers to see the available payment options directly from your product, cart, or payment pages.

## 管理并结束 A/B 试验
![管理试验的设置页面](https://b.stripecdn.com/docs-statics-srv/assets/manage-experiment.25dc48d02e880cae44369eb82eaab30c.png)

1. 要从您的支付方式设置中查看所有当前和过去的试验，点击溢出菜单(⋯)，然后选择**管理试验**。
2. There are four actions you can take while an experiment is active. If you have a Connect integration and select **treatment configuration**, any new payment method in treatment turns on for all users.
   - **调整流量分配**：您可以调整分配给测试组的流量百分比，范围从 1% 到 99%。
   - **查看试验报告**。
   - **Pause or resume an experiment**: When paused, only your control payment methods are available to customers and experiment data isn’t captured in your report.
   - **结束试验**：试验结束后，您可以选择采用测试设置，或者恢复到之前的（对照）设置。如果您的试验运行时间超过 180 天，我们将代表您终止试验并启用您的控制设置。

## 理解试验结果

试验开始后，在 Stripe 管理平台中查看其进度。
![在页面上显示试验结果](https://b.stripecdn.com/docs-statics-srv/assets/experiment-report.0d05f61a45c9a97306c62ffa616d4780.png)

当满足两个条件时，A/B 测试认为试验完成：

- 每个会话的平均收入[具有统计显著性](https://en.wikipedia.org/wiki/Statistical_significance)。当结果是由随机引起的概率小于 5% 时，我们认为结果具有统计学显著性。见[试验方法](https://docs.stripe.com/payments/a-b-testing.md#experiment-methodology)。
- 试验已经积累足够的会话。这是一个动态数字，基于您在试验创建期间设置的处理与对照组的百分比。

试验结果指标包括：

| Result metric | 描述 |
| --- | --- |
| **Average revenue per session** | Average revenue per session is the total revenue divided by the total number of sessions. It shows the difference in revenue per session between your treatment and control groups, and is a summary of the overall results of your experiment. The total number of sessions includes both sessions that resulted in a purchase and sessions that didn’t result in a purchase. Due to the significant variations in conversion rates and average order values by payment method, we recommend using the Average revenue per session metric as a guiding metric when determining the overall success of the experiment. |
| **Revenue at 100% of sessions** | Projected total revenue if the treatment group payment methods were offered to 100% of traffic across treatment and control. |
| **Gross revenue** | Actual revenue (full purchase amount). This amount is influenced mainly by your treatment/control percentage selection. |
| **Conversion rate** | Conversion rate is the number of sessions with a purchase divided by the total number of eligible sessions. Eligible sessions is defined as:
- One or more treatment payment methods was eligible (for example, the customer was in a country where the payment method is accepted)
- The payment interface (Payment Element or Checkout) was rendered to the customer |
| **Average order value** | Average order value is the average purchase amount for sessions where the customer made a purchase. |

### 统计显著性

使用概览表中的指标来理解统计学意义。当试验达到预计所需会话的至少 80% 时，指标显示绿色或黄色差异。

有三种类型的指示器：

- 灰色指示器意味着您的试验没有积累足够的会话来可靠地确定统计显著性。
- 绿色指标表明处理组和对照组之间有统计学上的显著增加。
- 黄色指示器显示出处理组和对照组之间的统计学显著降低。
![灰色标记表示没有统计学意义。](https://b.stripecdn.com/docs-statics-srv/assets/gray-indicator.5480d1fb0eab4d6a046c1bd10b5de350.png)

在达到统计显著性之前
![表示统计显著性的绿色标记。](https://b.stripecdn.com/docs-statics-srv/assets/green-indicator.2c1094ab3416c65174f86d0c24b27089.png)

在达到统计显著性后

### 进行额外分析

您可以从报告页面下载原始数据以进一步分析试验结果。

我们建议按 `experiment_session_id` 分组，以避免因页面刷新等情况导致的会话重复计数。这与 A/B 测试报告计算每个会话的平均收入、转化率和平均客单价的方法是一致的。

| 尺寸 | 描述 |
| --- | --- |
| `occurred_at_day` | 会话的日期 (‘yyyyMMdd’)。 |
| `experiment_session_id` | Stripe 为每个试验会话生成的唯一 ID。会话基于 UserAgent、IP 地址和日期。 |
| `is_treatment` | 布尔值，表示结果是否被分配为处理组 (1) 或对照组 (0)。 |
| `converted` | 布尔值，指示此会话是否成功转化（1 表示转化，0 表示未转化）。 |
| `payment_method` | 实际用于购买的支付方式。 |
| `converted_transaction_count` | The number of individual transaction-level conversions in the user session. Usually this value is either 1 or 0, however, multiple conversions can occur within the same session if the same customer makes multiple purchases within the same day. |
| `rendered_transaction_count` | The number of individual transaction-level renders in the user session. This can be a number greater than 1 if a customer visits the purchase page multiple times (for example, reloads or comes back later in the day). |
| `amount_capturable` | 总交易金额。 |
| `currency` | 此交易中使用的货币类型（例如 USD、GBP、EUR）。 |
| `is_eligible_session` | 布尔值，指示该会话是否符合 A/B 测试资格（1 表示符合，0 表示不符合）。如果此字段返回 0（例如，没有符合条件的处理组支付方式），则此会话不包括在任何报告的指标中，如平均客单价或转化率。 |
| `buyer_countries` | The country or countries associated with the user session. In most cases this is a single country, but there could be multiple if the customer is traveling or changes their browser’s location settings. |
| `control_payment_method_types` | 有资格在此会话中显示的对照组支付方式的列表。 |
| `treatment_payment_method_types` | 试验组支付方式列表，该会话中符合显示条件的支付方式。 |
| `rendered_payment_methods` | 用户会话中可用的支付方式列表，包括那些隐藏在“显示更多”选择器后的方式。 |
| `visible_payment_methods` | 用户会话中可见的支付方式列表（不隐藏在溢出菜单后面，如“显示更多”）。 |
| `connected_account_id` | 与会话关联的 Connect 子账户 ID。 |

### 试验方法

A/B 测试通过比较处理组和对照组的结果来衡量[平均处理效应](https://en.wikipedia.org/wiki/Average_treatment_effect)(ATE)。当某试验结果由于随机因素的概率低于 5% 时，我们认为该试验具有统计学显著性。在统计学术语中，我们使用 [Z 检验](https://en.wikipedia.org/wiki/Z-test)来计算处理组和对照组在 5% 水平的差异，实际上就是检查差异的 95% 置信区间是否包括 0。为了确定检测影响所需的会话数量，我们根据您选择的处理组和对照组的百分比分配运行检验效能计算。该检验效能计算返回了在 5% 显著性水平下检测处理组和对照组之间 1% 差异所需的 80% 效能的会话数。

> 为了向您提供此 A/B 测试服务，我们需要从您的交易数据中分析客户的活动。我们使用客户的 IP 地址和用户代理信息来识别在结账流程中向其显示支付方式的用户是否完成了结账流程。根据您和客户适用的法律，指示我们代表您开展此活动可能需要您采取措施，例如进行披露并征得客户对该活动的同意。请咨询您的法律顾问，确保您遵守适用数据保护法律下的所有义务。

## 支持的支付方式

### 集成选项

To use A/B testing, your integration must use [dynamic payment methods](https://docs.stripe.com/payments/payment-methods/dynamic-payment-methods.md?payment-ui=payment-element#customization-features).

You can then access A/B testing if you use either of the following:

- [Payment Element Web](https://docs.stripe.com/payments/payment-element.md) with the Payment Intents API
- [Checkout](https://docs.stripe.com/payments/checkout.md) in payment mode

### 支持的支付方式

|  |
| **支付方式** | **Payment Element** | (Connect)**Payment Element** 1 |
| [ACH 直接借记](https://docs.stripe.com/payments/ach-direct-debit.md) | ✓ 支持 | - 不支持 |
| [ACSS 借记](https://docs.stripe.com/payments/acss-debit.md) | ✓ 支持 | - 不支持 |
| [Affirm](https://docs.stripe.com/payments/affirm.md) | ✓ 支持 | ✓ 支持 |
| [Afterpay (Clearpay)](https://docs.stripe.com/payments/afterpay-clearpay.md) | ✓ 支持 | ✓ 支持 |
| [支付宝](https://docs.stripe.com/payments/alipay.md) | ✓ 支持 | - 不支持 |
| [Amazon Pay](https://docs.stripe.com/payments/amazon-pay.md) | ✓ 支持 | ✓ 支持 |
| [Apple Pay](https://docs.stripe.com/apple-pay.md) | ✓ 支持 | ✓ 支持 |
| [BECS 直接借记](https://docs.stripe.com/payments/au-becs-debit.md) | ✓ 支持 | - 不支持 |
| [Bacs 直接借记](https://docs.stripe.com/payments/bacs-debit/accept-a-payment.md) | ✓ 支持 | - 不支持 |
| [Bancontact](https://docs.stripe.com/payments/bancontact.md) | ✓ 支持 | ✓ 支持 |
| [BLIK](https://docs.stripe.com/payments/blik.md) | ✓ 支持 | ✓ 支持 |
| [Boleto](https://docs.stripe.com/payments/boleto.md) | ✓ 支持 | ✓ 支持 |
| [Cash App Pay](https://docs.stripe.com/payments/cash-app-pay.md) | ✓ 支持 | ✓ 支持 |
| [Stablecoins](https://docs.stripe.com/stablecoins.md) | ✓ 支持 | ✓ 支持 |
| [EPS](https://docs.stripe.com/payments/eps.md) | ✓ 支持 | ✓ 支持 |
| [FPX](https://docs.stripe.com/payments/fpx.md) | ✓ 支持 | - 不支持 |
| [Giropay](https://docs.stripe.com/payments/giropay.md) | ✓ 支持 | ✓ 支持 |
| [Google Pay](https://docs.stripe.com/google-pay.md) | ✓ 支持 | ✓ 支持 |
| [GrabPay](https://docs.stripe.com/payments/grabpay.md) | ✓ 支持 | ✓ 支持 |
| [iDEAL](https://docs.stripe.com/payments/ideal.md) | ✓ 支持 | ✓ 支持 |
| [Klarna](https://docs.stripe.com/payments/klarna.md) | ✓ 支持 | ✓ 支持 |
| [Konbini](https://docs.stripe.com/payments/konbini.md) | ✓ 支持 | - 不支持 |
| [MobilePay](https://docs.stripe.com/payments/mobilepay.md) | ✓ 支持 | ✓ 支持 |
| [OXXO](https://docs.stripe.com/payments/oxxo.md) | ✓ 支持 | ✓ 支持 |
| [P24](https://docs.stripe.com/payments/p24.md) | ✓ 支持 | ✓ 支持 |
| [Pay by Bank](https://docs.stripe.com/payments/pay-by-bank.md) | ✓ 支持 | ✓ 支持 |
| [PayNow](https://docs.stripe.com/payments/paynow.md) | ✓ 支持 | ✓ 支持 |
| [PromptPay](https://docs.stripe.com/payments/promptpay.md) | ✓ 支持 | ✓ 支持 |
| [Revolut Pay](https://docs.stripe.com/payments/revolut-pay.md) | ✓ 支持 | ✓ 支持 |
| [SEPA 借记](https://docs.stripe.com/payments/sepa-debit.md) | ✓ 支持 | - 不支持 |
| [Swish](https://docs.stripe.com/payments/swish.md) | ✓ 支持 | ✓ 支持 |
| [TWINT](https://docs.stripe.com/payments/twint.md) | ✓ 支持 | ✓ 支持 |
| [微信支付](https://docs.stripe.com/payments/wechat-pay.md) | ✓ 支持 | - 不支持 |
| [Zip](https://docs.stripe.com/payments/zip.md) | ✓ 支持 | ✓ 支持 |

1 某些支付方式要求用户在使用该支付方式之前执行额外的非 Stripe 操作（例如身份验证、接受服务条款等）。由于直接用户可以执行这些操作，因此我们支持对这些支付方式进行 A/B 测试。然而，由于 Connect 用户无法代表其 Connect 子账户采取行动，这意味着很少或没有 Connect 子账户能够使用该支付方式，我们不支持对这些支付方式进行 A/B 测试。

### Split testing for Connect (Connect)

A/B 测试适用于 Connect 平台，但不适用于单个 Connect 子账户。设置 A/B 测试时，为对照组和处理组选择的支付方式将适用于所有符合条件的 Connect 子账户。要选择退出特定的 Connect 子账户，您可以在试验创建过程中指定一个账户 ID 列表。

平台可以允许 Connect 子账户自定义支付方式设置，以启用或禁用特定的支付方式。如果 Connect 子账户启用或禁用了任何在处理组或对照组中的支付方式，该账户的偏好将适用于处理组和对照组的会话。例如，如果一个平台在 Klarna 开启的情况下运行一项试验，而一个 Connect 子账户关闭了 Klarna，那么 Klarna 就永远不会显示为该 Connect 子账户的用户可用的支付方式。
