Fix php code

This commit is contained in:
Laurent Destailleur 2018-03-10 23:50:41 +01:00
parent 390618db47
commit 0389664b1e
2 changed files with 329 additions and 314 deletions

View File

@ -1,313 +1,328 @@
<?php <?php
/* Copyright (C) 2018
define("NOLOGIN",1); // This means this output page does not require to be logged. *
define("NOCSRFCHECK",1); // We accept to go on this page from external web site. * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); * the Free Software Foundation; either version 3 of the License, or
if (is_numeric($entity)) define("DOLENTITY", $entity); * (at your option) any later version.
*
$res=0; * This program is distributed in the hope that it will be useful,
if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); // to work if your module directory is into a subdir of root htdocs directory * but WITHOUT ANY WARRANTY; without even the implied warranty of
if (! $res) die("Include of main fails"); * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
if (empty($conf->stripe->enabled)) accessforbidden('',0,0,1); *
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; * You should have received a copy of the GNU General Public License
require_once DOL_DOCUMENT_ROOT.'/includes/stripe/init.php'; * along with this program. If not, see <http://www.gnu.org/licenses/>.
require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; */
require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php';
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; define("NOLOGIN",1); // This means this output page does not require to be logged.
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; if (is_numeric($entity)) define("DOLENTITY", $entity);
// You can find your endpoint's secret in your webhook settings $res=0;
if (isset($_GET['connect'])){ if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); // to work if your module directory is into a subdir of root htdocs directory
if (isset($_GET['test'])) if (! $res) die("Include of main fails");
{
$endpoint_secret = $conf->global->STRIPE_TEST_WEBHOOK_CONNECT_KEY; if (empty($conf->stripe->enabled)) accessforbidden('',0,0,1);
$service = 'StripeTest'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
} require_once DOL_DOCUMENT_ROOT.'/includes/stripe/init.php';
else require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
{ require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php';
$endpoint_secret = $conf->global->STRIPE_LIVE_WEBHOOK_CONNECT_KEY; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
$service = 'StripeLive'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
} require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
}else { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
if (isset($_GET['test'])) require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
{
$endpoint_secret = $conf->global->STRIPE_TEST_WEBHOOK_KEY; // You can find your endpoint's secret in your webhook settings
$service = 'StripeTest'; if (isset($_GET['connect'])){
} if (isset($_GET['test']))
else {
{ $endpoint_secret = $conf->global->STRIPE_TEST_WEBHOOK_CONNECT_KEY;
$endpoint_secret = $conf->global->STRIPE_LIVE_WEBHOOK_KEY; $service = 'StripeTest';
$service = 'StripeLive'; }
} else
} {
$payload = @file_get_contents("php://input"); $endpoint_secret = $conf->global->STRIPE_LIVE_WEBHOOK_CONNECT_KEY;
$sig_header = $_SERVER["HTTP_STRIPE_SIGNATURE"]; $service = 'StripeLive';
$event = null; }
}else {
$error = 0; if (isset($_GET['test']))
{
try { $endpoint_secret = $conf->global->STRIPE_TEST_WEBHOOK_KEY;
$event = \Stripe\Webhook::constructEvent($payload, $sig_header, $endpoint_secret); $service = 'StripeTest';
} }
catch(\UnexpectedValueException $e) { else
// Invalid payload {
http_response_code(400); // PHP 5.4 or greater $endpoint_secret = $conf->global->STRIPE_LIVE_WEBHOOK_KEY;
exit(); $service = 'StripeLive';
} catch(\Stripe\Error\SignatureVerification $e) { }
// Invalid signature }
http_response_code(400); // PHP 5.4 or greater $payload = @file_get_contents("php://input");
exit(); $sig_header = $_SERVER["HTTP_STRIPE_SIGNATURE"];
} $event = null;
// Do something with $event $error = 0;
http_response_code(200); // PHP 5.4 or greater try {
$langs->load("main"); $event = \Stripe\Webhook::constructEvent($payload, $sig_header, $endpoint_secret);
$user = new User($db); }
$user->fetch(5); catch(\UnexpectedValueException $e) {
$user->getrights(); // Invalid payload
http_response_code(400); // PHP 5.4 or greater
if (! empty($conf->multicompany->enabled) && ! empty($conf->stripeconnect->enabled)) { exit();
$sql = "SELECT entity"; } catch(\Stripe\Error\SignatureVerification $e) {
$sql.= " FROM ".MAIN_DB_PREFIX."oauth_token"; // Invalid signature
$sql.= " WHERE service = '$service' and tokenstring = '%".$event->account."%'"; http_response_code(400); // PHP 5.4 or greater
exit();
dol_syslog(get_class($db) . "::fetch", LOG_DEBUG); }
$result = $db->query($sql);
if ($result) // Do something with $event
{
if ($db->num_rows($result)) http_response_code(200); // PHP 5.4 or greater
{ $langs->load("main");
$obj = $db->fetch_object($result); $user = new User($db);
$key=$obj->entity; $user->fetch(5);
} $user->getrights();
else {$key=1;}
} if (! empty($conf->multicompany->enabled) && ! empty($conf->stripeconnect->enabled)) {
else {$key=1;} $sql = "SELECT entity";
$ret=$mc->switchEntity($key); $sql.= " FROM ".MAIN_DB_PREFIX."oauth_token";
if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); $sql.= " WHERE service = '$service' and tokenstring = '%".$event->account."%'";
if (! $res) die("Include of main fails");
} dol_syslog(get_class($db) . "::fetch", LOG_DEBUG);
$result = $db->query($sql);
// list of action if ($result)
$stripe=new Stripe($db); {
if ($event->type == 'payout.created') { if ($db->num_rows($result))
$error=0; {
$obj = $db->fetch_object($result);
$result=dolibarr_set_const($db, $service."_NEXTPAYOUT",date('Y-m-d H:i:s',$event->data->object->arrival_date),'chaine',0,'',$conf->entity); $key=$obj->entity;
}
if ($result > 0) else {$key=1;
{ }
$body = "Un virement de ".price2num($event->data->object->amount/100)." ".$event->data->object->currency." est attendu sur votre compte le ".date('d-m-Y H:i:s',$event->data->object->arrival_date); }
$subject = '[NOTIFICATION] Virement programmée'; else {$key=1;
$headers = 'From: "'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'" <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; TODO convert in dolibarr standard }
mail(''.$conf->global->MAIN_INFO_SOCIETE_MAIL.'', $subject, $body, $headers); $ret=$mc->switchEntity($key);
return 1; if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php");
} if (! $res) die("Include of main fails");
else }
{
$error++; // list of action
return -1; $stripe=new Stripe($db);
} if ($event->type == 'payout.created') {
} $error=0;
elseif ($event->type == 'payout.paid') {
global $conf; $result=dolibarr_set_const($db, $service."_NEXTPAYOUT",date('Y-m-d H:i:s',$event->data->object->arrival_date),'chaine',0,'',$conf->entity);
$error=0;
$result=dolibarr_set_const($db, $service."_NEXTPAYOUT",null,'chaine',0,'',$conf->entity); if ($result > 0)
if ($result) {
{ $body = "Un virement de ".price2num($event->data->object->amount/100)." ".$event->data->object->currency." est attendu sur votre compte le ".date('d-m-Y H:i:s',$event->data->object->arrival_date);
$langs->load("errors"); $subject = '[NOTIFICATION] Virement programmée';
$headers = 'From: "'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'" <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; // TODO convert in dolibarr standard
$dateo = dol_now(); mail(''.$conf->global->MAIN_INFO_SOCIETE_MAIL.'', $subject, $body, $headers);
$label = $event->data->object->description; return 1;
$amount= $event->data->object->amount/100; }
$amount_to= $event->data->object->amount/100; else
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; {
$error++;
$accountfrom=new Account($db); return -1;
$accountfrom->fetch($conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS); }
}
$accountto=new Account($db); elseif ($event->type == 'payout.paid') {
$accountto->fetch($conf->global->STRIPE_BANK_ACCOUNT_FOR_BANKTRANFERS); global $conf;
$error=0;
if ($accountto->currency_code != $accountfrom->currency_code) { $result=dolibarr_set_const($db, $service."_NEXTPAYOUT",null,'chaine',0,'',$conf->entity);
$error++; if ($result)
setEventMessages($langs->trans("ErrorTransferBetweenDifferentCurrencyNotPossible"), null, 'errors'); {
} $langs->load("errors");
if ($accountto->id != $accountfrom->id) $dateo = dol_now();
{ $label = $event->data->object->description;
$amount= $event->data->object->amount/100;
$bank_line_id_from=0; $amount_to= $event->data->object->amount/100;
$bank_line_id_to=0; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$result=0;
$accountfrom=new Account($db);
// By default, electronic transfert from bank to bank $accountfrom->fetch($conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS);
$typefrom='PRE';
$typeto='VIR'; $accountto=new Account($db);
$accountto->fetch($conf->global->STRIPE_BANK_ACCOUNT_FOR_BANKTRANFERS);
if (! $error) $bank_line_id_from = $accountfrom->addline($dateo, $typefrom, $label, -1*price2num($amount), '', '', $user);
if (! ($bank_line_id_from > 0)) $error++; if ($accountto->currency_code != $accountfrom->currency_code) {
if ((! $error) && ($accountto->currency_code == $accountfrom->currency_code)) $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, price2num($amount), '', '', $user); $error++;
if ((! $error) && ($accountto->currency_code != $accountfrom->currency_code)) $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, price2num($amount_to), '', '', $user); setEventMessages($langs->trans("ErrorTransferBetweenDifferentCurrencyNotPossible"), null, 'errors');
if (! ($bank_line_id_to > 0)) $error++; }
if (! $error) $result=$accountfrom->add_url_line($bank_line_id_from, $bank_line_id_to, DOL_URL_ROOT.'/compta/bank/ligne.php?rowid=', '(banktransfert)', 'banktransfert'); if ($accountto->id != $accountfrom->id)
if (! ($result > 0)) $error++; {
if (! $error) $result=$accountto->add_url_line($bank_line_id_to, $bank_line_id_from, DOL_URL_ROOT.'/compta/bank/ligne.php?rowid=', '(banktransfert)', 'banktransfert');
if (! ($result > 0)) $error++; $bank_line_id_from=0;
} $bank_line_id_to=0;
$result=0;
$body = "Un virement de ".price2num($event->data->object->amount/100)." ".$event->data->object->currency." a ete effectue sur votre compte le ".date('d-m-Y H:i:s',$event->data->object->arrival_date);
$subject = '[NOTIFICATION] Virement effectué'; // By default, electronic transfert from bank to bank
$headers = 'From: "'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'" <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; TODO convert in dolibarr standard $typefrom='PRE';
mail(''.$conf->global->MAIN_INFO_SOCIETE_MAIL.'', $subject, $body, $headers); $typeto='VIR';
return 1; if (! $error) $bank_line_id_from = $accountfrom->addline($dateo, $typefrom, $label, -1*price2num($amount), '', '', $user);
} if (! ($bank_line_id_from > 0)) $error++;
else if ((! $error) && ($accountto->currency_code == $accountfrom->currency_code)) $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, price2num($amount), '', '', $user);
{ if ((! $error) && ($accountto->currency_code != $accountfrom->currency_code)) $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, price2num($amount_to), '', '', $user);
$error++; if (! ($bank_line_id_to > 0)) $error++;
return -1;
} if (! $error) $result=$accountfrom->add_url_line($bank_line_id_from, $bank_line_id_to, DOL_URL_ROOT.'/compta/bank/ligne.php?rowid=', '(banktransfert)', 'banktransfert');
} if (! ($result > 0)) $error++;
elseif ($event->type == 'charge.succeeded') { if (! $error) $result=$accountto->add_url_line($bank_line_id_to, $bank_line_id_from, DOL_URL_ROOT.'/compta/bank/ligne.php?rowid=', '(banktransfert)', 'banktransfert');
if (! ($result > 0)) $error++;
//TODO: create fees }
} $body = "Un virement de ".price2num($event->data->object->amount/100)." ".$event->data->object->currency." a ete effectue sur votre compte le ".date('d-m-Y H:i:s',$event->data->object->arrival_date);
elseif ($event->type == 'customer.source.created') { $subject = '[NOTIFICATION] Virement effectué';
$headers = 'From: "'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'" <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; // TODO convert in dolibarr standard
//TODO: save customer's source mail(''.$conf->global->MAIN_INFO_SOCIETE_MAIL.'', $subject, $body, $headers);
} return 1;
elseif ($event->type == 'customer.source.updated') { }
else
//TODO: update customer's source {
$error++;
} return -1;
elseif ($event->type == 'customer.source.delete') { }
}
//TODO: delete customer's source elseif ($event->type == 'charge.succeeded') {
} //TODO: create fees
elseif ($event->type == 'charge.failed') {
}
$subject = 'Your payment has been received: '.$event->data->object->id.''; elseif ($event->type == 'customer.source.created') {
$headers = 'From: "'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'" <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>';
//mail('ptibogxiv@msn.com', $subject, 'test', $headers); //TODO: save customer's source
} }
elseif (($event->type == 'source.chargeable') && ($event->data->object->type == 'three_d_secure') && ($event->data->object->three_d_secure->authenticated==true)) { elseif ($event->type == 'customer.source.updated') {
$stripe=new Stripe($db); //TODO: update customer's source
$charge=$stripe->CreatePaymentStripe($event->data->object->amount/100,$event->data->object->currency,$event->data->object->metadata->source,$event->data->object->metadata->idsource,$event->data->object->id,$event->data->object->metadata->customer,$stripe->getStripeAccount($service));
}
if (isset($charge->id) && $charge->statut=='error'){ elseif ($event->type == 'customer.source.delete') {
$msg=$charge->message;
$code=$charge->code; //TODO: delete customer's source
$error++;
} }
elseif (isset($charge->id) && $charge->statut=='success' && $event->data->object->metadata->source=='order') { elseif ($event->type == 'charge.failed') {
$order=new Commande($db);
$order->fetch($event->data->object->metadata->idsource); $subject = 'Your payment has been received: '.$event->data->object->id.'';
$invoice = new Facture($db); $headers = 'From: "'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'" <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>';
$idinv=$invoice->createFromOrder($order); //mail('ptibogxiv@msn.com', $subject, 'test', $headers);
if ($idinv > 0) }
{ elseif (($event->type == 'source.chargeable') && ($event->data->object->type == 'three_d_secure') && ($event->data->object->three_d_secure->authenticated==true)) {
$result=$invoice->validate($user);
if ($result > 0) { $stripe=new Stripe($db);
$invoice->fetch($idinv); $charge=$stripe->CreatePaymentStripe($event->data->object->amount/100,$event->data->object->currency,$event->data->object->metadata->source,$event->data->object->metadata->idsource,$event->data->object->id,$event->data->object->metadata->customer,$stripe->getStripeAccount($service));
$paiement = $invoice->getSommePaiement();
$creditnotes=$invoice->getSumCreditNotesUsed(); if (isset($charge->id) && $charge->statut=='error'){
$deposits=$invoice->getSumDepositsUsed(); $msg=$charge->message;
$ref=$invoice->ref; $code=$charge->code;
$ifverif=$invoice->socid; $error++;
$currency=$invoice->multicurrency_code; }
$total=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT'); elseif (isset($charge->id) && $charge->statut=='success' && $event->data->object->metadata->source=='order') {
}else{ $order=new Commande($db);
$msg=$invoice->error; $order->fetch($event->data->object->metadata->idsource);
$error++; $invoice = new Facture($db);
} $idinv=$invoice->createFromOrder($order);
}else{
$msg=$invoice->error; if ($idinv > 0)
$error++; {
} $result=$invoice->validate($user);
} if ($result > 0) {
$invoice->fetch($idinv);
if (!$error){ $paiement = $invoice->getSommePaiement();
$datepaye = dol_now(); $creditnotes=$invoice->getSumCreditNotesUsed();
$paiementcode ="CB"; $deposits=$invoice->getSumDepositsUsed();
$amounts=array(); $ref=$invoice->ref;
$amounts[$invoice->id] = $total; $ifverif=$invoice->socid;
$multicurrency_amounts=array(); $currency=$invoice->multicurrency_code;
//$multicurrency_amounts[$item] = $total; $total=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT');
$paiement = new Paiement($db); }else{
$paiement->datepaye = $datepaye; $msg=$invoice->error;
$paiement->amounts = $amounts; // Array with all payments dispatching $error++;
$paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching }
$paiement->paiementid = dol_getIdFromCode($db,$paiementcode,'c_paiement'); }else{
$paiement->num_paiement = $charge->message; $msg=$invoice->error;
$paiement->note = ''; $error++;
} }
}
if (! $error){
$paiement_id=$paiement->create($user, 0); if (!$error){
$datepaye = dol_now();
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE) && count($invoice->lines)){ $paiementcode ="CB";
$outputlangs = $langs; $amounts=array();
$newlang = ''; $amounts[$invoice->id] = $total;
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); $multicurrency_amounts=array();
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $invoice->thirdparty->default_lang; //$multicurrency_amounts[$item] = $total;
if (! empty($newlang)) { $paiement = new Paiement($db);
$outputlangs = new Translate("", $conf); $paiement->datepaye = $datepaye;
$outputlangs->setDefaultLang($newlang); $paiement->amounts = $amounts; // Array with all payments dispatching
} $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching
$model=$invoice->modelpdf; $paiement->paiementid = dol_getIdFromCode($db,$paiementcode,'c_paiement');
$ret = $invoice->fetch($invoice->id); // Reload to get new records $paiement->num_paiement = $charge->message;
$paiement->note = '';
$invoice->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);} }
if ($paiement_id < 0){
$msg=$paiement->errors; if (! $error){
$error++; $paiement_id=$paiement->create($user, 0);
}else{
if ($event->data->object->metadata->source=='order') { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE) && count($invoice->lines)){
$order->classifyBilled($user); $outputlangs = $langs;
} $newlang = '';
} if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09');
} if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $invoice->thirdparty->default_lang;
if (! empty($newlang)) {
if (! $error){ $outputlangs = new Translate("", $conf);
$label='(CustomerInvoicePayment)'; $outputlangs->setDefaultLang($newlang);
if (GETPOST('type') == 2) $label='(CustomerInvoicePaymentBack)'; }
$paiement->addPaymentToBank($user,'payment',$label,$conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS,'',''); $model=$invoice->modelpdf;
if ($result < 0) $ret = $invoice->fetch($invoice->id); // Reload to get new records
{
$msg=$paiement->errors; $invoice->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
$error++; }
} if ($paiement_id < 0){
$invoice->set_paid($user); $msg=$paiement->errors;
} $error++;
}else{
$body = ""; if ($event->data->object->metadata->source=='order') {
$subject = 'Facture '.$invoice->ref; $order->classifyBilled($user);
$headers = 'From: "'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'" <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; }
//mail('ptibogxiv@msn.com', $subject, $body, $headers); TODO convert in dolibarr standard }
} }
elseif ($event->type == 'customer.deleted') {
$db->begin(); if (! $error){
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_stripe WHERE fk_key = '".$event->data->object->id."' "; $label='(CustomerInvoicePayment)';
dol_syslog(get_class($this) . "::delete sql=" . $sql, LOG_DEBUG); if (GETPOST('type') == 2) $label='(CustomerInvoicePaymentBack)';
$db->query($sql); $paiement->addPaymentToBank($user,'payment',$label,$conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS,'','');
$db->commit(); if ($result < 0)
} {
$msg=$paiement->errors;
$error++;
}
?> $invoice->set_paid($user);
}
$body = "";
$subject = 'Facture '.$invoice->ref;
$headers = 'From: "'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'" <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>';
//mail('ptibogxiv@msn.com', $subject, $body, $headers); TODO convert in dolibarr standard
}
elseif ($event->type == 'customer.deleted') {
$db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_stripe WHERE fk_key = '".$event->data->object->id."' ";
dol_syslog(get_class($this) . "::delete sql=" . $sql, LOG_DEBUG);
$db->query($sql);
$db->commit();
}

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or * the Free Software Foundation; either version 3 of the License, or