首页 > 解决方案 > Stripe 与 Auth 和 Capture 连接,在 PHP 中检索 Charge

问题描述

我正在使用 auth 和 Capture 实现 Stripe Connect,到目前为止我已经成功了,但是当我尝试捕获经过身份验证的数量时,我无法这样做。因为条纹不允许我们将多个参数传递给Stripe:: Retrieve函数,但它可以处理我开发的 curl 请求。如下。

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

这工作正常,但是当我尝试做同样的事情时,它给我一个未知参数的错误,我可以理解 bcoz Stripe:: Retrieve does not accept extra parameter 我试图在 PHP 中这样做

$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();

有人可以建议我如何在 PHP 中存档吗?

标签: phpcurlstripe-paymentsstripe-connect

解决方案


我找到了这样的解决方案。

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

通过使用这个我解决了我的问题


推荐阅读