• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

stripe / stripe-php / 9308533534

30 May 2024 08:07PM UTC coverage: 65.24% (-0.9%) from 66.176%
9308533534

push

github

web-flow
Added PHPDocs for `create`, `update`, `delete`, `all`, `retrieve` methods after moving them out of traits.  (#1701)

* Demagiced crudl operation

* Improvements from codegen#1452

* Updated override to fix indents

1080 of 1682 new or added lines in 106 files covered. (64.21%)

15 existing lines in 3 files now uncovered.

3444 of 5279 relevant lines covered (65.24%)

2.29 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/lib/PaymentLink.php
1
<?php
2

3
// File generated from our OpenAPI spec
4

5
namespace Stripe;
6

7
/**
8
 * 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.
9
 *
10
 * When a customer opens a payment link it will open a new <a href="https://stripe.com/docs/api/checkout/sessions">checkout session</a> to render the payment page. You can use <a href="https://stripe.com/docs/api/events/types#event_types-checkout.session.completed">checkout session events</a> to track payments through payment links.
11
 *
12
 * Related guide: <a href="https://stripe.com/docs/payment-links">Payment Links API</a>
13
 *
14
 * @property string $id Unique identifier for the object.
15
 * @property string $object String representing the object's type. Objects of the same type share the same value.
16
 * @property bool $active Whether the payment link's <code>url</code> is active. If <code>false</code>, customers visiting the URL will be shown a page saying that the link has been deactivated.
17
 * @property \Stripe\StripeObject $after_completion
18
 * @property bool $allow_promotion_codes Whether user redeemable promotion codes are enabled.
19
 * @property null|string|\Stripe\Application $application The ID of the Connect application that created the Payment Link.
20
 * @property null|int $application_fee_amount 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.
21
 * @property null|float $application_fee_percent This represents the percentage of the subscription invoice total that will be transferred to the application owner's Stripe account.
22
 * @property \Stripe\StripeObject $automatic_tax
23
 * @property string $billing_address_collection Configuration for collecting the customer's billing address. Defaults to <code>auto</code>.
24
 * @property null|\Stripe\StripeObject $consent_collection When set, provides configuration to gather active consent from customers.
25
 * @property string $currency Three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a>, in lowercase. Must be a <a href="https://stripe.com/docs/currencies">supported currency</a>.
26
 * @property \Stripe\StripeObject[] $custom_fields Collect additional information from your customer using custom fields. Up to 3 fields are supported.
27
 * @property \Stripe\StripeObject $custom_text
28
 * @property string $customer_creation Configuration for Customer creation during checkout.
29
 * @property null|string $inactive_message The custom message to be displayed to a customer when a payment link is no longer active.
30
 * @property null|\Stripe\StripeObject $invoice_creation Configuration for creating invoice for payment mode payment links.
31
 * @property null|\Stripe\Collection<\Stripe\LineItem> $line_items The line items representing what is being sold.
32
 * @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
33
 * @property \Stripe\StripeObject $metadata Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
34
 * @property null|string|\Stripe\Account $on_behalf_of The account on behalf of which to charge. See the <a href="https://support.stripe.com/questions/sending-invoices-on-behalf-of-connected-accounts">Connect documentation</a> for details.
35
 * @property null|\Stripe\StripeObject $payment_intent_data Indicates the parameters to be passed to PaymentIntent creation during checkout.
36
 * @property string $payment_method_collection Configuration for collecting a payment method during checkout. Defaults to <code>always</code>.
37
 * @property null|string[] $payment_method_types The list of payment method types that customers can use. When <code>null</code>, Stripe will dynamically show relevant payment methods you've enabled in your <a href="https://dashboard.stripe.com/settings/payment_methods">payment method settings</a>.
38
 * @property \Stripe\StripeObject $phone_number_collection
39
 * @property null|\Stripe\StripeObject $restrictions Settings that restrict the usage of a payment link.
40
 * @property null|\Stripe\StripeObject $shipping_address_collection Configuration for collecting the customer's shipping address.
41
 * @property \Stripe\StripeObject[] $shipping_options The shipping rate options applied to the session.
42
 * @property string $submit_type Indicates the type of transaction being performed which customizes relevant text on the page, such as the submit button.
43
 * @property null|\Stripe\StripeObject $subscription_data 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 <code>subscription_data</code>.
44
 * @property \Stripe\StripeObject $tax_id_collection
45
 * @property null|\Stripe\StripeObject $transfer_data The account (if any) the payments will be attributed to for tax reporting, and where funds from each payment will be transferred to.
46
 * @property string $url The public URL that can be shared with customers.
47
 */
48
class PaymentLink extends ApiResource
49
{
50
    const OBJECT_NAME = 'payment_link';
51

52
    use ApiOperations\Update;
53

54
    const BILLING_ADDRESS_COLLECTION_AUTO = 'auto';
55
    const BILLING_ADDRESS_COLLECTION_REQUIRED = 'required';
56

57
    const CUSTOMER_CREATION_ALWAYS = 'always';
58
    const CUSTOMER_CREATION_IF_REQUIRED = 'if_required';
59

60
    const PAYMENT_METHOD_COLLECTION_ALWAYS = 'always';
61
    const PAYMENT_METHOD_COLLECTION_IF_REQUIRED = 'if_required';
62

63
    const SUBMIT_TYPE_AUTO = 'auto';
64
    const SUBMIT_TYPE_BOOK = 'book';
65
    const SUBMIT_TYPE_DONATE = 'donate';
66
    const SUBMIT_TYPE_PAY = 'pay';
67

68
    /**
69
     * Creates a payment link.
70
     *
71
     * @param null|array $params
72
     * @param null|array|string $options
73
     *
74
     * @throws \Stripe\Exception\ApiErrorException if the request fails
75
     *
76
     * @return \Stripe\PaymentLink the created resource
77
     */
NEW
78
    public static function create($params = null, $options = null)
×
79
    {
NEW
80
        self::_validateParams($params);
×
NEW
81
        $url = static::classUrl();
×
82

NEW
83
        list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
×
NEW
84
        $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
×
NEW
85
        $obj->setLastResponse($response);
×
86

NEW
87
        return $obj;
×
88
    }
89

90
    /**
91
     * Returns a list of your payment links.
92
     *
93
     * @param null|array $params
94
     * @param null|array|string $opts
95
     *
96
     * @throws \Stripe\Exception\ApiErrorException if the request fails
97
     *
98
     * @return \Stripe\Collection<\Stripe\PaymentLink> of ApiResources
99
     */
NEW
100
    public static function all($params = null, $opts = null)
×
101
    {
NEW
102
        $url = static::classUrl();
×
103

NEW
104
        return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
×
105
    }
106

107
    /**
108
     * Retrieve a payment link.
109
     *
110
     * @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
111
     * @param null|array|string $opts
112
     *
113
     * @throws \Stripe\Exception\ApiErrorException if the request fails
114
     *
115
     * @return \Stripe\PaymentLink
116
     */
NEW
117
    public static function retrieve($id, $opts = null)
×
118
    {
NEW
119
        $opts = \Stripe\Util\RequestOptions::parse($opts);
×
NEW
120
        $instance = new static($id, $opts);
×
NEW
121
        $instance->refresh();
×
122

NEW
123
        return $instance;
×
124
    }
125

126
    /**
127
     * Updates a payment link.
128
     *
129
     * @param string $id the ID of the resource to update
130
     * @param null|array $params
131
     * @param null|array|string $opts
132
     *
133
     * @throws \Stripe\Exception\ApiErrorException if the request fails
134
     *
135
     * @return \Stripe\PaymentLink the updated resource
136
     */
NEW
137
    public static function update($id, $params = null, $opts = null)
×
138
    {
NEW
139
        self::_validateParams($params);
×
NEW
140
        $url = static::resourceUrl($id);
×
141

NEW
142
        list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
×
NEW
143
        $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
×
NEW
144
        $obj->setLastResponse($response);
×
145

NEW
146
        return $obj;
×
147
    }
148

149
    /**
150
     * @param string $id
151
     * @param null|array $params
152
     * @param null|array|string $opts
153
     *
154
     * @throws \Stripe\Exception\ApiErrorException if the request fails
155
     *
156
     * @return \Stripe\Collection<\Stripe\LineItem> list of line items
157
     */
158
    public static function allLineItems($id, $params = null, $opts = null)
×
159
    {
160
        $url = static::resourceUrl($id) . '/line_items';
×
161
        list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
×
162
        $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
×
163
        $obj->setLastResponse($response);
×
164

165
        return $obj;
×
166
    }
167
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc