Class: Stripe::PaymentLink

Inherits:
APIResource show all
Extended by:
APIOperations::Create, APIOperations::List
Includes:
APIOperations::Save
Defined in:
lib/stripe/resources/payment_link.rb

Overview

A payment link is a shareable URL that will take your customers to a hosted payment page. A payment link can be shared and used multiple times.

When a customer opens a payment link it will open a new [checkout session](stripe.com/docs/api/checkout/sessions) to render the payment page. You can use [checkout session events](stripe.com/docs/api/events/types#event_types-checkout.session.completed) to track payments through payment links.

Related guide: [Payment Links API](stripe.com/docs/payment-links)

Defined Under Namespace

Classes: AfterCompletion, AutomaticTax, ConsentCollection, CreateParams, CustomField, CustomText, InvoiceCreation, ListLineItemsParams, ListParams, PaymentIntentData, PhoneNumberCollection, Restrictions, RetrieveParams, ShippingAddressCollection, ShippingOption, SubscriptionData, TaxIdCollection, TransferData, UpdateParams

Constant Summary collapse

OBJECT_NAME =
"payment_link"

Constants inherited from StripeObject

StripeObject::RESERVED_FIELD_NAMES

Instance Attribute Summary collapse

Attributes inherited from APIResource

#save_with_parent

Attributes inherited from StripeObject

#last_response

Class Method Summary collapse

Instance Method Summary collapse

Methods included from APIOperations::Create

create

Methods included from APIOperations::List

list

Methods included from APIOperations::Save

included, #save

Methods inherited from APIResource

class_name, custom_method, #refresh, #request_stripe_object, resource_url, #resource_url, retrieve, save_nested_resource

Methods included from APIOperations::Request

included

Methods inherited from StripeObject

#==, #[], #[]=, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, #hash, #initialize, #inspect, #keys, #marshal_dump, #marshal_load, protected_fields, #serialize_params, #to_hash, #to_json, #to_s, #update_attributes, #values

Constructor Details

This class inherits a constructor from Stripe::StripeObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Stripe::StripeObject

Instance Attribute Details

#activeObject (readonly)

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.



1683
1684
1685
# File 'lib/stripe/resources/payment_link.rb', line 1683

def active
  @active
end

#after_completionObject (readonly)

Attribute for field after_completion



1686
1687
1688
# File 'lib/stripe/resources/payment_link.rb', line 1686

def after_completion
  @after_completion
end

#allow_promotion_codesObject (readonly)

Whether user redeemable promotion codes are enabled.



1689
1690
1691
# File 'lib/stripe/resources/payment_link.rb', line 1689

def allow_promotion_codes
  @allow_promotion_codes
end

#applicationObject (readonly)

The ID of the Connect application that created the Payment Link.



1692
1693
1694
# File 'lib/stripe/resources/payment_link.rb', line 1692

def application
  @application
end

#application_fee_amountObject (readonly)

The amount of the application fee (if any) that will be requested to be applied to the payment and transferred to the application owner’s Stripe account.



1695
1696
1697
# File 'lib/stripe/resources/payment_link.rb', line 1695

def application_fee_amount
  @application_fee_amount
end

#application_fee_percentObject (readonly)

This represents the percentage of the subscription invoice total that will be transferred to the application owner’s Stripe account.



1698
1699
1700
# File 'lib/stripe/resources/payment_link.rb', line 1698

def application_fee_percent
  @application_fee_percent
end

#automatic_taxObject (readonly)

Attribute for field automatic_tax



1701
1702
1703
# File 'lib/stripe/resources/payment_link.rb', line 1701

def automatic_tax
  @automatic_tax
end

#billing_address_collectionObject (readonly)

Configuration for collecting the customer’s billing address. Defaults to ‘auto`.



1704
1705
1706
# File 'lib/stripe/resources/payment_link.rb', line 1704

def billing_address_collection
  @billing_address_collection
end

When set, provides configuration to gather active consent from customers.



1707
1708
1709
# File 'lib/stripe/resources/payment_link.rb', line 1707

def consent_collection
  @consent_collection
end

#currencyObject (readonly)

Three-letter [ISO currency code](www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](stripe.com/docs/currencies).



1710
1711
1712
# File 'lib/stripe/resources/payment_link.rb', line 1710

def currency
  @currency
end

#custom_fieldsObject (readonly)

Collect additional information from your customer using custom fields. Up to 3 fields are supported.



1713
1714
1715
# File 'lib/stripe/resources/payment_link.rb', line 1713

def custom_fields
  @custom_fields
end

#custom_textObject (readonly)

Attribute for field custom_text



1716
1717
1718
# File 'lib/stripe/resources/payment_link.rb', line 1716

def custom_text
  @custom_text
end

#customer_creationObject (readonly)

Configuration for Customer creation during checkout.



1719
1720
1721
# File 'lib/stripe/resources/payment_link.rb', line 1719

def customer_creation
  @customer_creation
end

#idObject (readonly)

Unique identifier for the object.



1722
1723
1724
# File 'lib/stripe/resources/payment_link.rb', line 1722

def id
  @id
end

#inactive_messageObject (readonly)

The custom message to be displayed to a customer when a payment link is no longer active.



1725
1726
1727
# File 'lib/stripe/resources/payment_link.rb', line 1725

def inactive_message
  @inactive_message
end

#invoice_creationObject (readonly)

Configuration for creating invoice for payment mode payment links.



1728
1729
1730
# File 'lib/stripe/resources/payment_link.rb', line 1728

def invoice_creation
  @invoice_creation
end

#line_itemsObject (readonly)

The line items representing what is being sold.



1731
1732
1733
# File 'lib/stripe/resources/payment_link.rb', line 1731

def line_items
  @line_items
end

#livemodeObject (readonly)

Has the value ‘true` if the object exists in live mode or the value `false` if the object exists in test mode.



1734
1735
1736
# File 'lib/stripe/resources/payment_link.rb', line 1734

def livemode
  @livemode
end

#metadataObject (readonly)

Set of [key-value pairs](stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.



1737
1738
1739
# File 'lib/stripe/resources/payment_link.rb', line 1737

def 
  @metadata
end

#objectObject (readonly)

String representing the object’s type. Objects of the same type share the same value.



1740
1741
1742
# File 'lib/stripe/resources/payment_link.rb', line 1740

def object
  @object
end

#on_behalf_ofObject (readonly)

The account on behalf of which to charge. See the [Connect documentation](support.stripe.com/questions/sending-invoices-on-behalf-of-connected-accounts) for details.



1743
1744
1745
# File 'lib/stripe/resources/payment_link.rb', line 1743

def on_behalf_of
  @on_behalf_of
end

#payment_intent_dataObject (readonly)

Indicates the parameters to be passed to PaymentIntent creation during checkout.



1746
1747
1748
# File 'lib/stripe/resources/payment_link.rb', line 1746

def payment_intent_data
  @payment_intent_data
end

#payment_method_collectionObject (readonly)

Configuration for collecting a payment method during checkout. Defaults to ‘always`.



1749
1750
1751
# File 'lib/stripe/resources/payment_link.rb', line 1749

def payment_method_collection
  @payment_method_collection
end

#payment_method_typesObject (readonly)

The list of payment method types that customers can use. When ‘null`, Stripe will dynamically show relevant payment methods you’ve enabled in your [payment method settings](dashboard.stripe.com/settings/payment_methods).



1752
1753
1754
# File 'lib/stripe/resources/payment_link.rb', line 1752

def payment_method_types
  @payment_method_types
end

#phone_number_collectionObject (readonly)

Attribute for field phone_number_collection



1755
1756
1757
# File 'lib/stripe/resources/payment_link.rb', line 1755

def phone_number_collection
  @phone_number_collection
end

#restrictionsObject (readonly)

Settings that restrict the usage of a payment link.



1758
1759
1760
# File 'lib/stripe/resources/payment_link.rb', line 1758

def restrictions
  @restrictions
end

#shipping_address_collectionObject (readonly)

Configuration for collecting the customer’s shipping address.



1761
1762
1763
# File 'lib/stripe/resources/payment_link.rb', line 1761

def shipping_address_collection
  @shipping_address_collection
end

#shipping_optionsObject (readonly)

The shipping rate options applied to the session.



1764
1765
1766
# File 'lib/stripe/resources/payment_link.rb', line 1764

def shipping_options
  @shipping_options
end

#submit_typeObject (readonly)

Indicates the type of transaction being performed which customizes relevant text on the page, such as the submit button.



1767
1768
1769
# File 'lib/stripe/resources/payment_link.rb', line 1767

def submit_type
  @submit_type
end

#subscription_dataObject (readonly)

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`.



1770
1771
1772
# File 'lib/stripe/resources/payment_link.rb', line 1770

def subscription_data
  @subscription_data
end

#tax_id_collectionObject (readonly)

Attribute for field tax_id_collection



1773
1774
1775
# File 'lib/stripe/resources/payment_link.rb', line 1773

def tax_id_collection
  @tax_id_collection
end

#transfer_dataObject (readonly)

The account (if any) the payments will be attributed to for tax reporting, and where funds from each payment will be transferred to.



1776
1777
1778
# File 'lib/stripe/resources/payment_link.rb', line 1776

def transfer_data
  @transfer_data
end

#urlObject (readonly)

The public URL that can be shared with customers.



1779
1780
1781
# File 'lib/stripe/resources/payment_link.rb', line 1779

def url
  @url
end

Class Method Details

.create(params = {}, opts = {}) ⇒ Object

Creates a payment link.



1782
1783
1784
# File 'lib/stripe/resources/payment_link.rb', line 1782

def self.create(params = {}, opts = {})
  request_stripe_object(method: :post, path: "/v1/payment_links", params: params, opts: opts)
end

.list(params = {}, opts = {}) ⇒ Object

Returns a list of your payment links.



1787
1788
1789
# File 'lib/stripe/resources/payment_link.rb', line 1787

def self.list(params = {}, opts = {})
  request_stripe_object(method: :get, path: "/v1/payment_links", params: params, opts: opts)
end

.list_line_items(payment_link, params = {}, opts = {}) ⇒ Object

When retrieving a payment link, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.



1802
1803
1804
1805
1806
1807
1808
1809
# File 'lib/stripe/resources/payment_link.rb', line 1802

def self.list_line_items(payment_link, params = {}, opts = {})
  request_stripe_object(
    method: :get,
    path: format("/v1/payment_links/%<payment_link>s/line_items", { payment_link: CGI.escape(payment_link) }),
    params: params,
    opts: opts
  )
end

.object_nameObject



16
17
18
# File 'lib/stripe/resources/payment_link.rb', line 16

def self.object_name
  "payment_link"
end

.update(id, params = {}, opts = {}) ⇒ Object

Updates a payment link.



1812
1813
1814
1815
1816
1817
1818
1819
# File 'lib/stripe/resources/payment_link.rb', line 1812

def self.update(id, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/payment_links/%<id>s", { id: CGI.escape(id) }),
    params: params,
    opts: opts
  )
end

Instance Method Details

#list_line_items(params = {}, opts = {}) ⇒ Object

When retrieving a payment link, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.



1792
1793
1794
1795
1796
1797
1798
1799
# File 'lib/stripe/resources/payment_link.rb', line 1792

def list_line_items(params = {}, opts = {})
  request_stripe_object(
    method: :get,
    path: format("/v1/payment_links/%<payment_link>s/line_items", { payment_link: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end