2016-12-12 33 views
0

我使用带管理帐户的Stripe Connect API将付款分配给我的应用上的服务提供商。条纹连接PHP - 拆分付款?

我们的应用程序想每次收取20%的费用,然后分配给服务提供商。

我知道我可以拿全额收费的,并将其发送到托管账户,就像这样:

\Stripe\Stripe::setApiKey('sk_live_xxxxxx'); 

$charge = \Stripe\Charge::create(array(
    "amount" => (int) $payment, 
    "currency" => "usd", 
    "customer" => $customerID, 
    "destination" => $providerID 
)); 

但是,有没有办法只发80%(或任何部分金额)的到目标账户的付款,其余部分保留在我们的帐户中?我真的不想为了促进这种模式而收取客户的信用卡两次。

回答

1

creating a charge with Connect,您选择与application_fee参数的平台的费用。所以你可以这样做:

$amount = 1000; // amount in cents 
$application_fee = intval($amount * 0.2); // 20% of the amount 

$charge = \Stripe\Charge::create(array(
    "amount" => $amount, 
    "currency" => "usd", 
    "customer" => $customerID, 
    "destination" => $providerID, 
    "application_fee" => $application_fee, 
)); 
+0

谢谢!像魅力一样工作 –