# Update a payment link

Updates a payment link.

## Prerequisites

Before you can run the following code snippet, you need to call these APIs with the provided parameters to set up the prerequisite API object(s).

1. createPrice
POST /v1/prices {"currency":"usd","unit_amount":1000,"recurring":{"interval":"month"},"product_data":{"name":"Gold Plan"}}
2. createPaymentLink
POST /v1/payment_links {"line_items":[{"price":"${node.prerequisites.createPrice.createPrice:id}","quantity":1}]}

## Request

```curl
curl https://api.stripe.com/v1/payment_links/{{PAYMENT_LINK_ID}} \
  -u "<<YOUR_SECRET_KEY>>" \
  -d "metadata[order_id]=6735"
```

### Response

```json
{
  "id": "plink_1MoC3ULkdIwHu7ixZjtGpVl2",
  "object": "payment_link",
  "active": true,
  "after_completion": {
    "hosted_confirmation": {
      "custom_message": null
    },
    "type": "hosted_confirmation"
  },
  "allow_promotion_codes": false,
  "application_fee_amount": null,
  "application_fee_percent": null,
  "automatic_tax": {
    "enabled": false,
    "liability": null
  },
  "billing_address_collection": "auto",
  "consent_collection": null,
  "currency": "usd",
  "custom_fields": [],
  "custom_text": {
    "shipping_address": null,
    "submit": null
  },
  "customer_creation": "if_required",
  "invoice_creation": {
    "enabled": false,
    "invoice_data": {
      "account_tax_ids": null,
      "custom_fields": null,
      "description": null,
      "footer": null,
      "issuer": null,
      "metadata": {},
      "rendering_options": null
    }
  },
  "livemode": false,
  "metadata": {
    "order_id": "6735"
  },
  "on_behalf_of": null,
  "payment_intent_data": null,
  "payment_method_collection": "always",
  "payment_method_types": null,
  "phone_number_collection": {
    "enabled": false
  },
  "shipping_address_collection": null,
  "shipping_options": [],
  "submit_type": "auto",
  "subscription_data": {
    "description": null,
    "invoice_settings": {
      "issuer": {
        "type": "self"
      }
    },
    "trial_period_days": null
  },
  "tax_id_collection": {
    "enabled": false
  },
  "transfer_data": null,
  "url": "https://buy.stripe.com/test_cN25nr0iZ7bUa7meUY"
}
```

## Returns

Updated payment link.

## Parameters

- `active` (boolean, optional)
  Whether the payment link’s `url` is active. If `false`, customers visiting the URL will be shown a page saying that the link has been deactivated.

