简体   繁体   English

如何在使用php创建条带管理帐户时提供外部帐户参数?

[英]How to provide external account parameter while creating managed account in stripe using php?

I am using stripe php library. 我正在使用条纹php库。

Here is my code: 这是我的代码:

$account = \Stripe\Account::create(
    array(
        "country" => "US",
        "managed" => true,
        "legal_entity" => array(
            'address' => array(
                'city' => 'Maxico',
                'country' => 'US',
                "line1" => 'H65',
                "line2" => 'standfort street',
                "postal_code" => '90046',
                "state" => 'CA'
            ),
            'business_name' => 'test business name',
            'business_tax_id' => '000000000',
            'dob' => array(
                'day' => '10',
                'month' => '01',
                'year' => '1988'
            ),
            'first_name' => 'Test',
            'last_name' => 'Tester',
            'personal_id_number' => '000000000',
            'ssn_last_4' => '0000',
            'type' => 'sole_prop'
        ),
        'tos_acceptance' => array(
            'date' => time(),
            'ip' => $_SERVER['REMOTE_ADDR']
        ),
        'external_account' => array(
            "country" => "US",
            "currency" => "usd",
            "account_holder_name" => 'Jane Austen',
            "account_holder_type" => 'individual',
            "routing_number" => "111000025",
            "account_number" => "000123456789"
        )
    )
);

This is the error I am getting: 这是我得到的错误:

The external_account hash must include an 'object' key indicating what type of external_account to create. external_account哈希必须包含一个'object'键,指示要创建的external_account的类型。

Any suggestion will be appreciated. 任何建议将不胜感激。

Use Stripe.js to create a bank account token client-side, then use this token when creating the managed account. 使用Stripe.js在客户端创建银行帐户令牌 ,然后在创建管理帐户时使用此令牌。 (This is the recommended way.) (这是推荐的方式。)

Here's an example of a form using Stripe.js to create bank account tokens: https://jsfiddle.net/ywain/L2cefvtp/ 以下是使用Stripe.js创建银行帐户令牌的表单示例: https ://jsfiddle.net/ywain/L2cefvtp/

and you'd update your code like this: 你会像这样更新你的代码:

        ...
        'external_account' => 'btok_...' // token returned by Stripe.js
    )

Alternatively, you can pass the external account information from your server instead. 或者,您也可以从服务器传递外部帐户信息。 This is not recommended, as it increases the security risk of your application. 建议不要这样做,因为这会增加应用程序的安全风险。 In this case, you must include the 'object' => 'bank_account' key/value pair in the array: 在这种情况下,您必须在数组中包含'object' => 'bank_account'键/值对:

        ...
        'external_account' => array(
            "object" => "bank_account",
            "country" => "US",
            "currency" => "usd",
            "account_holder_name" => 'Jane Austen',
            "account_holder_type" => 'individual',
            "routing_number" => "110000000",
            "account_number" => "000123456789"
        )
    )

You have to add stripe library first & then user the key to make object 您必须先添加条带库,然后使用密钥来创建对象

require_once(APPPATH.'libraries/stripe/init.php');

\Stripe\Stripe::setApiKey($this->privateKey);

Like this then you can create customer on stripe. 像这样你就可以在条纹上创建客户。

Here is library link. 是图书馆链接。

You can do something like this, creating a token client side (with the Android SDK, iOS or StripeJS) then in your server side you pass the token to the external account 您可以执行以下操作,创建令牌客户端(使用Android SDK,iOS或StripeJS),然后在服务器端将令牌传递到外部帐户

var stripe = require("stripe")("sk_test_c7VExQZarF76Mm59HTcD7NLo");

stripe.accounts.createExternalAccount(
  "acct_1DO7wfJyhqKlvfeX",
  { external_account: "btok_1DZipAJyhqKlvfeXSA5OATY1" },
  function(err, bank_account) {
    // asynchronously called
  }

);

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

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