Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/241.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何添加银行帐户并将其附加到“帐户”;“关联账户”;在条纹上?_Php_Stripe Payments - Fatal编程技术网

Php 如何添加银行帐户并将其附加到“帐户”;“关联账户”;在条纹上?

Php 如何添加银行帐户并将其附加到“帐户”;“关联账户”;在条纹上?,php,stripe-payments,Php,Stripe Payments,Stripe API解释了如何创建和更新帐户: Stripe Api还解释了如何创建银行帐户: 我正在尝试为连接的帐户创建银行帐户,但不幸的是,我一直被此错误消息阻止: 缺少必需的参数:外部帐户 以下是我创建连接帐户的过程: public function test_stripe_create_connected_account(Request $request) { \Stripe\Stripe::setApiKey("sk_test_..."); $acct = \S

Stripe API解释了如何创建和更新帐户:

Stripe Api还解释了如何创建银行帐户:

我正在尝试为连接的帐户创建银行帐户,但不幸的是,我一直被此错误消息阻止:

缺少必需的参数:外部帐户

以下是我创建连接帐户的过程:

public function test_stripe_create_connected_account(Request $request)
{

    \Stripe\Stripe::setApiKey("sk_test_...");

    $acct = \Stripe\Account::create(array(
        "country" => "CH",
        "type" => "custom",
        "email" => "test@test.ch"
    ));

}
然后,我通过以下方式更新帐户来完成此操作:

public function test_stripe_update_account(Request $request)
{

    try {

        \Stripe\Stripe::setApiKey("sk_test_...");

        $account = \Stripe\Account::retrieve("acct_1BTRCOB5XLEUUY47");
        $account->support_email = "victor@krown.ch";
        $account->support_phone = "0041764604220";

        $account->legal_entity->type = "company";
        $account->legal_entity->business_name = "Barbosa Duvanel SARL";
        $account->legal_entity->additional_owners = NULL;

        //NAME
        $account->legal_entity->first_name = "Victor";
        $account->legal_entity->last_name = "Duvanel";

        //BIRTH DATE
        $account->legal_entity->dob->day = 25;
        $account->legal_entity->dob->month = 3;
        $account->legal_entity->dob->year = 1988;

        //ADDRESS
        $account->legal_entity->address->city = "Genève";
        $account->legal_entity->address->country = "CH";
        $account->legal_entity->address->line1 = "Av de la Roseraie 76A";
        $account->legal_entity->address->line2 = "Genève";
        $account->legal_entity->address->postal_code = "1207";
        $account->legal_entity->address->state = "Genève";

        //PERSONAL ADDRESS
        $account->legal_entity->personal_address->city = "Genève";
        $account->legal_entity->personal_address->country = "CH";
        $account->legal_entity->personal_address->line1 = "Av de la Roseraie 76A";
        $account->legal_entity->personal_address->line2 = "Genève";
        $account->legal_entity->personal_address->postal_code = "1207";
        $account->legal_entity->personal_address->state = "Genève";

        //GENERAL CONDITIONS ACCEPTATION
        $account->tos_acceptance->date = time();
        $account->tos_acceptance->ip = $_SERVER['REMOTE_ADDR'];

        $account->save();

        $message = 'OK';
        $status = true;

    } catch (\Exception $error) {
        $message = $error->getMessage();
        $status = false;
    }

    $results = (object)array(
        'message' => $message,
        'status' => $status,
    );

    $response = response()->json($results, 200);
    return $response;

}
最后,我尝试将一个新的银行帐户附加到我的用户,如下所示:

public function test_stripe_create_bank_account(Request $request)
{

    try {

        \Stripe\Stripe::setApiKey("sk_test_...");

        $account = \Stripe\Account::retrieve("acct_1BSoOaGS1D3TfSN5");

        $account->external_accounts->create(
            array(
                "object" => "bank_account",
                "account_number" => "CH820024024090647501F",
                "country" => "CH",
                "currency" => "CHF",
            )
        );

        $message = 'OK';
        $status = true;

    } catch (\Exception $error) {
        $message = $error->getMessage();
        $status = false;
    }

    $results = (object)array(
        'message' => $message,
        'status' => $status,
    );

    $response = response()->json($results, 200);
    return $response;

}
我做错了什么

任何帮助都将不胜感激

您需要更改参数名称以将数组包装在参数名称下,如下所示:

$account->external_accounts->create(array(
    "external_account" => array(
        "object" => "bank_account",
        "account_number" => "CH820024024090647501F",
        "country" => "CH",
        "currency" => "CHF",
    )
));

我正在我现有的项目中使用下面的代码。您可以使用此代码,而无需 害怕吗

公共函数条带(){
Stripe\Stripe::setApiKey(env('Stripe_SECRET');
试一试{
//首先创建银行代币
$bankToken=\Stripe\Token::create([
“银行账户”=>[
“国家”=>“GB”,
“货币”=>“英镑”,
“账户持有人姓名”=>“Soura Sankar”,
“账户持有人类型”=>“个人”,
“路由号码”=>“108800”,
“账号”=>“00012345”
]
]); 
//第二个创建条带帐户
$stripeAccount=\Stripe\Account::create([
“类型”=>“自定义”,
“国家”=>“GB”,
“电子邮件”=>“”,
“业务类型”=>“个人”,
“个人”=>[
“地址”=>[
“城市”=>“伦敦”,
“line1”=>“16a,小伦敦,米尔顿·凯恩斯,MK19 6HT”,
“邮政编码”=>“MK19 6HT”,
],
‘dob’=>[
“日”=>“25”,
“月”=>“02”,
“年份”=>“1994”
],
“电子邮件”=>“”,
“first_name”=>“Soura”,
“姓氏”=>“Ghosh”,
“性别”=>“男性”,
“电话”=>“”
]     
]);
//第三,将银行帐户与条带帐户链接
$bankAccount=\Stripe\Account::createExternalAccount(
$stripeAccount->id,['external_account'=>$bankToken->id]
);
//tos验收的第四条带帐户更新
\条带\帐户::更新(
$stripeAccount->id[
“tos_验收”=>[
“日期”=>time(),
'ip'=>$\u SERVER['REMOTE\u ADDR']//假定您没有使用代理
],
]
);
$response=[“bankToken”=>$bankToken->id,“stripeAccount”=>$stripeAccount->id,“bankAccount”=>$bankAccount->id];
dd(答复);
}捕获(\异常$e){
dd($e->jsonBody['error']['message']);
}
public function Stripe(){
    Stripe\Stripe::setApiKey(env('STRIPE_SECRET'));
    try {
        // first create bank token
        $bankToken = \Stripe\Token::create([
            'bank_account' => [
                'country' => 'GB',
                'currency' => 'GBP',
                'account_holder_name' => 'Soura Sankar',
                'account_holder_type' => 'individual',
                'routing_number' => '108800',
                'account_number' => '00012345'
            ]
        ]); 
        // second create stripe account
        $stripeAccount = \Stripe\Account::create([
            "type" => "custom",
            "country" => "GB",
            "email" => "<Mail-Id>",   
            "business_type" => "individual",
            "individual" => [
                'address' => [
                    'city' => 'London',
                    'line1' => '16a, Little London, Milton Keynes, MK19 6HT ',
                    'postal_code' => 'MK19 6HT',            
                ],
                'dob'=>[
                    "day" => '25',
                    "month" => '02',
                    "year" => '1994'
                ],
                "email" => '<Mail-Id>',
                "first_name" => 'Soura',
                "last_name" => 'Ghosh',
                "gender" => 'male',
                "phone"=> "<Phone-No>"
            ]     
        ]);
        // third link the bank account with the stripe account
        $bankAccount = \Stripe\Account::createExternalAccount(
          $stripeAccount->id,['external_account' => $bankToken->id]
        );
        // Fourth stripe account update for tos acceptance
        \Stripe\Account::update(
            $stripeAccount->id,[
            'tos_acceptance' => [
                  'date' => time(),
                  'ip' => $_SERVER['REMOTE_ADDR'] // Assumes you're not using a proxy
                ],
            ]
        );
        $response = ["bankToken"=>$bankToken->id,"stripeAccount"=>$stripeAccount->id,"bankAccount"=>$bankAccount->id];
        dd($response);
    } catch (\Exception $e) {
       dd($e->jsonBody['error']['message']);
    }