Add name, address, city, etc. Into a Stripe Customer object in PHP

I use Stripefor payments and would like to add additional information (name and surname, address and phone number) to the user object.

$token  = $_POST['stripeToken'];
$email  = strip_tags(trim($_POST['email']));
$donation_type = $_POST['type'];
$donation_type_other = $_POST['other'];

// User Info
$name_first = $_POST['name_first'];
$name_last = $_POST['name_last'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$user_info = array("First Name" => $name_first, "Last Name" => $name_last, "Address" => $address, "State" => $state, "Zip Code" => $zip);

// Metadata for the charge
$metadata_charge = array();
if (!empty($donation_type_other) && $donation_type == 'Other') {
    $metadata_charge = array("Donation Type" => $donation_type, "Other" => $donation_type_other);   
} else {
    $metadata_charge = array("Donation Type" => $donation_type);    
}

$customer = \Stripe\Customer::create(array(
  'email' => $email,
  'card'  => $token,
  'metadata' => $user_info
));

$charge = \Stripe\Charge::create(array(
  'customer' => $customer->id,
  'receipt_email' => $email,
  'amount'   => $_POST['amount']*100,
  'currency' => 'usd',
  "metadata" => $metadata_charge
));

What is the best way to do this? Use metadatafor object Customer? Or would I set it as the shipping address / information?

+4
source share
1 answer

, , , , . Stripe - , , , . , ( cus_8Dmu7vi6wah58z), .

, . , , , .

, .

+4
source

All Articles