code
stringlengths 15
9.96M
| docstring
stringlengths 1
10.1k
| func_name
stringlengths 1
124
| language
stringclasses 1
value | repo
stringlengths 7
63
| path
stringlengths 6
186
| url
stringlengths 50
236
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
} | Creates a new subscription on an existing customer. Each customer can have up to
500 active or scheduled subscriptions.
When you create a subscription with
<code>collection_method=charge_automatically</code>, the first invoice is
finalized as part of the request. The <code>payment_behavior</code> parameter
determines the exact behavior of the initial payment.
To start subscriptions where the first invoice always begins in a
<code>draft</code> status, use <a
href="/docs/billing/subscriptions/subscription-schedules#managing">subscription
schedules</a> instead. Schedules provide the flexibility to model more complex
billing configurations that change over time.
@param null|array{add_invoice_items?: (array{discounts?: array{coupon?: string, discount?: string, promotion_code?: string}[], price?: string, price_data?: array{currency: string, product: string, tax_behavior?: string, unit_amount?: int, unit_amount_decimal?: string}, quantity?: int, tax_rates?: null|string[]})[], application_fee_percent?: null|float, automatic_tax?: array{enabled: bool, liability?: array{account?: string, type: string}}, backdate_start_date?: int, billing_cycle_anchor?: int, billing_cycle_anchor_config?: array{day_of_month: int, hour?: int, minute?: int, month?: int, second?: int}, cancel_at?: int, cancel_at_period_end?: bool, collection_method?: string, currency?: string, customer: string, days_until_due?: int, default_payment_method?: string, default_source?: string, default_tax_rates?: null|string[], description?: string, discounts?: null|array{coupon?: string, discount?: string, promotion_code?: string}[], expand?: string[], invoice_settings?: array{account_tax_ids?: null|string[], issuer?: array{account?: string, type: string}}, items?: (array{discounts?: null|array{coupon?: string, discount?: string, promotion_code?: string}[], metadata?: StripeObject, plan?: string, price?: string, price_data?: array{currency: string, product: string, recurring: array{interval: string, interval_count?: int}, tax_behavior?: string, unit_amount?: int, unit_amount_decimal?: string}, quantity?: int, tax_rates?: null|string[]})[], metadata?: null|StripeObject, off_session?: bool, on_behalf_of?: null|string, payment_behavior?: string, payment_settings?: array{payment_method_options?: array{acss_debit?: null|array{mandate_options?: array{transaction_type?: string}, verification_method?: string}, bancontact?: null|array{preferred_language?: string}, card?: null|array{mandate_options?: array{amount?: int, amount_type?: string, description?: string}, network?: string, request_three_d_secure?: string}, customer_balance?: null|array{bank_transfer?: array{eu_bank_transfer?: array{country: string}, type?: string}, funding_type?: string}, konbini?: null|array{}, sepa_debit?: null|array{}, us_bank_account?: null|array{financial_connections?: array{filters?: array{account_subcategories?: string[]}, permissions?: string[], prefetch?: string[]}, verification_method?: string}}, payment_method_types?: null|string[], save_default_payment_method?: string}, pending_invoice_item_interval?: null|array{interval: string, interval_count?: int}, proration_behavior?: string, transfer_data?: array{amount_percent?: float, destination: string}, trial_end?: array|int|string, trial_from_plan?: bool, trial_period_days?: int, trial_settings?: array{end_behavior: array{missing_payment_method: string}}} $params
@param null|array|string $options
@return Subscription the created resource
@throws Exception\ApiErrorException if the request fails | create | php | stripe/stripe-php | lib/Subscription.php | https://github.com/stripe/stripe-php/blob/master/lib/Subscription.php | MIT |
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, Collection::class, $params, $opts);
} | By default, returns a list of subscriptions that have not been canceled. In
order to list canceled subscriptions, specify <code>status=canceled</code>.
@param null|array{automatic_tax?: array{enabled: bool}, collection_method?: string, created?: array|int, current_period_end?: array|int, current_period_start?: array|int, customer?: string, ending_before?: string, expand?: string[], limit?: int, plan?: string, price?: string, starting_after?: string, status?: string, test_clock?: string} $params
@param null|array|string $opts
@return Collection<Subscription> of ApiResources
@throws Exception\ApiErrorException if the request fails | all | php | stripe/stripe-php | lib/Subscription.php | https://github.com/stripe/stripe-php/blob/master/lib/Subscription.php | MIT |
public static function retrieve($id, $opts = null)
{
$opts = Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
} | Retrieves the subscription with the given ID.
@param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
@param null|array|string $opts
@return Subscription
@throws Exception\ApiErrorException if the request fails | retrieve | php | stripe/stripe-php | lib/Subscription.php | https://github.com/stripe/stripe-php/blob/master/lib/Subscription.php | MIT |
public static function update($id, $params = null, $opts = null)
{
self::_validateParams($params);
$url = static::resourceUrl($id);
list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
} | Updates an existing subscription to match the specified parameters. When
changing prices or quantities, we optionally prorate the price we charge next
month to make up for any price changes. To preview how the proration is
calculated, use the <a href="/docs/api/invoices/create_preview">create
preview</a> endpoint.
By default, we prorate subscription changes. For example, if a customer signs up
on May 1 for a <currency>100</currency> price, they’ll be billed
<currency>100</currency> immediately. If on May 15 they switch to a
<currency>200</currency> price, then on June 1 they’ll be billed
<currency>250</currency> (<currency>200</currency> for a renewal of her
subscription, plus a <currency>50</currency> prorating adjustment for half of
the previous month’s <currency>100</currency> difference). Similarly, a
downgrade generates a credit that is applied to the next invoice. We also
prorate when you make quantity changes.
Switching prices does not normally change the billing date or generate an
immediate charge unless:
<ul> <li>The billing interval is changed (for example, from monthly to
yearly).</li> <li>The subscription moves from free to paid.</li> <li>A trial
starts or ends.</li> </ul>
In these cases, we apply a credit for the unused time on the previous price,
immediately charge the customer using the new price, and reset the billing date.
Learn about how <a
href="/docs/billing/subscriptions/upgrade-downgrade#immediate-payment">Stripe
immediately attempts payment for subscription changes</a>.
If you want to charge for an upgrade immediately, pass
<code>proration_behavior</code> as <code>always_invoice</code> to create
prorations, automatically invoice the customer for those proration adjustments,
and attempt to collect payment. If you pass <code>create_prorations</code>, the
prorations are created but not automatically invoiced. If you want to bill the
customer for the prorations before the subscription’s renewal date, you need to
manually <a href="/docs/api/invoices/create">invoice the customer</a>.
If you don’t want to prorate, set the <code>proration_behavior</code> option to
<code>none</code>. With this option, the customer is billed
<currency>100</currency> on May 1 and <currency>200</currency> on June 1.
Similarly, if you set <code>proration_behavior</code> to <code>none</code> when
switching between different billing intervals (for example, from monthly to
yearly), we don’t generate any credits for the old subscription’s unused time.
We still reset the billing date and bill immediately for the new subscription.
Updating the quantity on a subscription many times in an hour may result in <a
href="/docs/rate-limits">rate limiting</a>. If you need to bill for a frequently
changing quantity, consider integrating <a
href="/docs/billing/subscriptions/usage-based">usage-based billing</a> instead.
@param string $id the ID of the resource to update
@param null|array{add_invoice_items?: (array{discounts?: array{coupon?: string, discount?: string, promotion_code?: string}[], price?: string, price_data?: array{currency: string, product: string, tax_behavior?: string, unit_amount?: int, unit_amount_decimal?: string}, quantity?: int, tax_rates?: null|string[]})[], application_fee_percent?: null|float, automatic_tax?: array{enabled: bool, liability?: array{account?: string, type: string}}, billing_cycle_anchor?: string, cancel_at?: null|int, cancel_at_period_end?: bool, cancellation_details?: array{comment?: null|string, feedback?: null|string}, collection_method?: string, days_until_due?: int, default_payment_method?: string, default_source?: null|string, default_tax_rates?: null|string[], description?: null|string, discounts?: null|array{coupon?: string, discount?: string, promotion_code?: string}[], expand?: string[], invoice_settings?: array{account_tax_ids?: null|string[], issuer?: array{account?: string, type: string}}, items?: (array{clear_usage?: bool, deleted?: bool, discounts?: null|array{coupon?: string, discount?: string, promotion_code?: string}[], id?: string, metadata?: null|StripeObject, plan?: string, price?: string, price_data?: array{currency: string, product: string, recurring: array{interval: string, interval_count?: int}, tax_behavior?: string, unit_amount?: int, unit_amount_decimal?: string}, quantity?: int, tax_rates?: null|string[]})[], metadata?: null|StripeObject, off_session?: bool, on_behalf_of?: null|string, pause_collection?: null|array{behavior: string, resumes_at?: int}, payment_behavior?: string, payment_settings?: array{payment_method_options?: array{acss_debit?: null|array{mandate_options?: array{transaction_type?: string}, verification_method?: string}, bancontact?: null|array{preferred_language?: string}, card?: null|array{mandate_options?: array{amount?: int, amount_type?: string, description?: string}, network?: string, request_three_d_secure?: string}, customer_balance?: null|array{bank_transfer?: array{eu_bank_transfer?: array{country: string}, type?: string}, funding_type?: string}, konbini?: null|array{}, sepa_debit?: null|array{}, us_bank_account?: null|array{financial_connections?: array{filters?: array{account_subcategories?: string[]}, permissions?: string[], prefetch?: string[]}, verification_method?: string}}, payment_method_types?: null|string[], save_default_payment_method?: string}, pending_invoice_item_interval?: null|array{interval: string, interval_count?: int}, proration_behavior?: string, proration_date?: int, transfer_data?: null|array{amount_percent?: float, destination: string}, trial_end?: array|int|string, trial_from_plan?: bool, trial_settings?: array{end_behavior: array{missing_payment_method: string}}} $params
@param null|array|string $opts
@return Subscription the updated resource
@throws Exception\ApiErrorException if the request fails | update | php | stripe/stripe-php | lib/Subscription.php | https://github.com/stripe/stripe-php/blob/master/lib/Subscription.php | MIT |
public function deleteDiscount($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/discount';
list($response, $opts) = $this->_request('delete', $url, $params, $opts);
$this->refreshFrom(['discount' => null], $opts, true);
return $this;
} | @param null|array $params
@param null|array|string $opts
@return Subscription the updated subscription
@throws Exception\ApiErrorException if the request fails | deleteDiscount | php | stripe/stripe-php | lib/Subscription.php | https://github.com/stripe/stripe-php/blob/master/lib/Subscription.php | MIT |
public function cancel($params = null, $opts = null)
{
$url = $this->instanceUrl();
list($response, $opts) = $this->_request('delete', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
} | @param null|array $params
@param null|array|string $opts
@return Subscription the canceled subscription
@throws Exception\ApiErrorException if the request fails | cancel | php | stripe/stripe-php | lib/Subscription.php | https://github.com/stripe/stripe-php/blob/master/lib/Subscription.php | MIT |
public function resume($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/resume';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
} | @param null|array $params
@param null|array|string $opts
@return Subscription the resumed subscription
@throws Exception\ApiErrorException if the request fails | resume | php | stripe/stripe-php | lib/Subscription.php | https://github.com/stripe/stripe-php/blob/master/lib/Subscription.php | MIT |
public static function search($params = null, $opts = null)
{
$url = '/v1/subscriptions/search';
return static::_requestPage($url, SearchResult::class, $params, $opts);
} | @param null|array $params
@param null|array|string $opts
@return SearchResult<Subscription> the subscription search results
@throws Exception\ApiErrorException if the request fails | search | php | stripe/stripe-php | lib/Subscription.php | https://github.com/stripe/stripe-php/blob/master/lib/Subscription.php | MIT |
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
} | Creates a new file link object.
@param null|array{expand?: string[], expires_at?: int, file: string, metadata?: null|StripeObject} $params
@param null|array|string $options
@return FileLink the created resource
@throws Exception\ApiErrorException if the request fails | create | php | stripe/stripe-php | lib/FileLink.php | https://github.com/stripe/stripe-php/blob/master/lib/FileLink.php | MIT |
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, Collection::class, $params, $opts);
} | Returns a list of file links.
@param null|array{created?: array|int, ending_before?: string, expand?: string[], expired?: bool, file?: string, limit?: int, starting_after?: string} $params
@param null|array|string $opts
@return Collection<FileLink> of ApiResources
@throws Exception\ApiErrorException if the request fails | all | php | stripe/stripe-php | lib/FileLink.php | https://github.com/stripe/stripe-php/blob/master/lib/FileLink.php | MIT |
public static function retrieve($id, $opts = null)
{
$opts = Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
} | Retrieves the file link with the given ID.
@param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
@param null|array|string $opts
@return FileLink
@throws Exception\ApiErrorException if the request fails | retrieve | php | stripe/stripe-php | lib/FileLink.php | https://github.com/stripe/stripe-php/blob/master/lib/FileLink.php | MIT |
public static function update($id, $params = null, $opts = null)
{
self::_validateParams($params);
$url = static::resourceUrl($id);
list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
} | Updates an existing file link object. Expired links can no longer be updated.
@param string $id the ID of the resource to update
@param null|array{expand?: string[], expires_at?: null|array|int|string, metadata?: null|StripeObject} $params
@param null|array|string $opts
@return FileLink the updated resource
@throws Exception\ApiErrorException if the request fails | update | php | stripe/stripe-php | lib/FileLink.php | https://github.com/stripe/stripe-php/blob/master/lib/FileLink.php | MIT |
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
} | You can create coupons easily via the <a
href="https://dashboard.stripe.com/coupons">coupon management</a> page of the
Stripe dashboard. Coupon creation is also accessible via the API if you need to
create coupons on the fly.
A coupon has either a <code>percent_off</code> or an <code>amount_off</code> and
<code>currency</code>. If you set an <code>amount_off</code>, that amount will
be subtracted from any invoice’s subtotal. For example, an invoice with a
subtotal of <currency>100</currency> will have a final total of
<currency>0</currency> if a coupon with an <code>amount_off</code> of
<amount>200</amount> is applied to it and an invoice with a subtotal of
<currency>300</currency> will have a final total of <currency>100</currency> if
a coupon with an <code>amount_off</code> of <amount>200</amount> is applied to
it.
@param null|array{amount_off?: int, applies_to?: array{products?: string[]}, currency?: string, currency_options?: StripeObject, duration?: string, duration_in_months?: int, expand?: string[], id?: string, max_redemptions?: int, metadata?: null|StripeObject, name?: string, percent_off?: float, redeem_by?: int} $params
@param null|array|string $options
@return Coupon the created resource
@throws Exception\ApiErrorException if the request fails | create | php | stripe/stripe-php | lib/Coupon.php | https://github.com/stripe/stripe-php/blob/master/lib/Coupon.php | MIT |
public function delete($params = null, $opts = null)
{
self::_validateParams($params);
$url = $this->instanceUrl();
list($response, $opts) = $this->_request('delete', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
} | You can delete coupons via the <a
href="https://dashboard.stripe.com/coupons">coupon management</a> page of the
Stripe dashboard. However, deleting a coupon does not affect any customers who
have already applied the coupon; it means that new customers can’t redeem the
coupon. You can also delete coupons via the API.
@param null|array $params
@param null|array|string $opts
@return Coupon the deleted resource
@throws Exception\ApiErrorException if the request fails | delete | php | stripe/stripe-php | lib/Coupon.php | https://github.com/stripe/stripe-php/blob/master/lib/Coupon.php | MIT |
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, Collection::class, $params, $opts);
} | Returns a list of your coupons.
@param null|array{created?: array|int, ending_before?: string, expand?: string[], limit?: int, starting_after?: string} $params
@param null|array|string $opts
@return Collection<Coupon> of ApiResources
@throws Exception\ApiErrorException if the request fails | all | php | stripe/stripe-php | lib/Coupon.php | https://github.com/stripe/stripe-php/blob/master/lib/Coupon.php | MIT |
public static function retrieve($id, $opts = null)
{
$opts = Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
} | Retrieves the coupon with the given ID.
@param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
@param null|array|string $opts
@return Coupon
@throws Exception\ApiErrorException if the request fails | retrieve | php | stripe/stripe-php | lib/Coupon.php | https://github.com/stripe/stripe-php/blob/master/lib/Coupon.php | MIT |
public static function update($id, $params = null, $opts = null)
{
self::_validateParams($params);
$url = static::resourceUrl($id);
list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
} | Updates the metadata of a coupon. Other coupon details (currency, duration,
amount_off) are, by design, not editable.
@param string $id the ID of the resource to update
@param null|array{currency_options?: StripeObject, expand?: string[], metadata?: null|StripeObject, name?: string} $params
@param null|array|string $opts
@return Coupon the updated resource
@throws Exception\ApiErrorException if the request fails | update | php | stripe/stripe-php | lib/Coupon.php | https://github.com/stripe/stripe-php/blob/master/lib/Coupon.php | MIT |
public static function verifyHeader($payload, $header, $secret, $tolerance = null)
{
// Extract timestamp and signatures from header
$timestamp = self::getTimestamp($header);
$signatures = self::getSignatures($header, self::EXPECTED_SCHEME);
if (-1 === $timestamp) {
throw Exception\SignatureVerificationException::factory(
'Unable to extract timestamp and signatures from header',
$payload,
$header
);
}
if (empty($signatures)) {
throw Exception\SignatureVerificationException::factory(
'No signatures found with expected scheme',
$payload,
$header
);
}
// Check if expected signature is found in list of signatures from
// header
$signedPayload = "{$timestamp}.{$payload}";
$expectedSignature = self::computeSignature($signedPayload, $secret);
$signatureFound = false;
foreach ($signatures as $signature) {
if (Util\Util::secureCompare($expectedSignature, $signature)) {
$signatureFound = true;
break;
}
}
if (!$signatureFound) {
throw Exception\SignatureVerificationException::factory(
'No signatures found matching the expected signature for payload',
$payload,
$header
);
}
// Check if timestamp is within tolerance
if (($tolerance > 0) && (\abs(\time() - $timestamp) > $tolerance)) {
throw Exception\SignatureVerificationException::factory(
'Timestamp outside the tolerance zone',
$payload,
$header
);
}
return true;
} | Verifies the signature header sent by Stripe. Throws an
Exception\SignatureVerificationException exception if the verification fails for
any reason.
@param string $payload the payload sent by Stripe
@param string $header the contents of the signature header sent by
Stripe
@param string $secret secret used to generate the signature
@param int $tolerance maximum difference allowed between the header's
timestamp and the current time
@return bool
@throws Exception\SignatureVerificationException if the verification fails | verifyHeader | php | stripe/stripe-php | lib/WebhookSignature.php | https://github.com/stripe/stripe-php/blob/master/lib/WebhookSignature.php | MIT |
private static function computeSignature($payload, $secret)
{
return \hash_hmac('sha256', $payload, $secret);
} | Computes the signature for a given payload and secret.
The current scheme used by Stripe ("v1") is HMAC/SHA-256.
@param string $payload the payload to sign
@param string $secret the secret used to generate the signature
@return string the signature as a string | computeSignature | php | stripe/stripe-php | lib/WebhookSignature.php | https://github.com/stripe/stripe-php/blob/master/lib/WebhookSignature.php | MIT |
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
} | Creates a SetupIntent object.
After you create the SetupIntent, attach a payment method and <a
href="/docs/api/setup_intents/confirm">confirm</a> it to collect any required
permissions to charge the payment method later.
@param null|array{attach_to_self?: bool, automatic_payment_methods?: array{allow_redirects?: string, enabled: bool}, confirm?: bool, confirmation_token?: string, customer?: string, description?: string, expand?: string[], flow_directions?: string[], mandate_data?: null|array{customer_acceptance: array{accepted_at?: int, offline?: array{}, online?: array{ip_address: string, user_agent: string}, type: string}}, metadata?: StripeObject, on_behalf_of?: string, payment_method?: string, payment_method_configuration?: string, payment_method_data?: array{acss_debit?: array{account_number: string, institution_number: string, transit_number: string}, affirm?: array{}, afterpay_clearpay?: array{}, alipay?: array{}, allow_redisplay?: string, alma?: array{}, amazon_pay?: array{}, au_becs_debit?: array{account_number: string, bsb_number: string}, bacs_debit?: array{account_number?: string, sort_code?: string}, bancontact?: array{}, billie?: array{}, billing_details?: array{address?: null|array{city?: string, country?: string, line1?: string, line2?: string, postal_code?: string, state?: string}, email?: null|string, name?: null|string, phone?: null|string, tax_id?: string}, blik?: array{}, boleto?: array{tax_id: string}, cashapp?: array{}, customer_balance?: array{}, eps?: array{bank?: string}, fpx?: array{account_holder_type?: string, bank: string}, giropay?: array{}, grabpay?: array{}, ideal?: array{bank?: string}, interac_present?: array{}, kakao_pay?: array{}, klarna?: array{dob?: array{day: int, month: int, year: int}}, konbini?: array{}, kr_card?: array{}, link?: array{}, metadata?: StripeObject, mobilepay?: array{}, multibanco?: array{}, naver_pay?: array{funding?: string}, nz_bank_account?: array{account_holder_name?: string, account_number: string, bank_code: string, branch_code: string, reference?: string, suffix: string}, oxxo?: array{}, p24?: array{bank?: string}, pay_by_bank?: array{}, payco?: array{}, paynow?: array{}, paypal?: array{}, pix?: array{}, promptpay?: array{}, radar_options?: array{session?: string}, revolut_pay?: array{}, samsung_pay?: array{}, satispay?: array{}, sepa_debit?: array{iban: string}, sofort?: array{country: string}, swish?: array{}, twint?: array{}, type: string, us_bank_account?: array{account_holder_type?: string, account_number?: string, account_type?: string, financial_connections_account?: string, routing_number?: string}, wechat_pay?: array{}, zip?: array{}}, payment_method_options?: array{acss_debit?: array{currency?: string, mandate_options?: array{custom_mandate_url?: null|string, default_for?: string[], interval_description?: string, payment_schedule?: string, transaction_type?: string}, verification_method?: string}, amazon_pay?: array{}, bacs_debit?: array{mandate_options?: array{reference_prefix?: null|string}}, card?: array{mandate_options?: array{amount: int, amount_type: string, currency: string, description?: string, end_date?: int, interval: string, interval_count?: int, reference: string, start_date: int, supported_types?: string[]}, moto?: bool, network?: string, request_three_d_secure?: string, three_d_secure?: array{ares_trans_status?: string, cryptogram?: string, electronic_commerce_indicator?: string, network_options?: array{cartes_bancaires?: array{cb_avalgo: string, cb_exemption?: string, cb_score?: int}}, requestor_challenge_indicator?: string, transaction_id?: string, version?: string}}, card_present?: array{}, link?: array{persistent_token?: string}, paypal?: array{billing_agreement_id?: string}, sepa_debit?: array{mandate_options?: array{reference_prefix?: null|string}}, us_bank_account?: array{financial_connections?: array{filters?: array{account_subcategories?: string[]}, permissions?: string[], prefetch?: string[], return_url?: string}, mandate_options?: array{collection_method?: null|string}, networks?: array{requested?: string[]}, verification_method?: string}}, payment_method_types?: string[], return_url?: string, single_use?: array{amount: int, currency: string}, usage?: string, use_stripe_sdk?: bool} $params
@param null|array|string $options
@return SetupIntent the created resource
@throws Exception\ApiErrorException if the request fails | create | php | stripe/stripe-php | lib/SetupIntent.php | https://github.com/stripe/stripe-php/blob/master/lib/SetupIntent.php | MIT |
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, Collection::class, $params, $opts);
} | Returns a list of SetupIntents.
@param null|array{attach_to_self?: bool, created?: array|int, customer?: string, ending_before?: string, expand?: string[], limit?: int, payment_method?: string, starting_after?: string} $params
@param null|array|string $opts
@return Collection<SetupIntent> of ApiResources
@throws Exception\ApiErrorException if the request fails | all | php | stripe/stripe-php | lib/SetupIntent.php | https://github.com/stripe/stripe-php/blob/master/lib/SetupIntent.php | MIT |
public static function retrieve($id, $opts = null)
{
$opts = Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
} | Retrieves the details of a SetupIntent that has previously been created.
Client-side retrieval using a publishable key is allowed when the
<code>client_secret</code> is provided in the query string.
When retrieved with a publishable key, only a subset of properties will be
returned. Please refer to the <a href="#setup_intent_object">SetupIntent</a>
object reference for more details.
@param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
@param null|array|string $opts
@return SetupIntent
@throws Exception\ApiErrorException if the request fails | retrieve | php | stripe/stripe-php | lib/SetupIntent.php | https://github.com/stripe/stripe-php/blob/master/lib/SetupIntent.php | MIT |
public static function update($id, $params = null, $opts = null)
{
self::_validateParams($params);
$url = static::resourceUrl($id);
list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
} | Updates a SetupIntent object.
@param string $id the ID of the resource to update
@param null|array{attach_to_self?: bool, customer?: string, description?: string, expand?: string[], flow_directions?: string[], metadata?: null|StripeObject, payment_method?: string, payment_method_configuration?: string, payment_method_data?: array{acss_debit?: array{account_number: string, institution_number: string, transit_number: string}, affirm?: array{}, afterpay_clearpay?: array{}, alipay?: array{}, allow_redisplay?: string, alma?: array{}, amazon_pay?: array{}, au_becs_debit?: array{account_number: string, bsb_number: string}, bacs_debit?: array{account_number?: string, sort_code?: string}, bancontact?: array{}, billie?: array{}, billing_details?: array{address?: null|array{city?: string, country?: string, line1?: string, line2?: string, postal_code?: string, state?: string}, email?: null|string, name?: null|string, phone?: null|string, tax_id?: string}, blik?: array{}, boleto?: array{tax_id: string}, cashapp?: array{}, customer_balance?: array{}, eps?: array{bank?: string}, fpx?: array{account_holder_type?: string, bank: string}, giropay?: array{}, grabpay?: array{}, ideal?: array{bank?: string}, interac_present?: array{}, kakao_pay?: array{}, klarna?: array{dob?: array{day: int, month: int, year: int}}, konbini?: array{}, kr_card?: array{}, link?: array{}, metadata?: StripeObject, mobilepay?: array{}, multibanco?: array{}, naver_pay?: array{funding?: string}, nz_bank_account?: array{account_holder_name?: string, account_number: string, bank_code: string, branch_code: string, reference?: string, suffix: string}, oxxo?: array{}, p24?: array{bank?: string}, pay_by_bank?: array{}, payco?: array{}, paynow?: array{}, paypal?: array{}, pix?: array{}, promptpay?: array{}, radar_options?: array{session?: string}, revolut_pay?: array{}, samsung_pay?: array{}, satispay?: array{}, sepa_debit?: array{iban: string}, sofort?: array{country: string}, swish?: array{}, twint?: array{}, type: string, us_bank_account?: array{account_holder_type?: string, account_number?: string, account_type?: string, financial_connections_account?: string, routing_number?: string}, wechat_pay?: array{}, zip?: array{}}, payment_method_options?: array{acss_debit?: array{currency?: string, mandate_options?: array{custom_mandate_url?: null|string, default_for?: string[], interval_description?: string, payment_schedule?: string, transaction_type?: string}, verification_method?: string}, amazon_pay?: array{}, bacs_debit?: array{mandate_options?: array{reference_prefix?: null|string}}, card?: array{mandate_options?: array{amount: int, amount_type: string, currency: string, description?: string, end_date?: int, interval: string, interval_count?: int, reference: string, start_date: int, supported_types?: string[]}, moto?: bool, network?: string, request_three_d_secure?: string, three_d_secure?: array{ares_trans_status?: string, cryptogram?: string, electronic_commerce_indicator?: string, network_options?: array{cartes_bancaires?: array{cb_avalgo: string, cb_exemption?: string, cb_score?: int}}, requestor_challenge_indicator?: string, transaction_id?: string, version?: string}}, card_present?: array{}, link?: array{persistent_token?: string}, paypal?: array{billing_agreement_id?: string}, sepa_debit?: array{mandate_options?: array{reference_prefix?: null|string}}, us_bank_account?: array{financial_connections?: array{filters?: array{account_subcategories?: string[]}, permissions?: string[], prefetch?: string[], return_url?: string}, mandate_options?: array{collection_method?: null|string}, networks?: array{requested?: string[]}, verification_method?: string}}, payment_method_types?: string[]} $params
@param null|array|string $opts
@return SetupIntent the updated resource
@throws Exception\ApiErrorException if the request fails | update | php | stripe/stripe-php | lib/SetupIntent.php | https://github.com/stripe/stripe-php/blob/master/lib/SetupIntent.php | MIT |
public function cancel($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/cancel';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
} | @param null|array $params
@param null|array|string $opts
@return SetupIntent the canceled setup intent
@throws Exception\ApiErrorException if the request fails | cancel | php | stripe/stripe-php | lib/SetupIntent.php | https://github.com/stripe/stripe-php/blob/master/lib/SetupIntent.php | MIT |
public function confirm($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/confirm';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
} | @param null|array $params
@param null|array|string $opts
@return SetupIntent the confirmed setup intent
@throws Exception\ApiErrorException if the request fails | confirm | php | stripe/stripe-php | lib/SetupIntent.php | https://github.com/stripe/stripe-php/blob/master/lib/SetupIntent.php | MIT |
public function verifyMicrodeposits($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/verify_microdeposits';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
} | @param null|array $params
@param null|array|string $opts
@return SetupIntent the verified setup intent
@throws Exception\ApiErrorException if the request fails | verifyMicrodeposits | php | stripe/stripe-php | lib/SetupIntent.php | https://github.com/stripe/stripe-php/blob/master/lib/SetupIntent.php | MIT |
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
} | Creates a payment method configuration.
@param null|array{acss_debit?: array{display_preference?: array{preference?: string}}, affirm?: array{display_preference?: array{preference?: string}}, afterpay_clearpay?: array{display_preference?: array{preference?: string}}, alipay?: array{display_preference?: array{preference?: string}}, alma?: array{display_preference?: array{preference?: string}}, amazon_pay?: array{display_preference?: array{preference?: string}}, apple_pay?: array{display_preference?: array{preference?: string}}, apple_pay_later?: array{display_preference?: array{preference?: string}}, au_becs_debit?: array{display_preference?: array{preference?: string}}, bacs_debit?: array{display_preference?: array{preference?: string}}, bancontact?: array{display_preference?: array{preference?: string}}, billie?: array{display_preference?: array{preference?: string}}, blik?: array{display_preference?: array{preference?: string}}, boleto?: array{display_preference?: array{preference?: string}}, card?: array{display_preference?: array{preference?: string}}, cartes_bancaires?: array{display_preference?: array{preference?: string}}, cashapp?: array{display_preference?: array{preference?: string}}, customer_balance?: array{display_preference?: array{preference?: string}}, eps?: array{display_preference?: array{preference?: string}}, expand?: string[], fpx?: array{display_preference?: array{preference?: string}}, giropay?: array{display_preference?: array{preference?: string}}, google_pay?: array{display_preference?: array{preference?: string}}, grabpay?: array{display_preference?: array{preference?: string}}, ideal?: array{display_preference?: array{preference?: string}}, jcb?: array{display_preference?: array{preference?: string}}, klarna?: array{display_preference?: array{preference?: string}}, konbini?: array{display_preference?: array{preference?: string}}, link?: array{display_preference?: array{preference?: string}}, mobilepay?: array{display_preference?: array{preference?: string}}, multibanco?: array{display_preference?: array{preference?: string}}, name?: string, nz_bank_account?: array{display_preference?: array{preference?: string}}, oxxo?: array{display_preference?: array{preference?: string}}, p24?: array{display_preference?: array{preference?: string}}, parent?: string, pay_by_bank?: array{display_preference?: array{preference?: string}}, paynow?: array{display_preference?: array{preference?: string}}, paypal?: array{display_preference?: array{preference?: string}}, pix?: array{display_preference?: array{preference?: string}}, promptpay?: array{display_preference?: array{preference?: string}}, revolut_pay?: array{display_preference?: array{preference?: string}}, satispay?: array{display_preference?: array{preference?: string}}, sepa_debit?: array{display_preference?: array{preference?: string}}, sofort?: array{display_preference?: array{preference?: string}}, swish?: array{display_preference?: array{preference?: string}}, twint?: array{display_preference?: array{preference?: string}}, us_bank_account?: array{display_preference?: array{preference?: string}}, wechat_pay?: array{display_preference?: array{preference?: string}}, zip?: array{display_preference?: array{preference?: string}}} $params
@param null|array|string $options
@return PaymentMethodConfiguration the created resource
@throws Exception\ApiErrorException if the request fails | create | php | stripe/stripe-php | lib/PaymentMethodConfiguration.php | https://github.com/stripe/stripe-php/blob/master/lib/PaymentMethodConfiguration.php | MIT |
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, Collection::class, $params, $opts);
} | List payment method configurations.
@param null|array{application?: null|string, ending_before?: string, expand?: string[], limit?: int, starting_after?: string} $params
@param null|array|string $opts
@return Collection<PaymentMethodConfiguration> of ApiResources
@throws Exception\ApiErrorException if the request fails | all | php | stripe/stripe-php | lib/PaymentMethodConfiguration.php | https://github.com/stripe/stripe-php/blob/master/lib/PaymentMethodConfiguration.php | MIT |
public static function retrieve($id, $opts = null)
{
$opts = Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
} | Retrieve payment method configuration.
@param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
@param null|array|string $opts
@return PaymentMethodConfiguration
@throws Exception\ApiErrorException if the request fails | retrieve | php | stripe/stripe-php | lib/PaymentMethodConfiguration.php | https://github.com/stripe/stripe-php/blob/master/lib/PaymentMethodConfiguration.php | MIT |
public static function update($id, $params = null, $opts = null)
{
self::_validateParams($params);
$url = static::resourceUrl($id);
list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
} | Update payment method configuration.
@param string $id the ID of the resource to update
@param null|array{acss_debit?: array{display_preference?: array{preference?: string}}, active?: bool, affirm?: array{display_preference?: array{preference?: string}}, afterpay_clearpay?: array{display_preference?: array{preference?: string}}, alipay?: array{display_preference?: array{preference?: string}}, alma?: array{display_preference?: array{preference?: string}}, amazon_pay?: array{display_preference?: array{preference?: string}}, apple_pay?: array{display_preference?: array{preference?: string}}, apple_pay_later?: array{display_preference?: array{preference?: string}}, au_becs_debit?: array{display_preference?: array{preference?: string}}, bacs_debit?: array{display_preference?: array{preference?: string}}, bancontact?: array{display_preference?: array{preference?: string}}, billie?: array{display_preference?: array{preference?: string}}, blik?: array{display_preference?: array{preference?: string}}, boleto?: array{display_preference?: array{preference?: string}}, card?: array{display_preference?: array{preference?: string}}, cartes_bancaires?: array{display_preference?: array{preference?: string}}, cashapp?: array{display_preference?: array{preference?: string}}, customer_balance?: array{display_preference?: array{preference?: string}}, eps?: array{display_preference?: array{preference?: string}}, expand?: string[], fpx?: array{display_preference?: array{preference?: string}}, giropay?: array{display_preference?: array{preference?: string}}, google_pay?: array{display_preference?: array{preference?: string}}, grabpay?: array{display_preference?: array{preference?: string}}, ideal?: array{display_preference?: array{preference?: string}}, jcb?: array{display_preference?: array{preference?: string}}, klarna?: array{display_preference?: array{preference?: string}}, konbini?: array{display_preference?: array{preference?: string}}, link?: array{display_preference?: array{preference?: string}}, mobilepay?: array{display_preference?: array{preference?: string}}, multibanco?: array{display_preference?: array{preference?: string}}, name?: string, nz_bank_account?: array{display_preference?: array{preference?: string}}, oxxo?: array{display_preference?: array{preference?: string}}, p24?: array{display_preference?: array{preference?: string}}, pay_by_bank?: array{display_preference?: array{preference?: string}}, paynow?: array{display_preference?: array{preference?: string}}, paypal?: array{display_preference?: array{preference?: string}}, pix?: array{display_preference?: array{preference?: string}}, promptpay?: array{display_preference?: array{preference?: string}}, revolut_pay?: array{display_preference?: array{preference?: string}}, satispay?: array{display_preference?: array{preference?: string}}, sepa_debit?: array{display_preference?: array{preference?: string}}, sofort?: array{display_preference?: array{preference?: string}}, swish?: array{display_preference?: array{preference?: string}}, twint?: array{display_preference?: array{preference?: string}}, us_bank_account?: array{display_preference?: array{preference?: string}}, wechat_pay?: array{display_preference?: array{preference?: string}}, zip?: array{display_preference?: array{preference?: string}}} $params
@param null|array|string $opts
@return PaymentMethodConfiguration the updated resource
@throws Exception\ApiErrorException if the request fails | update | php | stripe/stripe-php | lib/PaymentMethodConfiguration.php | https://github.com/stripe/stripe-php/blob/master/lib/PaymentMethodConfiguration.php | MIT |
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
} | Creates a new customer object.
@param null|array{address?: null|array{city?: string, country?: string, line1?: string, line2?: string, postal_code?: string, state?: string}, balance?: int, cash_balance?: array{settings?: array{reconciliation_mode?: string}}, description?: string, email?: string, expand?: string[], invoice_prefix?: string, invoice_settings?: array{custom_fields?: null|array{name: string, value: string}[], default_payment_method?: string, footer?: string, rendering_options?: null|array{amount_tax_display?: null|string, template?: string}}, metadata?: null|StripeObject, name?: string, next_invoice_sequence?: int, payment_method?: string, phone?: string, preferred_locales?: string[], shipping?: null|array{address: array{city?: string, country?: string, line1?: string, line2?: string, postal_code?: string, state?: string}, name: string, phone?: string}, source?: string, tax?: array{ip_address?: null|string, validate_location?: string}, tax_exempt?: null|string, tax_id_data?: array{type: string, value: string}[], test_clock?: string, validate?: bool} $params
@param null|array|string $options
@return Customer the created resource
@throws Exception\ApiErrorException if the request fails | create | php | stripe/stripe-php | lib/Customer.php | https://github.com/stripe/stripe-php/blob/master/lib/Customer.php | MIT |
public function delete($params = null, $opts = null)
{
self::_validateParams($params);
$url = $this->instanceUrl();
list($response, $opts) = $this->_request('delete', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
} | Permanently deletes a customer. It cannot be undone. Also immediately cancels
any active subscriptions on the customer.
@param null|array $params
@param null|array|string $opts
@return Customer the deleted resource
@throws Exception\ApiErrorException if the request fails | delete | php | stripe/stripe-php | lib/Customer.php | https://github.com/stripe/stripe-php/blob/master/lib/Customer.php | MIT |
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, Collection::class, $params, $opts);
} | Returns a list of your customers. The customers are returned sorted by creation
date, with the most recent customers appearing first.
@param null|array{created?: array|int, email?: string, ending_before?: string, expand?: string[], limit?: int, starting_after?: string, test_clock?: string} $params
@param null|array|string $opts
@return Collection<Customer> of ApiResources
@throws Exception\ApiErrorException if the request fails | all | php | stripe/stripe-php | lib/Customer.php | https://github.com/stripe/stripe-php/blob/master/lib/Customer.php | MIT |
public static function retrieve($id, $opts = null)
{
$opts = Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
} | Retrieves a Customer object.
@param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
@param null|array|string $opts
@return Customer
@throws Exception\ApiErrorException if the request fails | retrieve | php | stripe/stripe-php | lib/Customer.php | https://github.com/stripe/stripe-php/blob/master/lib/Customer.php | MIT |
public static function update($id, $params = null, $opts = null)
{
self::_validateParams($params);
$url = static::resourceUrl($id);
list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
} | Updates the specified customer by setting the values of the parameters passed.
Any parameters not provided will be left unchanged. For example, if you pass the
<strong>source</strong> parameter, that becomes the customer’s active source
(e.g., a card) to be used for all charges in the future. When you update a
customer to a new valid card source by passing the <strong>source</strong>
parameter: for each of the customer’s current subscriptions, if the subscription
bills automatically and is in the <code>past_due</code> state, then the latest
open invoice for the subscription with automatic collection enabled will be
retried. This retry will not count as an automatic retry, and will not affect
the next regularly scheduled payment for the invoice. Changing the
<strong>default_source</strong> for a customer will not trigger this behavior.
This request accepts mostly the same arguments as the customer creation call.
@param string $id the ID of the resource to update
@param null|array{address?: null|array{city?: string, country?: string, line1?: string, line2?: string, postal_code?: string, state?: string}, balance?: int, cash_balance?: array{settings?: array{reconciliation_mode?: string}}, default_source?: string, description?: string, email?: string, expand?: string[], invoice_prefix?: string, invoice_settings?: array{custom_fields?: null|array{name: string, value: string}[], default_payment_method?: string, footer?: string, rendering_options?: null|array{amount_tax_display?: null|string, template?: string}}, metadata?: null|StripeObject, name?: string, next_invoice_sequence?: int, phone?: string, preferred_locales?: string[], shipping?: null|array{address: array{city?: string, country?: string, line1?: string, line2?: string, postal_code?: string, state?: string}, name: string, phone?: string}, source?: string, tax?: array{ip_address?: null|string, validate_location?: string}, tax_exempt?: null|string, validate?: bool} $params
@param null|array|string $opts
@return Customer the updated resource
@throws Exception\ApiErrorException if the request fails | update | php | stripe/stripe-php | lib/Customer.php | https://github.com/stripe/stripe-php/blob/master/lib/Customer.php | MIT |
public function deleteDiscount($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/discount';
list($response, $opts) = $this->_request('delete', $url, $params, $opts);
$this->refreshFrom(['discount' => null], $opts, true);
return $this;
} | @param null|array $params
@param null|array|string $opts
@return Customer the updated customer | deleteDiscount | php | stripe/stripe-php | lib/Customer.php | https://github.com/stripe/stripe-php/blob/master/lib/Customer.php | MIT |
public static function allPaymentMethods($id, $params = null, $opts = null)
{
$url = static::resourceUrl($id) . '/payment_methods';
list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
} | @param string $id
@param null|array $params
@param null|array|string $opts
@return Collection<PaymentMethod> list of payment methods
@throws Exception\ApiErrorException if the request fails | allPaymentMethods | php | stripe/stripe-php | lib/Customer.php | https://github.com/stripe/stripe-php/blob/master/lib/Customer.php | MIT |
public function retrievePaymentMethod($payment_method, $params = null, $opts = null)
{
$url = $this->instanceUrl() . '/payment_methods/' . $payment_method;
list($response, $opts) = $this->_request('get', $url, $params, $opts);
$obj = Util\Util::convertToStripeObject($response, $opts);
$obj->setLastResponse($response);
return $obj;
} | @param string $payment_method
@param null|array $params
@param null|array|string $opts
@return PaymentMethod the retrieved payment method
@throws Exception\ApiErrorException if the request fails | retrievePaymentMethod | php | stripe/stripe-php | lib/Customer.php | https://github.com/stripe/stripe-php/blob/master/lib/Customer.php | MIT |
public static function search($params = null, $opts = null)
{
$url = '/v1/customers/search';
return static::_requestPage($url, SearchResult::class, $params, $opts);
} | @param null|array $params
@param null|array|string $opts
@return SearchResult<Customer> the customer search results
@throws Exception\ApiErrorException if the request fails | search | php | stripe/stripe-php | lib/Customer.php | https://github.com/stripe/stripe-php/blob/master/lib/Customer.php | MIT |
public static function retrieveCashBalance($id, $cashBalanceId, $params = null, $opts = null)
{
return self::_retrieveNestedResource($id, static::PATH_CASH_BALANCE, $params, $opts);
} | @param string $id the ID of the customer to which the cash balance belongs
@param null|array $params
@param null|array|string $opts
@param mixed $cashBalanceId
@return CashBalance
@throws Exception\ApiErrorException if the request fails | retrieveCashBalance | php | stripe/stripe-php | lib/Customer.php | https://github.com/stripe/stripe-php/blob/master/lib/Customer.php | MIT |
public static function updateCashBalance($id, $cashBalanceId, $params = null, $opts = null)
{
return self::_updateNestedResource($id, static::PATH_CASH_BALANCE, $params, $opts);
} | @param string $id the ID of the customer to which the cash balance belongs
@param null|array $params
@param null|array|string $opts
@param mixed $cashBalanceId
@return CashBalance
@throws Exception\ApiErrorException if the request fails | updateCashBalance | php | stripe/stripe-php | lib/Customer.php | https://github.com/stripe/stripe-php/blob/master/lib/Customer.php | MIT |
public static function allBalanceTransactions($id, $params = null, $opts = null)
{
return self::_allNestedResources($id, static::PATH_BALANCE_TRANSACTIONS, $params, $opts);
} | @param string $id the ID of the customer on which to retrieve the customer balance transactions
@param null|array $params
@param null|array|string $opts
@return Collection<CustomerBalanceTransaction> the list of customer balance transactions
@throws Exception\ApiErrorException if the request fails | allBalanceTransactions | php | stripe/stripe-php | lib/Customer.php | https://github.com/stripe/stripe-php/blob/master/lib/Customer.php | MIT |
public static function createBalanceTransaction($id, $params = null, $opts = null)
{
return self::_createNestedResource($id, static::PATH_BALANCE_TRANSACTIONS, $params, $opts);
} | @param string $id the ID of the customer on which to create the customer balance transaction
@param null|array $params
@param null|array|string $opts
@return CustomerBalanceTransaction
@throws Exception\ApiErrorException if the request fails | createBalanceTransaction | php | stripe/stripe-php | lib/Customer.php | https://github.com/stripe/stripe-php/blob/master/lib/Customer.php | MIT |
public static function retrieveBalanceTransaction($id, $balanceTransactionId, $params = null, $opts = null)
{
return self::_retrieveNestedResource($id, static::PATH_BALANCE_TRANSACTIONS, $balanceTransactionId, $params, $opts);
} | @param string $id the ID of the customer to which the customer balance transaction belongs
@param string $balanceTransactionId the ID of the customer balance transaction to retrieve
@param null|array $params
@param null|array|string $opts
@return CustomerBalanceTransaction
@throws Exception\ApiErrorException if the request fails | retrieveBalanceTransaction | php | stripe/stripe-php | lib/Customer.php | https://github.com/stripe/stripe-php/blob/master/lib/Customer.php | MIT |
public static function updateBalanceTransaction($id, $balanceTransactionId, $params = null, $opts = null)
{
return self::_updateNestedResource($id, static::PATH_BALANCE_TRANSACTIONS, $balanceTransactionId, $params, $opts);
} | @param string $id the ID of the customer to which the customer balance transaction belongs
@param string $balanceTransactionId the ID of the customer balance transaction to update
@param null|array $params
@param null|array|string $opts
@return CustomerBalanceTransaction
@throws Exception\ApiErrorException if the request fails | updateBalanceTransaction | php | stripe/stripe-php | lib/Customer.php | https://github.com/stripe/stripe-php/blob/master/lib/Customer.php | MIT |
public static function allCashBalanceTransactions($id, $params = null, $opts = null)
{
return self::_allNestedResources($id, static::PATH_CASH_BALANCE_TRANSACTIONS, $params, $opts);
} | @param string $id the ID of the customer on which to retrieve the customer cash balance transactions
@param null|array $params
@param null|array|string $opts
@return Collection<CustomerCashBalanceTransaction> the list of customer cash balance transactions
@throws Exception\ApiErrorException if the request fails | allCashBalanceTransactions | php | stripe/stripe-php | lib/Customer.php | https://github.com/stripe/stripe-php/blob/master/lib/Customer.php | MIT |
public static function retrieveCashBalanceTransaction($id, $cashBalanceTransactionId, $params = null, $opts = null)
{
return self::_retrieveNestedResource($id, static::PATH_CASH_BALANCE_TRANSACTIONS, $cashBalanceTransactionId, $params, $opts);
} | @param string $id the ID of the customer to which the customer cash balance transaction belongs
@param string $cashBalanceTransactionId the ID of the customer cash balance transaction to retrieve
@param null|array $params
@param null|array|string $opts
@return CustomerCashBalanceTransaction
@throws Exception\ApiErrorException if the request fails | retrieveCashBalanceTransaction | php | stripe/stripe-php | lib/Customer.php | https://github.com/stripe/stripe-php/blob/master/lib/Customer.php | MIT |
public static function allSources($id, $params = null, $opts = null)
{
return self::_allNestedResources($id, static::PATH_SOURCES, $params, $opts);
} | @param string $id the ID of the customer on which to retrieve the payment sources
@param null|array $params
@param null|array|string $opts
@return Collection<BankAccount|Card|Source> the list of payment sources (BankAccount, Card or Source)
@throws Exception\ApiErrorException if the request fails | allSources | php | stripe/stripe-php | lib/Customer.php | https://github.com/stripe/stripe-php/blob/master/lib/Customer.php | MIT |
public static function createSource($id, $params = null, $opts = null)
{
return self::_createNestedResource($id, static::PATH_SOURCES, $params, $opts);
} | @param string $id the ID of the customer on which to create the payment source
@param null|array $params
@param null|array|string $opts
@return BankAccount|Card|Source
@throws Exception\ApiErrorException if the request fails | createSource | php | stripe/stripe-php | lib/Customer.php | https://github.com/stripe/stripe-php/blob/master/lib/Customer.php | MIT |
public static function deleteSource($id, $sourceId, $params = null, $opts = null)
{
return self::_deleteNestedResource($id, static::PATH_SOURCES, $sourceId, $params, $opts);
} | @param string $id the ID of the customer to which the payment source belongs
@param string $sourceId the ID of the payment source to delete
@param null|array $params
@param null|array|string $opts
@return BankAccount|Card|Source
@throws Exception\ApiErrorException if the request fails | deleteSource | php | stripe/stripe-php | lib/Customer.php | https://github.com/stripe/stripe-php/blob/master/lib/Customer.php | MIT |
public static function retrieveSource($id, $sourceId, $params = null, $opts = null)
{
return self::_retrieveNestedResource($id, static::PATH_SOURCES, $sourceId, $params, $opts);
} | @param string $id the ID of the customer to which the payment source belongs
@param string $sourceId the ID of the payment source to retrieve
@param null|array $params
@param null|array|string $opts
@return BankAccount|Card|Source
@throws Exception\ApiErrorException if the request fails | retrieveSource | php | stripe/stripe-php | lib/Customer.php | https://github.com/stripe/stripe-php/blob/master/lib/Customer.php | MIT |
public static function updateSource($id, $sourceId, $params = null, $opts = null)
{
return self::_updateNestedResource($id, static::PATH_SOURCES, $sourceId, $params, $opts);
} | @param string $id the ID of the customer to which the payment source belongs
@param string $sourceId the ID of the payment source to update
@param null|array $params
@param null|array|string $opts
@return BankAccount|Card|Source
@throws Exception\ApiErrorException if the request fails | updateSource | php | stripe/stripe-php | lib/Customer.php | https://github.com/stripe/stripe-php/blob/master/lib/Customer.php | MIT |
public static function allTaxIds($id, $params = null, $opts = null)
{
return self::_allNestedResources($id, static::PATH_TAX_IDS, $params, $opts);
} | @param string $id the ID of the customer on which to retrieve the tax ids
@param null|array $params
@param null|array|string $opts
@return Collection<TaxId> the list of tax ids
@throws Exception\ApiErrorException if the request fails | allTaxIds | php | stripe/stripe-php | lib/Customer.php | https://github.com/stripe/stripe-php/blob/master/lib/Customer.php | MIT |
public static function createTaxId($id, $params = null, $opts = null)
{
return self::_createNestedResource($id, static::PATH_TAX_IDS, $params, $opts);
} | @param string $id the ID of the customer on which to create the tax id
@param null|array $params
@param null|array|string $opts
@return TaxId
@throws Exception\ApiErrorException if the request fails | createTaxId | php | stripe/stripe-php | lib/Customer.php | https://github.com/stripe/stripe-php/blob/master/lib/Customer.php | MIT |
public static function deleteTaxId($id, $taxIdId, $params = null, $opts = null)
{
return self::_deleteNestedResource($id, static::PATH_TAX_IDS, $taxIdId, $params, $opts);
} | @param string $id the ID of the customer to which the tax id belongs
@param string $taxIdId the ID of the tax id to delete
@param null|array $params
@param null|array|string $opts
@return TaxId
@throws Exception\ApiErrorException if the request fails | deleteTaxId | php | stripe/stripe-php | lib/Customer.php | https://github.com/stripe/stripe-php/blob/master/lib/Customer.php | MIT |
public static function retrieveTaxId($id, $taxIdId, $params = null, $opts = null)
{
return self::_retrieveNestedResource($id, static::PATH_TAX_IDS, $taxIdId, $params, $opts);
} | @param string $id the ID of the customer to which the tax id belongs
@param string $taxIdId the ID of the tax id to retrieve
@param null|array $params
@param null|array|string $opts
@return TaxId
@throws Exception\ApiErrorException if the request fails | retrieveTaxId | php | stripe/stripe-php | lib/Customer.php | https://github.com/stripe/stripe-php/blob/master/lib/Customer.php | MIT |
public function instanceUrl()
{
$id = $this['id'];
$account = $this['account'];
if (!$id) {
throw new Exception\UnexpectedValueException(
'Could not determine which URL to request: '
. "class instance has invalid ID: {$id}",
null
);
}
$id = Util\Util::utf8($id);
$account = Util\Util::utf8($account);
$base = Account::classUrl();
$accountExtn = \urlencode($account);
$extn = \urlencode($id);
return "{$base}/{$accountExtn}/capabilities/{$extn}";
} | @return string the API URL for this Stripe account reversal | instanceUrl | php | stripe/stripe-php | lib/Capability.php | https://github.com/stripe/stripe-php/blob/master/lib/Capability.php | MIT |
public static function retrieve($_id, $_opts = null)
{
$msg = 'Capabilities cannot be retrieved without an account ID. '
. 'Retrieve a capability using `Account::retrieveCapability('
. "'account_id', 'capability_id')`.";
throw new Exception\BadMethodCallException($msg);
} | @param array|string $_id
@param null|array|string $_opts
@throws Exception\BadMethodCallException | retrieve | php | stripe/stripe-php | lib/Capability.php | https://github.com/stripe/stripe-php/blob/master/lib/Capability.php | MIT |
public static function update($_id, $_params = null, $_options = null)
{
$msg = 'Capabilities cannot be updated without an account ID. '
. 'Update a capability using `Account::updateCapability('
. "'account_id', 'capability_id', \$updateParams)`.";
throw new Exception\BadMethodCallException($msg);
} | @param string $_id
@param null|array $_params
@param null|array|string $_options
@throws Exception\BadMethodCallException | update | php | stripe/stripe-php | lib/Capability.php | https://github.com/stripe/stripe-php/blob/master/lib/Capability.php | MIT |
public function save($opts = null)
{
$params = $this->serializeParameters();
if (\count($params) > 0) {
$url = $this->instanceUrl();
list($response, $opts) = $this->_request('post', $url, $params, $opts, ['save']);
$this->refreshFrom($response, $opts);
}
return $this;
} | @param null|array|string $opts
@return static the saved resource
@throws Exception\ApiErrorException if the request fails
@deprecated The `save` method is deprecated and will be removed in a
future major version of the library. Use the static method `update`
on the resource instead. | save | php | stripe/stripe-php | lib/Capability.php | https://github.com/stripe/stripe-php/blob/master/lib/Capability.php | MIT |
public function __construct($apiKey = null, $apiBase = null, $appInfo = null)
{
$this->_apiKey = $apiKey;
if (!$apiBase) {
$apiBase = Stripe::$apiBase;
}
$this->_apiBase = $apiBase;
$this->_appInfo = $appInfo;
} | ApiRequestor constructor.
@param null|string $apiKey
@param null|string $apiBase
@param null|array $appInfo | __construct | php | stripe/stripe-php | lib/ApiRequestor.php | https://github.com/stripe/stripe-php/blob/master/lib/ApiRequestor.php | MIT |
private static function _telemetryJson($requestTelemetry)
{
$payload = [
'last_request_metrics' => [
'request_id' => $requestTelemetry->requestId,
'request_duration_ms' => $requestTelemetry->requestDuration,
],
];
if (\count($requestTelemetry->usage) > 0) {
$payload['last_request_metrics']['usage'] = $requestTelemetry->usage;
}
$result = \json_encode($payload);
if (false !== $result) {
return $result;
}
Stripe::getLogger()->error('Serializing telemetry payload failed!');
return '{}';
} | Creates a telemetry json blob for use in 'X-Stripe-Client-Telemetry' headers.
@static
@param RequestTelemetry $requestTelemetry
@return string | _telemetryJson | php | stripe/stripe-php | lib/ApiRequestor.php | https://github.com/stripe/stripe-php/blob/master/lib/ApiRequestor.php | MIT |
public function request($method, $url, $params = null, $headers = null, $apiMode = 'v1', $usage = [], $maxNetworkRetries = null)
{
$params = $params ?: [];
$headers = $headers ?: [];
list($rbody, $rcode, $rheaders, $myApiKey)
= $this->_requestRaw($method, $url, $params, $headers, $apiMode, $usage, $maxNetworkRetries);
$json = $this->_interpretResponse($rbody, $rcode, $rheaders, $apiMode);
$resp = new ApiResponse($rbody, $rcode, $rheaders, $json);
return [$resp, $myApiKey];
} | @param 'delete'|'get'|'post' $method
@param string $url
@param null|array $params
@param null|array $headers
@param 'v1'|'v2' $apiMode
@param string[] $usage
@param null|int $maxNetworkRetries
@return array tuple containing (ApiReponse, API key)
@throws Exception\ApiErrorException | request | php | stripe/stripe-php | lib/ApiRequestor.php | https://github.com/stripe/stripe-php/blob/master/lib/ApiRequestor.php | MIT |
public function requestStream($method, $url, $readBodyChunkCallable, $params = null, $headers = null, $apiMode = 'v1', $usage = [], $maxNetworkRetries = null)
{
$params = $params ?: [];
$headers = $headers ?: [];
list($rbody, $rcode, $rheaders, $myApiKey)
= $this->_requestRawStreaming($method, $url, $params, $headers, $apiMode, $usage, $readBodyChunkCallable, $maxNetworkRetries);
if ($rcode >= 300) {
$this->_interpretResponse($rbody, $rcode, $rheaders, $apiMode);
}
} | @param 'delete'|'get'|'post' $method
@param string $url
@param callable $readBodyChunkCallable
@param null|array $params
@param null|array $headers
@param 'v1'|'v2' $apiMode
@param string[] $usage
@param null|int $maxNetworkRetries
@throws Exception\ApiErrorException | requestStream | php | stripe/stripe-php | lib/ApiRequestor.php | https://github.com/stripe/stripe-php/blob/master/lib/ApiRequestor.php | MIT |
public function handleErrorResponse($rbody, $rcode, $rheaders, $resp, $apiMode)
{
if (!\is_array($resp) || !isset($resp['error'])) {
$msg = "Invalid response object from API: {$rbody} "
. "(HTTP response code was {$rcode})";
throw new Exception\UnexpectedValueException($msg);
}
$errorData = $resp['error'];
$error = null;
if (\is_string($errorData)) {
$error = self::_specificOAuthError($rbody, $rcode, $rheaders, $resp, $errorData);
}
if (!$error) {
$error = 'v1' === $apiMode ? self::_specificV1APIError($rbody, $rcode, $rheaders, $resp, $errorData) : self::_specificV2APIError($rbody, $rcode, $rheaders, $resp, $errorData);
}
throw $error;
} | @param string $rbody a JSON string
@param int $rcode
@param array $rheaders
@param array $resp
@param 'v1'|'v2' $apiMode
@throws Exception\UnexpectedValueException
@throws Exception\ApiErrorException | handleErrorResponse | php | stripe/stripe-php | lib/ApiRequestor.php | https://github.com/stripe/stripe-php/blob/master/lib/ApiRequestor.php | MIT |
private static function _specificV1APIError($rbody, $rcode, $rheaders, $resp, $errorData)
{
$msg = isset($errorData['message']) ? $errorData['message'] : null;
$param = isset($errorData['param']) ? $errorData['param'] : null;
$code = isset($errorData['code']) ? $errorData['code'] : null;
$type = isset($errorData['type']) ? $errorData['type'] : null;
$declineCode = isset($errorData['decline_code']) ? $errorData['decline_code'] : null;
switch ($rcode) {
case 400:
// 'rate_limit' code is deprecated, but left here for backwards compatibility
// for API versions earlier than 2015-09-08
if ('rate_limit' === $code) {
return Exception\RateLimitException::factory($msg, $rcode, $rbody, $resp, $rheaders, $code, $param);
}
if ('idempotency_error' === $type) {
return Exception\IdempotencyException::factory($msg, $rcode, $rbody, $resp, $rheaders, $code);
}
// fall through in generic 400 or 404, returns InvalidRequestException by default
// no break
case 404:
return Exception\InvalidRequestException::factory($msg, $rcode, $rbody, $resp, $rheaders, $code, $param);
case 401:
return Exception\AuthenticationException::factory($msg, $rcode, $rbody, $resp, $rheaders, $code);
case 402:
return Exception\CardException::factory($msg, $rcode, $rbody, $resp, $rheaders, $code, $declineCode, $param);
case 403:
return Exception\PermissionException::factory($msg, $rcode, $rbody, $resp, $rheaders, $code);
case 429:
return Exception\RateLimitException::factory($msg, $rcode, $rbody, $resp, $rheaders, $code, $param);
default:
return Exception\UnknownApiErrorException::factory($msg, $rcode, $rbody, $resp, $rheaders, $code);
}
} | @static
@param string $rbody
@param int $rcode
@param array $rheaders
@param array $resp
@param array $errorData
@return Exception\ApiErrorException | _specificV1APIError | php | stripe/stripe-php | lib/ApiRequestor.php | https://github.com/stripe/stripe-php/blob/master/lib/ApiRequestor.php | MIT |
private static function _specificV2APIError($rbody, $rcode, $rheaders, $resp, $errorData)
{
$msg = isset($errorData['message']) ? $errorData['message'] : null;
$code = isset($errorData['code']) ? $errorData['code'] : null;
$type = isset($errorData['type']) ? $errorData['type'] : null;
switch ($type) {
case 'idempotency_error':
return Exception\IdempotencyException::factory($msg, $rcode, $rbody, $resp, $rheaders, $code);
// The beginning of the section generated from our OpenAPI spec
case 'temporary_session_expired':
return Exception\TemporarySessionExpiredException::factory(
$msg,
$rcode,
$rbody,
$resp,
$rheaders,
$code
);
// The end of the section generated from our OpenAPI spec
default:
return self::_specificV1APIError($rbody, $rcode, $rheaders, $resp, $errorData);
}
} | @static
@param string $rbody
@param int $rcode
@param array $rheaders
@param array $resp
@param array $errorData
@return Exception\ApiErrorException | _specificV2APIError | php | stripe/stripe-php | lib/ApiRequestor.php | https://github.com/stripe/stripe-php/blob/master/lib/ApiRequestor.php | MIT |
private static function _specificOAuthError($rbody, $rcode, $rheaders, $resp, $errorCode)
{
$description = isset($resp['error_description']) ? $resp['error_description'] : $errorCode;
switch ($errorCode) {
case 'invalid_client':
return Exception\OAuth\InvalidClientException::factory($description, $rcode, $rbody, $resp, $rheaders, $errorCode);
case 'invalid_grant':
return Exception\OAuth\InvalidGrantException::factory($description, $rcode, $rbody, $resp, $rheaders, $errorCode);
case 'invalid_request':
return Exception\OAuth\InvalidRequestException::factory($description, $rcode, $rbody, $resp, $rheaders, $errorCode);
case 'invalid_scope':
return Exception\OAuth\InvalidScopeException::factory($description, $rcode, $rbody, $resp, $rheaders, $errorCode);
case 'unsupported_grant_type':
return Exception\OAuth\UnsupportedGrantTypeException::factory($description, $rcode, $rbody, $resp, $rheaders, $errorCode);
case 'unsupported_response_type':
return Exception\OAuth\UnsupportedResponseTypeException::factory($description, $rcode, $rbody, $resp, $rheaders, $errorCode);
default:
return Exception\OAuth\UnknownOAuthErrorException::factory($description, $rcode, $rbody, $resp, $rheaders, $errorCode);
}
} | @static
@param bool|string $rbody
@param int $rcode
@param array $rheaders
@param array $resp
@param string $errorCode
@return Exception\OAuth\OAuthErrorException | _specificOAuthError | php | stripe/stripe-php | lib/ApiRequestor.php | https://github.com/stripe/stripe-php/blob/master/lib/ApiRequestor.php | MIT |
private static function _formatAppInfo($appInfo)
{
if (null !== $appInfo) {
$string = $appInfo['name'];
if (\array_key_exists('version', $appInfo) && null !== $appInfo['version']) {
$string .= '/' . $appInfo['version'];
}
if (\array_key_exists('url', $appInfo) && null !== $appInfo['url']) {
$string .= ' (' . $appInfo['url'] . ')';
}
return $string;
}
return null;
} | @static
@param null|array $appInfo
@return null|string | _formatAppInfo | php | stripe/stripe-php | lib/ApiRequestor.php | https://github.com/stripe/stripe-php/blob/master/lib/ApiRequestor.php | MIT |
private static function _isDisabled($disableFunctionsOutput, $functionName)
{
$disabledFunctions = \explode(',', $disableFunctionsOutput);
foreach ($disabledFunctions as $disabledFunction) {
if (\trim($disabledFunction) === $functionName) {
return true;
}
}
return false;
} | @static
@param string $disableFunctionsOutput - String value of the 'disable_function' setting, as output by \ini_get('disable_functions')
@param string $functionName - Name of the function we are interesting in seeing whether or not it is disabled
@return bool | _isDisabled | php | stripe/stripe-php | lib/ApiRequestor.php | https://github.com/stripe/stripe-php/blob/master/lib/ApiRequestor.php | MIT |
private static function _defaultHeaders($apiKey, $clientInfo = null, $appInfo = null, $apiMode = 'v1')
{
$uaString = "Stripe/{$apiMode} PhpBindings/" . Stripe::VERSION;
$langVersion = \PHP_VERSION;
$uname_disabled = self::_isDisabled(\ini_get('disable_functions'), 'php_uname');
$uname = $uname_disabled ? '(disabled)' : \php_uname();
// Fallback to global configuration to maintain backwards compatibility.
$appInfo = $appInfo ?: Stripe::getAppInfo();
$ua = [
'bindings_version' => Stripe::VERSION,
'lang' => 'php',
'lang_version' => $langVersion,
'publisher' => 'stripe',
'uname' => $uname,
];
if ($clientInfo) {
$ua = \array_merge($clientInfo, $ua);
}
if (null !== $appInfo) {
$uaString .= ' ' . self::_formatAppInfo($appInfo);
$ua['application'] = $appInfo;
}
return [
'X-Stripe-Client-User-Agent' => \json_encode($ua),
'User-Agent' => $uaString,
'Authorization' => 'Bearer ' . $apiKey,
'Stripe-Version' => Stripe::getApiVersion(),
];
} | @static
@param string $apiKey the Stripe API key, to be used in regular API requests
@param null $clientInfo client user agent information
@param null $appInfo information to identify a plugin that integrates Stripe using this library
@param 'v1'|'v2' $apiMode
@return array | _defaultHeaders | php | stripe/stripe-php | lib/ApiRequestor.php | https://github.com/stripe/stripe-php/blob/master/lib/ApiRequestor.php | MIT |
private function _requestRaw($method, $url, $params, $headers, $apiMode, $usage, $maxNetworkRetries)
{
list($absUrl, $rawHeaders, $params, $hasFile, $myApiKey) = $this->_prepareRequest($method, $url, $params, $headers, $apiMode);
// for some reason, PHP users will sometimes include null bytes in their paths, which leads to cryptic server 400s.
// we'll be louder about this to help catch issues earlier.
if (false !== \strpos($absUrl, "\0") || false !== \strpos($absUrl, '%00')) {
throw new Exception\InvalidRequestException("URLs may not contain null bytes ('\\0'); double check any IDs you're including with the request.");
}
$requestStartMs = Util\Util::currentTimeMillis();
list($rbody, $rcode, $rheaders) = self::httpClient()->request(
$method,
$absUrl,
$rawHeaders,
$params,
$hasFile,
$apiMode,
$maxNetworkRetries
);
if (
isset($rheaders['request-id'])
&& \is_string($rheaders['request-id'])
&& '' !== $rheaders['request-id']
) {
self::$requestTelemetry = new RequestTelemetry(
$rheaders['request-id'],
Util\Util::currentTimeMillis() - $requestStartMs,
$usage
);
}
return [$rbody, $rcode, $rheaders, $myApiKey];
} | @param 'delete'|'get'|'post' $method
@param string $url
@param array $params
@param array $headers
@param 'v1'|'v2' $apiMode
@param string[] $usage
@param null|int $maxNetworkRetries
@return array
@throws Exception\AuthenticationException
@throws Exception\ApiConnectionException | _requestRaw | php | stripe/stripe-php | lib/ApiRequestor.php | https://github.com/stripe/stripe-php/blob/master/lib/ApiRequestor.php | MIT |
private function _requestRawStreaming($method, $url, $params, $headers, $apiMode, $usage, $readBodyChunkCallable, $maxNetworkRetries)
{
list($absUrl, $rawHeaders, $params, $hasFile, $myApiKey) = $this->_prepareRequest($method, $url, $params, $headers, $apiMode);
$requestStartMs = Util\Util::currentTimeMillis();
list($rbody, $rcode, $rheaders) = self::streamingHttpClient()->requestStream(
$method,
$absUrl,
$rawHeaders,
$params,
$hasFile,
$readBodyChunkCallable,
$maxNetworkRetries
);
if (
isset($rheaders['request-id'])
&& \is_string($rheaders['request-id'])
&& '' !== $rheaders['request-id']
) {
self::$requestTelemetry = new RequestTelemetry(
$rheaders['request-id'],
Util\Util::currentTimeMillis() - $requestStartMs
);
}
return [$rbody, $rcode, $rheaders, $myApiKey];
} | @param 'delete'|'get'|'post' $method
@param string $url
@param array $params
@param array $headers
@param string[] $usage
@param callable $readBodyChunkCallable
@param 'v1'|'v2' $apiMode
@param int $maxNetworkRetries
@return array
@throws Exception\AuthenticationException
@throws Exception\ApiConnectionException | _requestRawStreaming | php | stripe/stripe-php | lib/ApiRequestor.php | https://github.com/stripe/stripe-php/blob/master/lib/ApiRequestor.php | MIT |
private function _processResourceParam($resource)
{
if ('stream' !== \get_resource_type($resource)) {
throw new Exception\InvalidArgumentException(
'Attempted to upload a resource that is not a stream'
);
}
$metaData = \stream_get_meta_data($resource);
if ('plainfile' !== $metaData['wrapper_type']) {
throw new Exception\InvalidArgumentException(
'Only plainfile resource streams are supported'
);
}
// We don't have the filename or mimetype, but the API doesn't care
return new \CURLFile($metaData['uri']);
} | @param resource $resource
@return \CURLFile|string
@throws Exception\InvalidArgumentException | _processResourceParam | php | stripe/stripe-php | lib/ApiRequestor.php | https://github.com/stripe/stripe-php/blob/master/lib/ApiRequestor.php | MIT |
private function _interpretResponse($rbody, $rcode, $rheaders, $apiMode)
{
$resp = \json_decode($rbody, true);
$jsonError = \json_last_error();
if (null === $resp && \JSON_ERROR_NONE !== $jsonError) {
$msg = "Invalid response body from API: {$rbody} "
. "(HTTP response code was {$rcode}, json_last_error() was {$jsonError})";
throw new Exception\UnexpectedValueException($msg, $rcode);
}
if ($rcode < 200 || $rcode >= 300) {
$this->handleErrorResponse($rbody, $rcode, $rheaders, $resp, $apiMode);
}
return $resp;
} | @param string $rbody
@param int $rcode
@param array $rheaders
@param 'v1'|'v2' $apiMode
@return array
@throws Exception\UnexpectedValueException
@throws Exception\ApiErrorException | _interpretResponse | php | stripe/stripe-php | lib/ApiRequestor.php | https://github.com/stripe/stripe-php/blob/master/lib/ApiRequestor.php | MIT |
public static function setHttpClient($client)
{
self::$_httpClient = $client;
} | @static
@param HttpClient\ClientInterface $client | setHttpClient | php | stripe/stripe-php | lib/ApiRequestor.php | https://github.com/stripe/stripe-php/blob/master/lib/ApiRequestor.php | MIT |
public static function setStreamingHttpClient($client)
{
self::$_streamingHttpClient = $client;
} | @static
@param HttpClient\StreamingClientInterface $client | setStreamingHttpClient | php | stripe/stripe-php | lib/ApiRequestor.php | https://github.com/stripe/stripe-php/blob/master/lib/ApiRequestor.php | MIT |
public static function resetTelemetry()
{
self::$requestTelemetry = null;
} | @static
Resets any stateful telemetry data | resetTelemetry | php | stripe/stripe-php | lib/ApiRequestor.php | https://github.com/stripe/stripe-php/blob/master/lib/ApiRequestor.php | MIT |
public static function httpClient()
{
if (!self::$_httpClient) {
self::$_httpClient = HttpClient\CurlClient::instance();
}
return self::$_httpClient;
} | @return HttpClient\ClientInterface | httpClient | php | stripe/stripe-php | lib/ApiRequestor.php | https://github.com/stripe/stripe-php/blob/master/lib/ApiRequestor.php | MIT |
public static function streamingHttpClient()
{
if (!self::$_streamingHttpClient) {
self::$_streamingHttpClient = HttpClient\CurlClient::instance();
}
return self::$_streamingHttpClient;
} | @return HttpClient\StreamingClientInterface | streamingHttpClient | php | stripe/stripe-php | lib/ApiRequestor.php | https://github.com/stripe/stripe-php/blob/master/lib/ApiRequestor.php | MIT |
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, Collection::class, $params, $opts);
} | Returns a list of transactions that have contributed to the Stripe account
balance (e.g., charges, transfers, and so forth). The transactions are returned
in sorted order, with the most recent transactions appearing first.
Note that this endpoint was previously called “Balance history” and used the
path <code>/v1/balance/history</code>.
@param null|array{created?: array|int, currency?: string, ending_before?: string, expand?: string[], limit?: int, payout?: string, source?: string, starting_after?: string, type?: string} $params
@param null|array|string $opts
@return Collection<BalanceTransaction> of ApiResources
@throws Exception\ApiErrorException if the request fails | all | php | stripe/stripe-php | lib/BalanceTransaction.php | https://github.com/stripe/stripe-php/blob/master/lib/BalanceTransaction.php | MIT |
public static function retrieve($id, $opts = null)
{
$opts = Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
} | Retrieves the balance transaction with the given ID.
Note that this endpoint previously used the path
<code>/v1/balance/history/:id</code>.
@param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
@param null|array|string $opts
@return BalanceTransaction
@throws Exception\ApiErrorException if the request fails | retrieve | php | stripe/stripe-php | lib/BalanceTransaction.php | https://github.com/stripe/stripe-php/blob/master/lib/BalanceTransaction.php | MIT |
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
} | Issue a credit note to adjust the amount of a finalized invoice. For a
<code>status=open</code> invoice, a credit note reduces its
<code>amount_due</code>. For a <code>status=paid</code> invoice, a credit note
does not affect its <code>amount_due</code>. Instead, it can result in any
combination of the following:
<ul> <li>Refund: create a new refund (using <code>refund_amount</code>) or link
an existing refund (using <code>refund</code>).</li> <li>Customer balance
credit: credit the customer’s balance (using <code>credit_amount</code>) which
will be automatically applied to their next invoice when it’s finalized.</li>
<li>Outside of Stripe credit: record the amount that is or will be credited
outside of Stripe (using <code>out_of_band_amount</code>).</li> </ul>
For post-payment credit notes the sum of the refund, credit and outside of
Stripe amounts must equal the credit note total.
You may issue multiple credit notes for an invoice. Each credit note will
increment the invoice’s <code>pre_payment_credit_notes_amount</code> or
<code>post_payment_credit_notes_amount</code> depending on its
<code>status</code> at the time of credit note creation.
@param null|array{amount?: int, credit_amount?: int, effective_at?: int, email_type?: string, expand?: string[], invoice: string, lines?: (array{amount?: int, description?: string, invoice_line_item?: string, quantity?: int, tax_amounts?: null|array{amount: int, tax_rate: string, taxable_amount: int}[], tax_rates?: null|string[], type: string, unit_amount?: int, unit_amount_decimal?: string})[], memo?: string, metadata?: StripeObject, out_of_band_amount?: int, reason?: string, refund_amount?: int, refunds?: array{amount_refunded?: int, refund?: string}[], shipping_cost?: array{shipping_rate?: string}} $params
@param null|array|string $options
@return CreditNote the created resource
@throws Exception\ApiErrorException if the request fails | create | php | stripe/stripe-php | lib/CreditNote.php | https://github.com/stripe/stripe-php/blob/master/lib/CreditNote.php | MIT |
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, Collection::class, $params, $opts);
} | Returns a list of credit notes.
@param null|array{created?: array|int, customer?: string, ending_before?: string, expand?: string[], invoice?: string, limit?: int, starting_after?: string} $params
@param null|array|string $opts
@return Collection<CreditNote> of ApiResources
@throws Exception\ApiErrorException if the request fails | all | php | stripe/stripe-php | lib/CreditNote.php | https://github.com/stripe/stripe-php/blob/master/lib/CreditNote.php | MIT |
public static function retrieve($id, $opts = null)
{
$opts = Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
} | Retrieves the credit note object with the given identifier.
@param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
@param null|array|string $opts
@return CreditNote
@throws Exception\ApiErrorException if the request fails | retrieve | php | stripe/stripe-php | lib/CreditNote.php | https://github.com/stripe/stripe-php/blob/master/lib/CreditNote.php | MIT |
public static function update($id, $params = null, $opts = null)
{
self::_validateParams($params);
$url = static::resourceUrl($id);
list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
} | Updates an existing credit note.
@param string $id the ID of the resource to update
@param null|array{expand?: string[], memo?: string, metadata?: StripeObject} $params
@param null|array|string $opts
@return CreditNote the updated resource
@throws Exception\ApiErrorException if the request fails | update | php | stripe/stripe-php | lib/CreditNote.php | https://github.com/stripe/stripe-php/blob/master/lib/CreditNote.php | MIT |
public static function preview($params = null, $opts = null)
{
$url = static::classUrl() . '/preview';
list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
} | @param null|array $params
@param null|array|string $opts
@return CreditNote the previewed credit note
@throws Exception\ApiErrorException if the request fails | preview | php | stripe/stripe-php | lib/CreditNote.php | https://github.com/stripe/stripe-php/blob/master/lib/CreditNote.php | MIT |
public static function previewLines($params = null, $opts = null)
{
$url = static::classUrl() . '/preview/lines';
list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
} | @param null|array $params
@param null|array|string $opts
@return Collection<CreditNoteLineItem> list of credit note line items
@throws Exception\ApiErrorException if the request fails | previewLines | php | stripe/stripe-php | lib/CreditNote.php | https://github.com/stripe/stripe-php/blob/master/lib/CreditNote.php | MIT |
public function voidCreditNote($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/void';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
} | @param null|array $params
@param null|array|string $opts
@return CreditNote the voided credit note
@throws Exception\ApiErrorException if the request fails | voidCreditNote | php | stripe/stripe-php | lib/CreditNote.php | https://github.com/stripe/stripe-php/blob/master/lib/CreditNote.php | MIT |
public static function allLines($id, $params = null, $opts = null)
{
return self::_allNestedResources($id, static::PATH_LINES, $params, $opts);
} | @param string $id the ID of the credit note on which to retrieve the credit note line items
@param null|array $params
@param null|array|string $opts
@return Collection<CreditNoteLineItem> the list of credit note line items
@throws Exception\ApiErrorException if the request fails | allLines | php | stripe/stripe-php | lib/CreditNote.php | https://github.com/stripe/stripe-php/blob/master/lib/CreditNote.php | MIT |
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
} | Creates an item to be added to a draft invoice (up to 250 items per invoice). If
no invoice is specified, the item will be on the next invoice created for the
customer specified.
@param null|array{amount?: int, currency?: string, customer: string, description?: string, discountable?: bool, discounts?: null|array{coupon?: string, discount?: string, promotion_code?: string}[], expand?: string[], invoice?: string, metadata?: null|StripeObject, period?: array{end: int, start: int}, price_data?: array{currency: string, product: string, tax_behavior?: string, unit_amount?: int, unit_amount_decimal?: string}, pricing?: array{price?: string}, quantity?: int, subscription?: string, tax_behavior?: string, tax_code?: null|string, tax_rates?: string[], unit_amount_decimal?: string} $params
@param null|array|string $options
@return InvoiceItem the created resource
@throws Exception\ApiErrorException if the request fails | create | php | stripe/stripe-php | lib/InvoiceItem.php | https://github.com/stripe/stripe-php/blob/master/lib/InvoiceItem.php | MIT |
public function delete($params = null, $opts = null)
{
self::_validateParams($params);
$url = $this->instanceUrl();
list($response, $opts) = $this->_request('delete', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
} | Deletes an invoice item, removing it from an invoice. Deleting invoice items is
only possible when they’re not attached to invoices, or if it’s attached to a
draft invoice.
@param null|array $params
@param null|array|string $opts
@return InvoiceItem the deleted resource
@throws Exception\ApiErrorException if the request fails | delete | php | stripe/stripe-php | lib/InvoiceItem.php | https://github.com/stripe/stripe-php/blob/master/lib/InvoiceItem.php | MIT |
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, Collection::class, $params, $opts);
} | Returns a list of your invoice items. Invoice items are returned sorted by
creation date, with the most recently created invoice items appearing first.
@param null|array{created?: array|int, customer?: string, ending_before?: string, expand?: string[], invoice?: string, limit?: int, pending?: bool, starting_after?: string} $params
@param null|array|string $opts
@return Collection<InvoiceItem> of ApiResources
@throws Exception\ApiErrorException if the request fails | all | php | stripe/stripe-php | lib/InvoiceItem.php | https://github.com/stripe/stripe-php/blob/master/lib/InvoiceItem.php | MIT |
public static function retrieve($id, $opts = null)
{
$opts = Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
} | Retrieves the invoice item with the given ID.
@param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
@param null|array|string $opts
@return InvoiceItem
@throws Exception\ApiErrorException if the request fails | retrieve | php | stripe/stripe-php | lib/InvoiceItem.php | https://github.com/stripe/stripe-php/blob/master/lib/InvoiceItem.php | MIT |
public static function update($id, $params = null, $opts = null)
{
self::_validateParams($params);
$url = static::resourceUrl($id);
list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
} | Updates the amount or description of an invoice item on an upcoming invoice.
Updating an invoice item is only possible before the invoice it’s attached to is
closed.
@param string $id the ID of the resource to update
@param null|array{amount?: int, description?: string, discountable?: bool, discounts?: null|array{coupon?: string, discount?: string, promotion_code?: string}[], expand?: string[], metadata?: null|StripeObject, period?: array{end: int, start: int}, price_data?: array{currency: string, product: string, tax_behavior?: string, unit_amount?: int, unit_amount_decimal?: string}, pricing?: array{price?: string}, quantity?: int, tax_behavior?: string, tax_code?: null|string, tax_rates?: null|string[], unit_amount_decimal?: string} $params
@param null|array|string $opts
@return InvoiceItem the updated resource
@throws Exception\ApiErrorException if the request fails | update | php | stripe/stripe-php | lib/InvoiceItem.php | https://github.com/stripe/stripe-php/blob/master/lib/InvoiceItem.php | MIT |
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
} | Create an apple pay domain.
@param null|array{domain_name: string, expand?: string[]} $params
@param null|array|string $options
@return ApplePayDomain the created resource
@throws Exception\ApiErrorException if the request fails | create | php | stripe/stripe-php | lib/ApplePayDomain.php | https://github.com/stripe/stripe-php/blob/master/lib/ApplePayDomain.php | MIT |
public function delete($params = null, $opts = null)
{
self::_validateParams($params);
$url = $this->instanceUrl();
list($response, $opts) = $this->_request('delete', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
} | Delete an apple pay domain.
@param null|array $params
@param null|array|string $opts
@return ApplePayDomain the deleted resource
@throws Exception\ApiErrorException if the request fails | delete | php | stripe/stripe-php | lib/ApplePayDomain.php | https://github.com/stripe/stripe-php/blob/master/lib/ApplePayDomain.php | MIT |
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, Collection::class, $params, $opts);
} | List apple pay domains.
@param null|array{domain_name?: string, ending_before?: string, expand?: string[], limit?: int, starting_after?: string} $params
@param null|array|string $opts
@return Collection<ApplePayDomain> of ApiResources
@throws Exception\ApiErrorException if the request fails | all | php | stripe/stripe-php | lib/ApplePayDomain.php | https://github.com/stripe/stripe-php/blob/master/lib/ApplePayDomain.php | MIT |
public static function retrieve($id, $opts = null)
{
$opts = Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
} | Retrieve an apple pay domain.
@param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
@param null|array|string $opts
@return ApplePayDomain
@throws Exception\ApiErrorException if the request fails | retrieve | php | stripe/stripe-php | lib/ApplePayDomain.php | https://github.com/stripe/stripe-php/blob/master/lib/ApplePayDomain.php | MIT |
public static function classUrl()
{
return '/v1/apple_pay/domains';
} | @return string The class URL for this resource. It needs to be special
cased because it doesn't fit into the standard resource pattern. | classUrl | php | stripe/stripe-php | lib/ApplePayDomain.php | https://github.com/stripe/stripe-php/blob/master/lib/ApplePayDomain.php | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.