Skip to main content

Payment Links

A Payment Link is a shareable, reusable page to sell a product or service. You can create a link for a specific set of products and prices and share it with multiple customers through various channels. This allows for quick and easy payment collection without building a full checkout flow.

A Payment Link object contains all the information necessary to present a payment page to a customer. Here are some of its key attributes:

AttributeTypeDescription
idstringUnique identifier for the payment link object.
urlstringThe URL for the payment page. Customers can be redirected to this URL to make a payment.
activebooleanWhether the payment link is currently active and can be used for payments.
line_itemsarrayThe list of products and prices that will be purchased.
after_completionobjectBehavior after the purchase is complete, such as redirecting to a URL or showing a confirmation message.
allow_promotion_codesbooleanEnables the use of promotion codes on the payment page.
currency_idstringThe three-letter ISO currency code.
metadataobjectA set of key-value pairs that you can attach to the object. Useful for storing additional information.
created_atstringTimestamp of when the object was created.

Creates a new payment link.

Create a Payment Link

javascript
const paymentLink = await payment.paymentLinks.create({
  line_items: [
    {
      price_id: 'price_xxxxxxxxxxxxxx',
      quantity: 1,
      adjustable_quantity: {
        enabled: true,
        minimum: 1,
        maximum: 10,
      },
    },
  ],
  after_completion: {
    type: 'hosted_confirmation',
    hosted_confirmation: {
      custom_message: 'Thanks for your purchase!',
    },
  },
  metadata: {
    order_id: '6735',
  },
});

Parameters

NameTypeDescription
line_itemsarrayRequired. A list of line item objects, each representing a product to be purchased. See details below.
namestringAn optional internal name for the payment link.
lookup_keystringAn optional, unique string that can be used to retrieve the payment link.
currency_idstringThe ID of the currency for this payment link. If not provided, the default currency is used.
after_completionobjectSpecifies the behavior after a successful payment. See details below.
allow_promotion_codesbooleanSet to true to allow promotion codes to be redeemed. Defaults to false.
consent_collectionobjectConfigures consent collection for promotions and terms of service. See details below.
nft_mint_settingsobjectSettings for minting an NFT after the payment is complete. See details below.
metadataobjectA set of key-value pairs to store additional information.

line_items Object Properties

NameTypeDescription
price_idstringRequired. The ID of the price object.
quantitynumberRequired. The quantity of the product being purchased. Must be at least 1.
adjustable_quantityobjectConfiguration that allows the customer to adjust the quantity of this line item on the payment page. See details below.

line_items.adjustable_quantity Object Properties

NameTypeDescription
enabledbooleanRequired. Set to true to allow quantity adjustments.
minimumnumberThe minimum quantity the customer can select. Must be 0 or greater.
maximumnumberThe maximum quantity the customer can select. Must be greater than minimum.

after_completion Object Properties

NameTypeDescription
typestringRequired. The type of completion behavior. Can be hosted_confirmation or redirect.
hosted_confirmationobjectDisplays a hosted confirmation message to the customer. Used when type is hosted_confirmation.
redirectobjectRedirects the customer to a specific URL. Used when type is redirect.

after_completion.hosted_confirmation Object Properties

NameTypeDescription
custom_messagestringAn optional custom message to display to the customer. Max 200 characters.

after_completion.redirect Object Properties

NameTypeDescription
urlstringThe URL to redirect the customer to. Max 2048 characters.

consent_collection Object Properties

NameTypeDescription
promotionsstringDetermines how to handle consent for promotional communications. Can be none, opt_in, or opt_out.
terms_of_servicestringDetermines how to handle consent for terms of service. Can be none, opt_in, or opt_out.

nft_mint_settings Object Properties

NameTypeDescription
enabledbooleanRequired. Set to true to enable NFT minting after payment.
factorystringThe factory address for minting the NFT. Required if enabled is true.

Returns

Returns a TPaymentLinkExpanded object if the creation is successful.

Response

