Skip to content

birdy247/league-oauth2-stripe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

README

Stripe OAuth2 provider for League\OAuth2-Client.

Usage

First, add chrsm/league-oauth2-stripe to your composer.json.

Here's a (simple) example of how this package can be used:

<?php

require_once 'vendor/autoload.php';

use chrsm\oauth2\Stripe as StripeProvider;
use chrsm\oauth2\StripeAuthorizationCode;

$stripe = new StripeProvider([
    'clientId' => 'Your Stripe Client ID',
    'clientSecret' => 'Your Stripe Secret Key',
    'redirectUri' => 'URL where you would like Stripe to redirect your user to post-auth',
]);

// psuedo-code, but you get the idea..
if (!isset($tokenVariableFromStripe)) {
    header('Location: ' . $stripe->getAuthorizationUrl());
} else {
    $token = $stripe->getAccessToken(
        new StripeAuthorizationCode,
        [
            'code' => $tokenVariableFromStripe,
            'grant_type' => 'authorization_code',
        ]
    );

    // save what you want
    $accessToken = $token->accessToken;
    $refreshToken = $token->refreshToken;
    $publishableKey = $token->stripePublishableKey;
}

// .... elsewhere, once you have acquired an access token:
Stripe::setApiKey($accessToken);

Additionally, you can use the Publishable Key retrieved in Stripe Checkout (or basically anywhere you'd need a Stripe PK).

About

Stripe OAuth2 provider for League\OAuth2-Client.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages