No such customer

68 views
Skip to first unread message

Chamssoudine Bacar

unread,
Oct 2, 2015, 1:53:39 AM10/2/15
to Stripe API Discussion
Hi,

I have some problem by try working in stripe API (connected account).

I need to create a customer into connected account, then subscribe a plan to that customer and apply an application fee.
Below is my code but stripe return always returned "No such Customer".I think the problem is in ( \Stripe\Customer::retrieve($create_customer->id);) as i create into a connected account and try to fetch from platform account. if yes how can handle it? Thanks for your help.

\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 )
);

if(isset($create_customer->id)){

$cu = \Stripe\Customer::retrieve($create_customer->id);

$sub = $cu->subscriptions->create(array("plan" => $plan_id,'application_fee_percent' => 3),
array("stripe_account" => $stripe_id));

}

 } catch(\Stripe\Error\Card $e){

}

Matthew Arkin

unread,
Oct 2, 2015, 1:55:57 AM10/2/15
to Jake K.
As you stated you're creating the customer in the connected account so therefor only the connected account has access to it. You'd have to access it as the connected account:

$cu = \Stripe\Customer::retrieve($create_customer->id, array("stripe_account" => $stripe_id ));

--
You received this message because you are subscribed to the Google Groups "Stripe API Discussion" group.
To post to this group, send email to api-d...@lists.stripe.com.
Visit this group at http://groups.google.com/a/lists.stripe.com/group/api-discuss/.

To unsubscribe from this group and stop receiving emails from it, send an email to api-discuss...@lists.stripe.com.

Remi J.

unread,
Oct 2, 2015, 1:56:55 AM10/2/15
to api-d...@lists.stripe.com
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

On Thu, Oct 1, 2015 at 10:51 PM, Chamssoudine Bacar
<bacar.tech...@gmail.com> wrote:

Chamssoudine Bacar

unread,
Oct 2, 2015, 2:04:34 AM10/2/15
to Stripe API Discussion
Yes, thanks. i am trying.

$cu = \Stripe\Customer::retrieve($create_customer->id, array("stripe_account" => $stripe_id ));

Reply all
Reply to author
Forward
0 new messages