Fix php code
This commit is contained in:
parent
390618db47
commit
0389664b1e
@ -1,4 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/* Copyright (C) 2018
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
define("NOLOGIN",1); // This means this output page does not require to be logged.
|
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.
|
define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
|
||||||
@ -23,27 +38,27 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
|
|||||||
|
|
||||||
// You can find your endpoint's secret in your webhook settings
|
// You can find your endpoint's secret in your webhook settings
|
||||||
if (isset($_GET['connect'])){
|
if (isset($_GET['connect'])){
|
||||||
if (isset($_GET['test']))
|
if (isset($_GET['test']))
|
||||||
{
|
{
|
||||||
$endpoint_secret = $conf->global->STRIPE_TEST_WEBHOOK_CONNECT_KEY;
|
$endpoint_secret = $conf->global->STRIPE_TEST_WEBHOOK_CONNECT_KEY;
|
||||||
$service = 'StripeTest';
|
$service = 'StripeTest';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$endpoint_secret = $conf->global->STRIPE_LIVE_WEBHOOK_CONNECT_KEY;
|
$endpoint_secret = $conf->global->STRIPE_LIVE_WEBHOOK_CONNECT_KEY;
|
||||||
$service = 'StripeLive';
|
$service = 'StripeLive';
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
if (isset($_GET['test']))
|
if (isset($_GET['test']))
|
||||||
{
|
{
|
||||||
$endpoint_secret = $conf->global->STRIPE_TEST_WEBHOOK_KEY;
|
$endpoint_secret = $conf->global->STRIPE_TEST_WEBHOOK_KEY;
|
||||||
$service = 'StripeTest';
|
$service = 'StripeTest';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$endpoint_secret = $conf->global->STRIPE_LIVE_WEBHOOK_KEY;
|
$endpoint_secret = $conf->global->STRIPE_LIVE_WEBHOOK_KEY;
|
||||||
$service = 'StripeLive';
|
$service = 'StripeLive';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$payload = @file_get_contents("php://input");
|
$payload = @file_get_contents("php://input");
|
||||||
$sig_header = $_SERVER["HTTP_STRIPE_SIGNATURE"];
|
$sig_header = $_SERVER["HTTP_STRIPE_SIGNATURE"];
|
||||||
@ -52,16 +67,16 @@ $event = null;
|
|||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$event = \Stripe\Webhook::constructEvent($payload, $sig_header, $endpoint_secret);
|
$event = \Stripe\Webhook::constructEvent($payload, $sig_header, $endpoint_secret);
|
||||||
}
|
}
|
||||||
catch(\UnexpectedValueException $e) {
|
catch(\UnexpectedValueException $e) {
|
||||||
// Invalid payload
|
// Invalid payload
|
||||||
http_response_code(400); // PHP 5.4 or greater
|
http_response_code(400); // PHP 5.4 or greater
|
||||||
exit();
|
exit();
|
||||||
} catch(\Stripe\Error\SignatureVerification $e) {
|
} catch(\Stripe\Error\SignatureVerification $e) {
|
||||||
// Invalid signature
|
// Invalid signature
|
||||||
http_response_code(400); // PHP 5.4 or greater
|
http_response_code(400); // PHP 5.4 or greater
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do something with $event
|
// Do something with $event
|
||||||
@ -73,61 +88,63 @@ $user->fetch(5);
|
|||||||
$user->getrights();
|
$user->getrights();
|
||||||
|
|
||||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->stripeconnect->enabled)) {
|
if (! empty($conf->multicompany->enabled) && ! empty($conf->stripeconnect->enabled)) {
|
||||||
$sql = "SELECT entity";
|
$sql = "SELECT entity";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."oauth_token";
|
$sql.= " FROM ".MAIN_DB_PREFIX."oauth_token";
|
||||||
$sql.= " WHERE service = '$service' and tokenstring = '%".$event->account."%'";
|
$sql.= " WHERE service = '$service' and tokenstring = '%".$event->account."%'";
|
||||||
|
|
||||||
dol_syslog(get_class($db) . "::fetch", LOG_DEBUG);
|
dol_syslog(get_class($db) . "::fetch", LOG_DEBUG);
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
|
{
|
||||||
|
if ($db->num_rows($result))
|
||||||
{
|
{
|
||||||
if ($db->num_rows($result))
|
$obj = $db->fetch_object($result);
|
||||||
{
|
$key=$obj->entity;
|
||||||
$obj = $db->fetch_object($result);
|
}
|
||||||
$key=$obj->entity;
|
else {$key=1;
|
||||||
}
|
}
|
||||||
else {$key=1;}
|
}
|
||||||
}
|
else {$key=1;
|
||||||
else {$key=1;}
|
}
|
||||||
$ret=$mc->switchEntity($key);
|
$ret=$mc->switchEntity($key);
|
||||||
if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php");
|
if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php");
|
||||||
if (! $res) die("Include of main fails");
|
if (! $res) die("Include of main fails");
|
||||||
}
|
}
|
||||||
|
|
||||||
// list of action
|
// list of action
|
||||||
$stripe=new Stripe($db);
|
$stripe=new Stripe($db);
|
||||||
if ($event->type == 'payout.created') {
|
if ($event->type == 'payout.created') {
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
$result=dolibarr_set_const($db, $service."_NEXTPAYOUT",date('Y-m-d H:i:s',$event->data->object->arrival_date),'chaine',0,'',$conf->entity);
|
$result=dolibarr_set_const($db, $service."_NEXTPAYOUT",date('Y-m-d H:i:s',$event->data->object->arrival_date),'chaine',0,'',$conf->entity);
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
$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);
|
$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';
|
$subject = '[NOTIFICATION] Virement programmée';
|
||||||
$headers = 'From: "'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'" <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; TODO convert in dolibarr standard
|
$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);
|
mail(''.$conf->global->MAIN_INFO_SOCIETE_MAIL.'', $subject, $body, $headers);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($event->type == 'payout.paid') {
|
elseif ($event->type == 'payout.paid') {
|
||||||
global $conf;
|
global $conf;
|
||||||
$error=0;
|
$error=0;
|
||||||
$result=dolibarr_set_const($db, $service."_NEXTPAYOUT",null,'chaine',0,'',$conf->entity);
|
$result=dolibarr_set_const($db, $service."_NEXTPAYOUT",null,'chaine',0,'',$conf->entity);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
|
|
||||||
$dateo = dol_now();
|
$dateo = dol_now();
|
||||||
$label = $event->data->object->description;
|
$label = $event->data->object->description;
|
||||||
$amount= $event->data->object->amount/100;
|
$amount= $event->data->object->amount/100;
|
||||||
$amount_to= $event->data->object->amount/100;
|
$amount_to= $event->data->object->amount/100;
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||||
|
|
||||||
$accountfrom=new Account($db);
|
$accountfrom=new Account($db);
|
||||||
$accountfrom->fetch($conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS);
|
$accountfrom->fetch($conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS);
|
||||||
@ -157,157 +174,155 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
|||||||
if ((! $error) && ($accountto->currency_code != $accountfrom->currency_code)) $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, price2num($amount_to), '', '', $user);
|
if ((! $error) && ($accountto->currency_code != $accountfrom->currency_code)) $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, price2num($amount_to), '', '', $user);
|
||||||
if (! ($bank_line_id_to > 0)) $error++;
|
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 (! $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++;
|
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 (! $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++;
|
if (! ($result > 0)) $error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$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);
|
$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é';
|
$subject = '[NOTIFICATION] Virement effectué';
|
||||||
$headers = 'From: "'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'" <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; TODO convert in dolibarr standard
|
$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);
|
mail(''.$conf->global->MAIN_INFO_SOCIETE_MAIL.'', $subject, $body, $headers);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($event->type == 'charge.succeeded') {
|
elseif ($event->type == 'charge.succeeded') {
|
||||||
|
|
||||||
//TODO: create fees
|
//TODO: create fees
|
||||||
|
|
||||||
}
|
}
|
||||||
elseif ($event->type == 'customer.source.created') {
|
elseif ($event->type == 'customer.source.created') {
|
||||||
|
|
||||||
//TODO: save customer's source
|
//TODO: save customer's source
|
||||||
|
|
||||||
}
|
}
|
||||||
elseif ($event->type == 'customer.source.updated') {
|
elseif ($event->type == 'customer.source.updated') {
|
||||||
|
|
||||||
//TODO: update customer's source
|
//TODO: update customer's source
|
||||||
|
|
||||||
}
|
}
|
||||||
elseif ($event->type == 'customer.source.delete') {
|
elseif ($event->type == 'customer.source.delete') {
|
||||||
|
|
||||||
//TODO: delete customer's source
|
//TODO: delete customer's source
|
||||||
|
|
||||||
}
|
}
|
||||||
elseif ($event->type == 'charge.failed') {
|
elseif ($event->type == 'charge.failed') {
|
||||||
|
|
||||||
$subject = 'Your payment has been received: '.$event->data->object->id.'';
|
$subject = 'Your payment has been received: '.$event->data->object->id.'';
|
||||||
$headers = 'From: "'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'" <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>';
|
$headers = 'From: "'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'" <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>';
|
||||||
//mail('ptibogxiv@msn.com', $subject, 'test', $headers);
|
//mail('ptibogxiv@msn.com', $subject, 'test', $headers);
|
||||||
|
|
||||||
}
|
}
|
||||||
elseif (($event->type == 'source.chargeable') && ($event->data->object->type == 'three_d_secure') && ($event->data->object->three_d_secure->authenticated==true)) {
|
elseif (($event->type == 'source.chargeable') && ($event->data->object->type == 'three_d_secure') && ($event->data->object->three_d_secure->authenticated==true)) {
|
||||||
|
|
||||||
$stripe=new Stripe($db);
|
$stripe=new Stripe($db);
|
||||||
$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));
|
$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'){
|
if (isset($charge->id) && $charge->statut=='error'){
|
||||||
$msg=$charge->message;
|
$msg=$charge->message;
|
||||||
$code=$charge->code;
|
$code=$charge->code;
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
elseif (isset($charge->id) && $charge->statut=='success' && $event->data->object->metadata->source=='order') {
|
elseif (isset($charge->id) && $charge->statut=='success' && $event->data->object->metadata->source=='order') {
|
||||||
$order=new Commande($db);
|
$order=new Commande($db);
|
||||||
$order->fetch($event->data->object->metadata->idsource);
|
$order->fetch($event->data->object->metadata->idsource);
|
||||||
$invoice = new Facture($db);
|
$invoice = new Facture($db);
|
||||||
$idinv=$invoice->createFromOrder($order);
|
$idinv=$invoice->createFromOrder($order);
|
||||||
|
|
||||||
if ($idinv > 0)
|
if ($idinv > 0)
|
||||||
{
|
{
|
||||||
$result=$invoice->validate($user);
|
$result=$invoice->validate($user);
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
$invoice->fetch($idinv);
|
$invoice->fetch($idinv);
|
||||||
$paiement = $invoice->getSommePaiement();
|
$paiement = $invoice->getSommePaiement();
|
||||||
$creditnotes=$invoice->getSumCreditNotesUsed();
|
$creditnotes=$invoice->getSumCreditNotesUsed();
|
||||||
$deposits=$invoice->getSumDepositsUsed();
|
$deposits=$invoice->getSumDepositsUsed();
|
||||||
$ref=$invoice->ref;
|
$ref=$invoice->ref;
|
||||||
$ifverif=$invoice->socid;
|
$ifverif=$invoice->socid;
|
||||||
$currency=$invoice->multicurrency_code;
|
$currency=$invoice->multicurrency_code;
|
||||||
$total=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT');
|
$total=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT');
|
||||||
}else{
|
}else{
|
||||||
$msg=$invoice->error;
|
$msg=$invoice->error;
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$msg=$invoice->error;
|
$msg=$invoice->error;
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error){
|
if (!$error){
|
||||||
$datepaye = dol_now();
|
$datepaye = dol_now();
|
||||||
$paiementcode ="CB";
|
$paiementcode ="CB";
|
||||||
$amounts=array();
|
$amounts=array();
|
||||||
$amounts[$invoice->id] = $total;
|
$amounts[$invoice->id] = $total;
|
||||||
$multicurrency_amounts=array();
|
$multicurrency_amounts=array();
|
||||||
//$multicurrency_amounts[$item] = $total;
|
//$multicurrency_amounts[$item] = $total;
|
||||||
$paiement = new Paiement($db);
|
$paiement = new Paiement($db);
|
||||||
$paiement->datepaye = $datepaye;
|
$paiement->datepaye = $datepaye;
|
||||||
$paiement->amounts = $amounts; // Array with all payments dispatching
|
$paiement->amounts = $amounts; // Array with all payments dispatching
|
||||||
$paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching
|
$paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching
|
||||||
$paiement->paiementid = dol_getIdFromCode($db,$paiementcode,'c_paiement');
|
$paiement->paiementid = dol_getIdFromCode($db,$paiementcode,'c_paiement');
|
||||||
$paiement->num_paiement = $charge->message;
|
$paiement->num_paiement = $charge->message;
|
||||||
$paiement->note = '';
|
$paiement->note = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error){
|
if (! $error){
|
||||||
$paiement_id=$paiement->create($user, 0);
|
$paiement_id=$paiement->create($user, 0);
|
||||||
|
|
||||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE) && count($invoice->lines)){
|
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE) && count($invoice->lines)){
|
||||||
$outputlangs = $langs;
|
$outputlangs = $langs;
|
||||||
$newlang = '';
|
$newlang = '';
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09');
|
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 ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $invoice->thirdparty->default_lang;
|
||||||
if (! empty($newlang)) {
|
if (! empty($newlang)) {
|
||||||
$outputlangs = new Translate("", $conf);
|
$outputlangs = new Translate("", $conf);
|
||||||
$outputlangs->setDefaultLang($newlang);
|
$outputlangs->setDefaultLang($newlang);
|
||||||
}
|
}
|
||||||
$model=$invoice->modelpdf;
|
$model=$invoice->modelpdf;
|
||||||
$ret = $invoice->fetch($invoice->id); // Reload to get new records
|
$ret = $invoice->fetch($invoice->id); // Reload to get new records
|
||||||
|
|
||||||
$invoice->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);}
|
$invoice->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||||
if ($paiement_id < 0){
|
}
|
||||||
$msg=$paiement->errors;
|
if ($paiement_id < 0){
|
||||||
$error++;
|
$msg=$paiement->errors;
|
||||||
}else{
|
$error++;
|
||||||
if ($event->data->object->metadata->source=='order') {
|
}else{
|
||||||
$order->classifyBilled($user);
|
if ($event->data->object->metadata->source=='order') {
|
||||||
}
|
$order->classifyBilled($user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (! $error){
|
if (! $error){
|
||||||
$label='(CustomerInvoicePayment)';
|
$label='(CustomerInvoicePayment)';
|
||||||
if (GETPOST('type') == 2) $label='(CustomerInvoicePaymentBack)';
|
if (GETPOST('type') == 2) $label='(CustomerInvoicePaymentBack)';
|
||||||
$paiement->addPaymentToBank($user,'payment',$label,$conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS,'','');
|
$paiement->addPaymentToBank($user,'payment',$label,$conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS,'','');
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$msg=$paiement->errors;
|
$msg=$paiement->errors;
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
$invoice->set_paid($user);
|
$invoice->set_paid($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
$body = "";
|
$body = "";
|
||||||
$subject = 'Facture '.$invoice->ref;
|
$subject = 'Facture '.$invoice->ref;
|
||||||
$headers = 'From: "'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'" <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>';
|
$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
|
//mail('ptibogxiv@msn.com', $subject, $body, $headers); TODO convert in dolibarr standard
|
||||||
}
|
}
|
||||||
elseif ($event->type == 'customer.deleted') {
|
elseif ($event->type == 'customer.deleted') {
|
||||||
$db->begin();
|
$db->begin();
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_stripe WHERE fk_key = '".$event->data->object->id."' ";
|
$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);
|
dol_syslog(get_class($this) . "::delete sql=" . $sql, LOG_DEBUG);
|
||||||
$db->query($sql);
|
$db->query($sql);
|
||||||
$db->commit();
|
$db->commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user