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)) {
271 if (empty($PAYPAL_API_PASSWORD)) {
272 dol_print_error(
'',
"Paypal setup param PAYPAL_API_PASSWORD not defined");
275 if (empty($PAYPAL_API_SIGNATURE)) {
276 dol_print_error(
'',
"Paypal setup param PAYPAL_API_SIGNATURE not defined");
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';
297if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
299 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
300 if ($tmpsource && $REF) {
302 $tokenisok =
dol_verifyHash($conf->global->PAYMENT_SECURITY_TOKEN.$tmpsource.$REF, $SECUREKEY,
'2');
304 if ($tmpsource != $source) {
305 $tokenisok =
dol_verifyHash($conf->global->PAYMENT_SECURITY_TOKEN.$source.$REF, $SECUREKEY,
'2');
308 $tokenisok =
dol_verifyHash($conf->global->PAYMENT_SECURITY_TOKEN, $SECUREKEY,
'2');
311 $tokenisok = ($conf->global->PAYMENT_SECURITY_TOKEN == $SECUREKEY);
315 if (empty($conf->global->PAYMENT_SECURITY_ACCEPT_ANY_TOKEN)) {
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';
534 if (!empty($conf->global->STRIPE_LIVE) && !
GETPOST(
'forcesandbox',
'int')) {
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';
733 if (!empty($conf->global->STRIPE_LIVE) && !
GETPOST(
'forcesandbox',
'int')) {
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);
840if (!empty($conf->global->ONLINE_PAYMENT_CSS_URL)) {
841 $head =
'<link rel="stylesheet" type="text/css" href="'.$conf->global->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') && (!empty($conf->global->PAYPAL_API_SANDBOX) ||
GETPOST(
'forcesandbox',
'int'))) {
868 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Paypal'),
'',
'warning');
870if ((empty($paymentmethod) || $paymentmethod ==
'stripe') && isModEnabled(
'stripe') && (empty($conf->global->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;
896} elseif (!empty($conf->global->ONLINE_PAYMENT_LOGO)) {
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.
'"';
918 if (empty($conf->global->MAIN_HIDE_POWERED_BY)) {
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>';
923if (!empty($conf->global->MAIN_IMAGE_PUBLIC_PAYMENT)) {
924 print
'<div class="backimagepublicpayment">';
925 print
'<img id="idMAIN_IMAGE_PUBLIC_PAYMENT" src="'.$conf->global->MAIN_IMAGE_PUBLIC_PAYMENT.
'">';
932print
'<!-- Form to send a payment -->'.
"\n";
933print
'<!-- creditor = '.dol_escape_htmltag($creditor).
' -->'.
"\n";
935if (isModEnabled(
'paypal')) {
936 print
'<!-- PAYPAL_API_SANDBOX = '.getDolGlobalString(
'PAYPAL_API_SANDBOX').
' -->'.
"\n";
937 print
'<!-- PAYPAL_API_INTEGRAL_OR_PAYPALONLY = '.getDolGlobalString(
'PAYPAL_API_INTEGRAL_OR_PAYPALONLY').
' -->'.
"\n";
939if (isModEnabled(
'paybox')) {
940 print
'<!-- PAYBOX_CGI_URL = '.getDolGlobalString(
'PAYBOX_CGI_URL_V2').
' -->'.
"\n";
942if (isModEnabled(
'stripe')) {
943 print
'<!-- STRIPE_LIVE = '.getDolGlobalString(
'STRIPE_LIVE').
' -->'.
"\n";
945print
'<!-- urlok = '.$urlok.
' -->'.
"\n";
946print
'<!-- urlko = '.$urlko.
' -->'.
"\n";
950print
'<table id="dolpublictable" summary="Payment form" class="center">'.
"\n";
954if (!empty($conf->global->PAYMENT_NEWFORM_TEXT)) {
955 $langs->load(
"members");
956 if (preg_match(
'/^\((.*)\)$/', $conf->global->PAYMENT_NEWFORM_TEXT, $reg)) {
957 $text .= $langs->trans($reg[1]).
"<br>\n";
959 $text .= $conf->global->PAYMENT_NEWFORM_TEXT.
"<br>\n";
961 $text =
'<tr><td align="center"><br>'.$text.
'<br></td></tr>'.
"\n";
964 $text .=
'<tr><td class="textpublicpayment"><br><strong>'.$langs->trans(
"WelcomeOnPaymentPage").
'</strong></td></tr>'.
"\n";
965 $text .=
'<tr><td class="textpublicpayment">'.$langs->trans(
"ThisScreenAllowsYouToPay", $creditor).
'<br><br></td></tr>'.
"\n";
970print
'<tr><td align="center">';
971print
'<table with="100%" id="tablepublicpayment">';
972print
'<tr><td align="left" colspan="2" class="opacitymedium">'.$langs->trans(
"ThisIsInformationOnPayment").
' :</td></tr>'.
"\n";
983 $tag =
GETPOST(
"tag",
'alpha');
984 if (
GETPOST(
'fulltag',
'alpha')) {
985 $fulltag =
GETPOST(
'fulltag',
'alpha');
987 $fulltag =
"TAG=".$tag;
991 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
992 print
'</td><td class="CTableRow2">';
993 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
994 print
'<b>'.$creditor.
'</b>';
995 print
'<input type="hidden" name="creditor" value="'.$creditor.
'">';
996 print
'</td></tr>'.
"\n";
999 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Amount");
1000 if (empty($amount)) {
1001 print
' ('.$langs->trans(
"ToComplete").
')';
1003 print
'</td><td class="CTableRow2">';
1004 if (empty($amount) || !is_numeric($amount)) {
1005 print
'<input type="hidden" name="amount" value="'.price2num(
GETPOST(
"amount",
'alpha'),
'MT').
'">';
1006 print
'<input class="flat maxwidth75" type="text" name="newamount" value="'.price2num(
GETPOST(
"newamount",
"alpha"),
'MT').
'">';
1008 print
' <b>'.$langs->trans(
"Currency".$currency).
'</b>';
1010 print
'<b class="amount">'.price($amount, 1, $langs, 1, -1, -1, $currency).
'</b>';
1011 print
'<input type="hidden" name="amount" value="'.$amount.
'">';
1012 print
'<input type="hidden" name="newamount" value="'.$amount.
'">';
1014 print
'<input type="hidden" name="currency" value="'.$currency.
'">';
1015 print
'</td></tr>'.
"\n";
1018 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentCode");
1019 print
'</td><td class="CTableRow2"><b style="word-break: break-all;">'.$fulltag.
'</b>';
1020 print
'<input type="hidden" name="tag" value="'.$tag.
'">';
1021 print
'<input type="hidden" name="fulltag" value="'.$fulltag.
'">';
1022 print
'</td></tr>'.
"\n";
1030if ($source ==
'order') {
1032 $langs->load(
"orders");
1034 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
1037 $result = $order->fetch(
'', $ref);
1039 $mesg = $order->error;
1042 $result = $order->fetch_thirdparty($order->socid);
1046 if ($action !=
'dopayment') {
1047 $amount = $order->total_ttc;
1048 if (
GETPOST(
"amount",
'alpha')) {
1049 $amount =
GETPOST(
"amount",
'alpha');
1055 if (
GETPOST(
'fulltag',
'alpha')) {
1056 $fulltag =
GETPOST(
'fulltag',
'alpha');
1058 $fulltag =
'ORD='.$order->id.
'.CUS='.$order->thirdparty->id;
1060 $tag = $TAG; $fulltag .=
'.TAG='.$TAG;
1066 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
1067 print
'</td><td class="CTableRow2">';
1068 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1069 print
'<b>'.$creditor.
'</b>';
1070 print
'<input type="hidden" name="creditor" value="'.$creditor.
'">';
1071 print
'</td></tr>'.
"\n";
1074 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"ThirdParty");
1075 print
'</td><td class="CTableRow2">';
1076 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1077 print
'<b>'.$order->thirdparty->name.
'</b>';
1078 print
'</td></tr>'.
"\n";
1081 $text =
'<b>'.$langs->trans(
"PaymentOrderRef", $order->ref).
'</b>';
1082 if (
GETPOST(
'desc',
'alpha')) {
1083 $text =
'<b>'.$langs->trans(
GETPOST(
'desc',
'alpha')).
'</b>';
1085 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Designation");
1086 print
'</td><td class="CTableRow2">'.$text;
1087 print
'<input type="hidden" name="s" value="'.dol_escape_htmltag($source).
'">';
1088 print
'<input type="hidden" name="ref" value="'.dol_escape_htmltag($order->ref).
'">';
1089 print
'<input type="hidden" name="dol_id" value="'.dol_escape_htmltag($order->id).
'">';
1090 $directdownloadlink = $order->getLastMainDocLink(
'commande');
1091 if ($directdownloadlink) {
1092 print
'<br><a href="'.$directdownloadlink.
'" rel="nofollow noopener">';
1093 print
img_mime($order->last_main_doc,
'');
1094 print $langs->trans(
"DownloadDocument").
'</a>';
1096 print
'</td></tr>'.
"\n";
1099 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Amount");
1100 if (empty($amount)) {
1101 print
' ('.$langs->trans(
"ToComplete").
')';
1103 print
'</td><td class="CTableRow2">';
1104 if (empty($amount) || !is_numeric($amount)) {
1105 print
'<input type="hidden" name="amount" value="'.price2num(
GETPOST(
"amount",
'alpha'),
'MT').
'">';
1106 print
'<input class="flat maxwidth75" type="text" name="newamount" value="'.price2num(
GETPOST(
"newamount",
"alpha"),
'MT').
'">';
1108 print
' <b>'.$langs->trans(
"Currency".$currency).
'</b>';
1110 print
'<b class="amount">'.price($amount, 1, $langs, 1, -1, -1, $currency).
'</b>';
1111 print
'<input type="hidden" name="amount" value="'.$amount.
'">';
1112 print
'<input type="hidden" name="newamount" value="'.$amount.
'">';
1114 print
'<input type="hidden" name="currency" value="'.$currency.
'">';
1115 print
'</td></tr>'.
"\n";
1118 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentCode");
1119 print
'</td><td class="CTableRow2"><b style="word-break: break-all;">'.$fulltag.
'</b>';
1120 print
'<input type="hidden" name="tag" value="'.dol_escape_htmltag($tag).
'">';
1121 print
'<input type="hidden" name="fulltag" value="'.dol_escape_htmltag($fulltag).
'">';
1122 print
'</td></tr>'.
"\n";
1125 $shipToName = $order->thirdparty->name;
1126 $shipToStreet = $order->thirdparty->address;
1127 $shipToCity = $order->thirdparty->town;
1128 $shipToState = $order->thirdparty->state_code;
1129 $shipToCountryCode = $order->thirdparty->country_code;
1130 $shipToZip = $order->thirdparty->zip;
1131 $shipToStreet2 =
'';
1132 $phoneNum = $order->thirdparty->phone;
1133 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1134 print
'<input type="hidden" name="shipToName" value="'.dol_escape_htmltag($shipToName).
'">'.
"\n";
1135 print
'<input type="hidden" name="shipToStreet" value="'.dol_escape_htmltag($shipToStreet).
'">'.
"\n";
1136 print
'<input type="hidden" name="shipToCity" value="'.dol_escape_htmltag($shipToCity).
'">'.
"\n";
1137 print
'<input type="hidden" name="shipToState" value="'.dol_escape_htmltag($shipToState).
'">'.
"\n";
1138 print
'<input type="hidden" name="shipToCountryCode" value="'.dol_escape_htmltag($shipToCountryCode).
'">'.
"\n";
1139 print
'<input type="hidden" name="shipToZip" value="'.dol_escape_htmltag($shipToZip).
'">'.
"\n";
1140 print
'<input type="hidden" name="shipToStreet2" value="'.dol_escape_htmltag($shipToStreet2).
'">'.
"\n";
1141 print
'<input type="hidden" name="phoneNum" value="'.dol_escape_htmltag($phoneNum).
'">'.
"\n";
1143 print
'<!-- Shipping address not complete, so we don t use it -->'.
"\n";
1145 if (is_object($order->thirdparty)) {
1146 print
'<input type="hidden" name="thirdparty_id" value="'.$order->thirdparty->id.
'">'.
"\n";
1148 print
'<input type="hidden" name="email" value="'.$order->thirdparty->email.
'">'.
"\n";
1149 print
'<input type="hidden" name="vatnumber" value="'.dol_escape_htmltag($order->thirdparty->tva_intra).
'">'.
"\n";
1150 $labeldesc = $langs->trans(
"Order").
' '.$order->ref;
1151 if (
GETPOST(
'desc',
'alpha')) {
1152 $labeldesc =
GETPOST(
'desc',
'alpha');
1154 print
'<input type="hidden" name="desc" value="'.dol_escape_htmltag($labeldesc).
'">'.
"\n";
1159if ($source ==
'invoice') {
1161 $langs->load(
"bills");
1163 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1166 $result = $invoice->fetch(
'', $ref);
1168 $mesg = $invoice->error;
1171 $result = $invoice->fetch_thirdparty($invoice->socid);
1175 if ($action !=
'dopayment') {
1176 $amount =
price2num($invoice->total_ttc - ($invoice->getSommePaiement() + $invoice->getSumCreditNotesUsed() + $invoice->getSumDepositsUsed()));
1177 if (
GETPOST(
"amount",
'alpha')) {
1178 $amount =
GETPOST(
"amount",
'alpha');
1183 if (
GETPOST(
'fulltag',
'alpha')) {
1184 $fulltag =
GETPOST(
'fulltag',
'alpha');
1186 $fulltag =
'INV='.$invoice->id.
'.CUS='.$invoice->thirdparty->id;
1188 $tag = $TAG; $fulltag .=
'.TAG='.$TAG;
1194 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
1195 print
'</td><td class="CTableRow2">';
1196 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1197 print
'<b>'.$creditor.
'</b>';
1198 print
'<input type="hidden" name="creditor" value="'.dol_escape_htmltag($creditor).
'">';
1199 print
'</td></tr>'.
"\n";
1202 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"ThirdParty");
1203 print
'</td><td class="CTableRow2">';
1204 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1205 print
'<b>'.$invoice->thirdparty->name.
'</b>';
1206 print
'</td></tr>'.
"\n";
1209 $text =
'<b>'.$langs->trans(
"PaymentInvoiceRef", $invoice->ref).
'</b>';
1210 if (
GETPOST(
'desc',
'alpha')) {
1211 $text =
'<b>'.$langs->trans(
GETPOST(
'desc',
'alpha')).
'</b>';
1213 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Designation");
1214 print
'</td><td class="CTableRow2">'.$text;
1215 print
'<input type="hidden" name="s" value="'.dol_escape_htmltag($source).
'">';
1216 print
'<input type="hidden" name="ref" value="'.dol_escape_htmltag($invoice->ref).
'">';
1217 print
'<input type="hidden" name="dol_id" value="'.dol_escape_htmltag($invoice->id).
'">';
1218 $directdownloadlink = $invoice->getLastMainDocLink(
'facture');
1219 if ($directdownloadlink) {
1220 print
'<br><a href="'.$directdownloadlink.
'">';
1221 print
img_mime($invoice->last_main_doc,
'');
1222 print $langs->trans(
"DownloadDocument").
'</a>';
1224 print
'</td></tr>'.
"\n";
1227 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentAmount");
1228 if (empty($amount) && empty($object->paye)) {
1229 print
' ('.$langs->trans(
"ToComplete").
')';
1231 print
'</td><td class="CTableRow2">';
1232 if ($object->type == $object::TYPE_CREDIT_NOTE) {
1233 print
'<b>'.$langs->trans(
"CreditNote").
'</b>';
1234 } elseif (empty($object->paye)) {
1235 if (empty($amount) || !is_numeric($amount)) {
1236 print
'<input type="hidden" name="amount" value="'.price2num(
GETPOST(
"amount",
'alpha'),
'MT').
'">';
1237 print
'<input class="flat maxwidth75" type="text" name="newamount" value="'.price2num(
GETPOST(
"newamount",
"alpha"),
'MT').
'">';
1238 print
' <b>'.$langs->trans(
"Currency".$currency).
'</b>';
1240 print
'<b class="amount">'.price($amount, 1, $langs, 1, -1, -1, $currency).
'</b>';
1241 print
'<input type="hidden" name="amount" value="'.$amount.
'">';
1242 print
'<input type="hidden" name="newamount" value="'.$amount.
'">';
1245 print
'<b class="amount">'.price($object->total_ttc, 1, $langs, 1, -1, -1, $currency).
'</b>';
1247 print
'<input type="hidden" name="currency" value="'.$currency.
'">';
1248 print
'</td></tr>'.
"\n";
1251 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentCode");
1252 print
'</td><td class="CTableRow2"><b style="word-break: break-all;">'.$fulltag.
'</b>';
1253 print
'<input type="hidden" name="tag" value="'.$tag.
'">';
1254 print
'<input type="hidden" name="fulltag" value="'.$fulltag.
'">';
1255 print
'</td></tr>'.
"\n";
1258 $shipToName = $invoice->thirdparty->name;
1259 $shipToStreet = $invoice->thirdparty->address;
1260 $shipToCity = $invoice->thirdparty->town;
1261 $shipToState = $invoice->thirdparty->state_code;
1262 $shipToCountryCode = $invoice->thirdparty->country_code;
1263 $shipToZip = $invoice->thirdparty->zip;
1264 $shipToStreet2 =
'';
1265 $phoneNum = $invoice->thirdparty->phone;
1266 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1267 print
'<input type="hidden" name="shipToName" value="'.$shipToName.
'">'.
"\n";
1268 print
'<input type="hidden" name="shipToStreet" value="'.$shipToStreet.
'">'.
"\n";
1269 print
'<input type="hidden" name="shipToCity" value="'.$shipToCity.
'">'.
"\n";
1270 print
'<input type="hidden" name="shipToState" value="'.$shipToState.
'">'.
"\n";
1271 print
'<input type="hidden" name="shipToCountryCode" value="'.$shipToCountryCode.
'">'.
"\n";
1272 print
'<input type="hidden" name="shipToZip" value="'.$shipToZip.
'">'.
"\n";
1273 print
'<input type="hidden" name="shipToStreet2" value="'.$shipToStreet2.
'">'.
"\n";
1274 print
'<input type="hidden" name="phoneNum" value="'.$phoneNum.
'">'.
"\n";
1276 print
'<!-- Shipping address not complete, so we don t use it -->'.
"\n";
1278 if (is_object($invoice->thirdparty)) {
1279 print
'<input type="hidden" name="thirdparty_id" value="'.$invoice->thirdparty->id.
'">'.
"\n";
1281 print
'<input type="hidden" name="email" value="'.$invoice->thirdparty->email.
'">'.
"\n";
1282 print
'<input type="hidden" name="vatnumber" value="'.$invoice->thirdparty->tva_intra.
'">'.
"\n";
1283 $labeldesc = $langs->trans(
"Invoice").
' '.$invoice->ref;
1284 if (
GETPOST(
'desc',
'alpha')) {
1285 $labeldesc =
GETPOST(
'desc',
'alpha');
1287 print
'<input type="hidden" name="desc" value="'.dol_escape_htmltag($labeldesc).
'">'.
"\n";
1291if ($source ==
'contractline') {
1293 $langs->load(
"contracts");
1295 require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
1300 $result = $contractline->fetch(
'', $ref);
1302 $mesg = $contractline->error;
1305 if ($contractline->fk_contrat > 0) {
1306 $result = $contract->fetch($contractline->fk_contrat);
1308 $result = $contract->fetch_thirdparty($contract->socid);
1310 $mesg = $contract->error;
1314 $mesg =
'ErrorRecordNotFound';
1318 $object = $contractline;
1320 if ($action !=
'dopayment') {
1321 $amount = $contractline->total_ttc;
1323 if ($contractline->fk_product && !empty($conf->global->PAYMENT_USE_NEW_PRICE_FOR_CONTRACTLINES)) {
1325 $result = $product->fetch($contractline->fk_product);
1328 if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
1329 $pu_ht = $product->multiprices[$contract->thirdparty->price_level];
1330 $pu_ttc = $product->multiprices_ttc[$contract->thirdparty->price_level];
1331 $price_base_type = $product->multiprices_base_type[$contract->thirdparty->price_level];
1333 $pu_ht = $product->price;
1334 $pu_ttc = $product->price_ttc;
1335 $price_base_type = $product->price_base_type;
1339 if (empty($amount)) {
1345 if (
GETPOST(
"amount",
'alpha')) {
1346 $amount =
GETPOST(
"amount",
'alpha');
1351 if (
GETPOST(
'fulltag',
'alpha')) {
1352 $fulltag =
GETPOST(
'fulltag',
'alpha');
1354 $fulltag =
'COL='.$contractline->id.
'.CON='.$contract->id.
'.CUS='.$contract->thirdparty->id.
'.DAT='.
dol_print_date(
dol_now(),
'%Y%m%d%H%M%S');
1356 $tag = $TAG; $fulltag .=
'.TAG='.$TAG;
1367 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
1368 print
'</td><td class="CTableRow2"><b>'.$creditor.
'</b>';
1369 print
'<input type="hidden" name="creditor" value="'.$creditor.
'">';
1370 print
'</td></tr>'.
"\n";
1373 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"ThirdParty");
1374 print
'</td><td class="CTableRow2"><b>'.$contract->thirdparty->name.
'</b>';
1375 print
'</td></tr>'.
"\n";
1378 $text =
'<b>'.$langs->trans(
"PaymentRenewContractId", $contract->ref, $contractline->ref).
'</b>';
1379 if ($contractline->fk_product > 0) {
1380 $contractline->fetch_product();
1381 $text .=
'<br>'.$contractline->product->ref.($contractline->product->label ?
' - '.$contractline->product->label :
'');
1383 if ($contractline->description) {
1384 $text .=
'<br>'.dol_htmlentitiesbr($contractline->description);
1386 if ($contractline->date_end) {
1387 $text .=
'<br>'.$langs->trans(
"ExpiredSince").
': '.
dol_print_date($contractline->date_end);
1389 if (
GETPOST(
'desc',
'alpha')) {
1390 $text =
'<b>'.$langs->trans(
GETPOST(
'desc',
'alpha')).
'</b>';
1392 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Designation");
1393 print
'</td><td class="CTableRow2">'.$text;
1394 print
'<input type="hidden" name="source" value="'.dol_escape_htmltag($source).
'">';
1395 print
'<input type="hidden" name="ref" value="'.dol_escape_htmltag($contractline->ref).
'">';
1396 print
'<input type="hidden" name="dol_id" value="'.dol_escape_htmltag($contractline->id).
'">';
1397 $directdownloadlink = $contract->getLastMainDocLink(
'contract');
1398 if ($directdownloadlink) {
1399 print
'<br><a href="'.$directdownloadlink.
'">';
1400 print
img_mime($contract->last_main_doc,
'');
1401 print $langs->trans(
"DownloadDocument").
'</a>';
1403 print
'</td></tr>'.
"\n";
1406 $label = $langs->trans(
"Quantity");
1409 if ($contractline->fk_product) {
1410 if ($contractline->product->isService() && $contractline->product->duration_value > 0) {
1411 $label = $langs->trans(
"Duration");
1414 if ($contractline->product->duration_value > 1) {
1415 $dur = array(
"h"=>$langs->trans(
"Hours"),
"d"=>$langs->trans(
"DurationDays"),
"w"=>$langs->trans(
"DurationWeeks"),
"m"=>$langs->trans(
"DurationMonths"),
"y"=>$langs->trans(
"DurationYears"));
1417 $dur = array(
"h"=>$langs->trans(
"Hour"),
"d"=>$langs->trans(
"DurationDay"),
"w"=>$langs->trans(
"DurationWeek"),
"m"=>$langs->trans(
"DurationMonth"),
"y"=>$langs->trans(
"DurationYear"));
1419 $duration = $contractline->product->duration_value.
' '.$dur[$contractline->product->duration_unit];
1422 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$label.
'</td>';
1423 print
'<td class="CTableRow2"><b>'.($duration ? $duration : $qty).
'</b>';
1424 print
'<input type="hidden" name="newqty" value="'.dol_escape_htmltag($qty).
'">';
1425 print
'</b></td></tr>'.
"\n";
1428 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Amount");
1429 if (empty($amount)) {
1430 print
' ('.$langs->trans(
"ToComplete").
')';
1432 print
'</td><td class="CTableRow2">';
1433 if (empty($amount) || !is_numeric($amount)) {
1434 print
'<input type="hidden" name="amount" value="'.price2num(
GETPOST(
"amount",
'alpha'),
'MT').
'">';
1435 print
'<input class="flat maxwidth75" type="text" name="newamount" value="'.price2num(
GETPOST(
"newamount",
"alpha"),
'MT').
'">';
1437 print
' <b>'.$langs->trans(
"Currency".$currency).
'</b>';
1439 print
'<b class="amount">'.price($amount, 1, $langs, 1, -1, -1, $currency).
'</b>';
1440 print
'<input type="hidden" name="amount" value="'.$amount.
'">';
1441 print
'<input type="hidden" name="newamount" value="'.$amount.
'">';
1443 print
'<input type="hidden" name="currency" value="'.$currency.
'">';
1444 print
'</td></tr>'.
"\n";
1447 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentCode");
1448 print
'</td><td class="CTableRow2"><b style="word-break: break-all;">'.$fulltag.
'</b>';
1449 print
'<input type="hidden" name="tag" value="'.$tag.
'">';
1450 print
'<input type="hidden" name="fulltag" value="'.$fulltag.
'">';
1451 print
'</td></tr>'.
"\n";
1454 $shipToName = $contract->thirdparty->name;
1455 $shipToStreet = $contract->thirdparty->address;
1456 $shipToCity = $contract->thirdparty->town;
1457 $shipToState = $contract->thirdparty->state_code;
1458 $shipToCountryCode = $contract->thirdparty->country_code;
1459 $shipToZip = $contract->thirdparty->zip;
1460 $shipToStreet2 =
'';
1461 $phoneNum = $contract->thirdparty->phone;
1462 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1463 print
'<input type="hidden" name="shipToName" value="'.$shipToName.
'">'.
"\n";
1464 print
'<input type="hidden" name="shipToStreet" value="'.$shipToStreet.
'">'.
"\n";
1465 print
'<input type="hidden" name="shipToCity" value="'.$shipToCity.
'">'.
"\n";
1466 print
'<input type="hidden" name="shipToState" value="'.$shipToState.
'">'.
"\n";
1467 print
'<input type="hidden" name="shipToCountryCode" value="'.$shipToCountryCode.
'">'.
"\n";
1468 print
'<input type="hidden" name="shipToZip" value="'.$shipToZip.
'">'.
"\n";
1469 print
'<input type="hidden" name="shipToStreet2" value="'.$shipToStreet2.
'">'.
"\n";
1470 print
'<input type="hidden" name="phoneNum" value="'.$phoneNum.
'">'.
"\n";
1472 print
'<!-- Shipping address not complete, so we don t use it -->'.
"\n";
1474 if (is_object($contract->thirdparty)) {
1475 print
'<input type="hidden" name="thirdparty_id" value="'.$contract->thirdparty->id.
'">'.
"\n";
1477 print
'<input type="hidden" name="email" value="'.$contract->thirdparty->email.
'">'.
"\n";
1478 print
'<input type="hidden" name="vatnumber" value="'.$contract->thirdparty->tva_intra.
'">'.
"\n";
1479 $labeldesc = $langs->trans(
"Contract").
' '.$contract->ref;
1480 if (
GETPOST(
'desc',
'alpha')) {
1481 $labeldesc =
GETPOST(
'desc',
'alpha');
1483 print
'<input type="hidden" name="desc" value="'.dol_escape_htmltag($labeldesc).
'">'.
"\n";
1487if ($source ==
'member' || $source ==
'membersubscription') {
1488 $newsource =
'member';
1492 $langs->load(
"members");
1494 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
1495 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent_type.class.php';
1496 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
1501 $result = $member->fetch(
'', $ref);
1503 $mesg = $member->error;
1506 $member->fetch_thirdparty();
1509 $adht->fetch($member->typeid);
1513 if ($action !=
'dopayment') {
1514 $amount = $subscription->total_ttc;
1515 if (
GETPOST(
"amount",
'alpha')) {
1516 $amount =
GETPOST(
"amount",
'alpha');
1519 if (empty($amount)) {
1520 $amount = $adht->amount;
1523 $amount = max(0,
price2num($amount,
'MT'));
1526 if (
GETPOST(
'fulltag',
'alpha')) {
1527 $fulltag =
GETPOST(
'fulltag',
'alpha');
1531 $tag = $TAG; $fulltag .=
'.TAG='.$TAG;
1537 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
1538 print
'</td><td class="CTableRow2"><b>'.$creditor.
'</b>';
1539 print
'<input type="hidden" name="creditor" value="'.$creditor.
'">';
1540 print
'</td></tr>'.
"\n";
1543 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Member");
1544 print
'</td><td class="CTableRow2">';
1546 if ($member->morphy ==
'mor' && !empty($member->company)) {
1547 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1548 print $member->company;
1550 print
img_picto(
'',
'member',
'class="pictofixedwidth"');
1551 print $member->getFullName($langs);
1554 print
'</td></tr>'.
"\n";
1557 $text =
'<b>'.$langs->trans(
"PaymentSubscription").
'</b>';
1558 if (
GETPOST(
'desc',
'alpha')) {
1559 $text =
'<b>'.$langs->trans(
GETPOST(
'desc',
'alpha')).
'</b>';
1561 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Designation");
1562 print
'</td><td class="CTableRow2">'.$text;
1563 print
'<input type="hidden" name="source" value="'.dol_escape_htmltag($newsource).
'">';
1564 print
'<input type="hidden" name="ref" value="'.dol_escape_htmltag($member->ref).
'">';
1565 print
'</td></tr>'.
"\n";
1567 if ($object->datefin > 0) {
1568 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"DateEndSubscription");
1569 print
'</td><td class="CTableRow2">'.dol_print_date($member->datefin,
'day');
1570 print
'</td></tr>'.
"\n";
1573 if ($member->last_subscription_date || $member->last_subscription_amount) {
1576 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"LastSubscriptionDate");
1577 print
'</td><td class="CTableRow2">'.dol_print_date($member->last_subscription_date,
'day');
1578 print
'</td></tr>'.
"\n";
1582 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"LastSubscriptionAmount");
1583 print
'</td><td class="CTableRow2">'.price($member->last_subscription_amount);
1584 print
'</td></tr>'.
"\n";
1586 if (empty($amount) && !
GETPOST(
'newamount',
'alpha')) {
1587 $_GET[
'newamount'] = $member->last_subscription_amount;
1588 $_GET[
'amount'] = $member->last_subscription_amount;
1590 if (!empty($member->last_subscription_amount) && !GETPOSTISSET(
'newamount') && is_numeric($amount)) {
1591 $amount = max($member->last_subscription_amount, $amount);
1595 if ($member->type) {
1596 $oldtypeid = $member->typeid;
1597 $newtypeid = (int) (GETPOSTISSET(
"typeid") ?
GETPOST(
"typeid",
'int') : $member->typeid);
1599 if (!empty($conf->global->MEMBER_ALLOW_CHANGE_OF_TYPE)) {
1600 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent_type.class.php';
1603 $amountbytype = $adht->amountByType(1);
1606 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"LastMemberType");
1607 print
'</td><td class="CTableRow2">'.dol_escape_htmltag($member->type);
1608 print
"</td></tr>\n";
1611 $member->typeid = $newtypeid;
1612 $member->type =
dol_getIdFromCode($db, $newtypeid,
'adherent_type',
'rowid',
'libelle');
1617 $amount = (!empty($amountbytype[$member->typeid])) ? $amountbytype[$member->typeid] : $member->last_subscription_amount;
1619 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"NewSubscription");
1620 print
'</td><td class="CTableRow2">';
1621 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);
1622 print "</td></tr>\n
";
1623 } elseif ($action == 'dopayment') {
1624 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("NewMemberType
");
1625 print '</td><td class="CTableRow2
">'.dol_escape_htmltag($member->type);
1626 print '<input type="hidden
" name="membertypeid
" value="'.$member->typeid.'">';
1627 print "</td></tr>\n
";
1630 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("MemberType
");
1631 print '</td><td class="CTableRow2
">'.dol_escape_htmltag($member->type);
1632 print "</td></tr>\n
";
1637 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Amount
");
1638 // This place no longer allows amount edition
1639 if (!empty($conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO)) {
1640 print ' - <a href="'.$conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO.'" rel="external
" target="_blank
" rel="noopener noreferrer
">'.$langs->trans("SeeHere
").'</a>';
1642 print '</td><td class="CTableRow2
">';
1643 if (!empty($conf->global->MEMBER_MIN_AMOUNT) && $amount) {
1644 $amount = max(0, $conf->global->MEMBER_MIN_AMOUNT, $amount);
1646 $caneditamount = $adht->caneditamount;
1647 $minimumamount = empty($conf->global->MEMBER_MIN_AMOUNT)? $adht->amount : max($conf->global->MEMBER_MIN_AMOUNT, $adht->amount, $amount);
1649 if ($caneditamount && $action != 'dopayment') {
1650 if (GETPOSTISSET('newamount')) {
1651 print '<input type="text
" class="width75
" name="newamount
" value="'.price(price2num(GETPOST('newamount
'), '', 2), 1, $langs, 1, -1, -1).'">';
1653 print '<input type="text
" class="width75
" name="newamount
" value="'.price($amount, 1, $langs, 1, -1, -1).'">';
1656 print '<b class="amount
">'.price($amount, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
1657 if ($minimumamount > $amount) {
1658 print ' <span class="opacitymedium small
">'. $langs->trans("AmountIsLowerToMinimumNotice
", price($minimumamount, 1, $langs, 1, -1, -1, $currency)).'</span>';
1660 print '<input type="hidden
" name="newamount
" value="'.$amount.'">';
1662 print '<input type="hidden
" name="amount
" value="'.$amount.'">';
1663 print '<input type="hidden
" name="currency
" value="'.$currency.'">';
1664 print '</td></tr>'."\n
";
1667 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("PaymentCode
");
1668 print '</td><td class="CTableRow2
"><b style="word-
break:
break-all;
">'.$fulltag.'</b>';
1669 print '<input type="hidden
" name="tag
" value="'.$tag.'">';
1670 print '<input type="hidden
" name="fulltag
" value="'.$fulltag.'">';
1671 print '</td></tr>'."\n
";
1674 $shipToName = $member->getFullName($langs);
1675 $shipToStreet = $member->address;
1676 $shipToCity = $member->town;
1677 $shipToState = $member->state_code;
1678 $shipToCountryCode = $member->country_code;
1679 $shipToZip = $member->zip;
1680 $shipToStreet2 = '';
1681 $phoneNum = $member->phone;
1682 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1683 print '<!-- Shipping address information -->';
1684 print '<input type="hidden
" name="shipToName
" value="'.$shipToName.'">'."\n
";
1685 print '<input type="hidden
" name="shipToStreet
" value="'.$shipToStreet.'">'."\n
";
1686 print '<input type="hidden
" name="shipToCity
" value="'.$shipToCity.'">'."\n
";
1687 print '<input type="hidden
" name="shipToState
" value="'.$shipToState.'">'."\n
";
1688 print '<input type="hidden
" name="shipToCountryCode
" value="'.$shipToCountryCode.'">'."\n
";
1689 print '<input type="hidden
" name="shipToZip
" value="'.$shipToZip.'">'."\n
";
1690 print '<input type="hidden
" name="shipToStreet2
" value="'.$shipToStreet2.'">'."\n
";
1691 print '<input type="hidden
" name="phoneNum
" value="'.$phoneNum.'">'."\n
";
1693 print '<!-- Shipping address not complete, so we don t use it -->'."\n
";
1695 if (is_object($member->thirdparty)) {
1696 print '<input type="hidden
" name="thirdparty_id
" value="'.$member->thirdparty->id.'">'."\n
";
1698 print '<input type="hidden
" name="email
" value="'.$member->email.'">'."\n
";
1699 $labeldesc = $langs->trans("PaymentSubscription
");
1700 if (GETPOST('desc', 'alpha')) {
1701 $labeldesc = GETPOST('desc', 'alpha');
1703 print '<input type="hidden
" name="desc
" value="'.dol_escape_htmltag($labeldesc).'">'."\n
";
1706// Payment on donation
1707if ($source == 'donation') {
1709 $langs->load("don
");
1711 require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
1713 $don = new Don($db);
1714 $result = $don->fetch($ref);
1716 $mesg = $don->error;
1719 $don->fetch_thirdparty();
1723 if ($action != 'dopayment') { // Do not change amount if we just click on first dopayment
1724 if (GETPOST("amount
", 'alpha')) {
1725 $amount = GETPOST("amount
", 'alpha');
1727 $amount = $don->getRemainToPay();
1729 $amount = price2num($amount);
1732 if (GETPOST('fulltag', 'alpha')) {
1733 $fulltag = GETPOST('fulltag', 'alpha');
1735 $fulltag = 'DON='.$don->ref.'.DAT='.dol_print_date(dol_now(), '%Y%m%d%H%M%S');
1737 $tag = $TAG; $fulltag .= '.TAG='.$TAG;
1740 $fulltag = dol_string_unaccent($fulltag);
1743 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Creditor
");
1744 print '</td><td class="CTableRow2
"><b>'.$creditor.'</b>';
1745 print '<input type="hidden
" name="creditor
" value="'.$creditor.'">';
1746 print '</td></tr>'."\n
";
1749 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("ThirdParty
");
1750 print '</td><td class="CTableRow2
"><b>';
1751 if ($don->morphy == 'mor' && !empty($don->societe)) {
1752 print $don->societe;
1754 print $don->getFullName($langs);
1757 print '</td></tr>'."\n
";
1761 if (GETPOST('desc', 'alpha')) {
1762 $text = '<b>'.$langs->trans(GETPOST('desc', 'alpha')).'</b>';
1764 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Designation
");
1765 print '</td><td class="CTableRow2
">'.$text;
1766 print '<input type="hidden
" name="source
" value="'.dol_escape_htmltag($source).'">';
1767 print '<input type="hidden
" name="ref" value="'.dol_escape_htmltag($don->ref).'">';
1768 print '</td></tr>'."\n
";
1771 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Amount
");
1772 if (empty($amount)) {
1773 if (empty($conf->global->DONATION_NEWFORM_AMOUNT)) {
1774 print ' ('.$langs->trans("ToComplete
");
1776 if (!empty($conf->global->DONATION_EXT_URL_SUBSCRIPTION_INFO)) {
1777 print ' - <a href="'.$conf->global->DONATION_EXT_URL_SUBSCRIPTION_INFO.'" rel="external
" target="_blank
" rel="noopener noreferrer
">'.$langs->trans("SeeHere
").'</a>';
1779 if (empty($conf->global->DONATION_NEWFORM_AMOUNT)) {
1783 print '</td><td class="CTableRow2
">';
1785 if (empty($amount) || !is_numeric($amount)) {
1786 $valtoshow = price2num(GETPOST("newamount
", 'alpha'), 'MT');
1787 // force default subscription amount to value defined into constant...
1788 if (empty($valtoshow)) {
1789 if (!empty($conf->global->DONATION_NEWFORM_EDITAMOUNT)) {
1790 if (!empty($conf->global->DONATION_NEWFORM_AMOUNT)) {
1791 $valtoshow = $conf->global->DONATION_NEWFORM_AMOUNT;
1794 if (!empty($conf->global->DONATION_NEWFORM_AMOUNT)) {
1795 $amount = $conf->global->DONATION_NEWFORM_AMOUNT;
1800 if (empty($amount) || !is_numeric($amount)) {
1801 //$valtoshow=price2num(GETPOST("newamount
",'alpha'),'MT');
1802 if (!empty($conf->global->DONATION_MIN_AMOUNT) && $valtoshow) {
1803 $valtoshow = max($conf->global->DONATION_MIN_AMOUNT, $valtoshow);
1805 print '<input type="hidden
" name="amount
" value="'.price2num(GETPOST("amount", 'alpha
'), 'MT
').'">';
1806 print '<input class="flat maxwidth75
" type="text
" name="newamount
" value="'.$valtoshow.'">';
1808 print ' <b>'.$langs->trans("Currency
".$currency).'</b>';
1810 $valtoshow = $amount;
1811 if (!empty($conf->global->DONATION_MIN_AMOUNT) && $valtoshow) {
1812 $valtoshow = max($conf->global->DONATION_MIN_AMOUNT, $valtoshow);
1813 $amount = $valtoshow;
1815 print '<b class="amount
">'.price($valtoshow, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
1816 print '<input type="hidden
" name="amount
" value="'.$valtoshow.'">';
1817 print '<input type="hidden
" name="newamount
" value="'.$valtoshow.'">';
1819 print '<input type="hidden
" name="currency
" value="'.$currency.'">';
1820 print '</td></tr>'."\n
";
1823 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("PaymentCode
");
1824 print '</td><td class="CTableRow2
"><b style="word-
break:
break-all;
">'.$fulltag.'</b>';
1825 print '<input type="hidden
" name="tag
" value="'.$tag.'">';
1826 print '<input type="hidden
" name="fulltag
" value="'.$fulltag.'">';
1827 print '</td></tr>'."\n
";
1830 $shipToName = $don->getFullName($langs);
1831 $shipToStreet = $don->address;
1832 $shipToCity = $don->town;
1833 $shipToState = $don->state_code;
1834 $shipToCountryCode = $don->country_code;
1835 $shipToZip = $don->zip;
1836 $shipToStreet2 = '';
1837 $phoneNum = $don->phone;
1838 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1839 print '<!-- Shipping address information -->';
1840 print '<input type="hidden
" name="shipToName
" value="'.$shipToName.'">'."\n
";
1841 print '<input type="hidden
" name="shipToStreet
" value="'.$shipToStreet.'">'."\n
";
1842 print '<input type="hidden
" name="shipToCity
" value="'.$shipToCity.'">'."\n
";
1843 print '<input type="hidden
" name="shipToState
" value="'.$shipToState.'">'."\n
";
1844 print '<input type="hidden
" name="shipToCountryCode
" value="'.$shipToCountryCode.'">'."\n
";
1845 print '<input type="hidden
" name="shipToZip
" value="'.$shipToZip.'">'."\n
";
1846 print '<input type="hidden
" name="shipToStreet2
" value="'.$shipToStreet2.'">'."\n
";
1847 print '<input type="hidden
" name="phoneNum
" value="'.$phoneNum.'">'."\n
";
1849 print '<!-- Shipping address not complete, so we don t use it -->'."\n
";
1851 if (is_object($don->thirdparty)) {
1852 print '<input type="hidden
" name="thirdparty_id
" value="'.$don->thirdparty->id.'">'."\n
";
1854 print '<input type="hidden
" name="email
" value="'.$don->email.'">'."\n
";
1855 $labeldesc = $langs->trans("PaymentSubscription
");
1856 if (GETPOST('desc', 'alpha')) {
1857 $labeldesc = GETPOST('desc', 'alpha');
1859 print '<input type="hidden
" name="desc
" value="'.dol_escape_htmltag($labeldesc).'">'."\n
";
1862if ($source == 'organizedeventregistration') {
1864 $langs->loadLangs(array("members
", "eventorganization
"));
1866 if (GETPOST('fulltag', 'alpha')) {
1867 $fulltag = GETPOST('fulltag', 'alpha');
1869 $fulltag = 'ATT='.$attendee->id.'.DAT='.dol_print_date(dol_now(), '%Y%m%d%H%M%S');
1871 $tag = $TAG; $fulltag .= '.TAG='.$TAG;
1874 $fulltag = dol_string_unaccent($fulltag);
1877 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Creditor
");
1878 print '</td><td class="CTableRow2
"><b>'.$creditor.'</b>';
1879 print '<input type="hidden
" name="creditor
" value="'.$creditor.'">';
1880 print '</td></tr>'."\n
";
1883 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Attendee
");
1884 print '</td><td class="CTableRow2
"><b>';
1885 print $attendee->email;
1886 print ($thirdparty->name ? ' ('.$thirdparty->name.')' : '');
1888 print '</td></tr>'."\n
";
1890 if (! is_object($attendee->project)) {
1891 $text = 'ErrorProjectNotFound';
1893 $text = $langs->trans("PaymentEvent
").' - '.$attendee->project->title;
1897 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Designation
");
1898 print '</td><td class="CTableRow2
"><b>'.$text.'</b>';
1899 print '<input type="hidden
" name="source
" value="'.dol_escape_htmltag($source).'">';
1900 print '<input type="hidden
" name="ref" value="'.dol_escape_htmltag($invoice->id).'">';
1901 print '</td></tr>'."\n
";
1904 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Amount
");
1905 print '</td><td class="CTableRow2
">';
1906 $valtoshow = $amount;
1907 print '<b class="amount
">'.price($valtoshow, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
1908 print '<input type="hidden
" name="amount
" value="'.$valtoshow.'">';
1909 print '<input type="hidden
" name="newamount
" value="'.$valtoshow.'">';
1910 print '<input type="hidden
" name="currency
" value="'.$currency.'">';
1911 print '</td></tr>'."\n
";
1914 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("PaymentCode
");
1915 print '</td><td class="CTableRow2
"><b style="word-
break:
break-all;
">'.$fulltag.'</b>';
1916 print '<input type="hidden
" name="tag
" value="'.$tag.'">';
1917 print '<input type="hidden
" name="fulltag
" value="'.$fulltag.'">';
1918 print '</td></tr>'."\n
";
1921 $shipToName = $thirdparty->getFullName($langs);
1922 $shipToStreet = $thirdparty->address;
1923 $shipToCity = $thirdparty->town;
1924 $shipToState = $thirdparty->state_code;
1925 $shipToCountryCode = $thirdparty->country_code;
1926 $shipToZip = $thirdparty->zip;
1927 $shipToStreet2 = '';
1928 $phoneNum = $thirdparty->phone;
1929 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1930 print '<!-- Shipping address information -->';
1931 print '<input type="hidden
" name="shipToName
" value="'.$shipToName.'">'."\n
";
1932 print '<input type="hidden
" name="shipToStreet
" value="'.$shipToStreet.'">'."\n
";
1933 print '<input type="hidden
" name="shipToCity
" value="'.$shipToCity.'">'."\n
";
1934 print '<input type="hidden
" name="shipToState
" value="'.$shipToState.'">'."\n
";
1935 print '<input type="hidden
" name="shipToCountryCode
" value="'.$shipToCountryCode.'">'."\n
";
1936 print '<input type="hidden
" name="shipToZip
" value="'.$shipToZip.'">'."\n
";
1937 print '<input type="hidden
" name="shipToStreet2
" value="'.$shipToStreet2.'">'."\n
";
1938 print '<input type="hidden
" name="phoneNum
" value="'.$phoneNum.'">'."\n
";
1940 print '<!-- Shipping address not complete, so we don t use it -->'."\n
";
1942 print '<input type="hidden
" name="thirdparty_id
" value="'.$thirdparty->id.'">'."\n
";
1943 print '<input type="hidden
" name="email
" value="'.$thirdparty->email.'">'."\n
";
1944 $labeldesc = $langs->trans("PaymentSubscription
");
1945 if (GETPOST('desc', 'alpha')) {
1946 $labeldesc = GETPOST('desc', 'alpha');
1948 print '<input type="hidden
" name="desc
" value="'.dol_escape_htmltag($labeldesc).'">'."\n
";
1951if ($source == 'boothlocation') {
1953 $langs->load("members
");
1955 if (GETPOST('fulltag', 'alpha')) {
1956 $fulltag = GETPOST('fulltag', 'alpha');
1958 $fulltag = 'BOO='.GETPOST("booth
").'.DAT='.dol_print_date(dol_now(), '%Y%m%d%H%M%S');
1960 $tag = $TAG; $fulltag .= '.TAG='.$TAG;
1963 $fulltag = dol_string_unaccent($fulltag);
1966 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Creditor
");
1967 print '</td><td class="CTableRow2
"><b>'.$creditor.'</b>';
1968 print '<input type="hidden
" name="creditor
" value="'.$creditor.'">';
1969 print '</td></tr>'."\n
";
1972 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Attendee
");
1973 print '</td><td class="CTableRow2
"><b>';
1974 print $thirdparty->name;
1976 print '</td></tr>'."\n
";
1979 $text = '<b>'.$langs->trans("PaymentBoothLocation
").'</b>';
1980 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Designation
");
1981 print '</td><td class="CTableRow2
">'.$text;
1982 print '<input type="hidden
" name="source
" value="'.dol_escape_htmltag($source).'">';
1983 print '<input type="hidden
" name="ref" value="'.dol_escape_htmltag($invoice->id).'">';
1984 print '</td></tr>'."\n
";
1987 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Amount
");
1988 print '</td><td class="CTableRow2
">';
1989 $valtoshow = $amount;
1990 print '<b class="amount
">'.price($valtoshow, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
1991 print '<input type="hidden
" name="amount
" value="'.$valtoshow.'">';
1992 print '<input type="hidden
" name="newamount
" value="'.$valtoshow.'">';
1993 print '<input type="hidden
" name="currency
" value="'.$currency.'">';
1994 print '</td></tr>'."\n
";
1997 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("PaymentCode
");
1998 print '</td><td class="CTableRow2
"><b style="word-
break:
break-all;
">'.$fulltag.'</b>';
1999 print '<input type="hidden
" name="tag
" value="'.$tag.'">';
2000 print '<input type="hidden
" name="fulltag
" value="'.$fulltag.'">';
2001 print '</td></tr>'."\n
";
2004 $shipToName = $thirdparty->getFullName($langs);
2005 $shipToStreet = $thirdparty->address;
2006 $shipToCity = $thirdparty->town;
2007 $shipToState = $thirdparty->state_code;
2008 $shipToCountryCode = $thirdparty->country_code;
2009 $shipToZip = $thirdparty->zip;
2010 $shipToStreet2 = '';
2011 $phoneNum = $thirdparty->phone;
2012 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
2013 print '<!-- Shipping address information -->';
2014 print '<input type="hidden
" name="shipToName
" value="'.$shipToName.'">'."\n
";
2015 print '<input type="hidden
" name="shipToStreet
" value="'.$shipToStreet.'">'."\n
";
2016 print '<input type="hidden
" name="shipToCity
" value="'.$shipToCity.'">'."\n
";
2017 print '<input type="hidden
" name="shipToState
" value="'.$shipToState.'">'."\n
";
2018 print '<input type="hidden
" name="shipToCountryCode
" value="'.$shipToCountryCode.'">'."\n
";
2019 print '<input type="hidden
" name="shipToZip
" value="'.$shipToZip.'">'."\n
";
2020 print '<input type="hidden
" name="shipToStreet2
" value="'.$shipToStreet2.'">'."\n
";
2021 print '<input type="hidden
" name="phoneNum
" value="'.$phoneNum.'">'."\n
";
2023 print '<!-- Shipping address not complete, so we don t use it -->'."\n
";
2025 print '<input type="hidden
" name="thirdparty_id
" value="'.$thirdparty->id.'">'."\n
";
2026 print '<input type="hidden
" name="email
" value="'.$thirdparty->email.'">'."\n
";
2027 $labeldesc = $langs->trans("PaymentSubscription
");
2028 if (GETPOST('desc', 'alpha')) {
2029 $labeldesc = GETPOST('desc', 'alpha');
2031 print '<input type="hidden
" name="desc
" value="'.dol_escape_htmltag($labeldesc).'">'."\n
";
2034if (!$found && !$mesg) {
2035 $mesg = $langs->trans("ErrorBadParameters
");
2039 print '<tr><td align="center
" colspan="2
"><br><div class="warning
">'.dol_escape_htmltag($mesg, 1, 1, 'br').'</div></td></tr>'."\n
";
2042print '</table>'."\n
";
2046// Show all payment mode buttons (Stripe, Paypal, ...)
2047if ($action != 'dopayment') {
2048 if ($found && !$error) { // We are in a management option and no error
2049 // Check status of the object (Invoice) to verify if it is paid by external payment modules (ie Payzen, ...)
2051 'source' => $source,
2054 $reshook = $hookmanager->executeHooks('doCheckStatus', $parameters, $object, $action);
2056 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2057 } elseif ($reshook > 0) {
2058 print $hookmanager->resPrint;
2061 if ($source == 'order' && $object->billed) {
2062 print '<br><br><span class="amountpaymentcomplete size15x
">'.$langs->trans("OrderBilled
").'</span>';
2063 } elseif ($source == 'invoice' && $object->paye) {
2064 print '<br><br><span class="amountpaymentcomplete size15x
">'.$langs->trans("InvoicePaid
").'</span>';
2065 } elseif ($source == 'donation' && $object->paid) {
2066 print '<br><br><span class="amountpaymentcomplete size15x
">'.$langs->trans("DonationPaid
").'</span>';
2068 // Membership can be paid and we still allow to make renewal
2069 if (($source == 'member' || $source == 'membersubscription') && $object->datefin > dol_now()) {
2070 $langs->load("members
");
2071 print '<br><span class="amountpaymentcomplete size15x
">'.$langs->trans("MembershipPaid
", dol_print_date($object->datefin, 'day')).'</span><br>';
2072 print '<div class="opacitymedium margintoponly
">'.$langs->trans("PaymentWillBeRecordedForNextPeriod
").'</div>';
2075 // Buttons for all payments registration methods
2077 // This hook is used to add Button to newpayment.php for external payment modules (ie Payzen, ...)
2079 'paymentmethod' => $paymentmethod
2081 $reshook = $hookmanager->executeHooks('doAddButton', $parameters, $object, $action);
2083 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2084 } elseif ($reshook > 0) {
2085 print $hookmanager->resPrint;
2088 if ((empty($paymentmethod) || $paymentmethod == 'paybox') && isModEnabled('paybox')) {
2089 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").'">';
2091 print '<span class="buttonpaymentsmall
">'.$langs->trans("CreditOrDebitCard
").'</span>';
2094 $( document ).ready(function() {
2095 $("#div_dopayment_paybox
").click(function(){
2096 $("#dopayment_paybox
").click();
2098 $("#dopayment_paybox
").click(function(e){
2099 $("#div_dopayment_paybox
").css( \'cursor\', \'wait\' );
2100 e.stopPropagation();
2107 if ((empty($paymentmethod) || $paymentmethod == 'stripe') && isModEnabled('stripe')) {
2108 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").'">';
2109 print '<input type="hidden
" name="noidempotency
" value="'.GETPOST('noidempotency
', 'int').'">';
2111 print '<span class="buttonpaymentsmall
">'.$langs->trans("CreditOrDebitCard
").'</span>';
2114 $( document ).ready(function() {
2115 $("#div_dopayment_stripe
").click(function(){
2116 $("#dopayment_stripe
").click();
2118 $("#dopayment_stripe
").click(function(e){
2119 $("#div_dopayment_stripe
").css( \'cursor\', \'wait\' );
2120 e.stopPropagation();
2128 if ((empty($paymentmethod) || $paymentmethod == 'paypal') && isModEnabled('paypal')) {
2129 if (empty($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY)) {
2130 $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY = 'integral';
2133 print '<div class="button buttonpayment
" id="div_dopayment_paypal
">';
2134 if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY != 'integral') {
2135 print '<div style="line-height: 1em
"> </div>';
2137 print '<span class="fa fa-paypal
"></span> <input class="" type="submit
" id="dopayment_paypal
" name="dopayment_paypal
" value="'.$langs->trans("PaypalDoPayment").'">';
2138 if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'integral') {
2140 print '<span class="buttonpaymentsmall
">'.$langs->trans("CreditOrDebitCard
").'</span><span class="buttonpaymentsmall
"> - </span>';
2141 print '<span class="buttonpaymentsmall
">'.$langs->trans("PayPalBalance
").'</span>';
2143 if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'paypalonly') {
2145 //print '<span class="buttonpaymentsmall
">'.$langs->trans("PayPalBalance
").'"></span>
';
2149 $( document ).ready(
function() {
2150 $(
"#div_dopayment_paypal").click(
function(){
2151 $(
"#dopayment_paypal").click();
2153 $(
"#dopayment_paypal").click(
function(e){
2154 $(
"#div_dopayment_paypal").css( \
'cursor\', \'wait\' );
2155 e.stopPropagation();
2170print
'</td></tr>'.
"\n";
2172print
'</table>'.
"\n";
2174print
'</form>'.
"\n";
2182if (preg_match(
'/^dopayment/', $action)) {
2185 $_SESSION[
"currencyCodeType"] = $currency;
2186 $_SESSION[
"FinalPaymentAmt"] = $amount;
2187 $_SESSION[
'ipaddress'] = ($remoteip ? $remoteip :
'unknown');
2188 $_SESSION[
"paymentType"] =
'';
2191 if (
GETPOST(
'dopayment_stripe',
'alpha')) {
2199 background-color: white;
2202 border: 1px solid transparent;
2203 box-shadow: 0 1px 3px 0 #e6ebf1;
2204 -webkit-transition: box-shadow 150ms ease;
2205 transition: box-shadow 150ms ease;
2208 .StripeElement--focus {
2209 box-shadow: 0 1px 3px 0 #cfd7df;
2212 .StripeElement--invalid {
2213 border-color: #fa755a;
2216 .StripeElement--webkit-autofill {
2217 background-color: #fefde5 !important;
2223 print
'<!-- Show Stripe form payment-form STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION = '.$conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION.
' STRIPE_USE_NEW_CHECKOUT = '.$conf->global->STRIPE_USE_NEW_CHECKOUT.
' -->'.
"\n";
2224 print
'<form action="'.$_SERVER[
'REQUEST_URI'].
'" method="POST" id="payment-form">'.
"\n";
2226 print
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
2227 print
'<input type="hidden" name="dopayment_stripe" value="1">'.
"\n";
2228 print
'<input type="hidden" name="action" value="charge">'.
"\n";
2229 print
'<input type="hidden" name="tag" value="'.$TAG.
'">'.
"\n";
2230 print
'<input type="hidden" name="s" value="'.$source.
'">'.
"\n";
2231 print
'<input type="hidden" name="ref" value="'.$REF.
'">'.
"\n";
2232 print
'<input type="hidden" name="fulltag" value="'.$FULLTAG.
'">'.
"\n";
2233 print
'<input type="hidden" name="suffix" value="'.$suffix.
'">'.
"\n";
2234 print
'<input type="hidden" name="securekey" value="'.$SECUREKEY.
'">'.
"\n";
2235 print
'<input type="hidden" name="e" value="'.$entity.
'" />';
2236 print
'<input type="hidden" name="amount" value="'.$amount.
'">'.
"\n";
2237 print
'<input type="hidden" name="currency" value="'.$currency.
'">'.
"\n";
2238 print
'<input type="hidden" name="forcesandbox" value="'.GETPOST(
'forcesandbox',
'int').
'" />';
2239 print
'<input type="hidden" name="email" value="'.GETPOST(
'email',
'alpha').
'" />';
2240 print
'<input type="hidden" name="thirdparty_id" value="'.GETPOST(
'thirdparty_id',
'int').
'" />';
2241 print
'<input type="hidden" name="lang" value="'.$getpostlang.
'">';
2243 if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) || !empty($conf->global->STRIPE_USE_NEW_CHECKOUT)) {
2244 require_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
2246 $service =
'StripeLive';
2248 if (empty($conf->global->STRIPE_LIVE) ||
GETPOST(
'forcesandbox',
'alpha')) {
2249 $service =
'StripeTest';
2253 $stripe =
new Stripe($db);
2254 $stripeacc = $stripe->getStripeAccount($service);
2256 if (is_object($object) && is_object($object->thirdparty)) {
2257 $stripecu = $stripe->customerStripe($object->thirdparty, $stripeacc, $servicestatus, 1);
2260 if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) {
2261 $noidempotency_key = (GETPOSTISSET(
'noidempotency') ?
GETPOST(
'noidempotency',
'int') : 0);
2262 $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);
2265 if ($stripe->error) {
2276 <table id="dolpaymenttable" summary="Payment form" class="center centpercent">
2277 <tbody><tr><td class="textpublicpayment">';
2279 if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) {
2280 print
'<div id="payment-request-button"><!-- A Stripe Element will be inserted here. --></div>';
2283 print
'<div class="form-row '.(getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 2 ?
'center' :
'left').
'">';
2284 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 1) {
2285 print
'<label for="card-element">'.$langs->trans(
"CreditOrDebitCard").
'</label>';
2286 print
'<br><input id="cardholder-name" class="marginbottomonly" name="cardholder-name" value="" type="text" placeholder="'.$langs->trans(
"CardOwner").
'" autocomplete="off" autofocus required>';
2289 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 1) {
2290 print
'<div id="card-element">
2291 <!-- a Stripe Element will be inserted here. -->
2294 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 2) {
2295 print
'<div id="payment-element">
2296 <!-- a Stripe Element will be inserted here. -->
2300 print
'<!-- Used to display form errors -->
2301 <div id="card-errors" role="alert"></div>
2305 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>';
2306 print
'<img id="hourglasstopay" class="hidden" src="'.DOL_URL_ROOT.
'/theme/'.$conf->theme.
'/img/working.gif">';
2308 print
'</td></tr></tbody>';
2312 if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) {
2313 if (empty($paymentintent)) {
2314 print
'<center>'.$langs->trans(
"Error").
'</center>';
2316 print
'<input type="hidden" name="paymentintent_id" value="'.$paymentintent->id.
'">';
2321 print
'</form>'.
"\n";
2325 if (empty($stripearrayofkeys[
'publishable_key'])) {
2326 $langs->load(
"errors");
2327 print
info_admin($langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv(
"Stripe")), 0, 0,
'error');
2329 print
'<!-- JS Code for Stripe components -->';
2330 print
'<script src="https://js.stripe.com/v3/"></script>'.
"\n";
2331 print
'<!-- urllogofull = '.$urllogofull.
' -->'.
"\n";
2334 print
'<script type="text/javascript">'.
"\n";
2336 if (!empty($conf->global->STRIPE_USE_NEW_CHECKOUT)) {
2337 $amountstripe = $amount;
2341 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
2342 if (!in_array($currency, $arrayzerounitcurrency)) {
2343 $amountstripe = $amountstripe * 100;
2347 $metadata = array(
'dol_version'=>DOL_VERSION,
'dol_entity'=>$conf->entity,
'ipaddress'=>$ipaddress);
2348 if (is_object($object)) {
2349 $metadata[
'dol_type'] = $object->element;
2350 $metadata[
'dol_id'] = $object->id;
2352 $ref = $object->ref;
2356 $arrayforpaymentintent = array(
2357 'description'=>
'Stripe payment: '.$FULLTAG.($ref ?
' ref='.$ref :
''),
2358 "metadata" => $metadata
2361 $arrayforpaymentintent[
"statement_descriptor"] =
dol_trunc($TAG, 10,
'right',
'UTF-8', 1);
2364 $arrayforcheckout = array(
2365 'payment_method_types' => array(
'card'),
2366 'line_items' => array(array(
2367 'name' => $langs->transnoentitiesnoconv(
"Payment").
' '.$TAG,
2368 'description' =>
'Stripe payment: '.$FULLTAG.($ref ?
' ref='.$ref :
''),
2369 'amount' => $amountstripe,
2370 'currency' => $currency,
2374 'client_reference_id' => $FULLTAG,
2375 'success_url' => $urlok,
2376 'cancel_url' => $urlko,
2377 'payment_intent_data' => $arrayforpaymentintent
2380 $arrayforcheckout[
'customer'] = $stripecu;
2382 $arrayforcheckout[
'customer_email'] =
GETPOST(
'email',
'alpha');
2384 $sessionstripe = \Stripe\Checkout\Session::create($arrayforcheckout);
2389 $_SESSION[
"currencyCodeType"] = $currency;
2390 $_SESSION[
"paymentType"] =
'';
2391 $_SESSION[
"FinalPaymentAmt"] = $amount;
2392 $_SESSION[
'ipaddress'] = ($remoteip ? $remoteip :
'unknown');
2393 $_SESSION[
'payerID'] = is_object($stripecu) ? $stripecu->id :
'';
2394 $_SESSION[
'TRANSACTIONID'] = $sessionstripe->id;
2396 print $e->getMessage();
2403 if (empty($stripeacc)) {
2405 var stripe =
Stripe(
'<?php echo $stripearrayofkeys['publishable_key
']; // Defined into config.php ?>');
2409 var stripe =
Stripe(
'<?php echo $stripearrayofkeys['publishable_key
']; // Defined into config.php ?>', { stripeAccount:
'<?php echo $stripeacc; ?>' });
2415 var elements = stripe.elements();
2423 fontFamily:
'"Helvetica Neue", Helvetica, sans-serif',
2424 fontSmoothing:
'antialiased',
2432 iconColor:
'#fa755a'
2436 var cardElement = elements.create(
'card', {style: style});
2439 stripe.redirectToCheckout({
2443 sessionId:
'<?php print $sessionstripe->id; ?>'
2444 }).then(
function (result) {
2452 } elseif (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) {
2458 if (empty($stripeacc)) {
2460 var stripe =
Stripe(
'<?php echo $stripearrayofkeys['publishable_key
']; // Defined into config.php ?>');
2464 var stripe =
Stripe(
'<?php echo $stripearrayofkeys['publishable_key
']; // Defined into config.php ?>', { stripeAccount:
'<?php echo $stripeacc; ?>' });
2470 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 2) {
2472 var cardButton = document.getElementById(
'buttontopay');
2473 var clientSecret = cardButton.dataset.secret;
2474 var options = { clientSecret: clientSecret };
2477 var elements = stripe.elements(options);
2482 var elements = stripe.elements();
2493 fontFamily:
'"Helvetica Neue", Helvetica, sans-serif',
2494 fontSmoothing:
'antialiased',
2502 iconColor:
'#fa755a'
2507 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 2) {
2509 var paymentElement = elements.create(
"payment");
2512 paymentElement.mount(
"#payment-element");
2515 var cardButton = document.getElementById(
'buttontopay');
2517 cardButton.addEventListener(
'click',
function(event) {
2518 console.log(
"We click on buttontopay");
2519 event.preventDefault();
2522 jQuery(
'#hourglasstopay').show();
2523 jQuery(
'#buttontopay').hide();
2525 stripe.confirmPayment({
2526 elements,confirmParams: {
2527 return_url:
'<?php echo $urlok; ?>',
2528 payment_method_data: {
2531 <?php
if (
GETPOST(
'email',
'alpha') || (is_object($object) && is_object($object->thirdparty) && !empty($object->thirdparty->email))) {
2532 ?>, email:
'<?php echo dol_escape_js(GETPOST('email
', 'alpha
') ? GETPOST('email
', 'alpha
') : $object->thirdparty->email); ?>'<?php
2534 <?php
if (is_object($object) && is_object($object->thirdparty) && !empty($object->thirdparty->phone)) {
2535 ?>, phone:
'<?php echo dol_escape_js($object->thirdparty->phone); ?>'<?php
2537 <?php
if (is_object($object) && is_object($object->thirdparty)) {
2539 city:
'<?php echo dol_escape_js($object->thirdparty->town); ?>',
2540 <?php if ($object->thirdparty->country_code) {
2541 ?>country:
'<?php echo dol_escape_js($object->thirdparty->country_code); ?>',<?php
2543 line1:
'<?php echo dol_escape_js(preg_replace('/\s\s+/
', ' ', $object->thirdparty->address)); ?>',
2544 postal_code:
'<?php echo dol_escape_js($object->thirdparty->zip); ?>'
2549 save_payment_method:<?php
if ($stripecu) {
2556 ).then(
function(result) {
2557 console.log(result);
2559 console.log(
"Error on result of handleCardPayment");
2560 jQuery(
'#buttontopay').show();
2561 jQuery(
'#hourglasstopay').hide();
2563 var errorElement = document.getElementById(
'card-errors');
2564 console.log(result);
2565 errorElement.textContent = result.error.message;
2568 console.log(
"No error on result of handleCardPayment, so we submit the form");
2570 jQuery(
'#buttontopay').hide();
2571 jQuery(
'#hourglasstopay').show();
2573 jQuery(
'#payment-form').submit();
2581 var cardElement = elements.create(
'card', {style: style});
2584 cardElement.mount(
'#card-element');
2587 cardElement.addEventListener(
'change',
function(event) {
2588 var displayError = document.getElementById(
'card-errors');
2590 console.log(
"Show event error (like 'Incorrect card number', ...)");
2591 displayError.textContent =
event.error.message;
2593 console.log(
"Reset error message");
2594 displayError.textContent =
'';
2599 var cardholderName = document.getElementById(
'cardholder-name');
2600 var cardButton = document.getElementById(
'buttontopay');
2601 var clientSecret = cardButton.dataset.secret;
2603 cardButton.addEventListener(
'click',
function(event) {
2604 console.log(
"We click on buttontopay");
2605 event.preventDefault();
2607 if (cardholderName.value ==
'')
2609 console.log(
"Field Card holder is empty");
2610 var displayError = document.getElementById(
'card-errors');
2611 displayError.textContent =
'<?php print dol_escape_js($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardOwner"))); ?>';
2616 jQuery(
'#hourglasstopay').show();
2617 jQuery(
'#buttontopay').hide();
2619 stripe.handleCardPayment(
2620 clientSecret, cardElement, {
2621 payment_method_data: {
2623 name: cardholderName.value
2624 <?php
if (
GETPOST(
'email',
'alpha') || (is_object($object) && is_object($object->thirdparty) && !empty($object->thirdparty->email))) {
2625 ?>, email:
'<?php echo dol_escape_js(GETPOST('email
', 'alpha
') ? GETPOST('email
', 'alpha
') : $object->thirdparty->email); ?>'<?php
2627 <?php
if (is_object($object) && is_object($object->thirdparty) && !empty($object->thirdparty->phone)) {
2628 ?>, phone:
'<?php echo dol_escape_js($object->thirdparty->phone); ?>'<?php
2630 <?php
if (is_object($object) && is_object($object->thirdparty)) {
2632 city:
'<?php echo dol_escape_js($object->thirdparty->town); ?>',
2633 <?php if ($object->thirdparty->country_code) {
2634 ?>country:
'<?php echo dol_escape_js($object->thirdparty->country_code); ?>',<?php
2636 line1:
'<?php echo dol_escape_js(preg_replace('/\s\s+/
', ' ', $object->thirdparty->address)); ?>',
2637 postal_code:
'<?php echo dol_escape_js($object->thirdparty->zip); ?>'
2642 save_payment_method:<?php
if ($stripecu) {
2648 ).then(
function(result) {
2649 console.log(result);
2651 console.log(
"Error on result of handleCardPayment");
2652 jQuery(
'#buttontopay').show();
2653 jQuery(
'#hourglasstopay').hide();
2655 var errorElement = document.getElementById(
'card-errors');
2656 errorElement.textContent = result.error.message;
2659 console.log(
"No error on result of handleCardPayment, so we submit the form");
2661 jQuery(
'#buttontopay').hide();
2662 jQuery(
'#hourglasstopay').show();
2664 jQuery(
'#payment-form').submit();
2683 'paymentmethod' => $paymentmethod,
2684 'amount' => $amount,
2685 'currency' => $currency,
2686 'tag' =>
GETPOST(
"tag",
'alpha'),
2687 'dopayment' =>
GETPOST(
'dopayment',
'alpha')
2689 $reshook = $hookmanager->executeHooks(
'doPayment', $parameters, $object, $action);
2692 } elseif ($reshook > 0) {
2693 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 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.
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,...