# Stripe PHP bindings
[![Build Status](https://travis-ci.org/stripe/stripe-php.svg?branch=master)](https://travis-ci.org/stripe/stripe-php)
[![Latest Stable Version](https://poser.pugx.org/stripe/stripe-php/v/stable.svg)](https://packagist.org/packages/stripe/stripe-php)
[![Total Downloads](https://poser.pugx.org/stripe/stripe-php/downloads.svg)](https://packagist.org/packages/stripe/stripe-php)
[![License](https://poser.pugx.org/stripe/stripe-php/license.svg)](https://packagist.org/packages/stripe/stripe-php)
[![Code Coverage](https://coveralls.io/repos/stripe/stripe-php/badge.svg?branch=master)](https://coveralls.io/r/stripe/stripe-php?branch=master)
The Stripe PHP library provides convenient access to the Stripe API from
applications written in the PHP language. It includes a pre-defined set of
classes for API resources that initialize themselves dynamically from API
responses which makes it compatible with a wide range of versions of the Stripe
API.
## Requirements
PHP 5.6.0 and later.
## Composer
You can install the bindings via [Composer](http://getcomposer.org/). Run the following command:
```bash
composer require stripe/stripe-php
```
To use the bindings, use Composer's [autoload](https://getcomposer.org/doc/01-basic-usage.md#autoloading):
```php
require_once('vendor/autoload.php');
```
## Manual Installation
If you do not wish to use Composer, you can download the [latest release](https://github.com/stripe/stripe-php/releases). Then, to use the bindings, include the `init.php` file.
```php
require_once('/path/to/stripe-php/init.php');
```
## Dependencies
The bindings require the following extensions in order to work properly:
- [`curl`](https://secure.php.net/manual/en/book.curl.php), although you can use your own non-cURL client if you prefer
- [`json`](https://secure.php.net/manual/en/book.json.php)
- [`mbstring`](https://secure.php.net/manual/en/book.mbstring.php) (Multibyte String)
If you use Composer, these dependencies should be handled automatically. If you install manually, you'll want to make sure that these extensions are available.
## Getting Started
Simple usage looks like:
```php
\Stripe\Stripe::setApiKey('sk_test_BQokikJOvBiI2HlWgH4olfQ2');
$customer = \Stripe\Customer::create([
'description' => 'example customer',
'email' => '[email protected]',
'payment_method' => 'pm_card_visa',
]);
echo $customer;
```
## Documentation
See the [PHP API docs](https://stripe.com/docs/api/php#intro).
## Legacy Version Support
### PHP 5.4 & 5.5
If you are using PHP 5.4 or 5.5, you can download v6.21.1 ([zip](https://github.com/stripe/stripe-php/archive/v6.21.1.zip), [tar.gz](https://github.com/stripe/stripe-php/archive/v5.9.2.tar.gz)) from our [releases page](https://github.com/stripe/stripe-php/releases). This version will continue to work with new versions of the Stripe API for all common uses.
### PHP 5.3
If you are using PHP 5.3, you can download v5.9.2 ([zip](https://github.com/stripe/stripe-php/archive/v5.9.2.zip), [tar.gz](https://github.com/stripe/stripe-php/archive/v5.9.2.tar.gz)) from our [releases page](https://github.com/stripe/stripe-php/releases). This version will continue to work with new versions of the Stripe API for all common uses.
## Custom Request Timeouts
_NOTE:_ We do not recommend decreasing the timeout for non-read-only calls (e.g. charge creation), since even if you locally timeout, the request on Stripe's side can still complete. If you are decreasing timeouts on these calls, make sure to use [idempotency tokens](https://stripe.com/docs/api/php#idempotent_requests) to avoid executing the same transaction twice as a result of timeout retry logic.
To modify request timeouts (connect or total, in seconds) you'll need to tell the API client to use a CurlClient other than its default. You'll set the timeouts in that CurlClient.
```php
// set up your tweaked Curl client
$curl = new \Stripe\HttpClient\CurlClient();
$curl->setTimeout(10); // default is \Stripe\HttpClient\CurlClient::DEFAULT_TIMEOUT
$curl->setConnectTimeout(5); // default is \Stripe\HttpClient\CurlClient::DEFAULT_CONNECT_TIMEOUT
echo $curl->getTimeout(); // 10
echo $curl->getConnectTimeout(); // 5
// tell Stripe to use the tweaked client
\Stripe\ApiRequestor::setHttpClient($curl);
// use the Stripe API client as you normally would
```
## Custom cURL Options (e.g. proxies)
Need to set a proxy for your requests? Pass in the requisite `CURLOPT_*` array to the CurlClient constructor, using the same syntax as `curl_stopt_array()`. This will set the default cURL options for each HTTP request made by the SDK, though many more common options (e.g. timeouts; see above on how to set those) will be overridden by the client even if set here.
```php
// set up your tweaked Curl client
$curl = new \Stripe\HttpClient\CurlClient([CURLOPT_PROXY => 'proxy.local:80']);
// tell Stripe to use the tweaked client
\Stripe\ApiRequestor::setHttpClient($curl);
```
Alternately, a callable can be passed to the CurlClient constructor that returns the above array based on request inputs. See `testDefaultOptions()` in `tests/CurlClientTest.php` for an example of this behavior. Note that the callable is called at the beginning of every API request, before the request is sent.
### Configuring a Logger
The library does minimal logging, but it can be configured
with a [`PSR-3` compatible logger][psr3] so that messages
end up there instead of `error_log`:
```php
\Stripe\Stripe::setLogger($logger);
```
### Accessing response data
You can access the data from the last API response on any object via `getLastResponse()`.
```php
$customer = \Stripe\Customer::create([
'description' => 'example customer',
]);
echo $customer->getLastResponse()->headers['Request-Id'];
```
### SSL / TLS compatibility issues
Stripe's API now requires that [all connections use TLS 1.2](https://stripe.com/blog/upgrading-tls). Some systems (most notably some older CentOS and RHEL versions) are capable of using TLS 1.2 but will use TLS 1.0 or 1.1 by default. In this case, you'd get an `invalid_request_error` with the following error message: "Stripe no longer supports API requests made with TLS 1.0. Please initiate HTTPS connections with TLS 1.2 or later. You can learn more about this at [https://stripe.com/blog/upgrading-tls](https://stripe.com/blog/upgrading-tls).".
The recommended course of action is to [upgrade your cURL and OpenSSL packages](https://support.stripe.com/questions/how-do-i-upgrade-my-stripe-integration-from-tls-1-0-to-tls-1-2#php) so that TLS 1.2 is used by default, but if that is not possible, you might be able to solve the issue by setting the `CURLOPT_SSLVERSION` option to either `CURL_SSLVERSION_TLSv1` or `CURL_SSLVERSION_TLSv1_2`:
```php
$curl = new \Stripe\HttpClient\CurlClient([CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1]);
\Stripe\ApiRequestor::setHttpClient($curl);
```
### Per-request Configuration
For apps that need to use multiple keys during the lifetime of a process, like
one that uses [Stripe Connect][connect], it's also possible to set a
per-request key and/or account:
```php
$customers = \Stripe\Customer::all([],[
'api_key' => 'sk_test_...',
'stripe_account' => 'acct_...'
]);
\Stripe\Customer::retrieve("cus_123456789", [
'api_key' => 'sk_test_...',
'stripe_account' => 'acct_...'
]);
```
### Configuring CA Bundles
By default, the library will use its own internal bundle of known CA
certificates, but it's possible to configure your own:
```php
\Stripe\Stripe::setCABundlePath("path/to/ca/bundle");
```
### Configuring Automatic Retries
The library can be configured to automatically retry requests that fail due to
an intermittent network problem:
```php
\Stripe\Stripe::setMaxNetworkRetries(2);
```
[Idempotency keys][idempotency-keys] are added to requests to guarantee that
retries are safe.
### Request latency telemetry
By default, the library sends request latency telemetry to Stripe. These
numbers he
没有合适的资源?快使用搜索试试~ 我知道了~
【WordPress插件】2022年最新版完整功能demo+插件v11.2.1.zip
共230个文件
php:191个
png:18个
js:6个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 90 浏览量
2022-04-21
05:22:38
上传
评论
收藏 544KB ZIP 举报
温馨提示
"【WordPress插件】2022年最新版完整功能demo+插件v11.2.1 WP Crowdfunding Pro - The Ultimate Fundraising WordPress Plugin WP Crowdfunding Pro - 终极筹款WordPress插件" ---------- 泰森云每天更新发布最新WordPress主题、HTML主题、WordPress插件、shopify主题、opencart主题、PHP项目源码、安卓项目源码、ios项目源码,更有超10000个资源可供选择,如有需要请站内联系。
资源推荐
资源详情
资源评论
收起资源包目录
【WordPress插件】2022年最新版完整功能demo+插件v11.2.1.zip (230个子文件)
ca-certificates.crt 219KB
stripe-connect.css 26KB
license-form.css 4KB
wallet.css 3KB
installer.css 973B
phpstan.neon.dist 147B
stripe.js 4KB
stripe_checkout.js 4KB
wallet.js 4KB
installer.js 749B
frontend.js 534B
reports.js 192B
composer.json 922B
CHANGELOG.md 40KB
README.md 10KB
CODE_OF_CONDUCT.md 3KB
phpstan-baseline.neon 315B
cert.pem 9KB
init.php 26KB
init.php 23KB
StripeObject.php 18KB
Invoice.php 18KB
AuthorizeNetAIM.php 17KB
CurlClient.php 17KB
Account.php 16KB
wpcf-stripe-connect.php 15KB
ApiRequestor.php 14KB
init.php 14KB
Util.php 13KB
Customer.php 12KB
wpcf-reports-query.php 12KB
Charge.php 12KB
update.php 11KB
Event.php 11KB
payment_details_by_campaign.php 11KB
PaymentIntent.php 11KB
wpcf-new-backed.php 11KB
reports-area-chart.php 10KB
Subscription.php 10KB
wpcf-withdraw-request.php 9KB
wpcf-target-reached.php 9KB
reports-by-campaign.php 9KB
wpcf-campaign-update.php 9KB
wpcf-campaign-accept.php 9KB
ErrorObject.php 8KB
wpcf-campaign-submit.php 8KB
Source.php 8KB
init.php 8KB
Card.php 7KB
wpcf-new-user.php 7KB
init.php 7KB
Stripe.php 7KB
Collection.php 7KB
wpcf_withdraw_request_table.php 7KB
init.php 7KB
BankAccount.php 7KB
license-form.php 6KB
SetupIntent.php 6KB
init.php 6KB
tab-wallet.php 6KB
Transfer.php 6KB
wpcf_gateway_wallet.php 6KB
all_campaigns.php 6KB
Installer.php 6KB
Payout.php 6KB
Authorization.php 6KB
Init.php 6KB
CreditNote.php 5KB
BalanceTransaction.php 5KB
init.php 5KB
Order.php 5KB
Dispute.php 5KB
ApiErrorException.php 5KB
Plan.php 5KB
Session.php 5KB
WebhookSignature.php 4KB
ApplicationFee.php 4KB
BitcoinReceiver.php 4KB
Refund.php 4KB
NestedResource.php 4KB
Product.php 4KB
SubscriptionSchedule.php 4KB
SubscriptionItem.php 4KB
Topup.php 4KB
RequestOptions.php 4KB
AuthorizeNetRequest.php 4KB
Token.php 4KB
InvoiceItem.php 3KB
ApiResource.php 3KB
Person.php 3KB
OAuth.php 3KB
Review.php 3KB
tab-email.php 3KB
PayFull.php 3KB
File.php 3KB
PaymentMethod.php 3KB
CustomerBalanceTransaction.php 3KB
Card.php 3KB
TaxId.php 3KB
Recipient.php 3KB
共 230 条
- 1
- 2
- 3
资源评论
Lee达森
- 粉丝: 965
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- python-leetcode面试题解之第162题寻找峰值-题解.zip
- python-leetcode面试题解之第161题相隔为1的编辑距离-题解.zip
- python-leetcode面试题解之第160题相交链表-题解.zip
- python-leetcode面试题解之第159题至少包含两个不同字符的最长子串-题解.zip
- python-leetcode面试题解之第158题用Read4读取N个字符II-多次调用-题解.zip
- Python 程序语言设计模式思路-行为型模式:策略模式:将算法封装成独立的类,并使它们可以互相替换及支付模式数据压缩
- main.py
- Last Loaded Test.DBK
- Screenshot_20240520_163011.jpg
- ubuntu-python3-whisper-tornado docker镜像 Dockerfile
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功