- [`after_completion`](https://docs.stripe.com/api/payment-link/update.md?query=after_completion&api-version=2024-10-28.acacia) (object, optional)
  Behavior after the purchase is complete.

- `allow_promotion_codes` (boolean, optional)
  Enables user redeemable promotion codes.

- [`automatic_tax`](https://docs.stripe.com/api/payment-link/update.md?query=automatic_tax&api-version=2024-10-28.acacia) (object, optional)
  Configuration for automatic tax collection.

- `billing_address_collection` (enum, optional)
  Configuration for collecting the customer’s billing address. Defaults to `auto`.
Possible enum values:
  - `auto`
    Checkout will only collect the billing address when necessary. When using [automatic_tax](https://docs.stripe.com/docs/api/checkout/sessions/object.md?api-version=2024-10-28.acacia#checkout_session_object-automatic_tax-enabled), Checkout will collect the minimum number of fields required for tax calculation.

  - `required`
    Checkout will always collect the customer’s billing address.

- [`custom_fields`](https://docs.stripe.com/api/payment-link/update.md?query=custom_fields&api-version=2024-10-28.acacia) (array of objects, optional)
  Collect additional information from your customer using custom fields. Up to 3 fields are supported.

- [`custom_text`](https://docs.stripe.com/api/payment-link/update.md?query=custom_text&api-version=2024-10-28.acacia) (object, optional)
  Display additional text for your customers using custom text.

- `customer_creation` (enum, optional)
  Configures whether [checkout sessions](https://docs.stripe.com/docs/api/checkout/sessions.md?api-version=2024-10-28.acacia) created by this payment link create a [Customer](https://docs.stripe.com/docs/api/customers.md?api-version=2024-10-28.acacia).
Possible enum values:
  - `always`
    The Checkout Session will always create a [Customer](https://docs.stripe.com/docs/api/customers.md?api-version=2024-10-28.acacia) when a Session confirmation is attempted.

  - `if_required`
    The Checkout Session will only create a [Customer](https://docs.stripe.com/docs/api/customers.md?api-version=2024-10-28.acacia) if it is required for Session confirmation. Currently, only `subscription` mode Sessions and `payment` mode Sessions with [post-purchase invoices enabled](https://docs.stripe.com/docs/receipts.md?payment-ui=checkout&api-version=2024-10-28.acacia#paid-invoices) require a Customer.

- `inactive_message` (string, optional)
  The custom message to be displayed to a customer when a payment link is no longer active.

- [`invoice_creation`](https://docs.stripe.com/api/payment-link/update.md?query=invoice_creation&api-version=2024-10-28.acacia) (object, optional)
  Generate a post-purchase Invoice for one-time payments.

- [`line_items`](https://docs.stripe.com/api/payment-link/update.md?query=line_items&api-version=2024-10-28.acacia) (array of objects, optional)
  The line items representing what is being sold. Each line item represents an item being sold. Up to 20 line items are supported.

- `metadata` (object, optional)
  Set of [key-value pairs](https://docs.stripe.com/docs/api/metadata.md?api-version=2024-10-28.acacia) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`. Metadata associated with this Payment Link will automatically be copied to [checkout sessions](https://docs.stripe.com/docs/api/checkout/sessions.md?api-version=2024-10-28.acacia) created by this payment link.

- [`payment_intent_data`](https://docs.stripe.com/api/payment-link/update.md?query=payment_intent_data&api-version=2024-10-28.acacia) (object, optional)
  A subset of parameters to be passed to PaymentIntent creation for Checkout Sessions in `payment` mode.

- `payment_method_collection` (enum, optional)
  Specify whether Checkout should collect a payment method. When set to `if_required`, Checkout will not collect a payment method when the total due for the session is 0.This may occur if the Checkout Session includes a free trial or a discount.

  Can only be set in `subscription` mode. Defaults to `always`.

  If you’d like information on how to collect a payment method outside of Checkout, read the guide on [configuring subscriptions with a free trial](https://docs.stripe.com/docs/payments/checkout/free-trials.md?api-version=2024-10-28.acacia).
Possible enum values:
  - `always`
    The Checkout Session will always collect a PaymentMethod.

  - `if_required`
    The Checkout Session will only collect a PaymentMethod if there is an amount due.

- `payment_method_types` (array of enums, optional)
  The list of payment method types that customers can use. Pass an empty string to enable dynamic payment methods that use your [payment method settings](https://dashboard.stripe.com/settings/payment_methods).

- [`restrictions`](https://docs.stripe.com/api/payment-link/update.md?query=restrictions&api-version=2024-10-28.acacia) (object, optional)
  Settings that restrict the usage of a payment link.

- [`shipping_address_collection`](https://docs.stripe.com/api/payment-link/update.md?query=shipping_address_collection&api-version=2024-10-28.acacia) (object, optional)
  Configuration for collecting the customer’s shipping address.

- [`subscription_data`](https://docs.stripe.com/api/payment-link/update.md?query=subscription_data&api-version=2024-10-28.acacia) (object, optional)
  When creating a subscription, the specified configuration data will be used. There must be at least one line item with a recurring price to use `subscription_data`.

- [`tax_id_collection`](https://docs.stripe.com/api/payment-link/update.md?query=tax_id_collection&api-version=2024-10-28.acacia) (object, optional)
  Controls tax ID collection during checkout.
