#dino_pephanis - Customer
1 messages ยท Page 1 of 1 (latest)
Hi
The approach you are taking is the correct one. You need to use the stripe account header to assign the customer to the connected accout.
But, you might need to double check the syntax.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I was referred to an example on https://stripe.com/docs/connect/authentication
["email" => "person@example.edu"],
["stripe_account" => "{{CONNECTED_STRIPE_ACCOUNT_ID}}"]
);```
Were you using double quotes, or single?
$stripe->customers->create([$data],['stripe_account' => '{{CONNECTED_STRIPE_ACCOUNT_ID}}']);
$stripe->customers->create([$data],['stripe_account' => '{{CONNECTED_STRIPE_ACCOUNT_ID}}']);
I use single quote for all my data and worked fine until I tried to Connect the Stripe account
I just ask because the example uses double quotes and I haven't played enough with PHP to know whether or not that could disrupt the header assignment.
The error you are getting suggests that the PHP library is trying to pass the stripe_account as a parameter, rather than a header
It shouldn't as long as it is consistent - start & end string with same quote
Right, but since your request looks good to me, I'm trying to be nitpicky to see if it helps anything
What happens if you copy/paste this code right here? Does that run or give you the same error?
Is there a Customer and Customers
\Stripe\Customer::create vs $stripe->customers->create
I think the second is the preferred, more modern syntax. We discuss it a bit in the README for our PHP library.
https://github.com/stripe/stripe-php#getting-started
PHP library for the Stripe API. . Contribute to stripe/stripe-php development by creating an account on GitHub.
In essence these are the same thing?
It appears to be similar, based on the migration guide: https://github.com/stripe/stripe-php/wiki/Migration-to-StripeClient-and-services-in-7.33.0
In the API docs I couldn't find any reference to linking a Customer to a Connected Account https://stripe.com/docs/api/customers
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
We don't reference it explicitly in API docs because we'd be repeating ourselves for each API
It's one of the first things we reference near the top of the API docs
Okay cool
Can you re-purpose that request to assign the Customers to your Connected Accounts?
I presume you can't mix Legacy approach & StripeClient approach as when I use the Legacy approach to generate the customer I get a No such customer error
That error indicates you are making the request on a different account. Can you provide request IDs?
Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request
req_VBU4WZQe0t3ubW
Yup, no Stripe Account header
This is my function...
//TODO ADD TRY CATCH - Error handling
/** @var \Stripe\Card $card */
$card = $token->card;
\Stripe\Stripe::setApiKey('omnipay.gateways.stripe.secret_key');
$customer = \Stripe\Customer::create([
'name'=>$card->name,
'email'=>$this->getEmail(),
'address'=>[
'city'=>$card->address_city,
'country'=>$card->address_country,
'line1'=>$card->address_line1,
'line2'=>$card->address_line2,
'postal_code'=>$card->address_zip,
'state'=>$card->address_state,
],
['stripe_account' => $this->getStripeAccount()]
]);
$this->setStripeCustomer($customer);
$source = $this->stripe->customers->createSource(
$customer->id,
[
'source' => $token,
]
);
$this->setStripeSource($source);
}```
I have refactored to use the legacy approach
Okay so when you are creating the source, you need to still specify the stripe_account
Every time you want to interact with that Customer record, you will need to use that stripe_account header
$customer->id,
[ 'source' => $token,],
['stripe_account' => $this->getStripeAccount()]
);```
And what happens when you run that?
req_CTe7ggegULt6xD
parameter_unknown - stripe_account
Sorry need to go pick up my daughter - are you around tomorrow?
Okay, passed in again as a parameter, not a header.
Thanks for your help.