41if (!defined(
'NOLOGIN')) {
44if (!defined(
'NOCSRFCHECK')) {
45 define(
"NOCSRFCHECK", 1);
47if (!defined(
'NOIPCHECK')) {
48 define(
'NOIPCHECK',
'1');
50if (!defined(
'NOBROWSERNOTIF')) {
51 define(
'NOBROWSERNOTIF',
'1');
57$entity = (!empty($_GET[
'entity']) ? (int) $_GET[
'entity'] : (!empty($_POST[
'entity']) ? (int) $_POST[
'entity'] : (!empty($_GET[
'e']) ? (int) $_GET[
'e'] : (!empty($_POST[
'e']) ? (int) $_POST[
'e'] : 1))));
58if (is_numeric($entity)) {
59 define(
"DOLENTITY", $entity);
63require
'../../main.inc.php';
64require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
65require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
66require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
67require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
68require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
69require_once DOL_DOCUMENT_ROOT.
'/societe/class/societeaccount.class.php';
70require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
71require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
83$langs->loadLangs(array(
"main",
"other",
"dict",
"bills",
"companies",
"errors",
"paybox",
"paypal",
"stripe"));
87$hookmanager->initHooks(array(
'newpayment'));
93$action =
GETPOST(
'action',
'aZ09');
102$suffix =
GETPOST(
"suffix",
'aZ09');
104if (!
GETPOST(
"currency",
'alpha')) {
105 $currency =
$conf->currency;
107 $currency =
GETPOST(
"currency",
'aZ09');
110$getpostlang =
GETPOST(
'lang',
'aZ09');
115 if (!
GETPOST(
"amount",
'alpha') && !$source) {
116 print $langs->trans(
'ErrorBadParameters').
" - amount or source";
119 if (is_numeric($amount) && !
GETPOST(
"tag",
'alpha') && !$source) {
120 print $langs->trans(
'ErrorBadParameters').
" - tag or source";
123 if ($source && !
GETPOST(
"ref",
'alpha')) {
124 print $langs->trans(
'ErrorBadParameters').
" - ref";
132$paymentintent =
null;
136if ($source ==
'organizedeventregistration') {
143 $resultinvoice = $invoice->fetch($invoiceid);
145 if ($resultinvoice <= 0) {
158 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"eventorganization_conferenceorboothattendee";
159 $sql .=
" WHERE fk_invoice = ".((int) $invoiceid);
161 $resql = $db->query($sql);
163 $obj = $db->fetch_object($resql);
165 $attendeeid = $obj->rowid;
169 if ($attendeeid > 0) {
170 $resultattendee = $attendee->fetch($attendeeid);
172 if ($resultattendee <= 0) {
175 $attendee->fetch_projet();
177 $amount =
price2num($invoice->total_ttc);
179 $thirdparty =
new Societe($db);
180 $resultthirdparty = $thirdparty->fetch($invoice->socid);
181 if ($resultthirdparty <= 0) {
188} elseif ($source ==
'boothlocation') {
192 $resultinvoice = $invoice->fetch($invoiceid);
193 if ($resultinvoice <= 0) {
196 $amount =
price2num($invoice->total_ttc);
198 $thirdparty =
new Societe($db);
199 $resultthirdparty = $thirdparty->fetch($invoice->socid);
200 if ($resultthirdparty <= 0) {
208$paymentmethod =
GETPOST(
'paymentmethod',
'alphanohtml') ?
GETPOST(
'paymentmethod',
'alphanohtml') :
'';
209$validpaymentmethod = array();
212foreach ($_POST as $key => $val) {
214 if (preg_match(
'/^dopayment_(.*)$/', $key, $reg)) {
215 $paymentmethod = $reg[1];
224$urlwithroot = DOL_MAIN_URL_ROOT;
226$urlok = $urlwithroot.
'/public/payment/paymentok.php?';
227$urlko = $urlwithroot.
'/public/payment/paymentko.php?';
230$ref = $REF =
GETPOST(
'ref',
'alpha');
232$FULLTAG =
GETPOST(
"fulltag",
'alpha');
233$SECUREKEY =
GETPOST(
"securekey");
236$PAYPAL_API_SANDBOX =
"";
237$PAYPAL_API_USER =
"";
238$PAYPAL_API_PASSWORD =
"";
239$PAYPAL_API_SIGNATURE =
"";
241if ($paymentmethod && !preg_match(
'/'.preg_quote(
'PM='.$paymentmethod,
'/').
'/', $FULLTAG)) {
242 $FULLTAG .= ($FULLTAG ?
'.' :
'').
'PM='.$paymentmethod;
246 $FULLTAG .= ($FULLTAG ?
'.' :
'').
'WS='.$ws;
249if (!empty($suffix)) {
250 $urlok .=
'suffix='.urlencode($suffix).
'&';
251 $urlko .=
'suffix='.urlencode($suffix).
'&';
254 $urlok .=
's='.urlencode($source).
'&';
255 $urlko .=
's='.urlencode($source).
'&';
258 $urlok .=
'ref='.urlencode($REF).
'&';
259 $urlko .=
'ref='.urlencode($REF).
'&';
262 $urlok .=
'tag='.urlencode($TAG).
'&';
263 $urlko .=
'tag='.urlencode($TAG).
'&';
265if (!empty($FULLTAG)) {
266 $urlok .=
'fulltag='.urlencode($FULLTAG).
'&';
267 $urlko .=
'fulltag='.urlencode($FULLTAG).
'&';
269if (!empty($SECUREKEY)) {
270 $urlok .=
'securekey='.urlencode($SECUREKEY).
'&';
271 $urlko .=
'securekey='.urlencode($SECUREKEY).
'&';
273if (!empty($entity)) {
274 $urlok .=
'e='.urlencode((
string) ($entity)).
'&';
275 $urlko .=
'e='.urlencode((
string) ($entity)).
'&';
277if (!empty($getpostlang)) {
278 $urlok .=
'lang='.urlencode($getpostlang).
'&';
279 $urlko .=
'lang='.urlencode($getpostlang).
'&';
281$urlok = preg_replace(
'/&$/',
'', $urlok);
282$urlko = preg_replace(
'/&$/',
'', $urlko);
289@phan-var-force string $PAYPAL_API_SANDBOX
290@phan-var-force string $PAYPAL_API_OK
291@phan-var-force string $PAYPAL_API_KO
294if ((empty($paymentmethod) || $paymentmethod ==
'paypal') && isModEnabled(
'paypal')) {
295 global $PAYPAL_API_SANDBOX, $PAYPAL_API_OK, $PAYPAL_API_KO, $PAYPAL_API_USER, $PAYPAL_API_PASSWORD, $PAYPAL_API_SIGNATURE;
296 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypal.lib.php';
297 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypalfunctions.lib.php';
303 $PAYPAL_API_OK = $urlok;
307 $PAYPAL_API_KO = $urlko;
309 if (empty($PAYPAL_API_USER)) {
310 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>.';
313 if (empty($PAYPAL_API_PASSWORD)) {
314 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>.';
317 if (empty($PAYPAL_API_SIGNATURE)) {
318 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>.';
325if ((empty($paymentmethod) || $paymentmethod ==
'stripe') && isModEnabled(
'stripe')) {
326 require_once DOL_DOCUMENT_ROOT.
'/stripe/config.php';
331$validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod);
335if ($tmpsource ==
'membersubscription') {
336 $tmpsource =
'member';
342 if ($tmpsource && $REF) {
346 if ($tmpsource != $source) {
353 $tokenisok = (
$conf->global->PAYMENT_SECURITY_TOKEN == $SECUREKEY);
360 dol_syslog(
"Warning: PAYMENT_SECURITY_ACCEPT_ANY_TOKEN is on", LOG_WARNING);
365 print
'<div class="error">Bad value for key.</div>';
371if (!empty($paymentmethod) && empty($validpaymentmethod[$paymentmethod])) {
372 print
'Payment module for payment method '.$paymentmethod.
' is not active';
375if (empty($validpaymentmethod)) {
376 print
'No active payment module (Paypal, Stripe, Paybox, ...)';
381$creditor = $mysoc->name;
382$paramcreditor =
'ONLINE_PAYMENT_CREDITOR';
383$paramcreditorlong =
'ONLINE_PAYMENT_CREDITOR_'.$suffix;
398dol_syslog(
"--- newpayment.php action = ".$action.
" paymentmethod=".$paymentmethod.
' amount='.$amount.
' newamount='.
GETPOST(
"newamount",
'alpha'), LOG_DEBUG, 0,
'_payment');
401if ($action ==
'dopayment') {
402 if ($paymentmethod ==
'paypal') {
404 $PAYPAL_PAYMENT_TYPE =
'Sale';
407 $origfulltag =
GETPOST(
"fulltag",
'alpha');
408 $shipToName =
GETPOST(
"shipToName",
'alpha');
409 $shipToStreet =
GETPOST(
"shipToStreet",
'alpha');
410 $shipToCity =
GETPOST(
"shipToCity",
'alpha');
411 $shipToState =
GETPOST(
"shipToState",
'alpha');
412 $shipToCountryCode =
GETPOST(
"shipToCountryCode",
'alpha');
413 $shipToZip =
GETPOST(
"shipToZip",
'alpha');
414 $shipToStreet2 =
GETPOST(
"shipToStreet2",
'alpha');
415 $phoneNum =
GETPOST(
"phoneNum",
'alpha');
416 $email =
GETPOST(
"email",
'alpha');
417 $desc =
GETPOST(
"desc",
'alpha');
421 if ($shipToCountryCode ==
'ID' && !preg_match(
'/\-/', $shipToState)) {
422 $shipToState =
'ID-'.$shipToState;
425 if (empty($PAYPAL_API_PRICE) || !is_numeric($PAYPAL_API_PRICE)) {
426 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount"));
430 } elseif (!$origfulltag) {
431 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"PaymentCode"));
436 dol_syslog(
"newpayment.php call paypal api and do redirect", LOG_DEBUG);
439 $PAYPAL_API_DEVISE =
"USD";
440 if (!empty($currency)) {
441 $PAYPAL_API_DEVISE = $currency;
446 dol_syslog(
"PAYPAL_API_USER: $PAYPAL_API_USER", LOG_DEBUG);
447 dol_syslog(
"PAYPAL_API_PASSWORD: ".preg_replace(
'/./',
'*', $PAYPAL_API_PASSWORD), LOG_DEBUG);
448 dol_syslog(
"PAYPAL_API_SIGNATURE: $PAYPAL_API_SIGNATURE", LOG_DEBUG);
449 dol_syslog(
"PAYPAL_API_SANDBOX: $PAYPAL_API_SANDBOX", LOG_DEBUG);
450 dol_syslog(
"PAYPAL_API_OK: $PAYPAL_API_OK", LOG_DEBUG);
451 dol_syslog(
"PAYPAL_API_KO: $PAYPAL_API_KO", LOG_DEBUG);
452 dol_syslog(
"PAYPAL_API_PRICE: $PAYPAL_API_PRICE", LOG_DEBUG);
453 dol_syslog(
"PAYPAL_API_DEVISE: $PAYPAL_API_DEVISE", LOG_DEBUG);
455 dol_syslog(
"shipToName: $shipToName", LOG_DEBUG);
456 dol_syslog(
"shipToStreet: $shipToStreet", LOG_DEBUG);
457 dol_syslog(
"shipToCity: $shipToCity", LOG_DEBUG);
458 dol_syslog(
"shipToState: $shipToState", LOG_DEBUG);
459 dol_syslog(
"shipToCountryCode: $shipToCountryCode", LOG_DEBUG);
460 dol_syslog(
"shipToZip: $shipToZip", LOG_DEBUG);
461 dol_syslog(
"shipToStreet2: $shipToStreet2", LOG_DEBUG);
466 dol_syslog(
"SCRIPT_URI: ".(empty($_SERVER[
"SCRIPT_URI"]) ?
'' : $_SERVER[
"SCRIPT_URI"]), LOG_DEBUG);
469 $mesg =
print_paypal_redirect($PAYPAL_API_PRICE, $PAYPAL_API_DEVISE, $PAYPAL_PAYMENT_TYPE, $PAYPAL_API_OK, $PAYPAL_API_KO, $FULLTAG);
476 if ($paymentmethod ==
'paybox') {
481 $origfulltag =
GETPOST(
"fulltag",
'alpha');
484 $urlok = preg_replace(
'/securekey=[^&]+&?/',
'', $urlok);
485 $urlko = preg_replace(
'/securekey=[^&]+&?/',
'', $urlko);
487 if (empty($PRICE) || !is_numeric($PRICE)) {
488 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount"));
489 } elseif (empty($email)) {
490 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ONLINE_PAYMENT_SENDEMAIL"));
492 $mesg = $langs->trans(
"ErrorBadEMail", $email);
493 } elseif (!$origfulltag) {
494 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"PaymentCode"));
496 $mesg =
'Error urlok too long '.$urlok.
' (Paybox requires 150, found '.strlen($urlok).
')';
498 $mesg =
'Error urlko too long '.$urlko.
' (Paybox requires 150, found '.strlen($urlok).
')';
502 dol_syslog(
"newpayment.php call paybox api and do redirect", LOG_DEBUG);
504 include_once DOL_DOCUMENT_ROOT.
'/paybox/lib/paybox.lib.php';
512 if ($paymentmethod ==
'stripe') {
513 if (
GETPOST(
'newamount',
'alpha')) {
516 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount")),
null,
'errors');
526if ($action ==
'charge' && isModEnabled(
'stripe')) {
527 $amountstripe = (float) $amount;
531 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
532 if (!in_array($currency, $arrayzerounitcurrency)) {
533 $amountstripe *= 100;
536 dol_syslog(
"--- newpayment.php Execute action = ".$action.
" STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION=".
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION'), LOG_DEBUG, 0,
'_payment');
537 dol_syslog(
"GET=".var_export($_GET,
true), LOG_DEBUG, 0,
'_payment');
538 dol_syslog(
"POST=".var_export($_POST,
true), LOG_DEBUG, 0,
'_payment');
540 $stripeToken =
GETPOST(
"stripeToken",
'alpha');
541 $email =
GETPOST(
"email",
'alpha');
545 $vatnumber =
GETPOST(
'vatnumber',
'alpha');
546 $savesource = GETPOSTISSET(
'savesource') ?
GETPOSTINT(
'savesource') : 1;
548 dol_syslog(
"POST stripeToken = ".$stripeToken, LOG_DEBUG, 0,
'_payment');
549 dol_syslog(
"POST email = ".$email, LOG_DEBUG, 0,
'_payment');
550 dol_syslog(
"POST thirdparty_id = ".$thirdparty_id, LOG_DEBUG, 0,
'_payment');
551 dol_syslog(
"POST vatnumber = ".$vatnumber, LOG_DEBUG, 0,
'_payment');
558 if (!
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION')) {
561 'dol_version' => DOL_VERSION,
562 'dol_entity' =>
$conf->entity,
563 'dol_company' => $mysoc->name,
564 'dol_tax_num' => $vatnumber,
568 if (!empty($thirdparty_id)) {
569 $metadata[
"dol_thirdparty_id"] = $thirdparty_id;
572 if ($thirdparty_id > 0) {
573 dol_syslog(
"Search existing Stripe customer profile for thirdparty_id=".$thirdparty_id, LOG_DEBUG, 0,
'_payment');
575 $service =
'StripeTest';
578 $service =
'StripeLive';
582 $thirdparty =
new Societe($db);
583 $thirdparty->fetch($thirdparty_id);
586 include_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
587 $stripe =
new Stripe($db);
588 $stripeacc = $stripe->getStripeAccount($service);
589 $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 1);
590 if (empty($customer)) {
592 dol_syslog(
'Failed to get/create stripe customer for thirdparty id = '.$thirdparty_id.
' and servicestatus = '.$servicestatus.
': '.$stripe->error, LOG_ERR, 0,
'_payment');
593 setEventMessages(
'Failed to get/create stripe customer for thirdparty id = '.$thirdparty_id.
' and servicestatus = '.$servicestatus.
': '.$stripe->error,
null,
'errors');
600 $card = $customer->sources->create(array(
"source" => $stripeToken,
"metadata" => $metadata));
602 $card = $stripeToken;
607 dol_syslog(
'Failed to create card record', LOG_WARNING, 0,
'_payment');
611 if (!empty($FULLTAG)) {
612 $metadata[
"FULLTAG"] = $FULLTAG;
614 if (!empty($dol_id)) {
615 $metadata[
"dol_id"] = $dol_id;
617 if (!empty($dol_type)) {
618 $metadata[
"dol_type"] = $dol_type;
621 dol_syslog(
"Create charge on card ".$card->id, LOG_DEBUG, 0,
'_payment');
622 $charge = \Stripe\Charge::create(array(
623 'amount' =>
price2num($amountstripe,
'MU'),
624 'currency' => $currency,
626 'description' =>
'Stripe payment: '.$FULLTAG.
' ref='.$ref,
627 'metadata' => $metadata,
628 'customer' => $customer->id,
630 'statement_descriptor_suffix' =>
dol_trunc($FULLTAG, 10,
'right',
'UTF-8', 1),
631 ), array(
"idempotency_key" =>
"$FULLTAG",
"stripe_account" =>
"$stripeacc"));
633 if (empty($charge)) {
635 dol_syslog(
'Failed to charge card', LOG_WARNING, 0,
'_payment');
642 $vatcleaned = $vatnumber ? $vatnumber :
null;
653 dol_syslog(
"Create anonymous customer card profile", LOG_DEBUG, 0,
'_payment');
655 $customer = \Stripe\Customer::create(array(
657 'description' => ($email ?
'Anonymous customer for '.$email :
'Anonymous customer'),
658 'metadata' => $metadata,
659 'source' => $stripeToken
678 if (!empty($FULLTAG)) {
679 $metadata[
"FULLTAG"] = $FULLTAG;
681 if (!empty($dol_id)) {
682 $metadata[
"dol_id"] = $dol_id;
684 if (!empty($dol_type)) {
685 $metadata[
"dol_type"] = $dol_type;
690 dol_syslog(
"Create charge", LOG_DEBUG, 0,
'_payment');
691 $charge = \Stripe\Charge::create(array(
692 'customer' => $customer->id,
693 'amount' =>
price2num($amountstripe,
'MU'),
694 'currency' => $currency,
696 'description' =>
'Stripe payment: '.$FULLTAG.
' ref='.$ref,
697 'metadata' => $metadata,
698 'statement_descriptor' =>
dol_trunc($FULLTAG, 10,
'right',
'UTF-8', 1),
699 ), array(
"idempotency_key" => (
string) $FULLTAG,
"stripe_account" => (
string) $stripeacc));
701 if (empty($charge)) {
703 dol_syslog(
'Failed to charge card', LOG_WARNING, 0,
'_payment');
710 $body = $e->getJsonBody();
711 $err = $body[
'error'];
713 print(
'Status is:'.$e->getHttpStatus().
"\n");
714 print(
'Type is:'.$err[
'type'].
"\n");
715 print(
'Code is:'.$err[
'code'].
"\n");
717 print(
'Param is:'.$err[
'param'].
"\n");
718 print(
'Message is:'.$err[
'message'].
"\n");
721 $errormessage =
"ErrorCard ".$e->getMessage().
" err=".var_export($err,
true);
722 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
728 $errormessage =
"ErrorRateLimit ".$e->getMessage();
729 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
735 $errormessage =
"ErrorInvalidRequest ".$e->getMessage();
736 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
743 $errormessage =
"ErrorAuthentication ".$e->getMessage();
744 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
750 $errormessage =
"ErrorApiConnection ".$e->getMessage();
751 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
758 $errormessage =
"ErrorBase ".$e->getMessage();
759 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
765 $errormessage =
"ErrorException ".$e->getMessage();
766 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
773 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION')) {
774 $service =
'StripeTest';
777 $service =
'StripeLive';
780 include_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
781 $stripe =
new Stripe($db);
782 $stripeacc = $stripe->getStripeAccount($service);
786 $paymentintent_id =
GETPOST(
"paymentintent_id",
"alpha");
789 global $stripearrayofkeysbyenv;
790 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
793 if (empty($stripeacc)) {
794 $paymentintent = \Stripe\PaymentIntent::retrieve($paymentintent_id);
796 $paymentintent = \Stripe\PaymentIntent::retrieve($paymentintent_id, array(
"stripe_account" => $stripeacc));
800 $errormessage =
"CantRetrievePaymentIntent ".$e->getMessage();
801 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
806 if ($paymentintent->status !=
'succeeded') {
808 $errormessage =
"StatusOfRetrievedIntent is not succeeded: ".$paymentintent->status;
809 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
819 if (!empty($paymentintent->currency) && !empty($paymentintent->amount)) {
820 $currency = strtoupper($paymentintent->currency);
821 $amount = $paymentintent->amount;
825 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
826 if (!in_array($currency, $arrayzerounitcurrency)) {
836 $_SESSION[
"onlinetoken"] = $stripeToken;
837 $_SESSION[
"FinalPaymentAmt"] = $amount;
838 $_SESSION[
"currencyCodeType"] = $currency;
839 $_SESSION[
"paymentType"] =
'';
840 $_SESSION[
'ipaddress'] = ($remoteip ? $remoteip :
'unknown');
841 $_SESSION[
'payerID'] = is_object($customer) ? $customer->id :
'';
842 $_SESSION[
'TRANSACTIONID'] = (is_object($charge) ? $charge->id : (is_object($paymentintent) ? $paymentintent->id :
''));
843 $_SESSION[
'errormessage'] = $errormessage;
845 dol_syslog(
"Action charge stripe STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION=".
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION').
" ip=".$remoteip, LOG_DEBUG, 0,
'_payment');
846 dol_syslog(
"onlinetoken=".$_SESSION[
"onlinetoken"].
" FinalPaymentAmt=".$_SESSION[
"FinalPaymentAmt"].
" currencyCodeType=".$_SESSION[
"currencyCodeType"].
" payerID=".$_SESSION[
'payerID'].
" TRANSACTIONID=".$_SESSION[
'TRANSACTIONID'], LOG_DEBUG, 0,
'_payment');
847 dol_syslog(
"FULLTAG=".$FULLTAG, LOG_DEBUG, 0,
'_payment');
848 dol_syslog(
"error=".$error.
" errormessage=".$errormessage, LOG_DEBUG, 0,
'_payment');
849 dol_syslog(
"_SERVER[SERVER_NAME] = ".(empty($_SERVER[
"SERVER_NAME"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_NAME"])), LOG_DEBUG, 0,
'_payment');
850 dol_syslog(
"_SERVER[SERVER_ADDR] = ".(empty($_SERVER[
"SERVER_ADDR"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_ADDR"])), LOG_DEBUG, 0,
'_payment');
851 dol_syslog(
"Now call the redirect to paymentok or paymentko, URL = ".($error ? $urlko : $urlok), LOG_DEBUG, 0,
'_payment');
854 header(
"Location: ".$urlko);
857 header(
"Location: ".$urlok);
864 'paymentmethod' => $paymentmethod,
865 'validpaymentmethod' => &$validpaymentmethod
867$reshook = $hookmanager->executeHooks(
'doPayment', $parameters,
$object, $action);
870} elseif ($reshook > 0) {
871 print $hookmanager->resPrint;
880$form =
new Form($db);
884 $head =
'<link rel="stylesheet" type="text/css" href="' .
getDolGlobalString(
'ONLINE_PAYMENT_CSS_URL').
'?lang='.(!empty($getpostlang) ? $getpostlang : $langs->defaultlang).
'">'.
"\n";
887$conf->dol_hide_topmenu = 1;
888$conf->dol_hide_leftmenu = 1;
890$replacemainarea = (empty(
$conf->dol_hide_leftmenu) ?
'<div>' :
'').
'<div>';
891llxHeader($head, $langs->trans(
"PaymentForm"),
'',
'', 0, 0,
'',
'',
'',
'onlinepaymentbody', $replacemainarea);
893dol_syslog(
"newpayment.php show page source=".$source.
" paymentmethod=".$paymentmethod.
' amount='.$amount.
' newamount='.
GETPOST(
"newamount",
'alpha').
" ref=".$ref, LOG_DEBUG, 0,
'_payment');
894dol_syslog(
"_SERVER[SERVER_NAME] = ".(empty($_SERVER[
"SERVER_NAME"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_NAME"])), LOG_DEBUG, 0,
'_payment');
895dol_syslog(
"_SERVER[SERVER_ADDR] = ".(empty($_SERVER[
"SERVER_ADDR"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_ADDR"])), LOG_DEBUG, 0,
'_payment');
898if ($source && in_array($ref, array(
'member_ref',
'contractline_ref',
'invoice_ref',
'order_ref',
'donation_ref',
''))) {
899 $langs->load(
"errors");
900 dol_print_error_email(
'BADREFINPAYMENTFORM', $langs->trans(
"ErrorBadLinkSourceSetButBadValueForRef", $source, $ref));
909if ((empty($paymentmethod) || $paymentmethod ==
'paypal') && isModEnabled(
'paypal') && (
getDolGlobalString(
'PAYPAL_API_SANDBOX') ||
GETPOSTINT(
'forcesandbox'))) {
910 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Paypal'), array(),
'warning');
912if ((empty($paymentmethod) || $paymentmethod ==
'stripe') && isModEnabled(
'stripe') && (!
getDolGlobalString(
'STRIPE_LIVE') ||
GETPOSTINT(
'forcesandbox'))) {
913 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Stripe'), array(),
'warning');
917print
'<span id="dolpaymentspan"></span>'.
"\n";
918print
'<div class="center">'.
"\n";
919print
'<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
920print
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
921print
'<input type="hidden" name="action" value="dopayment">'.
"\n";
922print
'<input type="hidden" name="tag" value="'.GETPOST(
"tag",
'alpha').
'">'.
"\n";
923print
'<input type="hidden" name="suffix" value="'.dol_escape_htmltag($suffix).
'">'.
"\n";
924print
'<input type="hidden" name="securekey" value="'.dol_escape_htmltag($SECUREKEY).
'">'.
"\n";
925print
'<input type="hidden" name="e" value="'.$entity.
'" />';
926print
'<input type="hidden" name="forcesandbox" value="'.GETPOSTINT(
'forcesandbox').
'" />';
927print
'<input type="hidden" name="lang" value="'.$getpostlang.
'">';
928print
'<input type="hidden" name="ws" value="'.$ws.
'">';
934$logosmall = $mysoc->logo_small;
936$paramlogo =
'ONLINE_PAYMENT_LOGO_'.$suffix;
946if (!empty($logosmall) && is_readable(
$conf->mycompany->dir_output.
'/logos/thumbs/'.$logosmall)) {
947 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
948 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
949} elseif (!empty($logo) && is_readable(
$conf->mycompany->dir_output.
'/logos/'.$logo)) {
950 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
951 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
955if ($urllogo && !$ws) {
956 print
'<div class="backgreypublicpayment">';
957 print
'<div class="logopublicpayment">';
958 print
'<img id="dolpaymentlogo" src="'.$urllogo.
'"';
962 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>';
965} elseif ($creditor && !$ws) {
966 print
'<div class="backgreypublicpayment">';
967 print
'<div class="logopublicpayment">';
973 print
'<div class="backimagepublicpayment">';
974 print
'<img id="idMAIN_IMAGE_PUBLIC_PAYMENT" src="'.getDolGlobalString(
'MAIN_IMAGE_PUBLIC_PAYMENT').
'">';
981print
'<!-- Form to send a payment -->'.
"\n";
982print
'<!-- creditor = '.dol_escape_htmltag($creditor).
' -->'.
"\n";
984if (isModEnabled(
'paypal')) {
985 print
'<!-- PAYPAL_API_SANDBOX = '.getDolGlobalString(
'PAYPAL_API_SANDBOX').
' -->'.
"\n";
986 print
'<!-- PAYPAL_API_INTEGRAL_OR_PAYPALONLY = '.getDolGlobalString(
'PAYPAL_API_INTEGRAL_OR_PAYPALONLY').
' -->'.
"\n";
988if (isModEnabled(
'paybox')) {
989 print
'<!-- PAYBOX_CGI_URL = '.getDolGlobalString(
'PAYBOX_CGI_URL_V2').
' -->'.
"\n";
991if (isModEnabled(
'stripe')) {
992 print
'<!-- STRIPE_LIVE = '.getDolGlobalString(
'STRIPE_LIVE').
' -->'.
"\n";
994print
'<!-- urlok = '.$urlok.
' -->'.
"\n";
995print
'<!-- urlko = '.$urlko.
' -->'.
"\n";
999print
'<table id="dolpublictable" summary="Payment form" class="center">'.
"\n";
1004 $langs->load(
"members");
1005 if (preg_match(
'/^\((.*)\)$/',
$conf->global->PAYMENT_NEWFORM_TEXT, $reg)) {
1006 $text .= $langs->trans($reg[1]).
"<br>\n";
1010 $text =
'<tr><td align="center"><br>'.$text.
'<br></td></tr>'.
"\n";
1013 $text .=
'<tr><td class="textpublicpayment"><br><strong>'.$langs->trans(
"WelcomeOnPaymentPage").
'</strong></td></tr>'.
"\n";
1014 $text .=
'<tr><td class="textpublicpayment"><span class="opacitymedium">'.$langs->trans(
"ThisScreenAllowsYouToPay", $creditor).
'</span><br><br></td></tr>'.
"\n";
1019print
'<tr><td align="center">';
1020print
'<table class="centpercent left" id="tablepublicpayment">';
1021print
'<tr class="hideonsmartphone"><td colspan="2" align="left" class="opacitymedium">'.$langs->trans(
"ThisIsInformationOnPayment").
' :</td></tr>'.
"\n";
1034 $tag =
GETPOST(
"tag",
'alpha');
1035 if (
GETPOST(
'fulltag',
'alpha')) {
1036 $fulltag =
GETPOST(
'fulltag',
'alpha');
1038 $fulltag =
"TAG=".$tag;
1042 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
1043 print
'</td><td class="CTableRow2">';
1044 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1045 print
'<b>'.$creditor.
'</b>';
1046 print
'<input type="hidden" name="creditor" value="'.$creditor.
'">';
1047 print
'</td></tr>'.
"\n";
1050 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Amount");
1051 if (empty($amount)) {
1052 print
' ('.$langs->trans(
"ToComplete").
')';
1054 print
'</td><td class="CTableRow2">';
1055 if (empty($amount) || !is_numeric($amount)) {
1056 print
'<input type="hidden" name="amount" value="'.price2num(
GETPOST(
"amount",
'alpha'),
'MT').
'">';
1057 print
'<input class="flat maxwidth75" type="text" name="newamount" value="'.price2num(
GETPOST(
"newamount",
"alpha"),
'MT').
'">';
1059 print
' <b>'.$langs->trans(
"Currency".$currency).
'</b>';
1061 print
'<b class="amount">'.price($amount, 1, $langs, 1, -1, -1, $currency).
'</b>';
1062 print
'<input type="hidden" name="amount" value="'.$amount.
'">';
1063 print
'<input type="hidden" name="newamount" value="'.$amount.
'">';
1065 print
'<input type="hidden" name="currency" value="'.$currency.
'">';
1066 print
'</td></tr>'.
"\n";
1069 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentCode");
1070 print
'</td><td class="CTableRow2"><b style="word-break: break-all;">'.$fulltag.
'</b>';
1071 print
'<input type="hidden" name="tag" value="'.$tag.
'">';
1072 print
'<input type="hidden" name="fulltag" value="'.$fulltag.
'">';
1073 print
'</td></tr>'.
"\n";
1081if ($source ==
'order') {
1083 $langs->load(
"orders");
1085 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
1088 $result = $order->fetch(0, $ref);
1090 $mesg = $order->error;
1093 $result = $order->fetch_thirdparty($order->socid);
1097 if ($action !=
'dopayment') {
1098 $amount = $order->total_ttc;
1099 if (
GETPOST(
"amount",
'alpha')) {
1100 $amount =
GETPOST(
"amount",
'alpha');
1106 if (
GETPOST(
'fulltag',
'alpha')) {
1107 $fulltag =
GETPOST(
'fulltag',
'alpha');
1109 $fulltag =
'ORD='.$order->id.
'.CUS='.$order->thirdparty->id;
1112 $fulltag .=
'.TAG='.$TAG;
1118 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
1119 print
'</td><td class="CTableRow2">';
1120 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1121 print
'<b>'.$creditor.
'</b>';
1122 print
'<input type="hidden" name="creditor" value="'.$creditor.
'">';
1123 print
'</td></tr>'.
"\n";
1126 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"ThirdParty");
1127 print
'</td><td class="CTableRow2">';
1128 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1129 print
'<b>'.$order->thirdparty->name.
'</b>';
1130 print
'</td></tr>'.
"\n";
1133 $text =
'<b>'.$langs->trans(
"PaymentOrderRef", $order->ref).
'</b>';
1134 if (
GETPOST(
'desc',
'alpha')) {
1135 $text =
'<b>'.$langs->trans(
GETPOST(
'desc',
'alpha')).
'</b>';
1137 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Designation");
1138 print
'</td><td class="CTableRow2">'.$text;
1139 print
'<input type="hidden" name="s" value="'.dol_escape_htmltag($source).
'">';
1140 print
'<input type="hidden" name="ref" value="'.dol_escape_htmltag($order->ref).
'">';
1141 print
'<input type="hidden" name="dol_id" value="'.dol_escape_htmltag((
string) $order->id).
'">';
1142 $directdownloadlink = $order->getLastMainDocLink(
'commande');
1143 if ($directdownloadlink) {
1144 print
'<br><a href="'.$directdownloadlink.
'" rel="nofollow noopener">';
1145 print
img_mime($order->last_main_doc,
'');
1146 print $langs->trans(
"DownloadDocument").
'</a>';
1148 print
'</td></tr>'.
"\n";
1151 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Amount");
1152 if (empty($amount)) {
1153 print
' ('.$langs->trans(
"ToComplete").
')';
1155 print
'</td><td class="CTableRow2">';
1156 if (empty($amount) || !is_numeric($amount)) {
1157 print
'<input type="hidden" name="amount" value="'.price2num(
GETPOST(
"amount",
'alpha'),
'MT').
'">';
1158 print
'<input class="flat maxwidth75" type="text" name="newamount" value="'.price2num(
GETPOST(
"newamount",
"alpha"),
'MT').
'">';
1160 print
' <b>'.$langs->trans(
"Currency".$currency).
'</b>';
1162 print
'<b class="amount">'.price($amount, 1, $langs, 1, -1, -1, $currency).
'</b>';
1163 print
'<input type="hidden" name="amount" value="'.$amount.
'">';
1164 print
'<input type="hidden" name="newamount" value="'.$amount.
'">';
1166 print
'<input type="hidden" name="currency" value="'.$currency.
'">';
1167 print
'</td></tr>'.
"\n";
1170 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentCode");
1171 print
'</td><td class="CTableRow2"><b style="word-break: break-all;">'.$fulltag.
'</b>';
1172 print
'<input type="hidden" name="tag" value="'.dol_escape_htmltag($tag).
'">';
1173 print
'<input type="hidden" name="fulltag" value="'.dol_escape_htmltag($fulltag).
'">';
1174 print
'</td></tr>'.
"\n";
1177 $shipToName = $order->thirdparty->name;
1178 $shipToStreet = $order->thirdparty->address;
1179 $shipToCity = $order->thirdparty->town;
1180 $shipToState = $order->thirdparty->state_code;
1181 $shipToCountryCode = $order->thirdparty->country_code;
1182 $shipToZip = $order->thirdparty->zip;
1183 $shipToStreet2 =
'';
1184 $phoneNum = $order->thirdparty->phone;
1185 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1186 print
'<input type="hidden" name="shipToName" value="'.dol_escape_htmltag($shipToName).
'">'.
"\n";
1187 print
'<input type="hidden" name="shipToStreet" value="'.dol_escape_htmltag($shipToStreet).
'">'.
"\n";
1188 print
'<input type="hidden" name="shipToCity" value="'.dol_escape_htmltag($shipToCity).
'">'.
"\n";
1189 print
'<input type="hidden" name="shipToState" value="'.dol_escape_htmltag($shipToState).
'">'.
"\n";
1190 print
'<input type="hidden" name="shipToCountryCode" value="'.dol_escape_htmltag($shipToCountryCode).
'">'.
"\n";
1191 print
'<input type="hidden" name="shipToZip" value="'.dol_escape_htmltag($shipToZip).
'">'.
"\n";
1192 print
'<input type="hidden" name="shipToStreet2" value="'.dol_escape_htmltag($shipToStreet2).
'">'.
"\n";
1193 print
'<input type="hidden" name="phoneNum" value="'.dol_escape_htmltag($phoneNum).
'">'.
"\n";
1195 print
'<!-- Shipping address not complete, so we don t use it -->'.
"\n";
1197 if (is_object($order->thirdparty)) {
1198 print
'<input type="hidden" name="thirdparty_id" value="'.$order->thirdparty->id.
'">'.
"\n";
1200 print
'<input type="hidden" name="email" value="'.$order->thirdparty->email.
'">'.
"\n";
1201 print
'<input type="hidden" name="vatnumber" value="'.dol_escape_htmltag($order->thirdparty->tva_intra).
'">'.
"\n";
1202 $labeldesc = $langs->trans(
"Order").
' '.$order->ref;
1203 if (
GETPOST(
'desc',
'alpha')) {
1204 $labeldesc =
GETPOST(
'desc',
'alpha');
1206 print
'<input type="hidden" name="desc" value="'.dol_escape_htmltag($labeldesc).
'">'.
"\n";
1211if ($source ==
'invoice') {
1213 $langs->load(
"bills");
1214 $form->load_cache_types_paiements();
1216 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1219 $result = $invoice->fetch(0, $ref);
1221 $mesg = $invoice->error;
1224 $result = $invoice->fetch_thirdparty($invoice->socid);
1228 if ($action !=
'dopayment') {
1229 $amount =
price2num($invoice->total_ttc - ($invoice->getSommePaiement() + $invoice->getSumCreditNotesUsed() + $invoice->getSumDepositsUsed()));
1230 if (
GETPOST(
"amount",
'alpha')) {
1231 $amount =
GETPOST(
"amount",
'alpha');
1236 if (
GETPOST(
'fulltag',
'alpha')) {
1237 $fulltag =
GETPOST(
'fulltag',
'alpha');
1239 $fulltag =
'INV='.$invoice->id.
'.CUS='.$invoice->thirdparty->id;
1242 $fulltag .=
'.TAG='.$TAG;
1248 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
1249 print
'</td><td class="CTableRow2">';
1250 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1251 print
'<b>'.$creditor.
'</b>';
1252 print
'<input type="hidden" name="creditor" value="'.dol_escape_htmltag($creditor).
'">';
1253 print
'</td></tr>'.
"\n";
1256 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"ThirdParty");
1257 print
'</td><td class="CTableRow2">';
1258 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1259 print
'<b>'.$invoice->thirdparty->name.
'</b>';
1260 print
'</td></tr>'.
"\n";
1263 $text =
'<b>'.$langs->trans(
"PaymentInvoiceRef", $invoice->ref).
'</b>';
1264 if (
GETPOST(
'desc',
'alpha')) {
1265 $text =
'<b>'.$langs->trans(
GETPOST(
'desc',
'alpha')).
'</b>';
1267 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Designation");
1268 print
'</td><td class="CTableRow2">'.$text;
1269 print
'<input type="hidden" name="s" value="'.dol_escape_htmltag($source).
'">';
1270 print
'<input type="hidden" name="ref" value="'.dol_escape_htmltag($invoice->ref).
'">';
1271 print
'<input type="hidden" name="dol_id" value="'.dol_escape_htmltag((
string) $invoice->id).
'">';
1272 $directdownloadlink = $invoice->getLastMainDocLink(
'facture');
1273 if ($directdownloadlink) {
1274 print
'<br><a href="'.$directdownloadlink.
'">';
1275 print
img_mime($invoice->last_main_doc,
'');
1276 print $langs->trans(
"DownloadDocument").
'</a>';
1278 print
'</td></tr>'.
"\n";
1281 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentAmount");
1282 if (empty($amount) && empty(
$object->paye)) {
1283 print
' ('.$langs->trans(
"ToComplete").
')';
1285 print
'</td><td class="CTableRow2">';
1286 if (
$object->type == $object::TYPE_CREDIT_NOTE) {
1287 print
'<b>'.$langs->trans(
"CreditNote").
'</b>';
1288 } elseif (empty(
$object->paye)) {
1289 if (empty($amount) || !is_numeric($amount)) {
1290 print
'<input type="hidden" name="amount" value="'.price2num(
GETPOST(
"amount",
'alpha'),
'MT').
'">';
1291 print
'<input class="flat maxwidth75" type="text" name="newamount" value="'.price2num(
GETPOST(
"newamount",
"alpha"),
'MT').
'">';
1292 print
' <b>'.$langs->trans(
"Currency".$currency).
'</b>';
1294 print
'<b class="amount">'.price($amount, 1, $langs, 1, -1, -1, $currency).
'</b>';
1295 print
'<input type="hidden" name="amount" value="'.$amount.
'">';
1296 print
'<input type="hidden" name="newamount" value="'.$amount.
'">';
1299 print
'<b class="amount">'.price(
$object->total_ttc, 1, $langs, 1, -1, -1, $currency).
'</b>';
1301 print
'<input type="hidden" name="currency" value="'.$currency.
'">';
1302 print
'</td></tr>'.
"\n";
1305 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentCode");
1306 print
'</td><td class="CTableRow2"><b style="word-break: break-all;">'.$fulltag.
'</b>';
1307 print
'<input type="hidden" name="tag" value="'.(empty($tag) ?
'' : $tag).
'">';
1308 print
'<input type="hidden" name="fulltag" value="'.$fulltag.
'">';
1309 print
'</td></tr>'.
"\n";
1312 if ($invoice->status == $invoice::STATUS_VALIDATED && $invoice->mode_reglement_id > 0 && $form->cache_types_paiements[$invoice->mode_reglement_id][
"code"] ==
"VIR") {
1313 print
'<tr class="CTableRow2 center"><td class="CTableRow2" colspan="2">';
1314 print
'<div class="warning maxwidth1000">';
1315 print $langs->trans(
"PayOfBankTransferInvoice");
1317 print
'</td></tr>'.
"\n";
1321 $shipToName = $invoice->thirdparty->name;
1322 $shipToStreet = $invoice->thirdparty->address;
1323 $shipToCity = $invoice->thirdparty->town;
1324 $shipToState = $invoice->thirdparty->state_code;
1325 $shipToCountryCode = $invoice->thirdparty->country_code;
1326 $shipToZip = $invoice->thirdparty->zip;
1327 $shipToStreet2 =
'';
1328 $phoneNum = $invoice->thirdparty->phone;
1329 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1330 print
'<input type="hidden" name="shipToName" value="'.$shipToName.
'">'.
"\n";
1331 print
'<input type="hidden" name="shipToStreet" value="'.$shipToStreet.
'">'.
"\n";
1332 print
'<input type="hidden" name="shipToCity" value="'.$shipToCity.
'">'.
"\n";
1333 print
'<input type="hidden" name="shipToState" value="'.$shipToState.
'">'.
"\n";
1334 print
'<input type="hidden" name="shipToCountryCode" value="'.$shipToCountryCode.
'">'.
"\n";
1335 print
'<input type="hidden" name="shipToZip" value="'.$shipToZip.
'">'.
"\n";
1336 print
'<input type="hidden" name="shipToStreet2" value="'.$shipToStreet2.
'">'.
"\n";
1337 print
'<input type="hidden" name="phoneNum" value="'.$phoneNum.
'">'.
"\n";
1339 print
'<!-- Shipping address not complete, so we don t use it -->'.
"\n";
1341 if (is_object($invoice->thirdparty)) {
1342 print
'<input type="hidden" name="thirdparty_id" value="'.$invoice->thirdparty->id.
'">'.
"\n";
1344 print
'<input type="hidden" name="email" value="'.$invoice->thirdparty->email.
'">'.
"\n";
1345 print
'<input type="hidden" name="vatnumber" value="'.$invoice->thirdparty->tva_intra.
'">'.
"\n";
1346 $labeldesc = $langs->trans(
"Invoice").
' '.$invoice->ref;
1347 if (
GETPOST(
'desc',
'alpha')) {
1348 $labeldesc =
GETPOST(
'desc',
'alpha');
1350 print
'<input type="hidden" name="desc" value="'.dol_escape_htmltag($labeldesc).
'">'.
"\n";
1354if ($source ==
'contractline') {
1356 $langs->load(
"contracts");
1358 require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
1363 $result = $contractline->fetch(0, $ref);
1365 $mesg = $contractline->error;
1368 if ($contractline->fk_contrat > 0) {
1369 $result = $contract->fetch($contractline->fk_contrat);
1371 $result = $contract->fetch_thirdparty($contract->socid);
1373 $mesg = $contract->error;
1377 $mesg =
'ErrorRecordNotFound';
1383 if ($action !=
'dopayment') {
1384 $amount = $contractline->total_ttc;
1386 if ($contractline->fk_product &&
getDolGlobalString(
'PAYMENT_USE_NEW_PRICE_FOR_CONTRACTLINES')) {
1388 $result = $product->fetch($contractline->fk_product);
1392 $pu_ht = $product->multiprices[$contract->thirdparty->price_level];
1393 $pu_ttc = $product->multiprices_ttc[$contract->thirdparty->price_level];
1394 $price_base_type = $product->multiprices_base_type[$contract->thirdparty->price_level];
1396 $pu_ht = $product->price;
1397 $pu_ttc = $product->price_ttc;
1398 $price_base_type = $product->price_base_type;
1402 if (empty($amount)) {
1408 if (
GETPOST(
"amount",
'alpha')) {
1409 $amount =
GETPOST(
"amount",
'alpha');
1414 if (
GETPOST(
'fulltag',
'alpha')) {
1415 $fulltag =
GETPOST(
'fulltag',
'alpha');
1417 $fulltag =
'COL='.$contractline->id.
'.CON='.$contract->id.
'.CUS='.$contract->thirdparty->id.
'.DAT='.
dol_print_date(
dol_now(),
'%Y%m%d%H%M%S');
1420 $fulltag .=
'.TAG='.$TAG;
1431 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
1432 print
'</td><td class="CTableRow2"><b>'.$creditor.
'</b>';
1433 print
'<input type="hidden" name="creditor" value="'.$creditor.
'">';
1434 print
'</td></tr>'.
"\n";
1437 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"ThirdParty");
1438 print
'</td><td class="CTableRow2"><b>'.$contract->thirdparty->name.
'</b>';
1439 print
'</td></tr>'.
"\n";
1442 $text =
'<b>'.$langs->trans(
"PaymentRenewContractId", $contract->ref, $contractline->ref).
'</b>';
1443 if ($contractline->fk_product > 0) {
1444 $contractline->fetch_product();
1445 $text .=
'<br>'.$contractline->product->ref.($contractline->product->label ?
' - '.$contractline->product->label :
'');
1447 if ($contractline->description) {
1448 $text .=
'<br>'.dol_htmlentitiesbr($contractline->description);
1450 if ($contractline->date_end) {
1451 $text .=
'<br>'.$langs->trans(
"ExpiredSince").
': '.
dol_print_date($contractline->date_end);
1453 if (
GETPOST(
'desc',
'alpha')) {
1454 $text =
'<b>'.$langs->trans(
GETPOST(
'desc',
'alpha')).
'</b>';
1456 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Designation");
1457 print
'</td><td class="CTableRow2">'.$text;
1458 print
'<input type="hidden" name="source" value="'.dol_escape_htmltag($source).
'">';
1459 print
'<input type="hidden" name="ref" value="'.dol_escape_htmltag($contractline->ref).
'">';
1460 print
'<input type="hidden" name="dol_id" value="'.dol_escape_htmltag((
string) $contractline->id).
'">';
1461 $directdownloadlink = $contract->getLastMainDocLink(
'contract');
1462 if ($directdownloadlink) {
1463 print
'<br><a href="'.$directdownloadlink.
'">';
1464 print
img_mime($contract->last_main_doc,
'');
1465 print $langs->trans(
"DownloadDocument").
'</a>';
1467 print
'</td></tr>'.
"\n";
1470 $label = $langs->trans(
"Quantity");
1473 if ($contractline->fk_product) {
1474 if ($contractline->product->isService() && $contractline->product->duration_value > 0) {
1475 $label = $langs->trans(
"Duration");
1478 if ($contractline->product->duration_value > 1) {
1479 $dur = array(
"h" => $langs->trans(
"Hours"),
"d" => $langs->trans(
"DurationDays"),
"w" => $langs->trans(
"DurationWeeks"),
"m" => $langs->trans(
"DurationMonths"),
"y" => $langs->trans(
"DurationYears"));
1481 $dur = array(
"h" => $langs->trans(
"Hour"),
"d" => $langs->trans(
"DurationDay"),
"w" => $langs->trans(
"DurationWeek"),
"m" => $langs->trans(
"DurationMonth"),
"y" => $langs->trans(
"DurationYear"));
1483 $duration = $contractline->product->duration_value.
' '.$dur[$contractline->product->duration_unit];
1486 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$label.
'</td>';
1487 print
'<td class="CTableRow2"><b>'.($duration ? $duration : $qty).
'</b>';
1488 print
'<input type="hidden" name="newqty" value="'.dol_escape_htmltag((
string) $qty).
'">';
1489 print
'</b></td></tr>'.
"\n";
1492 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Amount");
1493 if (empty($amount)) {
1494 print
' ('.$langs->trans(
"ToComplete").
')';
1496 print
'</td><td class="CTableRow2">';
1497 if (empty($amount) || !is_numeric($amount)) {
1498 print
'<input type="hidden" name="amount" value="'.price2num(
GETPOST(
"amount",
'alpha'),
'MT').
'">';
1499 print
'<input class="flat maxwidth75" type="text" name="newamount" value="'.price2num(
GETPOST(
"newamount",
"alpha"),
'MT').
'">';
1501 print
' <b>'.$langs->trans(
"Currency".$currency).
'</b>';
1503 print
'<b class="amount">'.price($amount, 1, $langs, 1, -1, -1, $currency).
'</b>';
1504 print
'<input type="hidden" name="amount" value="'.$amount.
'">';
1505 print
'<input type="hidden" name="newamount" value="'.$amount.
'">';
1507 print
'<input type="hidden" name="currency" value="'.$currency.
'">';
1508 print
'</td></tr>'.
"\n";
1511 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentCode");
1512 print
'</td><td class="CTableRow2"><b style="word-break: break-all;">'.$fulltag.
'</b>';
1513 print
'<input type="hidden" name="tag" value="'.$tag.
'">';
1514 print
'<input type="hidden" name="fulltag" value="'.$fulltag.
'">';
1515 print
'</td></tr>'.
"\n";
1518 $shipToName = $contract->thirdparty->name;
1519 $shipToStreet = $contract->thirdparty->address;
1520 $shipToCity = $contract->thirdparty->town;
1521 $shipToState = $contract->thirdparty->state_code;
1522 $shipToCountryCode = $contract->thirdparty->country_code;
1523 $shipToZip = $contract->thirdparty->zip;
1524 $shipToStreet2 =
'';
1525 $phoneNum = $contract->thirdparty->phone;
1526 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1527 print
'<input type="hidden" name="shipToName" value="'.$shipToName.
'">'.
"\n";
1528 print
'<input type="hidden" name="shipToStreet" value="'.$shipToStreet.
'">'.
"\n";
1529 print
'<input type="hidden" name="shipToCity" value="'.$shipToCity.
'">'.
"\n";
1530 print
'<input type="hidden" name="shipToState" value="'.$shipToState.
'">'.
"\n";
1531 print
'<input type="hidden" name="shipToCountryCode" value="'.$shipToCountryCode.
'">'.
"\n";
1532 print
'<input type="hidden" name="shipToZip" value="'.$shipToZip.
'">'.
"\n";
1533 print
'<input type="hidden" name="shipToStreet2" value="'.$shipToStreet2.
'">'.
"\n";
1534 print
'<input type="hidden" name="phoneNum" value="'.$phoneNum.
'">'.
"\n";
1536 print
'<!-- Shipping address not complete, so we don t use it -->'.
"\n";
1538 if (is_object($contract->thirdparty)) {
1539 print
'<input type="hidden" name="thirdparty_id" value="'.$contract->thirdparty->id.
'">'.
"\n";
1541 print
'<input type="hidden" name="email" value="'.$contract->thirdparty->email.
'">'.
"\n";
1542 print
'<input type="hidden" name="vatnumber" value="'.$contract->thirdparty->tva_intra.
'">'.
"\n";
1543 $labeldesc = $langs->trans(
"Contract").
' '.$contract->ref;
1544 if (
GETPOST(
'desc',
'alpha')) {
1545 $labeldesc =
GETPOST(
'desc',
'alpha');
1547 print
'<input type="hidden" name="desc" value="'.dol_escape_htmltag($labeldesc).
'">'.
"\n";
1551if ($source ==
'member' || $source ==
'membersubscription') {
1552 $newsource =
'member';
1556 $langs->load(
"members");
1558 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
1559 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent_type.class.php';
1560 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
1565 $result = $member->fetch(0, $ref, 0,
'',
true,
true);
1567 $mesg = $member->error;
1570 $member->fetch_thirdparty();
1572 $adht->fetch($member->typeid);
1576 if ($action !=
'dopayment') {
1577 $amount = $member->last_subscription_amount;
1578 if (
GETPOST(
"amount",
'alpha')) {
1582 if (empty($amount)) {
1583 $amount = $adht->amount;
1586 $amount = max(0,
price2num($amount,
'MT'));
1589 if (
GETPOST(
'fulltag',
'alpha')) {
1590 $fulltag =
GETPOST(
'fulltag',
'alpha');
1595 $fulltag .=
'.TAG='.$TAG;
1601 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
1602 print
'</td><td class="CTableRow2"><b>'.$creditor.
'</b>';
1603 print
'<input type="hidden" name="creditor" value="'.$creditor.
'">';
1604 print
'</td></tr>'.
"\n";
1607 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Member");
1608 print
'</td><td class="CTableRow2">';
1610 if ($member->morphy ==
'mor' && !empty($member->company)) {
1611 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1612 print $member->company;
1614 print
img_picto(
'',
'member',
'class="pictofixedwidth"');
1615 print $member->getFullName($langs);
1618 print
'</td></tr>'.
"\n";
1621 $text =
'<b>'.$langs->trans(
"PaymentSubscription").
'</b>';
1622 if (
GETPOST(
'desc',
'alpha')) {
1623 $text =
'<b>'.$langs->trans(
GETPOST(
'desc',
'alpha')).
'</b>';
1625 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Designation");
1626 print
'</td><td class="CTableRow2">'.$text;
1627 print
'<input type="hidden" name="source" value="'.dol_escape_htmltag($newsource).
'">';
1628 print
'<input type="hidden" name="ref" value="'.dol_escape_htmltag($member->ref).
'">';
1629 print
'</td></tr>'.
"\n";
1632 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"DateEndSubscription");
1633 print
'</td><td class="CTableRow2">'.dol_print_date($member->datefin,
'day');
1634 print
'</td></tr>'.
"\n";
1637 if ($member->last_subscription_date || $member->last_subscription_amount) {
1640 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"LastSubscriptionDate");
1641 print
'</td><td class="CTableRow2">'.dol_print_date($member->last_subscription_date,
'day');
1642 print
'</td></tr>'.
"\n";
1646 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"LastSubscriptionAmount");
1647 print
'</td><td class="CTableRow2">'.price($member->last_subscription_amount);
1648 print
'</td></tr>'.
"\n";
1650 if (empty($amount) && !
GETPOST(
'newamount',
'alpha')) {
1651 $_GET[
'newamount'] = $member->last_subscription_amount;
1652 $_GET[
'amount'] = $member->last_subscription_amount;
1654 if (!empty($member->last_subscription_amount) && !GETPOSTISSET(
'newamount') && is_numeric($amount)) {
1655 $amount = max($member->last_subscription_amount, $amount);
1659 $amountbytype = $adht->amountByType(1);
1661 $typeid = $adht->id;
1662 $caneditamount = $adht->caneditamount;
1664 if ($member->type) {
1665 $oldtypeid = $member->typeid;
1666 $newtypeid = (int) (GETPOSTISSET(
"typeid") ?
GETPOSTINT(
"typeid") : $member->typeid);
1668 $typeid = $newtypeid;
1669 $adht->fetch($typeid);
1672 $caneditamount = $adht->caneditamount;
1676 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"LastMemberType");
1677 print
'</td><td class="CTableRow2">'.dol_escape_htmltag($member->type);
1678 print
"</td></tr>\n";
1681 $member->typeid = $newtypeid;
1682 $member->type = (string)
dol_getIdFromCode($db, $newtypeid,
'adherent_type',
'rowid',
'libelle');
1688 $amount = (!empty($amountbytype[$member->typeid])) ? $amountbytype[$member->typeid] : $member->last_subscription_amount;
1690 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"NewSubscription");
1691 print
'</td><td class="CTableRow2">';
1692 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);
1693 print "</td></tr>\n
";
1694 } elseif ($action == 'dopayment') {
1695 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("NewMemberType
");
1696 print '</td><td class="CTableRow2
">'.dol_escape_htmltag($member->type);
1697 print '<input type="hidden
" name="membertypeid
" value="'.$member->typeid.'">';
1698 print "</td></tr>\n
";
1701 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("MemberType
");
1702 print '</td><td class="CTableRow2
">'.dol_escape_htmltag($member->type);
1703 print "</td></tr>\n
";
1707 // Set amount for the subscription from the the type and options:
1708 // - First check the amount of the member type if not previous payment.
1709 $amount = ($member->last_subscription_amount ? $member->last_subscription_amount : (empty($amountbytype[$typeid]) ? 0 : $amountbytype[$typeid]));
1710 // - If not found, take the default amount
1711 if (empty($amount) && getDolGlobalString('MEMBER_NEWFORM_AMOUNT')) {
1712 $amount = getDolGlobalString('MEMBER_NEWFORM_AMOUNT');
1714 // - If an amount was posted from the form (for example from page with types of membership)
1715 if ($caneditamount && GETPOSTISSET('amount') && GETPOSTFLOAT('amount', 'MT') > 0) {
1716 $amount = GETPOSTFLOAT('amount', 'MT');
1718 // - If a new amount was posted from the form
1719 if ($caneditamount && GETPOSTISSET('newamount') && GETPOSTFLOAT('newamount', 'MT') > 0) {
1720 $amount = GETPOSTFLOAT('newamount', 'MT');
1722 // - If a min is set or an amount from the posted form, we take them into account
1723 $amount = max(0, (float) $amount, (float) getDolGlobalInt("MEMBER_MIN_AMOUNT
"));
1726 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Amount
");
1727 // This place no longer allows amount edition
1728 if (getDolGlobalString('MEMBER_EXT_URL_SUBSCRIPTION_INFO')) {
1729 print ' - <a href="' . getDolGlobalString('MEMBER_EXT_URL_SUBSCRIPTION_INFO
').'" rel="external
" target="_blank
" rel="noopener noreferrer
">'.$langs->trans("SeeHere
").'</a>';
1731 print '</td><td class="CTableRow2
">';
1733 $caneditamount = $adht->caneditamount;
1734 $minimumamount = !getDolGlobalString('MEMBER_MIN_AMOUNT') ? $adht->amount : max(getDolGlobalString('MEMBER_MIN_AMOUNT'), $adht->amount, $amount);
1736 if ($caneditamount && $action != 'dopayment') {
1737 if (GETPOSTISSET('newamount')) {
1738 print '<input type="text
" class="width75
" name="newamount
" value="'.price(price2num(GETPOST('newamount
'), '', 2), 1, $langs, 1, -1, -1).'">';
1740 print '<input type="text
" class="width75
" name="newamount
" value="'.price($amount, 1, $langs, 1, -1, -1).'">';
1743 print '<b class="amount
">'.price($amount, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
1744 if ($minimumamount > $amount) {
1745 print ' <span class="opacitymedium small
">'. $langs->trans("AmountIsLowerToMinimumNotice
", price($minimumamount, 1, $langs, 1, -1, -1, $currency)).'</span>';
1747 print '<input type="hidden
" name="newamount
" value="'.$amount.'">';
1749 print '<input type="hidden
" name="amount
" value="'.$amount.'">';
1750 print '<input type="hidden
" name="currency
" value="'.$currency.'">';
1751 print '</td></tr>'."\n
";
1754 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("PaymentCode
");
1755 print '</td><td class="CTableRow2
"><b style="word-
break:
break-all;
">'.$fulltag.'</b>';
1756 print '<input type="hidden
" name="tag
" value="'.$tag.'">';
1757 print '<input type="hidden
" name="fulltag
" value="'.$fulltag.'">';
1758 print '</td></tr>'."\n
";
1761 $shipToName = $member->getFullName($langs);
1762 $shipToStreet = $member->address;
1763 $shipToCity = $member->town;
1764 $shipToState = $member->state_code;
1765 $shipToCountryCode = $member->country_code;
1766 $shipToZip = $member->zip;
1767 $shipToStreet2 = '';
1768 $phoneNum = $member->phone;
1769 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1770 print '<!-- Shipping address information -->';
1771 print '<input type="hidden
" name="shipToName
" value="'.$shipToName.'">'."\n
";
1772 print '<input type="hidden
" name="shipToStreet
" value="'.$shipToStreet.'">'."\n
";
1773 print '<input type="hidden
" name="shipToCity
" value="'.$shipToCity.'">'."\n
";
1774 print '<input type="hidden
" name="shipToState
" value="'.$shipToState.'">'."\n
";
1775 print '<input type="hidden
" name="shipToCountryCode
" value="'.$shipToCountryCode.'">'."\n
";
1776 print '<input type="hidden
" name="shipToZip
" value="'.$shipToZip.'">'."\n
";
1777 print '<input type="hidden
" name="shipToStreet2
" value="'.$shipToStreet2.'">'."\n
";
1778 print '<input type="hidden
" name="phoneNum
" value="'.$phoneNum.'">'."\n
";
1780 print '<!-- Shipping address not complete, so we don t use it -->'."\n
";
1782 if (is_object($member->thirdparty)) {
1783 print '<input type="hidden
" name="thirdparty_id
" value="'.$member->thirdparty->id.'">'."\n
";
1785 print '<input type="hidden
" name="email" value="'.$member->email.'">'."\n
";
1786 $labeldesc = $langs->trans("PaymentSubscription
");
1787 if (GETPOST('desc', 'alpha')) {
1788 $labeldesc = GETPOST('desc', 'alpha');
1790 print '<input type="hidden
" name="desc
" value="'.dol_escape_htmltag($labeldesc).'">'."\n
";
1793// Payment on donation
1794if ($source == 'donation') {
1796 $langs->load("don
");
1798 require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
1800 $don = new Don($db);
1801 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
1802 $result = $don->fetch($ref);
1804 $mesg = $don->error;
1807 $don->fetch_thirdparty();
1811 if ($action != 'dopayment') { // Do not change amount if we just click on first dopayment
1812 if (GETPOST("amount
", 'alpha')) {
1813 $amount = GETPOST("amount
", 'alpha');
1815 $amount = $don->getRemainToPay();
1817 $amount = price2num($amount);
1820 if (GETPOST('fulltag', 'alpha')) {
1821 $fulltag = GETPOST('fulltag', 'alpha');
1823 $fulltag = 'DON='.$don->ref.'.DAT='.dol_print_date(dol_now(), '%Y%m%d%H%M%S');
1826 $fulltag .= '.TAG='.$TAG;
1829 $fulltag = dol_string_unaccent($fulltag);
1832 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Creditor
");
1833 print '</td><td class="CTableRow2
"><b>'.$creditor.'</b>';
1834 print '<input type="hidden
" name="creditor
" value="'.$creditor.'">';
1835 print '</td></tr>'."\n
";
1838 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("ThirdParty
");
1839 print '</td><td class="CTableRow2
"><b>';
1840 if ($don->morphy == 'mor' && !empty($don->societe)) {
1841 print $don->societe;
1843 print $don->getFullName($langs);
1846 print '</td></tr>'."\n
";
1850 if (GETPOST('desc', 'alpha')) {
1851 $text = '<b>'.$langs->trans(GETPOST('desc', 'alpha')).'</b>';
1853 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Designation
");
1854 print '</td><td class="CTableRow2
">'.$text;
1855 print '<input type="hidden
" name="source
" value="'.dol_escape_htmltag($source).'">';
1856 print '<input type="hidden
" name="ref" value="'.dol_escape_htmltag($don->ref).'">';
1857 print '</td></tr>'."\n
";
1860 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Amount
");
1861 if (empty($amount)) {
1862 if (!getDolGlobalString('DONATION_NEWFORM_AMOUNT')) {
1863 print ' ('.$langs->trans("ToComplete
");
1865 if (getDolGlobalString('DONATION_EXT_URL_SUBSCRIPTION_INFO')) {
1866 print ' - <a href="' . getDolGlobalString('DONATION_EXT_URL_SUBSCRIPTION_INFO
').'" rel="external
" target="_blank
" rel="noopener noreferrer
">'.$langs->trans("SeeHere
").'</a>';
1868 if (!getDolGlobalString('DONATION_NEWFORM_AMOUNT')) {
1872 print '</td><td class="CTableRow2
">';
1874 if (empty($amount) || !is_numeric($amount)) {
1875 $valtoshow = price2num(GETPOST("newamount
", 'alpha'), 'MT');
1876 // force default subscription amount to value defined into constant...
1877 if (empty($valtoshow)) {
1878 if (getDolGlobalString('DONATION_NEWFORM_EDITAMOUNT')) {
1879 if (getDolGlobalString('DONATION_NEWFORM_AMOUNT')) {
1880 $valtoshow = getDolGlobalString('DONATION_NEWFORM_AMOUNT');
1883 if (getDolGlobalString('DONATION_NEWFORM_AMOUNT')) {
1884 $amount = getDolGlobalString('DONATION_NEWFORM_AMOUNT');
1889 if (empty($amount) || !is_numeric($amount)) {
1890 //$valtoshow=price2num(GETPOST("newamount
",'alpha'),'MT');
1891 if (getDolGlobalString('DONATION_MIN_AMOUNT') && $valtoshow) {
1892 $valtoshow = max(getDolGlobalString('DONATION_MIN_AMOUNT'), $valtoshow);
1894 print '<input type="hidden
" name="amount
" value="'.price2num(GETPOST("amount", 'alpha
'), 'MT
').'">';
1895 print '<input class="flat maxwidth75
" type="text
" name="newamount
" value="'.$valtoshow.'">';
1897 print ' <b>'.$langs->trans("Currency
".$currency).'</b>';
1899 $valtoshow = $amount;
1900 if (getDolGlobalString('DONATION_MIN_AMOUNT') && $valtoshow) {
1901 $valtoshow = max(getDolGlobalString('DONATION_MIN_AMOUNT'), $valtoshow);
1902 $amount = $valtoshow;
1904 print '<b class="amount
">'.price($valtoshow, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
1905 print '<input type="hidden
" name="amount
" value="'.$valtoshow.'">';
1906 print '<input type="hidden
" name="newamount
" value="'.$valtoshow.'">';
1908 print '<input type="hidden
" name="currency
" value="'.$currency.'">';
1909 print '</td></tr>'."\n
";
1912 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("PaymentCode
");
1913 print '</td><td class="CTableRow2
"><b style="word-
break:
break-all;
">'.$fulltag.'</b>';
1914 print '<input type="hidden
" name="tag
" value="'.$tag.'">';
1915 print '<input type="hidden
" name="fulltag
" value="'.$fulltag.'">';
1916 print '</td></tr>'."\n
";
1919 $shipToName = $don->getFullName($langs);
1920 $shipToStreet = $don->address;
1921 $shipToCity = $don->town;
1922 $shipToState = $don->state_code;
1923 $shipToCountryCode = $don->country_code;
1924 $shipToZip = $don->zip;
1925 $shipToStreet2 = '';
1926 $phoneNum = $don->phone;
1927 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1928 print '<!-- Shipping address information -->';
1929 print '<input type="hidden
" name="shipToName
" value="'.$shipToName.'">'."\n
";
1930 print '<input type="hidden
" name="shipToStreet
" value="'.$shipToStreet.'">'."\n
";
1931 print '<input type="hidden
" name="shipToCity
" value="'.$shipToCity.'">'."\n
";
1932 print '<input type="hidden
" name="shipToState
" value="'.$shipToState.'">'."\n
";
1933 print '<input type="hidden
" name="shipToCountryCode
" value="'.$shipToCountryCode.'">'."\n
";
1934 print '<input type="hidden
" name="shipToZip
" value="'.$shipToZip.'">'."\n
";
1935 print '<input type="hidden
" name="shipToStreet2
" value="'.$shipToStreet2.'">'."\n
";
1936 print '<input type="hidden
" name="phoneNum
" value="'.$phoneNum.'">'."\n
";
1938 print '<!-- Shipping address not complete, so we don t use it -->'."\n
";
1940 if (is_object($don->thirdparty)) {
1941 print '<input type="hidden
" name="thirdparty_id
" value="'.$don->thirdparty->id.'">'."\n
";
1943 print '<input type="hidden
" name="email" value="'.$don->email.'">'."\n
";
1944 $labeldesc = $langs->trans("PaymentSubscription
");
1945 if (GETPOST('desc', 'alpha')) {
1946 $labeldesc = GETPOST('desc', 'alpha');
1948 print '<input type="hidden
" name="desc
" value="'.dol_escape_htmltag($labeldesc).'">'."\n
";
1951if ($source == 'organizedeventregistration' && is_object($thirdparty)) {
1953 $langs->loadLangs(array("members
", "eventorganization
"));
1955 if (GETPOST('fulltag', 'alpha')) {
1956 $fulltag = GETPOST('fulltag', 'alpha');
1958 $fulltag = 'ATT='.$attendee->id.'.DAT='.dol_print_date(dol_now(), '%Y%m%d%H%M%S');
1961 $fulltag .= '.TAG='.$TAG;
1964 $fulltag = dol_string_unaccent($fulltag);
1967 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Creditor
");
1968 print '</td><td class="CTableRow2
"><b>'.$creditor.'</b>';
1969 print '<input type="hidden
" name="creditor
" value="'.$creditor.'">';
1970 print '</td></tr>'."\n
";
1973 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Attendee
");
1974 print '</td><td class="CTableRow2
"><b>';
1975 print $attendee->email;
1976 print($thirdparty->name ? ' ('.$thirdparty->name.')' : '');
1978 print '</td></tr>'."\n
";
1980 if (! is_object($attendee->project)) {
1981 $text = 'ErrorProjectNotFound';
1983 $text = $langs->trans("PaymentEvent
").' - '.$attendee->project->title;
1987 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Designation
");
1988 print '</td><td class="CTableRow2
"><b>'.$text.'</b>';
1989 print '<input type="hidden
" name="source
" value="'.dol_escape_htmltag($source).'">';
1990 print '<input type="hidden
" name="ref" value="'.dol_escape_htmltag($invoice->id).'">';
1991 print '</td></tr>'."\n
";
1994 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Amount
");
1995 print '</td><td class="CTableRow2
">';
1996 $valtoshow = $amount;
1997 print '<b class="amount
">'.price($valtoshow, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
1998 print '<input type="hidden
" name="amount
" value="'.$valtoshow.'">';
1999 print '<input type="hidden
" name="newamount
" value="'.$valtoshow.'">';
2000 print '<input type="hidden
" name="currency
" value="'.$currency.'">';
2001 print '</td></tr>'."\n
";
2004 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("PaymentCode
");
2005 print '</td><td class="CTableRow2
"><b style="word-
break:
break-all;
">'.$fulltag.'</b>';
2006 print '<input type="hidden
" name="tag
" value="'.$tag.'">';
2007 print '<input type="hidden
" name="fulltag
" value="'.$fulltag.'">';
2008 print '</td></tr>'."\n
";
2011 $shipToName = $thirdparty->getFullName($langs);
2012 $shipToStreet = $thirdparty->address;
2013 $shipToCity = $thirdparty->town;
2014 $shipToState = $thirdparty->state_code;
2015 $shipToCountryCode = $thirdparty->country_code;
2016 $shipToZip = $thirdparty->zip;
2017 $shipToStreet2 = '';
2018 $phoneNum = $thirdparty->phone;
2019 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
2020 print '<!-- Shipping address information -->';
2021 print '<input type="hidden
" name="shipToName
" value="'.$shipToName.'">'."\n
";
2022 print '<input type="hidden
" name="shipToStreet
" value="'.$shipToStreet.'">'."\n
";
2023 print '<input type="hidden
" name="shipToCity
" value="'.$shipToCity.'">'."\n
";
2024 print '<input type="hidden
" name="shipToState
" value="'.$shipToState.'">'."\n
";
2025 print '<input type="hidden
" name="shipToCountryCode
" value="'.$shipToCountryCode.'">'."\n
";
2026 print '<input type="hidden
" name="shipToZip
" value="'.$shipToZip.'">'."\n
";
2027 print '<input type="hidden
" name="shipToStreet2
" value="'.$shipToStreet2.'">'."\n
";
2028 print '<input type="hidden
" name="phoneNum
" value="'.$phoneNum.'">'."\n
";
2030 print '<!-- Shipping address not complete, so we don t use it -->'."\n
";
2032 print '<input type="hidden
" name="thirdparty_id
" value="'.$thirdparty->id.'">'."\n
";
2033 print '<input type="hidden
" name="email" value="'.$thirdparty->email.'">'."\n
";
2034 $labeldesc = $langs->trans("PaymentSubscription
");
2035 if (GETPOST('desc', 'alpha')) {
2036 $labeldesc = GETPOST('desc', 'alpha');
2038 print '<input type="hidden
" name="desc
" value="'.dol_escape_htmltag($labeldesc).'">'."\n
";
2041if ($source == 'boothlocation') {
2043 $langs->load("members
");
2045 if (GETPOST('fulltag', 'alpha')) {
2046 $fulltag = GETPOST('fulltag', 'alpha');
2048 $fulltag = 'BOO='.GETPOST("booth
").'.DAT='.dol_print_date(dol_now(), '%Y%m%d%H%M%S');
2051 $fulltag .= '.TAG='.$TAG;
2054 $fulltag = dol_string_unaccent($fulltag);
2057 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Creditor
");
2058 print '</td><td class="CTableRow2
"><b>'.$creditor.'</b>';
2059 print '<input type="hidden
" name="creditor
" value="'.$creditor.'">';
2060 print '</td></tr>'."\n
";
2063 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Attendee
");
2064 print '</td><td class="CTableRow2
"><b>';
2065 print $thirdparty->name;
2067 print '</td></tr>'."\n
";
2070 $text = '<b>'.$langs->trans("PaymentBoothLocation
").'</b>';
2071 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Designation
");
2072 print '</td><td class="CTableRow2
">'.$text;
2073 print '<input type="hidden
" name="source
" value="'.dol_escape_htmltag($source).'">';
2074 print '<input type="hidden
" name="ref" value="'.dol_escape_htmltag($invoice->id).'">';
2075 print '</td></tr>'."\n
";
2078 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Amount
");
2079 print '</td><td class="CTableRow2
">';
2080 $valtoshow = $amount;
2081 print '<b class="amount
">'.price($valtoshow, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
2082 print '<input type="hidden
" name="amount
" value="'.$valtoshow.'">';
2083 print '<input type="hidden
" name="newamount
" value="'.$valtoshow.'">';
2084 print '<input type="hidden
" name="currency
" value="'.$currency.'">';
2085 print '</td></tr>'."\n
";
2088 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("PaymentCode
");
2089 print '</td><td class="CTableRow2
"><b style="word-
break:
break-all;
">'.$fulltag.'</b>';
2090 print '<input type="hidden
" name="tag
" value="'.$tag.'">';
2091 print '<input type="hidden
" name="fulltag
" value="'.$fulltag.'">';
2092 print '</td></tr>'."\n
";
2095 $shipToName = $thirdparty->getFullName($langs);
2096 $shipToStreet = $thirdparty->address;
2097 $shipToCity = $thirdparty->town;
2098 $shipToState = $thirdparty->state_code;
2099 $shipToCountryCode = $thirdparty->country_code;
2100 $shipToZip = $thirdparty->zip;
2101 $shipToStreet2 = '';
2102 $phoneNum = $thirdparty->phone;
2103 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
2104 print '<!-- Shipping address information -->';
2105 print '<input type="hidden
" name="shipToName
" value="'.$shipToName.'">'."\n
";
2106 print '<input type="hidden
" name="shipToStreet
" value="'.$shipToStreet.'">'."\n
";
2107 print '<input type="hidden
" name="shipToCity
" value="'.$shipToCity.'">'."\n
";
2108 print '<input type="hidden
" name="shipToState
" value="'.$shipToState.'">'."\n
";
2109 print '<input type="hidden
" name="shipToCountryCode
" value="'.$shipToCountryCode.'">'."\n
";
2110 print '<input type="hidden
" name="shipToZip
" value="'.$shipToZip.'">'."\n
";
2111 print '<input type="hidden
" name="shipToStreet2
" value="'.$shipToStreet2.'">'."\n
";
2112 print '<input type="hidden
" name="phoneNum
" value="'.$phoneNum.'">'."\n
";
2114 print '<!-- Shipping address not complete, so we don t use it -->'."\n
";
2116 print '<input type="hidden
" name="thirdparty_id
" value="'.$thirdparty->id.'">'."\n
";
2117 print '<input type="hidden
" name="email" value="'.$thirdparty->email.'">'."\n
";
2118 $labeldesc = $langs->trans("PaymentSubscription
");
2119 if (GETPOST('desc', 'alpha')) {
2120 $labeldesc = GETPOST('desc', 'alpha');
2122 print '<input type="hidden
" name="desc
" value="'.dol_escape_htmltag($labeldesc).'">'."\n
";
2125if (!$found && !$mesg) {
2126 $mesg = $langs->trans("ErrorBadParameters
");
2130 print '<tr><td align="center
" colspan="2
"><br><div class="warning
">'.dol_escape_htmltag($mesg, 1, 1, 'br').'</div></td></tr>'."\n
";
2133print '</table>'."\n
";
2137// Show all payment mode buttons (Stripe, Paypal, ...)
2138if ($action != 'dopayment') {
2139 if ($found && !$error) { // We are in a management option and no error
2140 // Check status of the object (Invoice) to verify if it is paid by external payment modules (ie Payzen, ...)
2142 'source' => $source,
2145 $reshook = $hookmanager->executeHooks('doCheckStatus', $parameters, $object, $action);
2147 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2148 } elseif ($reshook > 0) {
2149 print $hookmanager->resPrint;
2152 if ($source == 'order' && $object->billed) {
2153 print '<br><br><div class="amountpaymentcomplete size12x wrapimp
">'.$langs->trans("OrderBilled
").'</div>';
2154 } elseif ($source == 'invoice' && $object->paye) {
2155 print '<br><br><div class="amountpaymentcomplete size12x wrapimp
">'.$langs->trans("InvoicePaid
").'</div>';
2156 } elseif ($source == 'donation' && $object->paid) {
2157 print '<br><br><div class="amountpaymentcomplete size12x wrapimp
">'.$langs->trans("DonationPaid
").'</div>';
2159 // Membership can be paid and we still allow to make renewal
2160 if (($source == 'member' || $source == 'membersubscription') && $object->datefin > dol_now()) {
2161 $langs->load("members
");
2162 print '<br><div class="amountpaymentcomplete size12x wrapimp
">';
2163 $s = $langs->trans("MembershipPaid
", '{s1}');
2164 print str_replace('{s1}', '<span class="nobold
">'.dol_print_date($object->datefin, 'day').'</span>', $s);
2166 print '<div class="opacitymedium margintoponly
">'.$langs->trans("PaymentWillBeRecordedForNextPeriod
").'</div>';
2170 // Buttons for all payments registration methods
2172 // This hook is used to add Button to newpayment.php for external payment modules (ie Payzen, ...)
2174 'paymentmethod' => $paymentmethod
2176 $reshook = $hookmanager->executeHooks('doAddButton', $parameters, $object, $action);
2178 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2179 } elseif ($reshook >= 0) {
2180 print $hookmanager->resPrint;
2183 if ((empty($paymentmethod) || $paymentmethod == 'paybox') && isModEnabled('paybox')) {
2184 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").'">';
2186 print '<span class="buttonpaymentsmall
">'.$langs->trans("CreditOrDebitCard
").'</span>';
2189 $( document ).ready(function() {
2190 $("#div_dopayment_paybox
").click(function(){
2191 $("#dopayment_paybox
").click();
2193 $("#dopayment_paybox
").click(function(e){
2194 $("#div_dopayment_paybox
").css( \'cursor\', \'wait\' );
2195 e.stopPropagation();
2202 if ((empty($paymentmethod) || $paymentmethod == 'stripe') && isModEnabled('stripe')) {
2204 if (getDolGlobalString(strtoupper($source).'_FORCE_DISABLE_STRIPE')) { // Example: MEMBER_FORCE_DISABLE_STRIPE
2209 // 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.
2210 // 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).
2211 $noidempotency_key = (GETPOSTISSET('noidempotency') ? GETPOSTINT('noidempotency') : (getDolGlobalInt('STRIPE_USE_IDEMPOTENCY_BY_DEFAULT') ? 0 : 1));
2213 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").'">';
2214 print '<input type="hidden
" name="noidempotency
" value="'.$noidempotency_key.'">';
2216 print '<span class="buttonpaymentsmall
">'.$langs->trans("CreditOrDebitCard
").'</span>';
2219 $( document ).ready(function() {
2220 $("#div_dopayment_stripe
").click(function(){
2221 $("#dopayment_stripe
").click();
2223 $("#dopayment_stripe
").click(function(e){
2224 $("#div_dopayment_stripe
").css( \'cursor\', \'wait\' );
2225 e.stopPropagation();
2234 if ((empty($paymentmethod) || $paymentmethod == 'paypal') && isModEnabled('paypal')) {
2235 if (!getDolGlobalString('PAYPAL_API_INTEGRAL_OR_PAYPALONLY')) {
2236 $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY = 'integral';
2240 if (getDolGlobalString(strtoupper($source).'_FORCE_DISABLE_PAYPAL')) { // Example: MEMBER_FORCE_DISABLE_PAYPAL
2245 print '<div class="button buttonpayment
" id="div_dopayment_paypal
">';
2246 if (getDolGlobalString('PAYPAL_API_INTEGRAL_OR_PAYPALONLY') != 'integral') {
2247 print '<div style="line-height: 1em
"> </div>';
2249 print '<span class="fab fa-paypal
"></span> <input class="" type="submit
" id="dopayment_paypal
" name="dopayment_paypal
" value="'.$langs->trans("PaypalDoPayment").'">';
2250 if (getDolGlobalString('PAYPAL_API_INTEGRAL_OR_PAYPALONLY') == 'integral') {
2252 print '<span class="buttonpaymentsmall
">'.$langs->trans("CreditOrDebitCard
").'</span><span class="buttonpaymentsmall
"> - </span>';
2253 print '<span class="buttonpaymentsmall
">'.$langs->trans("PayPalBalance
").'</span>';
2255 //if (getDolGlobalString('PAYPAL_API_INTEGRAL_OR_PAYPALONLY') == 'paypalonly') {
2257 //print '<span class="buttonpaymentsmall
">'.$langs->trans("PayPalBalance
").'"></span>
';
2261 $( document ).ready(
function() {
2262 $(
"#div_dopayment_paypal").click(
function(){
2263 $(
"#dopayment_paypal").click();
2265 $(
"#dopayment_paypal").click(
function(e){
2266 $(
"#div_dopayment_paypal").css( \
'cursor\', \'wait\' );
2267 e.stopPropagation();
2283print
'</td></tr>'.
"\n";
2285print
'</table>'.
"\n";
2287print
'</form>'.
"\n";
2295if (preg_match(
'/^dopayment/', $action)) {
2298 $_SESSION[
"currencyCodeType"] = $currency;
2299 $_SESSION[
"FinalPaymentAmt"] = $amount;
2300 $_SESSION[
'ipaddress'] = ($remoteip ? $remoteip :
'unknown');
2301 $_SESSION[
"paymentType"] =
'';
2306 if (
GETPOST(
'dopayment_stripe',
'alpha')) {
2314 background-color: white;
2317 border: 1px solid transparent;
2318 box-shadow: 0 1px 3px 0 #e6ebf1;
2319 -webkit-transition: box-shadow 150ms ease;
2320 transition: box-shadow 150ms ease;
2323 .StripeElement--focus {
2324 box-shadow: 0 1px 3px 0 #cfd7df;
2327 .StripeElement--invalid {
2328 border-color: #fa755a;
2331 .StripeElement--webkit-autofill {
2332 background-color: #fefde5 !important;
2338 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";
2339 print
'<form action="'.$_SERVER[
'REQUEST_URI'].
'" method="POST" id="payment-form">'.
"\n";
2341 print
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
2342 print
'<input type="hidden" name="dopayment_stripe" value="1">'.
"\n";
2343 print
'<input type="hidden" name="action" value="charge">'.
"\n";
2344 print
'<input type="hidden" name="tag" value="'.$TAG.
'">'.
"\n";
2345 print
'<input type="hidden" name="s" value="'.$source.
'">'.
"\n";
2346 print
'<input type="hidden" name="ref" value="'.$REF.
'">'.
"\n";
2347 print
'<input type="hidden" name="fulltag" value="'.$FULLTAG.
'">'.
"\n";
2348 print
'<input type="hidden" name="suffix" value="'.$suffix.
'">'.
"\n";
2349 print
'<input type="hidden" name="securekey" value="'.$SECUREKEY.
'">'.
"\n";
2350 print
'<input type="hidden" name="e" value="'.$entity.
'" />';
2351 print
'<input type="hidden" name="amount" value="'.$amount.
'">'.
"\n";
2352 print
'<input type="hidden" name="currency" value="'.$currency.
'">'.
"\n";
2353 print
'<input type="hidden" name="forcesandbox" value="'.GETPOSTINT(
'forcesandbox').
'" />';
2354 print
'<input type="hidden" name="email" value="'.GETPOST(
'email',
'alpha').
'" />';
2355 print
'<input type="hidden" name="thirdparty_id" value="'.GETPOSTINT(
'thirdparty_id').
'" />';
2356 print
'<input type="hidden" name="lang" value="'.$getpostlang.
'">';
2359 require_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
2361 $service =
'StripeLive';
2364 $service =
'StripeTest';
2368 $stripe =
new Stripe($db);
2369 $stripeacc = $stripe->getStripeAccount($service);
2371 $stripecu = $stripe->customerStripe(
$object->thirdparty, $stripeacc, $servicestatus, 1);
2377 $noidempotency_key = (GETPOSTISSET(
'noidempotency') ?
GETPOSTINT(
'noidempotency') : (
getDolGlobalInt(
'STRIPE_USE_IDEMPOTENCY_BY_DEFAULT') ? 0 : 1));
2379 $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);
2382 if ($stripe->error) {
2393 <table id="dolpaymenttable" summary="Payment form" class="center centpercent">
2394 <tbody><tr><td class="textpublicpayment">';
2397 print
'<div id="payment-request-button"><!-- A Stripe Element will be inserted here. --></div>';
2400 print
'<div class="form-row '.(getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 2 ?
'center' :
'left').
'">';
2401 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 1) {
2402 print
'<label for="card-element">'.$langs->trans(
"CreditOrDebitCard").
'</label>';
2403 print
'<br><input id="cardholder-name" class="marginbottomonly" name="cardholder-name" value="" type="text" placeholder="'.$langs->trans(
"CardOwner").
'" autocomplete="off" autofocus required>';
2406 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 1) {
2407 print
'<div id="card-element">
2408 <!-- a Stripe Element will be inserted here. -->
2411 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 2) {
2412 print
'<div id="payment-element">
2413 <!-- a Stripe Element will be inserted here. -->
2417 print
'<!-- Used to display form errors -->
2418 <div id="card-errors" role="alert"></div>
2422 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>';
2423 print
'<img id="hourglasstopay" class="hidden" src="'.DOL_URL_ROOT.
'/theme/'.
$conf->theme.
'/img/working.gif">';
2425 print
'</td></tr></tbody>';
2430 if (empty($paymentintent)) {
2431 print
'<center>'.$langs->trans(
"Error").
'</center>';
2433 print
'<input type="hidden" name="paymentintent_id" value="'.$paymentintent->id.
'">';
2438 print
'</form>'.
"\n";
2442 if (empty($stripearrayofkeys[
'publishable_key'])) {
2443 $langs->load(
"errors");
2444 print
info_admin($langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv(
"Stripe")), 0, 0,
'error');
2446 print
'<!-- JS Code for Stripe components -->';
2447 print
'<script src="https://js.stripe.com/v3/"></script>'.
"\n";
2448 print
'<!-- urllogofull = '.$urllogofull.
' -->'.
"\n";
2451 print
'<script type="text/javascript">'.
"\n";
2454 $amountstripe = $amount;
2458 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
2459 if (!in_array($currency, $arrayzerounitcurrency)) {
2460 $amountstripe *= 100;
2464 $metadata = array(
'dol_version' => DOL_VERSION,
'dol_entity' =>
$conf->entity,
'ipaddress' => $ipaddress);
2466 $metadata[
'dol_type'] =
$object->element;
2467 $metadata[
'dol_id'] =
$object->id;
2473 $arrayforpaymentintent = array(
2474 'description' =>
'Stripe payment: '.$FULLTAG.($ref ?
' ref='.$ref :
''),
2475 "metadata" => $metadata
2478 $arrayforpaymentintent[
"statement_descriptor"] =
dol_trunc($TAG, 10,
'right',
'UTF-8', 1);
2481 $arrayforcheckout = array(
2482 'payment_method_types' => array(
'card'),
2483 'line_items' => array(array(
2484 'price_data' => array(
2485 'currency' => $currency,
2486 'unit_amount' => $amountstripe,
2487 'product_data' => array(
2488 'name' => $langs->transnoentitiesnoconv(
"Payment").
' '.$TAG,
2489 'description' =>
'Stripe payment: '.$FULLTAG.($ref ?
' ref='.$ref :
''),
2495 'mode' =>
'payment',
2496 'client_reference_id' => $FULLTAG,
2497 'success_url' => $urlok,
2498 'cancel_url' => $urlko,
2499 'payment_intent_data' => $arrayforpaymentintent
2502 $arrayforcheckout[
'customer'] = $stripecu;
2504 $arrayforcheckout[
'customer_email'] =
GETPOST(
'email',
'alpha');
2506 $sessionstripe = \Stripe\Checkout\Session::create($arrayforcheckout);
2511 $_SESSION[
"currencyCodeType"] = $currency;
2512 $_SESSION[
"paymentType"] =
'';
2513 $_SESSION[
"FinalPaymentAmt"] = $amount;
2514 $_SESSION[
'ipaddress'] = ($remoteip ? $remoteip :
'unknown');
2515 $_SESSION[
'payerID'] = is_object($stripecu) ? $stripecu->id :
'';
2516 $_SESSION[
'TRANSACTIONID'] = $sessionstripe->id;
2518 print $e->getMessage();
2524 if (empty($stripeacc)) {
2526 var stripe =
Stripe(
'<?php echo $stripearrayofkeys['publishable_key
']; // Defined into config.php?>');
2530 var stripe =
Stripe(
'<?php echo $stripearrayofkeys['publishable_key
']; // Defined into config.php?>', { stripeAccount:
'<?php echo $stripeacc; ?>' });
2535 var elements = stripe.elements();
2543 fontFamily:
'"Helvetica Neue", Helvetica, sans-serif',
2544 fontSmoothing:
'antialiased',
2552 iconColor:
'#fa755a'
2556 var cardElement = elements.create(
'card', {style: style});
2559 stripe.redirectToCheckout({
2563 sessionId:
'<?php print $sessionstripe->id; ?>'
2564 }).then(
function (result) {
2578 if (empty($stripeacc)) {
2580 var stripe =
Stripe(
'<?php echo $stripearrayofkeys['publishable_key
']; // Defined into config.php?>');
2584 var stripe =
Stripe(
'<?php echo $stripearrayofkeys['publishable_key
']; // Defined into config.php?>', { stripeAccount:
'<?php echo $stripeacc; ?>' });
2589 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 2) {
2591 var cardButton = document.getElementById(
'buttontopay');
2592 var clientSecret = cardButton.dataset.secret;
2593 var options = { clientSecret: clientSecret };
2596 var elements = stripe.elements(options);
2601 var elements = stripe.elements();
2611 fontFamily:
'"Helvetica Neue", Helvetica, sans-serif',
2612 fontSmoothing:
'antialiased',
2620 iconColor:
'#fa755a'
2625 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 2) {
2627 var paymentElement = elements.create(
"payment");
2630 paymentElement.mount(
"#payment-element");
2633 var cardButton = document.getElementById(
'buttontopay');
2635 cardButton.addEventListener(
'click',
function(event) {
2636 console.log(
"We click on buttontopay");
2637 event.preventDefault();
2640 jQuery(
'#hourglasstopay').show();
2641 jQuery(
'#buttontopay').hide();
2643 stripe.confirmPayment({
2644 elements,confirmParams: {
2645 return_url:
'<?php echo $urlok; ?>',
2646 payment_method_data: {
2650 ?>, email:
'<?php echo dol_escape_js(GETPOST('email
', 'alpha
') ? GETPOST('email
', 'alpha
') : $object->thirdparty->email); ?>'<?php
2653 ?>, phone:
'<?php echo dol_escape_js($object->thirdparty->phone); ?>'<?php
2657 city:
'<?php echo dol_escape_js($object->thirdparty->town); ?>',
2658 <?php if ($object->thirdparty->country_code) {
2659 ?>country:
'<?php echo dol_escape_js($object->thirdparty->country_code); ?>',<?php
2661 line1:
'<?php echo dol_escape_js(preg_replace('/\s\s+/
', ' ', $object->thirdparty->address)); ?>',
2662 postal_code:
'<?php echo dol_escape_js($object->thirdparty->zip); ?>'
2668 save_payment_method:<?php
if ($stripecu) {
2675 ).then(
function(result) {
2676 console.log(result);
2678 console.log(
"Error on result of handleCardPayment");
2679 jQuery(
'#buttontopay').show();
2680 jQuery(
'#hourglasstopay').hide();
2682 var errorElement = document.getElementById(
'card-errors');
2683 console.log(result);
2684 errorElement.textContent = result.error.message;
2687 console.log(
"No error on result of handleCardPayment, so we submit the form");
2689 jQuery(
'#buttontopay').hide();
2690 jQuery(
'#hourglasstopay').show();
2692 jQuery(
'#payment-form').submit();
2700 var cardElement = elements.create(
'card', {style: style});
2703 cardElement.mount(
'#card-element');
2706 cardElement.addEventListener(
'change',
function(event) {
2707 var displayError = document.getElementById(
'card-errors');
2709 console.log(
"Show event error (like 'Incorrect card number', ...)");
2710 displayError.textContent =
event.error.message;
2712 console.log(
"Reset error message");
2713 displayError.textContent =
'';
2718 var cardholderName = document.getElementById(
'cardholder-name');
2719 var cardButton = document.getElementById(
'buttontopay');
2720 var clientSecret = cardButton.dataset.secret;
2722 cardButton.addEventListener(
'click',
function(event) {
2723 console.log(
"We click on buttontopay");
2724 event.preventDefault();
2726 if (cardholderName.value ==
'')
2728 console.log(
"Field Card holder is empty");
2729 var displayError = document.getElementById(
'card-errors');
2730 displayError.textContent =
'<?php print dol_escape_js($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardOwner"))); ?>';
2735 jQuery(
'#hourglasstopay').show();
2736 jQuery(
'#buttontopay').hide();
2738 stripe.handleCardPayment(
2739 clientSecret, cardElement, {
2740 payment_method_data: {
2742 name: cardholderName.value
2744 ?>, email:
'<?php echo dol_escape_js(GETPOST('email
', 'alpha
') ? GETPOST('email
', 'alpha
') : $object->thirdparty->email); ?>'<?php
2747 ?>, phone:
'<?php echo dol_escape_js($object->thirdparty->phone); ?>'<?php
2751 city:
'<?php echo dol_escape_js($object->thirdparty->town); ?>',
2752 <?php if ($object->thirdparty->country_code) {
2753 ?>country:
'<?php echo dol_escape_js($object->thirdparty->country_code); ?>',<?php
2755 line1:
'<?php echo dol_escape_js(preg_replace('/\s\s+/
', ' ', $object->thirdparty->address)); ?>',
2756 postal_code:
'<?php echo dol_escape_js($object->thirdparty->zip); ?>'
2762 save_payment_method:<?php
if ($stripecu) {
2768 ).then(
function(result) {
2769 console.log(result);
2771 console.log(
"Error on result of handleCardPayment");
2772 jQuery(
'#buttontopay').show();
2773 jQuery(
'#hourglasstopay').hide();
2775 var errorElement = document.getElementById(
'card-errors');
2776 errorElement.textContent = result.error.message;
2779 console.log(
"No error on result of handleCardPayment, so we submit the form");
2781 jQuery(
'#buttontopay').hide();
2782 jQuery(
'#hourglasstopay').show();
2784 jQuery(
'#payment-form').submit();
2802 'paymentmethod' => $paymentmethod,
2803 'amount' => $amount,
2804 'currency' => $currency,
2805 'tag' =>
GETPOST(
"tag",
'alpha'),
2806 'dopayment' =>
GETPOST(
'dopayment',
'alpha')
2808 $reshook = $hookmanager->executeHooks(
'doPayment', $parameters,
$object, $action);
2811 } elseif ($reshook > 0) {
2812 print $hookmanager->resPrint;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage members of a foundation.
Class to manage members type.
Class to manage customers orders.
Class for ConferenceOrBoothAttendee.
Class to manage lines of contracts.
Class to manage invoices.
Class to manage payments of donations.
Class to manage products or services.
Class to manage third parties objects (customers, suppliers, prospects...)
Stripe class @TODO No reason to extends CommonObject.
htmlPrintOnlineFooter($fromcompany, $langs, $addformmessage=0, $suffix='', $object=null)
Show footer of company in HTML pages.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as p label as s rowid as s nom as s email
Sender: Who sends the email ("Sender" has sent emails on behalf of "From").
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_now($mode='auto')
Return date for now.
img_mime($file, $titlealt='', $morecss='')
Show MIME img of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_string_unaccent($str)
Clean a string from all accent characters to be used as ref, login or by dol_sanitizeFileName.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error_email($prefixcode, $errormessage='', $errormessages=array(), $morecss='error', $email='')
Show a public email and error code to contact if technical error.
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formatted messages to output (Used to show messages on html output).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
getUserRemoteIP()
Return the IP of remote user.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
ui state ui widget content ui state ui widget header ui state a ui button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
print_paybox_redirect($PRICE, $CURRENCY, $EMAIL, $urlok, $urlko, $TAG)
Create a redirect form to paybox form.
print_paypal_redirect($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $tag)
Send redirect to paypal to browser.
$conf db name
Only used if Module[ID]Name translation string is not found.
dol_verifyHash($chain, $hash, $type='0')
Compute a hash and compare it to the given one For backward compatibility reasons,...