41if (!defined(
'NOLOGIN')) {
44if (!defined(
'NOCSRFCHECK')) {
45 define(
"NOCSRFCHECK", 1);
47if (!defined(
'NOIPCHECK')) {
48 define(
'NOIPCHECK',
'1');
50if (!defined(
'NOBROWSERNOTIF')) {
51 define(
'NOBROWSERNOTIF',
'1');
57$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))));
58if (is_numeric($entity)) {
59 define(
"DOLENTITY", $entity);
63require
'../../main.inc.php';
64require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
65require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
66require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
67require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
68require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
69require_once DOL_DOCUMENT_ROOT.
'/societe/class/societeaccount.class.php';
70require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
71require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
83$langs->loadLangs(array(
"main",
"other",
"dict",
"bills",
"companies",
"errors",
"paybox",
"paypal",
"stripe"));
87$hookmanager->initHooks(array(
'newpayment'));
93$action =
GETPOST(
'action',
'aZ09');
102$suffix =
GETPOST(
"suffix",
'aZ09');
104if (!
GETPOST(
"currency",
'alpha')) {
105 $currency =
$conf->currency;
107 $currency =
GETPOST(
"currency",
'aZ09');
110$getpostlang =
GETPOST(
'lang',
'aZ09');
115 if (!
GETPOST(
"amount",
'alpha') && !$source) {
116 print $langs->trans(
'ErrorBadParameters').
" - amount or source";
119 if (is_numeric($amount) && !
GETPOST(
"tag",
'alpha') && !$source) {
120 print $langs->trans(
'ErrorBadParameters').
" - tag or source";
123 if ($source && !
GETPOST(
"ref",
'alpha')) {
124 print $langs->trans(
'ErrorBadParameters').
" - ref";
132$paymentintent =
null;
136if ($source ==
'organizedeventregistration') {
143 $resultinvoice = $invoice->fetch($invoiceid);
145 if ($resultinvoice <= 0) {
158 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"eventorganization_conferenceorboothattendee";
159 $sql .=
" WHERE fk_invoice = ".((int) $invoiceid);
161 $resql = $db->query($sql);
163 $obj = $db->fetch_object($resql);
165 $attendeeid = $obj->rowid;
169 if ($attendeeid > 0) {
170 $resultattendee = $attendee->fetch($attendeeid);
172 if ($resultattendee <= 0) {
175 $attendee->fetch_projet();
177 $amount =
price2num($invoice->total_ttc);
179 $thirdparty =
new Societe($db);
180 $resultthirdparty = $thirdparty->fetch($invoice->socid);
181 if ($resultthirdparty <= 0) {
188} elseif ($source ==
'boothlocation') {
192 $resultinvoice = $invoice->fetch($invoiceid);
193 if ($resultinvoice <= 0) {
196 $amount =
price2num($invoice->total_ttc);
198 $thirdparty =
new Societe($db);
199 $resultthirdparty = $thirdparty->fetch($invoice->socid);
200 if ($resultthirdparty <= 0) {
208$paymentmethod =
GETPOST(
'paymentmethod',
'alphanohtml') ?
GETPOST(
'paymentmethod',
'alphanohtml') :
'';
209$validpaymentmethod = array();
212foreach ($_POST as $key => $val) {
214 if (preg_match(
'/^dopayment_(.*)$/', $key, $reg)) {
215 $paymentmethod = $reg[1];
224$urlwithroot = DOL_MAIN_URL_ROOT;
226$urlok = $urlwithroot.
'/public/payment/paymentok.php?';
227$urlko = $urlwithroot.
'/public/payment/paymentko.php?';
230$ref = $REF =
GETPOST(
'ref',
'alpha');
232$FULLTAG =
GETPOST(
"fulltag",
'alpha');
233$SECUREKEY =
GETPOST(
"securekey");
235if ($paymentmethod && !preg_match(
'/'.preg_quote(
'PM='.$paymentmethod,
'/').
'/', $FULLTAG)) {
236 $FULLTAG .= ($FULLTAG ?
'.' :
'').
'PM='.$paymentmethod;
240 $FULLTAG .= ($FULLTAG ?
'.' :
'').
'WS='.$ws;
243if (!empty($suffix)) {
244 $urlok .=
'suffix='.urlencode($suffix).
'&';
245 $urlko .=
'suffix='.urlencode($suffix).
'&';
248 $urlok .=
's='.urlencode($source).
'&';
249 $urlko .=
's='.urlencode($source).
'&';
252 $urlok .=
'ref='.urlencode($REF).
'&';
253 $urlko .=
'ref='.urlencode($REF).
'&';
256 $urlok .=
'tag='.urlencode($TAG).
'&';
257 $urlko .=
'tag='.urlencode($TAG).
'&';
259if (!empty($FULLTAG)) {
260 $urlok .=
'fulltag='.urlencode($FULLTAG).
'&';
261 $urlko .=
'fulltag='.urlencode($FULLTAG).
'&';
263if (!empty($SECUREKEY)) {
264 $urlok .=
'securekey='.urlencode($SECUREKEY).
'&';
265 $urlko .=
'securekey='.urlencode($SECUREKEY).
'&';
267if (!empty($entity)) {
268 $urlok .=
'e='.urlencode((
string) ($entity)).
'&';
269 $urlko .=
'e='.urlencode((
string) ($entity)).
'&';
271if (!empty($getpostlang)) {
272 $urlok .=
'lang='.urlencode($getpostlang).
'&';
273 $urlko .=
'lang='.urlencode($getpostlang).
'&';
275$urlok = preg_replace(
'/&$/',
'', $urlok);
276$urlko = preg_replace(
'/&$/',
'', $urlko);
283@phan-var-force string $PAYPAL_API_SANDBOX
284@phan-var-force string $PAYPAL_API_OK
285@phan-var-force string $PAYPAL_API_KO
288if ((empty($paymentmethod) || $paymentmethod ==
'paypal') && isModEnabled(
'paypal')) {
289 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypal.lib.php';
290 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypalfunctions.lib.php';
296 $PAYPAL_API_OK = $urlok;
300 $PAYPAL_API_KO = $urlko;
302 if (empty($PAYPAL_API_USER)) {
303 print
'Paypal parameter PAYPAL_API_USER is not defined. Please <a href="'.DOL_URL_ROOT.
'/paypal/admin/paypal.php">complete the setup of module PayPal first</a>.';
306 if (empty($PAYPAL_API_PASSWORD)) {
307 print
'Paypal parameter PAYPAL_API_PASSWORD is not defined. Please <a href="'.DOL_URL_ROOT.
'/paypal/admin/paypal.php">complete the setup of module PayPal first</a>.';
310 if (empty($PAYPAL_API_SIGNATURE)) {
311 print
'Paypal parameter PAYPAL_API_SIGNATURE is not defined. Please <a href="'.DOL_URL_ROOT.
'/paypal/admin/paypal.php">complete the setup of module PayPal first</a>.';
318if ((empty($paymentmethod) || $paymentmethod ==
'stripe') && isModEnabled(
'stripe')) {
319 require_once DOL_DOCUMENT_ROOT.
'/stripe/config.php';
324$validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod);
328if ($tmpsource ==
'membersubscription') {
329 $tmpsource =
'member';
335 if ($tmpsource && $REF) {
339 if ($tmpsource != $source) {
346 $tokenisok = (
$conf->global->PAYMENT_SECURITY_TOKEN == $SECUREKEY);
353 dol_syslog(
"Warning: PAYMENT_SECURITY_ACCEPT_ANY_TOKEN is on", LOG_WARNING);
358 print
'<div class="error">Bad value for key.</div>';
364if (!empty($paymentmethod) && empty($validpaymentmethod[$paymentmethod])) {
365 print
'Payment module for payment method '.$paymentmethod.
' is not active';
368if (empty($validpaymentmethod)) {
369 print
'No active payment module (Paypal, Stripe, Paybox, ...)';
374$creditor = $mysoc->name;
375$paramcreditor =
'ONLINE_PAYMENT_CREDITOR';
376$paramcreditorlong =
'ONLINE_PAYMENT_CREDITOR_'.$suffix;
391dol_syslog(
"--- newpayment.php action = ".$action.
" paymentmethod=".$paymentmethod.
' amount='.$amount.
' newamount='.
GETPOST(
"newamount",
'alpha'), LOG_DEBUG, 0,
'_payment');
394if ($action ==
'dopayment') {
395 if ($paymentmethod ==
'paypal') {
397 $PAYPAL_PAYMENT_TYPE =
'Sale';
400 $origfulltag =
GETPOST(
"fulltag",
'alpha');
401 $shipToName =
GETPOST(
"shipToName",
'alpha');
402 $shipToStreet =
GETPOST(
"shipToStreet",
'alpha');
403 $shipToCity =
GETPOST(
"shipToCity",
'alpha');
404 $shipToState =
GETPOST(
"shipToState",
'alpha');
405 $shipToCountryCode =
GETPOST(
"shipToCountryCode",
'alpha');
406 $shipToZip =
GETPOST(
"shipToZip",
'alpha');
407 $shipToStreet2 =
GETPOST(
"shipToStreet2",
'alpha');
408 $phoneNum =
GETPOST(
"phoneNum",
'alpha');
409 $email =
GETPOST(
"email",
'alpha');
410 $desc =
GETPOST(
"desc",
'alpha');
414 if ($shipToCountryCode ==
'ID' && !preg_match(
'/\-/', $shipToState)) {
415 $shipToState =
'ID-'.$shipToState;
418 if (empty($PAYPAL_API_PRICE) || !is_numeric($PAYPAL_API_PRICE)) {
419 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount"));
423 } elseif (!$origfulltag) {
424 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"PaymentCode"));
429 dol_syslog(
"newpayment.php call paypal api and do redirect", LOG_DEBUG);
432 $PAYPAL_API_DEVISE =
"USD";
433 if (!empty($currency)) {
434 $PAYPAL_API_DEVISE = $currency;
439 dol_syslog(
"PAYPAL_API_USER: $PAYPAL_API_USER", LOG_DEBUG);
440 dol_syslog(
"PAYPAL_API_PASSWORD: ".preg_replace(
'/./',
'*', $PAYPAL_API_PASSWORD), LOG_DEBUG);
441 dol_syslog(
"PAYPAL_API_SIGNATURE: $PAYPAL_API_SIGNATURE", LOG_DEBUG);
442 dol_syslog(
"PAYPAL_API_SANDBOX: $PAYPAL_API_SANDBOX", LOG_DEBUG);
443 dol_syslog(
"PAYPAL_API_OK: $PAYPAL_API_OK", LOG_DEBUG);
444 dol_syslog(
"PAYPAL_API_KO: $PAYPAL_API_KO", LOG_DEBUG);
445 dol_syslog(
"PAYPAL_API_PRICE: $PAYPAL_API_PRICE", LOG_DEBUG);
446 dol_syslog(
"PAYPAL_API_DEVISE: $PAYPAL_API_DEVISE", LOG_DEBUG);
448 dol_syslog(
"shipToName: $shipToName", LOG_DEBUG);
449 dol_syslog(
"shipToStreet: $shipToStreet", LOG_DEBUG);
450 dol_syslog(
"shipToCity: $shipToCity", LOG_DEBUG);
451 dol_syslog(
"shipToState: $shipToState", LOG_DEBUG);
452 dol_syslog(
"shipToCountryCode: $shipToCountryCode", LOG_DEBUG);
453 dol_syslog(
"shipToZip: $shipToZip", LOG_DEBUG);
454 dol_syslog(
"shipToStreet2: $shipToStreet2", LOG_DEBUG);
459 dol_syslog(
"SCRIPT_URI: ".(empty($_SERVER[
"SCRIPT_URI"]) ?
'' : $_SERVER[
"SCRIPT_URI"]), LOG_DEBUG);
462 $mesg =
print_paypal_redirect($PAYPAL_API_PRICE, $PAYPAL_API_DEVISE, $PAYPAL_PAYMENT_TYPE, $PAYPAL_API_OK, $PAYPAL_API_KO, $FULLTAG);
469 if ($paymentmethod ==
'paybox') {
474 $origfulltag =
GETPOST(
"fulltag",
'alpha');
477 $urlok = preg_replace(
'/securekey=[^&]+&?/',
'', $urlok);
478 $urlko = preg_replace(
'/securekey=[^&]+&?/',
'', $urlko);
480 if (empty($PRICE) || !is_numeric($PRICE)) {
481 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount"));
482 } elseif (empty($email)) {
483 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ONLINE_PAYMENT_SENDEMAIL"));
485 $mesg = $langs->trans(
"ErrorBadEMail", $email);
486 } elseif (!$origfulltag) {
487 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"PaymentCode"));
489 $mesg =
'Error urlok too long '.$urlok.
' (Paybox requires 150, found '.strlen($urlok).
')';
491 $mesg =
'Error urlko too long '.$urlko.
' (Paybox requires 150, found '.strlen($urlok).
')';
495 dol_syslog(
"newpayment.php call paybox api and do redirect", LOG_DEBUG);
497 include_once DOL_DOCUMENT_ROOT.
'/paybox/lib/paybox.lib.php';
505 if ($paymentmethod ==
'stripe') {
506 if (
GETPOST(
'newamount',
'alpha')) {
509 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount")),
null,
'errors');
519if ($action ==
'charge' && isModEnabled(
'stripe')) {
520 $amountstripe = (float) $amount;
524 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
525 if (!in_array($currency, $arrayzerounitcurrency)) {
526 $amountstripe *= 100;
529 dol_syslog(
"--- newpayment.php Execute action = ".$action.
" STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION=".
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION'), LOG_DEBUG, 0,
'_payment');
530 dol_syslog(
"GET=".var_export($_GET,
true), LOG_DEBUG, 0,
'_payment');
531 dol_syslog(
"POST=".var_export($_POST,
true), LOG_DEBUG, 0,
'_payment');
533 $stripeToken =
GETPOST(
"stripeToken",
'alpha');
534 $email =
GETPOST(
"email",
'alpha');
538 $vatnumber =
GETPOST(
'vatnumber',
'alpha');
539 $savesource = GETPOSTISSET(
'savesource') ?
GETPOSTINT(
'savesource') : 1;
541 dol_syslog(
"POST stripeToken = ".$stripeToken, LOG_DEBUG, 0,
'_payment');
542 dol_syslog(
"POST email = ".$email, LOG_DEBUG, 0,
'_payment');
543 dol_syslog(
"POST thirdparty_id = ".$thirdparty_id, LOG_DEBUG, 0,
'_payment');
544 dol_syslog(
"POST vatnumber = ".$vatnumber, LOG_DEBUG, 0,
'_payment');
551 if (!
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION')) {
554 'dol_version' => DOL_VERSION,
555 'dol_entity' =>
$conf->entity,
556 'dol_company' => $mysoc->name,
557 'dol_tax_num' => $vatnumber,
561 if (!empty($thirdparty_id)) {
562 $metadata[
"dol_thirdparty_id"] = $thirdparty_id;
565 if ($thirdparty_id > 0) {
566 dol_syslog(
"Search existing Stripe customer profile for thirdparty_id=".$thirdparty_id, LOG_DEBUG, 0,
'_payment');
568 $service =
'StripeTest';
571 $service =
'StripeLive';
575 $thirdparty =
new Societe($db);
576 $thirdparty->fetch($thirdparty_id);
579 include_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
580 $stripe =
new Stripe($db);
581 $stripeacc = $stripe->getStripeAccount($service);
582 $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 1);
583 if (empty($customer)) {
585 dol_syslog(
'Failed to get/create stripe customer for thirdparty id = '.$thirdparty_id.
' and servicestatus = '.$servicestatus.
': '.$stripe->error, LOG_ERR, 0,
'_payment');
586 setEventMessages(
'Failed to get/create stripe customer for thirdparty id = '.$thirdparty_id.
' and servicestatus = '.$servicestatus.
': '.$stripe->error,
null,
'errors');
593 $card = $customer->sources->create(array(
"source" => $stripeToken,
"metadata" => $metadata));
595 $card = $stripeToken;
600 dol_syslog(
'Failed to create card record', LOG_WARNING, 0,
'_payment');
604 if (!empty($FULLTAG)) {
605 $metadata[
"FULLTAG"] = $FULLTAG;
607 if (!empty($dol_id)) {
608 $metadata[
"dol_id"] = $dol_id;
610 if (!empty($dol_type)) {
611 $metadata[
"dol_type"] = $dol_type;
614 dol_syslog(
"Create charge on card ".$card->id, LOG_DEBUG, 0,
'_payment');
615 $charge = \Stripe\Charge::create(array(
616 'amount' =>
price2num($amountstripe,
'MU'),
617 'currency' => $currency,
619 'description' =>
'Stripe payment: '.$FULLTAG.
' ref='.$ref,
620 'metadata' => $metadata,
621 'customer' => $customer->id,
623 'statement_descriptor_suffix' =>
dol_trunc($FULLTAG, 10,
'right',
'UTF-8', 1),
624 ), array(
"idempotency_key" =>
"$FULLTAG",
"stripe_account" =>
"$stripeacc"));
626 if (empty($charge)) {
628 dol_syslog(
'Failed to charge card', LOG_WARNING, 0,
'_payment');
635 $vatcleaned = $vatnumber ? $vatnumber :
null;
646 dol_syslog(
"Create anonymous customer card profile", LOG_DEBUG, 0,
'_payment');
648 $customer = \Stripe\Customer::create(array(
650 'description' => ($email ?
'Anonymous customer for '.$email :
'Anonymous customer'),
651 'metadata' => $metadata,
652 'source' => $stripeToken
671 if (!empty($FULLTAG)) {
672 $metadata[
"FULLTAG"] = $FULLTAG;
674 if (!empty($dol_id)) {
675 $metadata[
"dol_id"] = $dol_id;
677 if (!empty($dol_type)) {
678 $metadata[
"dol_type"] = $dol_type;
683 dol_syslog(
"Create charge", LOG_DEBUG, 0,
'_payment');
684 $charge = \Stripe\Charge::create(array(
685 'customer' => $customer->id,
686 'amount' =>
price2num($amountstripe,
'MU'),
687 'currency' => $currency,
689 'description' =>
'Stripe payment: '.$FULLTAG.
' ref='.$ref,
690 'metadata' => $metadata,
691 'statement_descriptor' =>
dol_trunc($FULLTAG, 10,
'right',
'UTF-8', 1),
692 ), array(
"idempotency_key" => (
string) $FULLTAG,
"stripe_account" => (
string) $stripeacc));
694 if (empty($charge)) {
696 dol_syslog(
'Failed to charge card', LOG_WARNING, 0,
'_payment');
703 $body = $e->getJsonBody();
704 $err = $body[
'error'];
706 print(
'Status is:'.$e->getHttpStatus().
"\n");
707 print(
'Type is:'.$err[
'type'].
"\n");
708 print(
'Code is:'.$err[
'code'].
"\n");
710 print(
'Param is:'.$err[
'param'].
"\n");
711 print(
'Message is:'.$err[
'message'].
"\n");
714 $errormessage =
"ErrorCard ".$e->getMessage().
" err=".var_export($err,
true);
715 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
721 $errormessage =
"ErrorRateLimit ".$e->getMessage();
722 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
728 $errormessage =
"ErrorInvalidRequest ".$e->getMessage();
729 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
736 $errormessage =
"ErrorAuthentication ".$e->getMessage();
737 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
743 $errormessage =
"ErrorApiConnection ".$e->getMessage();
744 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
751 $errormessage =
"ErrorBase ".$e->getMessage();
752 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
758 $errormessage =
"ErrorException ".$e->getMessage();
759 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
766 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION')) {
767 $service =
'StripeTest';
770 $service =
'StripeLive';
773 include_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
774 $stripe =
new Stripe($db);
775 $stripeacc = $stripe->getStripeAccount($service);
779 $paymentintent_id =
GETPOST(
"paymentintent_id",
"alpha");
782 global $stripearrayofkeysbyenv;
783 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
786 if (empty($stripeacc)) {
787 $paymentintent = \Stripe\PaymentIntent::retrieve($paymentintent_id);
789 $paymentintent = \Stripe\PaymentIntent::retrieve($paymentintent_id, array(
"stripe_account" => $stripeacc));
793 $errormessage =
"CantRetrievePaymentIntent ".$e->getMessage();
794 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
799 if ($paymentintent->status !=
'succeeded') {
801 $errormessage =
"StatusOfRetrievedIntent is not succeeded: ".$paymentintent->status;
802 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
812 if (!empty($paymentintent->currency) && !empty($paymentintent->amount)) {
813 $currency = strtoupper($paymentintent->currency);
814 $amount = $paymentintent->amount;
818 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
819 if (!in_array($currency, $arrayzerounitcurrency)) {
829 $_SESSION[
"onlinetoken"] = $stripeToken;
830 $_SESSION[
"FinalPaymentAmt"] = $amount;
831 $_SESSION[
"currencyCodeType"] = $currency;
832 $_SESSION[
"paymentType"] =
'';
833 $_SESSION[
'ipaddress'] = ($remoteip ? $remoteip :
'unknown');
834 $_SESSION[
'payerID'] = is_object($customer) ? $customer->id :
'';
835 $_SESSION[
'TRANSACTIONID'] = (is_object($charge) ? $charge->id : (is_object($paymentintent) ? $paymentintent->id :
''));
836 $_SESSION[
'errormessage'] = $errormessage;
838 dol_syslog(
"Action charge stripe STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION=".
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION').
" ip=".$remoteip, LOG_DEBUG, 0,
'_payment');
839 dol_syslog(
"onlinetoken=".$_SESSION[
"onlinetoken"].
" FinalPaymentAmt=".$_SESSION[
"FinalPaymentAmt"].
" currencyCodeType=".$_SESSION[
"currencyCodeType"].
" payerID=".$_SESSION[
'payerID'].
" TRANSACTIONID=".$_SESSION[
'TRANSACTIONID'], LOG_DEBUG, 0,
'_payment');
840 dol_syslog(
"FULLTAG=".$FULLTAG, LOG_DEBUG, 0,
'_payment');
841 dol_syslog(
"error=".$error.
" errormessage=".$errormessage, LOG_DEBUG, 0,
'_payment');
842 dol_syslog(
"_SERVER[SERVER_NAME] = ".(empty($_SERVER[
"SERVER_NAME"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_NAME"])), LOG_DEBUG, 0,
'_payment');
843 dol_syslog(
"_SERVER[SERVER_ADDR] = ".(empty($_SERVER[
"SERVER_ADDR"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_ADDR"])), LOG_DEBUG, 0,
'_payment');
844 dol_syslog(
"Now call the redirect to paymentok or paymentko, URL = ".($error ? $urlko : $urlok), LOG_DEBUG, 0,
'_payment');
847 header(
"Location: ".$urlko);
850 header(
"Location: ".$urlok);
857 'paymentmethod' => $paymentmethod,
858 'validpaymentmethod' => &$validpaymentmethod
860$reshook = $hookmanager->executeHooks(
'doPayment', $parameters,
$object, $action);
863} elseif ($reshook > 0) {
864 print $hookmanager->resPrint;
873$form =
new Form($db);
877 $head =
'<link rel="stylesheet" type="text/css" href="' .
getDolGlobalString(
'ONLINE_PAYMENT_CSS_URL').
'?lang='.(!empty($getpostlang) ? $getpostlang : $langs->defaultlang).
'">'.
"\n";
880$conf->dol_hide_topmenu = 1;
881$conf->dol_hide_leftmenu = 1;
883$replacemainarea = (empty(
$conf->dol_hide_leftmenu) ?
'<div>' :
'').
'<div>';
884llxHeader($head, $langs->trans(
"PaymentForm"),
'',
'', 0, 0,
'',
'',
'',
'onlinepaymentbody', $replacemainarea);
886dol_syslog(
"newpayment.php show page source=".$source.
" paymentmethod=".$paymentmethod.
' amount='.$amount.
' newamount='.
GETPOST(
"newamount",
'alpha').
" ref=".$ref, LOG_DEBUG, 0,
'_payment');
887dol_syslog(
"_SERVER[SERVER_NAME] = ".(empty($_SERVER[
"SERVER_NAME"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_NAME"])), LOG_DEBUG, 0,
'_payment');
888dol_syslog(
"_SERVER[SERVER_ADDR] = ".(empty($_SERVER[
"SERVER_ADDR"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_ADDR"])), LOG_DEBUG, 0,
'_payment');
891if ($source && in_array($ref, array(
'member_ref',
'contractline_ref',
'invoice_ref',
'order_ref',
'donation_ref',
''))) {
892 $langs->load(
"errors");
893 dol_print_error_email(
'BADREFINPAYMENTFORM', $langs->trans(
"ErrorBadLinkSourceSetButBadValueForRef", $source, $ref));
902if ((empty($paymentmethod) || $paymentmethod ==
'paypal') && isModEnabled(
'paypal') && (
getDolGlobalString(
'PAYPAL_API_SANDBOX') ||
GETPOSTINT(
'forcesandbox'))) {
903 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Paypal'), array(),
'warning');
905if ((empty($paymentmethod) || $paymentmethod ==
'stripe') && isModEnabled(
'stripe') && (!
getDolGlobalString(
'STRIPE_LIVE') ||
GETPOSTINT(
'forcesandbox'))) {
906 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Stripe'), array(),
'warning');
910print
'<span id="dolpaymentspan"></span>'.
"\n";
911print
'<div class="center">'.
"\n";
912print
'<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
913print
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
914print
'<input type="hidden" name="action" value="dopayment">'.
"\n";
915print
'<input type="hidden" name="tag" value="'.GETPOST(
"tag",
'alpha').
'">'.
"\n";
916print
'<input type="hidden" name="suffix" value="'.dol_escape_htmltag($suffix).
'">'.
"\n";
917print
'<input type="hidden" name="securekey" value="'.dol_escape_htmltag($SECUREKEY).
'">'.
"\n";
918print
'<input type="hidden" name="e" value="'.$entity.
'" />';
919print
'<input type="hidden" name="forcesandbox" value="'.GETPOSTINT(
'forcesandbox').
'" />';
920print
'<input type="hidden" name="lang" value="'.$getpostlang.
'">';
921print
'<input type="hidden" name="ws" value="'.$ws.
'">';
927$logosmall = $mysoc->logo_small;
929$paramlogo =
'ONLINE_PAYMENT_LOGO_'.$suffix;
939if (!empty($logosmall) && is_readable(
$conf->mycompany->dir_output.
'/logos/thumbs/'.$logosmall)) {
940 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
941 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
942} elseif (!empty($logo) && is_readable(
$conf->mycompany->dir_output.
'/logos/'.$logo)) {
943 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
944 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
948if ($urllogo && !$ws) {
949 print
'<div class="backgreypublicpayment">';
950 print
'<div class="logopublicpayment">';
951 print
'<img id="dolpaymentlogo" src="'.$urllogo.
'"';
955 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>';
958} elseif ($creditor && !$ws) {
959 print
'<div class="backgreypublicpayment">';
960 print
'<div class="logopublicpayment">';
966 print
'<div class="backimagepublicpayment">';
967 print
'<img id="idMAIN_IMAGE_PUBLIC_PAYMENT" src="'.getDolGlobalString(
'MAIN_IMAGE_PUBLIC_PAYMENT').
'">';
974print
'<!-- Form to send a payment -->'.
"\n";
975print
'<!-- creditor = '.dol_escape_htmltag($creditor).
' -->'.
"\n";
977if (isModEnabled(
'paypal')) {
978 print
'<!-- PAYPAL_API_SANDBOX = '.getDolGlobalString(
'PAYPAL_API_SANDBOX').
' -->'.
"\n";
979 print
'<!-- PAYPAL_API_INTEGRAL_OR_PAYPALONLY = '.getDolGlobalString(
'PAYPAL_API_INTEGRAL_OR_PAYPALONLY').
' -->'.
"\n";
981if (isModEnabled(
'paybox')) {
982 print
'<!-- PAYBOX_CGI_URL = '.getDolGlobalString(
'PAYBOX_CGI_URL_V2').
' -->'.
"\n";
984if (isModEnabled(
'stripe')) {
985 print
'<!-- STRIPE_LIVE = '.getDolGlobalString(
'STRIPE_LIVE').
' -->'.
"\n";
987print
'<!-- urlok = '.$urlok.
' -->'.
"\n";
988print
'<!-- urlko = '.$urlko.
' -->'.
"\n";
992print
'<table id="dolpublictable" summary="Payment form" class="center">'.
"\n";
997 $langs->load(
"members");
998 if (preg_match(
'/^\((.*)\)$/',
$conf->global->PAYMENT_NEWFORM_TEXT, $reg)) {
999 $text .= $langs->trans($reg[1]).
"<br>\n";
1003 $text =
'<tr><td align="center"><br>'.$text.
'<br></td></tr>'.
"\n";
1006 $text .=
'<tr><td class="textpublicpayment"><br><strong>'.$langs->trans(
"WelcomeOnPaymentPage").
'</strong></td></tr>'.
"\n";
1007 $text .=
'<tr><td class="textpublicpayment"><span class="opacitymedium">'.$langs->trans(
"ThisScreenAllowsYouToPay", $creditor).
'</span><br><br></td></tr>'.
"\n";
1012print
'<tr><td align="center">';
1013print
'<table class="centpercent left" id="tablepublicpayment">';
1014print
'<tr class="hideonsmartphone"><td colspan="2" align="left" class="opacitymedium">'.$langs->trans(
"ThisIsInformationOnPayment").
' :</td></tr>'.
"\n";
1027 $tag =
GETPOST(
"tag",
'alpha');
1028 if (
GETPOST(
'fulltag',
'alpha')) {
1029 $fulltag =
GETPOST(
'fulltag',
'alpha');
1031 $fulltag =
"TAG=".$tag;
1035 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
1036 print
'</td><td class="CTableRow2">';
1037 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1038 print
'<b>'.$creditor.
'</b>';
1039 print
'<input type="hidden" name="creditor" value="'.$creditor.
'">';
1040 print
'</td></tr>'.
"\n";
1043 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Amount");
1044 if (empty($amount)) {
1045 print
' ('.$langs->trans(
"ToComplete").
')';
1047 print
'</td><td class="CTableRow2">';
1048 if (empty($amount) || !is_numeric($amount)) {
1049 print
'<input type="hidden" name="amount" value="'.price2num(
GETPOST(
"amount",
'alpha'),
'MT').
'">';
1050 print
'<input class="flat maxwidth75" type="text" name="newamount" value="'.price2num(
GETPOST(
"newamount",
"alpha"),
'MT').
'">';
1052 print
' <b>'.$langs->trans(
"Currency".$currency).
'</b>';
1054 print
'<b class="amount">'.price($amount, 1, $langs, 1, -1, -1, $currency).
'</b>';
1055 print
'<input type="hidden" name="amount" value="'.$amount.
'">';
1056 print
'<input type="hidden" name="newamount" value="'.$amount.
'">';
1058 print
'<input type="hidden" name="currency" value="'.$currency.
'">';
1059 print
'</td></tr>'.
"\n";
1062 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentCode");
1063 print
'</td><td class="CTableRow2"><b style="word-break: break-all;">'.$fulltag.
'</b>';
1064 print
'<input type="hidden" name="tag" value="'.$tag.
'">';
1065 print
'<input type="hidden" name="fulltag" value="'.$fulltag.
'">';
1066 print
'</td></tr>'.
"\n";
1074if ($source ==
'order') {
1076 $langs->load(
"orders");
1078 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
1081 $result = $order->fetch(0, $ref);
1083 $mesg = $order->error;
1086 $result = $order->fetch_thirdparty($order->socid);
1090 if ($action !=
'dopayment') {
1091 $amount = $order->total_ttc;
1092 if (
GETPOST(
"amount",
'alpha')) {
1093 $amount =
GETPOST(
"amount",
'alpha');
1099 if (
GETPOST(
'fulltag',
'alpha')) {
1100 $fulltag =
GETPOST(
'fulltag',
'alpha');
1102 $fulltag =
'ORD='.$order->id.
'.CUS='.$order->thirdparty->id;
1105 $fulltag .=
'.TAG='.$TAG;
1111 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
1112 print
'</td><td class="CTableRow2">';
1113 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1114 print
'<b>'.$creditor.
'</b>';
1115 print
'<input type="hidden" name="creditor" value="'.$creditor.
'">';
1116 print
'</td></tr>'.
"\n";
1119 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"ThirdParty");
1120 print
'</td><td class="CTableRow2">';
1121 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1122 print
'<b>'.$order->thirdparty->name.
'</b>';
1123 print
'</td></tr>'.
"\n";
1126 $text =
'<b>'.$langs->trans(
"PaymentOrderRef", $order->ref).
'</b>';
1127 if (
GETPOST(
'desc',
'alpha')) {
1128 $text =
'<b>'.$langs->trans(
GETPOST(
'desc',
'alpha')).
'</b>';
1130 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Designation");
1131 print
'</td><td class="CTableRow2">'.$text;
1132 print
'<input type="hidden" name="s" value="'.dol_escape_htmltag($source).
'">';
1133 print
'<input type="hidden" name="ref" value="'.dol_escape_htmltag($order->ref).
'">';
1134 print
'<input type="hidden" name="dol_id" value="'.dol_escape_htmltag((
string) $order->id).
'">';
1135 $directdownloadlink = $order->getLastMainDocLink(
'commande');
1136 if ($directdownloadlink) {
1137 print
'<br><a href="'.$directdownloadlink.
'" rel="nofollow noopener">';
1138 print
img_mime($order->last_main_doc,
'');
1139 print $langs->trans(
"DownloadDocument").
'</a>';
1141 print
'</td></tr>'.
"\n";
1144 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Amount");
1145 if (empty($amount)) {
1146 print
' ('.$langs->trans(
"ToComplete").
')';
1148 print
'</td><td class="CTableRow2">';
1149 if (empty($amount) || !is_numeric($amount)) {
1150 print
'<input type="hidden" name="amount" value="'.price2num(
GETPOST(
"amount",
'alpha'),
'MT').
'">';
1151 print
'<input class="flat maxwidth75" type="text" name="newamount" value="'.price2num(
GETPOST(
"newamount",
"alpha"),
'MT').
'">';
1153 print
' <b>'.$langs->trans(
"Currency".$currency).
'</b>';
1155 print
'<b class="amount">'.price($amount, 1, $langs, 1, -1, -1, $currency).
'</b>';
1156 print
'<input type="hidden" name="amount" value="'.$amount.
'">';
1157 print
'<input type="hidden" name="newamount" value="'.$amount.
'">';
1159 print
'<input type="hidden" name="currency" value="'.$currency.
'">';
1160 print
'</td></tr>'.
"\n";
1163 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentCode");
1164 print
'</td><td class="CTableRow2"><b style="word-break: break-all;">'.$fulltag.
'</b>';
1165 print
'<input type="hidden" name="tag" value="'.dol_escape_htmltag($tag).
'">';
1166 print
'<input type="hidden" name="fulltag" value="'.dol_escape_htmltag($fulltag).
'">';
1167 print
'</td></tr>'.
"\n";
1170 $shipToName = $order->thirdparty->name;
1171 $shipToStreet = $order->thirdparty->address;
1172 $shipToCity = $order->thirdparty->town;
1173 $shipToState = $order->thirdparty->state_code;
1174 $shipToCountryCode = $order->thirdparty->country_code;
1175 $shipToZip = $order->thirdparty->zip;
1176 $shipToStreet2 =
'';
1177 $phoneNum = $order->thirdparty->phone;
1178 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1179 print
'<input type="hidden" name="shipToName" value="'.dol_escape_htmltag($shipToName).
'">'.
"\n";
1180 print
'<input type="hidden" name="shipToStreet" value="'.dol_escape_htmltag($shipToStreet).
'">'.
"\n";
1181 print
'<input type="hidden" name="shipToCity" value="'.dol_escape_htmltag($shipToCity).
'">'.
"\n";
1182 print
'<input type="hidden" name="shipToState" value="'.dol_escape_htmltag($shipToState).
'">'.
"\n";
1183 print
'<input type="hidden" name="shipToCountryCode" value="'.dol_escape_htmltag($shipToCountryCode).
'">'.
"\n";
1184 print
'<input type="hidden" name="shipToZip" value="'.dol_escape_htmltag($shipToZip).
'">'.
"\n";
1185 print
'<input type="hidden" name="shipToStreet2" value="'.dol_escape_htmltag($shipToStreet2).
'">'.
"\n";
1186 print
'<input type="hidden" name="phoneNum" value="'.dol_escape_htmltag($phoneNum).
'">'.
"\n";
1188 print
'<!-- Shipping address not complete, so we don t use it -->'.
"\n";
1190 if (is_object($order->thirdparty)) {
1191 print
'<input type="hidden" name="thirdparty_id" value="'.$order->thirdparty->id.
'">'.
"\n";
1193 print
'<input type="hidden" name="email" value="'.$order->thirdparty->email.
'">'.
"\n";
1194 print
'<input type="hidden" name="vatnumber" value="'.dol_escape_htmltag($order->thirdparty->tva_intra).
'">'.
"\n";
1195 $labeldesc = $langs->trans(
"Order").
' '.$order->ref;
1196 if (
GETPOST(
'desc',
'alpha')) {
1197 $labeldesc =
GETPOST(
'desc',
'alpha');
1199 print
'<input type="hidden" name="desc" value="'.dol_escape_htmltag($labeldesc).
'">'.
"\n";
1204if ($source ==
'invoice') {
1206 $langs->load(
"bills");
1207 $form->load_cache_types_paiements();
1209 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1212 $result = $invoice->fetch(0, $ref);
1214 $mesg = $invoice->error;
1217 $result = $invoice->fetch_thirdparty($invoice->socid);
1221 if ($action !=
'dopayment') {
1222 $amount =
price2num($invoice->total_ttc - ($invoice->getSommePaiement() + $invoice->getSumCreditNotesUsed() + $invoice->getSumDepositsUsed()));
1223 if (
GETPOST(
"amount",
'alpha')) {
1224 $amount =
GETPOST(
"amount",
'alpha');
1229 if (
GETPOST(
'fulltag',
'alpha')) {
1230 $fulltag =
GETPOST(
'fulltag',
'alpha');
1232 $fulltag =
'INV='.$invoice->id.
'.CUS='.$invoice->thirdparty->id;
1235 $fulltag .=
'.TAG='.$TAG;
1241 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
1242 print
'</td><td class="CTableRow2">';
1243 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1244 print
'<b>'.$creditor.
'</b>';
1245 print
'<input type="hidden" name="creditor" value="'.dol_escape_htmltag($creditor).
'">';
1246 print
'</td></tr>'.
"\n";
1249 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"ThirdParty");
1250 print
'</td><td class="CTableRow2">';
1251 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1252 print
'<b>'.$invoice->thirdparty->name.
'</b>';
1253 print
'</td></tr>'.
"\n";
1256 $text =
'<b>'.$langs->trans(
"PaymentInvoiceRef", $invoice->ref).
'</b>';
1257 if (
GETPOST(
'desc',
'alpha')) {
1258 $text =
'<b>'.$langs->trans(
GETPOST(
'desc',
'alpha')).
'</b>';
1260 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Designation");
1261 print
'</td><td class="CTableRow2">'.$text;
1262 print
'<input type="hidden" name="s" value="'.dol_escape_htmltag($source).
'">';
1263 print
'<input type="hidden" name="ref" value="'.dol_escape_htmltag($invoice->ref).
'">';
1264 print
'<input type="hidden" name="dol_id" value="'.dol_escape_htmltag((
string) $invoice->id).
'">';
1265 $directdownloadlink = $invoice->getLastMainDocLink(
'facture');
1266 if ($directdownloadlink) {
1267 print
'<br><a href="'.$directdownloadlink.
'">';
1268 print
img_mime($invoice->last_main_doc,
'');
1269 print $langs->trans(
"DownloadDocument").
'</a>';
1271 print
'</td></tr>'.
"\n";
1274 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentAmount");
1275 if (empty($amount) && empty(
$object->paye)) {
1276 print
' ('.$langs->trans(
"ToComplete").
')';
1278 print
'</td><td class="CTableRow2">';
1279 if (
$object->type == $object::TYPE_CREDIT_NOTE) {
1280 print
'<b>'.$langs->trans(
"CreditNote").
'</b>';
1281 } elseif (empty(
$object->paye)) {
1282 if (empty($amount) || !is_numeric($amount)) {
1283 print
'<input type="hidden" name="amount" value="'.price2num(
GETPOST(
"amount",
'alpha'),
'MT').
'">';
1284 print
'<input class="flat maxwidth75" type="text" name="newamount" value="'.price2num(
GETPOST(
"newamount",
"alpha"),
'MT').
'">';
1285 print
' <b>'.$langs->trans(
"Currency".$currency).
'</b>';
1287 print
'<b class="amount">'.price($amount, 1, $langs, 1, -1, -1, $currency).
'</b>';
1288 print
'<input type="hidden" name="amount" value="'.$amount.
'">';
1289 print
'<input type="hidden" name="newamount" value="'.$amount.
'">';
1292 print
'<b class="amount">'.price(
$object->total_ttc, 1, $langs, 1, -1, -1, $currency).
'</b>';
1294 print
'<input type="hidden" name="currency" value="'.$currency.
'">';
1295 print
'</td></tr>'.
"\n";
1298 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentCode");
1299 print
'</td><td class="CTableRow2"><b style="word-break: break-all;">'.$fulltag.
'</b>';
1300 print
'<input type="hidden" name="tag" value="'.(empty($tag) ?
'' : $tag).
'">';
1301 print
'<input type="hidden" name="fulltag" value="'.$fulltag.
'">';
1302 print
'</td></tr>'.
"\n";
1305 if ($invoice->status == $invoice::STATUS_VALIDATED && $invoice->mode_reglement_id > 0 && $form->cache_types_paiements[$invoice->mode_reglement_id][
"code"] ==
"VIR") {
1306 print
'<tr class="CTableRow2 center"><td class="CTableRow2" colspan="2">';
1307 print
'<div class="warning maxwidth1000">';
1308 print $langs->trans(
"PayOfBankTransferInvoice");
1310 print
'</td></tr>'.
"\n";
1314 $shipToName = $invoice->thirdparty->name;
1315 $shipToStreet = $invoice->thirdparty->address;
1316 $shipToCity = $invoice->thirdparty->town;
1317 $shipToState = $invoice->thirdparty->state_code;
1318 $shipToCountryCode = $invoice->thirdparty->country_code;
1319 $shipToZip = $invoice->thirdparty->zip;
1320 $shipToStreet2 =
'';
1321 $phoneNum = $invoice->thirdparty->phone;
1322 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1323 print
'<input type="hidden" name="shipToName" value="'.$shipToName.
'">'.
"\n";
1324 print
'<input type="hidden" name="shipToStreet" value="'.$shipToStreet.
'">'.
"\n";
1325 print
'<input type="hidden" name="shipToCity" value="'.$shipToCity.
'">'.
"\n";
1326 print
'<input type="hidden" name="shipToState" value="'.$shipToState.
'">'.
"\n";
1327 print
'<input type="hidden" name="shipToCountryCode" value="'.$shipToCountryCode.
'">'.
"\n";
1328 print
'<input type="hidden" name="shipToZip" value="'.$shipToZip.
'">'.
"\n";
1329 print
'<input type="hidden" name="shipToStreet2" value="'.$shipToStreet2.
'">'.
"\n";
1330 print
'<input type="hidden" name="phoneNum" value="'.$phoneNum.
'">'.
"\n";
1332 print
'<!-- Shipping address not complete, so we don t use it -->'.
"\n";
1334 if (is_object($invoice->thirdparty)) {
1335 print
'<input type="hidden" name="thirdparty_id" value="'.$invoice->thirdparty->id.
'">'.
"\n";
1337 print
'<input type="hidden" name="email" value="'.$invoice->thirdparty->email.
'">'.
"\n";
1338 print
'<input type="hidden" name="vatnumber" value="'.$invoice->thirdparty->tva_intra.
'">'.
"\n";
1339 $labeldesc = $langs->trans(
"Invoice").
' '.$invoice->ref;
1340 if (
GETPOST(
'desc',
'alpha')) {
1341 $labeldesc =
GETPOST(
'desc',
'alpha');
1343 print
'<input type="hidden" name="desc" value="'.dol_escape_htmltag($labeldesc).
'">'.
"\n";
1347if ($source ==
'contractline') {
1349 $langs->load(
"contracts");
1351 require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
1356 $result = $contractline->fetch(0, $ref);
1358 $mesg = $contractline->error;
1361 if ($contractline->fk_contrat > 0) {
1362 $result = $contract->fetch($contractline->fk_contrat);
1364 $result = $contract->fetch_thirdparty($contract->socid);
1366 $mesg = $contract->error;
1370 $mesg =
'ErrorRecordNotFound';
1376 if ($action !=
'dopayment') {
1377 $amount = $contractline->total_ttc;
1379 if ($contractline->fk_product &&
getDolGlobalString(
'PAYMENT_USE_NEW_PRICE_FOR_CONTRACTLINES')) {
1381 $result = $product->fetch($contractline->fk_product);
1385 $pu_ht = $product->multiprices[$contract->thirdparty->price_level];
1386 $pu_ttc = $product->multiprices_ttc[$contract->thirdparty->price_level];
1387 $price_base_type = $product->multiprices_base_type[$contract->thirdparty->price_level];
1389 $pu_ht = $product->price;
1390 $pu_ttc = $product->price_ttc;
1391 $price_base_type = $product->price_base_type;
1395 if (empty($amount)) {
1401 if (
GETPOST(
"amount",
'alpha')) {
1402 $amount =
GETPOST(
"amount",
'alpha');
1407 if (
GETPOST(
'fulltag',
'alpha')) {
1408 $fulltag =
GETPOST(
'fulltag',
'alpha');
1410 $fulltag =
'COL='.$contractline->id.
'.CON='.$contract->id.
'.CUS='.$contract->thirdparty->id.
'.DAT='.
dol_print_date(
dol_now(),
'%Y%m%d%H%M%S');
1413 $fulltag .=
'.TAG='.$TAG;
1424 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
1425 print
'</td><td class="CTableRow2"><b>'.$creditor.
'</b>';
1426 print
'<input type="hidden" name="creditor" value="'.$creditor.
'">';
1427 print
'</td></tr>'.
"\n";
1430 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"ThirdParty");
1431 print
'</td><td class="CTableRow2"><b>'.$contract->thirdparty->name.
'</b>';
1432 print
'</td></tr>'.
"\n";
1435 $text =
'<b>'.$langs->trans(
"PaymentRenewContractId", $contract->ref, $contractline->ref).
'</b>';
1436 if ($contractline->fk_product > 0) {
1437 $contractline->fetch_product();
1438 $text .=
'<br>'.$contractline->product->ref.($contractline->product->label ?
' - '.$contractline->product->label :
'');
1440 if ($contractline->description) {
1441 $text .=
'<br>'.dol_htmlentitiesbr($contractline->description);
1443 if ($contractline->date_end) {
1444 $text .=
'<br>'.$langs->trans(
"ExpiredSince").
': '.
dol_print_date($contractline->date_end);
1446 if (
GETPOST(
'desc',
'alpha')) {
1447 $text =
'<b>'.$langs->trans(
GETPOST(
'desc',
'alpha')).
'</b>';
1449 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Designation");
1450 print
'</td><td class="CTableRow2">'.$text;
1451 print
'<input type="hidden" name="source" value="'.dol_escape_htmltag($source).
'">';
1452 print
'<input type="hidden" name="ref" value="'.dol_escape_htmltag($contractline->ref).
'">';
1453 print
'<input type="hidden" name="dol_id" value="'.dol_escape_htmltag((
string) $contractline->id).
'">';
1454 $directdownloadlink = $contract->getLastMainDocLink(
'contract');
1455 if ($directdownloadlink) {
1456 print
'<br><a href="'.$directdownloadlink.
'">';
1457 print
img_mime($contract->last_main_doc,
'');
1458 print $langs->trans(
"DownloadDocument").
'</a>';
1460 print
'</td></tr>'.
"\n";
1463 $label = $langs->trans(
"Quantity");
1466 if ($contractline->fk_product) {
1467 if ($contractline->product->isService() && $contractline->product->duration_value > 0) {
1468 $label = $langs->trans(
"Duration");
1471 if ($contractline->product->duration_value > 1) {
1472 $dur = array(
"h" => $langs->trans(
"Hours"),
"d" => $langs->trans(
"DurationDays"),
"w" => $langs->trans(
"DurationWeeks"),
"m" => $langs->trans(
"DurationMonths"),
"y" => $langs->trans(
"DurationYears"));
1474 $dur = array(
"h" => $langs->trans(
"Hour"),
"d" => $langs->trans(
"DurationDay"),
"w" => $langs->trans(
"DurationWeek"),
"m" => $langs->trans(
"DurationMonth"),
"y" => $langs->trans(
"DurationYear"));
1476 $duration = $contractline->product->duration_value.
' '.$dur[$contractline->product->duration_unit];
1479 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$label.
'</td>';
1480 print
'<td class="CTableRow2"><b>'.($duration ? $duration : $qty).
'</b>';
1481 print
'<input type="hidden" name="newqty" value="'.dol_escape_htmltag((
string) $qty).
'">';
1482 print
'</b></td></tr>'.
"\n";
1485 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Amount");
1486 if (empty($amount)) {
1487 print
' ('.$langs->trans(
"ToComplete").
')';
1489 print
'</td><td class="CTableRow2">';
1490 if (empty($amount) || !is_numeric($amount)) {
1491 print
'<input type="hidden" name="amount" value="'.price2num(
GETPOST(
"amount",
'alpha'),
'MT').
'">';
1492 print
'<input class="flat maxwidth75" type="text" name="newamount" value="'.price2num(
GETPOST(
"newamount",
"alpha"),
'MT').
'">';
1494 print
' <b>'.$langs->trans(
"Currency".$currency).
'</b>';
1496 print
'<b class="amount">'.price($amount, 1, $langs, 1, -1, -1, $currency).
'</b>';
1497 print
'<input type="hidden" name="amount" value="'.$amount.
'">';
1498 print
'<input type="hidden" name="newamount" value="'.$amount.
'">';
1500 print
'<input type="hidden" name="currency" value="'.$currency.
'">';
1501 print
'</td></tr>'.
"\n";
1504 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentCode");
1505 print
'</td><td class="CTableRow2"><b style="word-break: break-all;">'.$fulltag.
'</b>';
1506 print
'<input type="hidden" name="tag" value="'.$tag.
'">';
1507 print
'<input type="hidden" name="fulltag" value="'.$fulltag.
'">';
1508 print
'</td></tr>'.
"\n";
1511 $shipToName = $contract->thirdparty->name;
1512 $shipToStreet = $contract->thirdparty->address;
1513 $shipToCity = $contract->thirdparty->town;
1514 $shipToState = $contract->thirdparty->state_code;
1515 $shipToCountryCode = $contract->thirdparty->country_code;
1516 $shipToZip = $contract->thirdparty->zip;
1517 $shipToStreet2 =
'';
1518 $phoneNum = $contract->thirdparty->phone;
1519 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1520 print
'<input type="hidden" name="shipToName" value="'.$shipToName.
'">'.
"\n";
1521 print
'<input type="hidden" name="shipToStreet" value="'.$shipToStreet.
'">'.
"\n";
1522 print
'<input type="hidden" name="shipToCity" value="'.$shipToCity.
'">'.
"\n";
1523 print
'<input type="hidden" name="shipToState" value="'.$shipToState.
'">'.
"\n";
1524 print
'<input type="hidden" name="shipToCountryCode" value="'.$shipToCountryCode.
'">'.
"\n";
1525 print
'<input type="hidden" name="shipToZip" value="'.$shipToZip.
'">'.
"\n";
1526 print
'<input type="hidden" name="shipToStreet2" value="'.$shipToStreet2.
'">'.
"\n";
1527 print
'<input type="hidden" name="phoneNum" value="'.$phoneNum.
'">'.
"\n";
1529 print
'<!-- Shipping address not complete, so we don t use it -->'.
"\n";
1531 if (is_object($contract->thirdparty)) {
1532 print
'<input type="hidden" name="thirdparty_id" value="'.$contract->thirdparty->id.
'">'.
"\n";
1534 print
'<input type="hidden" name="email" value="'.$contract->thirdparty->email.
'">'.
"\n";
1535 print
'<input type="hidden" name="vatnumber" value="'.$contract->thirdparty->tva_intra.
'">'.
"\n";
1536 $labeldesc = $langs->trans(
"Contract").
' '.$contract->ref;
1537 if (
GETPOST(
'desc',
'alpha')) {
1538 $labeldesc =
GETPOST(
'desc',
'alpha');
1540 print
'<input type="hidden" name="desc" value="'.dol_escape_htmltag($labeldesc).
'">'.
"\n";
1544if ($source ==
'member' || $source ==
'membersubscription') {
1545 $newsource =
'member';
1549 $langs->load(
"members");
1551 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
1552 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent_type.class.php';
1553 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
1559 $result = $member->fetch(0, $ref);
1561 $mesg = $member->error;
1564 $member->fetch_thirdparty();
1566 $adht->fetch($member->typeid);
1570 if ($action !=
'dopayment') {
1571 $amount = $subscription->total_ttc;
1572 if (
GETPOST(
"amount",
'alpha')) {
1576 if (empty($amount)) {
1577 $amount = $adht->amount;
1580 $amount = max(0,
price2num($amount,
'MT'));
1583 if (
GETPOST(
'fulltag',
'alpha')) {
1584 $fulltag =
GETPOST(
'fulltag',
'alpha');
1589 $fulltag .=
'.TAG='.$TAG;
1595 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
1596 print
'</td><td class="CTableRow2"><b>'.$creditor.
'</b>';
1597 print
'<input type="hidden" name="creditor" value="'.$creditor.
'">';
1598 print
'</td></tr>'.
"\n";
1601 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Member");
1602 print
'</td><td class="CTableRow2">';
1604 if ($member->morphy ==
'mor' && !empty($member->company)) {
1605 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1606 print $member->company;
1608 print
img_picto(
'',
'member',
'class="pictofixedwidth"');
1609 print $member->getFullName($langs);
1612 print
'</td></tr>'.
"\n";
1615 $text =
'<b>'.$langs->trans(
"PaymentSubscription").
'</b>';
1616 if (
GETPOST(
'desc',
'alpha')) {
1617 $text =
'<b>'.$langs->trans(
GETPOST(
'desc',
'alpha')).
'</b>';
1619 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Designation");
1620 print
'</td><td class="CTableRow2">'.$text;
1621 print
'<input type="hidden" name="source" value="'.dol_escape_htmltag($newsource).
'">';
1622 print
'<input type="hidden" name="ref" value="'.dol_escape_htmltag($member->ref).
'">';
1623 print
'</td></tr>'.
"\n";
1626 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"DateEndSubscription");
1627 print
'</td><td class="CTableRow2">'.dol_print_date($member->datefin,
'day');
1628 print
'</td></tr>'.
"\n";
1631 if ($member->last_subscription_date || $member->last_subscription_amount) {
1634 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"LastSubscriptionDate");
1635 print
'</td><td class="CTableRow2">'.dol_print_date($member->last_subscription_date,
'day');
1636 print
'</td></tr>'.
"\n";
1640 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"LastSubscriptionAmount");
1641 print
'</td><td class="CTableRow2">'.price($member->last_subscription_amount);
1642 print
'</td></tr>'.
"\n";
1644 if (empty($amount) && !
GETPOST(
'newamount',
'alpha')) {
1645 $_GET[
'newamount'] = $member->last_subscription_amount;
1646 $_GET[
'amount'] = $member->last_subscription_amount;
1648 if (!empty($member->last_subscription_amount) && !GETPOSTISSET(
'newamount') && is_numeric($amount)) {
1649 $amount = max($member->last_subscription_amount, $amount);
1653 $amountbytype = $adht->amountByType(1);
1655 $typeid = $adht->id;
1656 $caneditamount = $adht->caneditamount;
1658 if ($member->type) {
1659 $oldtypeid = $member->typeid;
1660 $newtypeid = (int) (GETPOSTISSET(
"typeid") ?
GETPOSTINT(
"typeid") : $member->typeid);
1662 $typeid = $newtypeid;
1663 $adht->fetch($typeid);
1666 $caneditamount = $adht->caneditamount;
1670 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"LastMemberType");
1671 print
'</td><td class="CTableRow2">'.dol_escape_htmltag($member->type);
1672 print
"</td></tr>\n";
1675 $member->typeid = $newtypeid;
1676 $member->type = (string)
dol_getIdFromCode($db, $newtypeid,
'adherent_type',
'rowid',
'libelle');
1682 $amount = (!empty($amountbytype[$member->typeid])) ? $amountbytype[$member->typeid] : $member->last_subscription_amount;
1684 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"NewSubscription");
1685 print
'</td><td class="CTableRow2">';
1686 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);
1687 print "</td></tr>\n
";
1688 } elseif ($action == 'dopayment') {
1689 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("NewMemberType
");
1690 print '</td><td class="CTableRow2
">'.dol_escape_htmltag($member->type);
1691 print '<input type="hidden
" name="membertypeid
" value="'.$member->typeid.'">';
1692 print "</td></tr>\n
";
1695 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("MemberType
");
1696 print '</td><td class="CTableRow2
">'.dol_escape_htmltag($member->type);
1697 print "</td></tr>\n
";
1701 // Set amount for the subscription from the the type and options:
1702 // - First check the amount of the member type if not previous payment.
1703 $amount = ($member->last_subscription_amount ? $member->last_subscription_amount : (empty($amountbytype[$typeid]) ? 0 : $amountbytype[$typeid]));
1704 // - If not found, take the default amount
1705 if (empty($amount) && getDolGlobalString('MEMBER_NEWFORM_AMOUNT')) {
1706 $amount = getDolGlobalString('MEMBER_NEWFORM_AMOUNT');
1708 // - If a new amount was posted from the form
1709 if ($caneditamount && GETPOSTISSET('newamount') && GETPOSTFLOAT('newamount', 'MT') > 0) {
1710 $amount = GETPOSTFLOAT('newamount', 'MT');
1712 // - If a min is set or an amount from the posted form, we take them into account
1713 $amount = max(0, (float) $amount, (float) getDolGlobalInt("MEMBER_MIN_AMOUNT
"));
1716 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Amount
");
1717 // This place no longer allows amount edition
1718 if (getDolGlobalString('MEMBER_EXT_URL_SUBSCRIPTION_INFO')) {
1719 print ' - <a href="' . getDolGlobalString('MEMBER_EXT_URL_SUBSCRIPTION_INFO
').'" rel="external
" target="_blank
" rel="noopener noreferrer
">'.$langs->trans("SeeHere
").'</a>';
1721 print '</td><td class="CTableRow2
">';
1723 $caneditamount = $adht->caneditamount;
1724 $minimumamount = !getDolGlobalString('MEMBER_MIN_AMOUNT') ? $adht->amount : max(getDolGlobalString('MEMBER_MIN_AMOUNT'), $adht->amount, $amount);
1726 if ($caneditamount && $action != 'dopayment') {
1727 if (GETPOSTISSET('newamount')) {
1728 print '<input type="text
" class="width75
" name="newamount
" value="'.price(price2num(GETPOST('newamount
'), '', 2), 1, $langs, 1, -1, -1).'">';
1730 print '<input type="text
" class="width75
" name="newamount
" value="'.price($amount, 1, $langs, 1, -1, -1).'">';
1733 print '<b class="amount
">'.price($amount, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
1734 if ($minimumamount > $amount) {
1735 print ' <span class="opacitymedium small
">'. $langs->trans("AmountIsLowerToMinimumNotice
", price($minimumamount, 1, $langs, 1, -1, -1, $currency)).'</span>';
1737 print '<input type="hidden
" name="newamount
" value="'.$amount.'">';
1739 print '<input type="hidden
" name="amount
" value="'.$amount.'">';
1740 print '<input type="hidden
" name="currency
" value="'.$currency.'">';
1741 print '</td></tr>'."\n
";
1744 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("PaymentCode
");
1745 print '</td><td class="CTableRow2
"><b style="word-
break:
break-all;
">'.$fulltag.'</b>';
1746 print '<input type="hidden
" name="tag
" value="'.$tag.'">';
1747 print '<input type="hidden
" name="fulltag
" value="'.$fulltag.'">';
1748 print '</td></tr>'."\n
";
1751 $shipToName = $member->getFullName($langs);
1752 $shipToStreet = $member->address;
1753 $shipToCity = $member->town;
1754 $shipToState = $member->state_code;
1755 $shipToCountryCode = $member->country_code;
1756 $shipToZip = $member->zip;
1757 $shipToStreet2 = '';
1758 $phoneNum = $member->phone;
1759 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1760 print '<!-- Shipping address information -->';
1761 print '<input type="hidden
" name="shipToName
" value="'.$shipToName.'">'."\n
";
1762 print '<input type="hidden
" name="shipToStreet
" value="'.$shipToStreet.'">'."\n
";
1763 print '<input type="hidden
" name="shipToCity
" value="'.$shipToCity.'">'."\n
";
1764 print '<input type="hidden
" name="shipToState
" value="'.$shipToState.'">'."\n
";
1765 print '<input type="hidden
" name="shipToCountryCode
" value="'.$shipToCountryCode.'">'."\n
";
1766 print '<input type="hidden
" name="shipToZip
" value="'.$shipToZip.'">'."\n
";
1767 print '<input type="hidden
" name="shipToStreet2
" value="'.$shipToStreet2.'">'."\n
";
1768 print '<input type="hidden
" name="phoneNum
" value="'.$phoneNum.'">'."\n
";
1770 print '<!-- Shipping address not complete, so we don t use it -->'."\n
";
1772 if (is_object($member->thirdparty)) {
1773 print '<input type="hidden
" name="thirdparty_id
" value="'.$member->thirdparty->id.'">'."\n
";
1775 print '<input type="hidden
" name="email" value="'.$member->email.'">'."\n
";
1776 $labeldesc = $langs->trans("PaymentSubscription
");
1777 if (GETPOST('desc', 'alpha')) {
1778 $labeldesc = GETPOST('desc', 'alpha');
1780 print '<input type="hidden
" name="desc
" value="'.dol_escape_htmltag($labeldesc).'">'."\n
";
1783// Payment on donation
1784if ($source == 'donation') {
1786 $langs->load("don
");
1788 require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
1790 $don = new Don($db);
1791 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
1792 $result = $don->fetch($ref);
1794 $mesg = $don->error;
1797 $don->fetch_thirdparty();
1801 if ($action != 'dopayment') { // Do not change amount if we just click on first dopayment
1802 if (GETPOST("amount
", 'alpha')) {
1803 $amount = GETPOST("amount
", 'alpha');
1805 $amount = $don->getRemainToPay();
1807 $amount = price2num($amount);
1810 if (GETPOST('fulltag', 'alpha')) {
1811 $fulltag = GETPOST('fulltag', 'alpha');
1813 $fulltag = 'DON='.$don->ref.'.DAT='.dol_print_date(dol_now(), '%Y%m%d%H%M%S');
1816 $fulltag .= '.TAG='.$TAG;
1819 $fulltag = dol_string_unaccent($fulltag);
1822 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Creditor
");
1823 print '</td><td class="CTableRow2
"><b>'.$creditor.'</b>';
1824 print '<input type="hidden
" name="creditor
" value="'.$creditor.'">';
1825 print '</td></tr>'."\n
";
1828 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("ThirdParty
");
1829 print '</td><td class="CTableRow2
"><b>';
1830 if ($don->morphy == 'mor' && !empty($don->societe)) {
1831 print $don->societe;
1833 print $don->getFullName($langs);
1836 print '</td></tr>'."\n
";
1840 if (GETPOST('desc', 'alpha')) {
1841 $text = '<b>'.$langs->trans(GETPOST('desc', 'alpha')).'</b>';
1843 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Designation
");
1844 print '</td><td class="CTableRow2
">'.$text;
1845 print '<input type="hidden
" name="source
" value="'.dol_escape_htmltag($source).'">';
1846 print '<input type="hidden
" name="ref" value="'.dol_escape_htmltag($don->ref).'">';
1847 print '</td></tr>'."\n
";
1850 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Amount
");
1851 if (empty($amount)) {
1852 if (!getDolGlobalString('DONATION_NEWFORM_AMOUNT')) {
1853 print ' ('.$langs->trans("ToComplete
");
1855 if (getDolGlobalString('DONATION_EXT_URL_SUBSCRIPTION_INFO')) {
1856 print ' - <a href="' . getDolGlobalString('DONATION_EXT_URL_SUBSCRIPTION_INFO
').'" rel="external
" target="_blank
" rel="noopener noreferrer
">'.$langs->trans("SeeHere
").'</a>';
1858 if (!getDolGlobalString('DONATION_NEWFORM_AMOUNT')) {
1862 print '</td><td class="CTableRow2
">';
1864 if (empty($amount) || !is_numeric($amount)) {
1865 $valtoshow = price2num(GETPOST("newamount
", 'alpha'), 'MT');
1866 // force default subscription amount to value defined into constant...
1867 if (empty($valtoshow)) {
1868 if (getDolGlobalString('DONATION_NEWFORM_EDITAMOUNT')) {
1869 if (getDolGlobalString('DONATION_NEWFORM_AMOUNT')) {
1870 $valtoshow = getDolGlobalString('DONATION_NEWFORM_AMOUNT');
1873 if (getDolGlobalString('DONATION_NEWFORM_AMOUNT')) {
1874 $amount = getDolGlobalString('DONATION_NEWFORM_AMOUNT');
1879 if (empty($amount) || !is_numeric($amount)) {
1880 //$valtoshow=price2num(GETPOST("newamount
",'alpha'),'MT');
1881 if (getDolGlobalString('DONATION_MIN_AMOUNT') && $valtoshow) {
1882 $valtoshow = max(getDolGlobalString('DONATION_MIN_AMOUNT'), $valtoshow);
1884 print '<input type="hidden
" name="amount
" value="'.price2num(GETPOST("amount", 'alpha
'), 'MT
').'">';
1885 print '<input class="flat maxwidth75
" type="text
" name="newamount
" value="'.$valtoshow.'">';
1887 print ' <b>'.$langs->trans("Currency
".$currency).'</b>';
1889 $valtoshow = $amount;
1890 if (getDolGlobalString('DONATION_MIN_AMOUNT') && $valtoshow) {
1891 $valtoshow = max(getDolGlobalString('DONATION_MIN_AMOUNT'), $valtoshow);
1892 $amount = $valtoshow;
1894 print '<b class="amount
">'.price($valtoshow, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
1895 print '<input type="hidden
" name="amount
" value="'.$valtoshow.'">';
1896 print '<input type="hidden
" name="newamount
" value="'.$valtoshow.'">';
1898 print '<input type="hidden
" name="currency
" value="'.$currency.'">';
1899 print '</td></tr>'."\n
";
1902 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("PaymentCode
");
1903 print '</td><td class="CTableRow2
"><b style="word-
break:
break-all;
">'.$fulltag.'</b>';
1904 print '<input type="hidden
" name="tag
" value="'.$tag.'">';
1905 print '<input type="hidden
" name="fulltag
" value="'.$fulltag.'">';
1906 print '</td></tr>'."\n
";
1909 $shipToName = $don->getFullName($langs);
1910 $shipToStreet = $don->address;
1911 $shipToCity = $don->town;
1912 $shipToState = $don->state_code;
1913 $shipToCountryCode = $don->country_code;
1914 $shipToZip = $don->zip;
1915 $shipToStreet2 = '';
1916 $phoneNum = $don->phone;
1917 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1918 print '<!-- Shipping address information -->';
1919 print '<input type="hidden
" name="shipToName
" value="'.$shipToName.'">'."\n
";
1920 print '<input type="hidden
" name="shipToStreet
" value="'.$shipToStreet.'">'."\n
";
1921 print '<input type="hidden
" name="shipToCity
" value="'.$shipToCity.'">'."\n
";
1922 print '<input type="hidden
" name="shipToState
" value="'.$shipToState.'">'."\n
";
1923 print '<input type="hidden
" name="shipToCountryCode
" value="'.$shipToCountryCode.'">'."\n
";
1924 print '<input type="hidden
" name="shipToZip
" value="'.$shipToZip.'">'."\n
";
1925 print '<input type="hidden
" name="shipToStreet2
" value="'.$shipToStreet2.'">'."\n
";
1926 print '<input type="hidden
" name="phoneNum
" value="'.$phoneNum.'">'."\n
";
1928 print '<!-- Shipping address not complete, so we don t use it -->'."\n
";
1930 if (is_object($don->thirdparty)) {
1931 print '<input type="hidden
" name="thirdparty_id
" value="'.$don->thirdparty->id.'">'."\n
";
1933 print '<input type="hidden
" name="email" value="'.$don->email.'">'."\n
";
1934 $labeldesc = $langs->trans("PaymentSubscription
");
1935 if (GETPOST('desc', 'alpha')) {
1936 $labeldesc = GETPOST('desc', 'alpha');
1938 print '<input type="hidden
" name="desc
" value="'.dol_escape_htmltag($labeldesc).'">'."\n
";
1941if ($source == 'organizedeventregistration' && is_object($thirdparty)) {
1943 $langs->loadLangs(array("members
", "eventorganization
"));
1945 if (GETPOST('fulltag', 'alpha')) {
1946 $fulltag = GETPOST('fulltag', 'alpha');
1948 $fulltag = 'ATT='.$attendee->id.'.DAT='.dol_print_date(dol_now(), '%Y%m%d%H%M%S');
1951 $fulltag .= '.TAG='.$TAG;
1954 $fulltag = dol_string_unaccent($fulltag);
1957 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Creditor
");
1958 print '</td><td class="CTableRow2
"><b>'.$creditor.'</b>';
1959 print '<input type="hidden
" name="creditor
" value="'.$creditor.'">';
1960 print '</td></tr>'."\n
";
1963 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Attendee
");
1964 print '</td><td class="CTableRow2
"><b>';
1965 print $attendee->email;
1966 print($thirdparty->name ? ' ('.$thirdparty->name.')' : '');
1968 print '</td></tr>'."\n
";
1970 if (! is_object($attendee->project)) {
1971 $text = 'ErrorProjectNotFound';
1973 $text = $langs->trans("PaymentEvent
").' - '.$attendee->project->title;
1977 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Designation
");
1978 print '</td><td class="CTableRow2
"><b>'.$text.'</b>';
1979 print '<input type="hidden
" name="source
" value="'.dol_escape_htmltag($source).'">';
1980 print '<input type="hidden
" name="ref" value="'.dol_escape_htmltag($invoice->id).'">';
1981 print '</td></tr>'."\n
";
1984 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Amount
");
1985 print '</td><td class="CTableRow2
">';
1986 $valtoshow = $amount;
1987 print '<b class="amount
">'.price($valtoshow, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
1988 print '<input type="hidden
" name="amount
" value="'.$valtoshow.'">';
1989 print '<input type="hidden
" name="newamount
" value="'.$valtoshow.'">';
1990 print '<input type="hidden
" name="currency
" value="'.$currency.'">';
1991 print '</td></tr>'."\n
";
1994 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("PaymentCode
");
1995 print '</td><td class="CTableRow2
"><b style="word-
break:
break-all;
">'.$fulltag.'</b>';
1996 print '<input type="hidden
" name="tag
" value="'.$tag.'">';
1997 print '<input type="hidden
" name="fulltag
" value="'.$fulltag.'">';
1998 print '</td></tr>'."\n
";
2001 $shipToName = $thirdparty->getFullName($langs);
2002 $shipToStreet = $thirdparty->address;
2003 $shipToCity = $thirdparty->town;
2004 $shipToState = $thirdparty->state_code;
2005 $shipToCountryCode = $thirdparty->country_code;
2006 $shipToZip = $thirdparty->zip;
2007 $shipToStreet2 = '';
2008 $phoneNum = $thirdparty->phone;
2009 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
2010 print '<!-- Shipping address information -->';
2011 print '<input type="hidden
" name="shipToName
" value="'.$shipToName.'">'."\n
";
2012 print '<input type="hidden
" name="shipToStreet
" value="'.$shipToStreet.'">'."\n
";
2013 print '<input type="hidden
" name="shipToCity
" value="'.$shipToCity.'">'."\n
";
2014 print '<input type="hidden
" name="shipToState
" value="'.$shipToState.'">'."\n
";
2015 print '<input type="hidden
" name="shipToCountryCode
" value="'.$shipToCountryCode.'">'."\n
";
2016 print '<input type="hidden
" name="shipToZip
" value="'.$shipToZip.'">'."\n
";
2017 print '<input type="hidden
" name="shipToStreet2
" value="'.$shipToStreet2.'">'."\n
";
2018 print '<input type="hidden
" name="phoneNum
" value="'.$phoneNum.'">'."\n
";
2020 print '<!-- Shipping address not complete, so we don t use it -->'."\n
";
2022 print '<input type="hidden
" name="thirdparty_id
" value="'.$thirdparty->id.'">'."\n
";
2023 print '<input type="hidden
" name="email" value="'.$thirdparty->email.'">'."\n
";
2024 $labeldesc = $langs->trans("PaymentSubscription
");
2025 if (GETPOST('desc', 'alpha')) {
2026 $labeldesc = GETPOST('desc', 'alpha');
2028 print '<input type="hidden
" name="desc
" value="'.dol_escape_htmltag($labeldesc).'">'."\n
";
2031if ($source == 'boothlocation') {
2033 $langs->load("members
");
2035 if (GETPOST('fulltag', 'alpha')) {
2036 $fulltag = GETPOST('fulltag', 'alpha');
2038 $fulltag = 'BOO='.GETPOST("booth
").'.DAT='.dol_print_date(dol_now(), '%Y%m%d%H%M%S');
2041 $fulltag .= '.TAG='.$TAG;
2044 $fulltag = dol_string_unaccent($fulltag);
2047 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Creditor
");
2048 print '</td><td class="CTableRow2
"><b>'.$creditor.'</b>';
2049 print '<input type="hidden
" name="creditor
" value="'.$creditor.'">';
2050 print '</td></tr>'."\n
";
2053 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Attendee
");
2054 print '</td><td class="CTableRow2
"><b>';
2055 print $thirdparty->name;
2057 print '</td></tr>'."\n
";
2060 $text = '<b>'.$langs->trans("PaymentBoothLocation
").'</b>';
2061 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Designation
");
2062 print '</td><td class="CTableRow2
">'.$text;
2063 print '<input type="hidden
" name="source
" value="'.dol_escape_htmltag($source).'">';
2064 print '<input type="hidden
" name="ref" value="'.dol_escape_htmltag($invoice->id).'">';
2065 print '</td></tr>'."\n
";
2068 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Amount
");
2069 print '</td><td class="CTableRow2
">';
2070 $valtoshow = $amount;
2071 print '<b class="amount
">'.price($valtoshow, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
2072 print '<input type="hidden
" name="amount
" value="'.$valtoshow.'">';
2073 print '<input type="hidden
" name="newamount
" value="'.$valtoshow.'">';
2074 print '<input type="hidden
" name="currency
" value="'.$currency.'">';
2075 print '</td></tr>'."\n
";
2078 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("PaymentCode
");
2079 print '</td><td class="CTableRow2
"><b style="word-
break:
break-all;
">'.$fulltag.'</b>';
2080 print '<input type="hidden
" name="tag
" value="'.$tag.'">';
2081 print '<input type="hidden
" name="fulltag
" value="'.$fulltag.'">';
2082 print '</td></tr>'."\n
";
2085 $shipToName = $thirdparty->getFullName($langs);
2086 $shipToStreet = $thirdparty->address;
2087 $shipToCity = $thirdparty->town;
2088 $shipToState = $thirdparty->state_code;
2089 $shipToCountryCode = $thirdparty->country_code;
2090 $shipToZip = $thirdparty->zip;
2091 $shipToStreet2 = '';
2092 $phoneNum = $thirdparty->phone;
2093 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
2094 print '<!-- Shipping address information -->';
2095 print '<input type="hidden
" name="shipToName
" value="'.$shipToName.'">'."\n
";
2096 print '<input type="hidden
" name="shipToStreet
" value="'.$shipToStreet.'">'."\n
";
2097 print '<input type="hidden
" name="shipToCity
" value="'.$shipToCity.'">'."\n
";
2098 print '<input type="hidden
" name="shipToState
" value="'.$shipToState.'">'."\n
";
2099 print '<input type="hidden
" name="shipToCountryCode
" value="'.$shipToCountryCode.'">'."\n
";
2100 print '<input type="hidden
" name="shipToZip
" value="'.$shipToZip.'">'."\n
";
2101 print '<input type="hidden
" name="shipToStreet2
" value="'.$shipToStreet2.'">'."\n
";
2102 print '<input type="hidden
" name="phoneNum
" value="'.$phoneNum.'">'."\n
";
2104 print '<!-- Shipping address not complete, so we don t use it -->'."\n
";
2106 print '<input type="hidden
" name="thirdparty_id
" value="'.$thirdparty->id.'">'."\n
";
2107 print '<input type="hidden
" name="email" value="'.$thirdparty->email.'">'."\n
";
2108 $labeldesc = $langs->trans("PaymentSubscription
");
2109 if (GETPOST('desc', 'alpha')) {
2110 $labeldesc = GETPOST('desc', 'alpha');
2112 print '<input type="hidden
" name="desc
" value="'.dol_escape_htmltag($labeldesc).'">'."\n
";
2115if (!$found && !$mesg) {
2116 $mesg = $langs->trans("ErrorBadParameters
");
2120 print '<tr><td align="center
" colspan="2
"><br><div class="warning
">'.dol_escape_htmltag($mesg, 1, 1, 'br').'</div></td></tr>'."\n
";
2123print '</table>'."\n
";
2127// Show all payment mode buttons (Stripe, Paypal, ...)
2128if ($action != 'dopayment') {
2129 if ($found && !$error) { // We are in a management option and no error
2130 // Check status of the object (Invoice) to verify if it is paid by external payment modules (ie Payzen, ...)
2132 'source' => $source,
2135 $reshook = $hookmanager->executeHooks('doCheckStatus', $parameters, $object, $action);
2137 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2138 } elseif ($reshook > 0) {
2139 print $hookmanager->resPrint;
2142 if ($source == 'order' && $object->billed) {
2143 print '<br><br><div class="amountpaymentcomplete size12x wrapimp
">'.$langs->trans("OrderBilled
").'</div>';
2144 } elseif ($source == 'invoice' && $object->paye) {
2145 print '<br><br><div class="amountpaymentcomplete size12x wrapimp
">'.$langs->trans("InvoicePaid
").'</div>';
2146 } elseif ($source == 'donation' && $object->paid) {
2147 print '<br><br><div class="amountpaymentcomplete size12x wrapimp
">'.$langs->trans("DonationPaid
").'</div>';
2149 // Membership can be paid and we still allow to make renewal
2150 if (($source == 'member' || $source == 'membersubscription') && $object->datefin > dol_now()) {
2151 $langs->load("members
");
2152 print '<br><div class="amountpaymentcomplete size12x wrapimp
">';
2153 $s = $langs->trans("MembershipPaid
", '{s1}');
2154 print str_replace('{s1}', '<span class="nobold
">'.dol_print_date($object->datefin, 'day').'</span>', $s);
2156 print '<div class="opacitymedium margintoponly
">'.$langs->trans("PaymentWillBeRecordedForNextPeriod
").'</div>';
2160 // Buttons for all payments registration methods
2162 // This hook is used to add Button to newpayment.php for external payment modules (ie Payzen, ...)
2164 'paymentmethod' => $paymentmethod
2166 $reshook = $hookmanager->executeHooks('doAddButton', $parameters, $object, $action);
2168 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2169 } elseif ($reshook >= 0) {
2170 print $hookmanager->resPrint;
2173 if ((empty($paymentmethod) || $paymentmethod == 'paybox') && isModEnabled('paybox')) {
2174 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").'">';
2176 print '<span class="buttonpaymentsmall
">'.$langs->trans("CreditOrDebitCard
").'</span>';
2179 $( document ).ready(function() {
2180 $("#div_dopayment_paybox
").click(function(){
2181 $("#dopayment_paybox
").click();
2183 $("#dopayment_paybox
").click(function(e){
2184 $("#div_dopayment_paybox
").css( \'cursor\', \'wait\' );
2185 e.stopPropagation();
2192 if ((empty($paymentmethod) || $paymentmethod == 'stripe') && isModEnabled('stripe')) {
2194 if (getDolGlobalString(strtoupper($source).'_FORCE_DISABLE_STRIPE')) { // Example: MEMBER_FORCE_DISABLE_STRIPE
2199 // By default noidempotency is set to 1, to avoid the error "Keys
for idempotant requests...
". It means we can pay several times the same tag/ref.
2200 // If STRIPE_USE_IDEMPOTENCY_BY_DEFAULT is set or param noidempotency=0 is added, then with add an idempotent key, so we must use a different tag/ref for each payment (if not we will get an error).
2201 $noidempotency_key = (GETPOSTISSET('noidempotency') ? GETPOSTINT('noidempotency') : (getDolGlobalInt('STRIPE_USE_IDEMPOTENCY_BY_DEFAULT') ? 0 : 1));
2203 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").'">';
2204 print '<input type="hidden
" name="noidempotency
" value="'.$noidempotency_key.'">';
2206 print '<span class="buttonpaymentsmall
">'.$langs->trans("CreditOrDebitCard
").'</span>';
2209 $( document ).ready(function() {
2210 $("#div_dopayment_stripe
").click(function(){
2211 $("#dopayment_stripe
").click();
2213 $("#dopayment_stripe
").click(function(e){
2214 $("#div_dopayment_stripe
").css( \'cursor\', \'wait\' );
2215 e.stopPropagation();
2224 if ((empty($paymentmethod) || $paymentmethod == 'paypal') && isModEnabled('paypal')) {
2225 if (!getDolGlobalString('PAYPAL_API_INTEGRAL_OR_PAYPALONLY')) {
2226 $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY = 'integral';
2230 if (getDolGlobalString(strtoupper($source).'_FORCE_DISABLE_PAYPAL')) { // Example: MEMBER_FORCE_DISABLE_PAYPAL
2235 print '<div class="button buttonpayment
" id="div_dopayment_paypal
">';
2236 if (getDolGlobalString('PAYPAL_API_INTEGRAL_OR_PAYPALONLY') != 'integral') {
2237 print '<div style="line-height: 1em
"> </div>';
2239 print '<span class="fab fa-paypal
"></span> <input class="" type="submit
" id="dopayment_paypal
" name="dopayment_paypal
" value="'.$langs->trans("PaypalDoPayment").'">';
2240 if (getDolGlobalString('PAYPAL_API_INTEGRAL_OR_PAYPALONLY') == 'integral') {
2242 print '<span class="buttonpaymentsmall
">'.$langs->trans("CreditOrDebitCard
").'</span><span class="buttonpaymentsmall
"> - </span>';
2243 print '<span class="buttonpaymentsmall
">'.$langs->trans("PayPalBalance
").'</span>';
2245 //if (getDolGlobalString('PAYPAL_API_INTEGRAL_OR_PAYPALONLY') == 'paypalonly') {
2247 //print '<span class="buttonpaymentsmall
">'.$langs->trans("PayPalBalance
").'"></span>
';
2251 $( document ).ready(
function() {
2252 $(
"#div_dopayment_paypal").click(
function(){
2253 $(
"#dopayment_paypal").click();
2255 $(
"#dopayment_paypal").click(
function(e){
2256 $(
"#div_dopayment_paypal").css( \
'cursor\', \'wait\' );
2257 e.stopPropagation();
2273print
'</td></tr>'.
"\n";
2275print
'</table>'.
"\n";
2277print
'</form>'.
"\n";
2285if (preg_match(
'/^dopayment/', $action)) {
2288 $_SESSION[
"currencyCodeType"] = $currency;
2289 $_SESSION[
"FinalPaymentAmt"] = $amount;
2290 $_SESSION[
'ipaddress'] = ($remoteip ? $remoteip :
'unknown');
2291 $_SESSION[
"paymentType"] =
'';
2296 if (
GETPOST(
'dopayment_stripe',
'alpha')) {
2304 background-color: white;
2307 border: 1px solid transparent;
2308 box-shadow: 0 1px 3px 0 #e6ebf1;
2309 -webkit-transition: box-shadow 150ms ease;
2310 transition: box-shadow 150ms ease;
2313 .StripeElement--focus {
2314 box-shadow: 0 1px 3px 0 #cfd7df;
2317 .StripeElement--invalid {
2318 border-color: #fa755a;
2321 .StripeElement--webkit-autofill {
2322 background-color: #fefde5 !important;
2328 print
'<!-- Show Stripe form payment-form STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION = ' .
getDolGlobalString(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION').
' STRIPE_USE_NEW_CHECKOUT = ' .
getDolGlobalString(
'STRIPE_USE_NEW_CHECKOUT').
' -->'.
"\n";
2329 print
'<form action="'.$_SERVER[
'REQUEST_URI'].
'" method="POST" id="payment-form">'.
"\n";
2331 print
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
2332 print
'<input type="hidden" name="dopayment_stripe" value="1">'.
"\n";
2333 print
'<input type="hidden" name="action" value="charge">'.
"\n";
2334 print
'<input type="hidden" name="tag" value="'.$TAG.
'">'.
"\n";
2335 print
'<input type="hidden" name="s" value="'.$source.
'">'.
"\n";
2336 print
'<input type="hidden" name="ref" value="'.$REF.
'">'.
"\n";
2337 print
'<input type="hidden" name="fulltag" value="'.$FULLTAG.
'">'.
"\n";
2338 print
'<input type="hidden" name="suffix" value="'.$suffix.
'">'.
"\n";
2339 print
'<input type="hidden" name="securekey" value="'.$SECUREKEY.
'">'.
"\n";
2340 print
'<input type="hidden" name="e" value="'.$entity.
'" />';
2341 print
'<input type="hidden" name="amount" value="'.$amount.
'">'.
"\n";
2342 print
'<input type="hidden" name="currency" value="'.$currency.
'">'.
"\n";
2343 print
'<input type="hidden" name="forcesandbox" value="'.GETPOSTINT(
'forcesandbox').
'" />';
2344 print
'<input type="hidden" name="email" value="'.GETPOST(
'email',
'alpha').
'" />';
2345 print
'<input type="hidden" name="thirdparty_id" value="'.GETPOSTINT(
'thirdparty_id').
'" />';
2346 print
'<input type="hidden" name="lang" value="'.$getpostlang.
'">';
2349 require_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
2351 $service =
'StripeLive';
2354 $service =
'StripeTest';
2358 $stripe =
new Stripe($db);
2359 $stripeacc = $stripe->getStripeAccount($service);
2361 $stripecu = $stripe->customerStripe(
$object->thirdparty, $stripeacc, $servicestatus, 1);
2367 $noidempotency_key = (GETPOSTISSET(
'noidempotency') ?
GETPOSTINT(
'noidempotency') : (
getDolGlobalInt(
'STRIPE_USE_IDEMPOTENCY_BY_DEFAULT') ? 0 : 1));
2369 $paymentintent = $stripe->getPaymentIntent($amount, $currency, ($tag ? $tag : $fulltag),
'Stripe payment: '.$fulltag.(is_object(
$object) ?
' ref='.
$object->
ref :
''),
$object, $stripecu, $stripeacc, $servicestatus, 0,
'automatic', false, null, 0, $noidempotency_key);
2372 if ($stripe->error) {
2383 <table id="dolpaymenttable" summary="Payment form" class="center centpercent">
2384 <tbody><tr><td class="textpublicpayment">';
2387 print
'<div id="payment-request-button"><!-- A Stripe Element will be inserted here. --></div>';
2390 print
'<div class="form-row '.(getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 2 ?
'center' :
'left').
'">';
2391 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 1) {
2392 print
'<label for="card-element">'.$langs->trans(
"CreditOrDebitCard").
'</label>';
2393 print
'<br><input id="cardholder-name" class="marginbottomonly" name="cardholder-name" value="" type="text" placeholder="'.$langs->trans(
"CardOwner").
'" autocomplete="off" autofocus required>';
2396 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 1) {
2397 print
'<div id="card-element">
2398 <!-- a Stripe Element will be inserted here. -->
2401 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 2) {
2402 print
'<div id="payment-element">
2403 <!-- a Stripe Element will be inserted here. -->
2407 print
'<!-- Used to display form errors -->
2408 <div id="card-errors" role="alert"></div>
2412 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>';
2413 print
'<img id="hourglasstopay" class="hidden" src="'.DOL_URL_ROOT.
'/theme/'.
$conf->theme.
'/img/working.gif">';
2415 print
'</td></tr></tbody>';
2420 if (empty($paymentintent)) {
2421 print
'<center>'.$langs->trans(
"Error").
'</center>';
2423 print
'<input type="hidden" name="paymentintent_id" value="'.$paymentintent->id.
'">';
2428 print
'</form>'.
"\n";
2432 if (empty($stripearrayofkeys[
'publishable_key'])) {
2433 $langs->load(
"errors");
2434 print
info_admin($langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv(
"Stripe")), 0, 0,
'error');
2436 print
'<!-- JS Code for Stripe components -->';
2437 print
'<script src="https://js.stripe.com/v3/"></script>'.
"\n";
2438 print
'<!-- urllogofull = '.$urllogofull.
' -->'.
"\n";
2441 print
'<script type="text/javascript">'.
"\n";
2444 $amountstripe = $amount;
2448 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
2449 if (!in_array($currency, $arrayzerounitcurrency)) {
2450 $amountstripe *= 100;
2454 $metadata = array(
'dol_version' => DOL_VERSION,
'dol_entity' =>
$conf->entity,
'ipaddress' => $ipaddress);
2456 $metadata[
'dol_type'] =
$object->element;
2457 $metadata[
'dol_id'] =
$object->id;
2463 $arrayforpaymentintent = array(
2464 'description' =>
'Stripe payment: '.$FULLTAG.($ref ?
' ref='.$ref :
''),
2465 "metadata" => $metadata
2468 $arrayforpaymentintent[
"statement_descriptor"] =
dol_trunc($TAG, 10,
'right',
'UTF-8', 1);
2471 $arrayforcheckout = array(
2472 'payment_method_types' => array(
'card'),
2473 'line_items' => array(array(
2474 'price_data' => array(
2475 'currency' => $currency,
2476 'unit_amount' => $amountstripe,
2477 'product_data' => array(
2478 'name' => $langs->transnoentitiesnoconv(
"Payment").
' '.$TAG,
2479 'description' =>
'Stripe payment: '.$FULLTAG.($ref ?
' ref='.$ref :
''),
2485 'mode' =>
'payment',
2486 'client_reference_id' => $FULLTAG,
2487 'success_url' => $urlok,
2488 'cancel_url' => $urlko,
2489 'payment_intent_data' => $arrayforpaymentintent
2492 $arrayforcheckout[
'customer'] = $stripecu;
2494 $arrayforcheckout[
'customer_email'] =
GETPOST(
'email',
'alpha');
2496 $sessionstripe = \Stripe\Checkout\Session::create($arrayforcheckout);
2501 $_SESSION[
"currencyCodeType"] = $currency;
2502 $_SESSION[
"paymentType"] =
'';
2503 $_SESSION[
"FinalPaymentAmt"] = $amount;
2504 $_SESSION[
'ipaddress'] = ($remoteip ? $remoteip :
'unknown');
2505 $_SESSION[
'payerID'] = is_object($stripecu) ? $stripecu->id :
'';
2506 $_SESSION[
'TRANSACTIONID'] = $sessionstripe->id;
2508 print $e->getMessage();
2514 if (empty($stripeacc)) {
2516 var stripe =
Stripe(
'<?php echo $stripearrayofkeys['publishable_key
']; // Defined into config.php?>');
2520 var stripe =
Stripe(
'<?php echo $stripearrayofkeys['publishable_key
']; // Defined into config.php?>', { stripeAccount:
'<?php echo $stripeacc; ?>' });
2525 var elements = stripe.elements();
2533 fontFamily:
'"Helvetica Neue", Helvetica, sans-serif',
2534 fontSmoothing:
'antialiased',
2542 iconColor:
'#fa755a'
2546 var cardElement = elements.create(
'card', {style: style});
2549 stripe.redirectToCheckout({
2553 sessionId:
'<?php print $sessionstripe->id; ?>'
2554 }).then(
function (result) {
2568 if (empty($stripeacc)) {
2570 var stripe =
Stripe(
'<?php echo $stripearrayofkeys['publishable_key
']; // Defined into config.php?>');
2574 var stripe =
Stripe(
'<?php echo $stripearrayofkeys['publishable_key
']; // Defined into config.php?>', { stripeAccount:
'<?php echo $stripeacc; ?>' });
2579 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 2) {
2581 var cardButton = document.getElementById(
'buttontopay');
2582 var clientSecret = cardButton.dataset.secret;
2583 var options = { clientSecret: clientSecret };
2586 var elements = stripe.elements(options);
2591 var elements = stripe.elements();
2601 fontFamily:
'"Helvetica Neue", Helvetica, sans-serif',
2602 fontSmoothing:
'antialiased',
2610 iconColor:
'#fa755a'
2615 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 2) {
2617 var paymentElement = elements.create(
"payment");
2620 paymentElement.mount(
"#payment-element");
2623 var cardButton = document.getElementById(
'buttontopay');
2625 cardButton.addEventListener(
'click',
function(event) {
2626 console.log(
"We click on buttontopay");
2627 event.preventDefault();
2630 jQuery(
'#hourglasstopay').show();
2631 jQuery(
'#buttontopay').hide();
2633 stripe.confirmPayment({
2634 elements,confirmParams: {
2635 return_url:
'<?php echo $urlok; ?>',
2636 payment_method_data: {
2640 ?>, email:
'<?php echo dol_escape_js(GETPOST('email
', 'alpha
') ? GETPOST('email
', 'alpha
') : $object->thirdparty->email); ?>'<?php
2643 ?>, phone:
'<?php echo dol_escape_js($object->thirdparty->phone); ?>'<?php
2647 city:
'<?php echo dol_escape_js($object->thirdparty->town); ?>',
2648 <?php if ($object->thirdparty->country_code) {
2649 ?>country:
'<?php echo dol_escape_js($object->thirdparty->country_code); ?>',<?php
2651 line1:
'<?php echo dol_escape_js(preg_replace('/\s\s+/
', ' ', $object->thirdparty->address)); ?>',
2652 postal_code:
'<?php echo dol_escape_js($object->thirdparty->zip); ?>'
2658 save_payment_method:<?php
if ($stripecu) {
2665 ).then(
function(result) {
2666 console.log(result);
2668 console.log(
"Error on result of handleCardPayment");
2669 jQuery(
'#buttontopay').show();
2670 jQuery(
'#hourglasstopay').hide();
2672 var errorElement = document.getElementById(
'card-errors');
2673 console.log(result);
2674 errorElement.textContent = result.error.message;
2677 console.log(
"No error on result of handleCardPayment, so we submit the form");
2679 jQuery(
'#buttontopay').hide();
2680 jQuery(
'#hourglasstopay').show();
2682 jQuery(
'#payment-form').submit();
2690 var cardElement = elements.create(
'card', {style: style});
2693 cardElement.mount(
'#card-element');
2696 cardElement.addEventListener(
'change',
function(event) {
2697 var displayError = document.getElementById(
'card-errors');
2699 console.log(
"Show event error (like 'Incorrect card number', ...)");
2700 displayError.textContent =
event.error.message;
2702 console.log(
"Reset error message");
2703 displayError.textContent =
'';
2708 var cardholderName = document.getElementById(
'cardholder-name');
2709 var cardButton = document.getElementById(
'buttontopay');
2710 var clientSecret = cardButton.dataset.secret;
2712 cardButton.addEventListener(
'click',
function(event) {
2713 console.log(
"We click on buttontopay");
2714 event.preventDefault();
2716 if (cardholderName.value ==
'')
2718 console.log(
"Field Card holder is empty");
2719 var displayError = document.getElementById(
'card-errors');
2720 displayError.textContent =
'<?php print dol_escape_js($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardOwner"))); ?>';
2725 jQuery(
'#hourglasstopay').show();
2726 jQuery(
'#buttontopay').hide();
2728 stripe.handleCardPayment(
2729 clientSecret, cardElement, {
2730 payment_method_data: {
2732 name: cardholderName.value
2734 ?>, email:
'<?php echo dol_escape_js(GETPOST('email
', 'alpha
') ? GETPOST('email
', 'alpha
') : $object->thirdparty->email); ?>'<?php
2737 ?>, phone:
'<?php echo dol_escape_js($object->thirdparty->phone); ?>'<?php
2741 city:
'<?php echo dol_escape_js($object->thirdparty->town); ?>',
2742 <?php if ($object->thirdparty->country_code) {
2743 ?>country:
'<?php echo dol_escape_js($object->thirdparty->country_code); ?>',<?php
2745 line1:
'<?php echo dol_escape_js(preg_replace('/\s\s+/
', ' ', $object->thirdparty->address)); ?>',
2746 postal_code:
'<?php echo dol_escape_js($object->thirdparty->zip); ?>'
2752 save_payment_method:<?php
if ($stripecu) {
2758 ).then(
function(result) {
2759 console.log(result);
2761 console.log(
"Error on result of handleCardPayment");
2762 jQuery(
'#buttontopay').show();
2763 jQuery(
'#hourglasstopay').hide();
2765 var errorElement = document.getElementById(
'card-errors');
2766 errorElement.textContent = result.error.message;
2769 console.log(
"No error on result of handleCardPayment, so we submit the form");
2771 jQuery(
'#buttontopay').hide();
2772 jQuery(
'#hourglasstopay').show();
2774 jQuery(
'#payment-form').submit();
2792 'paymentmethod' => $paymentmethod,
2793 'amount' => $amount,
2794 'currency' => $currency,
2795 'tag' =>
GETPOST(
"tag",
'alpha'),
2796 'dopayment' =>
GETPOST(
'dopayment',
'alpha')
2798 $reshook = $hookmanager->executeHooks(
'doPayment', $parameters,
$object, $action);
2801 } elseif ($reshook > 0) {
2802 print $hookmanager->resPrint;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
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 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...)
Stripe class @TODO No reason to extends CommonObject.
Class to manage subscriptions of foundation members.
htmlPrintOnlineFooter($fromcompany, $langs, $addformmessage=0, $suffix='', $object=null)
Show footer of company in HTML pages.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as p label as s rowid as s nom as s email
Sender: Who sends the email ("Sender" has sent emails on behalf of "From").
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_now($mode='auto')
Return date for now.
img_mime($file, $titlealt='', $morecss='')
Show MIME img of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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.
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 formatted messages to output (Used to show messages on html output).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
getUserRemoteIP()
Return the IP of remote user.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
ui state ui widget content ui state ui widget header ui state a ui button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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,...