feat: enrichir la création client Stripe avec toutes les infos entreprise
initStripeCustomer amélioré : - name : raison sociale (priorité) ou nom complet du contact - phone : téléphone du client - address : adresse complète (line1, line2, postal_code, city, country FR) - metadata : crm_user_id, siret, code_comptable - tax_id_data : numéro TVA intracommunautaire (eu_vat) si disponible finalizeStripeCustomer amélioré : - metadata enrichi avec code_comptable en plus du crm_user_id Le stripeCustomerId est stocké dans Customer::stripeCustomerId après la création et persiste en BDD via le flush. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -108,11 +108,33 @@ class ClientsController extends AbstractController
|
||||
}
|
||||
|
||||
\Stripe\Stripe::setApiKey($stripeSecretKey);
|
||||
$stripeCustomer = \Stripe\Customer::create([
|
||||
$params = [
|
||||
'email' => $customer->getEmail(),
|
||||
'name' => $customer->getFullName(),
|
||||
'metadata' => ['crm_user_id' => 'pending'],
|
||||
'name' => $customer->getRaisonSociale() ?? $customer->getFullName(),
|
||||
'phone' => $customer->getPhone(),
|
||||
'metadata' => [
|
||||
'crm_user_id' => 'pending',
|
||||
'siret' => $customer->getSiret() ?? '',
|
||||
'code_comptable' => $customer->getCodeComptable() ?? '',
|
||||
],
|
||||
];
|
||||
|
||||
$address = array_filter([
|
||||
'line1' => $customer->getAddress(),
|
||||
'line2' => $customer->getAddress2(),
|
||||
'postal_code' => $customer->getZipCode(),
|
||||
'city' => $customer->getCity(),
|
||||
'country' => 'FR',
|
||||
]);
|
||||
if (isset($address['line1'])) {
|
||||
$params['address'] = $address;
|
||||
}
|
||||
|
||||
if ($customer->getNumTva()) {
|
||||
$params['tax_id_data'] = [['type' => 'eu_vat', 'value' => $customer->getNumTva()]];
|
||||
}
|
||||
|
||||
$stripeCustomer = \Stripe\Customer::create($params);
|
||||
$customer->setStripeCustomerId($stripeCustomer->id);
|
||||
}
|
||||
|
||||
@@ -125,7 +147,10 @@ class ClientsController extends AbstractController
|
||||
|
||||
\Stripe\Stripe::setApiKey($stripeSecretKey);
|
||||
\Stripe\Customer::update($customer->getStripeCustomerId(), [
|
||||
'metadata' => ['crm_user_id' => (string) $user->getId()],
|
||||
'metadata' => [
|
||||
'crm_user_id' => (string) $user->getId(),
|
||||
'code_comptable' => $customer->getCodeComptable() ?? '',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user