#dino_pephanis - Customer

1 messages ยท Page 1 of 1 (latest)

mossy gale
#

Hi ๐Ÿ‘‹

edgy crown
#

Hi

mossy gale
#

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.

edgy crown
#
  ["email" => "person@example.edu"],
  ["stripe_account" => "{{CONNECTED_STRIPE_ACCOUNT_ID}}"]
);```
mossy gale
#

Were you using double quotes, or single?

edgy crown
#

$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

mossy gale
#

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

edgy crown
mossy gale
#

Right, but since your request looks good to me, I'm trying to be nitpicky to see if it helps anything

mossy gale
edgy crown
#

Is there a Customer and Customers

#

\Stripe\Customer::create vs $stripe->customers->create

mossy gale
edgy crown
mossy gale
edgy crown
mossy gale
#

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

edgy crown
#

Ah OK,

#

The example works

mossy gale
#

Okay cool

#

Can you re-purpose that request to assign the Customers to your Connected Accounts?

edgy crown
#

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

mossy gale
edgy crown
#

req_VBU4WZQe0t3ubW

mossy gale
#

Yup, no Stripe Account header

edgy crown
#

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

mossy gale
#

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

edgy crown
#
            $customer->id,
            [ 'source' => $token,],
            ['stripe_account' => $this->getStripeAccount()]
        );```
mossy gale
#

And what happens when you run that?

edgy crown
#

req_CTe7ggegULt6xD

#

parameter_unknown - stripe_account

#

Sorry need to go pick up my daughter - are you around tomorrow?

mossy gale
#

Okay, passed in again as a parameter, not a header.

edgy crown
#

Thanks for your help.