Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change StripeClient initialization #903

Merged
merged 1 commit into from
Mar 25, 2020
Merged

Conversation

ob-stripe
Copy link
Contributor

r? @remi-stripe @richardm-stripe
cc @stripe/api-libraries

Change the StripeClient constructor to expose a simpler API.

The new constructor takes a single argument, which can be a string (the API key) or an array with various configuration values.

In most cases, users will use the string form:

$stripe = new \Stripe\StripeClient('sk_test_123');

If needed, it's easy to pass "advanced" configuration settings:

$stripe = new \Stripe\StripeClient([
    'api_key' => 'sk_test_123',
    'client_id' => 'ca_123',
]);

The configuration array approach is used by other PHP libraries, including Guzzle, the most popular PHP HTTP client library (https://github.com/guzzle/guzzle/blob/1cdd69a0cd361ee8b6ba5584e45db80c0ea8b31c/src/Client.php#L51). The main downside is that there is no standard PHPDoc syntax for defining the shape of the array, but I think PHPStan and other static analyzer tools are working on something like this, and it's not that bad to just use freeform text to expose the various configuration keys and their expected types.

@ob-stripe ob-stripe merged commit f365a3d into integration-services Mar 25, 2020
@ob-stripe ob-stripe deleted the ob-client-init branch March 25, 2020 20:49
ob-stripe added a commit that referenced this pull request Apr 3, 2020
ob-stripe added a commit that referenced this pull request May 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants