39 if (!defined(
'NOLOGIN')) {
42 if (!defined(
'NOCSRFCHECK')) {
43 define(
"NOCSRFCHECK", 1);
45 if (!defined(
'NOIPCHECK')) {
46 define(
'NOIPCHECK',
'1');
48 if (!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))));
55 if (is_numeric($entity)) {
56 define(
"DOLENTITY", $entity);
60 require
'../../main.inc.php';
61 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
62 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
63 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
64 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
65 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
66 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societeaccount.class.php';
67 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
68 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
70 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.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');
91 if (!
GETPOST(
"currency",
'alpha')) {
92 $currency = $conf->currency;
94 $currency =
GETPOST(
"currency",
'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";
114 if ($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();
189 foreach ($_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');
208 $TAG =
GETPOST(
"tag",
'alpha');
209 $FULLTAG =
GETPOST(
"fulltag",
'alpha');
210 $SECUREKEY =
GETPOST(
"securekey");
212 if ($paymentmethod && !preg_match(
'/'.preg_quote(
'PM='.$paymentmethod,
'/').
'/', $FULLTAG)) {
213 $FULLTAG .= ($FULLTAG ?
'.' :
'').
'PM='.$paymentmethod;
216 if (!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).
'&';
232 if (!empty($FULLTAG)) {
233 $urlok .=
'fulltag='.urlencode($FULLTAG).
'&';
234 $urlko .=
'fulltag='.urlencode($FULLTAG).
'&';
236 if (!empty($SECUREKEY)) {
237 $urlok .=
'securekey='.urlencode($SECUREKEY).
'&';
238 $urlko .=
'securekey='.urlencode($SECUREKEY).
'&';
240 if (!empty($entity)) {
241 $urlok .=
'e='.urlencode($entity).
'&';
242 $urlko .=
'e='.urlencode($entity).
'&';
244 $urlok = preg_replace(
'/&$/',
'', $urlok);
245 $urlko = preg_replace(
'/&$/',
'', $urlko);
250 if ((empty($paymentmethod) || $paymentmethod ==
'paypal') &&
isModEnabled(
'paypal')) {
251 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypal.lib.php';
252 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypalfunctions.lib.php';
257 $PAYPAL_API_OK = $urlok;
261 $PAYPAL_API_KO = $urlko;
263 if (empty($PAYPAL_API_USER)) {
267 if (empty($PAYPAL_API_PASSWORD)) {
268 dol_print_error(
'',
"Paypal setup param PAYPAL_API_PASSWORD not defined");
271 if (empty($PAYPAL_API_SIGNATURE)) {
272 dol_print_error(
'',
"Paypal setup param PAYPAL_API_SIGNATURE not defined");
276 if ((empty($paymentmethod) || $paymentmethod ==
'paybox') &&
isModEnabled(
'paybox')) {
279 if ((empty($paymentmethod) || $paymentmethod ==
'stripe') &&
isModEnabled(
'stripe')) {
280 require_once DOL_DOCUMENT_ROOT.
'/stripe/config.php';
285 $validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod);
288 $tmpsource = $source;
289 if ($tmpsource ==
'membersubscription') {
290 $tmpsource =
'member';
293 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
295 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
296 if ($tmpsource && $REF) {
298 $tokenisok =
dol_verifyHash($conf->global->PAYMENT_SECURITY_TOKEN.$tmpsource.$REF, $SECUREKEY,
'2');
300 if ($tmpsource != $source) {
301 $tokenisok =
dol_verifyHash($conf->global->PAYMENT_SECURITY_TOKEN.$source.$REF, $SECUREKEY,
'2');
304 $tokenisok =
dol_verifyHash($conf->global->PAYMENT_SECURITY_TOKEN, $SECUREKEY,
'2');
307 $tokenisok = ($conf->global->PAYMENT_SECURITY_TOKEN == $SECUREKEY);
311 if (empty($conf->global->PAYMENT_SECURITY_ACCEPT_ANY_TOKEN)) {
314 dol_syslog(
"Warning: PAYMENT_SECURITY_ACCEPT_ANY_TOKEN is on", LOG_WARNING);
319 print
'<div class="error">Bad value for key.</div>';
325 if (!empty($paymentmethod) && empty($validpaymentmethod[$paymentmethod])) {
326 print
'Payment module for payment method '.$paymentmethod.
' is not active';
329 if (empty($validpaymentmethod)) {
330 print
'No active payment module (Paypal, Stripe, Paybox, ...)';
335 $creditor = $mysoc->name;
336 $paramcreditor =
'ONLINE_PAYMENT_CREDITOR';
337 $paramcreditorlong =
'ONLINE_PAYMENT_CREDITOR_'.$suffix;
338 if (!empty($conf->global->$paramcreditorlong)) {
339 $creditor = $conf->global->$paramcreditorlong;
340 } elseif (!empty($conf->global->$paramcreditor)) {
341 $creditor = $conf->global->$paramcreditor;
352 if ($action ==
'dopayment') {
353 dol_syslog(
"--- newpayment.php Execute action = ".$action.
" paymentmethod=".$paymentmethod.
' amount='.$amount.
' newamount='.
GETPOST(
"newamount",
'alpha'), LOG_DEBUG, 0,
'_payment');
355 if ($paymentmethod ==
'paypal') {
357 $PAYPAL_PAYMENT_TYPE =
'Sale';
360 $origfulltag =
GETPOST(
"fulltag",
'alpha');
361 $shipToName =
GETPOST(
"shipToName",
'alpha');
362 $shipToStreet =
GETPOST(
"shipToStreet",
'alpha');
363 $shipToCity =
GETPOST(
"shipToCity",
'alpha');
364 $shipToState =
GETPOST(
"shipToState",
'alpha');
365 $shipToCountryCode =
GETPOST(
"shipToCountryCode",
'alpha');
366 $shipToZip =
GETPOST(
"shipToZip",
'alpha');
367 $shipToStreet2 =
GETPOST(
"shipToStreet2",
'alpha');
368 $phoneNum =
GETPOST(
"phoneNum",
'alpha');
369 $email =
GETPOST(
"email",
'alpha');
370 $desc =
GETPOST(
"desc",
'alpha');
371 $thirdparty_id =
GETPOST(
'thirdparty_id',
'int');
374 if ($shipToCountryCode ==
'ID' && !preg_match(
'/\-/', $shipToState)) {
375 $shipToState =
'ID-'.$shipToState;
378 if (empty($PAYPAL_API_PRICE) || !is_numeric($PAYPAL_API_PRICE)) {
379 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount"));
383 } elseif (!$origfulltag) {
384 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"PaymentCode"));
390 dol_syslog(
"newpayment.php call paypal api and do redirect", LOG_DEBUG);
393 $PAYPAL_API_DEVISE =
"USD";
394 if (!empty($currency)) {
395 $PAYPAL_API_DEVISE = $currency;
400 dol_syslog(
"PAYPAL_API_USER: $PAYPAL_API_USER", LOG_DEBUG);
401 dol_syslog(
"PAYPAL_API_PASSWORD: ".preg_replace(
'/./',
'*', $PAYPAL_API_PASSWORD), LOG_DEBUG);
402 dol_syslog(
"PAYPAL_API_SIGNATURE: $PAYPAL_API_SIGNATURE", LOG_DEBUG);
403 dol_syslog(
"PAYPAL_API_SANDBOX: $PAYPAL_API_SANDBOX", LOG_DEBUG);
404 dol_syslog(
"PAYPAL_API_OK: $PAYPAL_API_OK", LOG_DEBUG);
405 dol_syslog(
"PAYPAL_API_KO: $PAYPAL_API_KO", LOG_DEBUG);
406 dol_syslog(
"PAYPAL_API_PRICE: $PAYPAL_API_PRICE", LOG_DEBUG);
407 dol_syslog(
"PAYPAL_API_DEVISE: $PAYPAL_API_DEVISE", LOG_DEBUG);
409 dol_syslog(
"shipToName: $shipToName", LOG_DEBUG);
410 dol_syslog(
"shipToStreet: $shipToStreet", LOG_DEBUG);
411 dol_syslog(
"shipToCity: $shipToCity", LOG_DEBUG);
412 dol_syslog(
"shipToState: $shipToState", LOG_DEBUG);
413 dol_syslog(
"shipToCountryCode: $shipToCountryCode", LOG_DEBUG);
414 dol_syslog(
"shipToZip: $shipToZip", LOG_DEBUG);
415 dol_syslog(
"shipToStreet2: $shipToStreet2", LOG_DEBUG);
420 dol_syslog(
"SCRIPT_URI: ".(empty($_SERVER[
"SCRIPT_URI"]) ?
'' : $_SERVER[
"SCRIPT_URI"]), LOG_DEBUG);
423 $mesg =
print_paypal_redirect($PAYPAL_API_PRICE, $PAYPAL_API_DEVISE, $PAYPAL_PAYMENT_TYPE, $PAYPAL_API_OK, $PAYPAL_API_KO, $FULLTAG);
430 if ($paymentmethod ==
'paybox') {
432 $email = $conf->global->ONLINE_PAYMENT_SENDEMAIL;
433 $thirdparty_id =
GETPOST(
'thirdparty_id',
'int');
435 $origfulltag =
GETPOST(
"fulltag",
'alpha');
438 $urlok = preg_replace(
'/securekey=[^&]+&?/',
'', $urlok);
439 $urlko = preg_replace(
'/securekey=[^&]+&?/',
'', $urlko);
441 if (empty($PRICE) || !is_numeric($PRICE)) {
442 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount"));
443 } elseif (empty($email)) {
444 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ONLINE_PAYMENT_SENDEMAIL"));
445 } elseif (!isValidEMail($email)) {
446 $mesg = $langs->trans(
"ErrorBadEMail", $email);
447 } elseif (!$origfulltag) {
448 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"PaymentCode"));
450 $mesg =
'Error urlok too long '.$urlok.
' (Paybox requires 150, found '.strlen($urlok).
')';
452 $mesg =
'Error urlko too long '.$urlko.
' (Paybox requires 150, found '.strlen($urlok).
')';
456 dol_syslog(
"newpayment.php call paybox api and do redirect", LOG_DEBUG);
458 include_once DOL_DOCUMENT_ROOT.
'/paybox/lib/paybox.lib.php';
466 if ($paymentmethod ==
'stripe') {
467 if (
GETPOST(
'newamount',
'alpha')) {
470 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount")),
null,
'errors');
481 $amountstripe = $amount;
485 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
486 if (!in_array($currency, $arrayzerounitcurrency)) {
487 $amountstripe = $amountstripe * 100;
490 dol_syslog(
"--- newpayment.php Execute action = ".$action.
" STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION=".
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION'), LOG_DEBUG, 0,
'_payment');
491 dol_syslog(
"GET=".var_export($_GET,
true), LOG_DEBUG, 0,
'_payment');
492 dol_syslog(
"POST=".var_export($_POST,
true), LOG_DEBUG, 0,
'_payment');
494 $stripeToken =
GETPOST(
"stripeToken",
'alpha');
495 $email =
GETPOST(
"email",
'alpha');
496 $thirdparty_id =
GETPOST(
'thirdparty_id',
'int');
498 $dol_id =
GETPOST(
'dol_id',
'int');
499 $vatnumber =
GETPOST(
'vatnumber',
'alpha');
502 dol_syslog(
"POST stripeToken = ".$stripeToken, LOG_DEBUG, 0,
'_payment');
503 dol_syslog(
"POST email = ".$email, LOG_DEBUG, 0,
'_payment');
504 dol_syslog(
"POST thirdparty_id = ".$thirdparty_id, LOG_DEBUG, 0,
'_payment');
505 dol_syslog(
"POST vatnumber = ".$vatnumber, LOG_DEBUG, 0,
'_payment');
511 if (!
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION')) {
514 'dol_version' => DOL_VERSION,
515 'dol_entity' => $conf->entity,
516 'dol_company' => $mysoc->name,
517 'dol_tax_num' => $vatnumber,
521 if (!empty($thirdparty_id)) {
522 $metadata[
"dol_thirdparty_id"] = $thirdparty_id;
525 if ($thirdparty_id > 0) {
526 dol_syslog(
"Search existing Stripe customer profile for thirdparty_id=".$thirdparty_id, LOG_DEBUG, 0,
'_payment');
528 $service =
'StripeTest';
530 if (!empty($conf->global->STRIPE_LIVE) && !
GETPOST(
'forcesandbox',
'int')) {
531 $service =
'StripeLive';
535 $thirdparty =
new Societe($db);
536 $thirdparty->fetch($thirdparty_id);
539 include_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
540 $stripe =
new Stripe($db);
541 $stripeacc = $stripe->getStripeAccount($service);
542 $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 1);
543 if (empty($customer)) {
545 dol_syslog(
'Failed to get/create stripe customer for thirdparty id = '.$thirdparty_id.
' and servicestatus = '.$servicestatus.
': '.$stripe->error, LOG_ERR, 0,
'_payment');
546 setEventMessages(
'Failed to get/create stripe customer for thirdparty id = '.$thirdparty_id.
' and servicestatus = '.$servicestatus.
': '.$stripe->error,
null,
'errors');
553 $card = $customer->sources->create(array(
"source" => $stripeToken,
"metadata" => $metadata));
555 $card = $stripeToken;
560 dol_syslog(
'Failed to create card record', LOG_WARNING, 0,
'_payment');
564 if (!empty($FULLTAG)) {
565 $metadata[
"FULLTAG"] = $FULLTAG;
567 if (!empty($dol_id)) {
568 $metadata[
"dol_id"] = $dol_id;
570 if (!empty($dol_type)) {
571 $metadata[
"dol_type"] = $dol_type;
574 dol_syslog(
"Create charge on card ".$card->id, LOG_DEBUG, 0,
'_payment');
575 $charge = \Stripe\Charge::create(array(
576 'amount' =>
price2num($amountstripe,
'MU'),
577 'currency' => $currency,
579 'description' =>
'Stripe payment: '.$FULLTAG.
' ref='.$ref,
580 'metadata' => $metadata,
581 'customer' => $customer->id,
583 'statement_descriptor_suffix' =>
dol_trunc($FULLTAG, 10,
'right',
'UTF-8', 1),
584 ), array(
"idempotency_key" =>
"$FULLTAG",
"stripe_account" =>
"$stripeacc"));
586 if (empty($charge)) {
588 dol_syslog(
'Failed to charge card', LOG_WARNING, 0,
'_payment');
595 $vatcleaned = $vatnumber ? $vatnumber :
null;
606 dol_syslog(
"Create anonymous customer card profile", LOG_DEBUG, 0,
'_payment');
608 $customer = \Stripe\Customer::create(array(
610 'description' => ($email ?
'Anonymous customer for '.$email :
'Anonymous customer'),
611 'metadata' => $metadata,
612 'source' => $stripeToken
631 if (!empty($FULLTAG)) {
632 $metadata[
"FULLTAG"] = $FULLTAG;
634 if (!empty($dol_id)) {
635 $metadata[
"dol_id"] = $dol_id;
637 if (!empty($dol_type)) {
638 $metadata[
"dol_type"] = $dol_type;
643 dol_syslog(
"Create charge", LOG_DEBUG, 0,
'_payment');
644 $charge = \Stripe\Charge::create(array(
645 'customer' => $customer->id,
646 'amount' =>
price2num($amountstripe,
'MU'),
647 'currency' => $currency,
649 'description' =>
'Stripe payment: '.$FULLTAG.
' ref='.$ref,
650 'metadata' => $metadata,
651 'statement_descriptor' =>
dol_trunc($FULLTAG, 10,
'right',
'UTF-8', 1),
652 ), array(
"idempotency_key" =>
"$FULLTAG",
"stripe_account" =>
"$stripeacc"));
654 if (empty($charge)) {
656 dol_syslog(
'Failed to charge card', LOG_WARNING, 0,
'_payment');
661 }
catch (\
Stripe\Error\Card $e) {
663 $body = $e->getJsonBody();
664 $err = $body[
'error'];
666 print(
'Status is:'.$e->getHttpStatus().
"\n");
667 print(
'Type is:'.$err[
'type'].
"\n");
668 print(
'Code is:'.$err[
'code'].
"\n");
670 print(
'Param is:'.$err[
'param'].
"\n");
671 print(
'Message is:'.$err[
'message'].
"\n");
674 $errormessage =
"ErrorCard ".$e->getMessage().
" err=".var_export($err,
true);
675 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
678 }
catch (\
Stripe\Error\RateLimit $e) {
681 $errormessage =
"ErrorRateLimit ".$e->getMessage();
682 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
685 }
catch (\
Stripe\Error\InvalidRequest $e) {
688 $errormessage =
"ErrorInvalidRequest ".$e->getMessage();
689 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
692 }
catch (\
Stripe\Error\Authentication $e) {
696 $errormessage =
"ErrorAuthentication ".$e->getMessage();
697 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
700 }
catch (\
Stripe\Error\ApiConnection $e) {
703 $errormessage =
"ErrorApiConnection ".$e->getMessage();
704 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
707 }
catch (\
Stripe\Error\Base $e) {
711 $errormessage =
"ErrorBase ".$e->getMessage();
712 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
718 $errormessage =
"ErrorException ".$e->getMessage();
719 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
726 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION')) {
727 $service =
'StripeTest';
729 if (!empty($conf->global->STRIPE_LIVE) && !
GETPOST(
'forcesandbox',
'int')) {
730 $service =
'StripeLive';
733 include_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
734 $stripe =
new Stripe($db);
735 $stripeacc = $stripe->getStripeAccount($service);
739 $paymentintent_id =
GETPOST(
"paymentintent_id",
"alpha");
742 global $stripearrayofkeysbyenv;
743 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
746 if (empty($stripeacc)) {
747 $paymentintent = \Stripe\PaymentIntent::retrieve($paymentintent_id);
749 $paymentintent = \Stripe\PaymentIntent::retrieve($paymentintent_id, array(
"stripe_account" => $stripeacc));
753 $errormessage =
"CantRetrievePaymentIntent ".$e->getMessage();
754 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
759 if ($paymentintent->status !=
'succeeded') {
761 $errormessage =
"StatusOfRetrievedIntent is not succeeded: ".$paymentintent->status;
762 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
772 if (!empty($paymentintent->currency) && !empty($paymentintent->amount)) {
773 $currency = strtoupper($paymentintent->currency);
774 $amount = $paymentintent->amount;
778 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
779 if (!in_array($currency, $arrayzerounitcurrency)) {
780 $amount = $amount / 100;
789 $_SESSION[
"onlinetoken"] = $stripeToken;
790 $_SESSION[
"FinalPaymentAmt"] = $amount;
791 $_SESSION[
"currencyCodeType"] = $currency;
792 $_SESSION[
"paymentType"] =
'';
793 $_SESSION[
'ipaddress'] = ($remoteip ? $remoteip :
'unknown');
794 $_SESSION[
'payerID'] = is_object($customer) ? $customer->id :
'';
795 $_SESSION[
'TRANSACTIONID'] = (is_object($charge) ? $charge->id : (is_object($paymentintent) ? $paymentintent->id :
''));
796 $_SESSION[
'errormessage'] = $errormessage;
798 dol_syslog(
"Action charge stripe STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION=".
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION').
" ip=".$remoteip, LOG_DEBUG, 0,
'_payment');
799 dol_syslog(
"onlinetoken=".$_SESSION[
"onlinetoken"].
" FinalPaymentAmt=".$_SESSION[
"FinalPaymentAmt"].
" currencyCodeType=".$_SESSION[
"currencyCodeType"].
" payerID=".$_SESSION[
'payerID'].
" TRANSACTIONID=".$_SESSION[
'TRANSACTIONID'], LOG_DEBUG, 0,
'_payment');
800 dol_syslog(
"FULLTAG=".$FULLTAG, LOG_DEBUG, 0,
'_payment');
801 dol_syslog(
"error=".$error.
" errormessage=".$errormessage, LOG_DEBUG, 0,
'_payment');
802 dol_syslog(
"_SERVER[SERVER_NAME] = ".(empty($_SERVER[
"SERVER_NAME"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_NAME"])), LOG_DEBUG, 0,
'_payment');
803 dol_syslog(
"_SERVER[SERVER_ADDR] = ".(empty($_SERVER[
"SERVER_ADDR"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_ADDR"])), LOG_DEBUG, 0,
'_payment');
804 dol_syslog(
"Now call the redirect to paymentok or paymentko, URL = ".($error ? $urlko : $urlok), LOG_DEBUG, 0,
'_payment');
807 header(
"Location: ".$urlko);
810 header(
"Location: ".$urlok);
823 if (!empty($conf->global->ONLINE_PAYMENT_CSS_URL)) {
824 $head =
'<link rel="stylesheet" type="text/css" href="'.$conf->global->ONLINE_PAYMENT_CSS_URL.
'?lang='.$langs->defaultlang.
'">'.
"\n";
827 $conf->dol_hide_topmenu = 1;
828 $conf->dol_hide_leftmenu = 1;
830 $replacemainarea = (empty($conf->dol_hide_leftmenu) ?
'<div>' :
'').
'<div>';
831 llxHeader($head, $langs->trans(
"PaymentForm"),
'',
'', 0, 0,
'',
'',
'',
'onlinepaymentbody', $replacemainarea);
833 dol_syslog(
"--- newpayment.php action = ".$action, LOG_DEBUG, 0,
'_payment');
834 dol_syslog(
"newpayment.php show page source=".$source.
" paymentmethod=".$paymentmethod.
' amount='.$amount.
' newamount='.
GETPOST(
"newamount",
'alpha').
" ref=".$ref, LOG_DEBUG, 0,
'_payment');
835 dol_syslog(
"_SERVER[SERVER_NAME] = ".(empty($_SERVER[
"SERVER_NAME"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_NAME"])), LOG_DEBUG, 0,
'_payment');
836 dol_syslog(
"_SERVER[SERVER_ADDR] = ".(empty($_SERVER[
"SERVER_ADDR"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_ADDR"])), LOG_DEBUG, 0,
'_payment');
839 if ($source && in_array($ref, array(
'member_ref',
'contractline_ref',
'invoice_ref',
'order_ref',
'donation_ref',
''))) {
840 $langs->load(
"errors");
841 dol_print_error_email(
'BADREFINPAYMENTFORM', $langs->trans(
"ErrorBadLinkSourceSetButBadValueForRef", $source, $ref));
850 if ((empty($paymentmethod) || $paymentmethod ==
'paypal') &&
isModEnabled(
'paypal') && (!empty($conf->global->PAYPAL_API_SANDBOX) ||
GETPOST(
'forcesandbox',
'int'))) {
851 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Paypal'),
'',
'warning');
853 if ((empty($paymentmethod) || $paymentmethod ==
'stripe') &&
isModEnabled(
'stripe') && (empty($conf->global->STRIPE_LIVE) ||
GETPOST(
'forcesandbox',
'int'))) {
854 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Stripe'),
'',
'warning');
858 print
'<span id="dolpaymentspan"></span>'.
"\n";
859 print
'<div class="center">'.
"\n";
860 print
'<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
861 print
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
862 print
'<input type="hidden" name="action" value="dopayment">'.
"\n";
863 print
'<input type="hidden" name="tag" value="'.GETPOST(
"tag",
'alpha').
'">'.
"\n";
864 print
'<input type="hidden" name="suffix" value="'.dol_escape_htmltag($suffix).
'">'.
"\n";
865 print
'<input type="hidden" name="securekey" value="'.dol_escape_htmltag($SECUREKEY).
'">'.
"\n";
866 print
'<input type="hidden" name="e" value="'.$entity.
'" />';
867 print
'<input type="hidden" name="forcesandbox" value="'.GETPOST(
'forcesandbox',
'int').
'" />';
873 $logosmall = $mysoc->logo_small;
874 $logo = $mysoc->logo;
875 $paramlogo =
'ONLINE_PAYMENT_LOGO_'.$suffix;
876 if (!empty($conf->global->$paramlogo)) {
877 $logosmall = $conf->global->$paramlogo;
878 } elseif (!empty($conf->global->ONLINE_PAYMENT_LOGO)) {
879 $logosmall = $conf->global->ONLINE_PAYMENT_LOGO;
885 if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.
'/logos/thumbs/'.$logosmall)) {
886 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
887 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
888 } elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.
'/logos/'.$logo)) {
889 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
890 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
895 print
'<div class="backgreypublicpayment">';
896 print
'<div class="logopublicpayment">';
897 print
'<img id="dolpaymentlogo" src="'.$urllogo.
'"';
900 if (empty($conf->global->MAIN_HIDE_POWERED_BY)) {
901 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>';
905 if (!empty($conf->global->MAIN_IMAGE_PUBLIC_PAYMENT)) {
906 print
'<div class="backimagepublicpayment">';
907 print
'<img id="idMAIN_IMAGE_PUBLIC_PAYMENT" src="'.$conf->global->MAIN_IMAGE_PUBLIC_PAYMENT.
'">';
914 print
'<!-- Form to send a payment -->'.
"\n";
915 print
'<!-- creditor = '.dol_escape_htmltag($creditor).
' -->'.
"\n";
918 print
'<!-- PAYPAL_API_SANDBOX = '.getDolGlobalString(
'PAYPAL_API_SANDBOX').
' -->'.
"\n";
919 print
'<!-- PAYPAL_API_INTEGRAL_OR_PAYPALONLY = '.getDolGlobalString(
'PAYPAL_API_INTEGRAL_OR_PAYPALONLY').
' -->'.
"\n";
922 print
'<!-- PAYBOX_CGI_URL = '.getDolGlobalString(
'PAYBOX_CGI_URL_V2').
' -->'.
"\n";
925 print
'<!-- STRIPE_LIVE = '.getDolGlobalString(
'STRIPE_LIVE').
' -->'.
"\n";
927 print
'<!-- urlok = '.$urlok.
' -->'.
"\n";
928 print
'<!-- urlko = '.$urlko.
' -->'.
"\n";
932 print
'<table id="dolpublictable" summary="Payment form" class="center">'.
"\n";
936 if (!empty($conf->global->PAYMENT_NEWFORM_TEXT)) {
937 $langs->load(
"members");
938 if (preg_match(
'/^\((.*)\)$/', $conf->global->PAYMENT_NEWFORM_TEXT, $reg)) {
939 $text .= $langs->trans($reg[1]).
"<br>\n";
941 $text .= $conf->global->PAYMENT_NEWFORM_TEXT.
"<br>\n";
943 $text =
'<tr><td align="center"><br>'.$text.
'<br></td></tr>'.
"\n";
946 $text .=
'<tr><td class="textpublicpayment"><br><strong>'.$langs->trans(
"WelcomeOnPaymentPage").
'</strong></td></tr>'.
"\n";
947 $text .=
'<tr><td class="textpublicpayment">'.$langs->trans(
"ThisScreenAllowsYouToPay", $creditor).
'<br><br></td></tr>'.
"\n";
952 print
'<tr><td align="center">';
953 print
'<table with="100%" id="tablepublicpayment">';
954 print
'<tr><td align="left" colspan="2" class="opacitymedium">'.$langs->trans(
"ThisIsInformationOnPayment").
' :</td></tr>'.
"\n";
965 $tag =
GETPOST(
"tag",
'alpha');
966 if (
GETPOST(
'fulltag',
'alpha')) {
967 $fulltag =
GETPOST(
'fulltag',
'alpha');
969 $fulltag =
"TAG=".$tag;
973 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
974 print
'</td><td class="CTableRow2">';
975 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
976 print
'<b>'.$creditor.
'</b>';
977 print
'<input type="hidden" name="creditor" value="'.$creditor.
'">';
978 print
'</td></tr>'.
"\n";
981 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Amount");
982 if (empty($amount)) {
983 print
' ('.$langs->trans(
"ToComplete").
')';
985 print
'</td><td class="CTableRow2">';
986 if (empty($amount) || !is_numeric($amount)) {
987 print
'<input type="hidden" name="amount" value="'.price2num(
GETPOST(
"amount",
'alpha'),
'MT').
'">';
988 print
'<input class="flat maxwidth75" type="text" name="newamount" value="'.price2num(
GETPOST(
"newamount",
"alpha"),
'MT').
'">';
990 print
' <b>'.$langs->trans(
"Currency".$currency).
'</b>';
992 print
'<b class="amount">'.price($amount, 1, $langs, 1, -1, -1, $currency).
'</b>';
993 print
'<input type="hidden" name="amount" value="'.$amount.
'">';
994 print
'<input type="hidden" name="newamount" value="'.$amount.
'">';
996 print
'<input type="hidden" name="currency" value="'.$currency.
'">';
997 print
'</td></tr>'.
"\n";
1000 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentCode");
1001 print
'</td><td class="CTableRow2"><b style="word-break: break-all;">'.$fulltag.
'</b>';
1002 print
'<input type="hidden" name="tag" value="'.$tag.
'">';
1003 print
'<input type="hidden" name="fulltag" value="'.$fulltag.
'">';
1004 print
'</td></tr>'.
"\n";
1012 if ($source ==
'order') {
1014 $langs->load(
"orders");
1016 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
1019 $result = $order->fetch(
'', $ref);
1021 $mesg = $order->error;
1024 $result = $order->fetch_thirdparty($order->socid);
1028 if ($action !=
'dopayment') {
1029 $amount = $order->total_ttc;
1030 if (
GETPOST(
"amount",
'alpha')) {
1031 $amount =
GETPOST(
"amount",
'alpha');
1036 if (
GETPOST(
'fulltag',
'alpha')) {
1037 $fulltag =
GETPOST(
'fulltag',
'alpha');
1039 $fulltag =
'ORD='.$order->id.
'.CUS='.$order->thirdparty->id;
1041 $tag = $TAG; $fulltag .=
'.TAG='.$TAG;
1047 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
1048 print
'</td><td class="CTableRow2">';
1049 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1050 print
'<b>'.$creditor.
'</b>';
1051 print
'<input type="hidden" name="creditor" value="'.$creditor.
'">';
1052 print
'</td></tr>'.
"\n";
1055 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"ThirdParty");
1056 print
'</td><td class="CTableRow2">';
1057 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1058 print
'<b>'.$order->thirdparty->name.
'</b>';
1059 print
'</td></tr>'.
"\n";
1062 $text =
'<b>'.$langs->trans(
"PaymentOrderRef", $order->ref).
'</b>';
1063 if (
GETPOST(
'desc',
'alpha')) {
1064 $text =
'<b>'.$langs->trans(
GETPOST(
'desc',
'alpha')).
'</b>';
1066 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Designation");
1067 print
'</td><td class="CTableRow2">'.$text;
1068 print
'<input type="hidden" name="s" value="'.dol_escape_htmltag($source).
'">';
1069 print
'<input type="hidden" name="ref" value="'.dol_escape_htmltag($order->ref).
'">';
1070 print
'<input type="hidden" name="dol_id" value="'.dol_escape_htmltag($order->id).
'">';
1071 $directdownloadlink = $order->getLastMainDocLink(
'commande');
1072 if ($directdownloadlink) {
1073 print
'<br><a href="'.$directdownloadlink.
'" rel="nofollow noopener">';
1074 print
img_mime($order->last_main_doc,
'');
1075 print $langs->trans(
"DownloadDocument").
'</a>';
1077 print
'</td></tr>'.
"\n";
1080 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Amount");
1081 if (empty($amount)) {
1082 print
' ('.$langs->trans(
"ToComplete").
')';
1084 print
'</td><td class="CTableRow2">';
1085 if (empty($amount) || !is_numeric($amount)) {
1086 print
'<input type="hidden" name="amount" value="'.price2num(
GETPOST(
"amount",
'alpha'),
'MT').
'">';
1087 print
'<input class="flat maxwidth75" type="text" name="newamount" value="'.price2num(
GETPOST(
"newamount",
"alpha"),
'MT').
'">';
1089 print
' <b>'.$langs->trans(
"Currency".$currency).
'</b>';
1091 print
'<b class="amount">'.price($amount, 1, $langs, 1, -1, -1, $currency).
'</b>';
1092 print
'<input type="hidden" name="amount" value="'.$amount.
'">';
1093 print
'<input type="hidden" name="newamount" value="'.$amount.
'">';
1095 print
'<input type="hidden" name="currency" value="'.$currency.
'">';
1096 print
'</td></tr>'.
"\n";
1099 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentCode");
1100 print
'</td><td class="CTableRow2"><b style="word-break: break-all;">'.$fulltag.
'</b>';
1101 print
'<input type="hidden" name="tag" value="'.dol_escape_htmltag($tag).
'">';
1102 print
'<input type="hidden" name="fulltag" value="'.dol_escape_htmltag($fulltag).
'">';
1103 print
'</td></tr>'.
"\n";
1106 $shipToName = $order->thirdparty->name;
1107 $shipToStreet = $order->thirdparty->address;
1108 $shipToCity = $order->thirdparty->town;
1109 $shipToState = $order->thirdparty->state_code;
1110 $shipToCountryCode = $order->thirdparty->country_code;
1111 $shipToZip = $order->thirdparty->zip;
1112 $shipToStreet2 =
'';
1113 $phoneNum = $order->thirdparty->phone;
1114 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1115 print
'<input type="hidden" name="shipToName" value="'.dol_escape_htmltag($shipToName).
'">'.
"\n";
1116 print
'<input type="hidden" name="shipToStreet" value="'.dol_escape_htmltag($shipToStreet).
'">'.
"\n";
1117 print
'<input type="hidden" name="shipToCity" value="'.dol_escape_htmltag($shipToCity).
'">'.
"\n";
1118 print
'<input type="hidden" name="shipToState" value="'.dol_escape_htmltag($shipToState).
'">'.
"\n";
1119 print
'<input type="hidden" name="shipToCountryCode" value="'.dol_escape_htmltag($shipToCountryCode).
'">'.
"\n";
1120 print
'<input type="hidden" name="shipToZip" value="'.dol_escape_htmltag($shipToZip).
'">'.
"\n";
1121 print
'<input type="hidden" name="shipToStreet2" value="'.dol_escape_htmltag($shipToStreet2).
'">'.
"\n";
1122 print
'<input type="hidden" name="phoneNum" value="'.dol_escape_htmltag($phoneNum).
'">'.
"\n";
1124 print
'<!-- Shipping address not complete, so we don t use it -->'.
"\n";
1126 if (is_object($order->thirdparty)) {
1127 print
'<input type="hidden" name="thirdparty_id" value="'.$order->thirdparty->id.
'">'.
"\n";
1129 print
'<input type="hidden" name="email" value="'.$order->thirdparty->email.
'">'.
"\n";
1130 print
'<input type="hidden" name="vatnumber" value="'.dol_escape_htmltag($order->thirdparty->tva_intra).
'">'.
"\n";
1131 $labeldesc = $langs->trans(
"Order").
' '.$order->ref;
1132 if (
GETPOST(
'desc',
'alpha')) {
1133 $labeldesc =
GETPOST(
'desc',
'alpha');
1135 print
'<input type="hidden" name="desc" value="'.dol_escape_htmltag($labeldesc).
'">'.
"\n";
1140 if ($source ==
'invoice') {
1142 $langs->load(
"bills");
1144 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1147 $result = $invoice->fetch(
'', $ref);
1149 $mesg = $invoice->error;
1152 $result = $invoice->fetch_thirdparty($invoice->socid);
1156 if ($action !=
'dopayment') {
1157 $amount =
price2num($invoice->total_ttc - ($invoice->getSommePaiement() + $invoice->getSumCreditNotesUsed() + $invoice->getSumDepositsUsed()));
1158 if (
GETPOST(
"amount",
'alpha')) {
1159 $amount =
GETPOST(
"amount",
'alpha');
1164 if (
GETPOST(
'fulltag',
'alpha')) {
1165 $fulltag =
GETPOST(
'fulltag',
'alpha');
1167 $fulltag =
'INV='.$invoice->id.
'.CUS='.$invoice->thirdparty->id;
1169 $tag = $TAG; $fulltag .=
'.TAG='.$TAG;
1175 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
1176 print
'</td><td class="CTableRow2">';
1177 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1178 print
'<b>'.$creditor.
'</b>';
1179 print
'<input type="hidden" name="creditor" value="'.dol_escape_htmltag($creditor).
'">';
1180 print
'</td></tr>'.
"\n";
1183 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"ThirdParty");
1184 print
'</td><td class="CTableRow2">';
1185 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1186 print
'<b>'.$invoice->thirdparty->name.
'</b>';
1187 print
'</td></tr>'.
"\n";
1190 $text =
'<b>'.$langs->trans(
"PaymentInvoiceRef", $invoice->ref).
'</b>';
1191 if (
GETPOST(
'desc',
'alpha')) {
1192 $text =
'<b>'.$langs->trans(
GETPOST(
'desc',
'alpha')).
'</b>';
1194 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Designation");
1195 print
'</td><td class="CTableRow2">'.$text;
1196 print
'<input type="hidden" name="s" value="'.dol_escape_htmltag($source).
'">';
1197 print
'<input type="hidden" name="ref" value="'.dol_escape_htmltag($invoice->ref).
'">';
1198 print
'<input type="hidden" name="dol_id" value="'.dol_escape_htmltag($invoice->id).
'">';
1199 $directdownloadlink = $invoice->getLastMainDocLink(
'facture');
1200 if ($directdownloadlink) {
1201 print
'<br><a href="'.$directdownloadlink.
'">';
1202 print
img_mime($invoice->last_main_doc,
'');
1203 print $langs->trans(
"DownloadDocument").
'</a>';
1205 print
'</td></tr>'.
"\n";
1208 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentAmount");
1209 if (empty($amount) && empty($object->paye)) {
1210 print
' ('.$langs->trans(
"ToComplete").
')';
1212 print
'</td><td class="CTableRow2">';
1213 if ($object->type == $object::TYPE_CREDIT_NOTE) {
1214 print
'<b>'.$langs->trans(
"CreditNote").
'</b>';
1215 } elseif (empty($object->paye)) {
1216 if (empty($amount) || !is_numeric($amount)) {
1217 print
'<input type="hidden" name="amount" value="'.price2num(
GETPOST(
"amount",
'alpha'),
'MT').
'">';
1218 print
'<input class="flat maxwidth75" type="text" name="newamount" value="'.price2num(
GETPOST(
"newamount",
"alpha"),
'MT').
'">';
1219 print
' <b>'.$langs->trans(
"Currency".$currency).
'</b>';
1221 print
'<b class="amount">'.price($amount, 1, $langs, 1, -1, -1, $currency).
'</b>';
1222 print
'<input type="hidden" name="amount" value="'.$amount.
'">';
1223 print
'<input type="hidden" name="newamount" value="'.$amount.
'">';
1226 print
'<b class="amount">'.price($object->total_ttc, 1, $langs, 1, -1, -1, $currency).
'</b>';
1228 print
'<input type="hidden" name="currency" value="'.$currency.
'">';
1229 print
'</td></tr>'.
"\n";
1232 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentCode");
1233 print
'</td><td class="CTableRow2"><b style="word-break: break-all;">'.$fulltag.
'</b>';
1234 print
'<input type="hidden" name="tag" value="'.$tag.
'">';
1235 print
'<input type="hidden" name="fulltag" value="'.$fulltag.
'">';
1236 print
'</td></tr>'.
"\n";
1239 $shipToName = $invoice->thirdparty->name;
1240 $shipToStreet = $invoice->thirdparty->address;
1241 $shipToCity = $invoice->thirdparty->town;
1242 $shipToState = $invoice->thirdparty->state_code;
1243 $shipToCountryCode = $invoice->thirdparty->country_code;
1244 $shipToZip = $invoice->thirdparty->zip;
1245 $shipToStreet2 =
'';
1246 $phoneNum = $invoice->thirdparty->phone;
1247 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1248 print
'<input type="hidden" name="shipToName" value="'.$shipToName.
'">'.
"\n";
1249 print
'<input type="hidden" name="shipToStreet" value="'.$shipToStreet.
'">'.
"\n";
1250 print
'<input type="hidden" name="shipToCity" value="'.$shipToCity.
'">'.
"\n";
1251 print
'<input type="hidden" name="shipToState" value="'.$shipToState.
'">'.
"\n";
1252 print
'<input type="hidden" name="shipToCountryCode" value="'.$shipToCountryCode.
'">'.
"\n";
1253 print
'<input type="hidden" name="shipToZip" value="'.$shipToZip.
'">'.
"\n";
1254 print
'<input type="hidden" name="shipToStreet2" value="'.$shipToStreet2.
'">'.
"\n";
1255 print
'<input type="hidden" name="phoneNum" value="'.$phoneNum.
'">'.
"\n";
1257 print
'<!-- Shipping address not complete, so we don t use it -->'.
"\n";
1259 if (is_object($invoice->thirdparty)) {
1260 print
'<input type="hidden" name="thirdparty_id" value="'.$invoice->thirdparty->id.
'">'.
"\n";
1262 print
'<input type="hidden" name="email" value="'.$invoice->thirdparty->email.
'">'.
"\n";
1263 print
'<input type="hidden" name="vatnumber" value="'.$invoice->thirdparty->tva_intra.
'">'.
"\n";
1264 $labeldesc = $langs->trans(
"Invoice").
' '.$invoice->ref;
1265 if (
GETPOST(
'desc',
'alpha')) {
1266 $labeldesc =
GETPOST(
'desc',
'alpha');
1268 print
'<input type="hidden" name="desc" value="'.dol_escape_htmltag($labeldesc).
'">'.
"\n";
1272 if ($source ==
'contractline') {
1274 $langs->load(
"contracts");
1276 require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
1281 $result = $contractline->fetch(
'', $ref);
1283 $mesg = $contractline->error;
1286 if ($contractline->fk_contrat > 0) {
1287 $result = $contract->fetch($contractline->fk_contrat);
1289 $result = $contract->fetch_thirdparty($contract->socid);
1291 $mesg = $contract->error;
1295 $mesg =
'ErrorRecordNotFound';
1299 $object = $contractline;
1301 if ($action !=
'dopayment') {
1302 $amount = $contractline->total_ttc;
1304 if ($contractline->fk_product && !empty($conf->global->PAYMENT_USE_NEW_PRICE_FOR_CONTRACTLINES)) {
1306 $result = $product->fetch($contractline->fk_product);
1309 if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
1310 $pu_ht = $product->multiprices[$contract->thirdparty->price_level];
1311 $pu_ttc = $product->multiprices_ttc[$contract->thirdparty->price_level];
1312 $price_base_type = $product->multiprices_base_type[$contract->thirdparty->price_level];
1314 $pu_ht = $product->price;
1315 $pu_ttc = $product->price_ttc;
1316 $price_base_type = $product->price_base_type;
1320 if (empty($amount)) {
1326 if (
GETPOST(
"amount",
'alpha')) {
1327 $amount =
GETPOST(
"amount",
'alpha');
1332 if (
GETPOST(
'fulltag',
'alpha')) {
1333 $fulltag =
GETPOST(
'fulltag',
'alpha');
1335 $fulltag =
'COL='.$contractline->id.
'.CON='.$contract->id.
'.CUS='.$contract->thirdparty->id.
'.DAT='.
dol_print_date(
dol_now(),
'%Y%m%d%H%M%S');
1337 $tag = $TAG; $fulltag .=
'.TAG='.$TAG;
1348 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
1349 print
'</td><td class="CTableRow2"><b>'.$creditor.
'</b>';
1350 print
'<input type="hidden" name="creditor" value="'.$creditor.
'">';
1351 print
'</td></tr>'.
"\n";
1354 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"ThirdParty");
1355 print
'</td><td class="CTableRow2"><b>'.$contract->thirdparty->name.
'</b>';
1356 print
'</td></tr>'.
"\n";
1359 $text =
'<b>'.$langs->trans(
"PaymentRenewContractId", $contract->ref, $contractline->ref).
'</b>';
1360 if ($contractline->fk_product > 0) {
1361 $contractline->fetch_product();
1362 $text .=
'<br>'.$contractline->product->ref.($contractline->product->label ?
' - '.$contractline->product->label :
'');
1364 if ($contractline->description) {
1365 $text .=
'<br>'.dol_htmlentitiesbr($contractline->description);
1367 if ($contractline->date_end) {
1368 $text .=
'<br>'.$langs->trans(
"ExpiredSince").
': '.
dol_print_date($contractline->date_end);
1370 if (
GETPOST(
'desc',
'alpha')) {
1371 $text =
'<b>'.$langs->trans(
GETPOST(
'desc',
'alpha')).
'</b>';
1373 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Designation");
1374 print
'</td><td class="CTableRow2">'.$text;
1375 print
'<input type="hidden" name="source" value="'.dol_escape_htmltag($source).
'">';
1376 print
'<input type="hidden" name="ref" value="'.dol_escape_htmltag($contractline->ref).
'">';
1377 print
'<input type="hidden" name="dol_id" value="'.dol_escape_htmltag($contractline->id).
'">';
1378 $directdownloadlink = $contract->getLastMainDocLink(
'contract');
1379 if ($directdownloadlink) {
1380 print
'<br><a href="'.$directdownloadlink.
'">';
1381 print
img_mime($contract->last_main_doc,
'');
1382 print $langs->trans(
"DownloadDocument").
'</a>';
1384 print
'</td></tr>'.
"\n";
1387 $label = $langs->trans(
"Quantity");
1390 if ($contractline->fk_product) {
1391 if ($contractline->product->isService() && $contractline->product->duration_value > 0) {
1392 $label = $langs->trans(
"Duration");
1395 if ($contractline->product->duration_value > 1) {
1396 $dur = array(
"h"=>$langs->trans(
"Hours"),
"d"=>$langs->trans(
"DurationDays"),
"w"=>$langs->trans(
"DurationWeeks"),
"m"=>$langs->trans(
"DurationMonths"),
"y"=>$langs->trans(
"DurationYears"));
1398 $dur = array(
"h"=>$langs->trans(
"Hour"),
"d"=>$langs->trans(
"DurationDay"),
"w"=>$langs->trans(
"DurationWeek"),
"m"=>$langs->trans(
"DurationMonth"),
"y"=>$langs->trans(
"DurationYear"));
1400 $duration = $contractline->product->duration_value.
' '.$dur[$contractline->product->duration_unit];
1403 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$label.
'</td>';
1404 print
'<td class="CTableRow2"><b>'.($duration ? $duration : $qty).
'</b>';
1405 print
'<input type="hidden" name="newqty" value="'.dol_escape_htmltag($qty).
'">';
1406 print
'</b></td></tr>'.
"\n";
1409 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Amount");
1410 if (empty($amount)) {
1411 print
' ('.$langs->trans(
"ToComplete").
')';
1413 print
'</td><td class="CTableRow2">';
1414 if (empty($amount) || !is_numeric($amount)) {
1415 print
'<input type="hidden" name="amount" value="'.price2num(
GETPOST(
"amount",
'alpha'),
'MT').
'">';
1416 print
'<input class="flat maxwidth75" type="text" name="newamount" value="'.price2num(
GETPOST(
"newamount",
"alpha"),
'MT').
'">';
1418 print
' <b>'.$langs->trans(
"Currency".$currency).
'</b>';
1420 print
'<b class="amount">'.price($amount, 1, $langs, 1, -1, -1, $currency).
'</b>';
1421 print
'<input type="hidden" name="amount" value="'.$amount.
'">';
1422 print
'<input type="hidden" name="newamount" value="'.$amount.
'">';
1424 print
'<input type="hidden" name="currency" value="'.$currency.
'">';
1425 print
'</td></tr>'.
"\n";
1428 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentCode");
1429 print
'</td><td class="CTableRow2"><b style="word-break: break-all;">'.$fulltag.
'</b>';
1430 print
'<input type="hidden" name="tag" value="'.$tag.
'">';
1431 print
'<input type="hidden" name="fulltag" value="'.$fulltag.
'">';
1432 print
'</td></tr>'.
"\n";
1435 $shipToName = $contract->thirdparty->name;
1436 $shipToStreet = $contract->thirdparty->address;
1437 $shipToCity = $contract->thirdparty->town;
1438 $shipToState = $contract->thirdparty->state_code;
1439 $shipToCountryCode = $contract->thirdparty->country_code;
1440 $shipToZip = $contract->thirdparty->zip;
1441 $shipToStreet2 =
'';
1442 $phoneNum = $contract->thirdparty->phone;
1443 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1444 print
'<input type="hidden" name="shipToName" value="'.$shipToName.
'">'.
"\n";
1445 print
'<input type="hidden" name="shipToStreet" value="'.$shipToStreet.
'">'.
"\n";
1446 print
'<input type="hidden" name="shipToCity" value="'.$shipToCity.
'">'.
"\n";
1447 print
'<input type="hidden" name="shipToState" value="'.$shipToState.
'">'.
"\n";
1448 print
'<input type="hidden" name="shipToCountryCode" value="'.$shipToCountryCode.
'">'.
"\n";
1449 print
'<input type="hidden" name="shipToZip" value="'.$shipToZip.
'">'.
"\n";
1450 print
'<input type="hidden" name="shipToStreet2" value="'.$shipToStreet2.
'">'.
"\n";
1451 print
'<input type="hidden" name="phoneNum" value="'.$phoneNum.
'">'.
"\n";
1453 print
'<!-- Shipping address not complete, so we don t use it -->'.
"\n";
1455 if (is_object($contract->thirdparty)) {
1456 print
'<input type="hidden" name="thirdparty_id" value="'.$contract->thirdparty->id.
'">'.
"\n";
1458 print
'<input type="hidden" name="email" value="'.$contract->thirdparty->email.
'">'.
"\n";
1459 print
'<input type="hidden" name="vatnumber" value="'.$contract->thirdparty->tva_intra.
'">'.
"\n";
1460 $labeldesc = $langs->trans(
"Contract").
' '.$contract->ref;
1461 if (
GETPOST(
'desc',
'alpha')) {
1462 $labeldesc =
GETPOST(
'desc',
'alpha');
1464 print
'<input type="hidden" name="desc" value="'.dol_escape_htmltag($labeldesc).
'">'.
"\n";
1468 if ($source ==
'member' || $source ==
'membersubscription') {
1469 $newsource =
'member';
1473 $langs->load(
"members");
1475 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
1476 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent_type.class.php';
1477 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
1482 $result = $member->fetch(
'', $ref);
1484 $mesg = $member->error;
1487 $member->fetch_thirdparty();
1490 $adht->fetch($member->typeid);
1494 if ($action !=
'dopayment') {
1495 $amount = $subscription->total_ttc;
1496 if (
GETPOST(
"amount",
'alpha')) {
1497 $amount =
GETPOST(
"amount",
'alpha');
1500 if (empty($amount)) {
1501 $amount = $adht->amount;
1504 $amount = max(0,
price2num($amount,
'MT'));
1507 if (
GETPOST(
'fulltag',
'alpha')) {
1508 $fulltag =
GETPOST(
'fulltag',
'alpha');
1512 $tag = $TAG; $fulltag .=
'.TAG='.$TAG;
1518 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
1519 print
'</td><td class="CTableRow2"><b>'.$creditor.
'</b>';
1520 print
'<input type="hidden" name="creditor" value="'.$creditor.
'">';
1521 print
'</td></tr>'.
"\n";
1524 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Member");
1525 print
'</td><td class="CTableRow2">';
1527 if ($member->morphy ==
'mor' && !empty($member->company)) {
1528 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1529 print $member->company;
1531 print
img_picto(
'',
'member',
'class="pictofixedwidth"');
1532 print $member->getFullName($langs);
1535 print
'</td></tr>'.
"\n";
1538 $text =
'<b>'.$langs->trans(
"PaymentSubscription").
'</b>';
1539 if (
GETPOST(
'desc',
'alpha')) {
1540 $text =
'<b>'.$langs->trans(
GETPOST(
'desc',
'alpha')).
'</b>';
1542 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Designation");
1543 print
'</td><td class="CTableRow2">'.$text;
1544 print
'<input type="hidden" name="source" value="'.dol_escape_htmltag($newsource).
'">';
1545 print
'<input type="hidden" name="ref" value="'.dol_escape_htmltag($member->ref).
'">';
1546 print
'</td></tr>'.
"\n";
1548 if ($object->datefin > 0) {
1549 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"DateEndSubscription");
1550 print
'</td><td class="CTableRow2">'.dol_print_date($member->datefin,
'day');
1551 print
'</td></tr>'.
"\n";
1554 if ($member->last_subscription_date || $member->last_subscription_amount) {
1557 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"LastSubscriptionDate");
1558 print
'</td><td class="CTableRow2">'.dol_print_date($member->last_subscription_date,
'day');
1559 print
'</td></tr>'.
"\n";
1563 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"LastSubscriptionAmount");
1564 print
'</td><td class="CTableRow2">'.price($member->last_subscription_amount);
1565 print
'</td></tr>'.
"\n";
1567 if (empty($amount) && !
GETPOST(
'newamount',
'alpha')) {
1568 $_GET[
'newamount'] = $member->last_subscription_amount;
1572 if ($member->type) {
1573 $oldtypeid = $member->typeid;
1576 if (!empty($conf->global->MEMBER_ALLOW_CHANGE_OF_TYPE)) {
1577 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent_type.class.php';
1580 $amountbytype = $adht->amountByType(1);
1583 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"LastMemberType");
1584 print
'</td><td class="CTableRow2">'.dol_escape_htmltag($member->type);
1585 print
"</td></tr>\n";
1588 $member->typeid = $newtypeid;
1589 $member->type =
dol_getIdFromCode($db, $newtypeid,
'adherent_type',
'rowid',
'libelle');
1594 $amount = (!empty($amountbytype[$member->typeid])) ? $amountbytype[$member->typeid] : $member->last_subscription_amount;
1596 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"NewSubscription");
1597 print
'</td><td class="CTableRow2">';
1598 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);
1599 print "</td></tr>\n
";
1600 } elseif ($action == 'dopayment') {
1601 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("NewMemberType
");
1602 print '</td><td class="CTableRow2
">'.dol_escape_htmltag($member->type);
1603 print '<input type="hidden
" name="membertypeid
" value="'.$member->typeid.'">';
1604 print "</td></tr>\n
";
1607 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("MemberType
");
1608 print '</td><td class="CTableRow2
">'.dol_escape_htmltag($member->type);
1609 print "</td></tr>\n
";
1614 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Amount
");
1615 // This place no longer allows amount edition
1616 if (!empty($conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO)) {
1617 print ' - <a href="'.$conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO.'" rel="external
" target="_blank
" rel="noopener noreferrer
">'.$langs->trans("SeeHere
").'</a>';
1619 print '</td><td class="CTableRow2
">';
1620 if (!empty($conf->global->MEMBER_MIN_AMOUNT) && $amount) {
1621 $amount = max(0, $conf->global->MEMBER_MIN_AMOUNT, $amount);
1623 print '<b class="amount
">'.price($amount, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
1624 $caneditamount = !empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) || $adht->caneditamount;
1625 $minimumamount = empty($conf->global->MEMBER_MIN_AMOUNT)? $adht->amount : max($conf->global->MEMBER_MIN_AMOUNT, $adht->amount > $amount);
1626 if (!$caneditamount && $minimumamount > $amount) {
1627 print ' '. $langs->trans("AmountIsLowerToMinimumNotice
", price($adht->amount, 1, $langs, 1, -1, -1, $currency));
1630 print '<input type="hidden
" name="amount
" value="'.$amount.'">';
1631 print '<input type="hidden
" name="newamount
" value="'.$amount.'">';
1632 print '<input type="hidden
" name="currency
" value="'.$currency.'">';
1633 print '</td></tr>'."\n
";
1636 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("PaymentCode
");
1637 print '</td><td class="CTableRow2
"><b style="word-
break:
break-all;
">'.$fulltag.'</b>';
1638 print '<input type="hidden
" name="tag
" value="'.$tag.'">';
1639 print '<input type="hidden
" name="fulltag
" value="'.$fulltag.'">';
1640 print '</td></tr>'."\n
";
1643 $shipToName = $member->getFullName($langs);
1644 $shipToStreet = $member->address;
1645 $shipToCity = $member->town;
1646 $shipToState = $member->state_code;
1647 $shipToCountryCode = $member->country_code;
1648 $shipToZip = $member->zip;
1649 $shipToStreet2 = '';
1650 $phoneNum = $member->phone;
1651 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1652 print '<!-- Shipping address information -->';
1653 print '<input type="hidden
" name="shipToName
" value="'.$shipToName.'">'."\n
";
1654 print '<input type="hidden
" name="shipToStreet
" value="'.$shipToStreet.'">'."\n
";
1655 print '<input type="hidden
" name="shipToCity
" value="'.$shipToCity.'">'."\n
";
1656 print '<input type="hidden
" name="shipToState
" value="'.$shipToState.'">'."\n
";
1657 print '<input type="hidden
" name="shipToCountryCode
" value="'.$shipToCountryCode.'">'."\n
";
1658 print '<input type="hidden
" name="shipToZip
" value="'.$shipToZip.'">'."\n
";
1659 print '<input type="hidden
" name="shipToStreet2
" value="'.$shipToStreet2.'">'."\n
";
1660 print '<input type="hidden
" name="phoneNum
" value="'.$phoneNum.'">'."\n
";
1662 print '<!-- Shipping address not complete, so we don t use it -->'."\n
";
1664 if (is_object($member->thirdparty)) {
1665 print '<input type="hidden
" name="thirdparty_id
" value="'.$member->thirdparty->id.'">'."\n
";
1667 print '<input type="hidden
" name="email
" value="'.$member->email.'">'."\n
";
1668 $labeldesc = $langs->trans("PaymentSubscription
");
1669 if (GETPOST('desc', 'alpha')) {
1670 $labeldesc = GETPOST('desc', 'alpha');
1672 print '<input type="hidden
" name="desc
" value="'.dol_escape_htmltag($labeldesc).'">'."\n
";
1675 // Payment on donation
1676 if ($source == 'donation') {
1678 $langs->load("don
");
1680 require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
1682 $don = new Don($db);
1683 $result = $don->fetch($ref);
1685 $mesg = $don->error;
1688 $don->fetch_thirdparty();
1692 if ($action != 'dopayment') { // Do not change amount if we just click on first dopayment
1693 if (GETPOST("amount
", 'alpha')) {
1694 $amount = GETPOST("amount
", 'alpha');
1696 $amount = $don->getRemainToPay();
1698 $amount = price2num($amount);
1701 if (GETPOST('fulltag', 'alpha')) {
1702 $fulltag = GETPOST('fulltag', 'alpha');
1704 $fulltag = 'DON='.$don->ref.'.DAT='.dol_print_date(dol_now(), '%Y%m%d%H%M%S');
1706 $tag = $TAG; $fulltag .= '.TAG='.$TAG;
1709 $fulltag = dol_string_unaccent($fulltag);
1712 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Creditor
");
1713 print '</td><td class="CTableRow2
"><b>'.$creditor.'</b>';
1714 print '<input type="hidden
" name="creditor
" value="'.$creditor.'">';
1715 print '</td></tr>'."\n
";
1718 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("ThirdParty
");
1719 print '</td><td class="CTableRow2
"><b>';
1720 if ($don->morphy == 'mor' && !empty($don->societe)) {
1721 print $don->societe;
1723 print $don->getFullName($langs);
1726 print '</td></tr>'."\n
";
1730 if (GETPOST('desc', 'alpha')) {
1731 $text = '<b>'.$langs->trans(GETPOST('desc', 'alpha')).'</b>';
1733 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Designation
");
1734 print '</td><td class="CTableRow2
">'.$text;
1735 print '<input type="hidden
" name="source
" value="'.dol_escape_htmltag($source).'">';
1736 print '<input type="hidden
" name="ref" value="'.dol_escape_htmltag($don->ref).'">';
1737 print '</td></tr>'."\n
";
1740 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Amount
");
1741 if (empty($amount)) {
1742 if (empty($conf->global->MEMBER_NEWFORM_AMOUNT)) {
1743 print ' ('.$langs->trans("ToComplete
");
1745 if (!empty($conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO)) {
1746 print ' - <a href="'.$conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO.'" rel="external
" target="_blank
" rel="noopener noreferrer
">'.$langs->trans("SeeHere
").'</a>';
1748 if (empty($conf->global->MEMBER_NEWFORM_AMOUNT)) {
1752 print '</td><td class="CTableRow2
">';
1754 if (empty($amount) || !is_numeric($amount)) {
1755 $valtoshow = price2num(GETPOST("newamount
", 'alpha'), 'MT');
1756 // force default subscription amount to value defined into constant...
1757 if (empty($valtoshow)) {
1758 if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) {
1759 if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT)) {
1760 $valtoshow = $conf->global->MEMBER_NEWFORM_AMOUNT;
1763 if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT)) {
1764 $amount = $conf->global->MEMBER_NEWFORM_AMOUNT;
1769 if (empty($amount) || !is_numeric($amount)) {
1770 //$valtoshow=price2num(GETPOST("newamount
",'alpha'),'MT');
1771 if (!empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) {
1772 $valtoshow = max($conf->global->MEMBER_MIN_AMOUNT, $valtoshow);
1774 print '<input type="hidden
" name="amount
" value="'.price2num(GETPOST("amount", 'alpha
'), 'MT
').'">';
1775 print '<input class="flat maxwidth75
" type="text
" name="newamount
" value="'.$valtoshow.'">';
1777 print ' <b>'.$langs->trans("Currency
".$currency).'</b>';
1779 $valtoshow = $amount;
1780 if (!empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) {
1781 $valtoshow = max($conf->global->MEMBER_MIN_AMOUNT, $valtoshow);
1782 $amount = $valtoshow;
1784 print '<b class="amount
">'.price($valtoshow, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
1785 print '<input type="hidden
" name="amount
" value="'.$valtoshow.'">';
1786 print '<input type="hidden
" name="newamount
" value="'.$valtoshow.'">';
1788 print '<input type="hidden
" name="currency
" value="'.$currency.'">';
1789 print '</td></tr>'."\n
";
1792 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("PaymentCode
");
1793 print '</td><td class="CTableRow2
"><b style="word-
break:
break-all;
">'.$fulltag.'</b>';
1794 print '<input type="hidden
" name="tag
" value="'.$tag.'">';
1795 print '<input type="hidden
" name="fulltag
" value="'.$fulltag.'">';
1796 print '</td></tr>'."\n
";
1799 $shipToName = $don->getFullName($langs);
1800 $shipToStreet = $don->address;
1801 $shipToCity = $don->town;
1802 $shipToState = $don->state_code;
1803 $shipToCountryCode = $don->country_code;
1804 $shipToZip = $don->zip;
1805 $shipToStreet2 = '';
1806 $phoneNum = $don->phone;
1807 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1808 print '<!-- Shipping address information -->';
1809 print '<input type="hidden
" name="shipToName
" value="'.$shipToName.'">'."\n
";
1810 print '<input type="hidden
" name="shipToStreet
" value="'.$shipToStreet.'">'."\n
";
1811 print '<input type="hidden
" name="shipToCity
" value="'.$shipToCity.'">'."\n
";
1812 print '<input type="hidden
" name="shipToState
" value="'.$shipToState.'">'."\n
";
1813 print '<input type="hidden
" name="shipToCountryCode
" value="'.$shipToCountryCode.'">'."\n
";
1814 print '<input type="hidden
" name="shipToZip
" value="'.$shipToZip.'">'."\n
";
1815 print '<input type="hidden
" name="shipToStreet2
" value="'.$shipToStreet2.'">'."\n
";
1816 print '<input type="hidden
" name="phoneNum
" value="'.$phoneNum.'">'."\n
";
1818 print '<!-- Shipping address not complete, so we don t use it -->'."\n
";
1820 if (is_object($don->thirdparty)) {
1821 print '<input type="hidden
" name="thirdparty_id
" value="'.$don->thirdparty->id.'">'."\n
";
1823 print '<input type="hidden
" name="email
" value="'.$don->email.'">'."\n
";
1824 $labeldesc = $langs->trans("PaymentSubscription
");
1825 if (GETPOST('desc', 'alpha')) {
1826 $labeldesc = GETPOST('desc', 'alpha');
1828 print '<input type="hidden
" name="desc
" value="'.dol_escape_htmltag($labeldesc).'">'."\n
";
1831 if ($source == 'organizedeventregistration') {
1833 $langs->loadLangs(array("members
", "eventorganization
"));
1835 if (GETPOST('fulltag', 'alpha')) {
1836 $fulltag = GETPOST('fulltag', 'alpha');
1838 $fulltag = 'ATT='.$attendee->id.'.DAT='.dol_print_date(dol_now(), '%Y%m%d%H%M%S');
1840 $tag = $TAG; $fulltag .= '.TAG='.$TAG;
1843 $fulltag = dol_string_unaccent($fulltag);
1846 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Creditor
");
1847 print '</td><td class="CTableRow2
"><b>'.$creditor.'</b>';
1848 print '<input type="hidden
" name="creditor
" value="'.$creditor.'">';
1849 print '</td></tr>'."\n
";
1852 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Attendee
");
1853 print '</td><td class="CTableRow2
"><b>';
1854 print $attendee->email;
1855 print ($thirdparty->name ? ' ('.$thirdparty->name.')' : '');
1857 print '</td></tr>'."\n
";
1859 if (! is_object($attendee->project)) {
1860 $text = 'ErrorProjectNotFound';
1862 $text = $langs->trans("PaymentEvent
").' - '.$attendee->project->title;
1866 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Designation
");
1867 print '</td><td class="CTableRow2
"><b>'.$text.'</b>';
1868 print '<input type="hidden
" name="source
" value="'.dol_escape_htmltag($source).'">';
1869 print '<input type="hidden
" name="ref" value="'.dol_escape_htmltag($invoice->id).'">';
1870 print '</td></tr>'."\n
";
1873 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Amount
");
1874 print '</td><td class="CTableRow2
">';
1875 $valtoshow = $amount;
1876 print '<b class="amount
">'.price($valtoshow, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
1877 print '<input type="hidden
" name="amount
" value="'.$valtoshow.'">';
1878 print '<input type="hidden
" name="newamount
" value="'.$valtoshow.'">';
1879 print '<input type="hidden
" name="currency
" value="'.$currency.'">';
1880 print '</td></tr>'."\n
";
1883 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("PaymentCode
");
1884 print '</td><td class="CTableRow2
"><b style="word-
break:
break-all;
">'.$fulltag.'</b>';
1885 print '<input type="hidden
" name="tag
" value="'.$tag.'">';
1886 print '<input type="hidden
" name="fulltag
" value="'.$fulltag.'">';
1887 print '</td></tr>'."\n
";
1890 $shipToName = $thirdparty->getFullName($langs);
1891 $shipToStreet = $thirdparty->address;
1892 $shipToCity = $thirdparty->town;
1893 $shipToState = $thirdparty->state_code;
1894 $shipToCountryCode = $thirdparty->country_code;
1895 $shipToZip = $thirdparty->zip;
1896 $shipToStreet2 = '';
1897 $phoneNum = $thirdparty->phone;
1898 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1899 print '<!-- Shipping address information -->';
1900 print '<input type="hidden
" name="shipToName
" value="'.$shipToName.'">'."\n
";
1901 print '<input type="hidden
" name="shipToStreet
" value="'.$shipToStreet.'">'."\n
";
1902 print '<input type="hidden
" name="shipToCity
" value="'.$shipToCity.'">'."\n
";
1903 print '<input type="hidden
" name="shipToState
" value="'.$shipToState.'">'."\n
";
1904 print '<input type="hidden
" name="shipToCountryCode
" value="'.$shipToCountryCode.'">'."\n
";
1905 print '<input type="hidden
" name="shipToZip
" value="'.$shipToZip.'">'."\n
";
1906 print '<input type="hidden
" name="shipToStreet2
" value="'.$shipToStreet2.'">'."\n
";
1907 print '<input type="hidden
" name="phoneNum
" value="'.$phoneNum.'">'."\n
";
1909 print '<!-- Shipping address not complete, so we don t use it -->'."\n
";
1911 print '<input type="hidden
" name="thirdparty_id
" value="'.$thirdparty->id.'">'."\n
";
1912 print '<input type="hidden
" name="email
" value="'.$thirdparty->email.'">'."\n
";
1913 $labeldesc = $langs->trans("PaymentSubscription
");
1914 if (GETPOST('desc', 'alpha')) {
1915 $labeldesc = GETPOST('desc', 'alpha');
1917 print '<input type="hidden
" name="desc
" value="'.dol_escape_htmltag($labeldesc).'">'."\n
";
1920 if ($source == 'boothlocation') {
1922 $langs->load("members
");
1924 if (GETPOST('fulltag', 'alpha')) {
1925 $fulltag = GETPOST('fulltag', 'alpha');
1927 $fulltag = 'BOO='.GETPOST("booth
").'.DAT='.dol_print_date(dol_now(), '%Y%m%d%H%M%S');
1929 $tag = $TAG; $fulltag .= '.TAG='.$TAG;
1932 $fulltag = dol_string_unaccent($fulltag);
1935 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Creditor
");
1936 print '</td><td class="CTableRow2
"><b>'.$creditor.'</b>';
1937 print '<input type="hidden
" name="creditor
" value="'.$creditor.'">';
1938 print '</td></tr>'."\n
";
1941 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Attendee
");
1942 print '</td><td class="CTableRow2
"><b>';
1943 print $thirdparty->name;
1945 print '</td></tr>'."\n
";
1948 $text = '<b>'.$langs->trans("PaymentBoothLocation
").'</b>';
1949 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Designation
");
1950 print '</td><td class="CTableRow2
">'.$text;
1951 print '<input type="hidden
" name="source
" value="'.dol_escape_htmltag($source).'">';
1952 print '<input type="hidden
" name="ref" value="'.dol_escape_htmltag($invoice->id).'">';
1953 print '</td></tr>'."\n
";
1956 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Amount
");
1957 print '</td><td class="CTableRow2
">';
1958 $valtoshow = $amount;
1959 print '<b class="amount
">'.price($valtoshow, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
1960 print '<input type="hidden
" name="amount
" value="'.$valtoshow.'">';
1961 print '<input type="hidden
" name="newamount
" value="'.$valtoshow.'">';
1962 print '<input type="hidden
" name="currency
" value="'.$currency.'">';
1963 print '</td></tr>'."\n
";
1966 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("PaymentCode
");
1967 print '</td><td class="CTableRow2
"><b style="word-
break:
break-all;
">'.$fulltag.'</b>';
1968 print '<input type="hidden
" name="tag
" value="'.$tag.'">';
1969 print '<input type="hidden
" name="fulltag
" value="'.$fulltag.'">';
1970 print '</td></tr>'."\n
";
1973 $shipToName = $thirdparty->getFullName($langs);
1974 $shipToStreet = $thirdparty->address;
1975 $shipToCity = $thirdparty->town;
1976 $shipToState = $thirdparty->state_code;
1977 $shipToCountryCode = $thirdparty->country_code;
1978 $shipToZip = $thirdparty->zip;
1979 $shipToStreet2 = '';
1980 $phoneNum = $thirdparty->phone;
1981 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1982 print '<!-- Shipping address information -->';
1983 print '<input type="hidden
" name="shipToName
" value="'.$shipToName.'">'."\n
";
1984 print '<input type="hidden
" name="shipToStreet
" value="'.$shipToStreet.'">'."\n
";
1985 print '<input type="hidden
" name="shipToCity
" value="'.$shipToCity.'">'."\n
";
1986 print '<input type="hidden
" name="shipToState
" value="'.$shipToState.'">'."\n
";
1987 print '<input type="hidden
" name="shipToCountryCode
" value="'.$shipToCountryCode.'">'."\n
";
1988 print '<input type="hidden
" name="shipToZip
" value="'.$shipToZip.'">'."\n
";
1989 print '<input type="hidden
" name="shipToStreet2
" value="'.$shipToStreet2.'">'."\n
";
1990 print '<input type="hidden
" name="phoneNum
" value="'.$phoneNum.'">'."\n
";
1992 print '<!-- Shipping address not complete, so we don t use it -->'."\n
";
1994 print '<input type="hidden
" name="thirdparty_id
" value="'.$thirdparty->id.'">'."\n
";
1995 print '<input type="hidden
" name="email
" value="'.$thirdparty->email.'">'."\n
";
1996 $labeldesc = $langs->trans("PaymentSubscription
");
1997 if (GETPOST('desc', 'alpha')) {
1998 $labeldesc = GETPOST('desc', 'alpha');
2000 print '<input type="hidden
" name="desc
" value="'.dol_escape_htmltag($labeldesc).'">'."\n
";
2003 if (!$found && !$mesg) {
2004 $mesg = $langs->trans("ErrorBadParameters
");
2008 print '<tr><td align="center
" colspan="2
"><br><div class="warning
">'.dol_escape_htmltag($mesg, 1, 1, 'br').'</div></td></tr>'."\n
";
2011 print '</table>'."\n
";
2015 // Show all payment mode buttons (Stripe, Paypal, ...)
2016 if ($action != 'dopayment') {
2017 if ($found && !$error) { // We are in a management option and no error
2018 // Check status of the object (Invoice) to verify if it is paid by external payment modules (ie Payzen, ...)
2020 'source' => $source,
2023 $reshook = $hookmanager->executeHooks('doCheckStatus', $parameters, $object, $action);
2024 if ($source == 'order' && $object->billed) {
2025 print '<br><br><span class="amountpaymentcomplete size15x
">'.$langs->trans("OrderBilled
").'</span>';
2026 } elseif ($source == 'invoice' && $object->paye) {
2027 print '<br><br><span class="amountpaymentcomplete size15x
">'.$langs->trans("InvoicePaid
").'</span>';
2028 } elseif ($source == 'donation' && $object->paid) {
2029 print '<br><br><span class="amountpaymentcomplete size15x
">'.$langs->trans("DonationPaid
").'</span>';
2031 // Membership can be paid and we still allow to make renewal
2032 if (($source == 'member' || $source == 'membersubscription') && $object->datefin > dol_now()) {
2033 $langs->load("members
");
2034 print '<br><span class="amountpaymentcomplete size15x
">'.$langs->trans("MembershipPaid
", dol_print_date($object->datefin, 'day')).'</span><br>';
2035 print '<div class="opacitymedium margintoponly
">'.$langs->trans("PaymentWillBeRecordedForNextPeriod
").'</div>';
2038 // Buttons for all payments registration methods
2040 // This hook is used to add Button to newpayment.php for external payment modules (ie Payzen, ...)
2042 'paymentmethod' => $paymentmethod
2044 $reshook = $hookmanager->executeHooks('doAddButton', $parameters, $object, $action);
2045 if ((empty($paymentmethod) || $paymentmethod == 'paybox') && isModEnabled('paybox')) {
2046 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").'">';
2048 print '<span class="buttonpaymentsmall
">'.$langs->trans("CreditOrDebitCard
").'</span>';
2051 $( document ).ready(function() {
2052 $("#div_dopayment_paybox
").click(function(){
2053 $("#dopayment_paybox
").click();
2055 $("#dopayment_paybox
").click(function(e){
2056 $("#div_dopayment_paybox
").css( \'cursor\', \'wait\' );
2057 e.stopPropagation();
2064 if ((empty($paymentmethod) || $paymentmethod == 'stripe') && isModEnabled('stripe')) {
2065 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").'">';
2066 print '<input type="hidden
" name="noidempotency
" value="'.GETPOST('noidempotency
', 'int').'">';
2068 print '<span class="buttonpaymentsmall
">'.$langs->trans("CreditOrDebitCard
").'</span>';
2071 $( document ).ready(function() {
2072 $("#div_dopayment_stripe
").click(function(){
2073 $("#dopayment_stripe
").click();
2075 $("#dopayment_stripe
").click(function(e){
2076 $("#div_dopayment_stripe
").css( \'cursor\', \'wait\' );
2077 e.stopPropagation();
2085 if ((empty($paymentmethod) || $paymentmethod == 'paypal') && isModEnabled('paypal')) {
2086 if (empty($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY)) {
2087 $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY = 'integral';
2090 print '<div class="button buttonpayment
" id="div_dopayment_paypal
">';
2091 if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY != 'integral') {
2092 print '<div style="line-height: 1em
"> </div>';
2094 print '<span class="fa fa-paypal
"></span> <input class="" type="submit
" id="dopayment_paypal
" name="dopayment_paypal
" value="'.$langs->trans("PaypalDoPayment").'">';
2095 if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'integral') {
2097 print '<span class="buttonpaymentsmall
">'.$langs->trans("CreditOrDebitCard
").'</span><span class="buttonpaymentsmall
"> - </span>';
2098 print '<span class="buttonpaymentsmall
">'.$langs->trans("PayPalBalance
").'</span>';
2100 if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'paypalonly') {
2102 //print '<span class="buttonpaymentsmall
">'.$langs->trans("PayPalBalance
").'"></span>
';
2106 $( document ).ready(
function() {
2107 $(
"#div_dopayment_paypal").click(
function(){
2108 $(
"#dopayment_paypal").click();
2110 $(
"#dopayment_paypal").click(
function(e){
2111 $(
"#div_dopayment_paypal").css( \
'cursor\', \'wait\' );
2112 e.stopPropagation();
2127 print
'</td></tr>'.
"\n";
2129 print
'</table>'.
"\n";
2131 print
'</form>'.
"\n";
2132 print
'</div>'.
"\n";
2139 if (preg_match(
'/^dopayment/', $action)) {
2142 $_SESSION[
"currencyCodeType"] = $currency;
2143 $_SESSION[
"FinalPaymentAmt"] = $amount;
2144 $_SESSION[
'ipaddress'] = ($remoteip ? $remoteip :
'unknown');
2145 $_SESSION[
"paymentType"] =
'';
2148 if (
GETPOST(
'dopayment_stripe',
'alpha')) {
2156 background-color: white;
2159 border: 1px solid transparent;
2160 box-shadow: 0 1px 3px 0 #e6ebf1;
2161 -webkit-transition: box-shadow 150ms ease;
2162 transition: box-shadow 150ms ease;
2165 .StripeElement--focus {
2166 box-shadow: 0 1px 3px 0 #cfd7df;
2169 .StripeElement--invalid {
2170 border-color: #fa755a;
2173 .StripeElement--webkit-autofill {
2174 background-color: #fefde5 !important;
2180 print
'<!-- 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";
2181 print
'<form action="'.$_SERVER[
'REQUEST_URI'].
'" method="POST" id="payment-form">'.
"\n";
2183 print
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
2184 print
'<input type="hidden" name="dopayment_stripe" value="1">'.
"\n";
2185 print
'<input type="hidden" name="action" value="charge">'.
"\n";
2186 print
'<input type="hidden" name="tag" value="'.$TAG.
'">'.
"\n";
2187 print
'<input type="hidden" name="s" value="'.$source.
'">'.
"\n";
2188 print
'<input type="hidden" name="ref" value="'.$REF.
'">'.
"\n";
2189 print
'<input type="hidden" name="fulltag" value="'.$FULLTAG.
'">'.
"\n";
2190 print
'<input type="hidden" name="suffix" value="'.$suffix.
'">'.
"\n";
2191 print
'<input type="hidden" name="securekey" value="'.$SECUREKEY.
'">'.
"\n";
2192 print
'<input type="hidden" name="e" value="'.$entity.
'" />';
2193 print
'<input type="hidden" name="amount" value="'.$amount.
'">'.
"\n";
2194 print
'<input type="hidden" name="currency" value="'.$currency.
'">'.
"\n";
2195 print
'<input type="hidden" name="forcesandbox" value="'.GETPOST(
'forcesandbox',
'int').
'" />';
2196 print
'<input type="hidden" name="email" value="'.GETPOST(
'email',
'alpha').
'" />';
2197 print
'<input type="hidden" name="thirdparty_id" value="'.GETPOST(
'thirdparty_id',
'int').
'" />';
2199 if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) || !empty($conf->global->STRIPE_USE_NEW_CHECKOUT)) {
2200 require_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
2202 $service =
'StripeLive';
2204 if (empty($conf->global->STRIPE_LIVE) ||
GETPOST(
'forcesandbox',
'alpha')) {
2205 $service =
'StripeTest';
2209 $stripe =
new Stripe($db);
2210 $stripeacc = $stripe->getStripeAccount($service);
2212 if (is_object($object) && is_object($object->thirdparty)) {
2213 $stripecu = $stripe->customerStripe($object->thirdparty, $stripeacc, $servicestatus, 1);
2216 if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) {
2217 $noidempotency_key = (
GETPOSTISSET(
'noidempotency') ?
GETPOST(
'noidempotency',
'int') : 0);
2218 $paymentintent = $stripe->getPaymentIntent($amount, $currency, $tag,
'Stripe payment: '.$fulltag.(is_object($object) ?
' ref='.$object->ref :
''), $object, $stripecu, $stripeacc, $servicestatus, 0,
'automatic',
false,
null, 0, $noidempotency_key);
2221 if ($stripe->error) {
2234 <table id="dolpaymenttable" summary="Payment form" class="center centpercent">
2235 <tbody><tr><td class="textpublicpayment">';
2237 if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) {
2238 print
'<div id="payment-request-button"><!-- A Stripe Element will be inserted here. --></div>';
2241 print
'<div class="form-row '.(getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 2 ?
'center' :
'left').
'">';
2242 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 1) {
2243 print
'<label for="card-element">'.$langs->trans(
"CreditOrDebitCard").
'</label>';
2244 print
'<br><input id="cardholder-name" class="marginbottomonly" name="cardholder-name" value="" type="text" placeholder="'.$langs->trans(
"CardOwner").
'" autocomplete="off" autofocus required>';
2247 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 1) {
2248 print
'<div id="card-element">
2249 <!-- a Stripe Element will be inserted here. -->
2252 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 2) {
2253 print
'<div id="payment-element">
2254 <!-- a Stripe Element will be inserted here. -->
2258 print
'<!-- Used to display form errors -->
2259 <div id="card-errors" role="alert"></div>
2263 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>';
2264 print
'<img id="hourglasstopay" class="hidden" src="'.DOL_URL_ROOT.
'/theme/'.$conf->theme.
'/img/working.gif">';
2266 print
'</td></tr></tbody>';
2270 if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) {
2271 if (empty($paymentintent)) {
2272 print
'<center>'.$langs->trans(
"Error").
'</center>';
2274 print
'<input type="hidden" name="paymentintent_id" value="'.$paymentintent->id.
'">';
2279 print
'</form>'.
"\n";
2283 if (empty($stripearrayofkeys[
'publishable_key'])) {
2284 $langs->load(
"errors");
2285 print
info_admin($langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv(
"Stripe")), 0, 0,
'error');
2287 print
'<!-- JS Code for Stripe components -->';
2288 print
'<script src="https://js.stripe.com/v3/"></script>'.
"\n";
2289 print
'<!-- urllogofull = '.$urllogofull.
' -->'.
"\n";
2292 print
'<script type="text/javascript">'.
"\n";
2294 if (!empty($conf->global->STRIPE_USE_NEW_CHECKOUT)) {
2295 $amountstripe = $amount;
2299 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
2300 if (!in_array($currency, $arrayzerounitcurrency)) {
2301 $amountstripe = $amountstripe * 100;
2305 $metadata = array(
'dol_version'=>DOL_VERSION,
'dol_entity'=>$conf->entity,
'ipaddress'=>$ipaddress);
2306 if (is_object($object)) {
2307 $metadata[
'dol_type'] = $object->element;
2308 $metadata[
'dol_id'] = $object->id;
2310 $ref = $object->ref;
2314 $arrayforpaymentintent = array(
2315 'description'=>
'Stripe payment: '.$FULLTAG.($ref ?
' ref='.$ref :
''),
2316 "metadata" => $metadata
2319 $arrayforpaymentintent[
"statement_descriptor"] =
dol_trunc($TAG, 10,
'right',
'UTF-8', 1);
2322 $arrayforcheckout = array(
2323 'payment_method_types' => array(
'card'),
2324 'line_items' => array(array(
2325 'name' => $langs->transnoentitiesnoconv(
"Payment").
' '.$TAG,
2326 'description' =>
'Stripe payment: '.$FULLTAG.($ref ?
' ref='.$ref :
''),
2327 'amount' => $amountstripe,
2328 'currency' => $currency,
2332 'client_reference_id' => $FULLTAG,
2333 'success_url' => $urlok,
2334 'cancel_url' => $urlko,
2335 'payment_intent_data' => $arrayforpaymentintent
2338 $arrayforcheckout[
'customer'] = $stripecu;
2340 $arrayforcheckout[
'customer_email'] =
GETPOST(
'email',
'alpha');
2342 $sessionstripe = \Stripe\Checkout\Session::create($arrayforcheckout);
2347 $_SESSION[
"currencyCodeType"] = $currency;
2348 $_SESSION[
"paymentType"] =
'';
2349 $_SESSION[
"FinalPaymentAmt"] = $amount;
2350 $_SESSION[
'ipaddress'] = ($remoteip ? $remoteip :
'unknown');
2351 $_SESSION[
'payerID'] = is_object($stripecu) ? $stripecu->id :
'';
2352 $_SESSION[
'TRANSACTIONID'] = $sessionstripe->id;
2354 print $e->getMessage();
2361 if (empty($stripeacc)) {
2363 var stripe =
Stripe(
'<?php echo $stripearrayofkeys['publishable_key
']; // Defined into config.php ?>');
2367 var stripe =
Stripe(
'<?php echo $stripearrayofkeys['publishable_key
']; // Defined into config.php ?>', { stripeAccount:
'<?php echo $stripeacc; ?>' });
2373 var elements = stripe.elements();
2381 fontFamily:
'"Helvetica Neue", Helvetica, sans-serif',
2382 fontSmoothing:
'antialiased',
2390 iconColor:
'#fa755a'
2394 var cardElement = elements.create(
'card', {style: style});
2397 stripe.redirectToCheckout({
2401 sessionId:
'<?php print $sessionstripe->id; ?>'
2402 }).then(
function (result) {
2410 } elseif (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) {
2416 if (empty($stripeacc)) {
2418 var stripe =
Stripe(
'<?php echo $stripearrayofkeys['publishable_key
']; // Defined into config.php ?>');
2422 var stripe =
Stripe(
'<?php echo $stripearrayofkeys['publishable_key
']; // Defined into config.php ?>', { stripeAccount:
'<?php echo $stripeacc; ?>' });
2428 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 2) {
2430 var cardButton = document.getElementById(
'buttontopay');
2431 var clientSecret = cardButton.dataset.secret;
2432 var options = { clientSecret: clientSecret };
2435 var elements = stripe.elements(options);
2440 var elements = stripe.elements();
2451 fontFamily:
'"Helvetica Neue", Helvetica, sans-serif',
2452 fontSmoothing:
'antialiased',
2460 iconColor:
'#fa755a'
2465 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 2) {
2467 var paymentElement = elements.create(
"payment");
2470 paymentElement.mount(
"#payment-element");
2473 var cardButton = document.getElementById(
'buttontopay');
2475 cardButton.addEventListener(
'click',
function(event) {
2476 console.log(
"We click on buttontopay");
2477 event.preventDefault();
2480 jQuery(
'#hourglasstopay').show();
2481 jQuery(
'#buttontopay').hide();
2483 stripe.confirmPayment({
2484 elements,confirmParams: {
2485 return_url:
'<?php echo $urlok; ?>',
2486 payment_method_data: {
2489 <?php
if (
GETPOST(
'email',
'alpha') || (is_object($object) && is_object($object->thirdparty) && !empty($object->thirdparty->email))) {
2490 ?>, email:
'<?php echo dol_escape_js(GETPOST('email
', 'alpha
') ? GETPOST('email
', 'alpha
') : $object->thirdparty->email); ?>'<?php
2492 <?php
if (is_object($object) && is_object($object->thirdparty) && !empty($object->thirdparty->phone)) {
2493 ?>, phone:
'<?php echo dol_escape_js($object->thirdparty->phone); ?>'<?php
2495 <?php
if (is_object($object) && is_object($object->thirdparty)) {
2497 city:
'<?php echo dol_escape_js($object->thirdparty->town); ?>',
2498 <?php if ($object->thirdparty->country_code) {
2499 ?>country:
'<?php echo dol_escape_js($object->thirdparty->country_code); ?>',<?php
2501 line1:
'<?php echo dol_escape_js(preg_replace('/\s\s+/
', ' ', $object->thirdparty->address)); ?>',
2502 postal_code:
'<?php echo dol_escape_js($object->thirdparty->zip); ?>'
2507 save_payment_method:<?php
if ($stripecu) {
2514 ).then(
function(result) {
2515 console.log(result);
2517 console.log(
"Error on result of handleCardPayment");
2518 jQuery(
'#buttontopay').show();
2519 jQuery(
'#hourglasstopay').hide();
2521 var errorElement = document.getElementById(
'card-errors');
2522 console.log(result);
2523 errorElement.textContent = result.error.message;
2526 console.log(
"No error on result of handleCardPayment, so we submit the form");
2528 jQuery(
'#buttontopay').hide();
2529 jQuery(
'#hourglasstopay').show();
2531 jQuery(
'#payment-form').submit();
2539 var cardElement = elements.create(
'card', {style: style});
2542 cardElement.mount(
'#card-element');
2545 cardElement.addEventListener(
'change',
function(event) {
2546 var displayError = document.getElementById(
'card-errors');
2548 console.log(
"Show event error (like 'Incorrect card number', ...)");
2549 displayError.textContent =
event.error.message;
2551 console.log(
"Reset error message");
2552 displayError.textContent =
'';
2557 var cardholderName = document.getElementById(
'cardholder-name');
2558 var cardButton = document.getElementById(
'buttontopay');
2559 var clientSecret = cardButton.dataset.secret;
2561 cardButton.addEventListener(
'click',
function(event) {
2562 console.log(
"We click on buttontopay");
2563 event.preventDefault();
2565 if (cardholderName.value ==
'')
2567 console.log(
"Field Card holder is empty");
2568 var displayError = document.getElementById(
'card-errors');
2569 displayError.textContent =
'<?php print dol_escape_js($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardOwner"))); ?>';
2574 jQuery(
'#hourglasstopay').show();
2575 jQuery(
'#buttontopay').hide();
2577 stripe.handleCardPayment(
2578 clientSecret, cardElement, {
2579 payment_method_data: {
2581 name: cardholderName.value
2582 <?php
if (
GETPOST(
'email',
'alpha') || (is_object($object) && is_object($object->thirdparty) && !empty($object->thirdparty->email))) {
2583 ?>, email:
'<?php echo dol_escape_js(GETPOST('email
', 'alpha
') ? GETPOST('email
', 'alpha
') : $object->thirdparty->email); ?>'<?php
2585 <?php
if (is_object($object) && is_object($object->thirdparty) && !empty($object->thirdparty->phone)) {
2586 ?>, phone:
'<?php echo dol_escape_js($object->thirdparty->phone); ?>'<?php
2588 <?php
if (is_object($object) && is_object($object->thirdparty)) {
2590 city:
'<?php echo dol_escape_js($object->thirdparty->town); ?>',
2591 <?php if ($object->thirdparty->country_code) {
2592 ?>country:
'<?php echo dol_escape_js($object->thirdparty->country_code); ?>',<?php
2594 line1:
'<?php echo dol_escape_js(preg_replace('/\s\s+/
', ' ', $object->thirdparty->address)); ?>',
2595 postal_code:
'<?php echo dol_escape_js($object->thirdparty->zip); ?>'
2600 save_payment_method:<?php
if ($stripecu) {
2606 ).then(
function(result) {
2607 console.log(result);
2609 console.log(
"Error on result of handleCardPayment");
2610 jQuery(
'#buttontopay').show();
2611 jQuery(
'#hourglasstopay').hide();
2613 var errorElement = document.getElementById(
'card-errors');
2614 errorElement.textContent = result.error.message;
2617 console.log(
"No error on result of handleCardPayment, so we submit the form");
2619 jQuery(
'#buttontopay').hide();
2620 jQuery(
'#hourglasstopay').show();
2622 jQuery(
'#payment-form').submit();
2641 'paymentmethod' => $paymentmethod,
2642 'amount' => $amount,
2643 'currency' => $currency,
2644 'tag' =>
GETPOST(
"tag",
'alpha'),
2645 'dopayment' =>
GETPOST(
'dopayment',
'alpha')
2647 $reshook = $hookmanager->executeHooks(
'doPayment', $parameters, $object, $action);
2651 htmlPrintOnlinePaymentFooter($mysoc, $langs, 1, $suffix, $object);
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.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getUserRemoteIP()
Return the IP of remote user.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
table tableforfield 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,...