title: Error sharing customer stripe and create charges with php
body: <p>I'm sorry for my english.</p>
  
  <p>I'm try to create a charge with a connected account in stripe using standalone account. I'm connecting my accounts using this article in stripe: <a href="https://stripe.com/docs/connect/standalone-accounts#sample-code" rel="nofollow noreferrer">Sample OAuth Applications</a>. I have 3 accounts: A) Main account. In this account are the clients of our app. Account B and account C are other accounts connected to account A (I see this two accounts connect in the settings of account A. That tells me that two account is already connected, right?). All user's app is in account A and we want share to account B and C, that's our target.</p>
  
  <p>When the accounts has been connected we save in our DB the acces_token and refresh token. The <a href="https://stripe.com/docs/connect/shared-customers" rel="nofollow noreferrer">docs</a> of shared customers says that we need create a token with the customer_id and the account_id in order to create a token with the credit card info of customer but when we execute the code it returns an error: </p>
  
  <p>The provided key 'sk_test_********************uJ3l' does not have access to account 'acct_--------------' (or that account does not exist). Application access may have been revoked.</p>
  
  <p>We have test a several combinations of variables pass to api and the result always returns an error.</p>
  
  <p>What are doing wrong in this case. Can you help us???</p>
  
  <p>This is the code that we using: All the comments has been the another test that we try:</p>
  
  <pre><code>public function createtransaction($customer_id, $paymentDesc, $destinationAccount) {
  
          $errors = array();
          try {
              $secret_key = $this-&gt;get_secret_key();
  
              \Stripe\Stripe::setApiKey($secret_key);
  
              // THIS ONLY FOR TESTING PURPOSE. WE WANT SEE IF CAN ACCESS TO CONNECTED ACCOUNT
              // Fetching an account just needs the ID as a parameter
              // WHIT ACCESS_TOKEN WORKS THE RETRIEVE METHOD
              // $account = \Stripe\Account::retrieve('access_token_from_db');
              // WHIT ACCOUNT_ID DOES NOT. RETURNS AN ERROR
              // $account = \Stripe\Account::retrieve('acct_***********');
              // echo "&lt;pre&gt;------";
              // print_r($account);
              // echo "-----&lt;/pre&gt;";
  
  
              // HERE ONLY WE CAN TEST IF WE CAN CREATE A CUSTOMER. THIS IS ONLY TO CHECK IF THE ACCOUNT IS CONNECTED. THE CUSTOMER ALREADY EXISTS IN MAIN ACCOUNT 
              // Recommended: sending API key with every request
              // \Stripe\Customer::create(
              //   array("description" =&gt; "example@stripe.com"),
              //   array("api_key" =&gt; 'sk_test_***************') // account's access token from the Connect flow
              // SAME. WITH stripe_account DOES NOT WORK. WHIT api_key PARAM WORKS WELL
              // );
  
              // THE DOCS SAYS WE NEED CREATE A TOEKN WITH customer AND stripe_account, BUT IT RETURNS AN ERROR OF PERMISSION
              // Create a Token from the existing customer on the platform's account
              // $token = \Stripe\Token::create(
              //  array("customer" =&gt; $customer_id),
              //  array("stripe_account" =&gt; 'acct_********************') // id of the connected account
              // );
  
              // echo "&lt;pre&gt;------";
              // print_r($token);
              // echo "-----&lt;/pre&gt;";
  
              // ONE COMBINATION. DOES NOT WORK
              // var_dump($customer_id, $paymentDesc, $destinationAccount);
              // $charge = \Stripe\Charge::create(array(
              //  "amount" =&gt; $paymentDesc['total'] * 100,
              //  "currency" =&gt; "usd",
              //  "source" =&gt; $token,
              //  "description" =&gt; $paymentDesc['description'],
              //  'destination' =&gt; $destinationAccount
              // ));
              //
              //
  
              // IT WORKS IN THE MAIN ACCOUNT BUT IT IS NOT OUR GOAL, BUT WE CAN TRANSFER THE MONEY TO ANOTHER CONNECTED ACCOUNT
              // $charge = \Stripe\Charge::create(array(
              //  'amount' =&gt; $paymentDesc['total'] * 100,
              //  'currency' =&gt; 'usd',
              //  'customer' =&gt; $customer_id,
              //  "description" =&gt; $paymentDesc['description']
              // ));
  
              // ANOTHER COMBINATION. DOES NOT WORK
              /*$charge = \Stripe\Charge::create(array(
                  'amount' =&gt; $paymentDesc['total'] * 100,
                  'currency' =&gt; 'usd',
                  "description" =&gt; $paymentDesc['description'],
                  'customer' =&gt; $customer_id
              ), array('stripe_account' =&gt; 'acct_************'));*/
  
              // ANOTHER COMBINATION. DOES NOT WORK
              /*$charge = \Stripe\Charge::create(array(
                  'amount' =&gt; $paymentDesc['total'] * 100,
                  'currency' =&gt; 'usd',
                  "description" =&gt; $paymentDesc['description'],
                  'customer' =&gt; $customer_id
              ), array('api_key' =&gt; 'ACCESS_TOKEN_IN_DB'));
  
              echo "&lt;pre&gt;------";
              print_r($charge);
              echo "-----&lt;/pre&gt;";
  
              return array('charge' =&gt; $charge);*/
  
          } catch(Stripe_CardError $e) {
              $errors = array('error' =&gt; false, 'message' =&gt; 'Card was declined.', 'e' =&gt; $e);
          } catch (Stripe_InvalidRequestError $e) {
              $errors = array('error' =&gt; false, 'message' =&gt; 'Invalid parameters were supplied to Stripe\'s API', 'e' =&gt; $e);
          } catch (Stripe_AuthenticationError $e) {
              $errors = array('error' =&gt; false, 'message' =&gt; 'Authentication with Stripe\'s API failed!', 'e' =&gt; $e);
          } catch (Stripe_ApiConnectionError $e) {
              $errors = array('error' =&gt; false, 'message' =&gt; 'Network communication with Stripe failed', 'e' =&gt; $e);
          } catch (Stripe_Error $e) {
              $errors = array('error' =&gt; false, 'message' =&gt; 'Stripe error. Something wrong just happened!', 'e' =&gt; $e);
          } catch (Exception $e) {
              $errors = array('error' =&gt; false, 'message' =&gt; 'An error has ocurred getting info customer.', 'e' =&gt; $e);
          }
  
          return $errors;
      }
  </code></pre>