Payment links

Learn how to accept payments without building a custom marketplace.

Building an online checkout experience is simple with payment links, which can be generated via the API. Once created, you'll receive a URL that you can share with customers or use in a custom integration. Options such as adjustable pricing, limited usages, and expiration are also customizable. You can try the demo below here.

2660

Create a payment link with the API

To create a payment link, you'll need to specify the prices a customer will pay for at checkout. This can be done by passing objects containing price and quantity to line_items, with each element representing a different item. There is no limit to the number of line items you can pass.

const { Pluto } = require('@plutohq/pluto-node');
const pluto = new Pluto(process.env.PLUTO_SECRET_KEY);

const paymentLink = await pluto.paymentLinks.create({
  line_items: [
    { price: 'price_gDBPRx0dSyhyKk0SzMzrT', quantity: 1 },
    { price: 'price_SGYekZQ7DAc2a8W8WQdkM', quantity: 1 },
  ],
});
curl https://api.pluto.co/v1/payment_links \
    -u PLUTO_SECRET_KEY: \
  -d "line_items[0][price]"="price_gDBPRx0dSyhyKk0SzMzrT" \
  -d "line_items[0][quantity]"=1 \
  -d "line_items[1][price]"="price_SGYekZQ7DAc2a8W8WQdkM" \
  -d "line_items[1][price]"=1 \

📘

Payment links with recurring prices

Currently, payment links only support one-time payments, not subscriptions. However, this functionality will be released in a future update.

Limit usages

Inventory control can be enabled by passing max_usages to a payment link. Pluto calculates the remaining inventory by subtracting pending and successful checkouts from the maximum usages of the payment link. If a user attempts to purchase and their checkout fails, the inventory will be re-incremented. Customers who attempt to pay after the inventory has been depleted will be shown an out-of-stock error.

const { Pluto } = require('@plutohq/pluto-node');
const pluto = new Pluto(process.env.PLUTO_SECRET_KEY);

const paymentLink = await pluto.paymentLinks.create({
  line_items: [
    { price: '{{PRICE_ID}}', quantity: 1 },
  ],
  max_usages: 10,
});
curl https://api.pluto.co/v1/payment_links \
    -u PLUTO_SECRET_KEY: \
  -d "line_items[0][price]"="{{PRICE_ID}}" \
  -d "line_items[0][quantity]"=1 \
  -d "max_usages"=10

Set an expiration date

Pass a date to the expires_at field to configure when the payment link should be deactivated.

const { Pluto } = require('@plutohq/pluto-node');
const pluto = new Pluto(process.env.PLUTO_SECRET_KEY);

const paymentLink = await pluto.paymentLinks.create({
  line_items: [
    { price: '{{PRICE_ID}}', quantity: 1 },
  ],
  expiration_date: new Date(),
});
curl https://api.pluto.co/v1/payment_links \
    -u PLUTO_SECRET_KEY: \
  -d "line_items[0][price]"="{{PRICE_ID}}" \
  -d "line_items[0][quantity]"=1 \
  -d "expiration_date"=1662069298740

Allow customers to set the price at checkout

Passing an adjustable price to line_items will allow customers to set the unit cost of a product at checkout. For more information, see adjustable pricing.

Deactivate a payment link

Deleting a payment link will render it inactive, preventing customers from accessing the link.

const { Pluto } = require('@plutohq/pluto-node');
const pluto = new Pluto(process.env.PLUTO_SECRET_KEY);

const paymentLink = await pluto.paymentLinks.delete('{{PAYMENT_LINK_ID}}');

Set an application fee (Connect only)

Platform accounts creating payment links on the behalf of Pluto Connect accounts can pass an application_fee_percent. This fee will be paid out to the platform account any time a customer successfully checks out using the link.

const { Pluto } = require('@plutohq/pluto-node');
const pluto = new Pluto(process.env.PLUTO_SECRET_KEY);

const paymentLink = await pluto.paymentLinks.create({
  line_items: [
    { price: '{{PRICE_ID}}', quantity: 1 },
  ],
  application_fee_percent: 5,
}, { plutoAccount: '{{CONNECT_ACCOUNT_ID}}' });
curl https://api.pluto.co/v1/payment_links \
    -u PLUTO_SECRET_KEY: \
  -d "line_items[0][price]"="{{PRICE_ID}}" \
  -d "line_items[0][quantity]"=1 \
  -d "application_fee_percent"=5