json
{
  "id": "plink_xxxxxxxxxxxxxx",
  "active": true,
  "url": "https://payment.arcblock.io/pl/plink_xxxxxxxxxxxxxx",
  "line_items": [
    {
      "price_id": "price_xxxxxxxxxxxxxx",
      "quantity": 1,
      "adjustable_quantity": {
        "enabled": true,
        "minimum": 1,
        "maximum": 10
      }
    }
  ],
  "after_completion": {
    "type": "hosted_confirmation",
    "hosted_confirmation": {
      "custom_message": "Thanks for your purchase!"
    }
  },
  "metadata": {
    "order_id": "6735"
  }
}

Retrieves the details of an existing payment link.

Retrieve a Payment Link

javascript
const paymentLinkId = 'plink_xxxxxxxxxxxxxx';
const paymentLink = await payment.paymentLinks.retrieve(paymentLinkId);

Parameters

NameTypeDescription
idstringRequired. The unique identifier or lookup_key of the payment link to retrieve.

Returns

Returns a TPaymentLinkExpanded object, which includes expanded details about the line items and their associated prices and products.

Response

json
{
  "id": "plink_xxxxxxxxxxxxxx",
  "active": true,
  "url": "https://payment.arcblock.io/pl/plink_xxxxxxxxxxxxxx",
  "line_items": [
    {
      "price_id": "price_xxxxxxxxxxxxxx",
      "quantity": 1,
      "price": {
        "id": "price_xxxxxxxxxxxxxx",
        "product_id": "prod_yyyyyyyyyyyyyy",
        "unit_amount": "10.00",
        "product": {
          "id": "prod_yyyyyyyyyyyyyy",
          "name": "My Awesome Product"
        }
      }
    }
  ]
}

Updates a payment link by setting the values of the parameters passed. Any parameters not provided will be left unchanged. Note that you cannot update an archived payment link.

Update a Payment Link

javascript
const paymentLinkId = 'plink_xxxxxxxxxxxxxx';
const updatedPaymentLink = await payment.paymentLinks.update(paymentLinkId, {
  active: false,
  metadata: {
    order_id: '6735-updated'
  }
});

Parameters

NameTypeDescription
idstringRequired. The ID of the payment link to update.
...The second argument is an object containing the fields to update. It supports many of the same parameters as the create method, such as active, line_items, metadata, and after_completion. All fields are optional.

Returns

Returns the updated TPaymentLink object.

Response

json
{
  "id": "plink_xxxxxxxxxxxxxx",
  "active": false,
  "metadata": {
    "order_id": "6735-updated"
  }
}

Returns a list of your payment links.

List Payment Links

javascript
const paymentLinks = await payment.paymentLinks.list({
  active: true,
  limit: 5
});

Parameters

NameTypeDescription
activebooleanFilters the list to only include active or inactive payment links.
donationstringSet to 'hide' to exclude payment links where submit_type is donate.
pagenumberThe page number for pagination. Defaults to 1.
pageSizenumberThe number of objects to return per page. Defaults to 20.
orderstringThe order to sort the results by. For example, 'created_at:DESC'.

Returns

Returns a paginated object containing a list of TPaymentLinkExpanded objects.

Response

json
{
  "count": 15,
  "list": [
    {
      "id": "plink_xxxxxxxxxxxxxx",
      "active": true
    },
    {
      "id": "plink_yyyyyyyyyyyyyy",
      "active": true
    }
  ],
  "paging": {
    "page": 1,
    "pageSize": 5
  }
}

Deactivates a payment link, making it unusable for payments. This action is reversible by updating the active attribute to true.

Archive a Payment Link

javascript
const paymentLinkId = 'plink_xxxxxxxxxxxxxx';
const archivedPaymentLink = await payment.paymentLinks.archive(paymentLinkId);

Parameters

NameTypeDescription
idstringRequired. The ID of the payment link to archive.

Returns

Returns the archived TPaymentLink object with its active property set to false.

Response

json
{
  "id": "plink_xxxxxxxxxxxxxx",
  "active": false,
  "url": "https://payment.arcblock.io/pl/plink_xxxxxxxxxxxxxx"
}