| 1 |
<?php |
| 2 |
|
| 3 |
// File generated from our OpenAPI spec |
| 4 |
|
| 5 |
namespace Stripe\Service; |
| 6 |
|
| 7 |
class CustomerService extends \Stripe\Service\AbstractService |
| 8 |
{ |
| 9 |
/** |
| 10 |
* Returns a list of your customers. The customers are returned sorted by creation |
| 11 |
* date, with the most recent customers appearing first. |
| 12 |
* |
| 13 |
* @param null|array $params |
| 14 |
* @param null|array|\Stripe\Util\RequestOptions $opts |
| 15 |
* |
| 16 |
* @throws \Stripe\Exception\ApiErrorException if the request fails |
| 17 |
* |
| 18 |
* @return \Stripe\Collection<\Stripe\Customer> |
| 19 |
*/ |
| 20 |
public function all($params = null, $opts = null) |
| 21 |
{ |
| 22 |
return $this->requestCollection('get', '/v1/customers', $params, $opts); |
| 23 |
} |
| 24 |
|
| 25 |
/** |
| 26 |
* Returns a list of transactions that updated the customer’s <a |
| 27 |
* href="/docs/billing/customer/balance">balances</a>. |
| 28 |
* |
| 29 |
* @param string $parentId |
| 30 |
* @param null|array $params |
| 31 |
* @param null|array|\Stripe\Util\RequestOptions $opts |
| 32 |
* |
| 33 |
* @throws \Stripe\Exception\ApiErrorException if the request fails |
| 34 |
* |
| 35 |
* @return \Stripe\Collection<\Stripe\CustomerBalanceTransaction> |
| 36 |
*/ |
| 37 |
public function allBalanceTransactions($parentId, $params = null, $opts = null) |
| 38 |
{ |
| 39 |
return $this->requestCollection('get', $this->buildPath('/v1/customers/%s/balance_transactions', $parentId), $params, $opts); |
| 40 |
} |
| 41 |
|
| 42 |
/** |
| 43 |
* Returns a list of PaymentMethods for a given Customer. |
| 44 |
* |
| 45 |
* @param string $id |
| 46 |
* @param null|array $params |
| 47 |
* @param null|array|\Stripe\Util\RequestOptions $opts |
| 48 |
* |
| 49 |
* @throws \Stripe\Exception\ApiErrorException if the request fails |
| 50 |
* |
| 51 |
* @return \Stripe\Collection<\Stripe\Customer> |
| 52 |
*/ |
| 53 |
public function allPaymentMethods($id, $params = null, $opts = null) |
| 54 |
{ |
| 55 |
return $this->requestCollection('get', $this->buildPath('/v1/customers/%s/payment_methods', $id), $params, $opts); |
| 56 |
} |
| 57 |
|
| 58 |
/** |
| 59 |
* List sources for a specified customer. |
| 60 |
* |
| 61 |
* @param string $parentId |
| 62 |
* @param null|array $params |
| 63 |
* @param null|array|\Stripe\Util\RequestOptions $opts |
| 64 |
* |
| 65 |
* @throws \Stripe\Exception\ApiErrorException if the request fails |
| 66 |
* |
| 67 |
* @return \Stripe\Collection<\Stripe\AlipayAccount|\Stripe\BankAccount|\Stripe\BitcoinReceiver|\Stripe\Card|\Stripe\Source> |
| 68 |
*/ |
| 69 |
public function allSources($parentId, $params = null, $opts = null) |
| 70 |
{ |
| 71 |
return $this->requestCollection('get', $this->buildPath('/v1/customers/%s/sources', $parentId), $params, $opts); |
| 72 |
} |
| 73 |
|
| 74 |
/** |
| 75 |
* Returns a list of tax IDs for a customer. |
| 76 |
* |
| 77 |
* @param string $parentId |
| 78 |
* @param null|array $params |
| 79 |
* @param null|array|\Stripe\Util\RequestOptions $opts |
| 80 |
* |
| 81 |
* @throws \Stripe\Exception\ApiErrorException if the request fails |
| 82 |
* |
| 83 |
* @return \Stripe\Collection<\Stripe\TaxId> |
| 84 |
*/ |
| 85 |
public function allTaxIds($parentId, $params = null, $opts = null) |
| 86 |
{ |
| 87 |
return $this->requestCollection('get', $this->buildPath('/v1/customers/%s/tax_ids', $parentId), $params, $opts); |
| 88 |
} |
| 89 |
|
| 90 |
/** |
| 91 |
* Creates a new customer object. |
| 92 |
* |
| 93 |
* @param null|array $params |
| 94 |
* @param null|array|\Stripe\Util\RequestOptions $opts |
| 95 |
* |
| 96 |
* @throws \Stripe\Exception\ApiErrorException if the request fails |
| 97 |
* |
| 98 |
* @return \Stripe\Customer |
| 99 |
*/ |
| 100 |
public function create($params = null, $opts = null) |
| 101 |
{ |
| 102 |
return $this->request('post', '/v1/customers', $params, $opts); |
| 103 |
} |
| 104 |
|
| 105 |
/** |
| 106 |
* Creates an immutable transaction that updates the customer’s credit <a |
| 107 |
* href="/docs/billing/customer/balance">balance</a>. |
| 108 |
* |
| 109 |
* @param string $parentId |
| 110 |
* @param null|array $params |
| 111 |
* @param null|array|\Stripe\Util\RequestOptions $opts |
| 112 |
* |
| 113 |
* @throws \Stripe\Exception\ApiErrorException if the request fails |
| 114 |
* |
| 115 |
* @return \Stripe\CustomerBalanceTransaction |
| 116 |
*/ |
| 117 |
public function createBalanceTransaction($parentId, $params = null, $opts = null) |
| 118 |
{ |
| 119 |
return $this->request('post', $this->buildPath('/v1/customers/%s/balance_transactions', $parentId), $params, $opts); |
| 120 |
} |
| 121 |
|
| 122 |
/** |
| 123 |
* Retrieve funding instructions for a customer cash balance. If funding |
| 124 |
* instructions do not yet exist for the customer, new funding instructions will be |
| 125 |
* created. If funding instructions have already been created for a given customer, |
| 126 |
* the same funding instructions will be retrieved. In other words, we will return |
| 127 |
* the same funding instructions each time. |
| 128 |
* |
| 129 |
* @param string $id |
| 130 |
* @param null|array $params |
| 131 |
* @param null|array|\Stripe\Util\RequestOptions $opts |
| 132 |
* |
| 133 |
* @throws \Stripe\Exception\ApiErrorException if the request fails |
| 134 |
* |
| 135 |
* @return \Stripe\Customer |
| 136 |
*/ |
| 137 |
public function createFundingInstructions($id, $params = null, $opts = null) |
| 138 |
{ |
| 139 |
return $this->request('post', $this->buildPath('/v1/customers/%s/funding_instructions', $id), $params, $opts); |
| 140 |
} |
| 141 |
|
| 142 |
/** |
| 143 |
* When you create a new credit card, you must specify a customer or recipient on |
| 144 |
* which to create it. |
| 145 |
* |
| 146 |
* If the card’s owner has no default card, then the new card will become the |
| 147 |
* default. However, if the owner already has a default, then it will not change. |
| 148 |
* To change the default, you should <a href="/docs/api#update_customer">update the |
| 149 |
* customer</a> to have a new <code>default_source</code>. |
| 150 |
* |
| 151 |
* @param string $parentId |
| 152 |
* @param null|array $params |
| 153 |
* @param null|array|\Stripe\Util\RequestOptions $opts |
| 154 |
* |
| 155 |
* @throws \Stripe\Exception\ApiErrorException if the request fails |
| 156 |
* |
| 157 |
* @return \Stripe\AlipayAccount|\Stripe\BankAccount|\Stripe\BitcoinReceiver|\Stripe\Card|\Stripe\Source |
| 158 |
*/ |
| 159 |
public function createSource($parentId, $params = null, $opts = null) |
| 160 |
{ |
| 161 |
return $this->request('post', $this->buildPath('/v1/customers/%s/sources', $parentId), $params, $opts); |
| 162 |
} |
| 163 |
|
| 164 |
/** |
| 165 |
* Creates a new <code>TaxID</code> object for a customer. |
| 166 |
* |
| 167 |
* @param string $parentId |
| 168 |
* @param null|array $params |
| 169 |
* @param null|array|\Stripe\Util\RequestOptions $opts |
| 170 |
* |
| 171 |
* @throws \Stripe\Exception\ApiErrorException if the request fails |
| 172 |
* |
| 173 |
* @return \Stripe\TaxId |
| 174 |
*/ |
| 175 |
public function createTaxId($parentId, $params = null, $opts = null) |
| 176 |
{ |
| 177 |
return $this->request('post', $this->buildPath('/v1/customers/%s/tax_ids', $parentId), $params, $opts); |
| 178 |
} |
| 179 |
|
| 180 |
/** |
| 181 |
* Permanently deletes a customer. It cannot be undone. Also immediately cancels |
| 182 |
* any active subscriptions on the customer. |
| 183 |
* |
| 184 |
* @param string $id |
| 185 |
* @param null|array $params |
| 186 |
* @param null|array|\Stripe\Util\RequestOptions $opts |
| 187 |
* |
| 188 |
* @throws \Stripe\Exception\ApiErrorException if the request fails |
| 189 |
* |
| 190 |
* @return \Stripe\Customer |
| 191 |
*/ |
| 192 |
public function delete($id, $params = null, $opts = null) |
| 193 |
{ |
| 194 |
return $this->request('delete', $this->buildPath('/v1/customers/%s', $id), $params, $opts); |
| 195 |
} |
| 196 |
|
| 197 |
/** |
| 198 |
* Removes the currently applied discount on a customer. |
| 199 |
* |
| 200 |
* @param string $id |
| 201 |
* @param null|array $params |
| 202 |
* @param null|array|\Stripe\Util\RequestOptions $opts |
| 203 |
* |
| 204 |
* @throws \Stripe\Exception\ApiErrorException if the request fails |
| 205 |
* |
| 206 |
* @return \Stripe\Customer |
| 207 |
*/ |
| 208 |
public function deleteDiscount($id, $params = null, $opts = null) |
| 209 |
{ |
| 210 |
return $this->request('delete', $this->buildPath('/v1/customers/%s/discount', $id), $params, $opts); |
| 211 |
} |
| 212 |
|
| 213 |
/** |
| 214 |
* @param string $parentId |
| 215 |
* @param string $id |
| 216 |
* @param null|array $params |
| 217 |
* @param null|array|\Stripe\Util\RequestOptions $opts |
| 218 |
* |
| 219 |
* @throws \Stripe\Exception\ApiErrorException if the request fails |
| 220 |
* |
| 221 |
* @return \Stripe\AlipayAccount|\Stripe\BankAccount|\Stripe\BitcoinReceiver|\Stripe\Card|\Stripe\Source |
| 222 |
*/ |
| 223 |
public function deleteSource($parentId, $id, $params = null, $opts = null) |
| 224 |
{ |
| 225 |
return $this->request('delete', $this->buildPath('/v1/customers/%s/sources/%s', $parentId, $id), $params, $opts); |
| 226 |
} |
| 227 |
|
| 228 |
/** |
| 229 |
* Deletes an existing <code>TaxID</code> object. |
| 230 |
* |
| 231 |
* @param string $parentId |
| 232 |
* @param string $id |
| 233 |
* @param null|array $params |
| 234 |
* @param null|array|\Stripe\Util\RequestOptions $opts |
| 235 |
* |
| 236 |
* @throws \Stripe\Exception\ApiErrorException if the request fails |
| 237 |
* |
| 238 |
* @return \Stripe\TaxId |
| 239 |
*/ |
| 240 |
public function deleteTaxId($parentId, $id, $params = null, $opts = null) |
| 241 |
{ |
| 242 |
return $this->request('delete', $this->buildPath('/v1/customers/%s/tax_ids/%s', $parentId, $id), $params, $opts); |
| 243 |
} |
| 244 |
|
| 245 |
/** |
| 246 |
* Retrieves a Customer object. |
| 247 |
* |
| 248 |
* @param string $id |
| 249 |
* @param null|array $params |
| 250 |
* @param null|array|\Stripe\Util\RequestOptions $opts |
| 251 |
* |
| 252 |
* @throws \Stripe\Exception\ApiErrorException if the request fails |
| 253 |
* |
| 254 |
* @return \Stripe\Customer |
| 255 |
*/ |
| 256 |
public function retrieve($id, $params = null, $opts = null) |
| 257 |
{ |
| 258 |
return $this->request('get', $this->buildPath('/v1/customers/%s', $id), $params, $opts); |
| 259 |
} |
| 260 |
|
| 261 |
/** |
| 262 |
* Retrieves a specific customer balance transaction that updated the customer’s <a |
| 263 |
* href="/docs/billing/customer/balance">balances</a>. |
| 264 |
* |
| 265 |
* @param string $parentId |
| 266 |
* @param string $id |
| 267 |
* @param null|array $params |
| 268 |
* @param null|array|\Stripe\Util\RequestOptions $opts |
| 269 |
* |
| 270 |
* @throws \Stripe\Exception\ApiErrorException if the request fails |
| 271 |
* |
| 272 |
* @return \Stripe\CustomerBalanceTransaction |
| 273 |
*/ |
| 274 |
public function retrieveBalanceTransaction($parentId, $id, $params = null, $opts = null) |
| 275 |
{ |
| 276 |
return $this->request('get', $this->buildPath('/v1/customers/%s/balance_transactions/%s', $parentId, $id), $params, $opts); |
| 277 |
} |
| 278 |
|
| 279 |
/** |
| 280 |
* Retrieves a customer’s cash balance. |
| 281 |
* |
| 282 |
* @param string $parentId |
| 283 |
* @param null|array $params |
| 284 |
* @param null|array|\Stripe\Util\RequestOptions $opts |
| 285 |
* |
| 286 |
* @throws \Stripe\Exception\ApiErrorException if the request fails |
| 287 |
* |
| 288 |
* @return \Stripe\cash_balance |
| 289 |
*/ |
| 290 |
public function retrieveCashBalance($parentId, $params = null, $opts = null) |
| 291 |
{ |
| 292 |
return $this->request('get', $this->buildPath('/v1/customers/%s/cash_balance', $parentId), $params, $opts); |
| 293 |
} |
| 294 |
|
| 295 |
/** |
| 296 |
* Retrieve a specified source for a given customer. |
| 297 |
* |
| 298 |
* @param string $parentId |
| 299 |
* @param string $id |
| 300 |
* @param null|array $params |
| 301 |
* @param null|array|\Stripe\Util\RequestOptions $opts |
| 302 |
* |
| 303 |
* @throws \Stripe\Exception\ApiErrorException if the request fails |
| 304 |
* |
| 305 |
* @return \Stripe\AlipayAccount|\Stripe\BankAccount|\Stripe\BitcoinReceiver|\Stripe\Card|\Stripe\Source |
| 306 |
*/ |
| 307 |
public function retrieveSource($parentId, $id, $params = null, $opts = null) |
| 308 |
{ |
| 309 |
return $this->request('get', $this->buildPath('/v1/customers/%s/sources/%s', $parentId, $id), $params, $opts); |
| 310 |
} |
| 311 |
|
| 312 |
/** |
| 313 |
* Retrieves the <code>TaxID</code> object with the given identifier. |
| 314 |
* |
| 315 |
* @param string $parentId |
| 316 |
* @param string $id |
| 317 |
* @param null|array $params |
| 318 |
* @param null|array|\Stripe\Util\RequestOptions $opts |
| 319 |
* |
| 320 |
* @throws \Stripe\Exception\ApiErrorException if the request fails |
| 321 |
* |
| 322 |
* @return \Stripe\TaxId |
| 323 |
*/ |
| 324 |
public function retrieveTaxId($parentId, $id, $params = null, $opts = null) |
| 325 |
{ |
| 326 |
return $this->request('get', $this->buildPath('/v1/customers/%s/tax_ids/%s', $parentId, $id), $params, $opts); |
| 327 |
} |
| 328 |
|
| 329 |
/** |
| 330 |
* Search for customers you’ve previously created using Stripe’s <a |
| 331 |
* href="/docs/search#search-query-language">Search Query Language</a>. Don’t use |
| 332 |
* search in read-after-write flows where strict consistency is necessary. Under |
| 333 |
* normal operating conditions, data is searchable in less than a minute. |
| 334 |
* Occasionally, propagation of new or updated data can be up to an hour behind |
| 335 |
* during outages. Search functionality is not available to merchants in India. |
| 336 |
* |
| 337 |
* @param null|array $params |
| 338 |
* @param null|array|\Stripe\Util\RequestOptions $opts |
| 339 |
* |
| 340 |
* @throws \Stripe\Exception\ApiErrorException if the request fails |
| 341 |
* |
| 342 |
* @return \Stripe\SearchResult<\Stripe\Customer> |
| 343 |
*/ |
| 344 |
public function search($params = null, $opts = null) |
| 345 |
{ |
| 346 |
return $this->requestSearchResult('get', '/v1/customers/search', $params, $opts); |
| 347 |
} |
| 348 |
|
| 349 |
/** |
| 350 |
* Updates the specified customer by setting the values of the parameters passed. |
| 351 |
* Any parameters not provided will be left unchanged. For example, if you pass the |
| 352 |
* <strong>source</strong> parameter, that becomes the customer’s active source |
| 353 |
* (e.g., a card) to be used for all charges in the future. When you update a |
| 354 |
* customer to a new valid card source by passing the <strong>source</strong> |
| 355 |
* parameter: for each of the customer’s current subscriptions, if the subscription |
| 356 |
* bills automatically and is in the <code>past_due</code> state, then the latest |
| 357 |
* open invoice for the subscription with automatic collection enabled will be |
| 358 |
* retried. This retry will not count as an automatic retry, and will not affect |
| 359 |
* the next regularly scheduled payment for the invoice. Changing the |
| 360 |
* <strong>default_source</strong> for a customer will not trigger this behavior. |
| 361 |
* |
| 362 |
* This request accepts mostly the same arguments as the customer creation call. |
| 363 |
* |
| 364 |
* @param string $id |
| 365 |
* @param null|array $params |
| 366 |
* @param null|array|\Stripe\Util\RequestOptions $opts |
| 367 |
* |
| 368 |
* @throws \Stripe\Exception\ApiErrorException if the request fails |
| 369 |
* |
| 370 |
* @return \Stripe\Customer |
| 371 |
*/ |
| 372 |
public function update($id, $params = null, $opts = null) |
| 373 |
{ |
| 374 |
return $this->request('post', $this->buildPath('/v1/customers/%s', $id), $params, $opts); |
| 375 |
} |
| 376 |
|
| 377 |
/** |
| 378 |
* Most credit balance transaction fields are immutable, but you may update its |
| 379 |
* <code>description</code> and <code>metadata</code>. |
| 380 |
* |
| 381 |
* @param string $parentId |
| 382 |
* @param string $id |
| 383 |
* @param null|array $params |
| 384 |
* @param null|array|\Stripe\Util\RequestOptions $opts |
| 385 |
* |
| 386 |
* @throws \Stripe\Exception\ApiErrorException if the request fails |
| 387 |
* |
| 388 |
* @return \Stripe\CustomerBalanceTransaction |
| 389 |
*/ |
| 390 |
public function updateBalanceTransaction($parentId, $id, $params = null, $opts = null) |
| 391 |
{ |
| 392 |
return $this->request('post', $this->buildPath('/v1/customers/%s/balance_transactions/%s', $parentId, $id), $params, $opts); |
| 393 |
} |
| 394 |
|
| 395 |
/** |
| 396 |
* Updates a customer’s cash balance. |
| 397 |
* |
| 398 |
* @param string $parentId |
| 399 |
* @param null|array $params |
| 400 |
* @param null|array|\Stripe\Util\RequestOptions $opts |
| 401 |
* |
| 402 |
* @throws \Stripe\Exception\ApiErrorException if the request fails |
| 403 |
* |
| 404 |
* @return \Stripe\cash_balance |
| 405 |
*/ |
| 406 |
public function updateCashBalance($parentId, $params = null, $opts = null) |
| 407 |
{ |
| 408 |
return $this->request('post', $this->buildPath('/v1/customers/%s/cash_balance', $parentId), $params, $opts); |
| 409 |
} |
| 410 |
|
| 411 |
/** |
| 412 |
* @param string $parentId |
| 413 |
* @param string $id |
| 414 |
* @param null|array $params |
| 415 |
* @param null|array|\Stripe\Util\RequestOptions $opts |
| 416 |
* |
| 417 |
* @throws \Stripe\Exception\ApiErrorException if the request fails |
| 418 |
* |
| 419 |
* @return \Stripe\AlipayAccount|\Stripe\BankAccount|\Stripe\BitcoinReceiver|\Stripe\Card|\Stripe\Source |
| 420 |
*/ |
| 421 |
public function updateSource($parentId, $id, $params = null, $opts = null) |
| 422 |
{ |
| 423 |
return $this->request('post', $this->buildPath('/v1/customers/%s/sources/%s', $parentId, $id), $params, $opts); |
| 424 |
} |
| 425 |
|
| 426 |
/** |
| 427 |
* @param string $parentId |
| 428 |
* @param string $id |
| 429 |
* @param null|array $params |
| 430 |
* @param null|array|\Stripe\Util\RequestOptions $opts |
| 431 |
* |
| 432 |
* @throws \Stripe\Exception\ApiErrorException if the request fails |
| 433 |
* |
| 434 |
* @return \Stripe\AlipayAccount|\Stripe\BankAccount|\Stripe\BitcoinReceiver|\Stripe\Card|\Stripe\Source |
| 435 |
*/ |
| 436 |
public function verifySource($parentId, $id, $params = null, $opts = null) |
| 437 |
{ |
| 438 |
return $this->request('post', $this->buildPath('/v1/customers/%s/sources/%s/verify', $parentId, $id), $params, $opts); |
| 439 |
} |
| 440 |
} |
| 441 |
|