Search code examples
phpcurlstripe-paymentsstripe-connect

Stripe connect with Auth and Capture retrieving Charge in Php


I am implementing Stripe Connect with auth and Capture and so far I am succeeded in it but when I am trying to Capture the authenticated amount I am not able to do so. because stripe does not allow us to pass multiple parameters to Stripe:: Retrieve function but its working on curl request which I have developed. which as follow.

curl https://api.stripe.com/v1/charges/ch_1CfTe5Dye6RVcYtHp*****/capture \

-u sk_test_C5uYX8juNRT9kTj******: \
-d application_fee=1000 \
-H "Stripe-Account: acct_1CNbqaDy*****" \
-X POST

this is working fine but when I try to do the same thing it is giving me an error on an unknown parameter which I can understand bcoz Stripe:: Retrieve does not accept extra parameter I am trying to do it in PHP like this

$stripe = array(
             "secret_key" => "sk_test_C5uYX8juNRT9k********",
             "publishable_key" => "pk_test_b2gp9tSHK9iP******"
          );

$keystripe = \Stripe\Stripe::setApiKey($stripe['secret_key']);
$res = \Stripe\Charge::retrieve(array(
                               "id" =>"ch_1CfTe5Dye6RVcYtHp********",
                               "application_fee" => 1000),
                              array("stripe_account" =>  "acct_1CNbqaDy*****"));

$re = $res->capture();

Can someone suggest me how can I archive this in PHP?


Solution

  • I have found the solution which is like this.

    $keystripe = \Stripe\Stripe::setApiKey('sk_test_C5uYX8juNRT9kTj9wj******');
    $res = \Stripe\Charge::retrieve('ch_1CjkyXDye6RVcYt******', ["stripe_account" => "acct_xxx"]);
    $re =  $res->capture(["application_fee" =>1000]);
    

    by using this I have resolved my problem