diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index 4e0c683a73f..519f2b42938 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -306,7 +306,7 @@ if (! empty($conf->product->enabled)) print ''; print ''.$langs->trans("SetDefaultBarcodeTypeProducts").''; print ''; - $formbarcode->select_barcode_type($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE,"PRODUIT_DEFAULT_BARCODE_TYPE",1); + print $formbarcode->selectBarcodeType($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE, "PRODUIT_DEFAULT_BARCODE_TYPE", 1); print ''; } @@ -317,7 +317,7 @@ if (! empty($conf->societe->enabled)) print ''; print ''.$langs->trans("SetDefaultBarcodeTypeThirdParties").''; print ''; - print $formbarcode->select_barcode_type($conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY,"GENBARCODE_BARCODETYPE_THIRDPARTY",1); + print $formbarcode->selectBarcodeType($conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY, "GENBARCODE_BARCODETYPE_THIRDPARTY", 1); print ''; } diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php index 6dd578993ca..a1f3632fd2f 100644 --- a/htdocs/barcode/printsheet.php +++ b/htdocs/barcode/printsheet.php @@ -178,19 +178,19 @@ if ($action == 'builddoc') { // List of values to scan for a replacement $substitutionarray = array ( - '%LOGIN%'=>$user->login, - '%COMPANY%'=>$mysoc->name, - '%ADDRESS%'=>$mysoc->address, - '%ZIP%'=>$mysoc->zip, - '%TOWN%'=>$mysoc->town, - '%COUNTRY%'=>$mysoc->country, - '%COUNTRY_CODE%'=>$mysoc->country_code, - '%EMAIL%'=>$mysoc->email, - '%YEAR%'=>$year, - '%MONTH%'=>$month, - '%DAY%'=>$day, - '%DOL_MAIN_URL_ROOT%'=>DOL_MAIN_URL_ROOT, - '%SERVER%'=>"http://".$_SERVER["SERVER_NAME"]."/" + '%LOGIN%' => $user->login, + '%COMPANY%' => $mysoc->name, + '%ADDRESS%' => $mysoc->address, + '%ZIP%' => $mysoc->zip, + '%TOWN%' => $mysoc->town, + '%COUNTRY%' => $mysoc->country, + '%COUNTRY_CODE%' => $mysoc->country_code, + '%EMAIL%' => $mysoc->email, + '%YEAR%' => $year, + '%MONTH%' => $month, + '%DAY%' => $day, + '%DOL_MAIN_URL_ROOT%' => DOL_MAIN_URL_ROOT, + '%SERVER%' => "http://".$_SERVER["SERVER_NAME"]."/", ); complete_substitutions_array($substitutionarray, $langs); @@ -416,7 +416,7 @@ print $langs->trans("BarcodeType").'   '; print '
'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; $formbarcode = new FormBarCode($db); -$formbarcode->select_barcode_type($fk_barcode_type, 'fk_barcode_type', 1); +print $formbarcode->selectBarcodeType($fk_barcode_type, 'fk_barcode_type', 1); print '
'; // Barcode value diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index abc616795d2..3bd5997506e 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -346,7 +346,7 @@ class Account extends CommonObject * @param int $fk_bank To search using bank transaction id * @param int $url_id To search using link to * @param string $type To search using type - * @return array|-1 Array of links array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> ) or -1 on error + * @return array|int Array of links array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> ) or -1 on error */ function get_url($fk_bank='', $url_id='', $type='') { diff --git a/htdocs/core/class/html.formbarcode.class.php b/htdocs/core/class/html.formbarcode.class.php index bcc6e2646fc..c2c408801c4 100644 --- a/htdocs/core/class/html.formbarcode.class.php +++ b/htdocs/core/class/html.formbarcode.class.php @@ -1,21 +1,22 @@ - * Copyright (C) 2008-2012 Laurent Destailleur -* -* 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 . -* -*/ +/* Copyright (C) 2007-2012 Regis Houssin + * Copyright (C) 2008-2012 Laurent Destailleur + * Copyright (C) 2018 Frédéric France + * + * 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 . + * + */ /** * \file htdocs/core/class/html.formbarcode.class.php @@ -105,17 +106,33 @@ class FormBarCode // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** - * Return form to select type of barcode + * Print form to select type of barcode * - * @param int $selected Id code pre-selected - * @param string $htmlname Name of HTML select field - * @param int $useempty Affiche valeur vide dans liste - * @return void + * @param int $selected Id code pre-selected + * @param string $htmlname Name of HTML select field + * @param int $useempty Affiche valeur vide dans liste + * @return void + * @deprecated */ - function select_barcode_type($selected='',$htmlname='barcodetype_id',$useempty=0) + function select_barcode_type($selected='', $htmlname='barcodetype_id', $useempty=0) { // phpcs:enable - global $langs,$conf; + print $this->selectBarcodeType($selected, $htmlname, $useempty); + } + + /** + * Return html form to select type of barcode + * + * @param int $selected Id code pre-selected + * @param string $htmlname Name of HTML select field + * @param int $useempty Display empty value in select + * @return string + */ + function selectBarcodeType($selected='', $htmlname='barcodetype_id', $useempty=0) + { + global $langs, $conf; + + $out = ''; $sql = "SELECT rowid, code, libelle"; $sql.= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; @@ -124,44 +141,37 @@ class FormBarCode $sql.= " ORDER BY code"; $result = $this->db->query($sql); - if ($result) - { + if ($result) { $num = $this->db->num_rows($result); $i = 0; - if ($useempty && $num > 0) - { - print ''; + $out .= ''; + } else { $langs->load("errors"); - print ''; + $out .= ''; } - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($result); - if ($selected == $obj->rowid) - { - print ''; + $out .= $obj->libelle; + $out .= ''; $i++; } - print ""; - print ajax_combobox("select_".$htmlname); + $out .= ""; + $out .= ajax_combobox("select_".$htmlname); } else { dol_print_error($this->db); } + return $out; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps @@ -172,22 +182,37 @@ class FormBarCode * @param int $selected Id condition preselected * @param string $htmlname Nom du formulaire select * @return void + * @deprecated */ function form_barcode_type($page, $selected='', $htmlname='barcodetype_id') { // phpcs:enable - global $langs,$conf; - if ($htmlname != "none") - { - print '
'; - print ''; - print ''; - print ''; - print ''; - print '
'; - $this->select_barcode_type($selected, $htmlname, 1); - print ''; - print '
'; + print $this->formBarcodeType($page, $selected, $htmlname); + } + + /** + * Return html form to select type of barcode + * + * @param string $page Page + * @param int $selected Id condition preselected + * @param string $htmlname Nom du formulaire select + * @return string + */ + function formBarcodeType($page, $selected='', $htmlname='barcodetype_id') + { + global $langs, $conf; + $out = ''; + if ($htmlname != "none") { + $out .= '
'; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= '
'; + $out .= $this->selectBarcodeType($selected, $htmlname, 1); + $out .= ''; + $out .= '
'; } + return $out; } } diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index 15a6b361079..684472d82c4 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -90,7 +90,7 @@ class modAgenda extends DolibarrModules $resql = $this->db->query($sqlreadactions); if ($resql) { - while ($obj = $this->db->fetch_object($sqlreadactions)) + while ($obj = $this->db->fetch_object($resql)) { //if (preg_match('/_CREATE$/',$obj->code) && (! in_array($obj->code, array('COMPANY_CREATE','PRODUCT_CREATE','TASK_CREATE')))) continue; // We don't track such events (*_CREATE) by default, we prefer validation (except thirdparty/product/task creation because there is no validation). if (preg_match('/^TASK_/',$obj->code)) continue; // We don't track such events by default. diff --git a/htdocs/langs/en_US/stripe.lang b/htdocs/langs/en_US/stripe.lang index ecd176a0ae7..ed3d24f4370 100644 --- a/htdocs/langs/en_US/stripe.lang +++ b/htdocs/langs/en_US/stripe.lang @@ -22,7 +22,7 @@ ToOfferALinkForOnlinePaymentOnContractLine=URL to offer a %s online payment user ToOfferALinkForOnlinePaymentOnFreeAmount=URL to offer a %s online payment user interface for a free amount ToOfferALinkForOnlinePaymentOnMemberSubscription=URL to offer a %s online payment user interface for a member subscription YouCanAddTagOnUrl=You can also add url parameter &tag=value to any of those URL (required only for free payment) to add your own payment comment tag. -SetupStripeToHavePaymentCreatedAutomatically=Setup your Stripe with url %s to have payment created automatically when validated by Stripe. +SetupStripeToHavePaymentCreatedAutomatically=Setup your Stripe with url %s to have payment created automatically when validated by Stripe. AccountParameter=Account parameters UsageParameter=Usage parameters InformationToFindParameters=Help to find your %s account information @@ -60,4 +60,5 @@ DeleteACard=Delete Card ConfirmDeleteCard=Are you sure you want to delete this Credit or Debit card? CreateCustomerOnStripe=Create customer on Stripe CreateCardOnStripe=Create card on Stripe -ShowInStripe=Show in Stripe \ No newline at end of file +ShowInStripe=Show in Stripe +StripeUserAccountForActions=User account to use for some emails notification of Stripe events (Stripe payouts) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 52815c1303d..d51a4fa494c 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -977,7 +977,7 @@ else } require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; $formbarcode = new FormBarCode($db); - print $formbarcode->select_barcode_type($fk_barcode_type, 'fk_barcode_type', 1); + print $formbarcode->selectBarcodeType($fk_barcode_type, 'fk_barcode_type', 1); print ''.$langs->trans("BarcodeValue").''; $tmpcode=isset($_POST['barcode'])?GETPOST('barcode'):$object->barcode; if (empty($tmpcode) && ! empty($modBarCodeProduct->code_auto)) $tmpcode=$modBarCodeProduct->getNextValue($object,$type); @@ -1343,7 +1343,7 @@ else } require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; $formbarcode = new FormBarCode($db); - print $formbarcode->select_barcode_type($fk_barcode_type, 'fk_barcode_type', 1); + print $formbarcode->selectBarcodeType($fk_barcode_type, 'fk_barcode_type', 1); print ''.$langs->trans("BarcodeValue").''; $tmpcode=isset($_POST['barcode'])?GETPOST('barcode'):$object->barcode; if (empty($tmpcode) && ! empty($modBarCodeProduct->code_auto)) $tmpcode=$modBarCodeProduct->getNextValue($object,$type); @@ -1639,7 +1639,7 @@ else } if ($action == 'editbarcodetype') { - $formbarcode->form_barcode_type($_SERVER['PHP_SELF'].'?id='.$object->id,$object->barcode_type,'fk_barcode_type'); + print $formbarcode->formBarcodeType($_SERVER['PHP_SELF'].'?id='.$object->id, $object->barcode_type, 'fk_barcode_type'); } else { diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php index faca27f78c7..ffd1bf4f559 100644 --- a/htdocs/public/stripe/ipn.php +++ b/htdocs/public/stripe/ipn.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2018 Thibault FOUCART + * Copyright (C) 2018 Frédéric France * * 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 @@ -34,6 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; +require_once DOL_DOCUMENT_ROOT .'/core/class/CMailFile.class.php'; // You can find your endpoint's secret in your webhook settings if (isset($_GET['connect'])){ @@ -86,9 +88,12 @@ catch(\UnexpectedValueException $e) { // Do something with $event http_response_code(200); // PHP 5.4 or greater + $langs->load("main"); + +// TODO Do we really need a user in setup just to have an name to fill an email topic when it is a technical system notification email $user = new User($db); -$user->fetch(5); +$user->fetch($conf->global->STRIPE_USER_ACCOUNT_FOR_ACTIONS); $user->getrights(); if (! empty($conf->multicompany->enabled) && ! empty($conf->stripeconnect->enabled) && is_object($mc)) { @@ -126,12 +131,37 @@ if ($event->type == 'payout.created') { if ($result > 0) { - // TODO Use CMail and translation - $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'; - $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); - return 1; + $subject = '[NOTIFICATION] Payment out scheduled'; + if (!empty($user->email)) { + $sendto = dolGetFirstLastname($user->firstname, $user->lastname) . " <".$user->email.">"; + } else { + $sendto = $conf->global->MAIN_INFO_SOCIETE_MAIL.'" <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; + } + $replyto = $sendto; + $sendtocc = ''; + if (!empty($conf->global->ONLINE_PAYMENT_SENDEMAIL)) { + $sendtocc = $conf->global->ONLINE_PAYMENT_SENDEMAIL.'" <'.$conf->global->ONLINE_PAYMENT_SENDEMAIL.'>'; + } + + $message = "A bank transfer of ".price2num($event->data->object->amount/100)." ".$event->data->object->currency." should arrive in your account the ".dol_print_date($event->data->object->arrival_date, 'dayhour'); + + $mailfile = new CMailFile( + $subject, + $sendto, + $replyto, + $message, + array(), + array(), + array(), + $sendtocc, + '', + 0, + -1 + ); + + $ret = $mailfile->sendfile(); + + return 1; } else { diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 19d12a33005..6a4dd8713f7 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -3,6 +3,7 @@ * Copyright (C) 2017 Olivier Geffroy * Copyright (C) 2017 Saasprov * Copyright (C) 2018 ptibogxiv + * Copyright (C) 2018 Frédéric France * * 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 @@ -70,10 +71,14 @@ if ($action == 'setvalue' && $user->admin) $result = dolibarr_set_const($db, "STRIPE_BANK_ACCOUNT_FOR_PAYMENTS", GETPOST('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS', 'int'), 'chaine', 0, '', $conf->entity); if (! $result > 0) $error ++; - $result = dolibarr_set_const($db, "STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS", GETPOST('STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS', 'int'), 'chaine', 0, '', $conf->entity); + $result = dolibarr_set_const($db, "STRIPE_USER_ACCOUNT_FOR_ACTIONS", GETPOST('STRIPE_USER_ACCOUNT_FOR_ACTIONS', 'int'), 'chaine', 0, '', $conf->entity); + if (! $result > 0) { + $error ++; + } + $result = dolibarr_set_const($db, "STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS", GETPOST('STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS', 'int'), 'chaine', 0, '', $conf->entity); if (! $result > 0) $error ++; - $result = dolibarr_set_const($db, "STRIPE_MINIMAL_3DSECURE", GETPOST('STRIPE_MINIMAL_3DSECURE', 'int'), 'chaine', 0, '', $conf->entity); + $result = dolibarr_set_const($db, "STRIPE_MINIMAL_3DSECURE", GETPOST('STRIPE_MINIMAL_3DSECURE', 'int'), 'chaine', 0, '', $conf->entity); if (! $result > 0) $error ++; $result = dolibarr_set_const($db, "ONLINE_PAYMENT_CSS_URL", GETPOST('ONLINE_PAYMENT_CSS_URL', 'alpha'), 'chaine', 0, '', $conf->entity); @@ -116,10 +121,8 @@ if ($action == 'setvalue' && $user->admin) if ($action=="setlive") { $liveenable = GETPOST('value','int'); - $res = dolibarr_set_const($db, "STRIPE_LIVE", $liveenable,'yesno',0,'',$conf->entity); - if (! $res > 0) $error++; - if (! $error) - { + $res = dolibarr_set_const($db, "STRIPE_LIVE", $liveenable, 'yesno', 0, '', $conf->entity); + if ($res > 0) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else @@ -251,6 +254,11 @@ print 'name; print ''; +print ''; +print $langs->trans("StripeUserAccountForActions").''; +print $form->select_dolusers($conf->global->STRIPE_USER_ACCOUNT_FOR_ACTIONS, 'STRIPE_USER_ACCOUNT_FOR_ACTIONS', 0); +print ''; + print ''; print $langs->trans("BankAccount").''; print $form->select_comptes($conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS, 'STRIPE_BANK_ACCOUNT_FOR_PAYMENTS', 0, '', 1); @@ -357,4 +365,3 @@ if (! empty($conf->use_javascript_ajax)) // End of page llxFooter(); $db->close(); - diff --git a/htdocs/stripe/charge.php b/htdocs/stripe/charge.php index 2f3d184fdb9..b5f0238e9a2 100644 --- a/htdocs/stripe/charge.php +++ b/htdocs/stripe/charge.php @@ -125,15 +125,19 @@ if (!$rowid) // Save into $tmparray all metadata $tmparray = dolExplodeIntoArray($FULLTAG,'.','='); // Load origin object according to metadata - if (! empty($tmparray['CUS'])) + if (! empty($tmparray['CUS']) && $tmparray['CUS'] > 0) { $societestatic->fetch($tmparray['CUS']); } + elseif (! empty($charge->metadata->dol_thirdparty_id) && $charge->metadata->dol_thirdparty_id > 0) + { + $societestatic->fetch($charge->metadata->dol_thirdparty_id); + } else { $societestatic->id = 0; } - if (! empty($tmparray['MEM'])) + if (! empty($tmparray['MEM']) && $tmparray['MEM'] > 0) { $memberstatic->fetch($tmparray['MEM']); } @@ -142,9 +146,14 @@ if (!$rowid) $memberstatic->id = 0; } - print ''; - // Ref - print "".$charge->id."\n"; + print ''; + // Ref + $url='https://dashboard.stripe.com/test/payments/'.$charge->id; + if ($servicestatus) + { + $url='https://dashboard.stripe.com/payments/'.$charge->id; + } + print "".img_picto($langs->trans('ShowInStripe'), 'object_globe')." ".$charge->id."\n"; // Stripe customer print "".$charge->customer."\n"; // Link @@ -153,23 +162,26 @@ if (!$rowid) { print $societestatic->getNomUrl(1); } - if ($memberstatic->id > 0) + elseif ($memberstatic->id > 0) { print $memberstatic->getNomUrl(1); } print "\n"; // Origine print ""; - print $FULLTAG; - if ($charge->metadata->source=="order"){ + if ($charge->metadata->dol_type=="order"){ $object = new Commande($db); - $object->fetch($charge->metadata->idsource); - print "".img_picto('', 'object_order')." ".$object->ref.""; - } elseif ($charge->metadata->source=="invoice"){ + $object->fetch($charge->metadata->dol_id); + if ($object->id > 0) { + print "".img_picto('', 'object_order')." ".$object->ref.""; + } else print $FULLTAG; + } elseif ($charge->metadata->dol_type=="invoice"){ $object = new Facture($db); - $object->fetch($charge->metadata->idsource); - print "".img_picto('', 'object_invoice')." ".$object->ref.""; - } + $object->fetch($charge->metadata->dol_id); + if ($object->id > 0) { + print "".img_picto('', 'object_invoice')." ".$object->ref.""; + } else print $FULLTAG; + } else print $FULLTAG; print "\n"; // Date payment print ''.dol_print_date($charge->created,'%d/%m/%Y %H:%M')."\n"; @@ -190,14 +202,16 @@ if (!$rowid) // Status print ''; if ($charge->refunded=='1'){ - print $langs->trans("refunded"); + print img_picto($langs->trans("refunded"),'statut6'); } elseif ($charge->paid=='1'){ - print $langs->trans("".$charge->status.""); + + print img_picto($langs->trans("".$charge->status.""),'statut4'); + } else { $label="Message: ".$charge->failure_message."
"; $label.="Réseau: ".$charge->outcome->network_status."
"; $label.="Statut: ".$langs->trans("".$charge->outcome->seller_message.""); - print $form->textwithpicto($langs->trans("".$charge->status.""),$label,1); + print $form->textwithpicto(img_picto($langs->trans("".$charge->status.""),'statut8'),$label,1); } print "\n"; diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 895ade49d09..901997cef3b 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -335,18 +335,19 @@ class Stripe extends CommonObject /** * Create charge with public/payment/newpayment.php, stripe/card.php, cronjobs or REST API * - * @param int $amount Amount to pay - * @param string $currency EUR, GPB... - * @param string $origin Object type to pay (order, invoice, contract...) - * @param int $item Object id to pay - * @param string $source src_xxxxx or card_xxxxx - * @param string $customer Stripe customer ref 'cus_xxxxxxxxxxxxx' via customerStripe() - * @param string $account Stripe account ref 'acc_xxxxxxxxxxxxx' via getStripeAccount() + * @param int $amount Amount to pay + * @param string $currency EUR, GPB... + * @param string $origin Object type to pay (order, invoice, contract...) + * @param int $item Object id to pay + * @param string $source src_xxxxx or card_xxxxx + * @param string $customer Stripe customer ref 'cus_xxxxxxxxxxxxx' via customerStripe() + * @param string $account Stripe account ref 'acc_xxxxxxxxxxxxx' via getStripeAccount() * @param int $status Status (0=test, 1=live) * @param int $usethirdpartyemailforreceiptemail Use thirdparty email as receipt email + * @param boolean $capture Set capture flag to true (take payment) or false (wait) * @return Stripe */ - public function createPaymentStripe($amount, $currency, $origin, $item, $source, $customer, $account, $status=0, $usethirdpartyemailforreceiptemail=0) + public function createPaymentStripe($amount, $currency, $origin, $item, $source, $customer, $account, $status=0, $usethirdpartyemailforreceiptemail=0, $capture=true) { global $conf; @@ -417,9 +418,9 @@ class Stripe extends CommonObject $charge = \Stripe\Charge::create(array( "amount" => "$stripeamount", "currency" => "$currency", - "capture" => true, "statement_descriptor" => dol_trunc(dol_trunc(dol_string_unaccent($mysoc->name), 8, 'right', 'UTF-8', 1).' '.$description, 22, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt - "description" => "Stripe payment: ".$description, + "description" => "Stripe payment: ".$description, + "capture" => $capture, "metadata" => $metadata, "source" => "$source" )); @@ -427,9 +428,9 @@ class Stripe extends CommonObject $paymentarray = array( "amount" => "$stripeamount", "currency" => "$currency", - "capture" => true, - "statement_descriptor" => dol_trunc(dol_trunc(dol_string_unaccent($mysoc->name), 8, 'right', 'UTF-8', 1).' '.$description, 22, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt - "description" => "Stripe payment: ".$description, + "statement_descriptor" => dol_trunc(dol_trunc(dol_string_unaccent($mysoc->name), 8, 'right', 'UTF-8', 1).' '.$description, 22, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt + "description" => "Stripe payment: ".$description, + "capture" => $capture, "metadata" => $metadata, "source" => "$source", "customer" => "$customer" @@ -452,9 +453,9 @@ class Stripe extends CommonObject $paymentarray = array( "amount" => "$stripeamount", "currency" => "$currency", - "capture" => true, "statement_descriptor" => dol_trunc(dol_trunc(dol_string_unaccent($mysoc->name), 8, 'right', 'UTF-8', 1).' '.$description, 22, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt - "description" => "Stripe payment: ".$description, + "description" => "Stripe payment: ".$description, + "capture" => $capture, "metadata" => $metadata, "source" => "$source", "customer" => "$customer"