使用 Stripe Connect 自定义 API (PHP) 更新连接的帐户身份信息时收到“您传递了空字符串”错误

问题描述 投票:0回答:2

我正在制作一个表单来使用 Stripe Connect 自定义 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[address]”传递了一个空字符串。我们假设空值是试图取消设置参数;但是“legal_entity[address]”无法取消设置。您应该从请求中删除“legal_entity[address]”或提供非空值。

编辑:如果我尝试检索 [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();

我收到以下错误:

一旦提供了完整的基本法律实体信息(类型、公司名称、名字、姓氏和地址),您就无法取消其中任何信息,只能更新它。

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

php stripe-connect
2个回答
0
投票

不确定我的建议是否有效,但看起来您完全用新数据覆盖了

legal_entity
。尝试将现有数据与新数据合并。比如:

$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 = array_merge($account->legal_entity, $legal_entity);
$account->save();

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" => "[email protected]"
));

// 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();
© www.soinside.com 2019 - 2024. All rights reserved.