PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.13
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.13
1.8.13.1 1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 All 212 releases
charitable / vendor / stripe / stripe-php / lib / Service / PaymentMethodService.php

PaymentMethodService.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.13, at vendor/stripe/stripe-php/lib/Service/PaymentMethodService.php

136 lines 5.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // File generated from our OpenAPI spec
4
5 namespace Stripe\Service;
6
7 class PaymentMethodService extends \Stripe\Service\AbstractService
8 {
9 /**
10 * Returns a list of PaymentMethods attached to the StripeAccount. For listing a
11 * customer’s payment methods, you should use <a
12 * href="/docs/api/payment_methods/customer_list">List a Customer’s
13 * PaymentMethods</a>.
14 *
15 * @param null|array $params
16 * @param null|array|\Stripe\Util\RequestOptions $opts
17 *
18 * @throws \Stripe\Exception\ApiErrorException if the request fails
19 *
20 * @return \Stripe\Collection<\Stripe\PaymentMethod>
21 */
22 public function all($params = null, $opts = null)
23 {
24 return $this->requestCollection('get', '/v1/payment_methods', $params, $opts);
25 }
26
27 /**
28 * Attaches a PaymentMethod object to a Customer.
29 *
30 * To attach a new PaymentMethod to a customer for future payments, we recommend
31 * you use a <a href="/docs/api/setup_intents">SetupIntent</a> or a PaymentIntent
32 * with <a
33 * href="/docs/api/payment_intents/create#create_payment_intent-setup_future_usage">setup_future_usage</a>.
34 * These approaches will perform any necessary steps to set up the PaymentMethod
35 * for future payments. Using the <code>/v1/payment_methods/:id/attach</code>
36 * endpoint without first using a SetupIntent or PaymentIntent with
37 * <code>setup_future_usage</code> does not optimize the PaymentMethod for future
38 * use, which makes later declines and payment friction more likely. See <a
39 * href="/docs/payments/payment-intents#future-usage">Optimizing cards for future
40 * payments</a> for more information about setting up future payments.
41 *
42 * To use this PaymentMethod as the default for invoice or subscription payments,
43 * set <a
44 * href="/docs/api/customers/update#update_customer-invoice_settings-default_payment_method"><code>invoice_settings.default_payment_method</code></a>,
45 * on the Customer to the PaymentMethod’s ID.
46 *
47 * @param string $id
48 * @param null|array $params
49 * @param null|array|\Stripe\Util\RequestOptions $opts
50 *
51 * @throws \Stripe\Exception\ApiErrorException if the request fails
52 *
53 * @return \Stripe\PaymentMethod
54 */
55 public function attach($id, $params = null, $opts = null)
56 {
57 return $this->request('post', $this->buildPath('/v1/payment_methods/%s/attach', $id), $params, $opts);
58 }
59
60 /**
61 * Creates a PaymentMethod object. Read the <a
62 * href="/docs/stripe-js/reference#stripe-create-payment-method">Stripe.js
63 * reference</a> to learn how to create PaymentMethods via Stripe.js.
64 *
65 * Instead of creating a PaymentMethod directly, we recommend using the <a
66 * href="/docs/payments/accept-a-payment">PaymentIntents</a> API to accept a
67 * payment immediately or the <a
68 * href="/docs/payments/save-and-reuse">SetupIntent</a> API to collect payment
69 * method details ahead of a future payment.
70 *
71 * @param null|array $params
72 * @param null|array|\Stripe\Util\RequestOptions $opts
73 *
74 * @throws \Stripe\Exception\ApiErrorException if the request fails
75 *
76 * @return \Stripe\PaymentMethod
77 */
78 public function create($params = null, $opts = null)
79 {
80 return $this->request('post', '/v1/payment_methods', $params, $opts);
81 }
82
83 /**
84 * Detaches a PaymentMethod object from a Customer. After a PaymentMethod is
85 * detached, it can no longer be used for a payment or re-attached to a Customer.
86 *
87 * @param string $id
88 * @param null|array $params
89 * @param null|array|\Stripe\Util\RequestOptions $opts
90 *
91 * @throws \Stripe\Exception\ApiErrorException if the request fails
92 *
93 * @return \Stripe\PaymentMethod
94 */
95 public function detach($id, $params = null, $opts = null)
96 {
97 return $this->request('post', $this->buildPath('/v1/payment_methods/%s/detach', $id), $params, $opts);
98 }
99
100 /**
101 * Retrieves a PaymentMethod object attached to the StripeAccount. To retrieve a
102 * payment method attached to a Customer, you should use <a
103 * href="/docs/api/payment_methods/customer">Retrieve a Customer’s
104 * PaymentMethods</a>.
105 *
106 * @param string $id
107 * @param null|array $params
108 * @param null|array|\Stripe\Util\RequestOptions $opts
109 *
110 * @throws \Stripe\Exception\ApiErrorException if the request fails
111 *
112 * @return \Stripe\PaymentMethod
113 */
114 public function retrieve($id, $params = null, $opts = null)
115 {
116 return $this->request('get', $this->buildPath('/v1/payment_methods/%s', $id), $params, $opts);
117 }
118
119 /**
120 * Updates a PaymentMethod object. A PaymentMethod must be attached a customer to
121 * be updated.
122 *
123 * @param string $id
124 * @param null|array $params
125 * @param null|array|\Stripe\Util\RequestOptions $opts
126 *
127 * @throws \Stripe\Exception\ApiErrorException if the request fails
128 *
129 * @return \Stripe\PaymentMethod
130 */
131 public function update($id, $params = null, $opts = null)
132 {
133 return $this->request('post', $this->buildPath('/v1/payment_methods/%s', $id), $params, $opts);
134 }
135 }
136