Showing posts with label stripe-standard-account. Show all posts
Showing posts with label stripe-standard-account. Show all posts

Monday, September 18, 2017

Stripe Using Connect with Deferred Standard Accounts | Stripe Create Deferred Standard Account | Stripe Create Connected Account Using API Call

1 Login to your stripe account and navigate to https://dashboard.stripe.com/account/applications/settings and follow below steps:









2. Now have to create Deferred (standard) account using below code snippet (API call). Later account holder will login to their account and complete their verification process:



<?php
include_once "curl.php";

$api_key = "sk_test_eXF..........jWrcHK95rwj";
$url = "https://api.stripe.com/v1/accounts";

$params = array(
    "type" => "standard",
    "country" => "AU",
    "email" => "pritomkucse+stripe1@gmail.com"
);

$headers[] = "Authorization: Bearer $api_key";
$headers[] = "Content-Type: application/x-www-form-urlencoded";

$result = CurlExecutor::execute($url, "POST", null, $params, $headers);
$result["response"] = json_decode($result["response"]);
CurlExecutor::prettyPrint($result);

Successful output would be like below:


Array
(
    [code] => 200
    [response] => stdClass Object
        (
            [id] => acct_1B3......1R7ddx6
            [object] => account
            [business_logo] => 
            [business_name] => 
            [business_url] => 
            [charges_enabled] => 1
            [country] => AU
            [default_currency] => aud
            [details_submitted] => 
            [display_name] => 
            [email] => pritomkucse+stripe1@gmail.com
            [keys] => stdClass Object
                (
                    [secret] => sk_test_wel..........5fXfyBsmhI6
                    [publishable] => pk_test_mlPoU..........zBUbHBFof
                )

            [metadata] => stdClass Object
                (
                )

            [payouts_enabled] => 
            [statement_descriptor] => 
            [support_email] => 
            [support_phone] => 
            [timezone] => Etc/UTC
            [type] => standard
        )

)

Use "keys/secret" (actually it is "Secret key" for API), you can use this Key to process all your transactions.

And list of your connected account is below:




Stripe Using Connect with Standard Accounts | Stripe Create Standard Account

1 Login to your stripe account and navigate to https://dashboard.stripe.com/account/applications/settings and follow below steps:








2. Copy Client ID and follow below PHP script (which will redirect target users to Stripe application page to fill up their personal details to create and account with Stripe):



<?php
$client_id = "ca_BPnCyPD...........ODApFdHyTXHbwQ";
$auth_url = "https://connect.stripe.com/oauth/authorize?".
    "response_type=code&client_id=$client_id&scope=read_write".
    "&redirect_uri=".rawurlencode("http://localhost/ci/dragon71/stripe/callback.php").
    "&state=".md5(trim(true));
header("Refresh:0; url=$auth_url");

3. After completing procedures there, Stripe will redirect back to our target redirect URL as below:


http://localhost/ci/dragon71/stripe/callback.php?state=c4ca4238a0b923820dcc509a6f75849b&scope=read_write&code=ac_BQGZyHtVkFbOFYhNPTlAdbZeZcMutzec

If fails then:

http://localhost/ci/dragon71/stripe/callback.php?state=c4ca4238a0b923820dcc509a6f75849b&error=access_denied&error_description=The+user+denied+your+request

4. One thing we forgot, have to collect our API Key to request API call, navigate to https://dashboard.stripe.com/account/apikeys to collect your API Key's.




5. After successful redirect back, it's time to collect access token to procedure further. 


<?php
include_once "curl.php";

$api_key = "sk_test_eXF4.........jWrcHK95rwj";
$url = "https://connect.stripe.com/oauth/token";

$params = array(
    "code" => $_GET["code"],
    "grant_type" => "authorization_code"
);

$headers[] = "Authorization: Bearer $api_key";
$headers[] = "Content-Type: application/x-www-form-urlencoded";

$result = CurlExecutor::execute($url, "POST", null, $params, $headers);
$result["response"] = json_decode($result["response"]);
CurlExecutor::prettyPrint($result);

Successful output would be like below:


Array
(
    [code] => 200
    [response] => stdClass Object
        (
            [access_token] => sk_test_oWtb.........xb4tLBXqZmh
            [livemode] => 
            [refresh_token] => rt_BQGsyumxyAoDH....................aPMt5MvpprSnpwD
            [token_type] => bearer
            [stripe_publishable_key] => pk_test_xHhgw.........zfo0QYltBB
            [stripe_user_id] => acct_1B3........3aeEh
            [scope] => read_write
        )

)

Use "access_token" (actually it is "Secret key" for API), you can use this Key to process all your transactions.

And list of your connected account is below: