39if (!defined(
'NOLOGIN')) {
42if (!defined(
'NOCSRFCHECK')) {
43 define(
"NOCSRFCHECK", 1);
45if (!defined(
'NOIPCHECK')) {
46 define(
'NOIPCHECK',
'1');
48if (!defined(
'NOBROWSERNOTIF')) {
49 define(
'NOBROWSERNOTIF',
'1');
55$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))));
56if (is_numeric($entity)) {
57 define(
"DOLENTITY", $entity);
61require
'../../main.inc.php';
62require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
63require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
64require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
65require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
66require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
67require_once DOL_DOCUMENT_ROOT.
'/societe/class/societeaccount.class.php';
68require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
69require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
73$hookmanager->initHooks(array(
'newpayment'));
76$langs->loadLangs(array(
"main",
"other",
"dict",
"bills",
"companies",
"errors",
"paybox",
"paypal",
"stripe"));
81$action =
GETPOST(
'action',
'aZ09');
90$suffix =
GETPOST(
"suffix",
'aZ09');
92if (!
GETPOST(
"currency",
'alpha')) {
93 $currency = $conf->currency;
95 $currency =
GETPOST(
"currency",
'aZ09');
98$getpostlang =
GETPOST(
'lang',
'aZ09');
102 if (!
GETPOST(
"amount",
'alpha') && !$source) {
103 print $langs->trans(
'ErrorBadParameters').
" - amount or source";
106 if (is_numeric($amount) && !
GETPOST(
"tag",
'alpha') && !$source) {
107 print $langs->trans(
'ErrorBadParameters').
" - tag or source";
110 if ($source && !
GETPOST(
"ref",
'alpha')) {
111 print $langs->trans(
'ErrorBadParameters').
" - ref";
116if ($source ==
'organizedeventregistration') {
123 $resultinvoice = $invoice->fetch($invoiceid);
125 if ($resultinvoice <= 0) {
138 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"eventorganization_conferenceorboothattendee";
139 $sql .=
" WHERE fk_invoice = ".((int) $invoiceid);
140 $resql = $db->query($sql);
142 $obj = $db->fetch_object($resql);
144 $attendeeid = $obj->rowid;
148 if ($attendeeid > 0) {
149 $resultattendee = $attendee->fetch($attendeeid);
151 if ($resultattendee <= 0) {
154 $attendee->fetch_projet();
156 $amount =
price2num($invoice->total_ttc);
158 $thirdparty =
new Societe($db);
159 $resultthirdparty = $thirdparty->fetch($invoice->socid);
160 if ($resultthirdparty <= 0) {
167} elseif ($source ==
'boothlocation') {
171 $resultinvoice = $invoice->fetch($invoiceid);
172 if ($resultinvoice <= 0) {
175 $amount =
price2num($invoice->total_ttc);
177 $thirdparty =
new Societe($db);
178 $resultthirdparty = $thirdparty->fetch($invoice->socid);
179 if ($resultthirdparty <= 0) {
187$paymentmethod =
GETPOST(
'paymentmethod',
'alphanohtml') ?
GETPOST(
'paymentmethod',
'alphanohtml') :
'';
188$validpaymentmethod = array();
191foreach ($_POST as $key => $val) {
193 if (preg_match(
'/^dopayment_(.*)$/', $key, $reg)) {
194 $paymentmethod = $reg[1];
203$urlwithroot = DOL_MAIN_URL_ROOT;
205$urlok = $urlwithroot.
'/public/payment/paymentok.php?';
206$urlko = $urlwithroot.
'/public/payment/paymentko.php?';
209$ref = $REF =
GETPOST(
'ref',
'alpha');
211$FULLTAG =
GETPOST(
"fulltag",
'alpha');
212$SECUREKEY =
GETPOST(
"securekey");
214if ($paymentmethod && !preg_match(
'/'.preg_quote(
'PM='.$paymentmethod,
'/').
'/', $FULLTAG)) {
215 $FULLTAG .= ($FULLTAG ?
'.' :
'').
'PM='.$paymentmethod;
219 $FULLTAG .= ($FULLTAG ?
'.' :
'').
'WS='.$ws;
222if (!empty($suffix)) {
223 $urlok .=
'suffix='.urlencode($suffix).
'&';
224 $urlko .=
'suffix='.urlencode($suffix).
'&';
227 $urlok .=
's='.urlencode($source).
'&';
228 $urlko .=
's='.urlencode($source).
'&';
231 $urlok .=
'ref='.urlencode($REF).
'&';
232 $urlko .=
'ref='.urlencode($REF).
'&';
235 $urlok .=
'tag='.urlencode($TAG).
'&';
236 $urlko .=
'tag='.urlencode($TAG).
'&';
238if (!empty($FULLTAG)) {
239 $urlok .=
'fulltag='.urlencode($FULLTAG).
'&';
240 $urlko .=
'fulltag='.urlencode($FULLTAG).
'&';
242if (!empty($SECUREKEY)) {
243 $urlok .=
'securekey='.urlencode($SECUREKEY).
'&';
244 $urlko .=
'securekey='.urlencode($SECUREKEY).
'&';
246if (!empty($entity)) {
247 $urlok .=
'e='.urlencode((
string) ($entity)).
'&';
248 $urlko .=
'e='.urlencode((
string) ($entity)).
'&';
250if (!empty($getpostlang)) {
251 $urlok .=
'lang='.urlencode($getpostlang).
'&';
252 $urlko .=
'lang='.urlencode($getpostlang).
'&';
254$urlok = preg_replace(
'/&$/',
'', $urlok);
255$urlko = preg_replace(
'/&$/',
'', $urlko);
260if ((empty($paymentmethod) || $paymentmethod ==
'paypal') && isModEnabled(
'paypal')) {
261 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypal.lib.php';
262 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypalfunctions.lib.php';
267 $PAYPAL_API_OK = $urlok;
271 $PAYPAL_API_KO = $urlko;
273 if (empty($PAYPAL_API_USER)) {
274 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>.';
277 if (empty($PAYPAL_API_PASSWORD)) {
278 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>.';
281 if (empty($PAYPAL_API_SIGNATURE)) {
282 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>.';
286if ((empty($paymentmethod) || $paymentmethod ==
'paybox') && isModEnabled(
'paybox')) {
289if ((empty($paymentmethod) || $paymentmethod ==
'stripe') && isModEnabled(
'stripe')) {
290 require_once DOL_DOCUMENT_ROOT.
'/stripe/config.php';
295$validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod);
299if ($tmpsource ==
'membersubscription') {
300 $tmpsource =
'member';
306 if ($tmpsource && $REF) {
310 if ($tmpsource != $source) {
314 $tokenisok =
dol_verifyHash($conf->global->PAYMENT_SECURITY_TOKEN, $SECUREKEY,
'2');
317 $tokenisok = ($conf->global->PAYMENT_SECURITY_TOKEN == $SECUREKEY);
324 dol_syslog(
"Warning: PAYMENT_SECURITY_ACCEPT_ANY_TOKEN is on", LOG_WARNING);
329 print
'<div class="error">Bad value for key.</div>';
335if (!empty($paymentmethod) && empty($validpaymentmethod[$paymentmethod])) {
336 print
'Payment module for payment method '.$paymentmethod.
' is not active';
339if (empty($validpaymentmethod)) {
340 print
'No active payment module (Paypal, Stripe, Paybox, ...)';
345$creditor = $mysoc->name;
346$paramcreditor =
'ONLINE_PAYMENT_CREDITOR';
347$paramcreditorlong =
'ONLINE_PAYMENT_CREDITOR_'.$suffix;
348if (!empty($conf->global->$paramcreditorlong)) {
350} elseif (!empty($conf->global->$paramcreditor)) {
362dol_syslog(
"--- newpayment.php action = ".$action.
" paymentmethod=".$paymentmethod.
' amount='.$amount.
' newamount='.
GETPOST(
"newamount",
'alpha'), LOG_DEBUG, 0,
'_payment');
365if ($action ==
'dopayment') {
366 if ($paymentmethod ==
'paypal') {
368 $PAYPAL_PAYMENT_TYPE =
'Sale';
371 $origfulltag =
GETPOST(
"fulltag",
'alpha');
372 $shipToName =
GETPOST(
"shipToName",
'alpha');
373 $shipToStreet =
GETPOST(
"shipToStreet",
'alpha');
374 $shipToCity =
GETPOST(
"shipToCity",
'alpha');
375 $shipToState =
GETPOST(
"shipToState",
'alpha');
376 $shipToCountryCode =
GETPOST(
"shipToCountryCode",
'alpha');
377 $shipToZip =
GETPOST(
"shipToZip",
'alpha');
378 $shipToStreet2 =
GETPOST(
"shipToStreet2",
'alpha');
379 $phoneNum =
GETPOST(
"phoneNum",
'alpha');
380 $email =
GETPOST(
"email",
'alpha');
381 $desc =
GETPOST(
"desc",
'alpha');
385 if ($shipToCountryCode ==
'ID' && !preg_match(
'/\-/', $shipToState)) {
386 $shipToState =
'ID-'.$shipToState;
389 if (empty($PAYPAL_API_PRICE) || !is_numeric($PAYPAL_API_PRICE)) {
390 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount"));
394 } elseif (!$origfulltag) {
395 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"PaymentCode"));
400 dol_syslog(
"newpayment.php call paypal api and do redirect", LOG_DEBUG);
403 $PAYPAL_API_DEVISE =
"USD";
404 if (!empty($currency)) {
405 $PAYPAL_API_DEVISE = $currency;
410 dol_syslog(
"PAYPAL_API_USER: $PAYPAL_API_USER", LOG_DEBUG);
411 dol_syslog(
"PAYPAL_API_PASSWORD: ".preg_replace(
'/./',
'*', $PAYPAL_API_PASSWORD), LOG_DEBUG);
412 dol_syslog(
"PAYPAL_API_SIGNATURE: $PAYPAL_API_SIGNATURE", LOG_DEBUG);
413 dol_syslog(
"PAYPAL_API_SANDBOX: $PAYPAL_API_SANDBOX", LOG_DEBUG);
414 dol_syslog(
"PAYPAL_API_OK: $PAYPAL_API_OK", LOG_DEBUG);
415 dol_syslog(
"PAYPAL_API_KO: $PAYPAL_API_KO", LOG_DEBUG);
416 dol_syslog(
"PAYPAL_API_PRICE: $PAYPAL_API_PRICE", LOG_DEBUG);
417 dol_syslog(
"PAYPAL_API_DEVISE: $PAYPAL_API_DEVISE", LOG_DEBUG);
419 dol_syslog(
"shipToName: $shipToName", LOG_DEBUG);
420 dol_syslog(
"shipToStreet: $shipToStreet", LOG_DEBUG);
421 dol_syslog(
"shipToCity: $shipToCity", LOG_DEBUG);
422 dol_syslog(
"shipToState: $shipToState", LOG_DEBUG);
423 dol_syslog(
"shipToCountryCode: $shipToCountryCode", LOG_DEBUG);
424 dol_syslog(
"shipToZip: $shipToZip", LOG_DEBUG);
425 dol_syslog(
"shipToStreet2: $shipToStreet2", LOG_DEBUG);
430 dol_syslog(
"SCRIPT_URI: ".(empty($_SERVER[
"SCRIPT_URI"]) ?
'' : $_SERVER[
"SCRIPT_URI"]), LOG_DEBUG);
433 $mesg =
print_paypal_redirect($PAYPAL_API_PRICE, $PAYPAL_API_DEVISE, $PAYPAL_PAYMENT_TYPE, $PAYPAL_API_OK, $PAYPAL_API_KO, $FULLTAG);
440 if ($paymentmethod ==
'paybox') {
445 $origfulltag =
GETPOST(
"fulltag",
'alpha');
448 $urlok = preg_replace(
'/securekey=[^&]+&?/',
'', $urlok);
449 $urlko = preg_replace(
'/securekey=[^&]+&?/',
'', $urlko);
451 if (empty($PRICE) || !is_numeric($PRICE)) {
452 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount"));
453 } elseif (empty($email)) {
454 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ONLINE_PAYMENT_SENDEMAIL"));
456 $mesg = $langs->trans(
"ErrorBadEMail", $email);
457 } elseif (!$origfulltag) {
458 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"PaymentCode"));
460 $mesg =
'Error urlok too long '.$urlok.
' (Paybox requires 150, found '.strlen($urlok).
')';
462 $mesg =
'Error urlko too long '.$urlko.
' (Paybox requires 150, found '.strlen($urlok).
')';
466 dol_syslog(
"newpayment.php call paybox api and do redirect", LOG_DEBUG);
468 include_once DOL_DOCUMENT_ROOT.
'/paybox/lib/paybox.lib.php';
476 if ($paymentmethod ==
'stripe') {
477 if (
GETPOST(
'newamount',
'alpha')) {
480 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount")),
null,
'errors');
490if ($action ==
'charge' && isModEnabled(
'stripe')) {
491 $amountstripe = $amount;
495 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
496 if (!in_array($currency, $arrayzerounitcurrency)) {
497 $amountstripe = $amountstripe * 100;
500 dol_syslog(
"--- newpayment.php Execute action = ".$action.
" STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION=".
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION'), LOG_DEBUG, 0,
'_payment');
501 dol_syslog(
"GET=".var_export($_GET,
true), LOG_DEBUG, 0,
'_payment');
502 dol_syslog(
"POST=".var_export($_POST,
true), LOG_DEBUG, 0,
'_payment');
504 $stripeToken =
GETPOST(
"stripeToken",
'alpha');
505 $email =
GETPOST(
"email",
'alpha');
509 $vatnumber =
GETPOST(
'vatnumber',
'alpha');
510 $savesource = GETPOSTISSET(
'savesource') ?
GETPOSTINT(
'savesource') : 1;
512 dol_syslog(
"POST stripeToken = ".$stripeToken, LOG_DEBUG, 0,
'_payment');
513 dol_syslog(
"POST email = ".$email, LOG_DEBUG, 0,
'_payment');
514 dol_syslog(
"POST thirdparty_id = ".$thirdparty_id, LOG_DEBUG, 0,
'_payment');
515 dol_syslog(
"POST vatnumber = ".$vatnumber, LOG_DEBUG, 0,
'_payment');
521 if (!
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION')) {
524 'dol_version' => DOL_VERSION,
525 'dol_entity' => $conf->entity,
526 'dol_company' => $mysoc->name,
527 'dol_tax_num' => $vatnumber,
531 if (!empty($thirdparty_id)) {
532 $metadata[
"dol_thirdparty_id"] = $thirdparty_id;
535 if ($thirdparty_id > 0) {
536 dol_syslog(
"Search existing Stripe customer profile for thirdparty_id=".$thirdparty_id, LOG_DEBUG, 0,
'_payment');
538 $service =
'StripeTest';
541 $service =
'StripeLive';
545 $thirdparty =
new Societe($db);
546 $thirdparty->fetch($thirdparty_id);
549 include_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
550 $stripe =
new Stripe($db);
551 $stripeacc = $stripe->getStripeAccount($service);
552 $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 1);
553 if (empty($customer)) {
555 dol_syslog(
'Failed to get/create stripe customer for thirdparty id = '.$thirdparty_id.
' and servicestatus = '.$servicestatus.
': '.$stripe->error, LOG_ERR, 0,
'_payment');
556 setEventMessages(
'Failed to get/create stripe customer for thirdparty id = '.$thirdparty_id.
' and servicestatus = '.$servicestatus.
': '.$stripe->error,
null,
'errors');
563 $card = $customer->sources->create(array(
"source" => $stripeToken,
"metadata" => $metadata));
565 $card = $stripeToken;
570 dol_syslog(
'Failed to create card record', LOG_WARNING, 0,
'_payment');
574 if (!empty($FULLTAG)) {
575 $metadata[
"FULLTAG"] = $FULLTAG;
577 if (!empty($dol_id)) {
578 $metadata[
"dol_id"] = $dol_id;
580 if (!empty($dol_type)) {
581 $metadata[
"dol_type"] = $dol_type;
584 dol_syslog(
"Create charge on card ".$card->id, LOG_DEBUG, 0,
'_payment');
585 $charge = \Stripe\Charge::create(array(
586 'amount' =>
price2num($amountstripe,
'MU'),
587 'currency' => $currency,
589 'description' =>
'Stripe payment: '.$FULLTAG.
' ref='.$ref,
590 'metadata' => $metadata,
591 'customer' => $customer->id,
593 'statement_descriptor_suffix' =>
dol_trunc($FULLTAG, 10,
'right',
'UTF-8', 1),
594 ), array(
"idempotency_key" =>
"$FULLTAG",
"stripe_account" =>
"$stripeacc"));
596 if (empty($charge)) {
598 dol_syslog(
'Failed to charge card', LOG_WARNING, 0,
'_payment');
605 $vatcleaned = $vatnumber ? $vatnumber :
null;
616 dol_syslog(
"Create anonymous customer card profile", LOG_DEBUG, 0,
'_payment');
618 $customer = \Stripe\Customer::create(array(
620 'description' => ($email ?
'Anonymous customer for '.$email :
'Anonymous customer'),
621 'metadata' => $metadata,
622 'source' => $stripeToken
641 if (!empty($FULLTAG)) {
642 $metadata[
"FULLTAG"] = $FULLTAG;
644 if (!empty($dol_id)) {
645 $metadata[
"dol_id"] = $dol_id;
647 if (!empty($dol_type)) {
648 $metadata[
"dol_type"] = $dol_type;
653 dol_syslog(
"Create charge", LOG_DEBUG, 0,
'_payment');
654 $charge = \Stripe\Charge::create(array(
655 'customer' => $customer->id,
656 'amount' =>
price2num($amountstripe,
'MU'),
657 'currency' => $currency,
659 'description' =>
'Stripe payment: '.$FULLTAG.
' ref='.$ref,
660 'metadata' => $metadata,
661 'statement_descriptor' =>
dol_trunc($FULLTAG, 10,
'right',
'UTF-8', 1),
662 ), array(
"idempotency_key" =>
"$FULLTAG",
"stripe_account" =>
"$stripeacc"));
664 if (empty($charge)) {
666 dol_syslog(
'Failed to charge card', LOG_WARNING, 0,
'_payment');
673 $body = $e->getJsonBody();
674 $err = $body[
'error'];
676 print(
'Status is:'.$e->getHttpStatus().
"\n");
677 print(
'Type is:'.$err[
'type'].
"\n");
678 print(
'Code is:'.$err[
'code'].
"\n");
680 print(
'Param is:'.$err[
'param'].
"\n");
681 print(
'Message is:'.$err[
'message'].
"\n");
684 $errormessage =
"ErrorCard ".$e->getMessage().
" err=".var_export($err,
true);
685 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
691 $errormessage =
"ErrorRateLimit ".$e->getMessage();
692 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
698 $errormessage =
"ErrorInvalidRequest ".$e->getMessage();
699 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
706 $errormessage =
"ErrorAuthentication ".$e->getMessage();
707 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
713 $errormessage =
"ErrorApiConnection ".$e->getMessage();
714 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
721 $errormessage =
"ErrorBase ".$e->getMessage();
722 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
728 $errormessage =
"ErrorException ".$e->getMessage();
729 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
736 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION')) {
737 $service =
'StripeTest';
740 $service =
'StripeLive';
743 include_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
744 $stripe =
new Stripe($db);
745 $stripeacc = $stripe->getStripeAccount($service);
749 $paymentintent_id =
GETPOST(
"paymentintent_id",
"alpha");
752 global $stripearrayofkeysbyenv;
753 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
756 if (empty($stripeacc)) {
757 $paymentintent = \Stripe\PaymentIntent::retrieve($paymentintent_id);
759 $paymentintent = \Stripe\PaymentIntent::retrieve($paymentintent_id, array(
"stripe_account" => $stripeacc));
763 $errormessage =
"CantRetrievePaymentIntent ".$e->getMessage();
764 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
769 if ($paymentintent->status !=
'succeeded') {
771 $errormessage =
"StatusOfRetrievedIntent is not succeeded: ".$paymentintent->status;
772 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
782 if (!empty($paymentintent->currency) && !empty($paymentintent->amount)) {
783 $currency = strtoupper($paymentintent->currency);
784 $amount = $paymentintent->amount;
788 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
789 if (!in_array($currency, $arrayzerounitcurrency)) {
790 $amount = $amount / 100;
799 $_SESSION[
"onlinetoken"] = $stripeToken;
800 $_SESSION[
"FinalPaymentAmt"] = $amount;
801 $_SESSION[
"currencyCodeType"] = $currency;
802 $_SESSION[
"paymentType"] =
'';
803 $_SESSION[
'ipaddress'] = ($remoteip ? $remoteip :
'unknown');
804 $_SESSION[
'payerID'] = is_object($customer) ? $customer->id :
'';
805 $_SESSION[
'TRANSACTIONID'] = (is_object($charge) ? $charge->id : (is_object($paymentintent) ? $paymentintent->id :
''));
806 $_SESSION[
'errormessage'] = $errormessage;
808 dol_syslog(
"Action charge stripe STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION=".
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION').
" ip=".$remoteip, LOG_DEBUG, 0,
'_payment');
809 dol_syslog(
"onlinetoken=".$_SESSION[
"onlinetoken"].
" FinalPaymentAmt=".$_SESSION[
"FinalPaymentAmt"].
" currencyCodeType=".$_SESSION[
"currencyCodeType"].
" payerID=".$_SESSION[
'payerID'].
" TRANSACTIONID=".$_SESSION[
'TRANSACTIONID'], LOG_DEBUG, 0,
'_payment');
810 dol_syslog(
"FULLTAG=".$FULLTAG, LOG_DEBUG, 0,
'_payment');
811 dol_syslog(
"error=".$error.
" errormessage=".$errormessage, LOG_DEBUG, 0,
'_payment');
812 dol_syslog(
"_SERVER[SERVER_NAME] = ".(empty($_SERVER[
"SERVER_NAME"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_NAME"])), LOG_DEBUG, 0,
'_payment');
813 dol_syslog(
"_SERVER[SERVER_ADDR] = ".(empty($_SERVER[
"SERVER_ADDR"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_ADDR"])), LOG_DEBUG, 0,
'_payment');
814 dol_syslog(
"Now call the redirect to paymentok or paymentko, URL = ".($error ? $urlko : $urlok), LOG_DEBUG, 0,
'_payment');
817 header(
"Location: ".$urlko);
820 header(
"Location: ".$urlok);
827 'paymentmethod' => $paymentmethod,
828 'validpaymentmethod' => &$validpaymentmethod
830$reshook = $hookmanager->executeHooks(
'doPayment', $parameters,
$object, $action);
833} elseif ($reshook > 0) {
834 print $hookmanager->resPrint;
843$form =
new Form($db);
847 $head =
'<link rel="stylesheet" type="text/css" href="' .
getDolGlobalString(
'ONLINE_PAYMENT_CSS_URL').
'?lang='.(!empty($getpostlang) ? $getpostlang : $langs->defaultlang).
'">'.
"\n";
850$conf->dol_hide_topmenu = 1;
851$conf->dol_hide_leftmenu = 1;
853$replacemainarea = (empty($conf->dol_hide_leftmenu) ?
'<div>' :
'').
'<div>';
854llxHeader($head, $langs->trans(
"PaymentForm"),
'',
'', 0, 0,
'',
'',
'',
'onlinepaymentbody', $replacemainarea);
856dol_syslog(
"newpayment.php show page source=".$source.
" paymentmethod=".$paymentmethod.
' amount='.$amount.
' newamount='.
GETPOST(
"newamount",
'alpha').
" ref=".$ref, LOG_DEBUG, 0,
'_payment');
857dol_syslog(
"_SERVER[SERVER_NAME] = ".(empty($_SERVER[
"SERVER_NAME"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_NAME"])), LOG_DEBUG, 0,
'_payment');
858dol_syslog(
"_SERVER[SERVER_ADDR] = ".(empty($_SERVER[
"SERVER_ADDR"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_ADDR"])), LOG_DEBUG, 0,
'_payment');
861if ($source && in_array($ref, array(
'member_ref',
'contractline_ref',
'invoice_ref',
'order_ref',
'donation_ref',
''))) {
862 $langs->load(
"errors");
863 dol_print_error_email(
'BADREFINPAYMENTFORM', $langs->trans(
"ErrorBadLinkSourceSetButBadValueForRef", $source, $ref));
872if ((empty($paymentmethod) || $paymentmethod ==
'paypal') && isModEnabled(
'paypal') && (
getDolGlobalString(
'PAYPAL_API_SANDBOX') ||
GETPOSTINT(
'forcesandbox'))) {
873 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Paypal'),
'',
'warning');
875if ((empty($paymentmethod) || $paymentmethod ==
'stripe') && isModEnabled(
'stripe') && (!
getDolGlobalString(
'STRIPE_LIVE') ||
GETPOSTINT(
'forcesandbox'))) {
876 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Stripe'),
'',
'warning');
880print
'<span id="dolpaymentspan"></span>'.
"\n";
881print
'<div class="center">'.
"\n";
882print
'<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
883print
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
884print
'<input type="hidden" name="action" value="dopayment">'.
"\n";
885print
'<input type="hidden" name="tag" value="'.GETPOST(
"tag",
'alpha').
'">'.
"\n";
886print
'<input type="hidden" name="suffix" value="'.dol_escape_htmltag($suffix).
'">'.
"\n";
887print
'<input type="hidden" name="securekey" value="'.dol_escape_htmltag($SECUREKEY).
'">'.
"\n";
888print
'<input type="hidden" name="e" value="'.$entity.
'" />';
889print
'<input type="hidden" name="forcesandbox" value="'.GETPOSTINT(
'forcesandbox').
'" />';
890print
'<input type="hidden" name="lang" value="'.$getpostlang.
'">';
891print
'<input type="hidden" name="ws" value="'.$ws.
'">';
897$logosmall = $mysoc->logo_small;
899$paramlogo =
'ONLINE_PAYMENT_LOGO_'.$suffix;
900if (!empty($conf->global->$paramlogo)) {
909if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.
'/logos/thumbs/'.$logosmall)) {
910 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
911 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
912} elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.
'/logos/'.$logo)) {
913 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
914 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
918if ($urllogo && !$ws) {
919 print
'<div class="backgreypublicpayment">';
920 print
'<div class="logopublicpayment">';
921 print
'<img id="dolpaymentlogo" src="'.$urllogo.
'"';
925 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>';
928} elseif ($creditor && !$ws) {
929 print
'<div class="backgreypublicpayment">';
930 print
'<div class="logopublicpayment">';
936 print
'<div class="backimagepublicpayment">';
937 print
'<img id="idMAIN_IMAGE_PUBLIC_PAYMENT" src="'.getDolGlobalString(
'MAIN_IMAGE_PUBLIC_PAYMENT').
'">';
944print
'<!-- Form to send a payment -->'.
"\n";
945print
'<!-- creditor = '.dol_escape_htmltag($creditor).
' -->'.
"\n";
947if (isModEnabled(
'paypal')) {
948 print
'<!-- PAYPAL_API_SANDBOX = '.getDolGlobalString(
'PAYPAL_API_SANDBOX').
' -->'.
"\n";
949 print
'<!-- PAYPAL_API_INTEGRAL_OR_PAYPALONLY = '.getDolGlobalString(
'PAYPAL_API_INTEGRAL_OR_PAYPALONLY').
' -->'.
"\n";
951if (isModEnabled(
'paybox')) {
952 print
'<!-- PAYBOX_CGI_URL = '.getDolGlobalString(
'PAYBOX_CGI_URL_V2').
' -->'.
"\n";
954if (isModEnabled(
'stripe')) {
955 print
'<!-- STRIPE_LIVE = '.getDolGlobalString(
'STRIPE_LIVE').
' -->'.
"\n";
957print
'<!-- urlok = '.$urlok.
' -->'.
"\n";
958print
'<!-- urlko = '.$urlko.
' -->'.
"\n";
962print
'<table id="dolpublictable" summary="Payment form" class="center">'.
"\n";
967 $langs->load(
"members");
968 if (preg_match(
'/^\((.*)\)$/', $conf->global->PAYMENT_NEWFORM_TEXT, $reg)) {
969 $text .= $langs->trans($reg[1]).
"<br>\n";
973 $text =
'<tr><td align="center"><br>'.$text.
'<br></td></tr>'.
"\n";
976 $text .=
'<tr><td class="textpublicpayment"><br><strong>'.$langs->trans(
"WelcomeOnPaymentPage").
'</strong></td></tr>'.
"\n";
977 $text .=
'<tr><td class="textpublicpayment"><span class="opacitymedium">'.$langs->trans(
"ThisScreenAllowsYouToPay", $creditor).
'</span><br><br></td></tr>'.
"\n";
982print
'<tr><td align="center">';
983print
'<table class="centpercent left" id="tablepublicpayment">';
984print
'<tr class="hideonsmartphone"><td colspan="2" align="left" class="opacitymedium">'.$langs->trans(
"ThisIsInformationOnPayment").
' :</td></tr>'.
"\n";
995 $tag =
GETPOST(
"tag",
'alpha');
996 if (
GETPOST(
'fulltag',
'alpha')) {
997 $fulltag =
GETPOST(
'fulltag',
'alpha');
999 $fulltag =
"TAG=".$tag;
1003 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
1004 print
'</td><td class="CTableRow2">';
1005 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1006 print
'<b>'.$creditor.
'</b>';
1007 print
'<input type="hidden" name="creditor" value="'.$creditor.
'">';
1008 print
'</td></tr>'.
"\n";
1011 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Amount");
1012 if (empty($amount)) {
1013 print
' ('.$langs->trans(
"ToComplete").
')';
1015 print
'</td><td class="CTableRow2">';
1016 if (empty($amount) || !is_numeric($amount)) {
1017 print
'<input type="hidden" name="amount" value="'.price2num(
GETPOST(
"amount",
'alpha'),
'MT').
'">';
1018 print
'<input class="flat maxwidth75" type="text" name="newamount" value="'.price2num(
GETPOST(
"newamount",
"alpha"),
'MT').
'">';
1020 print
' <b>'.$langs->trans(
"Currency".$currency).
'</b>';
1022 print
'<b class="amount">'.price($amount, 1, $langs, 1, -1, -1, $currency).
'</b>';
1023 print
'<input type="hidden" name="amount" value="'.$amount.
'">';
1024 print
'<input type="hidden" name="newamount" value="'.$amount.
'">';
1026 print
'<input type="hidden" name="currency" value="'.$currency.
'">';
1027 print
'</td></tr>'.
"\n";
1030 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentCode");
1031 print
'</td><td class="CTableRow2"><b style="word-break: break-all;">'.$fulltag.
'</b>';
1032 print
'<input type="hidden" name="tag" value="'.$tag.
'">';
1033 print
'<input type="hidden" name="fulltag" value="'.$fulltag.
'">';
1034 print
'</td></tr>'.
"\n";
1042if ($source ==
'order') {
1044 $langs->load(
"orders");
1046 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
1049 $result = $order->fetch(
'', $ref);
1051 $mesg = $order->error;
1054 $result = $order->fetch_thirdparty($order->socid);
1058 if ($action !=
'dopayment') {
1059 $amount = $order->total_ttc;
1060 if (
GETPOST(
"amount",
'alpha')) {
1061 $amount =
GETPOST(
"amount",
'alpha');
1067 if (
GETPOST(
'fulltag',
'alpha')) {
1068 $fulltag =
GETPOST(
'fulltag',
'alpha');
1070 $fulltag =
'ORD='.$order->id.
'.CUS='.$order->thirdparty->id;
1073 $fulltag .=
'.TAG='.$TAG;
1079 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
1080 print
'</td><td class="CTableRow2">';
1081 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1082 print
'<b>'.$creditor.
'</b>';
1083 print
'<input type="hidden" name="creditor" value="'.$creditor.
'">';
1084 print
'</td></tr>'.
"\n";
1087 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"ThirdParty");
1088 print
'</td><td class="CTableRow2">';
1089 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1090 print
'<b>'.$order->thirdparty->name.
'</b>';
1091 print
'</td></tr>'.
"\n";
1094 $text =
'<b>'.$langs->trans(
"PaymentOrderRef", $order->ref).
'</b>';
1095 if (
GETPOST(
'desc',
'alpha')) {
1096 $text =
'<b>'.$langs->trans(
GETPOST(
'desc',
'alpha')).
'</b>';
1098 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Designation");
1099 print
'</td><td class="CTableRow2">'.$text;
1100 print
'<input type="hidden" name="s" value="'.dol_escape_htmltag($source).
'">';
1101 print
'<input type="hidden" name="ref" value="'.dol_escape_htmltag($order->ref).
'">';
1102 print
'<input type="hidden" name="dol_id" value="'.dol_escape_htmltag($order->id).
'">';
1103 $directdownloadlink = $order->getLastMainDocLink(
'commande');
1104 if ($directdownloadlink) {
1105 print
'<br><a href="'.$directdownloadlink.
'" rel="nofollow noopener">';
1106 print
img_mime($order->last_main_doc,
'');
1107 print $langs->trans(
"DownloadDocument").
'</a>';
1109 print
'</td></tr>'.
"\n";
1112 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Amount");
1113 if (empty($amount)) {
1114 print
' ('.$langs->trans(
"ToComplete").
')';
1116 print
'</td><td class="CTableRow2">';
1117 if (empty($amount) || !is_numeric($amount)) {
1118 print
'<input type="hidden" name="amount" value="'.price2num(
GETPOST(
"amount",
'alpha'),
'MT').
'">';
1119 print
'<input class="flat maxwidth75" type="text" name="newamount" value="'.price2num(
GETPOST(
"newamount",
"alpha"),
'MT').
'">';
1121 print
' <b>'.$langs->trans(
"Currency".$currency).
'</b>';
1123 print
'<b class="amount">'.price($amount, 1, $langs, 1, -1, -1, $currency).
'</b>';
1124 print
'<input type="hidden" name="amount" value="'.$amount.
'">';
1125 print
'<input type="hidden" name="newamount" value="'.$amount.
'">';
1127 print
'<input type="hidden" name="currency" value="'.$currency.
'">';
1128 print
'</td></tr>'.
"\n";
1131 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentCode");
1132 print
'</td><td class="CTableRow2"><b style="word-break: break-all;">'.$fulltag.
'</b>';
1133 print
'<input type="hidden" name="tag" value="'.dol_escape_htmltag($tag).
'">';
1134 print
'<input type="hidden" name="fulltag" value="'.dol_escape_htmltag($fulltag).
'">';
1135 print
'</td></tr>'.
"\n";
1138 $shipToName = $order->thirdparty->name;
1139 $shipToStreet = $order->thirdparty->address;
1140 $shipToCity = $order->thirdparty->town;
1141 $shipToState = $order->thirdparty->state_code;
1142 $shipToCountryCode = $order->thirdparty->country_code;
1143 $shipToZip = $order->thirdparty->zip;
1144 $shipToStreet2 =
'';
1145 $phoneNum = $order->thirdparty->phone;
1146 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1147 print
'<input type="hidden" name="shipToName" value="'.dol_escape_htmltag($shipToName).
'">'.
"\n";
1148 print
'<input type="hidden" name="shipToStreet" value="'.dol_escape_htmltag($shipToStreet).
'">'.
"\n";
1149 print
'<input type="hidden" name="shipToCity" value="'.dol_escape_htmltag($shipToCity).
'">'.
"\n";
1150 print
'<input type="hidden" name="shipToState" value="'.dol_escape_htmltag($shipToState).
'">'.
"\n";
1151 print
'<input type="hidden" name="shipToCountryCode" value="'.dol_escape_htmltag($shipToCountryCode).
'">'.
"\n";
1152 print
'<input type="hidden" name="shipToZip" value="'.dol_escape_htmltag($shipToZip).
'">'.
"\n";
1153 print
'<input type="hidden" name="shipToStreet2" value="'.dol_escape_htmltag($shipToStreet2).
'">'.
"\n";
1154 print
'<input type="hidden" name="phoneNum" value="'.dol_escape_htmltag($phoneNum).
'">'.
"\n";
1156 print
'<!-- Shipping address not complete, so we don t use it -->'.
"\n";
1158 if (is_object($order->thirdparty)) {
1159 print
'<input type="hidden" name="thirdparty_id" value="'.$order->thirdparty->id.
'">'.
"\n";
1161 print
'<input type="hidden" name="email" value="'.$order->thirdparty->email.
'">'.
"\n";
1162 print
'<input type="hidden" name="vatnumber" value="'.dol_escape_htmltag($order->thirdparty->tva_intra).
'">'.
"\n";
1163 $labeldesc = $langs->trans(
"Order").
' '.$order->ref;
1164 if (
GETPOST(
'desc',
'alpha')) {
1165 $labeldesc =
GETPOST(
'desc',
'alpha');
1167 print
'<input type="hidden" name="desc" value="'.dol_escape_htmltag($labeldesc).
'">'.
"\n";
1172if ($source ==
'invoice') {
1174 $langs->load(
"bills");
1175 $form->load_cache_types_paiements();
1177 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1180 $result = $invoice->fetch(
'', $ref);
1182 $mesg = $invoice->error;
1185 $result = $invoice->fetch_thirdparty($invoice->socid);
1189 if ($action !=
'dopayment') {
1190 $amount =
price2num($invoice->total_ttc - ($invoice->getSommePaiement() + $invoice->getSumCreditNotesUsed() + $invoice->getSumDepositsUsed()));
1191 if (
GETPOST(
"amount",
'alpha')) {
1192 $amount =
GETPOST(
"amount",
'alpha');
1197 if (
GETPOST(
'fulltag',
'alpha')) {
1198 $fulltag =
GETPOST(
'fulltag',
'alpha');
1200 $fulltag =
'INV='.$invoice->id.
'.CUS='.$invoice->thirdparty->id;
1203 $fulltag .=
'.TAG='.$TAG;
1209 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
1210 print
'</td><td class="CTableRow2">';
1211 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1212 print
'<b>'.$creditor.
'</b>';
1213 print
'<input type="hidden" name="creditor" value="'.dol_escape_htmltag($creditor).
'">';
1214 print
'</td></tr>'.
"\n";
1217 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"ThirdParty");
1218 print
'</td><td class="CTableRow2">';
1219 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1220 print
'<b>'.$invoice->thirdparty->name.
'</b>';
1221 print
'</td></tr>'.
"\n";
1224 $text =
'<b>'.$langs->trans(
"PaymentInvoiceRef", $invoice->ref).
'</b>';
1225 if (
GETPOST(
'desc',
'alpha')) {
1226 $text =
'<b>'.$langs->trans(
GETPOST(
'desc',
'alpha')).
'</b>';
1228 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Designation");
1229 print
'</td><td class="CTableRow2">'.$text;
1230 print
'<input type="hidden" name="s" value="'.dol_escape_htmltag($source).
'">';
1231 print
'<input type="hidden" name="ref" value="'.dol_escape_htmltag($invoice->ref).
'">';
1232 print
'<input type="hidden" name="dol_id" value="'.dol_escape_htmltag($invoice->id).
'">';
1233 $directdownloadlink = $invoice->getLastMainDocLink(
'facture');
1234 if ($directdownloadlink) {
1235 print
'<br><a href="'.$directdownloadlink.
'">';
1236 print
img_mime($invoice->last_main_doc,
'');
1237 print $langs->trans(
"DownloadDocument").
'</a>';
1239 print
'</td></tr>'.
"\n";
1242 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentAmount");
1243 if (empty($amount) && empty(
$object->paye)) {
1244 print
' ('.$langs->trans(
"ToComplete").
')';
1246 print
'</td><td class="CTableRow2">';
1247 if (
$object->type == $object::TYPE_CREDIT_NOTE) {
1248 print
'<b>'.$langs->trans(
"CreditNote").
'</b>';
1249 } elseif (empty(
$object->paye)) {
1250 if (empty($amount) || !is_numeric($amount)) {
1251 print
'<input type="hidden" name="amount" value="'.price2num(
GETPOST(
"amount",
'alpha'),
'MT').
'">';
1252 print
'<input class="flat maxwidth75" type="text" name="newamount" value="'.price2num(
GETPOST(
"newamount",
"alpha"),
'MT').
'">';
1253 print
' <b>'.$langs->trans(
"Currency".$currency).
'</b>';
1255 print
'<b class="amount">'.price($amount, 1, $langs, 1, -1, -1, $currency).
'</b>';
1256 print
'<input type="hidden" name="amount" value="'.$amount.
'">';
1257 print
'<input type="hidden" name="newamount" value="'.$amount.
'">';
1260 print
'<b class="amount">'.price(
$object->total_ttc, 1, $langs, 1, -1, -1, $currency).
'</b>';
1262 print
'<input type="hidden" name="currency" value="'.$currency.
'">';
1263 print
'</td></tr>'.
"\n";
1266 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentCode");
1267 print
'</td><td class="CTableRow2"><b style="word-break: break-all;">'.$fulltag.
'</b>';
1268 print
'<input type="hidden" name="tag" value="'.(empty($tag) ?
'' : $tag).
'">';
1269 print
'<input type="hidden" name="fulltag" value="'.$fulltag.
'">';
1270 print
'</td></tr>'.
"\n";
1273 if ($invoice->status == $invoice::STATUS_VALIDATED && $invoice->mode_reglement_id > 0 && $form->cache_types_paiements[$invoice->mode_reglement_id][
"code"] ==
"VIR") {
1274 print
'<tr class="CTableRow2 center"><td class="CTableRow2" colspan="2">';
1275 print
'<div class="warning maxwidth1000">';
1276 print $langs->trans(
"PayOfBankTransferInvoice");
1278 print
'</td></tr>'.
"\n";
1282 $shipToName = $invoice->thirdparty->name;
1283 $shipToStreet = $invoice->thirdparty->address;
1284 $shipToCity = $invoice->thirdparty->town;
1285 $shipToState = $invoice->thirdparty->state_code;
1286 $shipToCountryCode = $invoice->thirdparty->country_code;
1287 $shipToZip = $invoice->thirdparty->zip;
1288 $shipToStreet2 =
'';
1289 $phoneNum = $invoice->thirdparty->phone;
1290 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1291 print
'<input type="hidden" name="shipToName" value="'.$shipToName.
'">'.
"\n";
1292 print
'<input type="hidden" name="shipToStreet" value="'.$shipToStreet.
'">'.
"\n";
1293 print
'<input type="hidden" name="shipToCity" value="'.$shipToCity.
'">'.
"\n";
1294 print
'<input type="hidden" name="shipToState" value="'.$shipToState.
'">'.
"\n";
1295 print
'<input type="hidden" name="shipToCountryCode" value="'.$shipToCountryCode.
'">'.
"\n";
1296 print
'<input type="hidden" name="shipToZip" value="'.$shipToZip.
'">'.
"\n";
1297 print
'<input type="hidden" name="shipToStreet2" value="'.$shipToStreet2.
'">'.
"\n";
1298 print
'<input type="hidden" name="phoneNum" value="'.$phoneNum.
'">'.
"\n";
1300 print
'<!-- Shipping address not complete, so we don t use it -->'.
"\n";
1302 if (is_object($invoice->thirdparty)) {
1303 print
'<input type="hidden" name="thirdparty_id" value="'.$invoice->thirdparty->id.
'">'.
"\n";
1305 print
'<input type="hidden" name="email" value="'.$invoice->thirdparty->email.
'">'.
"\n";
1306 print
'<input type="hidden" name="vatnumber" value="'.$invoice->thirdparty->tva_intra.
'">'.
"\n";
1307 $labeldesc = $langs->trans(
"Invoice").
' '.$invoice->ref;
1308 if (
GETPOST(
'desc',
'alpha')) {
1309 $labeldesc =
GETPOST(
'desc',
'alpha');
1311 print
'<input type="hidden" name="desc" value="'.dol_escape_htmltag($labeldesc).
'">'.
"\n";
1315if ($source ==
'contractline') {
1317 $langs->load(
"contracts");
1319 require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
1324 $result = $contractline->fetch(
'', $ref);
1326 $mesg = $contractline->error;
1329 if ($contractline->fk_contrat > 0) {
1330 $result = $contract->fetch($contractline->fk_contrat);
1332 $result = $contract->fetch_thirdparty($contract->socid);
1334 $mesg = $contract->error;
1338 $mesg =
'ErrorRecordNotFound';
1344 if ($action !=
'dopayment') {
1345 $amount = $contractline->total_ttc;
1347 if ($contractline->fk_product &&
getDolGlobalString(
'PAYMENT_USE_NEW_PRICE_FOR_CONTRACTLINES')) {
1349 $result = $product->fetch($contractline->fk_product);
1353 $pu_ht = $product->multiprices[$contract->thirdparty->price_level];
1354 $pu_ttc = $product->multiprices_ttc[$contract->thirdparty->price_level];
1355 $price_base_type = $product->multiprices_base_type[$contract->thirdparty->price_level];
1357 $pu_ht = $product->price;
1358 $pu_ttc = $product->price_ttc;
1359 $price_base_type = $product->price_base_type;
1363 if (empty($amount)) {
1369 if (
GETPOST(
"amount",
'alpha')) {
1370 $amount =
GETPOST(
"amount",
'alpha');
1375 if (
GETPOST(
'fulltag',
'alpha')) {
1376 $fulltag =
GETPOST(
'fulltag',
'alpha');
1378 $fulltag =
'COL='.$contractline->id.
'.CON='.$contract->id.
'.CUS='.$contract->thirdparty->id.
'.DAT='.
dol_print_date(
dol_now(),
'%Y%m%d%H%M%S');
1381 $fulltag .=
'.TAG='.$TAG;
1392 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
1393 print
'</td><td class="CTableRow2"><b>'.$creditor.
'</b>';
1394 print
'<input type="hidden" name="creditor" value="'.$creditor.
'">';
1395 print
'</td></tr>'.
"\n";
1398 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"ThirdParty");
1399 print
'</td><td class="CTableRow2"><b>'.$contract->thirdparty->name.
'</b>';
1400 print
'</td></tr>'.
"\n";
1403 $text =
'<b>'.$langs->trans(
"PaymentRenewContractId", $contract->ref, $contractline->ref).
'</b>';
1404 if ($contractline->fk_product > 0) {
1405 $contractline->fetch_product();
1406 $text .=
'<br>'.$contractline->product->ref.($contractline->product->label ?
' - '.$contractline->product->label :
'');
1408 if ($contractline->description) {
1409 $text .=
'<br>'.dol_htmlentitiesbr($contractline->description);
1411 if ($contractline->date_end) {
1412 $text .=
'<br>'.$langs->trans(
"ExpiredSince").
': '.
dol_print_date($contractline->date_end);
1414 if (
GETPOST(
'desc',
'alpha')) {
1415 $text =
'<b>'.$langs->trans(
GETPOST(
'desc',
'alpha')).
'</b>';
1417 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Designation");
1418 print
'</td><td class="CTableRow2">'.$text;
1419 print
'<input type="hidden" name="source" value="'.dol_escape_htmltag($source).
'">';
1420 print
'<input type="hidden" name="ref" value="'.dol_escape_htmltag($contractline->ref).
'">';
1421 print
'<input type="hidden" name="dol_id" value="'.dol_escape_htmltag($contractline->id).
'">';
1422 $directdownloadlink = $contract->getLastMainDocLink(
'contract');
1423 if ($directdownloadlink) {
1424 print
'<br><a href="'.$directdownloadlink.
'">';
1425 print
img_mime($contract->last_main_doc,
'');
1426 print $langs->trans(
"DownloadDocument").
'</a>';
1428 print
'</td></tr>'.
"\n";
1431 $label = $langs->trans(
"Quantity");
1434 if ($contractline->fk_product) {
1435 if ($contractline->product->isService() && $contractline->product->duration_value > 0) {
1436 $label = $langs->trans(
"Duration");
1439 if ($contractline->product->duration_value > 1) {
1440 $dur = array(
"h" => $langs->trans(
"Hours"),
"d" => $langs->trans(
"DurationDays"),
"w" => $langs->trans(
"DurationWeeks"),
"m" => $langs->trans(
"DurationMonths"),
"y" => $langs->trans(
"DurationYears"));
1442 $dur = array(
"h" => $langs->trans(
"Hour"),
"d" => $langs->trans(
"DurationDay"),
"w" => $langs->trans(
"DurationWeek"),
"m" => $langs->trans(
"DurationMonth"),
"y" => $langs->trans(
"DurationYear"));
1444 $duration = $contractline->product->duration_value.
' '.$dur[$contractline->product->duration_unit];
1447 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$label.
'</td>';
1448 print
'<td class="CTableRow2"><b>'.($duration ? $duration : $qty).
'</b>';
1449 print
'<input type="hidden" name="newqty" value="'.dol_escape_htmltag($qty).
'">';
1450 print
'</b></td></tr>'.
"\n";
1453 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Amount");
1454 if (empty($amount)) {
1455 print
' ('.$langs->trans(
"ToComplete").
')';
1457 print
'</td><td class="CTableRow2">';
1458 if (empty($amount) || !is_numeric($amount)) {
1459 print
'<input type="hidden" name="amount" value="'.price2num(
GETPOST(
"amount",
'alpha'),
'MT').
'">';
1460 print
'<input class="flat maxwidth75" type="text" name="newamount" value="'.price2num(
GETPOST(
"newamount",
"alpha"),
'MT').
'">';
1462 print
' <b>'.$langs->trans(
"Currency".$currency).
'</b>';
1464 print
'<b class="amount">'.price($amount, 1, $langs, 1, -1, -1, $currency).
'</b>';
1465 print
'<input type="hidden" name="amount" value="'.$amount.
'">';
1466 print
'<input type="hidden" name="newamount" value="'.$amount.
'">';
1468 print
'<input type="hidden" name="currency" value="'.$currency.
'">';
1469 print
'</td></tr>'.
"\n";
1472 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentCode");
1473 print
'</td><td class="CTableRow2"><b style="word-break: break-all;">'.$fulltag.
'</b>';
1474 print
'<input type="hidden" name="tag" value="'.$tag.
'">';
1475 print
'<input type="hidden" name="fulltag" value="'.$fulltag.
'">';
1476 print
'</td></tr>'.
"\n";
1479 $shipToName = $contract->thirdparty->name;
1480 $shipToStreet = $contract->thirdparty->address;
1481 $shipToCity = $contract->thirdparty->town;
1482 $shipToState = $contract->thirdparty->state_code;
1483 $shipToCountryCode = $contract->thirdparty->country_code;
1484 $shipToZip = $contract->thirdparty->zip;
1485 $shipToStreet2 =
'';
1486 $phoneNum = $contract->thirdparty->phone;
1487 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1488 print
'<input type="hidden" name="shipToName" value="'.$shipToName.
'">'.
"\n";
1489 print
'<input type="hidden" name="shipToStreet" value="'.$shipToStreet.
'">'.
"\n";
1490 print
'<input type="hidden" name="shipToCity" value="'.$shipToCity.
'">'.
"\n";
1491 print
'<input type="hidden" name="shipToState" value="'.$shipToState.
'">'.
"\n";
1492 print
'<input type="hidden" name="shipToCountryCode" value="'.$shipToCountryCode.
'">'.
"\n";
1493 print
'<input type="hidden" name="shipToZip" value="'.$shipToZip.
'">'.
"\n";
1494 print
'<input type="hidden" name="shipToStreet2" value="'.$shipToStreet2.
'">'.
"\n";
1495 print
'<input type="hidden" name="phoneNum" value="'.$phoneNum.
'">'.
"\n";
1497 print
'<!-- Shipping address not complete, so we don t use it -->'.
"\n";
1499 if (is_object($contract->thirdparty)) {
1500 print
'<input type="hidden" name="thirdparty_id" value="'.$contract->thirdparty->id.
'">'.
"\n";
1502 print
'<input type="hidden" name="email" value="'.$contract->thirdparty->email.
'">'.
"\n";
1503 print
'<input type="hidden" name="vatnumber" value="'.$contract->thirdparty->tva_intra.
'">'.
"\n";
1504 $labeldesc = $langs->trans(
"Contract").
' '.$contract->ref;
1505 if (
GETPOST(
'desc',
'alpha')) {
1506 $labeldesc =
GETPOST(
'desc',
'alpha');
1508 print
'<input type="hidden" name="desc" value="'.dol_escape_htmltag($labeldesc).
'">'.
"\n";
1512if ($source ==
'member' || $source ==
'membersubscription') {
1513 $newsource =
'member';
1517 $langs->load(
"members");
1519 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
1520 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent_type.class.php';
1521 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
1527 $result = $member->fetch(
'', $ref);
1529 $mesg = $member->error;
1532 $member->fetch_thirdparty();
1534 $adht->fetch($member->typeid);
1538 if ($action !=
'dopayment') {
1539 $amount = $subscription->total_ttc;
1540 if (
GETPOST(
"amount",
'alpha')) {
1544 if (empty($amount)) {
1545 $amount = $adht->amount;
1548 $amount = max(0,
price2num($amount,
'MT'));
1551 if (
GETPOST(
'fulltag',
'alpha')) {
1552 $fulltag =
GETPOST(
'fulltag',
'alpha');
1557 $fulltag .=
'.TAG='.$TAG;
1563 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
1564 print
'</td><td class="CTableRow2"><b>'.$creditor.
'</b>';
1565 print
'<input type="hidden" name="creditor" value="'.$creditor.
'">';
1566 print
'</td></tr>'.
"\n";
1569 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Member");
1570 print
'</td><td class="CTableRow2">';
1572 if ($member->morphy ==
'mor' && !empty($member->company)) {
1573 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1574 print $member->company;
1576 print
img_picto(
'',
'member',
'class="pictofixedwidth"');
1577 print $member->getFullName($langs);
1580 print
'</td></tr>'.
"\n";
1583 $text =
'<b>'.$langs->trans(
"PaymentSubscription").
'</b>';
1584 if (
GETPOST(
'desc',
'alpha')) {
1585 $text =
'<b>'.$langs->trans(
GETPOST(
'desc',
'alpha')).
'</b>';
1587 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Designation");
1588 print
'</td><td class="CTableRow2">'.$text;
1589 print
'<input type="hidden" name="source" value="'.dol_escape_htmltag($newsource).
'">';
1590 print
'<input type="hidden" name="ref" value="'.dol_escape_htmltag($member->ref).
'">';
1591 print
'</td></tr>'.
"\n";
1594 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"DateEndSubscription");
1595 print
'</td><td class="CTableRow2">'.dol_print_date($member->datefin,
'day');
1596 print
'</td></tr>'.
"\n";
1599 if ($member->last_subscription_date || $member->last_subscription_amount) {
1602 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"LastSubscriptionDate");
1603 print
'</td><td class="CTableRow2">'.dol_print_date($member->last_subscription_date,
'day');
1604 print
'</td></tr>'.
"\n";
1608 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"LastSubscriptionAmount");
1609 print
'</td><td class="CTableRow2">'.price($member->last_subscription_amount);
1610 print
'</td></tr>'.
"\n";
1612 if (empty($amount) && !
GETPOST(
'newamount',
'alpha')) {
1613 $_GET[
'newamount'] = $member->last_subscription_amount;
1614 $_GET[
'amount'] = $member->last_subscription_amount;
1616 if (!empty($member->last_subscription_amount) && !GETPOSTISSET(
'newamount') && is_numeric($amount)) {
1617 $amount = max($member->last_subscription_amount, $amount);
1621 $amountbytype = $adht->amountByType(1);
1623 $typeid = $adht->id;
1624 $caneditamount = $adht->caneditamount;
1626 if ($member->type) {
1627 $oldtypeid = $member->typeid;
1628 $newtypeid = (int) (GETPOSTISSET(
"typeid") ?
GETPOSTINT(
"typeid") : $member->typeid);
1630 $typeid = $newtypeid;
1631 $adht->fetch($typeid);
1634 $caneditamount = $adht->caneditamount;
1638 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"LastMemberType");
1639 print
'</td><td class="CTableRow2">'.dol_escape_htmltag($member->type);
1640 print
"</td></tr>\n";
1643 $member->typeid = $newtypeid;
1644 $member->type = (string)
dol_getIdFromCode($db, $newtypeid,
'adherent_type',
'rowid',
'libelle');
1650 $amount = (!empty($amountbytype[$member->typeid])) ? $amountbytype[$member->typeid] : $member->last_subscription_amount;
1652 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"NewSubscription");
1653 print
'</td><td class="CTableRow2">';
1654 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);
1655 print "</td></tr>\n
";
1656 } elseif ($action == 'dopayment') {
1657 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("NewMemberType
");
1658 print '</td><td class="CTableRow2
">'.dol_escape_htmltag($member->type);
1659 print '<input type="hidden
" name="membertypeid
" value="'.$member->typeid.'">';
1660 print "</td></tr>\n
";
1663 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("MemberType
");
1664 print '</td><td class="CTableRow2
">'.dol_escape_htmltag($member->type);
1665 print "</td></tr>\n
";
1669 // Set amount for the subscription from the the type and options:
1670 // - First check the amount of the member type if not previous payment.
1671 $amount = ($member->last_subscription_amount ? $member->last_subscription_amount : (empty($amountbytype[$typeid]) ? 0 : $amountbytype[$typeid]));
1672 // - If not found, take the default amount
1673 if (empty($amount) && getDolGlobalString('MEMBER_NEWFORM_AMOUNT')) {
1674 $amount = getDolGlobalString('MEMBER_NEWFORM_AMOUNT');
1676 // - If a new amount was posted from the form
1677 if ($caneditamount && GETPOSTISSET('newamount') && GETPOSTFLOAT('newamount', 'MT') > 0) {
1678 $amount = GETPOSTFLOAT('newamount', 'MT');
1680 // - If a min is set or an amount from the posted form, we take them into account
1681 $amount = max(0, (float) $amount, (float) getDolGlobalInt("MEMBER_MIN_AMOUNT
"));
1684 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Amount
");
1685 // This place no longer allows amount edition
1686 if (getDolGlobalString('MEMBER_EXT_URL_SUBSCRIPTION_INFO')) {
1687 print ' - <a href="' . getDolGlobalString('MEMBER_EXT_URL_SUBSCRIPTION_INFO
').'" rel="external
" target="_blank
" rel="noopener noreferrer
">'.$langs->trans("SeeHere
").'</a>';
1689 print '</td><td class="CTableRow2
">';
1691 $caneditamount = $adht->caneditamount;
1692 $minimumamount = !getDolGlobalString('MEMBER_MIN_AMOUNT') ? $adht->amount : max(getDolGlobalString('MEMBER_MIN_AMOUNT'), $adht->amount, $amount);
1694 if ($caneditamount && $action != 'dopayment') {
1695 if (GETPOSTISSET('newamount')) {
1696 print '<input type="text
" class="width75
" name="newamount
" value="'.price(price2num(GETPOST('newamount
'), '', 2), 1, $langs, 1, -1, -1).'">';
1698 print '<input type="text
" class="width75
" name="newamount
" value="'.price($amount, 1, $langs, 1, -1, -1).'">';
1701 print '<b class="amount
">'.price($amount, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
1702 if ($minimumamount > $amount) {
1703 print ' <span class="opacitymedium small
">'. $langs->trans("AmountIsLowerToMinimumNotice
", price($minimumamount, 1, $langs, 1, -1, -1, $currency)).'</span>';
1705 print '<input type="hidden
" name="newamount
" value="'.$amount.'">';
1707 print '<input type="hidden
" name="amount
" value="'.$amount.'">';
1708 print '<input type="hidden
" name="currency
" value="'.$currency.'">';
1709 print '</td></tr>'."\n
";
1712 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("PaymentCode
");
1713 print '</td><td class="CTableRow2
"><b style="word-
break:
break-all;
">'.$fulltag.'</b>';
1714 print '<input type="hidden
" name="tag
" value="'.$tag.'">';
1715 print '<input type="hidden
" name="fulltag
" value="'.$fulltag.'">';
1716 print '</td></tr>'."\n
";
1719 $shipToName = $member->getFullName($langs);
1720 $shipToStreet = $member->address;
1721 $shipToCity = $member->town;
1722 $shipToState = $member->state_code;
1723 $shipToCountryCode = $member->country_code;
1724 $shipToZip = $member->zip;
1725 $shipToStreet2 = '';
1726 $phoneNum = $member->phone;
1727 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1728 print '<!-- Shipping address information -->';
1729 print '<input type="hidden
" name="shipToName
" value="'.$shipToName.'">'."\n
";
1730 print '<input type="hidden
" name="shipToStreet
" value="'.$shipToStreet.'">'."\n
";
1731 print '<input type="hidden
" name="shipToCity
" value="'.$shipToCity.'">'."\n
";
1732 print '<input type="hidden
" name="shipToState
" value="'.$shipToState.'">'."\n
";
1733 print '<input type="hidden
" name="shipToCountryCode
" value="'.$shipToCountryCode.'">'."\n
";
1734 print '<input type="hidden
" name="shipToZip
" value="'.$shipToZip.'">'."\n
";
1735 print '<input type="hidden
" name="shipToStreet2
" value="'.$shipToStreet2.'">'."\n
";
1736 print '<input type="hidden
" name="phoneNum
" value="'.$phoneNum.'">'."\n
";
1738 print '<!-- Shipping address not complete, so we don t use it -->'."\n
";
1740 if (is_object($member->thirdparty)) {
1741 print '<input type="hidden
" name="thirdparty_id
" value="'.$member->thirdparty->id.'">'."\n
";
1743 print '<input type="hidden
" name="email
" value="'.$member->email.'">'."\n
";
1744 $labeldesc = $langs->trans("PaymentSubscription
");
1745 if (GETPOST('desc', 'alpha')) {
1746 $labeldesc = GETPOST('desc', 'alpha');
1748 print '<input type="hidden
" name="desc
" value="'.dol_escape_htmltag($labeldesc).'">'."\n
";
1751// Payment on donation
1752if ($source == 'donation') {
1754 $langs->load("don
");
1756 require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
1758 $don = new Don($db);
1759 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
1760 $result = $don->fetch($ref);
1762 $mesg = $don->error;
1765 $don->fetch_thirdparty();
1769 if ($action != 'dopayment') { // Do not change amount if we just click on first dopayment
1770 if (GETPOST("amount
", 'alpha')) {
1771 $amount = GETPOST("amount
", 'alpha');
1773 $amount = $don->getRemainToPay();
1775 $amount = price2num($amount);
1778 if (GETPOST('fulltag', 'alpha')) {
1779 $fulltag = GETPOST('fulltag', 'alpha');
1781 $fulltag = 'DON='.$don->ref.'.DAT='.dol_print_date(dol_now(), '%Y%m%d%H%M%S');
1784 $fulltag .= '.TAG='.$TAG;
1787 $fulltag = dol_string_unaccent($fulltag);
1790 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Creditor
");
1791 print '</td><td class="CTableRow2
"><b>'.$creditor.'</b>';
1792 print '<input type="hidden
" name="creditor
" value="'.$creditor.'">';
1793 print '</td></tr>'."\n
";
1796 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("ThirdParty
");
1797 print '</td><td class="CTableRow2
"><b>';
1798 if ($don->morphy == 'mor' && !empty($don->societe)) {
1799 print $don->societe;
1801 print $don->getFullName($langs);
1804 print '</td></tr>'."\n
";
1808 if (GETPOST('desc', 'alpha')) {
1809 $text = '<b>'.$langs->trans(GETPOST('desc', 'alpha')).'</b>';
1811 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Designation
");
1812 print '</td><td class="CTableRow2
">'.$text;
1813 print '<input type="hidden
" name="source
" value="'.dol_escape_htmltag($source).'">';
1814 print '<input type="hidden
" name="ref" value="'.dol_escape_htmltag($don->ref).'">';
1815 print '</td></tr>'."\n
";
1818 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Amount
");
1819 if (empty($amount)) {
1820 if (!getDolGlobalString('DONATION_NEWFORM_AMOUNT')) {
1821 print ' ('.$langs->trans("ToComplete
");
1823 if (getDolGlobalString('DONATION_EXT_URL_SUBSCRIPTION_INFO')) {
1824 print ' - <a href="' . getDolGlobalString('DONATION_EXT_URL_SUBSCRIPTION_INFO
').'" rel="external
" target="_blank
" rel="noopener noreferrer
">'.$langs->trans("SeeHere
").'</a>';
1826 if (!getDolGlobalString('DONATION_NEWFORM_AMOUNT')) {
1830 print '</td><td class="CTableRow2
">';
1832 if (empty($amount) || !is_numeric($amount)) {
1833 $valtoshow = price2num(GETPOST("newamount
", 'alpha'), 'MT');
1834 // force default subscription amount to value defined into constant...
1835 if (empty($valtoshow)) {
1836 if (getDolGlobalString('DONATION_NEWFORM_EDITAMOUNT')) {
1837 if (getDolGlobalString('DONATION_NEWFORM_AMOUNT')) {
1838 $valtoshow = getDolGlobalString('DONATION_NEWFORM_AMOUNT');
1841 if (getDolGlobalString('DONATION_NEWFORM_AMOUNT')) {
1842 $amount = getDolGlobalString('DONATION_NEWFORM_AMOUNT');
1847 if (empty($amount) || !is_numeric($amount)) {
1848 //$valtoshow=price2num(GETPOST("newamount
",'alpha'),'MT');
1849 if (getDolGlobalString('DONATION_MIN_AMOUNT') && $valtoshow) {
1850 $valtoshow = max(getDolGlobalString('DONATION_MIN_AMOUNT'), $valtoshow);
1852 print '<input type="hidden
" name="amount
" value="'.price2num(GETPOST("amount", 'alpha
'), 'MT
').'">';
1853 print '<input class="flat maxwidth75
" type="text
" name="newamount
" value="'.$valtoshow.'">';
1855 print ' <b>'.$langs->trans("Currency
".$currency).'</b>';
1857 $valtoshow = $amount;
1858 if (getDolGlobalString('DONATION_MIN_AMOUNT') && $valtoshow) {
1859 $valtoshow = max(getDolGlobalString('DONATION_MIN_AMOUNT'), $valtoshow);
1860 $amount = $valtoshow;
1862 print '<b class="amount
">'.price($valtoshow, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
1863 print '<input type="hidden
" name="amount
" value="'.$valtoshow.'">';
1864 print '<input type="hidden
" name="newamount
" value="'.$valtoshow.'">';
1866 print '<input type="hidden
" name="currency
" value="'.$currency.'">';
1867 print '</td></tr>'."\n
";
1870 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("PaymentCode
");
1871 print '</td><td class="CTableRow2
"><b style="word-
break:
break-all;
">'.$fulltag.'</b>';
1872 print '<input type="hidden
" name="tag
" value="'.$tag.'">';
1873 print '<input type="hidden
" name="fulltag
" value="'.$fulltag.'">';
1874 print '</td></tr>'."\n
";
1877 $shipToName = $don->getFullName($langs);
1878 $shipToStreet = $don->address;
1879 $shipToCity = $don->town;
1880 $shipToState = $don->state_code;
1881 $shipToCountryCode = $don->country_code;
1882 $shipToZip = $don->zip;
1883 $shipToStreet2 = '';
1884 $phoneNum = $don->phone;
1885 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1886 print '<!-- Shipping address information -->';
1887 print '<input type="hidden
" name="shipToName
" value="'.$shipToName.'">'."\n
";
1888 print '<input type="hidden
" name="shipToStreet
" value="'.$shipToStreet.'">'."\n
";
1889 print '<input type="hidden
" name="shipToCity
" value="'.$shipToCity.'">'."\n
";
1890 print '<input type="hidden
" name="shipToState
" value="'.$shipToState.'">'."\n
";
1891 print '<input type="hidden
" name="shipToCountryCode
" value="'.$shipToCountryCode.'">'."\n
";
1892 print '<input type="hidden
" name="shipToZip
" value="'.$shipToZip.'">'."\n
";
1893 print '<input type="hidden
" name="shipToStreet2
" value="'.$shipToStreet2.'">'."\n
";
1894 print '<input type="hidden
" name="phoneNum
" value="'.$phoneNum.'">'."\n
";
1896 print '<!-- Shipping address not complete, so we don t use it -->'."\n
";
1898 if (is_object($don->thirdparty)) {
1899 print '<input type="hidden
" name="thirdparty_id
" value="'.$don->thirdparty->id.'">'."\n
";
1901 print '<input type="hidden
" name="email
" value="'.$don->email.'">'."\n
";
1902 $labeldesc = $langs->trans("PaymentSubscription
");
1903 if (GETPOST('desc', 'alpha')) {
1904 $labeldesc = GETPOST('desc', 'alpha');
1906 print '<input type="hidden
" name="desc
" value="'.dol_escape_htmltag($labeldesc).'">'."\n
";
1909if ($source == 'organizedeventregistration') {
1911 $langs->loadLangs(array("members
", "eventorganization
"));
1913 if (GETPOST('fulltag', 'alpha')) {
1914 $fulltag = GETPOST('fulltag', 'alpha');
1916 $fulltag = 'ATT='.$attendee->id.'.DAT='.dol_print_date(dol_now(), '%Y%m%d%H%M%S');
1919 $fulltag .= '.TAG='.$TAG;
1922 $fulltag = dol_string_unaccent($fulltag);
1925 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Creditor
");
1926 print '</td><td class="CTableRow2
"><b>'.$creditor.'</b>';
1927 print '<input type="hidden
" name="creditor
" value="'.$creditor.'">';
1928 print '</td></tr>'."\n
";
1931 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Attendee
");
1932 print '</td><td class="CTableRow2
"><b>';
1933 print $attendee->email;
1934 print($thirdparty->name ? ' ('.$thirdparty->name.')' : '');
1936 print '</td></tr>'."\n
";
1938 if (! is_object($attendee->project)) {
1939 $text = 'ErrorProjectNotFound';
1941 $text = $langs->trans("PaymentEvent
").' - '.$attendee->project->title;
1945 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Designation
");
1946 print '</td><td class="CTableRow2
"><b>'.$text.'</b>';
1947 print '<input type="hidden
" name="source
" value="'.dol_escape_htmltag($source).'">';
1948 print '<input type="hidden
" name="ref" value="'.dol_escape_htmltag($invoice->id).'">';
1949 print '</td></tr>'."\n
";
1952 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Amount
");
1953 print '</td><td class="CTableRow2
">';
1954 $valtoshow = $amount;
1955 print '<b class="amount
">'.price($valtoshow, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
1956 print '<input type="hidden
" name="amount
" value="'.$valtoshow.'">';
1957 print '<input type="hidden
" name="newamount
" value="'.$valtoshow.'">';
1958 print '<input type="hidden
" name="currency
" value="'.$currency.'">';
1959 print '</td></tr>'."\n
";
1962 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("PaymentCode
");
1963 print '</td><td class="CTableRow2
"><b style="word-
break:
break-all;
">'.$fulltag.'</b>';
1964 print '<input type="hidden
" name="tag
" value="'.$tag.'">';
1965 print '<input type="hidden
" name="fulltag
" value="'.$fulltag.'">';
1966 print '</td></tr>'."\n
";
1969 $shipToName = $thirdparty->getFullName($langs);
1970 $shipToStreet = $thirdparty->address;
1971 $shipToCity = $thirdparty->town;
1972 $shipToState = $thirdparty->state_code;
1973 $shipToCountryCode = $thirdparty->country_code;
1974 $shipToZip = $thirdparty->zip;
1975 $shipToStreet2 = '';
1976 $phoneNum = $thirdparty->phone;
1977 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1978 print '<!-- Shipping address information -->';
1979 print '<input type="hidden
" name="shipToName
" value="'.$shipToName.'">'."\n
";
1980 print '<input type="hidden
" name="shipToStreet
" value="'.$shipToStreet.'">'."\n
";
1981 print '<input type="hidden
" name="shipToCity
" value="'.$shipToCity.'">'."\n
";
1982 print '<input type="hidden
" name="shipToState
" value="'.$shipToState.'">'."\n
";
1983 print '<input type="hidden
" name="shipToCountryCode
" value="'.$shipToCountryCode.'">'."\n
";
1984 print '<input type="hidden
" name="shipToZip
" value="'.$shipToZip.'">'."\n
";
1985 print '<input type="hidden
" name="shipToStreet2
" value="'.$shipToStreet2.'">'."\n
";
1986 print '<input type="hidden
" name="phoneNum
" value="'.$phoneNum.'">'."\n
";
1988 print '<!-- Shipping address not complete, so we don t use it -->'."\n
";
1990 print '<input type="hidden
" name="thirdparty_id
" value="'.$thirdparty->id.'">'."\n
";
1991 print '<input type="hidden
" name="email
" value="'.$thirdparty->email.'">'."\n
";
1992 $labeldesc = $langs->trans("PaymentSubscription
");
1993 if (GETPOST('desc', 'alpha')) {
1994 $labeldesc = GETPOST('desc', 'alpha');
1996 print '<input type="hidden
" name="desc
" value="'.dol_escape_htmltag($labeldesc).'">'."\n
";
1999if ($source == 'boothlocation') {
2001 $langs->load("members
");
2003 if (GETPOST('fulltag', 'alpha')) {
2004 $fulltag = GETPOST('fulltag', 'alpha');
2006 $fulltag = 'BOO='.GETPOST("booth
").'.DAT='.dol_print_date(dol_now(), '%Y%m%d%H%M%S');
2009 $fulltag .= '.TAG='.$TAG;
2012 $fulltag = dol_string_unaccent($fulltag);
2015 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Creditor
");
2016 print '</td><td class="CTableRow2
"><b>'.$creditor.'</b>';
2017 print '<input type="hidden
" name="creditor
" value="'.$creditor.'">';
2018 print '</td></tr>'."\n
";
2021 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Attendee
");
2022 print '</td><td class="CTableRow2
"><b>';
2023 print $thirdparty->name;
2025 print '</td></tr>'."\n
";
2028 $text = '<b>'.$langs->trans("PaymentBoothLocation
").'</b>';
2029 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Designation
");
2030 print '</td><td class="CTableRow2
">'.$text;
2031 print '<input type="hidden
" name="source
" value="'.dol_escape_htmltag($source).'">';
2032 print '<input type="hidden
" name="ref" value="'.dol_escape_htmltag($invoice->id).'">';
2033 print '</td></tr>'."\n
";
2036 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Amount
");
2037 print '</td><td class="CTableRow2
">';
2038 $valtoshow = $amount;
2039 print '<b class="amount
">'.price($valtoshow, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
2040 print '<input type="hidden
" name="amount
" value="'.$valtoshow.'">';
2041 print '<input type="hidden
" name="newamount
" value="'.$valtoshow.'">';
2042 print '<input type="hidden
" name="currency
" value="'.$currency.'">';
2043 print '</td></tr>'."\n
";
2046 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("PaymentCode
");
2047 print '</td><td class="CTableRow2
"><b style="word-
break:
break-all;
">'.$fulltag.'</b>';
2048 print '<input type="hidden
" name="tag
" value="'.$tag.'">';
2049 print '<input type="hidden
" name="fulltag
" value="'.$fulltag.'">';
2050 print '</td></tr>'."\n
";
2053 $shipToName = $thirdparty->getFullName($langs);
2054 $shipToStreet = $thirdparty->address;
2055 $shipToCity = $thirdparty->town;
2056 $shipToState = $thirdparty->state_code;
2057 $shipToCountryCode = $thirdparty->country_code;
2058 $shipToZip = $thirdparty->zip;
2059 $shipToStreet2 = '';
2060 $phoneNum = $thirdparty->phone;
2061 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
2062 print '<!-- Shipping address information -->';
2063 print '<input type="hidden
" name="shipToName
" value="'.$shipToName.'">'."\n
";
2064 print '<input type="hidden
" name="shipToStreet
" value="'.$shipToStreet.'">'."\n
";
2065 print '<input type="hidden
" name="shipToCity
" value="'.$shipToCity.'">'."\n
";
2066 print '<input type="hidden
" name="shipToState
" value="'.$shipToState.'">'."\n
";
2067 print '<input type="hidden
" name="shipToCountryCode
" value="'.$shipToCountryCode.'">'."\n
";
2068 print '<input type="hidden
" name="shipToZip
" value="'.$shipToZip.'">'."\n
";
2069 print '<input type="hidden
" name="shipToStreet2
" value="'.$shipToStreet2.'">'."\n
";
2070 print '<input type="hidden
" name="phoneNum
" value="'.$phoneNum.'">'."\n
";
2072 print '<!-- Shipping address not complete, so we don t use it -->'."\n
";
2074 print '<input type="hidden
" name="thirdparty_id
" value="'.$thirdparty->id.'">'."\n
";
2075 print '<input type="hidden
" name="email
" value="'.$thirdparty->email.'">'."\n
";
2076 $labeldesc = $langs->trans("PaymentSubscription
");
2077 if (GETPOST('desc', 'alpha')) {
2078 $labeldesc = GETPOST('desc', 'alpha');
2080 print '<input type="hidden
" name="desc
" value="'.dol_escape_htmltag($labeldesc).'">'."\n
";
2083if (!$found && !$mesg) {
2084 $mesg = $langs->trans("ErrorBadParameters
");
2088 print '<tr><td align="center
" colspan="2
"><br><div class="warning
">'.dol_escape_htmltag($mesg, 1, 1, 'br').'</div></td></tr>'."\n
";
2091print '</table>'."\n
";
2095// Show all payment mode buttons (Stripe, Paypal, ...)
2096if ($action != 'dopayment') {
2097 if ($found && !$error) { // We are in a management option and no error
2098 // Check status of the object (Invoice) to verify if it is paid by external payment modules (ie Payzen, ...)
2100 'source' => $source,
2103 $reshook = $hookmanager->executeHooks('doCheckStatus', $parameters, $object, $action);
2105 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2106 } elseif ($reshook > 0) {
2107 print $hookmanager->resPrint;
2110 if ($source == 'order' && $object->billed) {
2111 print '<br><br><div class="amountpaymentcomplete size12x wrapimp
">'.$langs->trans("OrderBilled
").'</div>';
2112 } elseif ($source == 'invoice' && $object->paye) {
2113 print '<br><br><div class="amountpaymentcomplete size12x wrapimp
">'.$langs->trans("InvoicePaid
").'</div>';
2114 } elseif ($source == 'donation' && $object->paid) {
2115 print '<br><br><div class="amountpaymentcomplete size12x wrapimp
">'.$langs->trans("DonationPaid
").'</div>';
2117 // Membership can be paid and we still allow to make renewal
2118 if (($source == 'member' || $source == 'membersubscription') && $object->datefin > dol_now()) {
2119 $langs->load("members
");
2120 print '<br><div class="amountpaymentcomplete size12x wrapimp
">';
2121 $s = $langs->trans("MembershipPaid
", '{s1}');
2122 print str_replace('{s1}', '<span class="nobold
">'.dol_print_date($object->datefin, 'day').'</span>', $s);
2124 print '<div class="opacitymedium margintoponly
">'.$langs->trans("PaymentWillBeRecordedForNextPeriod
").'</div>';
2128 // Buttons for all payments registration methods
2130 // This hook is used to add Button to newpayment.php for external payment modules (ie Payzen, ...)
2132 'paymentmethod' => $paymentmethod
2134 $reshook = $hookmanager->executeHooks('doAddButton', $parameters, $object, $action);
2136 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2137 } elseif ($reshook > 0) {
2138 print $hookmanager->resPrint;
2141 if ((empty($paymentmethod) || $paymentmethod == 'paybox') && isModEnabled('paybox')) {
2142 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").'">';
2144 print '<span class="buttonpaymentsmall
">'.$langs->trans("CreditOrDebitCard
").'</span>';
2147 $( document ).ready(function() {
2148 $("#div_dopayment_paybox
").click(function(){
2149 $("#dopayment_paybox
").click();
2151 $("#dopayment_paybox
").click(function(e){
2152 $("#div_dopayment_paybox
").css( \'cursor\', \'wait\' );
2153 e.stopPropagation();
2160 if ((empty($paymentmethod) || $paymentmethod == 'stripe') && isModEnabled('stripe')) {
2162 if (getDolGlobalString(strtoupper($source).'_FORCE_DISABLE_STRIPE')) { // Example: MEMBER_FORCE_DISABLE_STRIPE
2167 // 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.
2168 // 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).
2169 $noidempotency_key = (GETPOSTISSET('noidempotency') ? GETPOSTINT('noidempotency') : (getDolGlobalInt('STRIPE_USE_IDEMPOTENCY_BY_DEFAULT') ? 0 : 1));
2171 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").'">';
2172 print '<input type="hidden
" name="noidempotency
" value="'.$noidempotency_key.'">';
2174 print '<span class="buttonpaymentsmall
">'.$langs->trans("CreditOrDebitCard
").'</span>';
2177 $( document ).ready(function() {
2178 $("#div_dopayment_stripe
").click(function(){
2179 $("#dopayment_stripe
").click();
2181 $("#dopayment_stripe
").click(function(e){
2182 $("#div_dopayment_stripe
").css( \'cursor\', \'wait\' );
2183 e.stopPropagation();
2192 if ((empty($paymentmethod) || $paymentmethod == 'paypal') && isModEnabled('paypal')) {
2193 if (!getDolGlobalString('PAYPAL_API_INTEGRAL_OR_PAYPALONLY')) {
2194 $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY = 'integral';
2198 if (getDolGlobalString(strtoupper($source).'_FORCE_DISABLE_PAYPAL')) { // Example: MEMBER_FORCE_DISABLE_PAYPAL
2203 print '<div class="button buttonpayment
" id="div_dopayment_paypal
">';
2204 if (getDolGlobalString('PAYPAL_API_INTEGRAL_OR_PAYPALONLY') != 'integral') {
2205 print '<div style="line-height: 1em
"> </div>';
2207 print '<span class="fab fa-paypal
"></span> <input class="" type="submit
" id="dopayment_paypal
" name="dopayment_paypal
" value="'.$langs->trans("PaypalDoPayment").'">';
2208 if (getDolGlobalString('PAYPAL_API_INTEGRAL_OR_PAYPALONLY') == 'integral') {
2210 print '<span class="buttonpaymentsmall
">'.$langs->trans("CreditOrDebitCard
").'</span><span class="buttonpaymentsmall
"> - </span>';
2211 print '<span class="buttonpaymentsmall
">'.$langs->trans("PayPalBalance
").'</span>';
2213 if (getDolGlobalString('PAYPAL_API_INTEGRAL_OR_PAYPALONLY') == 'paypalonly') {
2215 //print '<span class="buttonpaymentsmall
">'.$langs->trans("PayPalBalance
").'"></span>
';
2219 $( document ).ready(
function() {
2220 $(
"#div_dopayment_paypal").click(
function(){
2221 $(
"#dopayment_paypal").click();
2223 $(
"#dopayment_paypal").click(
function(e){
2224 $(
"#div_dopayment_paypal").css( \
'cursor\', \'wait\' );
2225 e.stopPropagation();
2241print
'</td></tr>'.
"\n";
2243print
'</table>'.
"\n";
2245print
'</form>'.
"\n";
2253if (preg_match(
'/^dopayment/', $action)) {
2256 $_SESSION[
"currencyCodeType"] = $currency;
2257 $_SESSION[
"FinalPaymentAmt"] = $amount;
2258 $_SESSION[
'ipaddress'] = ($remoteip ? $remoteip :
'unknown');
2259 $_SESSION[
"paymentType"] =
'';
2262 if (
GETPOST(
'dopayment_stripe',
'alpha')) {
2270 background-color: white;
2273 border: 1px solid transparent;
2274 box-shadow: 0 1px 3px 0 #e6ebf1;
2275 -webkit-transition: box-shadow 150ms ease;
2276 transition: box-shadow 150ms ease;
2279 .StripeElement--focus {
2280 box-shadow: 0 1px 3px 0 #cfd7df;
2283 .StripeElement--invalid {
2284 border-color: #fa755a;
2287 .StripeElement--webkit-autofill {
2288 background-color: #fefde5 !important;
2294 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";
2295 print
'<form action="'.$_SERVER[
'REQUEST_URI'].
'" method="POST" id="payment-form">'.
"\n";
2297 print
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
2298 print
'<input type="hidden" name="dopayment_stripe" value="1">'.
"\n";
2299 print
'<input type="hidden" name="action" value="charge">'.
"\n";
2300 print
'<input type="hidden" name="tag" value="'.$TAG.
'">'.
"\n";
2301 print
'<input type="hidden" name="s" value="'.$source.
'">'.
"\n";
2302 print
'<input type="hidden" name="ref" value="'.$REF.
'">'.
"\n";
2303 print
'<input type="hidden" name="fulltag" value="'.$FULLTAG.
'">'.
"\n";
2304 print
'<input type="hidden" name="suffix" value="'.$suffix.
'">'.
"\n";
2305 print
'<input type="hidden" name="securekey" value="'.$SECUREKEY.
'">'.
"\n";
2306 print
'<input type="hidden" name="e" value="'.$entity.
'" />';
2307 print
'<input type="hidden" name="amount" value="'.$amount.
'">'.
"\n";
2308 print
'<input type="hidden" name="currency" value="'.$currency.
'">'.
"\n";
2309 print
'<input type="hidden" name="forcesandbox" value="'.GETPOSTINT(
'forcesandbox').
'" />';
2310 print
'<input type="hidden" name="email" value="'.GETPOST(
'email',
'alpha').
'" />';
2311 print
'<input type="hidden" name="thirdparty_id" value="'.GETPOSTINT(
'thirdparty_id').
'" />';
2312 print
'<input type="hidden" name="lang" value="'.$getpostlang.
'">';
2315 require_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
2317 $service =
'StripeLive';
2320 $service =
'StripeTest';
2324 $stripe =
new Stripe($db);
2325 $stripeacc = $stripe->getStripeAccount($service);
2328 $stripecu = $stripe->customerStripe(
$object->thirdparty, $stripeacc, $servicestatus, 1);
2334 $noidempotency_key = (GETPOSTISSET(
'noidempotency') ?
GETPOSTINT(
'noidempotency') : (
getDolGlobalInt(
'STRIPE_USE_IDEMPOTENCY_BY_DEFAULT') ? 0 : 1));
2336 $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);
2339 if ($stripe->error) {
2350 <table id="dolpaymenttable" summary="Payment form" class="center centpercent">
2351 <tbody><tr><td class="textpublicpayment">';
2354 print
'<div id="payment-request-button"><!-- A Stripe Element will be inserted here. --></div>';
2357 print
'<div class="form-row '.(getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 2 ?
'center' :
'left').
'">';
2358 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 1) {
2359 print
'<label for="card-element">'.$langs->trans(
"CreditOrDebitCard").
'</label>';
2360 print
'<br><input id="cardholder-name" class="marginbottomonly" name="cardholder-name" value="" type="text" placeholder="'.$langs->trans(
"CardOwner").
'" autocomplete="off" autofocus required>';
2363 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 1) {
2364 print
'<div id="card-element">
2365 <!-- a Stripe Element will be inserted here. -->
2368 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 2) {
2369 print
'<div id="payment-element">
2370 <!-- a Stripe Element will be inserted here. -->
2374 print
'<!-- Used to display form errors -->
2375 <div id="card-errors" role="alert"></div>
2379 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>';
2380 print
'<img id="hourglasstopay" class="hidden" src="'.DOL_URL_ROOT.
'/theme/'.$conf->theme.
'/img/working.gif">';
2382 print
'</td></tr></tbody>';
2387 if (empty($paymentintent)) {
2388 print
'<center>'.$langs->trans(
"Error").
'</center>';
2390 print
'<input type="hidden" name="paymentintent_id" value="'.$paymentintent->id.
'">';
2395 print
'</form>'.
"\n";
2399 if (empty($stripearrayofkeys[
'publishable_key'])) {
2400 $langs->load(
"errors");
2401 print
info_admin($langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv(
"Stripe")), 0, 0,
'error');
2403 print
'<!-- JS Code for Stripe components -->';
2404 print
'<script src="https://js.stripe.com/v3/"></script>'.
"\n";
2405 print
'<!-- urllogofull = '.$urllogofull.
' -->'.
"\n";
2408 print
'<script type="text/javascript">'.
"\n";
2411 $amountstripe = $amount;
2415 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
2416 if (!in_array($currency, $arrayzerounitcurrency)) {
2417 $amountstripe = $amountstripe * 100;
2421 $metadata = array(
'dol_version' => DOL_VERSION,
'dol_entity' => $conf->entity,
'ipaddress' => $ipaddress);
2423 $metadata[
'dol_type'] =
$object->element;
2424 $metadata[
'dol_id'] =
$object->id;
2430 $arrayforpaymentintent = array(
2431 'description' =>
'Stripe payment: '.$FULLTAG.($ref ?
' ref='.$ref :
''),
2432 "metadata" => $metadata
2435 $arrayforpaymentintent[
"statement_descriptor"] =
dol_trunc($TAG, 10,
'right',
'UTF-8', 1);
2438 $arrayforcheckout = array(
2439 'payment_method_types' => array(
'card'),
2440 'line_items' => array(array(
2441 'price_data' => array(
2442 'currency' => $currency,
2443 'unit_amount' => $amountstripe,
2444 'product_data' => array(
2445 'name' => $langs->transnoentitiesnoconv(
"Payment").
' '.$TAG,
2446 'description' =>
'Stripe payment: '.$FULLTAG.($ref ?
' ref='.$ref :
''),
2452 'mode' =>
'payment',
2453 'client_reference_id' => $FULLTAG,
2454 'success_url' => $urlok,
2455 'cancel_url' => $urlko,
2456 'payment_intent_data' => $arrayforpaymentintent
2459 $arrayforcheckout[
'customer'] = $stripecu;
2461 $arrayforcheckout[
'customer_email'] =
GETPOST(
'email',
'alpha');
2463 $sessionstripe = \Stripe\Checkout\Session::create($arrayforcheckout);
2468 $_SESSION[
"currencyCodeType"] = $currency;
2469 $_SESSION[
"paymentType"] =
'';
2470 $_SESSION[
"FinalPaymentAmt"] = $amount;
2471 $_SESSION[
'ipaddress'] = ($remoteip ? $remoteip :
'unknown');
2472 $_SESSION[
'payerID'] = is_object($stripecu) ? $stripecu->id :
'';
2473 $_SESSION[
'TRANSACTIONID'] = $sessionstripe->id;
2475 print $e->getMessage();
2481 if (empty($stripeacc)) {
2483 var stripe =
Stripe(
'<?php echo $stripearrayofkeys['publishable_key
']; // Defined into config.php?>');
2487 var stripe =
Stripe(
'<?php echo $stripearrayofkeys['publishable_key
']; // Defined into config.php?>', { stripeAccount:
'<?php echo $stripeacc; ?>' });
2492 var elements = stripe.elements();
2500 fontFamily:
'"Helvetica Neue", Helvetica, sans-serif',
2501 fontSmoothing:
'antialiased',
2509 iconColor:
'#fa755a'
2513 var cardElement = elements.create(
'card', {style: style});
2516 stripe.redirectToCheckout({
2520 sessionId:
'<?php print $sessionstripe->id; ?>'
2521 }).then(
function (result) {
2535 if (empty($stripeacc)) {
2537 var stripe =
Stripe(
'<?php echo $stripearrayofkeys['publishable_key
']; // Defined into config.php?>');
2541 var stripe =
Stripe(
'<?php echo $stripearrayofkeys['publishable_key
']; // Defined into config.php?>', { stripeAccount:
'<?php echo $stripeacc; ?>' });
2546 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 2) {
2548 var cardButton = document.getElementById(
'buttontopay');
2549 var clientSecret = cardButton.dataset.secret;
2550 var options = { clientSecret: clientSecret };
2553 var elements = stripe.elements(options);
2558 var elements = stripe.elements();
2568 fontFamily:
'"Helvetica Neue", Helvetica, sans-serif',
2569 fontSmoothing:
'antialiased',
2577 iconColor:
'#fa755a'
2582 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 2) {
2584 var paymentElement = elements.create(
"payment");
2587 paymentElement.mount(
"#payment-element");
2590 var cardButton = document.getElementById(
'buttontopay');
2592 cardButton.addEventListener(
'click',
function(event) {
2593 console.log(
"We click on buttontopay");
2594 event.preventDefault();
2597 jQuery(
'#hourglasstopay').show();
2598 jQuery(
'#buttontopay').hide();
2600 stripe.confirmPayment({
2601 elements,confirmParams: {
2602 return_url:
'<?php echo $urlok; ?>',
2603 payment_method_data: {
2607 ?>, email:
'<?php echo dol_escape_js(GETPOST('email
', 'alpha
') ? GETPOST('email
', 'alpha
') : $object->thirdparty->email); ?>'<?php
2610 ?>, phone:
'<?php echo dol_escape_js($object->thirdparty->phone); ?>'<?php
2614 city:
'<?php echo dol_escape_js($object->thirdparty->town); ?>',
2615 <?php if ($object->thirdparty->country_code) {
2616 ?>country:
'<?php echo dol_escape_js($object->thirdparty->country_code); ?>',<?php
2618 line1:
'<?php echo dol_escape_js(preg_replace('/\s\s+/
', ' ', $object->thirdparty->address)); ?>',
2619 postal_code:
'<?php echo dol_escape_js($object->thirdparty->zip); ?>'
2625 save_payment_method:<?php
if ($stripecu) {
2632 ).then(
function(result) {
2633 console.log(result);
2635 console.log(
"Error on result of handleCardPayment");
2636 jQuery(
'#buttontopay').show();
2637 jQuery(
'#hourglasstopay').hide();
2639 var errorElement = document.getElementById(
'card-errors');
2640 console.log(result);
2641 errorElement.textContent = result.error.message;
2644 console.log(
"No error on result of handleCardPayment, so we submit the form");
2646 jQuery(
'#buttontopay').hide();
2647 jQuery(
'#hourglasstopay').show();
2649 jQuery(
'#payment-form').submit();
2657 var cardElement = elements.create(
'card', {style: style});
2660 cardElement.mount(
'#card-element');
2663 cardElement.addEventListener(
'change',
function(event) {
2664 var displayError = document.getElementById(
'card-errors');
2666 console.log(
"Show event error (like 'Incorrect card number', ...)");
2667 displayError.textContent =
event.error.message;
2669 console.log(
"Reset error message");
2670 displayError.textContent =
'';
2675 var cardholderName = document.getElementById(
'cardholder-name');
2676 var cardButton = document.getElementById(
'buttontopay');
2677 var clientSecret = cardButton.dataset.secret;
2679 cardButton.addEventListener(
'click',
function(event) {
2680 console.log(
"We click on buttontopay");
2681 event.preventDefault();
2683 if (cardholderName.value ==
'')
2685 console.log(
"Field Card holder is empty");
2686 var displayError = document.getElementById(
'card-errors');
2687 displayError.textContent =
'<?php print dol_escape_js($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardOwner"))); ?>';
2692 jQuery(
'#hourglasstopay').show();
2693 jQuery(
'#buttontopay').hide();
2695 stripe.handleCardPayment(
2696 clientSecret, cardElement, {
2697 payment_method_data: {
2699 name: cardholderName.value
2701 ?>, email:
'<?php echo dol_escape_js(GETPOST('email
', 'alpha
') ? GETPOST('email
', 'alpha
') : $object->thirdparty->email); ?>'<?php
2704 ?>, phone:
'<?php echo dol_escape_js($object->thirdparty->phone); ?>'<?php
2708 city:
'<?php echo dol_escape_js($object->thirdparty->town); ?>',
2709 <?php if ($object->thirdparty->country_code) {
2710 ?>country:
'<?php echo dol_escape_js($object->thirdparty->country_code); ?>',<?php
2712 line1:
'<?php echo dol_escape_js(preg_replace('/\s\s+/
', ' ', $object->thirdparty->address)); ?>',
2713 postal_code:
'<?php echo dol_escape_js($object->thirdparty->zip); ?>'
2719 save_payment_method:<?php
if ($stripecu) {
2725 ).then(
function(result) {
2726 console.log(result);
2728 console.log(
"Error on result of handleCardPayment");
2729 jQuery(
'#buttontopay').show();
2730 jQuery(
'#hourglasstopay').hide();
2732 var errorElement = document.getElementById(
'card-errors');
2733 errorElement.textContent = result.error.message;
2736 console.log(
"No error on result of handleCardPayment, so we submit the form");
2738 jQuery(
'#buttontopay').hide();
2739 jQuery(
'#hourglasstopay').show();
2741 jQuery(
'#payment-form').submit();
2759 'paymentmethod' => $paymentmethod,
2760 'amount' => $amount,
2761 'currency' => $currency,
2762 'tag' =>
GETPOST(
"tag",
'alpha'),
2763 'dopayment' =>
GETPOST(
'dopayment',
'alpha')
2765 $reshook = $hookmanager->executeHooks(
'doPayment', $parameters,
$object, $action);
2768 } elseif ($reshook > 0) {
2769 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()
Empty header.
Class to manage members of a foundation.
Class to manage members type.
Class to manage customers orders.
Class for ConferenceOrBoothAttendee.
Class to manage contracts.
Class to manage lines of contracts.
Class to manage invoices.
Class to manage payments of donations.
Class to manage products or services.
Class to manage third parties objects (customers, suppliers, prospects...)
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.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_print_error_email($prefixcode, $errormessage='', $errormessages=array(), $morecss='error', $email='')
Show a public email and error code to contact if technical error.
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print 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 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'))
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,...