0
votes

Dear Stack overflow users,

I'm trying to create a customer through the Stripe API in PHP. But I'm not sure how I can add the optional child arguments; name, address_city, address_country, address_zip etc.

I added them as metadata but then they don't show up under the customer's card.

$customer = \Stripe\Customer::create(

                array(
                'email'=>$email,
                'source'=>$token,
                 'metadata'=>array(
                  'full_name'=>$fullname,
                  'address'=>$address,
                  'zip_code'=>$zip_code,
                  'city'=>$city,
                  'country'=>$country,
                  'email'=>$email
                  ),
                  'plan'=>$plan

                   )
                  );                        

I would also like to ask; Do you recommend adding these "optional" fields. Is it Higher/lower risk that a card gets declined like this? Does it look better for Stripe when we include these fields?

Please let me know :)

Thanks in advance.

1

1 Answers

0
votes

The best way is to save only customer card and email and then retrieve customer ID from stripe and save it in your own database along with other details like address, city and country etc.

Create new customer in stripe

$customer = Stripe_Customer::create(array(
   "card" => $_POST['CARD'],
   "email" => $_POST['EMAIL']
));

Use this customer key in creating subscriber and then insert into your database

$CUST_KEY = $customer->id;

Later you can use the customer key to add another subscriber and can map any customer detail on your database with your stripe account.

Stripe_Customer::retrieve("$CUST_KEY");