# Link with Checkout

Use Link with Stripe's prebuilt checkout page.

You can also use Link with [Payment Links](https://docs.stripe.com/payment-links.md).

Checkout is a [prebuilt payment form](https://docs.stripe.com/payments/checkout.md) that you can embed on your site or use as a Stripe-hosted payment page. Use Link with Checkout to allow your customers to securely save and reuse their payment information. For logged-in customers already using Link, it autofills this information regardless of whether they initially saved it on a different business’s checkout page.

Checkout supports Link with no additional fees, and the same [pricing](https://stripe.com/pricing) applies as for other card payments. For information about how your payment integration affects Link, see [Link in different payment integrations](https://docs.stripe.com/payments/link/link-payment-integrations.md).
![将 Link 添加到您预先构建的结账页面](https://b.stripecdn.com/docs-statics-srv/assets/link-in-checkout.2eb9f8d06da3dca74af9b81fa7524049.png)

在预置结账页面中添加 Link

## Before you begin

Build an integration to [accept a payment](https://docs.stripe.com/payments/accept-a-payment.md?integration=checkout) using Checkout.

## Enable Link in Checkout

Accept payments with Link using information your customer stores in the [Link app](https://link.com/). When you receive a payment from a customer using Link in Checkout, the `payment_method.type` listed for the payment is `link`. To add Link to your [Checkout integration](https://docs.stripe.com/payments/accept-a-payment.md?integration=checkout), create a Checkout Session with `link` as a payment method type.

#### Use dynamic payment methods

Use [dynamic payment methods](https://docs.stripe.com/payments/payment-methods/dynamic-payment-methods.md) to increase conversion by showing the most relevant payment methods to your customers. If you collect card details for [future usage with Setup Intents](https://docs.stripe.com/payments/save-and-reuse.md), list payment methods manually instead of using dynamic payment methods.

To add Link as a payment method:

1. Enable the Link payment method from your [payment method settings](https://dashboard.stripe.com/settings/payment_methods).
1. 如果您的现有集成可手动列出支付方式，请从您的集成中删除 [payment_method_types](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-payment_method_types)参数。
![Preview of Link enabled as payment method in the Stripe Dashboard](https://b.stripecdn.com/docs-statics-srv/assets/enable-link-stripe-dashboard.1bd2411da48c323997c27a6dabee9b4c.png)

Link enabled as a payment method in the Stripe Dashboard

After you remove the `payment_method_types` parameter from your integration, some payment methods turn on automatically, including cards and wallets. The currency parameter restricts the payment methods that the customer sees during the checkout session.

```curl
curl https://api.stripe.com/v1/checkout/sessions \
  -u "<<YOUR_SECRET_KEY>>:" \
  -d "line_items[0][price_data][unit_amount]=2000" \
  -d "line_items[0][price_data][product_data][name]=T-shirt" \
  -d "line_items[0][price_data][currency]=usd" \
  -d "line_items[0][quantity]=1" \
  -d mode=payment \
  --data-urlencode "success_url=https://example.com/success"
```

#### Manually list payment methods

When creating a new [Checkout Session](https://docs.stripe.com/api/checkout/sessions.md), you need to:

1. Add `link` to the list of `payment_method_types`.
1. Make sure `card` is also included in the list of `payment_method_types`.
1. Make sure all your `line_items` use the same currency.

#### Ruby

```ruby
client.v1.checkout.sessions.create({
  mode: 'payment',payment_method_types: ['card', 'link'],
  line_items: [{
    price_data: {
      currency: 'usd',
      product_data: {
        name: 'T-shirt',
      },
      unit_amount: 2000,
    },
    quantity: 1,
  }],
  success_url: 'https://example.com/success',
})
```

## Test the integration

> 不要在*沙盒* (A sandbox is an isolated test environment that allows you to test Stripe functionality in your account without affecting your live integration. Use sandboxes to safely experiment with new features and changes) Link 账户中存储真实用户数据。应将这些测试账户视为公开可用，因为它们与您的可发布密钥相关联。

目前，Link 仅支持信用卡、借记卡以及符合条件的美国银行账户购买。Link 需要进行[域名注册](https://docs.stripe.com/payments/payment-methods/pmd-registration.md)。

您可以使用任意有效的电子邮件地址为 Link 创建沙盒账户。下表展示了 Stripe 接受用于沙盒账户身份验证的固定一次性验证码值：

| 值             | 结果           |
| ------------- | ------------ |
| 非下方所列的任意 6 位数 | 成功           |
| 000001        | 错误，验证码无效     |
| 000002        | 错误，验证码已过期    |
| 000003        | 错误，超过了最大尝试次数 |

### 多个资金来源

由于 Stripe 增加了额外的资金来源支持，因此您不需要更新您的集成。Stripe 会自动为它们提供与卡和银行账户支付相同的交易结算时间和担保。

## Link for Connect platforms 

Link is automatically available to any connected account that uses Checkout through a Connect platform integration.

- If you’re a Connect platform, you can manage Link for your platform account through [Link settings](https://dashboard.stripe.com/settings/link) in your Dashboard. Your connected accounts manage Link from within their own Dashboard settings.
- If you’re a connected account processing payments through a Connect platform, you can manage Link for both payments processed through a platform and payments processed without a platform in your Link settings in the Dashboard.

## Disable Link 

You can disable Link in the Stripe Dashboard [payment method settings](https://dashboard.stripe.com/settings/payment_methods). You must change the settings for Link individually for each [payment method configuration](https://docs.stripe.com/payments/payment-method-configurations.md).

After you disable Link for a payment method configuration, the change might take a few minutes to take effect on your website.

## See also

- [Stripe Checkout](https://docs.stripe.com/payments/checkout.md)
- [How Checkout works](https://docs.stripe.com/payments/checkout/how-checkout-works.md)
- [Quickstart](https://docs.stripe.com/checkout/quickstart.md)
