2017-11-29 3 views
1

ストライプAPIは、アカウントを作成し、それを更新する方法について説明します。 https://stripe.com/docs/api#external_accounts銀行口座を追加し、それをStripeの「接続アカウント」に添付するにはどうすればいいですか?

ストライプAPIはまた、銀行口座を作成する方法について説明します。 https://stripe.com/docs/api#account_create_bank_account

私は、接続のための銀行口座を作成しようとしています残念ながら私はこのエラーメッセージでブロックされ続けます:

必須パラメータ:external_accountがありません。ここで

私は、接続アカウントを作成する進めた方法です:

public function test_stripe_create_connected_account(Request $request) 
{ 

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

    $acct = \Stripe\Account::create(array(
     "country" => "CH", 
     "type" => "custom", 
     "email" => "[email protected]" 
    )); 

} 

それから私はこの方法でそれを更新することで、アカウントを完了します。

public function test_stripe_update_account(Request $request) 
{ 

    try { 

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

     $account = \Stripe\Account::retrieve("acct_1BTRCOB5XLEUUY47"); 
     $account->support_email = "[email protected]"; 
     $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; 

} 

私は間違って何をしていますか?

助けていただけたら幸いです!あなたはこのように、external_accountパラメータ名の下に配列をラップするために、あなたのexternal account creation requestを変更する必要が

答えて

2

:それは確かに働いた

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

はあなたに感謝、私はとても近かったです! – 118218

関連する問題