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](docs.stripe.com/api/checkout/sessions) to render the payment page. You can use [checkout session events](docs.stripe.com/api/events/types#event_types-checkout.session.completed) to track payments through payment links.

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

Defined Under Namespace

Classes: AfterCompletion, AutomaticTax, ConsentCollection, CustomField, CustomText, InvoiceCreation, ManagedPayments, NameCollection, OptionalItem, PaymentIntentData, PaymentMethodOptions, PhoneNumberCollection, Restrictions, ShippingAddressCollection, ShippingOption, SubscriptionData, TaxIdCollection, TransferData

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

#==, #[], #[]=, #_get_inner_class_type, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, field_encodings, #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.



708
709
710
# File 'lib/stripe/resources/payment_link.rb', line 708

def active
  @active
end

#after_completionObject (readonly)

Attribute for field after_completion



710
711
712
# File 'lib/stripe/resources/payment_link.rb', line 710

def after_completion
  @after_completion
end

#allow_promotion_codesObject (readonly)

Whether user redeemable promotion codes are enabled.



712
713
714
# File 'lib/stripe/resources/payment_link.rb', line 712

def allow_promotion_codes
  @allow_promotion_codes
end

#applicationObject (readonly)

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



714
715
716
# File 'lib/stripe/resources/payment_link.rb', line 714

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.



716
717
718
# File 'lib/stripe/resources/payment_link.rb', line 716

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.



718
719
720
# File 'lib/stripe/resources/payment_link.rb', line 718

def application_fee_percent
  @application_fee_percent
end

#automatic_taxObject (readonly)

Attribute for field automatic_tax



720
721
722
# File 'lib/stripe/resources/payment_link.rb', line 720

def automatic_tax
  @automatic_tax
end

#billing_address_collectionObject (readonly)

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



722
723
724
# File 'lib/stripe/resources/payment_link.rb', line 722

def billing_address_collection
  @billing_address_collection
end

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



724
725
726
# File 'lib/stripe/resources/payment_link.rb', line 724

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



726
727
728
# File 'lib/stripe/resources/payment_link.rb', line 726

def currency
  @currency
end

#custom_fieldsObject (readonly)

Collect additional information from your customer using custom fields. Up to 3 fields are supported. You can’t set this parameter if ‘ui_mode` is `custom`.



728
729
730
# File 'lib/stripe/resources/payment_link.rb', line 728

def custom_fields
  @custom_fields
end

#custom_textObject (readonly)

Attribute for field custom_text



730
731
732
# File 'lib/stripe/resources/payment_link.rb', line 730

def custom_text
  @custom_text
end

#customer_creationObject (readonly)

Configuration for Customer creation during checkout.



732
733
734
# File 'lib/stripe/resources/payment_link.rb', line 732

def customer_creation
  @customer_creation
end

#idObject (readonly)

Unique identifier for the object.



734
735
736
# File 'lib/stripe/resources/payment_link.rb', line 734

def id
  @id
end

#inactive_messageObject (readonly)

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



736
737
738
# File 'lib/stripe/resources/payment_link.rb', line 736

def inactive_message
  @inactive_message
end

#invoice_creationObject (readonly)

Configuration for creating invoice for payment mode payment links.



738
739
740
# File 'lib/stripe/resources/payment_link.rb', line 738

def invoice_creation
  @invoice_creation
end

#line_itemsObject (readonly)

The line items representing what is being sold.



740
741
742
# File 'lib/stripe/resources/payment_link.rb', line 740

def line_items
  @line_items
end

#livemodeObject (readonly)

If the object exists in live mode, the value is ‘true`. If the object exists in test mode, the value is `false`.



742
743
744
# File 'lib/stripe/resources/payment_link.rb', line 742

def livemode
  @livemode
end

#managed_paymentsObject (readonly)

Settings for Managed Payments for this Payment Link and resulting [CheckoutSessions](/api/checkout/sessions/object), [PaymentIntents](/api/payment_intents/object), [Invoices](/api/invoices/object), and [Subscriptions](/api/subscriptions/object).



744
745
746
# File 'lib/stripe/resources/payment_link.rb', line 744

def managed_payments
  @managed_payments
end

#metadataObject (readonly)

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



746
747
748
# File 'lib/stripe/resources/payment_link.rb', line 746

def 
  @metadata
end

#name_collectionObject (readonly)

Attribute for field name_collection



748
749
750
# File 'lib/stripe/resources/payment_link.rb', line 748

def name_collection
  @name_collection
end

#objectObject (readonly)

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



750
751
752
# File 'lib/stripe/resources/payment_link.rb', line 750

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.



752
753
754
# File 'lib/stripe/resources/payment_link.rb', line 752

def on_behalf_of
  @on_behalf_of
end

#optional_itemsObject (readonly)

The optional items presented to the customer at checkout.



754
755
756
# File 'lib/stripe/resources/payment_link.rb', line 754

def optional_items
  @optional_items
end

#payment_intent_dataObject (readonly)

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



756
757
758
# File 'lib/stripe/resources/payment_link.rb', line 756

def payment_intent_data
  @payment_intent_data
end

#payment_method_collectionObject (readonly)

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



758
759
760
# File 'lib/stripe/resources/payment_link.rb', line 758

def payment_method_collection
  @payment_method_collection
end

#payment_method_optionsObject (readonly)

Payment-method-specific configuration.



760
761
762
# File 'lib/stripe/resources/payment_link.rb', line 760

def payment_method_options
  @payment_method_options
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).



