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)

Constant Summary collapse

OBJECT_NAME =
"payment_link"

Constants inherited from StripeObject

StripeObject::RESERVED_FIELD_NAMES

Instance Attribute Summary

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

Class Method Details

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

Creates a payment link.



21
22
23
# File 'lib/stripe/resources/payment_link.rb', line 21

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

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

Returns a list of your payment links.



26
27
28
# File 'lib/stripe/resources/payment_link.rb', line 26

def self.list(filters = {}, opts = {})
  request_stripe_object(method: :get, path: "/v1/payment_links", params: filters, 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.



41
42
43
44
45
46
47
48
# File 'lib/stripe/resources/payment_link.rb', line 41

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.



51
52
53
54
55
56
57
58
# File 'lib/stripe/resources/payment_link.rb', line 51

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.



31
32
33
34
35
36
37
38
# File 'lib/stripe/resources/payment_link.rb', line 31

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