39if (!defined(
'NOLOGIN')) {
42if (!defined(
'NOCSRFCHECK')) {
43 define(
"NOCSRFCHECK", 1);
45if (!defined(
'NOIPCHECK')) {
46 define(
'NOIPCHECK',
'1');
48if (!defined(
'NOBROWSERNOTIF')) {
49 define(
'NOBROWSERNOTIF',
'1');
54$entity = (!empty($_GET[
'entity']) ? (int) $_GET[
'entity'] : (!empty($_POST[
'entity']) ? (int) $_POST[
'entity'] : (!empty($_GET[
'e']) ? (int) $_GET[
'e'] : (!empty($_POST[
'e']) ? (int) $_POST[
'e'] : 1))));
55if (is_numeric($entity)) {
56 define(
"DOLENTITY", $entity);
60require
'../../main.inc.php';
61require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
62require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
63require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
64require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
65require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
66require_once DOL_DOCUMENT_ROOT.
'/societe/class/societeaccount.class.php';
67require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
68require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
72$hookmanager->initHooks(array(
'newpayment'));
75$langs->loadLangs(array(
"main",
"other",
"dict",
"bills",
"companies",
"errors",
"paybox",
"paypal",
"stripe"));
80$action =
GETPOST(
'action',
'aZ09');
89$suffix =
GETPOST(
"suffix",
'aZ09');
91if (!
GETPOST(
"currency",
'alpha')) {
92 $currency = $conf->currency;
94 $currency =
GETPOST(
"currency",
'aZ09');
97$getpostlang =
GETPOST(
'lang',
'aZ09');
100 if (!
GETPOST(
"amount",
'alpha') && !$source) {
101 print $langs->trans(
'ErrorBadParameters').
" - amount or source";
104 if (is_numeric($amount) && !
GETPOST(
"tag",
'alpha') && !$source) {
105 print $langs->trans(
'ErrorBadParameters').
" - tag or source";
108 if ($source && !
GETPOST(
"ref",
'alpha')) {
109 print $langs->trans(
'ErrorBadParameters').
" - ref";
114if ($source ==
'organizedeventregistration') {
118 $invoiceid =
GETPOST(
'ref',
'int');
121 $resultinvoice = $invoice->fetch($invoiceid);
123 if ($resultinvoice <= 0) {
136 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"eventorganization_conferenceorboothattendee";
137 $sql .=
" WHERE fk_invoice = ".((int) $invoiceid);
138 $resql = $db->query($sql);
140 $obj = $db->fetch_object($resql);
142 $attendeeid = $obj->rowid;
146 if ($attendeeid > 0) {
147 $resultattendee = $attendee->fetch($attendeeid);
149 if ($resultattendee <= 0) {
152 $attendee->fetch_projet();
154 $amount =
price2num($invoice->total_ttc);
156 $thirdparty =
new Societe($db);
157 $resultthirdparty = $thirdparty->fetch($invoice->socid);
158 if ($resultthirdparty <= 0) {
161 $object = $thirdparty;
165} elseif ($source ==
'boothlocation') {
169 $resultinvoice = $invoice->fetch($invoiceid);
170 if ($resultinvoice <= 0) {
173 $amount =
price2num($invoice->total_ttc);
175 $thirdparty =
new Societe($db);
176 $resultthirdparty = $thirdparty->fetch($invoice->socid);
177 if ($resultthirdparty <= 0) {
180 $object = $thirdparty;
185$paymentmethod =
GETPOST(
'paymentmethod',
'alphanohtml') ?
GETPOST(
'paymentmethod',
'alphanohtml') :
'';
186$validpaymentmethod = array();
189foreach ($_POST as $key => $val) {
191 if (preg_match(
'/^dopayment_(.*)$/', $key, $reg)) {
192 $paymentmethod = $reg[1];
201$urlwithroot = DOL_MAIN_URL_ROOT;
203$urlok = $urlwithroot.
'/public/payment/paymentok.php?';
204$urlko = $urlwithroot.
'/public/payment/paymentko.php?';
207$ref = $REF =
GETPOST(
'ref',
'alpha');
209$FULLTAG =
GETPOST(
"fulltag",
'alpha');
210$SECUREKEY =
GETPOST(
"securekey");
212if ($paymentmethod && !preg_match(
'/'.preg_quote(
'PM='.$paymentmethod,
'/').
'/', $FULLTAG)) {
213 $FULLTAG .= ($FULLTAG ?
'.' :
'').
'PM='.$paymentmethod;
216if (!empty($suffix)) {
217 $urlok .=
'suffix='.urlencode($suffix).
'&';
218 $urlko .=
'suffix='.urlencode($suffix).
'&';
221 $urlok .=
's='.urlencode($source).
'&';
222 $urlko .=
's='.urlencode($source).
'&';
225 $urlok .=
'ref='.urlencode($REF).
'&';
226 $urlko .=
'ref='.urlencode($REF).
'&';
229 $urlok .=
'tag='.urlencode($TAG).
'&';
230 $urlko .=
'tag='.urlencode($TAG).
'&';
232if (!empty($FULLTAG)) {
233 $urlok .=
'fulltag='.urlencode($FULLTAG).
'&';
234 $urlko .=
'fulltag='.urlencode($FULLTAG).
'&';
236if (!empty($SECUREKEY)) {
237 $urlok .=
'securekey='.urlencode($SECUREKEY).
'&';
238 $urlko .=
'securekey='.urlencode($SECUREKEY).
'&';
240if (!empty($entity)) {
241 $urlok .=
'e='.urlencode($entity).
'&';
242 $urlko .=
'e='.urlencode($entity).
'&';
244if (!empty($getpostlang)) {
245 $urlok .=
'lang='.urlencode($getpostlang).
'&';
246 $urlko .=
'lang='.urlencode($getpostlang).
'&';
248$urlok = preg_replace(
'/&$/',
'', $urlok);
249$urlko = preg_replace(
'/&$/',
'', $urlko);
254if ((empty($paymentmethod) || $paymentmethod ==
'paypal') && isModEnabled(
'paypal')) {
255 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypal.lib.php';
256 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypalfunctions.lib.php';
261 $PAYPAL_API_OK = $urlok;
265 $PAYPAL_API_KO = $urlko;
267 if (empty($PAYPAL_API_USER)) {
268 print
'Paypal parameter PAYPAL_API_USER is not defined. Please <a href="'.DOL_URL_ROOT.
'/paypal/admin/paypal.php">complete the setup of module PayPal first</a>.';
271 if (empty($PAYPAL_API_PASSWORD)) {
272 print
'Paypal parameter PAYPAL_API_PASSWORD is not defined. Please <a href="'.DOL_URL_ROOT.
'/paypal/admin/paypal.php">complete the setup of module PayPal first</a>.';
275 if (empty($PAYPAL_API_SIGNATURE)) {
276 print
'Paypal parameter PAYPAL_API_SIGNATURE is not defined. Please <a href="'.DOL_URL_ROOT.
'/paypal/admin/paypal.php">complete the setup of module PayPal first</a>.';
280if ((empty($paymentmethod) || $paymentmethod ==
'paybox') && isModEnabled(
'paybox')) {
283if ((empty($paymentmethod) || $paymentmethod ==
'stripe') && isModEnabled(
'stripe')) {
284 require_once DOL_DOCUMENT_ROOT.
'/stripe/config.php';
289$validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod);
293if ($tmpsource ==
'membersubscription') {
294 $tmpsource =
'member';
300 if ($tmpsource && $REF) {
304 if ($tmpsource != $source) {
308 $tokenisok =
dol_verifyHash($conf->global->PAYMENT_SECURITY_TOKEN, $SECUREKEY,
'2');
311 $tokenisok = ($conf->global->PAYMENT_SECURITY_TOKEN == $SECUREKEY);
318 dol_syslog(
"Warning: PAYMENT_SECURITY_ACCEPT_ANY_TOKEN is on", LOG_WARNING);
323 print
'<div class="error">Bad value for key.</div>';
329if (!empty($paymentmethod) && empty($validpaymentmethod[$paymentmethod])) {
330 print
'Payment module for payment method '.$paymentmethod.
' is not active';
333if (empty($validpaymentmethod)) {
334 print
'No active payment module (Paypal, Stripe, Paybox, ...)';
339$creditor = $mysoc->name;
340$paramcreditor =
'ONLINE_PAYMENT_CREDITOR';
341$paramcreditorlong =
'ONLINE_PAYMENT_CREDITOR_'.$suffix;
342if (!empty($conf->global->$paramcreditorlong)) {
343 $creditor = $conf->global->$paramcreditorlong;
344} elseif (!empty($conf->global->$paramcreditor)) {
345 $creditor = $conf->global->$paramcreditor;
356if ($action ==
'dopayment') {
357 dol_syslog(
"--- newpayment.php Execute action = ".$action.
" paymentmethod=".$paymentmethod.
' amount='.$amount.
' newamount='.
GETPOST(
"newamount",
'alpha'), LOG_DEBUG, 0,
'_payment');
359 if ($paymentmethod ==
'paypal') {
361 $PAYPAL_PAYMENT_TYPE =
'Sale';
364 $origfulltag =
GETPOST(
"fulltag",
'alpha');
365 $shipToName =
GETPOST(
"shipToName",
'alpha');
366 $shipToStreet =
GETPOST(
"shipToStreet",
'alpha');
367 $shipToCity =
GETPOST(
"shipToCity",
'alpha');
368 $shipToState =
GETPOST(
"shipToState",
'alpha');
369 $shipToCountryCode =
GETPOST(
"shipToCountryCode",
'alpha');
370 $shipToZip =
GETPOST(
"shipToZip",
'alpha');
371 $shipToStreet2 =
GETPOST(
"shipToStreet2",
'alpha');
372 $phoneNum =
GETPOST(
"phoneNum",
'alpha');
373 $email =
GETPOST(
"email",
'alpha');
374 $desc =
GETPOST(
"desc",
'alpha');
375 $thirdparty_id =
GETPOST(
'thirdparty_id',
'int');
378 if ($shipToCountryCode ==
'ID' && !preg_match(
'/\-/', $shipToState)) {
379 $shipToState =
'ID-'.$shipToState;
382 if (empty($PAYPAL_API_PRICE) || !is_numeric($PAYPAL_API_PRICE)) {
383 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount"));
387 } elseif (!$origfulltag) {
388 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"PaymentCode"));
394 dol_syslog(
"newpayment.php call paypal api and do redirect", LOG_DEBUG);
397 $PAYPAL_API_DEVISE =
"USD";
398 if (!empty($currency)) {
399 $PAYPAL_API_DEVISE = $currency;
404 dol_syslog(
"PAYPAL_API_USER: $PAYPAL_API_USER", LOG_DEBUG);
405 dol_syslog(
"PAYPAL_API_PASSWORD: ".preg_replace(
'/./',
'*', $PAYPAL_API_PASSWORD), LOG_DEBUG);
406 dol_syslog(
"PAYPAL_API_SIGNATURE: $PAYPAL_API_SIGNATURE", LOG_DEBUG);
407 dol_syslog(
"PAYPAL_API_SANDBOX: $PAYPAL_API_SANDBOX", LOG_DEBUG);
408 dol_syslog(
"PAYPAL_API_OK: $PAYPAL_API_OK", LOG_DEBUG);
409 dol_syslog(
"PAYPAL_API_KO: $PAYPAL_API_KO", LOG_DEBUG);
410 dol_syslog(
"PAYPAL_API_PRICE: $PAYPAL_API_PRICE", LOG_DEBUG);
411 dol_syslog(
"PAYPAL_API_DEVISE: $PAYPAL_API_DEVISE", LOG_DEBUG);
413 dol_syslog(
"shipToName: $shipToName", LOG_DEBUG);
414 dol_syslog(
"shipToStreet: $shipToStreet", LOG_DEBUG);
415 dol_syslog(
"shipToCity: $shipToCity", LOG_DEBUG);
416 dol_syslog(
"shipToState: $shipToState", LOG_DEBUG);
417 dol_syslog(
"shipToCountryCode: $shipToCountryCode", LOG_DEBUG);
418 dol_syslog(
"shipToZip: $shipToZip", LOG_DEBUG);
419 dol_syslog(
"shipToStreet2: $shipToStreet2", LOG_DEBUG);
424 dol_syslog(
"SCRIPT_URI: ".(empty($_SERVER[
"SCRIPT_URI"]) ?
'' : $_SERVER[
"SCRIPT_URI"]), LOG_DEBUG);
427 $mesg =
print_paypal_redirect($PAYPAL_API_PRICE, $PAYPAL_API_DEVISE, $PAYPAL_PAYMENT_TYPE, $PAYPAL_API_OK, $PAYPAL_API_KO, $FULLTAG);
434 if ($paymentmethod ==
'paybox') {
436 $email = $conf->global->ONLINE_PAYMENT_SENDEMAIL;
437 $thirdparty_id =
GETPOST(
'thirdparty_id',
'int');
439 $origfulltag =
GETPOST(
"fulltag",
'alpha');
442 $urlok = preg_replace(
'/securekey=[^&]+&?/',
'', $urlok);
443 $urlko = preg_replace(
'/securekey=[^&]+&?/',
'', $urlko);
445 if (empty($PRICE) || !is_numeric($PRICE)) {
446 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount"));
447 } elseif (empty($email)) {
448 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ONLINE_PAYMENT_SENDEMAIL"));
449 } elseif (!isValidEMail($email)) {
450 $mesg = $langs->trans(
"ErrorBadEMail", $email);
451 } elseif (!$origfulltag) {
452 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"PaymentCode"));
454 $mesg =
'Error urlok too long '.$urlok.
' (Paybox requires 150, found '.strlen($urlok).
')';
456 $mesg =
'Error urlko too long '.$urlko.
' (Paybox requires 150, found '.strlen($urlok).
')';
460 dol_syslog(
"newpayment.php call paybox api and do redirect", LOG_DEBUG);
462 include_once DOL_DOCUMENT_ROOT.
'/paybox/lib/paybox.lib.php';
470 if ($paymentmethod ==
'stripe') {
471 if (
GETPOST(
'newamount',
'alpha')) {
474 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount")),
null,
'errors');
484if ($action ==
'charge' && isModEnabled(
'stripe')) {
485 $amountstripe = $amount;
489 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
490 if (!in_array($currency, $arrayzerounitcurrency)) {
491 $amountstripe = $amountstripe * 100;
494 dol_syslog(
"--- newpayment.php Execute action = ".$action.
" STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION=".
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION'), LOG_DEBUG, 0,
'_payment');
495 dol_syslog(
"GET=".var_export($_GET,
true), LOG_DEBUG, 0,
'_payment');
496 dol_syslog(
"POST=".var_export($_POST,
true), LOG_DEBUG, 0,
'_payment');
498 $stripeToken =
GETPOST(
"stripeToken",
'alpha');
499 $email =
GETPOST(
"email",
'alpha');
500 $thirdparty_id =
GETPOST(
'thirdparty_id',
'int');
502 $dol_id =
GETPOST(
'dol_id',
'int');
503 $vatnumber =
GETPOST(
'vatnumber',
'alpha');
504 $savesource = GETPOSTISSET(
'savesource') ?
GETPOST(
'savesource',
'int') : 1;
506 dol_syslog(
"POST stripeToken = ".$stripeToken, LOG_DEBUG, 0,
'_payment');
507 dol_syslog(
"POST email = ".$email, LOG_DEBUG, 0,
'_payment');
508 dol_syslog(
"POST thirdparty_id = ".$thirdparty_id, LOG_DEBUG, 0,
'_payment');
509 dol_syslog(
"POST vatnumber = ".$vatnumber, LOG_DEBUG, 0,
'_payment');
515 if (!
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION')) {
518 'dol_version' => DOL_VERSION,
519 'dol_entity' => $conf->entity,
520 'dol_company' => $mysoc->name,
521 'dol_tax_num' => $vatnumber,
525 if (!empty($thirdparty_id)) {
526 $metadata[
"dol_thirdparty_id"] = $thirdparty_id;
529 if ($thirdparty_id > 0) {
530 dol_syslog(
"Search existing Stripe customer profile for thirdparty_id=".$thirdparty_id, LOG_DEBUG, 0,
'_payment');
532 $service =
'StripeTest';
535 $service =
'StripeLive';
539 $thirdparty =
new Societe($db);
540 $thirdparty->fetch($thirdparty_id);
543 include_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
544 $stripe =
new Stripe($db);
545 $stripeacc = $stripe->getStripeAccount($service);
546 $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 1);
547 if (empty($customer)) {
549 dol_syslog(
'Failed to get/create stripe customer for thirdparty id = '.$thirdparty_id.
' and servicestatus = '.$servicestatus.
': '.$stripe->error, LOG_ERR, 0,
'_payment');
550 setEventMessages(
'Failed to get/create stripe customer for thirdparty id = '.$thirdparty_id.
' and servicestatus = '.$servicestatus.
': '.$stripe->error,
null,
'errors');
557 $card = $customer->sources->create(array(
"source" => $stripeToken,
"metadata" => $metadata));
559 $card = $stripeToken;
564 dol_syslog(
'Failed to create card record', LOG_WARNING, 0,
'_payment');
568 if (!empty($FULLTAG)) {
569 $metadata[
"FULLTAG"] = $FULLTAG;
571 if (!empty($dol_id)) {
572 $metadata[
"dol_id"] = $dol_id;
574 if (!empty($dol_type)) {
575 $metadata[
"dol_type"] = $dol_type;
578 dol_syslog(
"Create charge on card ".$card->id, LOG_DEBUG, 0,
'_payment');
579 $charge = \Stripe\Charge::create(array(
580 'amount' =>
price2num($amountstripe,
'MU'),
581 'currency' => $currency,
583 'description' =>
'Stripe payment: '.$FULLTAG.
' ref='.$ref,
584 'metadata' => $metadata,
585 'customer' => $customer->id,
587 'statement_descriptor_suffix' =>
dol_trunc($FULLTAG, 10,
'right',
'UTF-8', 1),
588 ), array(
"idempotency_key" =>
"$FULLTAG",
"stripe_account" =>
"$stripeacc"));
590 if (empty($charge)) {
592 dol_syslog(
'Failed to charge card', LOG_WARNING, 0,
'_payment');
599 $vatcleaned = $vatnumber ? $vatnumber :
null;
610 dol_syslog(
"Create anonymous customer card profile", LOG_DEBUG, 0,
'_payment');
612 $customer = \Stripe\Customer::create(array(
614 'description' => ($email ?
'Anonymous customer for '.$email :
'Anonymous customer'),
615 'metadata' => $metadata,
616 'source' => $stripeToken
635 if (!empty($FULLTAG)) {
636 $metadata[
"FULLTAG"] = $FULLTAG;
638 if (!empty($dol_id)) {
639 $metadata[
"dol_id"] = $dol_id;
641 if (!empty($dol_type)) {
642 $metadata[
"dol_type"] = $dol_type;
647 dol_syslog(
"Create charge", LOG_DEBUG, 0,
'_payment');
648 $charge = \Stripe\Charge::create(array(
649 'customer' => $customer->id,
650 'amount' =>
price2num($amountstripe,
'MU'),
651 'currency' => $currency,
653 'description' =>
'Stripe payment: '.$FULLTAG.
' ref='.$ref,
654 'metadata' => $metadata,
655 'statement_descriptor' =>
dol_trunc($FULLTAG, 10,
'right',
'UTF-8', 1),
656 ), array(
"idempotency_key" =>
"$FULLTAG",
"stripe_account" =>
"$stripeacc"));
658 if (empty($charge)) {
660 dol_syslog(
'Failed to charge card', LOG_WARNING, 0,
'_payment');
665 }
catch (\
Stripe\Error\Card $e) {
667 $body = $e->getJsonBody();
668 $err = $body[
'error'];
670 print(
'Status is:'.$e->getHttpStatus().
"\n");
671 print(
'Type is:'.$err[
'type'].
"\n");
672 print(
'Code is:'.$err[
'code'].
"\n");
674 print(
'Param is:'.$err[
'param'].
"\n");
675 print(
'Message is:'.$err[
'message'].
"\n");
678 $errormessage =
"ErrorCard ".$e->getMessage().
" err=".var_export($err,
true);
679 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
682 }
catch (\
Stripe\Error\RateLimit $e) {
685 $errormessage =
"ErrorRateLimit ".$e->getMessage();
686 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
689 }
catch (\
Stripe\Error\InvalidRequest $e) {
692 $errormessage =
"ErrorInvalidRequest ".$e->getMessage();
693 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
696 }
catch (\
Stripe\Error\Authentication $e) {
700 $errormessage =
"ErrorAuthentication ".$e->getMessage();
701 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
704 }
catch (\
Stripe\Error\ApiConnection $e) {
707 $errormessage =
"ErrorApiConnection ".$e->getMessage();
708 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
711 }
catch (\
Stripe\Error\Base $e) {
715 $errormessage =
"ErrorBase ".$e->getMessage();
716 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
722 $errormessage =
"ErrorException ".$e->getMessage();
723 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
730 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION')) {
731 $service =
'StripeTest';
734 $service =
'StripeLive';
737 include_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
738 $stripe =
new Stripe($db);
739 $stripeacc = $stripe->getStripeAccount($service);
743 $paymentintent_id =
GETPOST(
"paymentintent_id",
"alpha");
746 global $stripearrayofkeysbyenv;
747 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
750 if (empty($stripeacc)) {
751 $paymentintent = \Stripe\PaymentIntent::retrieve($paymentintent_id);
753 $paymentintent = \Stripe\PaymentIntent::retrieve($paymentintent_id, array(
"stripe_account" => $stripeacc));
757 $errormessage =
"CantRetrievePaymentIntent ".$e->getMessage();
758 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
763 if ($paymentintent->status !=
'succeeded') {
765 $errormessage =
"StatusOfRetrievedIntent is not succeeded: ".$paymentintent->status;
766 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
776 if (!empty($paymentintent->currency) && !empty($paymentintent->amount)) {
777 $currency = strtoupper($paymentintent->currency);
778 $amount = $paymentintent->amount;
782 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
783 if (!in_array($currency, $arrayzerounitcurrency)) {
784 $amount = $amount / 100;
793 $_SESSION[
"onlinetoken"] = $stripeToken;
794 $_SESSION[
"FinalPaymentAmt"] = $amount;
795 $_SESSION[
"currencyCodeType"] = $currency;
796 $_SESSION[
"paymentType"] =
'';
797 $_SESSION[
'ipaddress'] = ($remoteip ? $remoteip :
'unknown');
798 $_SESSION[
'payerID'] = is_object($customer) ? $customer->id :
'';
799 $_SESSION[
'TRANSACTIONID'] = (is_object($charge) ? $charge->id : (is_object($paymentintent) ? $paymentintent->id :
''));
800 $_SESSION[
'errormessage'] = $errormessage;
802 dol_syslog(
"Action charge stripe STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION=".
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION').
" ip=".$remoteip, LOG_DEBUG, 0,
'_payment');
803 dol_syslog(
"onlinetoken=".$_SESSION[
"onlinetoken"].
" FinalPaymentAmt=".$_SESSION[
"FinalPaymentAmt"].
" currencyCodeType=".$_SESSION[
"currencyCodeType"].
" payerID=".$_SESSION[
'payerID'].
" TRANSACTIONID=".$_SESSION[
'TRANSACTIONID'], LOG_DEBUG, 0,
'_payment');
804 dol_syslog(
"FULLTAG=".$FULLTAG, LOG_DEBUG, 0,
'_payment');
805 dol_syslog(
"error=".$error.
" errormessage=".$errormessage, LOG_DEBUG, 0,
'_payment');
806 dol_syslog(
"_SERVER[SERVER_NAME] = ".(empty($_SERVER[
"SERVER_NAME"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_NAME"])), LOG_DEBUG, 0,
'_payment');
807 dol_syslog(
"_SERVER[SERVER_ADDR] = ".(empty($_SERVER[
"SERVER_ADDR"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_ADDR"])), LOG_DEBUG, 0,
'_payment');
808 dol_syslog(
"Now call the redirect to paymentok or paymentko, URL = ".($error ? $urlko : $urlok), LOG_DEBUG, 0,
'_payment');
811 header(
"Location: ".$urlko);
814 header(
"Location: ".$urlok);
821 'paymentmethod' => $paymentmethod,
822 'validpaymentmethod' => &$validpaymentmethod
824$reshook = $hookmanager->executeHooks(
'doPayment', $parameters, $object, $action);
827} elseif ($reshook > 0) {
828 print $hookmanager->resPrint;
837$form =
new Form($db);
841 $head =
'<link rel="stylesheet" type="text/css" href="' .
getDolGlobalString(
'ONLINE_PAYMENT_CSS_URL').
'?lang='.(!empty($getpostlang) ? $getpostlang : $langs->defaultlang).
'">'.
"\n";
844$conf->dol_hide_topmenu = 1;
845$conf->dol_hide_leftmenu = 1;
847$replacemainarea = (empty($conf->dol_hide_leftmenu) ?
'<div>' :
'').
'<div>';
848llxHeader($head, $langs->trans(
"PaymentForm"),
'',
'', 0, 0,
'',
'',
'',
'onlinepaymentbody', $replacemainarea);
850dol_syslog(
"--- newpayment.php action = ".$action, LOG_DEBUG, 0,
'_payment');
851dol_syslog(
"newpayment.php show page source=".$source.
" paymentmethod=".$paymentmethod.
' amount='.$amount.
' newamount='.
GETPOST(
"newamount",
'alpha').
" ref=".$ref, LOG_DEBUG, 0,
'_payment');
852dol_syslog(
"_SERVER[SERVER_NAME] = ".(empty($_SERVER[
"SERVER_NAME"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_NAME"])), LOG_DEBUG, 0,
'_payment');
853dol_syslog(
"_SERVER[SERVER_ADDR] = ".(empty($_SERVER[
"SERVER_ADDR"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_ADDR"])), LOG_DEBUG, 0,
'_payment');
856if ($source && in_array($ref, array(
'member_ref',
'contractline_ref',
'invoice_ref',
'order_ref',
'donation_ref',
''))) {
857 $langs->load(
"errors");
858 dol_print_error_email(
'BADREFINPAYMENTFORM', $langs->trans(
"ErrorBadLinkSourceSetButBadValueForRef", $source, $ref));
867if ((empty($paymentmethod) || $paymentmethod ==
'paypal') && isModEnabled(
'paypal') && (
getDolGlobalString(
'PAYPAL_API_SANDBOX') ||
GETPOST(
'forcesandbox',
'int'))) {
868 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Paypal'),
'',
'warning');
870if ((empty($paymentmethod) || $paymentmethod ==
'stripe') && isModEnabled(
'stripe') && (!
getDolGlobalString(
'STRIPE_LIVE') ||
GETPOST(
'forcesandbox',
'int'))) {
871 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Stripe'),
'',
'warning');
875print
'<span id="dolpaymentspan"></span>'.
"\n";
876print
'<div class="center">'.
"\n";
877print
'<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
878print
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
879print
'<input type="hidden" name="action" value="dopayment">'.
"\n";
880print
'<input type="hidden" name="tag" value="'.GETPOST(
"tag",
'alpha').
'">'.
"\n";
881print
'<input type="hidden" name="suffix" value="'.dol_escape_htmltag($suffix).
'">'.
"\n";
882print
'<input type="hidden" name="securekey" value="'.dol_escape_htmltag($SECUREKEY).
'">'.
"\n";
883print
'<input type="hidden" name="e" value="'.$entity.
'" />';
884print
'<input type="hidden" name="forcesandbox" value="'.GETPOST(
'forcesandbox',
'int').
'" />';
885print
'<input type="hidden" name="lang" value="'.$getpostlang.
'">';
891$logosmall = $mysoc->logo_small;
893$paramlogo =
'ONLINE_PAYMENT_LOGO_'.$suffix;
894if (!empty($conf->global->$paramlogo)) {
895 $logosmall = $conf->global->$paramlogo;
897 $logosmall = $conf->global->ONLINE_PAYMENT_LOGO;
903if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.
'/logos/thumbs/'.$logosmall)) {
904 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
905 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
906} elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.
'/logos/'.$logo)) {
907 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
908 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
913 print
'<div class="backgreypublicpayment">';
914 print
'<div class="logopublicpayment">';
915 print
'<img id="dolpaymentlogo" src="'.$urllogo.
'"';
919 print
'<div class="poweredbypublicpayment opacitymedium right"><a class="poweredbyhref" href="https://www.dolibarr.org?utm_medium=website&utm_source=poweredby" target="dolibarr" rel="noopener">'.$langs->trans(
"PoweredBy").
'<br><img class="poweredbyimg" src="'.DOL_URL_ROOT.
'/theme/dolibarr_logo.svg" width="80px"></a></div>';
922} elseif ($creditor) {
923 print
'<div class="backgreypublicpayment">';
924 print
'<div class="logopublicpayment">';
930 print
'<div class="backimagepublicpayment">';
931 print
'<img id="idMAIN_IMAGE_PUBLIC_PAYMENT" src="'.getDolGlobalString(
'MAIN_IMAGE_PUBLIC_PAYMENT').
'">';
938print
'<!-- Form to send a payment -->'.
"\n";
939print
'<!-- creditor = '.dol_escape_htmltag($creditor).
' -->'.
"\n";
941if (isModEnabled(
'paypal')) {
942 print
'<!-- PAYPAL_API_SANDBOX = '.getDolGlobalString(
'PAYPAL_API_SANDBOX').
' -->'.
"\n";
943 print
'<!-- PAYPAL_API_INTEGRAL_OR_PAYPALONLY = '.getDolGlobalString(
'PAYPAL_API_INTEGRAL_OR_PAYPALONLY').
' -->'.
"\n";
945if (isModEnabled(
'paybox')) {
946 print
'<!-- PAYBOX_CGI_URL = '.getDolGlobalString(
'PAYBOX_CGI_URL_V2').
' -->'.
"\n";
948if (isModEnabled(
'stripe')) {
949 print
'<!-- STRIPE_LIVE = '.getDolGlobalString(
'STRIPE_LIVE').
' -->'.
"\n";
951print
'<!-- urlok = '.$urlok.
' -->'.
"\n";
952print
'<!-- urlko = '.$urlko.
' -->'.
"\n";
956print
'<table id="dolpublictable" summary="Payment form" class="center">'.
"\n";
961 $langs->load(
"members");
962 if (preg_match(
'/^\((.*)\)$/', $conf->global->PAYMENT_NEWFORM_TEXT, $reg)) {
963 $text .= $langs->trans($reg[1]).
"<br>\n";
967 $text =
'<tr><td align="center"><br>'.$text.
'<br></td></tr>'.
"\n";
970 $text .=
'<tr><td class="textpublicpayment"><br><strong>'.$langs->trans(
"WelcomeOnPaymentPage").
'</strong></td></tr>'.
"\n";
971 $text .=
'<tr><td class="textpublicpayment"><span class="opacitymedium">'.$langs->trans(
"ThisScreenAllowsYouToPay", $creditor).
'</span><br><br></td></tr>'.
"\n";
976print
'<tr><td align="center">';
977print
'<table with="100%" id="tablepublicpayment">';
978print
'<tr><td align="left" colspan="2" class="opacitymedium">'.$langs->trans(
"ThisIsInformationOnPayment").
' :</td></tr>'.
"\n";
989 $tag =
GETPOST(
"tag",
'alpha');
990 if (
GETPOST(
'fulltag',
'alpha')) {
991 $fulltag =
GETPOST(
'fulltag',
'alpha');
993 $fulltag =
"TAG=".$tag;
997 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
998 print
'</td><td class="CTableRow2">';
999 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1000 print
'<b>'.$creditor.
'</b>';
1001 print
'<input type="hidden" name="creditor" value="'.$creditor.
'">';
1002 print
'</td></tr>'.
"\n";
1005 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Amount");
1006 if (empty($amount)) {
1007 print
' ('.$langs->trans(
"ToComplete").
')';
1009 print
'</td><td class="CTableRow2">';
1010 if (empty($amount) || !is_numeric($amount)) {
1011 print
'<input type="hidden" name="amount" value="'.price2num(
GETPOST(
"amount",
'alpha'),
'MT').
'">';
1012 print
'<input class="flat maxwidth75" type="text" name="newamount" value="'.price2num(
GETPOST(
"newamount",
"alpha"),
'MT').
'">';
1014 print
' <b>'.$langs->trans(
"Currency".$currency).
'</b>';
1016 print
'<b class="amount">'.price($amount, 1, $langs, 1, -1, -1, $currency).
'</b>';
1017 print
'<input type="hidden" name="amount" value="'.$amount.
'">';
1018 print
'<input type="hidden" name="newamount" value="'.$amount.
'">';
1020 print
'<input type="hidden" name="currency" value="'.$currency.
'">';
1021 print
'</td></tr>'.
"\n";
1024 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentCode");
1025 print
'</td><td class="CTableRow2"><b style="word-break: break-all;">'.$fulltag.
'</b>';
1026 print
'<input type="hidden" name="tag" value="'.$tag.
'">';
1027 print
'<input type="hidden" name="fulltag" value="'.$fulltag.
'">';
1028 print
'</td></tr>'.
"\n";
1036if ($source ==
'order') {
1038 $langs->load(
"orders");
1040 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
1043 $result = $order->fetch(
'', $ref);
1045 $mesg = $order->error;
1048 $result = $order->fetch_thirdparty($order->socid);
1052 if ($action !=
'dopayment') {
1053 $amount = $order->total_ttc;
1054 if (
GETPOST(
"amount",
'alpha')) {
1055 $amount =
GETPOST(
"amount",
'alpha');
1061 if (
GETPOST(
'fulltag',
'alpha')) {
1062 $fulltag =
GETPOST(
'fulltag',
'alpha');
1064 $fulltag =
'ORD='.$order->id.
'.CUS='.$order->thirdparty->id;
1067 $fulltag .=
'.TAG='.$TAG;
1073 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
1074 print
'</td><td class="CTableRow2">';
1075 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1076 print
'<b>'.$creditor.
'</b>';
1077 print
'<input type="hidden" name="creditor" value="'.$creditor.
'">';
1078 print
'</td></tr>'.
"\n";
1081 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"ThirdParty");
1082 print
'</td><td class="CTableRow2">';
1083 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1084 print
'<b>'.$order->thirdparty->name.
'</b>';
1085 print
'</td></tr>'.
"\n";
1088 $text =
'<b>'.$langs->trans(
"PaymentOrderRef", $order->ref).
'</b>';
1089 if (
GETPOST(
'desc',
'alpha')) {
1090 $text =
'<b>'.$langs->trans(
GETPOST(
'desc',
'alpha')).
'</b>';
1092 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Designation");
1093 print
'</td><td class="CTableRow2">'.$text;
1094 print
'<input type="hidden" name="s" value="'.dol_escape_htmltag($source).
'">';
1095 print
'<input type="hidden" name="ref" value="'.dol_escape_htmltag($order->ref).
'">';
1096 print
'<input type="hidden" name="dol_id" value="'.dol_escape_htmltag($order->id).
'">';
1097 $directdownloadlink = $order->getLastMainDocLink(
'commande');
1098 if ($directdownloadlink) {
1099 print
'<br><a href="'.$directdownloadlink.
'" rel="nofollow noopener">';
1100 print
img_mime($order->last_main_doc,
'');
1101 print $langs->trans(
"DownloadDocument").
'</a>';
1103 print
'</td></tr>'.
"\n";
1106 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Amount");
1107 if (empty($amount)) {
1108 print
' ('.$langs->trans(
"ToComplete").
')';
1110 print
'</td><td class="CTableRow2">';
1111 if (empty($amount) || !is_numeric($amount)) {
1112 print
'<input type="hidden" name="amount" value="'.price2num(
GETPOST(
"amount",
'alpha'),
'MT').
'">';
1113 print
'<input class="flat maxwidth75" type="text" name="newamount" value="'.price2num(
GETPOST(
"newamount",
"alpha"),
'MT').
'">';
1115 print
' <b>'.$langs->trans(
"Currency".$currency).
'</b>';
1117 print
'<b class="amount">'.price($amount, 1, $langs, 1, -1, -1, $currency).
'</b>';
1118 print
'<input type="hidden" name="amount" value="'.$amount.
'">';
1119 print
'<input type="hidden" name="newamount" value="'.$amount.
'">';
1121 print
'<input type="hidden" name="currency" value="'.$currency.
'">';
1122 print
'</td></tr>'.
"\n";
1125 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentCode");
1126 print
'</td><td class="CTableRow2"><b style="word-break: break-all;">'.$fulltag.
'</b>';
1127 print
'<input type="hidden" name="tag" value="'.dol_escape_htmltag($tag).
'">';
1128 print
'<input type="hidden" name="fulltag" value="'.dol_escape_htmltag($fulltag).
'">';
1129 print
'</td></tr>'.
"\n";
1132 $shipToName = $order->thirdparty->name;
1133 $shipToStreet = $order->thirdparty->address;
1134 $shipToCity = $order->thirdparty->town;
1135 $shipToState = $order->thirdparty->state_code;
1136 $shipToCountryCode = $order->thirdparty->country_code;
1137 $shipToZip = $order->thirdparty->zip;
1138 $shipToStreet2 =
'';
1139 $phoneNum = $order->thirdparty->phone;
1140 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1141 print
'<input type="hidden" name="shipToName" value="'.dol_escape_htmltag($shipToName).
'">'.
"\n";
1142 print
'<input type="hidden" name="shipToStreet" value="'.dol_escape_htmltag($shipToStreet).
'">'.
"\n";
1143 print
'<input type="hidden" name="shipToCity" value="'.dol_escape_htmltag($shipToCity).
'">'.
"\n";
1144 print
'<input type="hidden" name="shipToState" value="'.dol_escape_htmltag($shipToState).
'">'.
"\n";
1145 print
'<input type="hidden" name="shipToCountryCode" value="'.dol_escape_htmltag($shipToCountryCode).
'">'.
"\n";
1146 print
'<input type="hidden" name="shipToZip" value="'.dol_escape_htmltag($shipToZip).
'">'.
"\n";
1147 print
'<input type="hidden" name="shipToStreet2" value="'.dol_escape_htmltag($shipToStreet2).
'">'.
"\n";
1148 print
'<input type="hidden" name="phoneNum" value="'.dol_escape_htmltag($phoneNum).
'">'.
"\n";
1150 print
'<!-- Shipping address not complete, so we don t use it -->'.
"\n";
1152 if (is_object($order->thirdparty)) {
1153 print
'<input type="hidden" name="thirdparty_id" value="'.$order->thirdparty->id.
'">'.
"\n";
1155 print
'<input type="hidden" name="email" value="'.$order->thirdparty->email.
'">'.
"\n";
1156 print
'<input type="hidden" name="vatnumber" value="'.dol_escape_htmltag($order->thirdparty->tva_intra).
'">'.
"\n";
1157 $labeldesc = $langs->trans(
"Order").
' '.$order->ref;
1158 if (
GETPOST(
'desc',
'alpha')) {
1159 $labeldesc =
GETPOST(
'desc',
'alpha');
1161 print
'<input type="hidden" name="desc" value="'.dol_escape_htmltag($labeldesc).
'">'.
"\n";
1166if ($source ==
'invoice') {
1168 $langs->load(
"bills");
1170 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1173 $result = $invoice->fetch(
'', $ref);
1175 $mesg = $invoice->error;
1178 $result = $invoice->fetch_thirdparty($invoice->socid);
1182 if ($action !=
'dopayment') {
1183 $amount =
price2num($invoice->total_ttc - ($invoice->getSommePaiement() + $invoice->getSumCreditNotesUsed() + $invoice->getSumDepositsUsed()));
1184 if (
GETPOST(
"amount",
'alpha')) {
1185 $amount =
GETPOST(
"amount",
'alpha');
1190 if (
GETPOST(
'fulltag',
'alpha')) {
1191 $fulltag =
GETPOST(
'fulltag',
'alpha');
1193 $fulltag =
'INV='.$invoice->id.
'.CUS='.$invoice->thirdparty->id;
1196 $fulltag .=
'.TAG='.$TAG;
1202 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
1203 print
'</td><td class="CTableRow2">';
1204 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1205 print
'<b>'.$creditor.
'</b>';
1206 print
'<input type="hidden" name="creditor" value="'.dol_escape_htmltag($creditor).
'">';
1207 print
'</td></tr>'.
"\n";
1210 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"ThirdParty");
1211 print
'</td><td class="CTableRow2">';
1212 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1213 print
'<b>'.$invoice->thirdparty->name.
'</b>';
1214 print
'</td></tr>'.
"\n";
1217 $text =
'<b>'.$langs->trans(
"PaymentInvoiceRef", $invoice->ref).
'</b>';
1218 if (
GETPOST(
'desc',
'alpha')) {
1219 $text =
'<b>'.$langs->trans(
GETPOST(
'desc',
'alpha')).
'</b>';
1221 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Designation");
1222 print
'</td><td class="CTableRow2">'.$text;
1223 print
'<input type="hidden" name="s" value="'.dol_escape_htmltag($source).
'">';
1224 print
'<input type="hidden" name="ref" value="'.dol_escape_htmltag($invoice->ref).
'">';
1225 print
'<input type="hidden" name="dol_id" value="'.dol_escape_htmltag($invoice->id).
'">';
1226 $directdownloadlink = $invoice->getLastMainDocLink(
'facture');
1227 if ($directdownloadlink) {
1228 print
'<br><a href="'.$directdownloadlink.
'">';
1229 print
img_mime($invoice->last_main_doc,
'');
1230 print $langs->trans(
"DownloadDocument").
'</a>';
1232 print
'</td></tr>'.
"\n";
1235 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentAmount");
1236 if (empty($amount) && empty($object->paye)) {
1237 print
' ('.$langs->trans(
"ToComplete").
')';
1239 print
'</td><td class="CTableRow2">';
1240 if ($object->type == $object::TYPE_CREDIT_NOTE) {
1241 print
'<b>'.$langs->trans(
"CreditNote").
'</b>';
1242 } elseif (empty($object->paye)) {
1243 if (empty($amount) || !is_numeric($amount)) {
1244 print
'<input type="hidden" name="amount" value="'.price2num(
GETPOST(
"amount",
'alpha'),
'MT').
'">';
1245 print
'<input class="flat maxwidth75" type="text" name="newamount" value="'.price2num(
GETPOST(
"newamount",
"alpha"),
'MT').
'">';
1246 print
' <b>'.$langs->trans(
"Currency".$currency).
'</b>';
1248 print
'<b class="amount">'.price($amount, 1, $langs, 1, -1, -1, $currency).
'</b>';
1249 print
'<input type="hidden" name="amount" value="'.$amount.
'">';
1250 print
'<input type="hidden" name="newamount" value="'.$amount.
'">';
1253 print
'<b class="amount">'.price($object->total_ttc, 1, $langs, 1, -1, -1, $currency).
'</b>';
1255 print
'<input type="hidden" name="currency" value="'.$currency.
'">';
1256 print
'</td></tr>'.
"\n";
1259 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentCode");
1260 print
'</td><td class="CTableRow2"><b style="word-break: break-all;">'.$fulltag.
'</b>';
1261 print
'<input type="hidden" name="tag" value="'.$tag.
'">';
1262 print
'<input type="hidden" name="fulltag" value="'.$fulltag.
'">';
1263 print
'</td></tr>'.
"\n";
1266 $shipToName = $invoice->thirdparty->name;
1267 $shipToStreet = $invoice->thirdparty->address;
1268 $shipToCity = $invoice->thirdparty->town;
1269 $shipToState = $invoice->thirdparty->state_code;
1270 $shipToCountryCode = $invoice->thirdparty->country_code;
1271 $shipToZip = $invoice->thirdparty->zip;
1272 $shipToStreet2 =
'';
1273 $phoneNum = $invoice->thirdparty->phone;
1274 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1275 print
'<input type="hidden" name="shipToName" value="'.$shipToName.
'">'.
"\n";
1276 print
'<input type="hidden" name="shipToStreet" value="'.$shipToStreet.
'">'.
"\n";
1277 print
'<input type="hidden" name="shipToCity" value="'.$shipToCity.
'">'.
"\n";
1278 print
'<input type="hidden" name="shipToState" value="'.$shipToState.
'">'.
"\n";
1279 print
'<input type="hidden" name="shipToCountryCode" value="'.$shipToCountryCode.
'">'.
"\n";
1280 print
'<input type="hidden" name="shipToZip" value="'.$shipToZip.
'">'.
"\n";
1281 print
'<input type="hidden" name="shipToStreet2" value="'.$shipToStreet2.
'">'.
"\n";
1282 print
'<input type="hidden" name="phoneNum" value="'.$phoneNum.
'">'.
"\n";
1284 print
'<!-- Shipping address not complete, so we don t use it -->'.
"\n";
1286 if (is_object($invoice->thirdparty)) {
1287 print
'<input type="hidden" name="thirdparty_id" value="'.$invoice->thirdparty->id.
'">'.
"\n";
1289 print
'<input type="hidden" name="email" value="'.$invoice->thirdparty->email.
'">'.
"\n";
1290 print
'<input type="hidden" name="vatnumber" value="'.$invoice->thirdparty->tva_intra.
'">'.
"\n";
1291 $labeldesc = $langs->trans(
"Invoice").
' '.$invoice->ref;
1292 if (
GETPOST(
'desc',
'alpha')) {
1293 $labeldesc =
GETPOST(
'desc',
'alpha');
1295 print
'<input type="hidden" name="desc" value="'.dol_escape_htmltag($labeldesc).
'">'.
"\n";
1299if ($source ==
'contractline') {
1301 $langs->load(
"contracts");
1303 require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
1308 $result = $contractline->fetch(
'', $ref);
1310 $mesg = $contractline->error;
1313 if ($contractline->fk_contrat > 0) {
1314 $result = $contract->fetch($contractline->fk_contrat);
1316 $result = $contract->fetch_thirdparty($contract->socid);
1318 $mesg = $contract->error;
1322 $mesg =
'ErrorRecordNotFound';
1326 $object = $contractline;
1328 if ($action !=
'dopayment') {
1329 $amount = $contractline->total_ttc;
1331 if ($contractline->fk_product &&
getDolGlobalString(
'PAYMENT_USE_NEW_PRICE_FOR_CONTRACTLINES')) {
1333 $result = $product->fetch($contractline->fk_product);
1337 $pu_ht = $product->multiprices[$contract->thirdparty->price_level];
1338 $pu_ttc = $product->multiprices_ttc[$contract->thirdparty->price_level];
1339 $price_base_type = $product->multiprices_base_type[$contract->thirdparty->price_level];
1341 $pu_ht = $product->price;
1342 $pu_ttc = $product->price_ttc;
1343 $price_base_type = $product->price_base_type;
1347 if (empty($amount)) {
1353 if (
GETPOST(
"amount",
'alpha')) {
1354 $amount =
GETPOST(
"amount",
'alpha');
1359 if (
GETPOST(
'fulltag',
'alpha')) {
1360 $fulltag =
GETPOST(
'fulltag',
'alpha');
1362 $fulltag =
'COL='.$contractline->id.
'.CON='.$contract->id.
'.CUS='.$contract->thirdparty->id.
'.DAT='.
dol_print_date(
dol_now(),
'%Y%m%d%H%M%S');
1365 $fulltag .=
'.TAG='.$TAG;
1376 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
1377 print
'</td><td class="CTableRow2"><b>'.$creditor.
'</b>';
1378 print
'<input type="hidden" name="creditor" value="'.$creditor.
'">';
1379 print
'</td></tr>'.
"\n";
1382 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"ThirdParty");
1383 print
'</td><td class="CTableRow2"><b>'.$contract->thirdparty->name.
'</b>';
1384 print
'</td></tr>'.
"\n";
1387 $text =
'<b>'.$langs->trans(
"PaymentRenewContractId", $contract->ref, $contractline->ref).
'</b>';
1388 if ($contractline->fk_product > 0) {
1389 $contractline->fetch_product();
1390 $text .=
'<br>'.$contractline->product->ref.($contractline->product->label ?
' - '.$contractline->product->label :
'');
1392 if ($contractline->description) {
1393 $text .=
'<br>'.dol_htmlentitiesbr($contractline->description);
1395 if ($contractline->date_end) {
1396 $text .=
'<br>'.$langs->trans(
"ExpiredSince").
': '.
dol_print_date($contractline->date_end);
1398 if (
GETPOST(
'desc',
'alpha')) {
1399 $text =
'<b>'.$langs->trans(
GETPOST(
'desc',
'alpha')).
'</b>';
1401 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Designation");
1402 print
'</td><td class="CTableRow2">'.$text;
1403 print
'<input type="hidden" name="source" value="'.dol_escape_htmltag($source).
'">';
1404 print
'<input type="hidden" name="ref" value="'.dol_escape_htmltag($contractline->ref).
'">';
1405 print
'<input type="hidden" name="dol_id" value="'.dol_escape_htmltag($contractline->id).
'">';
1406 $directdownloadlink = $contract->getLastMainDocLink(
'contract');
1407 if ($directdownloadlink) {
1408 print
'<br><a href="'.$directdownloadlink.
'">';
1409 print
img_mime($contract->last_main_doc,
'');
1410 print $langs->trans(
"DownloadDocument").
'</a>';
1412 print
'</td></tr>'.
"\n";
1415 $label = $langs->trans(
"Quantity");
1418 if ($contractline->fk_product) {
1419 if ($contractline->product->isService() && $contractline->product->duration_value > 0) {
1420 $label = $langs->trans(
"Duration");
1423 if ($contractline->product->duration_value > 1) {
1424 $dur = array(
"h"=>$langs->trans(
"Hours"),
"d"=>$langs->trans(
"DurationDays"),
"w"=>$langs->trans(
"DurationWeeks"),
"m"=>$langs->trans(
"DurationMonths"),
"y"=>$langs->trans(
"DurationYears"));
1426 $dur = array(
"h"=>$langs->trans(
"Hour"),
"d"=>$langs->trans(
"DurationDay"),
"w"=>$langs->trans(
"DurationWeek"),
"m"=>$langs->trans(
"DurationMonth"),
"y"=>$langs->trans(
"DurationYear"));
1428 $duration = $contractline->product->duration_value.
' '.$dur[$contractline->product->duration_unit];
1431 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$label.
'</td>';
1432 print
'<td class="CTableRow2"><b>'.($duration ? $duration : $qty).
'</b>';
1433 print
'<input type="hidden" name="newqty" value="'.dol_escape_htmltag($qty).
'">';
1434 print
'</b></td></tr>'.
"\n";
1437 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Amount");
1438 if (empty($amount)) {
1439 print
' ('.$langs->trans(
"ToComplete").
')';
1441 print
'</td><td class="CTableRow2">';
1442 if (empty($amount) || !is_numeric($amount)) {
1443 print
'<input type="hidden" name="amount" value="'.price2num(
GETPOST(
"amount",
'alpha'),
'MT').
'">';
1444 print
'<input class="flat maxwidth75" type="text" name="newamount" value="'.price2num(
GETPOST(
"newamount",
"alpha"),
'MT').
'">';
1446 print
' <b>'.$langs->trans(
"Currency".$currency).
'</b>';
1448 print
'<b class="amount">'.price($amount, 1, $langs, 1, -1, -1, $currency).
'</b>';
1449 print
'<input type="hidden" name="amount" value="'.$amount.
'">';
1450 print
'<input type="hidden" name="newamount" value="'.$amount.
'">';
1452 print
'<input type="hidden" name="currency" value="'.$currency.
'">';
1453 print
'</td></tr>'.
"\n";
1456 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentCode");
1457 print
'</td><td class="CTableRow2"><b style="word-break: break-all;">'.$fulltag.
'</b>';
1458 print
'<input type="hidden" name="tag" value="'.$tag.
'">';
1459 print
'<input type="hidden" name="fulltag" value="'.$fulltag.
'">';
1460 print
'</td></tr>'.
"\n";
1463 $shipToName = $contract->thirdparty->name;
1464 $shipToStreet = $contract->thirdparty->address;
1465 $shipToCity = $contract->thirdparty->town;
1466 $shipToState = $contract->thirdparty->state_code;
1467 $shipToCountryCode = $contract->thirdparty->country_code;
1468 $shipToZip = $contract->thirdparty->zip;
1469 $shipToStreet2 =
'';
1470 $phoneNum = $contract->thirdparty->phone;
1471 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1472 print
'<input type="hidden" name="shipToName" value="'.$shipToName.
'">'.
"\n";
1473 print
'<input type="hidden" name="shipToStreet" value="'.$shipToStreet.
'">'.
"\n";
1474 print
'<input type="hidden" name="shipToCity" value="'.$shipToCity.
'">'.
"\n";
1475 print
'<input type="hidden" name="shipToState" value="'.$shipToState.
'">'.
"\n";
1476 print
'<input type="hidden" name="shipToCountryCode" value="'.$shipToCountryCode.
'">'.
"\n";
1477 print
'<input type="hidden" name="shipToZip" value="'.$shipToZip.
'">'.
"\n";
1478 print
'<input type="hidden" name="shipToStreet2" value="'.$shipToStreet2.
'">'.
"\n";
1479 print
'<input type="hidden" name="phoneNum" value="'.$phoneNum.
'">'.
"\n";
1481 print
'<!-- Shipping address not complete, so we don t use it -->'.
"\n";
1483 if (is_object($contract->thirdparty)) {
1484 print
'<input type="hidden" name="thirdparty_id" value="'.$contract->thirdparty->id.
'">'.
"\n";
1486 print
'<input type="hidden" name="email" value="'.$contract->thirdparty->email.
'">'.
"\n";
1487 print
'<input type="hidden" name="vatnumber" value="'.$contract->thirdparty->tva_intra.
'">'.
"\n";
1488 $labeldesc = $langs->trans(
"Contract").
' '.$contract->ref;
1489 if (
GETPOST(
'desc',
'alpha')) {
1490 $labeldesc =
GETPOST(
'desc',
'alpha');
1492 print
'<input type="hidden" name="desc" value="'.dol_escape_htmltag($labeldesc).
'">'.
"\n";
1496if ($source ==
'member' || $source ==
'membersubscription') {
1497 $newsource =
'member';
1501 $langs->load(
"members");
1503 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
1504 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent_type.class.php';
1505 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
1510 $result = $member->fetch(
'', $ref);
1512 $mesg = $member->error;
1515 $member->fetch_thirdparty();
1518 $adht->fetch($member->typeid);
1522 if ($action !=
'dopayment') {
1523 $amount = $subscription->total_ttc;
1524 if (
GETPOST(
"amount",
'alpha')) {
1525 $amount =
GETPOST(
"amount",
'alpha');
1528 if (empty($amount)) {
1529 $amount = $adht->amount;
1532 $amount = max(0,
price2num($amount,
'MT'));
1535 if (
GETPOST(
'fulltag',
'alpha')) {
1536 $fulltag =
GETPOST(
'fulltag',
'alpha');
1541 $fulltag .=
'.TAG='.$TAG;
1547 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
1548 print
'</td><td class="CTableRow2"><b>'.$creditor.
'</b>';
1549 print
'<input type="hidden" name="creditor" value="'.$creditor.
'">';
1550 print
'</td></tr>'.
"\n";
1553 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Member");
1554 print
'</td><td class="CTableRow2">';
1556 if ($member->morphy ==
'mor' && !empty($member->company)) {
1557 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1558 print $member->company;
1560 print
img_picto(
'',
'member',
'class="pictofixedwidth"');
1561 print $member->getFullName($langs);
1564 print
'</td></tr>'.
"\n";
1567 $text =
'<b>'.$langs->trans(
"PaymentSubscription").
'</b>';
1568 if (
GETPOST(
'desc',
'alpha')) {
1569 $text =
'<b>'.$langs->trans(
GETPOST(
'desc',
'alpha')).
'</b>';
1571 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Designation");
1572 print
'</td><td class="CTableRow2">'.$text;
1573 print
'<input type="hidden" name="source" value="'.dol_escape_htmltag($newsource).
'">';
1574 print
'<input type="hidden" name="ref" value="'.dol_escape_htmltag($member->ref).
'">';
1575 print
'</td></tr>'.
"\n";
1577 if ($object->datefin > 0) {
1578 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"DateEndSubscription");
1579 print
'</td><td class="CTableRow2">'.dol_print_date($member->datefin,
'day');
1580 print
'</td></tr>'.
"\n";
1583 if ($member->last_subscription_date || $member->last_subscription_amount) {
1586 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"LastSubscriptionDate");
1587 print
'</td><td class="CTableRow2">'.dol_print_date($member->last_subscription_date,
'day');
1588 print
'</td></tr>'.
"\n";
1592 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"LastSubscriptionAmount");
1593 print
'</td><td class="CTableRow2">'.price($member->last_subscription_amount);
1594 print
'</td></tr>'.
"\n";
1596 if (empty($amount) && !
GETPOST(
'newamount',
'alpha')) {
1597 $_GET[
'newamount'] = $member->last_subscription_amount;
1598 $_GET[
'amount'] = $member->last_subscription_amount;
1600 if (!empty($member->last_subscription_amount) && !GETPOSTISSET(
'newamount') && is_numeric($amount)) {
1601 $amount = max($member->last_subscription_amount, $amount);
1605 if ($member->type) {
1606 $oldtypeid = $member->typeid;
1607 $newtypeid = (int) (GETPOSTISSET(
"typeid") ?
GETPOST(
"typeid",
'int') : $member->typeid);
1610 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent_type.class.php';
1613 $amountbytype = $adht->amountByType(1);
1616 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"LastMemberType");
1617 print
'</td><td class="CTableRow2">'.dol_escape_htmltag($member->type);
1618 print
"</td></tr>\n";
1621 $member->typeid = $newtypeid;
1622 $member->type =
dol_getIdFromCode($db, $newtypeid,
'adherent_type',
'rowid',
'libelle');
1627 $amount = (!empty($amountbytype[$member->typeid])) ? $amountbytype[$member->typeid] : $member->last_subscription_amount;
1629 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"NewSubscription");
1630 print
'</td><td class="CTableRow2">';
1631 print $form->selectarray(
"typeid", $adht->liste_array(1), $member->typeid, 0, 0, 0,
'onchange="window.location.replace(\''.$urlwithroot.
'/public/payment/newpayment.php?source='.urlencode($source).
'&ref='.urlencode($ref).
'&amount='.urlencode($amount).
'&typeid=\' + this.value + \'&securekey='.urlencode($SECUREKEY).
'\');
"', 0, 0, 0, '', '', 1);
1632 print "</td></tr>\n
";
1633 } elseif ($action == 'dopayment') {
1634 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("NewMemberType
");
1635 print '</td><td class="CTableRow2
">'.dol_escape_htmltag($member->type);
1636 print '<input type="hidden
" name="membertypeid
" value="'.$member->typeid.'">';
1637 print "</td></tr>\n
";
1640 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("MemberType
");
1641 print '</td><td class="CTableRow2
">'.dol_escape_htmltag($member->type);
1642 print "</td></tr>\n
";
1647 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Amount
");
1648 // This place no longer allows amount edition
1649 if (getDolGlobalString('MEMBER_EXT_URL_SUBSCRIPTION_INFO')) {
1650 print ' - <a href="' . getDolGlobalString('MEMBER_EXT_URL_SUBSCRIPTION_INFO
').'" rel="external
" target="_blank
" rel="noopener noreferrer
">'.$langs->trans("SeeHere
").'</a>';
1652 print '</td><td class="CTableRow2
">';
1653 if (getDolGlobalString('MEMBER_MIN_AMOUNT') && $amount) {
1654 $amount = max(0, getDolGlobalString('MEMBER_MIN_AMOUNT'), $amount);
1656 $caneditamount = $adht->caneditamount;
1657 $minimumamount = !getDolGlobalString('MEMBER_MIN_AMOUNT') ? $adht->amount : max(getDolGlobalString('MEMBER_MIN_AMOUNT'), $adht->amount, $amount);
1659 if ($caneditamount && $action != 'dopayment') {
1660 if (GETPOSTISSET('newamount')) {
1661 print '<input type="text
" class="width75
" name="newamount
" value="'.price(price2num(GETPOST('newamount
'), '', 2), 1, $langs, 1, -1, -1).'">';
1663 print '<input type="text
" class="width75
" name="newamount
" value="'.price($amount, 1, $langs, 1, -1, -1).'">';
1666 print '<b class="amount
">'.price($amount, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
1667 if ($minimumamount > $amount) {
1668 print ' <span class="opacitymedium small
">'. $langs->trans("AmountIsLowerToMinimumNotice
", price($minimumamount, 1, $langs, 1, -1, -1, $currency)).'</span>';
1670 print '<input type="hidden
" name="newamount
" value="'.$amount.'">';
1672 print '<input type="hidden
" name="amount
" value="'.$amount.'">';
1673 print '<input type="hidden
" name="currency
" value="'.$currency.'">';
1674 print '</td></tr>'."\n
";
1677 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("PaymentCode
");
1678 print '</td><td class="CTableRow2
"><b style="word-
break:
break-all;
">'.$fulltag.'</b>';
1679 print '<input type="hidden
" name="tag
" value="'.$tag.'">';
1680 print '<input type="hidden
" name="fulltag
" value="'.$fulltag.'">';
1681 print '</td></tr>'."\n
";
1684 $shipToName = $member->getFullName($langs);
1685 $shipToStreet = $member->address;
1686 $shipToCity = $member->town;
1687 $shipToState = $member->state_code;
1688 $shipToCountryCode = $member->country_code;
1689 $shipToZip = $member->zip;
1690 $shipToStreet2 = '';
1691 $phoneNum = $member->phone;
1692 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1693 print '<!-- Shipping address information -->';
1694 print '<input type="hidden
" name="shipToName
" value="'.$shipToName.'">'."\n
";
1695 print '<input type="hidden
" name="shipToStreet
" value="'.$shipToStreet.'">'."\n
";
1696 print '<input type="hidden
" name="shipToCity
" value="'.$shipToCity.'">'."\n
";
1697 print '<input type="hidden
" name="shipToState
" value="'.$shipToState.'">'."\n
";
1698 print '<input type="hidden
" name="shipToCountryCode
" value="'.$shipToCountryCode.'">'."\n
";
1699 print '<input type="hidden
" name="shipToZip
" value="'.$shipToZip.'">'."\n
";
1700 print '<input type="hidden
" name="shipToStreet2
" value="'.$shipToStreet2.'">'."\n
";
1701 print '<input type="hidden
" name="phoneNum
" value="'.$phoneNum.'">'."\n
";
1703 print '<!-- Shipping address not complete, so we don t use it -->'."\n
";
1705 if (is_object($member->thirdparty)) {
1706 print '<input type="hidden
" name="thirdparty_id
" value="'.$member->thirdparty->id.'">'."\n
";
1708 print '<input type="hidden
" name="email
" value="'.$member->email.'">'."\n
";
1709 $labeldesc = $langs->trans("PaymentSubscription
");
1710 if (GETPOST('desc', 'alpha')) {
1711 $labeldesc = GETPOST('desc', 'alpha');
1713 print '<input type="hidden
" name="desc
" value="'.dol_escape_htmltag($labeldesc).'">'."\n
";
1716// Payment on donation
1717if ($source == 'donation') {
1719 $langs->load("don
");
1721 require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
1723 $don = new Don($db);
1724 $result = $don->fetch($ref);
1726 $mesg = $don->error;
1729 $don->fetch_thirdparty();
1733 if ($action != 'dopayment') { // Do not change amount if we just click on first dopayment
1734 if (GETPOST("amount
", 'alpha')) {
1735 $amount = GETPOST("amount
", 'alpha');
1737 $amount = $don->getRemainToPay();
1739 $amount = price2num($amount);
1742 if (GETPOST('fulltag', 'alpha')) {
1743 $fulltag = GETPOST('fulltag', 'alpha');
1745 $fulltag = 'DON='.$don->ref.'.DAT='.dol_print_date(dol_now(), '%Y%m%d%H%M%S');
1748 $fulltag .= '.TAG='.$TAG;
1751 $fulltag = dol_string_unaccent($fulltag);
1754 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Creditor
");
1755 print '</td><td class="CTableRow2
"><b>'.$creditor.'</b>';
1756 print '<input type="hidden
" name="creditor
" value="'.$creditor.'">';
1757 print '</td></tr>'."\n
";
1760 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("ThirdParty
");
1761 print '</td><td class="CTableRow2
"><b>';
1762 if ($don->morphy == 'mor' && !empty($don->societe)) {
1763 print $don->societe;
1765 print $don->getFullName($langs);
1768 print '</td></tr>'."\n
";
1772 if (GETPOST('desc', 'alpha')) {
1773 $text = '<b>'.$langs->trans(GETPOST('desc', 'alpha')).'</b>';
1775 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Designation
");
1776 print '</td><td class="CTableRow2
">'.$text;
1777 print '<input type="hidden
" name="source
" value="'.dol_escape_htmltag($source).'">';
1778 print '<input type="hidden
" name="ref" value="'.dol_escape_htmltag($don->ref).'">';
1779 print '</td></tr>'."\n
";
1782 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Amount
");
1783 if (empty($amount)) {
1784 if (!getDolGlobalString('DONATION_NEWFORM_AMOUNT')) {
1785 print ' ('.$langs->trans("ToComplete
");
1787 if (getDolGlobalString('DONATION_EXT_URL_SUBSCRIPTION_INFO')) {
1788 print ' - <a href="' . getDolGlobalString('DONATION_EXT_URL_SUBSCRIPTION_INFO
').'" rel="external
" target="_blank
" rel="noopener noreferrer
">'.$langs->trans("SeeHere
").'</a>';
1790 if (!getDolGlobalString('DONATION_NEWFORM_AMOUNT')) {
1794 print '</td><td class="CTableRow2
">';
1796 if (empty($amount) || !is_numeric($amount)) {
1797 $valtoshow = price2num(GETPOST("newamount
", 'alpha'), 'MT');
1798 // force default subscription amount to value defined into constant...
1799 if (empty($valtoshow)) {
1800 if (getDolGlobalString('DONATION_NEWFORM_EDITAMOUNT')) {
1801 if (getDolGlobalString('DONATION_NEWFORM_AMOUNT')) {
1802 $valtoshow = $conf->global->DONATION_NEWFORM_AMOUNT;
1805 if (getDolGlobalString('DONATION_NEWFORM_AMOUNT')) {
1806 $amount = $conf->global->DONATION_NEWFORM_AMOUNT;
1811 if (empty($amount) || !is_numeric($amount)) {
1812 //$valtoshow=price2num(GETPOST("newamount
",'alpha'),'MT');
1813 if (getDolGlobalString('DONATION_MIN_AMOUNT') && $valtoshow) {
1814 $valtoshow = max(getDolGlobalString('DONATION_MIN_AMOUNT'), $valtoshow);
1816 print '<input type="hidden
" name="amount
" value="'.price2num(GETPOST("amount", 'alpha
'), 'MT
').'">';
1817 print '<input class="flat maxwidth75
" type="text
" name="newamount
" value="'.$valtoshow.'">';
1819 print ' <b>'.$langs->trans("Currency
".$currency).'</b>';
1821 $valtoshow = $amount;
1822 if (getDolGlobalString('DONATION_MIN_AMOUNT') && $valtoshow) {
1823 $valtoshow = max(getDolGlobalString('DONATION_MIN_AMOUNT'), $valtoshow);
1824 $amount = $valtoshow;
1826 print '<b class="amount
">'.price($valtoshow, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
1827 print '<input type="hidden
" name="amount
" value="'.$valtoshow.'">';
1828 print '<input type="hidden
" name="newamount
" value="'.$valtoshow.'">';
1830 print '<input type="hidden
" name="currency
" value="'.$currency.'">';
1831 print '</td></tr>'."\n
";
1834 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("PaymentCode
");
1835 print '</td><td class="CTableRow2
"><b style="word-
break:
break-all;
">'.$fulltag.'</b>';
1836 print '<input type="hidden
" name="tag
" value="'.$tag.'">';
1837 print '<input type="hidden
" name="fulltag
" value="'.$fulltag.'">';
1838 print '</td></tr>'."\n
";
1841 $shipToName = $don->getFullName($langs);
1842 $shipToStreet = $don->address;
1843 $shipToCity = $don->town;
1844 $shipToState = $don->state_code;
1845 $shipToCountryCode = $don->country_code;
1846 $shipToZip = $don->zip;
1847 $shipToStreet2 = '';
1848 $phoneNum = $don->phone;
1849 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1850 print '<!-- Shipping address information -->';
1851 print '<input type="hidden
" name="shipToName
" value="'.$shipToName.'">'."\n
";
1852 print '<input type="hidden
" name="shipToStreet
" value="'.$shipToStreet.'">'."\n
";
1853 print '<input type="hidden
" name="shipToCity
" value="'.$shipToCity.'">'."\n
";
1854 print '<input type="hidden
" name="shipToState
" value="'.$shipToState.'">'."\n
";
1855 print '<input type="hidden
" name="shipToCountryCode
" value="'.$shipToCountryCode.'">'."\n
";
1856 print '<input type="hidden
" name="shipToZip
" value="'.$shipToZip.'">'."\n
";
1857 print '<input type="hidden
" name="shipToStreet2
" value="'.$shipToStreet2.'">'."\n
";
1858 print '<input type="hidden
" name="phoneNum
" value="'.$phoneNum.'">'."\n
";
1860 print '<!-- Shipping address not complete, so we don t use it -->'."\n
";
1862 if (is_object($don->thirdparty)) {
1863 print '<input type="hidden
" name="thirdparty_id
" value="'.$don->thirdparty->id.'">'."\n
";
1865 print '<input type="hidden
" name="email
" value="'.$don->email.'">'."\n
";
1866 $labeldesc = $langs->trans("PaymentSubscription
");
1867 if (GETPOST('desc', 'alpha')) {
1868 $labeldesc = GETPOST('desc', 'alpha');
1870 print '<input type="hidden
" name="desc
" value="'.dol_escape_htmltag($labeldesc).'">'."\n
";
1873if ($source == 'organizedeventregistration') {
1875 $langs->loadLangs(array("members
", "eventorganization
"));
1877 if (GETPOST('fulltag', 'alpha')) {
1878 $fulltag = GETPOST('fulltag', 'alpha');
1880 $fulltag = 'ATT='.$attendee->id.'.DAT='.dol_print_date(dol_now(), '%Y%m%d%H%M%S');
1883 $fulltag .= '.TAG='.$TAG;
1886 $fulltag = dol_string_unaccent($fulltag);
1889 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Creditor
");
1890 print '</td><td class="CTableRow2
"><b>'.$creditor.'</b>';
1891 print '<input type="hidden
" name="creditor
" value="'.$creditor.'">';
1892 print '</td></tr>'."\n
";
1895 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Attendee
");
1896 print '</td><td class="CTableRow2
"><b>';
1897 print $attendee->email;
1898 print($thirdparty->name ? ' ('.$thirdparty->name.')' : '');
1900 print '</td></tr>'."\n
";
1902 if (! is_object($attendee->project)) {
1903 $text = 'ErrorProjectNotFound';
1905 $text = $langs->trans("PaymentEvent
").' - '.$attendee->project->title;
1909 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Designation
");
1910 print '</td><td class="CTableRow2
"><b>'.$text.'</b>';
1911 print '<input type="hidden
" name="source
" value="'.dol_escape_htmltag($source).'">';
1912 print '<input type="hidden
" name="ref" value="'.dol_escape_htmltag($invoice->id).'">';
1913 print '</td></tr>'."\n
";
1916 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Amount
");
1917 print '</td><td class="CTableRow2
">';
1918 $valtoshow = $amount;
1919 print '<b class="amount
">'.price($valtoshow, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
1920 print '<input type="hidden
" name="amount
" value="'.$valtoshow.'">';
1921 print '<input type="hidden
" name="newamount
" value="'.$valtoshow.'">';
1922 print '<input type="hidden
" name="currency
" value="'.$currency.'">';
1923 print '</td></tr>'."\n
";
1926 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("PaymentCode
");
1927 print '</td><td class="CTableRow2
"><b style="word-
break:
break-all;
">'.$fulltag.'</b>';
1928 print '<input type="hidden
" name="tag
" value="'.$tag.'">';
1929 print '<input type="hidden
" name="fulltag
" value="'.$fulltag.'">';
1930 print '</td></tr>'."\n
";
1933 $shipToName = $thirdparty->getFullName($langs);
1934 $shipToStreet = $thirdparty->address;
1935 $shipToCity = $thirdparty->town;
1936 $shipToState = $thirdparty->state_code;
1937 $shipToCountryCode = $thirdparty->country_code;
1938 $shipToZip = $thirdparty->zip;
1939 $shipToStreet2 = '';
1940 $phoneNum = $thirdparty->phone;
1941 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1942 print '<!-- Shipping address information -->';
1943 print '<input type="hidden
" name="shipToName
" value="'.$shipToName.'">'."\n
";
1944 print '<input type="hidden
" name="shipToStreet
" value="'.$shipToStreet.'">'."\n
";
1945 print '<input type="hidden
" name="shipToCity
" value="'.$shipToCity.'">'."\n
";
1946 print '<input type="hidden
" name="shipToState
" value="'.$shipToState.'">'."\n
";
1947 print '<input type="hidden
" name="shipToCountryCode
" value="'.$shipToCountryCode.'">'."\n
";
1948 print '<input type="hidden
" name="shipToZip
" value="'.$shipToZip.'">'."\n
";
1949 print '<input type="hidden
" name="shipToStreet2
" value="'.$shipToStreet2.'">'."\n
";
1950 print '<input type="hidden
" name="phoneNum
" value="'.$phoneNum.'">'."\n
";
1952 print '<!-- Shipping address not complete, so we don t use it -->'."\n
";
1954 print '<input type="hidden
" name="thirdparty_id
" value="'.$thirdparty->id.'">'."\n
";
1955 print '<input type="hidden
" name="email
" value="'.$thirdparty->email.'">'."\n
";
1956 $labeldesc = $langs->trans("PaymentSubscription
");
1957 if (GETPOST('desc', 'alpha')) {
1958 $labeldesc = GETPOST('desc', 'alpha');
1960 print '<input type="hidden
" name="desc
" value="'.dol_escape_htmltag($labeldesc).'">'."\n
";
1963if ($source == 'boothlocation') {
1965 $langs->load("members
");
1967 if (GETPOST('fulltag', 'alpha')) {
1968 $fulltag = GETPOST('fulltag', 'alpha');
1970 $fulltag = 'BOO='.GETPOST("booth
").'.DAT='.dol_print_date(dol_now(), '%Y%m%d%H%M%S');
1973 $fulltag .= '.TAG='.$TAG;
1976 $fulltag = dol_string_unaccent($fulltag);
1979 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Creditor
");
1980 print '</td><td class="CTableRow2
"><b>'.$creditor.'</b>';
1981 print '<input type="hidden
" name="creditor
" value="'.$creditor.'">';
1982 print '</td></tr>'."\n
";
1985 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Attendee
");
1986 print '</td><td class="CTableRow2
"><b>';
1987 print $thirdparty->name;
1989 print '</td></tr>'."\n
";
1992 $text = '<b>'.$langs->trans("PaymentBoothLocation
").'</b>';
1993 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Designation
");
1994 print '</td><td class="CTableRow2
">'.$text;
1995 print '<input type="hidden
" name="source
" value="'.dol_escape_htmltag($source).'">';
1996 print '<input type="hidden
" name="ref" value="'.dol_escape_htmltag($invoice->id).'">';
1997 print '</td></tr>'."\n
";
2000 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Amount
");
2001 print '</td><td class="CTableRow2
">';
2002 $valtoshow = $amount;
2003 print '<b class="amount
">'.price($valtoshow, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
2004 print '<input type="hidden
" name="amount
" value="'.$valtoshow.'">';
2005 print '<input type="hidden
" name="newamount
" value="'.$valtoshow.'">';
2006 print '<input type="hidden
" name="currency
" value="'.$currency.'">';
2007 print '</td></tr>'."\n
";
2010 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("PaymentCode
");
2011 print '</td><td class="CTableRow2
"><b style="word-
break:
break-all;
">'.$fulltag.'</b>';
2012 print '<input type="hidden
" name="tag
" value="'.$tag.'">';
2013 print '<input type="hidden
" name="fulltag
" value="'.$fulltag.'">';
2014 print '</td></tr>'."\n
";
2017 $shipToName = $thirdparty->getFullName($langs);
2018 $shipToStreet = $thirdparty->address;
2019 $shipToCity = $thirdparty->town;
2020 $shipToState = $thirdparty->state_code;
2021 $shipToCountryCode = $thirdparty->country_code;
2022 $shipToZip = $thirdparty->zip;
2023 $shipToStreet2 = '';
2024 $phoneNum = $thirdparty->phone;
2025 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
2026 print '<!-- Shipping address information -->';
2027 print '<input type="hidden
" name="shipToName
" value="'.$shipToName.'">'."\n
";
2028 print '<input type="hidden
" name="shipToStreet
" value="'.$shipToStreet.'">'."\n
";
2029 print '<input type="hidden
" name="shipToCity
" value="'.$shipToCity.'">'."\n
";
2030 print '<input type="hidden
" name="shipToState
" value="'.$shipToState.'">'."\n
";
2031 print '<input type="hidden
" name="shipToCountryCode
" value="'.$shipToCountryCode.'">'."\n
";
2032 print '<input type="hidden
" name="shipToZip
" value="'.$shipToZip.'">'."\n
";
2033 print '<input type="hidden
" name="shipToStreet2
" value="'.$shipToStreet2.'">'."\n
";
2034 print '<input type="hidden
" name="phoneNum
" value="'.$phoneNum.'">'."\n
";
2036 print '<!-- Shipping address not complete, so we don t use it -->'."\n
";
2038 print '<input type="hidden
" name="thirdparty_id
" value="'.$thirdparty->id.'">'."\n
";
2039 print '<input type="hidden
" name="email
" value="'.$thirdparty->email.'">'."\n
";
2040 $labeldesc = $langs->trans("PaymentSubscription
");
2041 if (GETPOST('desc', 'alpha')) {
2042 $labeldesc = GETPOST('desc', 'alpha');
2044 print '<input type="hidden
" name="desc
" value="'.dol_escape_htmltag($labeldesc).'">'."\n
";
2047if (!$found && !$mesg) {
2048 $mesg = $langs->trans("ErrorBadParameters
");
2052 print '<tr><td align="center
" colspan="2
"><br><div class="warning
">'.dol_escape_htmltag($mesg, 1, 1, 'br').'</div></td></tr>'."\n
";
2055print '</table>'."\n
";
2059// Show all payment mode buttons (Stripe, Paypal, ...)
2060if ($action != 'dopayment') {
2061 if ($found && !$error) { // We are in a management option and no error
2062 // Check status of the object (Invoice) to verify if it is paid by external payment modules (ie Payzen, ...)
2064 'source' => $source,
2067 $reshook = $hookmanager->executeHooks('doCheckStatus', $parameters, $object, $action);
2069 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2070 } elseif ($reshook > 0) {
2071 print $hookmanager->resPrint;
2074 if ($source == 'order' && $object->billed) {
2075 print '<br><br><span class="amountpaymentcomplete size12x
">'.$langs->trans("OrderBilled
").'</span>';
2076 } elseif ($source == 'invoice' && $object->paye) {
2077 print '<br><br><span class="amountpaymentcomplete size12x
">'.$langs->trans("InvoicePaid
").'</span>';
2078 } elseif ($source == 'donation' && $object->paid) {
2079 print '<br><br><span class="amountpaymentcomplete size12x
">'.$langs->trans("DonationPaid
").'</span>';
2081 // Membership can be paid and we still allow to make renewal
2082 if (($source == 'member' || $source == 'membersubscription') && $object->datefin > dol_now()) {
2083 $langs->load("members
");
2084 print '<br><span class="amountpaymentcomplete size12x
">';
2085 $s = $langs->trans("MembershipPaid
", '{s1}');
2086 print str_replace('{s1}', '<span class="nobold
">'.dol_print_date($object->datefin, 'day').'</span>', $s);
2087 print '</span><br>';
2088 print '<div class="opacitymedium margintoponly
">'.$langs->trans("PaymentWillBeRecordedForNextPeriod
").'</div>';
2092 // Buttons for all payments registration methods
2094 // This hook is used to add Button to newpayment.php for external payment modules (ie Payzen, ...)
2096 'paymentmethod' => $paymentmethod
2098 $reshook = $hookmanager->executeHooks('doAddButton', $parameters, $object, $action);
2100 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2101 } elseif ($reshook > 0) {
2102 print $hookmanager->resPrint;
2105 if ((empty($paymentmethod) || $paymentmethod == 'paybox') && isModEnabled('paybox')) {
2106 print '<div class="button buttonpayment
" id="div_dopayment_paybox
"><span class="fa fa-credit-card
"></span> <input class="" type="submit
" id="dopayment_paybox
" name="dopayment_paybox
" value="'.$langs->trans("PayBoxDoPayment").'">';
2108 print '<span class="buttonpaymentsmall
">'.$langs->trans("CreditOrDebitCard
").'</span>';
2111 $( document ).ready(function() {
2112 $("#div_dopayment_paybox
").click(function(){
2113 $("#dopayment_paybox
").click();
2115 $("#dopayment_paybox
").click(function(e){
2116 $("#div_dopayment_paybox
").css( \'cursor\', \'wait\' );
2117 e.stopPropagation();
2124 if ((empty($paymentmethod) || $paymentmethod == 'stripe') && isModEnabled('stripe')) {
2125 print '<div class="button buttonpayment
" id="div_dopayment_stripe
"><span class="fa fa-credit-card
"></span> <input class="" type="submit
" id="dopayment_stripe
" name="dopayment_stripe
" value="'.$langs->trans("StripeDoPayment").'">';
2126 print '<input type="hidden
" name="noidempotency
" value="'.GETPOST('noidempotency
', 'int').'">';
2128 print '<span class="buttonpaymentsmall
">'.$langs->trans("CreditOrDebitCard
").'</span>';
2131 $( document ).ready(function() {
2132 $("#div_dopayment_stripe
").click(function(){
2133 $("#dopayment_stripe
").click();
2135 $("#dopayment_stripe
").click(function(e){
2136 $("#div_dopayment_stripe
").css( \'cursor\', \'wait\' );
2137 e.stopPropagation();
2145 if ((empty($paymentmethod) || $paymentmethod == 'paypal') && isModEnabled('paypal')) {
2146 if (!getDolGlobalString('PAYPAL_API_INTEGRAL_OR_PAYPALONLY')) {
2147 $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY = 'integral';
2150 print '<div class="button buttonpayment
" id="div_dopayment_paypal
">';
2151 if (getDolGlobalString('PAYPAL_API_INTEGRAL_OR_PAYPALONLY') != 'integral') {
2152 print '<div style="line-height: 1em
"> </div>';
2154 print '<span class="fab fa-paypal
"></span> <input class="" type="submit
" id="dopayment_paypal
" name="dopayment_paypal
" value="'.$langs->trans("PaypalDoPayment").'">';
2155 if (getDolGlobalString('PAYPAL_API_INTEGRAL_OR_PAYPALONLY') == 'integral') {
2157 print '<span class="buttonpaymentsmall
">'.$langs->trans("CreditOrDebitCard
").'</span><span class="buttonpaymentsmall
"> - </span>';
2158 print '<span class="buttonpaymentsmall
">'.$langs->trans("PayPalBalance
").'</span>';
2160 if (getDolGlobalString('PAYPAL_API_INTEGRAL_OR_PAYPALONLY') == 'paypalonly') {
2162 //print '<span class="buttonpaymentsmall
">'.$langs->trans("PayPalBalance
").'"></span>
';
2166 $( document ).ready(
function() {
2167 $(
"#div_dopayment_paypal").click(
function(){
2168 $(
"#dopayment_paypal").click();
2170 $(
"#dopayment_paypal").click(
function(e){
2171 $(
"#div_dopayment_paypal").css( \
'cursor\', \'wait\' );
2172 e.stopPropagation();
2187print
'</td></tr>'.
"\n";
2189print
'</table>'.
"\n";
2191print
'</form>'.
"\n";
2199if (preg_match(
'/^dopayment/', $action)) {
2202 $_SESSION[
"currencyCodeType"] = $currency;
2203 $_SESSION[
"FinalPaymentAmt"] = $amount;
2204 $_SESSION[
'ipaddress'] = ($remoteip ? $remoteip :
'unknown');
2205 $_SESSION[
"paymentType"] =
'';
2208 if (
GETPOST(
'dopayment_stripe',
'alpha')) {
2216 background-color: white;
2219 border: 1px solid transparent;
2220 box-shadow: 0 1px 3px 0 #e6ebf1;
2221 -webkit-transition: box-shadow 150ms ease;
2222 transition: box-shadow 150ms ease;
2225 .StripeElement--focus {
2226 box-shadow: 0 1px 3px 0 #cfd7df;
2229 .StripeElement--invalid {
2230 border-color: #fa755a;
2233 .StripeElement--webkit-autofill {
2234 background-color: #fefde5 !important;
2240 print
'<!-- Show Stripe form payment-form STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION = ' .
getDolGlobalString(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION').
' STRIPE_USE_NEW_CHECKOUT = ' .
getDolGlobalString(
'STRIPE_USE_NEW_CHECKOUT').
' -->'.
"\n";
2241 print
'<form action="'.$_SERVER[
'REQUEST_URI'].
'" method="POST" id="payment-form">'.
"\n";
2243 print
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
2244 print
'<input type="hidden" name="dopayment_stripe" value="1">'.
"\n";
2245 print
'<input type="hidden" name="action" value="charge">'.
"\n";
2246 print
'<input type="hidden" name="tag" value="'.$TAG.
'">'.
"\n";
2247 print
'<input type="hidden" name="s" value="'.$source.
'">'.
"\n";
2248 print
'<input type="hidden" name="ref" value="'.$REF.
'">'.
"\n";
2249 print
'<input type="hidden" name="fulltag" value="'.$FULLTAG.
'">'.
"\n";
2250 print
'<input type="hidden" name="suffix" value="'.$suffix.
'">'.
"\n";
2251 print
'<input type="hidden" name="securekey" value="'.$SECUREKEY.
'">'.
"\n";
2252 print
'<input type="hidden" name="e" value="'.$entity.
'" />';
2253 print
'<input type="hidden" name="amount" value="'.$amount.
'">'.
"\n";
2254 print
'<input type="hidden" name="currency" value="'.$currency.
'">'.
"\n";
2255 print
'<input type="hidden" name="forcesandbox" value="'.GETPOST(
'forcesandbox',
'int').
'" />';
2256 print
'<input type="hidden" name="email" value="'.GETPOST(
'email',
'alpha').
'" />';
2257 print
'<input type="hidden" name="thirdparty_id" value="'.GETPOST(
'thirdparty_id',
'int').
'" />';
2258 print
'<input type="hidden" name="lang" value="'.$getpostlang.
'">';
2261 require_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
2263 $service =
'StripeLive';
2266 $service =
'StripeTest';
2270 $stripe =
new Stripe($db);
2271 $stripeacc = $stripe->getStripeAccount($service);
2273 if (is_object($object) && is_object($object->thirdparty)) {
2274 $stripecu = $stripe->customerStripe($object->thirdparty, $stripeacc, $servicestatus, 1);
2278 $noidempotency_key = (GETPOSTISSET(
'noidempotency') ?
GETPOST(
'noidempotency',
'int') : 0);
2279 $paymentintent = $stripe->getPaymentIntent($amount, $currency, ($tag ? $tag : $fulltag),
'Stripe payment: '.$fulltag.(is_object($object) ?
' ref='.$object->
ref :
''), $object, $stripecu, $stripeacc, $servicestatus, 0,
'automatic', false, null, 0, $noidempotency_key);
2282 if ($stripe->error) {
2293 <table id="dolpaymenttable" summary="Payment form" class="center centpercent">
2294 <tbody><tr><td class="textpublicpayment">';
2297 print
'<div id="payment-request-button"><!-- A Stripe Element will be inserted here. --></div>';
2300 print
'<div class="form-row '.(getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 2 ?
'center' :
'left').
'">';
2301 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 1) {
2302 print
'<label for="card-element">'.$langs->trans(
"CreditOrDebitCard").
'</label>';
2303 print
'<br><input id="cardholder-name" class="marginbottomonly" name="cardholder-name" value="" type="text" placeholder="'.$langs->trans(
"CardOwner").
'" autocomplete="off" autofocus required>';
2306 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 1) {
2307 print
'<div id="card-element">
2308 <!-- a Stripe Element will be inserted here. -->
2311 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 2) {
2312 print
'<div id="payment-element">
2313 <!-- a Stripe Element will be inserted here. -->
2317 print
'<!-- Used to display form errors -->
2318 <div id="card-errors" role="alert"></div>
2322 print
'<button class="button buttonpayment" style="text-align: center; padding-left: 0; padding-right: 0;" id="buttontopay" data-secret="'.(is_object($paymentintent) ? $paymentintent->client_secret :
'').
'">'.$langs->trans(
"ValidatePayment").
'</button>';
2323 print
'<img id="hourglasstopay" class="hidden" src="'.DOL_URL_ROOT.
'/theme/'.$conf->theme.
'/img/working.gif">';
2325 print
'</td></tr></tbody>';
2330 if (empty($paymentintent)) {
2331 print
'<center>'.$langs->trans(
"Error").
'</center>';
2333 print
'<input type="hidden" name="paymentintent_id" value="'.$paymentintent->id.
'">';
2338 print
'</form>'.
"\n";
2342 if (empty($stripearrayofkeys[
'publishable_key'])) {
2343 $langs->load(
"errors");
2344 print
info_admin($langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv(
"Stripe")), 0, 0,
'error');
2346 print
'<!-- JS Code for Stripe components -->';
2347 print
'<script src="https://js.stripe.com/v3/"></script>'.
"\n";
2348 print
'<!-- urllogofull = '.$urllogofull.
' -->'.
"\n";
2351 print
'<script type="text/javascript">'.
"\n";
2354 $amountstripe = $amount;
2358 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
2359 if (!in_array($currency, $arrayzerounitcurrency)) {
2360 $amountstripe = $amountstripe * 100;
2364 $metadata = array(
'dol_version'=>DOL_VERSION,
'dol_entity'=>$conf->entity,
'ipaddress'=>$ipaddress);
2365 if (is_object($object)) {
2366 $metadata[
'dol_type'] = $object->element;
2367 $metadata[
'dol_id'] = $object->id;
2369 $ref = $object->ref;
2373 $arrayforpaymentintent = array(
2374 'description'=>
'Stripe payment: '.$FULLTAG.($ref ?
' ref='.$ref :
''),
2375 "metadata" => $metadata
2378 $arrayforpaymentintent[
"statement_descriptor"] =
dol_trunc($TAG, 10,
'right',
'UTF-8', 1);
2381 $arrayforcheckout = array(
2382 'payment_method_types' => array(
'card'),
2383 'line_items' => array(array(
2384 'price_data' => array(
2385 'currency' => $currency,
2386 'unit_amount' => $amountstripe,
2387 'product_data' => array(
2388 'name' => $langs->transnoentitiesnoconv(
"Payment").
' '.$TAG,
2389 'description' =>
'Stripe payment: '.$FULLTAG.($ref ?
' ref='.$ref :
''),
2395 'mode' =>
'payment',
2396 'client_reference_id' => $FULLTAG,
2397 'success_url' => $urlok,
2398 'cancel_url' => $urlko,
2399 'payment_intent_data' => $arrayforpaymentintent
2402 $arrayforcheckout[
'customer'] = $stripecu;
2404 $arrayforcheckout[
'customer_email'] =
GETPOST(
'email',
'alpha');
2406 $sessionstripe = \Stripe\Checkout\Session::create($arrayforcheckout);
2411 $_SESSION[
"currencyCodeType"] = $currency;
2412 $_SESSION[
"paymentType"] =
'';
2413 $_SESSION[
"FinalPaymentAmt"] = $amount;
2414 $_SESSION[
'ipaddress'] = ($remoteip ? $remoteip :
'unknown');
2415 $_SESSION[
'payerID'] = is_object($stripecu) ? $stripecu->id :
'';
2416 $_SESSION[
'TRANSACTIONID'] = $sessionstripe->id;
2418 print $e->getMessage();
2424 if (empty($stripeacc)) {
2426 var stripe =
Stripe(
'<?php echo $stripearrayofkeys['publishable_key
']; // Defined into config.php?>');
2430 var stripe =
Stripe(
'<?php echo $stripearrayofkeys['publishable_key
']; // Defined into config.php?>', { stripeAccount:
'<?php echo $stripeacc; ?>' });
2435 var elements = stripe.elements();
2443 fontFamily:
'"Helvetica Neue", Helvetica, sans-serif',
2444 fontSmoothing:
'antialiased',
2452 iconColor:
'#fa755a'
2456 var cardElement = elements.create(
'card', {style: style});
2459 stripe.redirectToCheckout({
2463 sessionId:
'<?php print $sessionstripe->id; ?>'
2464 }).then(
function (result) {
2478 if (empty($stripeacc)) {
2480 var stripe =
Stripe(
'<?php echo $stripearrayofkeys['publishable_key
']; // Defined into config.php?>');
2484 var stripe =
Stripe(
'<?php echo $stripearrayofkeys['publishable_key
']; // Defined into config.php?>', { stripeAccount:
'<?php echo $stripeacc; ?>' });
2489 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 2) {
2491 var cardButton = document.getElementById(
'buttontopay');
2492 var clientSecret = cardButton.dataset.secret;
2493 var options = { clientSecret: clientSecret };
2496 var elements = stripe.elements(options);
2501 var elements = stripe.elements();
2511 fontFamily:
'"Helvetica Neue", Helvetica, sans-serif',
2512 fontSmoothing:
'antialiased',
2520 iconColor:
'#fa755a'
2525 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 2) {
2527 var paymentElement = elements.create(
"payment");
2530 paymentElement.mount(
"#payment-element");
2533 var cardButton = document.getElementById(
'buttontopay');
2535 cardButton.addEventListener(
'click',
function(event) {
2536 console.log(
"We click on buttontopay");
2537 event.preventDefault();
2540 jQuery(
'#hourglasstopay').show();
2541 jQuery(
'#buttontopay').hide();
2543 stripe.confirmPayment({
2544 elements,confirmParams: {
2545 return_url:
'<?php echo $urlok; ?>',
2546 payment_method_data: {
2549 <?php
if (
GETPOST(
'email',
'alpha') || (is_object($object) && is_object($object->thirdparty) && !empty($object->thirdparty->email))) {
2550 ?>, email:
'<?php echo dol_escape_js(GETPOST('email
', 'alpha
') ? GETPOST('email
', 'alpha
') : $object->thirdparty->email); ?>'<?php
2552 <?php
if (is_object($object) && is_object($object->thirdparty) && !empty($object->thirdparty->phone)) {
2553 ?>, phone:
'<?php echo dol_escape_js($object->thirdparty->phone); ?>'<?php
2555 <?php
if (is_object($object) && is_object($object->thirdparty)) {
2557 city:
'<?php echo dol_escape_js($object->thirdparty->town); ?>',
2558 <?php if ($object->thirdparty->country_code) {
2559 ?>country:
'<?php echo dol_escape_js($object->thirdparty->country_code); ?>',<?php
2561 line1:
'<?php echo dol_escape_js(preg_replace('/\s\s+/
', ' ', $object->thirdparty->address)); ?>',
2562 postal_code:
'<?php echo dol_escape_js($object->thirdparty->zip); ?>'
2568 save_payment_method:<?php
if ($stripecu) {
2575 ).then(
function(result) {
2576 console.log(result);
2578 console.log(
"Error on result of handleCardPayment");
2579 jQuery(
'#buttontopay').show();
2580 jQuery(
'#hourglasstopay').hide();
2582 var errorElement = document.getElementById(
'card-errors');
2583 console.log(result);
2584 errorElement.textContent = result.error.message;
2587 console.log(
"No error on result of handleCardPayment, so we submit the form");
2589 jQuery(
'#buttontopay').hide();
2590 jQuery(
'#hourglasstopay').show();
2592 jQuery(
'#payment-form').submit();
2600 var cardElement = elements.create(
'card', {style: style});
2603 cardElement.mount(
'#card-element');
2606 cardElement.addEventListener(
'change',
function(event) {
2607 var displayError = document.getElementById(
'card-errors');
2609 console.log(
"Show event error (like 'Incorrect card number', ...)");
2610 displayError.textContent =
event.error.message;
2612 console.log(
"Reset error message");
2613 displayError.textContent =
'';
2618 var cardholderName = document.getElementById(
'cardholder-name');
2619 var cardButton = document.getElementById(
'buttontopay');
2620 var clientSecret = cardButton.dataset.secret;
2622 cardButton.addEventListener(
'click',
function(event) {
2623 console.log(
"We click on buttontopay");
2624 event.preventDefault();
2626 if (cardholderName.value ==
'')
2628 console.log(
"Field Card holder is empty");
2629 var displayError = document.getElementById(
'card-errors');
2630 displayError.textContent =
'<?php print dol_escape_js($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardOwner"))); ?>';
2635 jQuery(
'#hourglasstopay').show();
2636 jQuery(
'#buttontopay').hide();
2638 stripe.handleCardPayment(
2639 clientSecret, cardElement, {
2640 payment_method_data: {
2642 name: cardholderName.value
2643 <?php
if (
GETPOST(
'email',
'alpha') || (is_object($object) && is_object($object->thirdparty) && !empty($object->thirdparty->email))) {
2644 ?>, email:
'<?php echo dol_escape_js(GETPOST('email
', 'alpha
') ? GETPOST('email
', 'alpha
') : $object->thirdparty->email); ?>'<?php
2646 <?php
if (is_object($object) && is_object($object->thirdparty) && !empty($object->thirdparty->phone)) {
2647 ?>, phone:
'<?php echo dol_escape_js($object->thirdparty->phone); ?>'<?php
2649 <?php
if (is_object($object) && is_object($object->thirdparty)) {
2651 city:
'<?php echo dol_escape_js($object->thirdparty->town); ?>',
2652 <?php if ($object->thirdparty->country_code) {
2653 ?>country:
'<?php echo dol_escape_js($object->thirdparty->country_code); ?>',<?php
2655 line1:
'<?php echo dol_escape_js(preg_replace('/\s\s+/
', ' ', $object->thirdparty->address)); ?>',
2656 postal_code:
'<?php echo dol_escape_js($object->thirdparty->zip); ?>'
2662 save_payment_method:<?php
if ($stripecu) {
2668 ).then(
function(result) {
2669 console.log(result);
2671 console.log(
"Error on result of handleCardPayment");
2672 jQuery(
'#buttontopay').show();
2673 jQuery(
'#hourglasstopay').hide();
2675 var errorElement = document.getElementById(
'card-errors');
2676 errorElement.textContent = result.error.message;
2679 console.log(
"No error on result of handleCardPayment, so we submit the form");
2681 jQuery(
'#buttontopay').hide();
2682 jQuery(
'#hourglasstopay').show();
2684 jQuery(
'#payment-form').submit();
2702 'paymentmethod' => $paymentmethod,
2703 'amount' => $amount,
2704 'currency' => $currency,
2705 'tag' =>
GETPOST(
"tag",
'alpha'),
2706 'dopayment' =>
GETPOST(
'dopayment',
'alpha')
2708 $reshook = $hookmanager->executeHooks(
'doPayment', $parameters, $object, $action);
2711 } elseif ($reshook > 0) {
2712 print $hookmanager->resPrint;
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage members of a foundation.
Class to manage members type.
Class to manage customers orders.
Class for ConferenceOrBoothAttendee.
Class to manage contracts.
Class to manage lines of contracts.
Class to manage invoices.
Class to manage payments of donations.
Class to manage products or services.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage subscriptions of foundation members.
htmlPrintOnlineFooter($fromcompany, $langs, $addformmessage=0, $suffix='', $object=null)
Show footer of company in HTML pages.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
img_mime($file, $titlealt='', $morecss='')
Show MIME img of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
dol_string_unaccent($str)
Clean a string from all accent characters to be used as ref, login or by dol_sanitizeFileName.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_print_error_email($prefixcode, $errormessage='', $errormessages=array(), $morecss='error', $email='')
Show a public email and error code to contact if technical error.
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formated messages to output (Used to show messages on html output).
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
getUserRemoteIP()
Return the IP of remote user.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
ui dialog ui datepicker calendar ui widget content ui state ui datepicker calendar ui widget header ui state ui datepicker calendar ui button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
print_paybox_redirect($PRICE, $CURRENCY, $EMAIL, $urlok, $urlko, $TAG)
Create a redirect form to paybox form.
print_paypal_redirect($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $tag)
Send redirect to paypal to browser.
$conf db name
Only used if Module[ID]Name translation string is not found.
dol_verifyHash($chain, $hash, $type='0')
Compute a hash and compare it to the given one For backward compatibility reasons,...