Request payment anywhere, anytime with Payment Links
Tags: stripe, payment, ecommerce
Published: 2022-03-31 21:55:16

---
title: Request payment anywhere, anytime with Payment Links
published: true
description: Learn how to request payment in seconds with Payment Links
tags: stripe, payment, ecommerce
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wm8zei0y4vunx62uc8jl.png
---

Did you know you can request payment from someone with little to no code? That’s what [Payment Links](https://stripe.com/payments/payment-links) are about.

With Payment Links, you can share a link to a generated payment page, with anyone and as many times as you’d like.

Let’s go through a couple of ways to do this.

## No-code solution via the Stripe dashboard

From the [Stripe dashboard](https://dashboard.stripe.com/), navigate to the Payments tab, select Payment Links in the left nav and click on the “Create payment link” button.

![Stripe dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mrmtap303k0zfe6jvhwc.png)

From there, select one or multiple products you'd like to create a Payment Link for, select a quantity or let customers select it. There are additional options if you'd like to allow promotion codes or collect some customers personal details, but that's pretty much it!

In the preview section, you can toggle views between desktop and mobile to see how the payment page would look like on different devices.

![Gif showing the preview going from desktop view to mobile view](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f651zjyh8h4bm5ai46m3.gif)

Finally, you can decide if you'd like to show a confirmation page after the payment is confirmed.

Once you're happy with it, click on the "Create link" button and you now have a link you can copy and paste anywhere to request payment for a product or subscription! 🎉 Additionally, you can also download the image of a QR code so your customers can pay by scanning it.

![GIF showing the QR code button on the Payment Link page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n17ghp14zsis0oqlpbmk.gif)


## In less than 5 lines of code

If you'd rather automate the process of creating Payment Links, you can do it with a very small amount of code.

For example, if you're using Node.js, here's the code you will need:

```javascript
const stripe = require('stripe')('YOUR-STRIPE-SECRET-KEY');

const paymentLink = await stripe.paymentLinks.create({
  line_items: [{price: '{{PRICE_ID}}', quantity: 1}],
});
```

You can find your secret key by [visiting the dashboard](https://dashboard.stripe.com/apikeys). Price IDs can be found on product pages, under the Pricing section. A price ID starts with `price_`.

When running this code sample, the value of the `paymentLink` variable will be an object of the following shape:

```js
{
  id: 'plink_5KhHxFLbMooaWdpX1j0LsyAAA',
  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 },
  billing_address_collection: 'auto',
  livemode: false,
  metadata: {},
  on_behalf_of: null,
  payment_method_types: null,
  phone_number_collection: { enabled: false },
  shipping_address_collection: null,
  subscription_data: null,
  transfer_data: null,
  url: 'https://buy.stripe.com/test_9PT4gl7RY6ACCCC8wx'
}
```

If Node.js isn't the language you're the most familiar with, no problem, we have code samples available in more languages [in our docs](https://stripe.com/docs/payments/payment-links/api#create-link).

Alternatively, if you'd like to test this functionality quickly, you can also run the following curl command:

```bash
curl https://api.stripe.com/v1/payment_links \
  -u {{YOUR-STRIPE-API-KEY}} \
  -d "line_items[0][price]"="{{PRICE_ID}}" \
  -d "line_items[0][quantity]"=1
```

## Deactivating a payment link

Finally, an important thing to note is that, after creating a payment link, you cannot delete it but you can deactivate it by updating the status `active` to `false`.

You can do this either by doing an API request or directly from the dashboard.

### Deactivating via API request

Updating the details of a payment link using the API can be done by calling the `update` method, passing the payment link ID and the object `{active: false}`.

```js
const stripe = require('stripe')('YOUR-STRIPE-API-KEY');

const paymentLink = await stripe.paymentLinks.update(
  'plink_5KhHxFLbMooaWdpX1j0LsyAAA',
  {active: false}
);
```

### Deactivating via the dashboard

Using the dashboard, navigate to the [Payment Links page](https://dashboard.stripe.com/payment-links) where you should see a list of your payment links.

On the far right of each row, click on the ellipsis and click on "Deactivate".

![Screenshot of the payment links list, showing the Deactivate option](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lubfg3lay0r0qxb32l9x.png)


After being deactivated, a payment link will redirect to an expiration page so customers will no longer be able to complete a purchase using this link.

---

This post covered how to create a simple payment link but if you'd like to learn more about the different additional options available, feel free to check [our docs](https://stripe.com/docs/payments/payment-links/api)!

### Stay connected

In addition, you can stay up to date with Stripe in a few ways:
📣 Follow us on [Twitter](https://twitter.com/StripeDev)
💬 Join the official [Discord server](https://discord.com/invite/RuJnSBXrQn)
📺 Subscribe to our [Youtube channel](https://www.youtube.com/StripeDevelopers)
📧 Sign up for the [Dev Digest](https://go.stripe.global/dev-digest)