Payment Links
A Payment Link is a shareable, reusable page for accepting payments. You can send the link to your customers, and they can use it to purchase products, subscribe to services, or make donations without you needing to build a custom payment interface. Each Payment Link object provides a unique URL that directs users to a secure, hosted payment page.
This is useful for scenarios like selling a single product, setting up a subscription, or collecting donations with minimal integration effort.
The Payment Link Object#
A Payment Link object contains all the details needed to present a payment page, including line items, currency, and behavior after payment completion.
{
"id": "plink_xxxxxxxxxxxxxx",
"active": true,
"name": "Premium Subscription",
"line_items": [
{
"price_id": "price_yyyyyyyyyyyyyy",
"quantity": 1,
"adjustable_quantity": {
"enabled": false
},
"price": {
"id": "price_yyyyyyyyyyyyyy",
"product_id": "prod_zzzzzzzzzzzzzz",
"active": true,
"type": "recurring",
"unit_amount": "29.99",
"currency_id": "usd_12345",
"recurring": {
"interval": "month",
"interval_count": 1
},
"product": {
"id": "prod_zzzzzzzzzzzzzz",
"name": "Premium Tier"
}
}
}
],
"currency_id": "usd_12345",
"after_completion": {
"type": "hosted_confirmation",
"hosted_confirmation": {
"custom_message": "Thank you for subscribing!"
}
},
"allow_promotion_codes": true,
"customer_creation": "always",
"submit_type": "pay",
"url": "https://example.com/pay/plink_xxxxxxxxxxxxxx",
"livemode": false,
"created_at": "2023-10-27T10:00:00.000Z",
"updated_at": "2023-10-27T10:00:00.000Z",
"metadata": {}
}
Create a Payment Link#
Creates a new Payment Link object.
payment.paymentLinks.create(params)
Parameters
Name | Type | Description |
---|---|---|
|
| Required. A list of line item objects, each representing a product or price. See details below. |
|
| Optional. The internal name for the payment link. Max 255 characters. |
|
| Optional. A unique string to identify the payment link, which can be used to retrieve it later. Max 128 characters. |
|
| Optional. The ID of the currency for the payment. If not provided, the default currency is used. |
|
| Optional. Defines the behavior after a successful payment. See details below. |
|
| Optional. Toggles whether promotion codes can be used with this link. Defaults to |
|
| Optional. Toggles subscription grouping. Only supported for stake-free subscriptions. Defaults to |
|
| Optional. Configuration for NFT minting after payment. See details below. |
|
| Optional. Manages the collection of customer consent for promotions and terms of service. See details below. |
|
| Optional. A set of key-value pairs that you can attach to the object. |
line_items
Object Properties
Name | Type | Description |
---|---|---|
|
| Required. The ID of the |
|
| Required. The quantity of the price to be purchased. Must be at least 1. |
|
| Optional. Configuration to allow customers to change the quantity on the payment page. See details below. |
adjustable_quantity
Object Properties
Name | Type | Description |
---|---|---|
|
| Required. If |
|
| Optional. The minimum quantity the customer can select. Must be less than |
|
| Optional. The maximum quantity the customer can select. |
after_completion
Object Properties
Name | Type | Description |
---|---|---|
|
| Required. The type of action to perform. Can be |
|
| Optional. Displays a confirmation message on a hosted page. Used when |
|
| Optional. Redirects the customer to a specific URL. Used when |
hosted_confirmation
Object Properties
Name | Type | Description |
---|---|---|
|
| Optional. A custom message to display to the customer. Max 200 characters. |
redirect
Object Properties
Name | Type | Description |
---|---|---|
|
| Required. The URL to redirect the customer to. Max 2048 characters. |
nft_mint_settings
Object Properties
Name | Type | Description |
---|---|---|
|
| Required. Set to |
|
| Optional. The factory address required for minting. Required if |
consent_collection
Object Properties
Name | Type | Description |
---|---|---|
|
| Required. Determines how promotional consent is collected. Can be |
|
| Required. Determines how terms of service consent is collected. Can be |
Returns
Returns the created TPaymentLink
object.
Example Request
const paymentLink = await payment.paymentLinks.create({
name: 'Monthly Pro Plan',
line_items: [
{
price_id: 'price_yyyyyyyyyyyyyy',
quantity: 1,
},
],
after_completion: {
type: 'hosted_confirmation',
hosted_confirmation: {
custom_message: 'Thanks for your subscription!',
},
},
allow_promotion_codes: true,
});
console.log(paymentLink);
Example Response
{
"id": "plink_xxxxxxxxxxxxxx",
"active": true,
"name": "Monthly Pro Plan",
"line_items": [
{
"price_id": "price_yyyyyyyyyyyyyy",
"quantity": 1
}
],
"after_completion": {
"type": "hosted_confirmation",
"hosted_confirmation": {
"custom_message": "Thanks for your subscription!"
}
},
"allow_promotion_codes": true,
"url": "https://example.com/pay/plink_xxxxxxxxxxxxxx",
"livemode": false
}
Retrieve a Payment Link#
Retrieves the details of an existing Payment Link by its ID or lookup_key
.
payment.paymentLinks.retrieve(id)
Parameters
Name | Type | Description |
---|---|---|
|
| Required. The unique identifier ( |
Returns
Returns the TPaymentLinkExpanded
object if found, otherwise returns a 404 error.
Example Request
const paymentLinkId = 'plink_xxxxxxxxxxxxxx';
const paymentLink = await payment.paymentLinks.retrieve(paymentLinkId);
console.log(paymentLink);
Example Response
{
"id": "plink_xxxxxxxxxxxxxx",
"active": true,
"name": "Monthly Pro Plan",
"line_items": [
{
"price_id": "price_yyyyyyyyyyyyyy",
"quantity": 1,
"price": {
"id": "price_yyyyyyyyyyyyyy",
"product_id": "prod_zzzzzzzzzzzzzz",
"type": "recurring",
"unit_amount": "12.00"
}
}
],
"url": "https://example.com/pay/plink_xxxxxxxxxxxxxx",
"livemode": false
}
Update a Payment Link#
Updates an existing Payment Link. Only active payment links can be updated.
payment.paymentLinks.update(id, params)
Parameters
Name | Type | Description |
---|---|---|
|
| Required. The ID of the Payment Link to update. |
|
| Optional. The updated name for the payment link. |
|
| Optional. Whether the link is active. Use the |
|
| Optional. An updated list of line items. |
|
| Optional. Updated behavior after a successful payment. |
|
| Optional. Toggles whether promotion codes can be used. |
|
| Optional. A new set of key-value pairs. This will replace the existing metadata, not merge with it. |
Returns
Returns the updated TPaymentLink
object.
Example Request
const paymentLinkId = 'plink_xxxxxxxxxxxxxx';
const updatedLink = await payment.paymentLinks.update(paymentLinkId, {
name: 'Updated Monthly Pro Plan',
metadata: { order_id: '6735' },
});
console.log(updatedLink);
Example Response
{
"id": "plink_xxxxxxxxxxxxxx",
"active": true,
"name": "Updated Monthly Pro Plan",
"metadata": { "order_id": "6735" },
"url": "https://example.com/pay/plink_xxxxxxxxxxxxxx"
}
List Payment Links#
Returns a paginated list of your Payment Links.
payment.paymentLinks.list(params)
Parameters
Name | Type | Description |
---|---|---|
|
| Optional. Filters the list to return only active or inactive payment links. |
|
| Optional. Set to |
|
| Optional. Filters by live or test mode. |
|
| Optional. The page number for pagination. Defaults to |
|
| Optional. The number of items per page. Defaults to |
|
| Optional. An array defining the sort order, e.g., |
Returns
Returns a paginated object containing a list
of TPaymentLinkExpanded
objects, the total count
, and paging
information.
Example Request
const paymentLinks = await payment.paymentLinks.list({
active: true,
pageSize: 5,
});
console.log(`Found ${paymentLinks.count} active payment links.`);
console.log(paymentLinks.list);
Example Response
{
"count": 50,
"list": [
{
"id": "plink_xxxxxxxxxxxxxx",
"active": true,
"name": "Monthly Pro Plan"
},
{
"id": "plink_zzzzzzzzzzzzzz",
"active": true,
"name": "Annual Premium Plan"
}
],
"paging": {
"page": 1,
"pageSize": 5
}
}
Archive a Payment Link#
Deactivates a Payment Link, making it unusable for new payments. This action cannot be undone, and archived links cannot be updated.
payment.paymentLinks.archive(id)
Parameters
Name | Type | Description |
---|---|---|
|
| Required. The ID of the Payment Link to archive. |
Returns
Returns the TPaymentLink
object with its active
status set to false
.
Example Request
const paymentLinkId = 'plink_xxxxxxxxxxxxxx';
const archivedLink = await payment.paymentLinks.archive(paymentLinkId);
console.log(`Archived: ${archivedLink.id}, Active: ${archivedLink.active}`);
Example Response
{
"id": "plink_xxxxxxxxxxxxxx",
"active": false,
"name": "Monthly Pro Plan"
}
This marks the payment link as inactive, preventing any new payments.