Reputation: 483
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?
Upvotes: 0
Views: 365
Reputation: 483
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
Upvotes: 1
Reputation: 7198
As per the docs on this, you should pass the arguments for capturing to the capture
function, not the retrieve
function. It's a two step process, you get the charge object by calling retrieve
, and then capture it, passing arguments. The code would look like this :
$charge = \Stripe\Charge::retrieve("ch_xxx", array("stripe_account" => "acct_xxx"));
$charge->capture(array(
"application_fee" => 1000
),array("stripe_account" => "acct_xxx"));
Upvotes: 0