762
763
764
# File 'lib/stripe/resources/payment_link.rb', line 762

def payment_method_types
  @payment_method_types
end

#phone_number_collectionObject (readonly)

Attribute for field phone_number_collection



764
765
766
# File 'lib/stripe/resources/payment_link.rb', line 764

def phone_number_collection
  @phone_number_collection
end

#restrictionsObject (readonly)

Settings that restrict the usage of a payment link.



766
767
768
# File 'lib/stripe/resources/payment_link.rb', line 766

def restrictions
  @restrictions
end

#shipping_address_collectionObject (readonly)

Configuration for collecting the customer’s shipping address.



768
769
770
# File 'lib/stripe/resources/payment_link.rb', line 768

def shipping_address_collection
  @shipping_address_collection
end

#shipping_optionsObject (readonly)

The shipping rate options applied to the session.



770
771
772
# File 'lib/stripe/resources/payment_link.rb', line 770

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.



772
773
774
# File 'lib/stripe/resources/payment_link.rb', line 772

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



774
775
776
# File 'lib/stripe/resources/payment_link.rb', line 774

def subscription_data
  @subscription_data
end

#tax_id_collectionObject (readonly)

Attribute for field tax_id_collection



776
777
778
# File 'lib/stripe/resources/payment_link.rb', line 776

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.



778
779
780
# File 'lib/stripe/resources/payment_link.rb', line 778

def transfer_data
  @transfer_data
end

#urlObject (readonly)

The public URL that can be shared with customers.



780
781
782
# File 'lib/stripe/resources/payment_link.rb', line 780

def url
  @url
end

Class Method Details

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

Creates a payment link.



783
784
785
# File 'lib/stripe/resources/payment_link.rb', line 783

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

.field_remappingsObject



845
846
847
# File 'lib/stripe/resources/payment_link.rb', line 845

def self.field_remappings
  @field_remappings = {}
end

.inner_class_typesObject



822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
# File 'lib/stripe/resources/payment_link.rb', line 822

def self.inner_class_types
  @inner_class_types = {
    after_completion: AfterCompletion,
    automatic_tax: AutomaticTax,
    consent_collection: ConsentCollection,
    custom_fields: CustomField,
    custom_text: CustomText,
    invoice_creation: InvoiceCreation,
    managed_payments: ManagedPayments,
    name_collection: NameCollection,
    optional_items: OptionalItem,
    payment_intent_data: PaymentIntentData,
    payment_method_options: PaymentMethodOptions,
    phone_number_collection: PhoneNumberCollection,
    restrictions: Restrictions,
    shipping_address_collection: ShippingAddressCollection,
    shipping_options: ShippingOption,
    subscription_data: SubscriptionData,
    tax_id_collection: TaxIdCollection,
    transfer_data: TransferData,
  }
end

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

Returns a list of your payment links.



788
789
790
# File 'lib/stripe/resources/payment_link.rb', line 788

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.



803
804
805
806
807
808
809
810
# File 'lib/stripe/resources/payment_link.rb', line 803

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(payment_link, params = {}, opts = {}) ⇒ Object

Updates a payment link.



813
814
815
816
817
818
819
820
# File 'lib/stripe/resources/payment_link.rb', line 813

def self.update(payment_link, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/payment_links/%<payment_link>s", { payment_link: CGI.escape(payment_link) }),
    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.



793
794
795
796
797
798
799
800
# File 'lib/stripe/resources/payment_link.rb', line 793

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