简体   繁体   English

如何使用API​​将Stripe余额提取到自己的银行帐户?

[英]How to withdraw Stripe balance to own bank account using API?

I used to have a cron script that runs every week to withdraw cash from my Stripe balance to my bank account. 我曾经有一个cron脚本,该脚本每周运行一次,以将Stripe余额中的现金提取到我的银行帐户中。 We are now re-visiting Stripe (we left them for a diff payment processor, but we are returning back to them), and I've come to learn that the Recipients object is now deprecated. 现在,我们正在重新访问Stripe(我们将它们留给了差异支付处理器,但我们将返回给他们),并且我开始了解到Recipients对象现在已被弃用。 I've been unable to find a simple way to do this with the new method they are suggesting (via Connect ). 我一直无法找到一种简单的方法来使用他们建议的新方法(通过Connect )。

This was my old code: 这是我的旧代码:

$stripe_bal = Stripe_Balance::retrieve();
$stripe_avail = $stripe_bal['available'][0]['amount'];

if($stripe_avail > 1) {
    $transfer = Stripe_Transfer::create(array(
        'amount' => $stripe_avail, // amount in cents
        'currency' => 'usd',
        'recipient' => 'self',
        'statement_descriptor' => 'stripe balance cash out'
    ));
}

How do I do the same exact code above for their latest API using Connect ? 我如何使用Connect为它们的最新API进行与上面相同的代码? I'm unable to find an exact example or documentation that covers or even mentions this. 我找不到涵盖甚至提到这一点的确切示例或文档。 I know how to do it manually on their GUI, but I'd like to automate it using their API, since it's going to be tedious to have to log in every week to clean my account. 我知道如何在他们的GUI上手动进行操作,但是我想使用他们的API将其自动化,因为必须每周登录以清理我的帐户非常繁琐。 I don't want to clean it out everyday either; 我也不想每天都清理它; I want to stick to doing it once a week. 我想坚持每周做一次。

For those who are curious, I finally figured this one out. 对于那些好奇的人,我终于想出了这一点。 Here's how to do it using API version 2017-01-27 : 使用API​​版本2017-01-27如下:

$stripe_bal = \Stripe\Balance::retrieve();
$stripe_avail = $stripe_bal['available'][0]['amount'];

if($stripe_avail > 1) {
    $transfer = \Stripe\Transfer::create([
        'amount' => $stripe_avail, // amount in cents
        'currency' => 'usd',
        'destination' => 'default_for_currency',
        'statement_descriptor' => 'stripe balance cash out'
    ]);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM