接收"你传了一个空字符串"使用Stripe Connect Custom API(PHP)更新连接的帐户身份信息时出错

时间:2017-11-27 15:09:37

标签: php stripe-connect

我正在使用Stripe Connect Custom API制作表单来更新/添加身份信息。但是我收到"您在API 中为我未提交的字段传递了一个空字符串" 错误。

$legal_entity = array(
    'first_name'=>$first_name,
    'last_name'=>$last_name,
    'maiden_name'=>$maiden_name,
    'personal_id_number'=>$personal_id_number,
    'dob' => array(
        'day' => $dob_day,
        'month' => $dob_month,
        'year' => $dob_year
    ),
    'personal_address' => array(
        'line1' => $address_line1,
        'line2' => $address_line2,
        'city' => $address_city,
        'state' => $address_state,
        'country' => $address_country,
        'postal_code' => $address_postal_code
    ),

);

$account = \Stripe\Account::retrieve($stripe_account_id);
$account->legal_entity = $legal_entity;
$account->save();
  

您为' legal_entity [type]'传递了一个空字符串。我们假设空值是试图取消设置参数;然而' legal_entity [type]'不能解开。您应该删除' legal_entity [type]'来自您的请求或提供非空值。

正如你所看到的;我根本没有定义[type]成员。如果我添加它;然后我得到以下错误:

  

您为' legal_entity [地址]'传递了一个空字符串。我们假设空值是试图取消设置参数;然而' legal_entity [地址]'不能解开。您应该删除' legal_entity [地址]'来自您的请求或提供非空值。

编辑:如果我尝试检索[legal_entity]并简单地更新它并重新保存它;像这样:

$account = \Stripe\Account::retrieve($stripe_account_id);
$legal_entity = $account->legal_entity;


$legal_entity['first_name'] = $first_name;

$legal_entity['last_name'] = $last_name;

$legal_entity['maiden_name'] = $maiden_name;

$legal_entity['personal_id_number'] = $personal_id_number;

$legal_entity['dob'] = array(
    'day' => $dob_day,
    'month' => $dob_month,
    'year' => $dob_year
);

$legal_entity['personal_address'] = array(
    'line1' => $address_line1,
    'line2' => $address_line2,
    'city' => $address_city,
    'state' => $address_state,
    'country' => $address_country,
    'postal_code' => $address_postal_code
);


$account->legal_entity = $legal_entity;
$account->save();

我收到以下错误:

  

一旦提供了一整套基本法律实体信息(type,business_name,first_name,last_name和address),就不能取消任何一项,只更新它。

如何更新帐户持有人或其他所有者?

1 个答案:

答案 0 :(得分:0)

在更新的示例中省略$account->legal_entity = $legal_entity;

例如,这很好用!

// see https://stripe.com/docs/api/php#update_account for all options
$account = \Stripe\Account::create(array(
  "type" => "custom",
  "country" => "US",
  "email" => "test@example.com"
));

// retrieve and update the account
$account = \Stripe\Account::retrieve($account->id);

$legal_entity = $account->legal_entity;

$legal_entity['type'] = "individual";
$legal_entity['first_name'] = "Jane";
$legal_entity['last_name'] = "Allen";
$legal_entity['personal_id_number'] = "000000000";

$legal_entity['dob'] = array(
    'day' => 1,
    'month' => 1,
    'year' => 1901
);

$legal_entity['address'] = array(
    'line1' => "1 Main St",
    'line2' => "Suite 111",
    'city' => "San Francisco",
    'state' => "CA",
    'country' => "US",
    'postal_code' => "94103"
);

$account->tos_acceptance = array(
    'date' => time(), 
    "ip" => "10.10.0.10"
);

echo $account->save();