Hey!
The issue here is that you're making the call to the Retrieve Customer
API [1] without passing the `stripe_account` parameter [2] which means
we look for that customer on your platform and it fails. You need to
make sure that you pass that second array like this:
$cu = \Stripe\Customer::retrieve(
array("id" => $create_customer->id),
array("stripe_account" => $stripe_id)
);
Based on your code, you also don't need to retrieve the customer since
it's already returned by your call to the Create Customer API [3] and
it's stored in $create_customer so you could do:
\Stripe\Stripe::setApiKey($sk_key);
try{
$create_customer = \Stripe\Customer::create(
array("description" => "Customer creation and plan subscription.",
'email' => $email, 'source' => $token),
array("stripe_account" => $stripe_id )
);
$sub = $create_customer->subscriptions->create(array("plan" =>
$plan_id,'application_fee_percent' => 3),
array("stripe_account" => $stripe_id));
} catch(\Stripe\Error\Card $e){
echo "error $e";
}
[1]
https://stripe.com/docs/api#retrieve_customer
[2]
https://stripe.com/docs/connect/authentication#authentication-via-the-stripe-account-header
[3]
https://stripe.com/docs/api#create_customer