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';
75$hookmanager->initHooks(array(
'newpayment'));
78$langs->loadLangs(array(
"main",
"other",
"dict",
"bills",
"companies",
"errors",
"paybox",
"paypal",
"stripe"));
83$action =
GETPOST(
'action',
'aZ09');
92$suffix =
GETPOST(
"suffix",
'aZ09');
94if (!
GETPOST(
"currency",
'alpha')) {
95 $currency = $conf->currency;
97 $currency =
GETPOST(
"currency",
'aZ09');
100$getpostlang =
GETPOST(
'lang',
'aZ09');
105 if (!
GETPOST(
"amount",
'alpha') && !$source) {
106 print $langs->trans(
'ErrorBadParameters').
" - amount or source";
109 if (is_numeric($amount) && !
GETPOST(
"tag",
'alpha') && !$source) {
110 print $langs->trans(
'ErrorBadParameters').
" - tag or source";
113 if ($source && !
GETPOST(
"ref",
'alpha')) {
114 print $langs->trans(
'ErrorBadParameters').
" - ref";
122$paymentintent =
null;
126if ($source ==
'organizedeventregistration') {
133 $resultinvoice = $invoice->fetch($invoiceid);
135 if ($resultinvoice <= 0) {
148 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"eventorganization_conferenceorboothattendee";
149 $sql .=
" WHERE fk_invoice = ".((int) $invoiceid);
151 $resql = $db->query($sql);
153 $obj = $db->fetch_object($resql);
155 $attendeeid = $obj->rowid;
159 if ($attendeeid > 0) {
160 $resultattendee = $attendee->fetch($attendeeid);
162 if ($resultattendee <= 0) {
165 $attendee->fetch_projet();
167 $amount =
price2num($invoice->total_ttc);
169 $thirdparty =
new Societe($db);
170 $resultthirdparty = $thirdparty->fetch($invoice->socid);
171 if ($resultthirdparty <= 0) {
178} elseif ($source ==
'boothlocation') {
182 $resultinvoice = $invoice->fetch($invoiceid);
183 if ($resultinvoice <= 0) {
186 $amount =
price2num($invoice->total_ttc);
188 $thirdparty =
new Societe($db);
189 $resultthirdparty = $thirdparty->fetch($invoice->socid);
190 if ($resultthirdparty <= 0) {
198$paymentmethod =
GETPOST(
'paymentmethod',
'alphanohtml') ?
GETPOST(
'paymentmethod',
'alphanohtml') :
'';
199$validpaymentmethod = array();
202foreach ($_POST as $key => $val) {
204 if (preg_match(
'/^dopayment_(.*)$/', $key, $reg)) {
205 $paymentmethod = $reg[1];
214$urlwithroot = DOL_MAIN_URL_ROOT;
216$urlok = $urlwithroot.
'/public/payment/paymentok.php?';
217$urlko = $urlwithroot.
'/public/payment/paymentko.php?';
220$ref = $REF =
GETPOST(
'ref',
'alpha');
222$FULLTAG =
GETPOST(
"fulltag",
'alpha');
223$SECUREKEY =
GETPOST(
"securekey");
225if ($paymentmethod && !preg_match(
'/'.preg_quote(
'PM='.$paymentmethod,
'/').
'/', $FULLTAG)) {
226 $FULLTAG .= ($FULLTAG ?
'.' :
'').
'PM='.$paymentmethod;
230 $FULLTAG .= ($FULLTAG ?
'.' :
'').
'WS='.$ws;
233if (!empty($suffix)) {
234 $urlok .=
'suffix='.urlencode($suffix).
'&';
235 $urlko .=
'suffix='.urlencode($suffix).
'&';
238 $urlok .=
's='.urlencode($source).
'&';
239 $urlko .=
's='.urlencode($source).
'&';
242 $urlok .=
'ref='.urlencode($REF).
'&';
243 $urlko .=
'ref='.urlencode($REF).
'&';
246 $urlok .=
'tag='.urlencode($TAG).
'&';
247 $urlko .=
'tag='.urlencode($TAG).
'&';
249if (!empty($FULLTAG)) {
250 $urlok .=
'fulltag='.urlencode($FULLTAG).
'&';
251 $urlko .=
'fulltag='.urlencode($FULLTAG).
'&';
253if (!empty($SECUREKEY)) {
254 $urlok .=
'securekey='.urlencode($SECUREKEY).
'&';
255 $urlko .=
'securekey='.urlencode($SECUREKEY).
'&';
257if (!empty($entity)) {
258 $urlok .=
'e='.urlencode((
string) ($entity)).
'&';
259 $urlko .=
'e='.urlencode((
string) ($entity)).
'&';
261if (!empty($getpostlang)) {
262 $urlok .=
'lang='.urlencode($getpostlang).
'&';
263 $urlko .=
'lang='.urlencode($getpostlang).
'&';
265$urlok = preg_replace(
'/&$/',
'', $urlok);
266$urlko = preg_replace(
'/&$/',
'', $urlko);
273@phan-var-force string $PAYPAL_API_SANDBOX
274@phan-var-force string $PAYPAL_API_OK
275@phan-var-force string $PAYPAL_API_KO
278if ((empty($paymentmethod) || $paymentmethod ==
'paypal') && isModEnabled(
'paypal')) {
279 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypal.lib.php';
280 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypalfunctions.lib.php';
286 $PAYPAL_API_OK = $urlok;
290 $PAYPAL_API_KO = $urlko;
292 if (empty($PAYPAL_API_USER)) {
293 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>.';
296 if (empty($PAYPAL_API_PASSWORD)) {
297 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>.';
300 if (empty($PAYPAL_API_SIGNATURE)) {
301 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>.';
308if ((empty($paymentmethod) || $paymentmethod ==
'stripe') && isModEnabled(
'stripe')) {
309 require_once DOL_DOCUMENT_ROOT.
'/stripe/config.php';
314$validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod);
318if ($tmpsource ==
'membersubscription') {
319 $tmpsource =
'member';
325 if ($tmpsource && $REF) {
329 if ($tmpsource != $source) {
333 $tokenisok =
dol_verifyHash($conf->global->PAYMENT_SECURITY_TOKEN, $SECUREKEY,
'2');
336 $tokenisok = ($conf->global->PAYMENT_SECURITY_TOKEN == $SECUREKEY);
343 dol_syslog(
"Warning: PAYMENT_SECURITY_ACCEPT_ANY_TOKEN is on", LOG_WARNING);
348 print
'<div class="error">Bad value for key.</div>';
354if (!empty($paymentmethod) && empty($validpaymentmethod[$paymentmethod])) {
355 print
'Payment module for payment method '.$paymentmethod.
' is not active';
358if (empty($validpaymentmethod)) {
359 print
'No active payment module (Paypal, Stripe, Paybox, ...)';
364$creditor = $mysoc->name;
365$paramcreditor =
'ONLINE_PAYMENT_CREDITOR';
366$paramcreditorlong =
'ONLINE_PAYMENT_CREDITOR_'.$suffix;
381dol_syslog(
"--- newpayment.php action = ".$action.
" paymentmethod=".$paymentmethod.
' amount='.$amount.
' newamount='.
GETPOST(
"newamount",
'alpha'), LOG_DEBUG, 0,
'_payment');
384if ($action ==
'dopayment') {
385 if ($paymentmethod ==
'paypal') {
387 $PAYPAL_PAYMENT_TYPE =
'Sale';
390 $origfulltag =
GETPOST(
"fulltag",
'alpha');
391 $shipToName =
GETPOST(
"shipToName",
'alpha');
392 $shipToStreet =
GETPOST(
"shipToStreet",
'alpha');
393 $shipToCity =
GETPOST(
"shipToCity",
'alpha');
394 $shipToState =
GETPOST(
"shipToState",
'alpha');
395 $shipToCountryCode =
GETPOST(
"shipToCountryCode",
'alpha');
396 $shipToZip =
GETPOST(
"shipToZip",
'alpha');
397 $shipToStreet2 =
GETPOST(
"shipToStreet2",
'alpha');
398 $phoneNum =
GETPOST(
"phoneNum",
'alpha');
399 $email =
GETPOST(
"email",
'alpha');
400 $desc =
GETPOST(
"desc",
'alpha');
404 if ($shipToCountryCode ==
'ID' && !preg_match(
'/\-/', $shipToState)) {
405 $shipToState =
'ID-'.$shipToState;
408 if (empty($PAYPAL_API_PRICE) || !is_numeric($PAYPAL_API_PRICE)) {
409 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount"));
413 } elseif (!$origfulltag) {
414 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"PaymentCode"));
419 dol_syslog(
"newpayment.php call paypal api and do redirect", LOG_DEBUG);
422 $PAYPAL_API_DEVISE =
"USD";
423 if (!empty($currency)) {
424 $PAYPAL_API_DEVISE = $currency;
429 dol_syslog(
"PAYPAL_API_USER: $PAYPAL_API_USER", LOG_DEBUG);
430 dol_syslog(
"PAYPAL_API_PASSWORD: ".preg_replace(
'/./',
'*', $PAYPAL_API_PASSWORD), LOG_DEBUG);
431 dol_syslog(
"PAYPAL_API_SIGNATURE: $PAYPAL_API_SIGNATURE", LOG_DEBUG);
432 dol_syslog(
"PAYPAL_API_SANDBOX: $PAYPAL_API_SANDBOX", LOG_DEBUG);
433 dol_syslog(
"PAYPAL_API_OK: $PAYPAL_API_OK", LOG_DEBUG);
434 dol_syslog(
"PAYPAL_API_KO: $PAYPAL_API_KO", LOG_DEBUG);
435 dol_syslog(
"PAYPAL_API_PRICE: $PAYPAL_API_PRICE", LOG_DEBUG);
436 dol_syslog(
"PAYPAL_API_DEVISE: $PAYPAL_API_DEVISE", LOG_DEBUG);
438 dol_syslog(
"shipToName: $shipToName", LOG_DEBUG);
439 dol_syslog(
"shipToStreet: $shipToStreet", LOG_DEBUG);
440 dol_syslog(
"shipToCity: $shipToCity", LOG_DEBUG);
441 dol_syslog(
"shipToState: $shipToState", LOG_DEBUG);
442 dol_syslog(
"shipToCountryCode: $shipToCountryCode", LOG_DEBUG);
443 dol_syslog(
"shipToZip: $shipToZip", LOG_DEBUG);
444 dol_syslog(
"shipToStreet2: $shipToStreet2", LOG_DEBUG);
449 dol_syslog(
"SCRIPT_URI: ".(empty($_SERVER[
"SCRIPT_URI"]) ?
'' : $_SERVER[
"SCRIPT_URI"]), LOG_DEBUG);
452 $mesg =
print_paypal_redirect($PAYPAL_API_PRICE, $PAYPAL_API_DEVISE, $PAYPAL_PAYMENT_TYPE, $PAYPAL_API_OK, $PAYPAL_API_KO, $FULLTAG);
459 if ($paymentmethod ==
'paybox') {
464 $origfulltag =
GETPOST(
"fulltag",
'alpha');
467 $urlok = preg_replace(
'/securekey=[^&]+&?/',
'', $urlok);
468 $urlko = preg_replace(
'/securekey=[^&]+&?/',
'', $urlko);
470 if (empty($PRICE) || !is_numeric($PRICE)) {
471 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount"));
472 } elseif (empty($email)) {
473 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ONLINE_PAYMENT_SENDEMAIL"));
475 $mesg = $langs->trans(
"ErrorBadEMail", $email);
476 } elseif (!$origfulltag) {
477 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"PaymentCode"));
479 $mesg =
'Error urlok too long '.$urlok.
' (Paybox requires 150, found '.strlen($urlok).
')';
481 $mesg =
'Error urlko too long '.$urlko.
' (Paybox requires 150, found '.strlen($urlok).
')';
485 dol_syslog(
"newpayment.php call paybox api and do redirect", LOG_DEBUG);
487 include_once DOL_DOCUMENT_ROOT.
'/paybox/lib/paybox.lib.php';
495 if ($paymentmethod ==
'stripe') {
496 if (
GETPOST(
'newamount',
'alpha')) {
499 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount")),
null,
'errors');
509if ($action ==
'charge' && isModEnabled(
'stripe')) {
510 $amountstripe = (float) $amount;
514 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
515 if (!in_array($currency, $arrayzerounitcurrency)) {
516 $amountstripe *= 100;
519 dol_syslog(
"--- newpayment.php Execute action = ".$action.
" STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION=".
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION'), LOG_DEBUG, 0,
'_payment');
520 dol_syslog(
"GET=".var_export($_GET,
true), LOG_DEBUG, 0,
'_payment');
521 dol_syslog(
"POST=".var_export($_POST,
true), LOG_DEBUG, 0,
'_payment');
523 $stripeToken =
GETPOST(
"stripeToken",
'alpha');
524 $email =
GETPOST(
"email",
'alpha');
528 $vatnumber =
GETPOST(
'vatnumber',
'alpha');
529 $savesource = GETPOSTISSET(
'savesource') ?
GETPOSTINT(
'savesource') : 1;
531 dol_syslog(
"POST stripeToken = ".$stripeToken, LOG_DEBUG, 0,
'_payment');
532 dol_syslog(
"POST email = ".$email, LOG_DEBUG, 0,
'_payment');
533 dol_syslog(
"POST thirdparty_id = ".$thirdparty_id, LOG_DEBUG, 0,
'_payment');
534 dol_syslog(
"POST vatnumber = ".$vatnumber, LOG_DEBUG, 0,
'_payment');
541 if (!
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION')) {
544 'dol_version' => DOL_VERSION,
545 'dol_entity' => $conf->entity,
546 'dol_company' => $mysoc->name,
547 'dol_tax_num' => $vatnumber,
551 if (!empty($thirdparty_id)) {
552 $metadata[
"dol_thirdparty_id"] = $thirdparty_id;
555 if ($thirdparty_id > 0) {
556 dol_syslog(
"Search existing Stripe customer profile for thirdparty_id=".$thirdparty_id, LOG_DEBUG, 0,
'_payment');
558 $service =
'StripeTest';
561 $service =
'StripeLive';
565 $thirdparty =
new Societe($db);
566 $thirdparty->fetch($thirdparty_id);
569 include_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
570 $stripe =
new Stripe($db);
571 $stripeacc = $stripe->getStripeAccount($service);
572 $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 1);
573 if (empty($customer)) {
575 dol_syslog(
'Failed to get/create stripe customer for thirdparty id = '.$thirdparty_id.
' and servicestatus = '.$servicestatus.
': '.$stripe->error, LOG_ERR, 0,
'_payment');
576 setEventMessages(
'Failed to get/create stripe customer for thirdparty id = '.$thirdparty_id.
' and servicestatus = '.$servicestatus.
': '.$stripe->error,
null,
'errors');
583 $card = $customer->sources->create(array(
"source" => $stripeToken,
"metadata" => $metadata));
585 $card = $stripeToken;
590 dol_syslog(
'Failed to create card record', LOG_WARNING, 0,
'_payment');
594 if (!empty($FULLTAG)) {
595 $metadata[
"FULLTAG"] = $FULLTAG;
597 if (!empty($dol_id)) {
598 $metadata[
"dol_id"] = $dol_id;
600 if (!empty($dol_type)) {
601 $metadata[
"dol_type"] = $dol_type;
604 dol_syslog(
"Create charge on card ".$card->id, LOG_DEBUG, 0,
'_payment');
605 $charge = \Stripe\Charge::create(array(
606 'amount' =>
price2num($amountstripe,
'MU'),
607 'currency' => $currency,
609 'description' =>
'Stripe payment: '.$FULLTAG.
' ref='.$ref,
610 'metadata' => $metadata,
611 'customer' => $customer->id,
613 'statement_descriptor_suffix' =>
dol_trunc($FULLTAG, 10,
'right',
'UTF-8', 1),
614 ), array(
"idempotency_key" =>
"$FULLTAG",
"stripe_account" =>
"$stripeacc"));
616 if (empty($charge)) {
618 dol_syslog(
'Failed to charge card', LOG_WARNING, 0,
'_payment');
625 $vatcleaned = $vatnumber ? $vatnumber :
null;
636 dol_syslog(
"Create anonymous customer card profile", LOG_DEBUG, 0,
'_payment');
638 $customer = \Stripe\Customer::create(array(
640 'description' => ($email ?
'Anonymous customer for '.$email :
'Anonymous customer'),
641 'metadata' => $metadata,
642 'source' => $stripeToken
661 if (!empty($FULLTAG)) {
662 $metadata[
"FULLTAG"] = $FULLTAG;
664 if (!empty($dol_id)) {
665 $metadata[
"dol_id"] = $dol_id;
667 if (!empty($dol_type)) {
668 $metadata[
"dol_type"] = $dol_type;
673 dol_syslog(
"Create charge", LOG_DEBUG, 0,
'_payment');
674 $charge = \Stripe\Charge::create(array(
675 'customer' => $customer->id,
676 'amount' =>
price2num($amountstripe,
'MU'),
677 'currency' => $currency,
679 'description' =>
'Stripe payment: '.$FULLTAG.
' ref='.$ref,
680 'metadata' => $metadata,
681 'statement_descriptor' =>
dol_trunc($FULLTAG, 10,
'right',
'UTF-8', 1),
682 ), array(
"idempotency_key" => (
string) $FULLTAG,
"stripe_account" => (
string) $stripeacc));
684 if (empty($charge)) {
686 dol_syslog(
'Failed to charge card', LOG_WARNING, 0,
'_payment');
693 $body = $e->getJsonBody();
694 $err = $body[
'error'];
696 print(
'Status is:'.$e->getHttpStatus().
"\n");
697 print(
'Type is:'.$err[
'type'].
"\n");
698 print(
'Code is:'.$err[
'code'].
"\n");
700 print(
'Param is:'.$err[
'param'].
"\n");
701 print(
'Message is:'.$err[
'message'].
"\n");
704 $errormessage =
"ErrorCard ".$e->getMessage().
" err=".var_export($err,
true);
705 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
711 $errormessage =
"ErrorRateLimit ".$e->getMessage();
712 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
718 $errormessage =
"ErrorInvalidRequest ".$e->getMessage();
719 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
726 $errormessage =
"ErrorAuthentication ".$e->getMessage();
727 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
733 $errormessage =
"ErrorApiConnection ".$e->getMessage();
734 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
741 $errormessage =
"ErrorBase ".$e->getMessage();
742 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
748 $errormessage =
"ErrorException ".$e->getMessage();
749 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
756 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION')) {
757 $service =
'StripeTest';
760 $service =
'StripeLive';
763 include_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
764 $stripe =
new Stripe($db);
765 $stripeacc = $stripe->getStripeAccount($service);
769 $paymentintent_id =
GETPOST(
"paymentintent_id",
"alpha");
772 global $stripearrayofkeysbyenv;
773 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
776 if (empty($stripeacc)) {
777 $paymentintent = \Stripe\PaymentIntent::retrieve($paymentintent_id);
779 $paymentintent = \Stripe\PaymentIntent::retrieve($paymentintent_id, array(
"stripe_account" => $stripeacc));
783 $errormessage =
"CantRetrievePaymentIntent ".$e->getMessage();
784 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
789 if ($paymentintent->status !=
'succeeded') {
791 $errormessage =
"StatusOfRetrievedIntent is not succeeded: ".$paymentintent->status;
792 dol_syslog($errormessage, LOG_WARNING, 0,
'_payment');
802 if (!empty($paymentintent->currency) && !empty($paymentintent->amount)) {
803 $currency = strtoupper($paymentintent->currency);
804 $amount = $paymentintent->amount;
808 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
809 if (!in_array($currency, $arrayzerounitcurrency)) {
819 $_SESSION[
"onlinetoken"] = $stripeToken;
820 $_SESSION[
"FinalPaymentAmt"] = $amount;
821 $_SESSION[
"currencyCodeType"] = $currency;
822 $_SESSION[
"paymentType"] =
'';
823 $_SESSION[
'ipaddress'] = ($remoteip ? $remoteip :
'unknown');
824 $_SESSION[
'payerID'] = is_object($customer) ? $customer->id :
'';
825 $_SESSION[
'TRANSACTIONID'] = (is_object($charge) ? $charge->id : (is_object($paymentintent) ? $paymentintent->id :
''));
826 $_SESSION[
'errormessage'] = $errormessage;
828 dol_syslog(
"Action charge stripe STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION=".
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION').
" ip=".$remoteip, LOG_DEBUG, 0,
'_payment');
829 dol_syslog(
"onlinetoken=".$_SESSION[
"onlinetoken"].
" FinalPaymentAmt=".$_SESSION[
"FinalPaymentAmt"].
" currencyCodeType=".$_SESSION[
"currencyCodeType"].
" payerID=".$_SESSION[
'payerID'].
" TRANSACTIONID=".$_SESSION[
'TRANSACTIONID'], LOG_DEBUG, 0,
'_payment');
830 dol_syslog(
"FULLTAG=".$FULLTAG, LOG_DEBUG, 0,
'_payment');
831 dol_syslog(
"error=".$error.
" errormessage=".$errormessage, LOG_DEBUG, 0,
'_payment');
832 dol_syslog(
"_SERVER[SERVER_NAME] = ".(empty($_SERVER[
"SERVER_NAME"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_NAME"])), LOG_DEBUG, 0,
'_payment');
833 dol_syslog(
"_SERVER[SERVER_ADDR] = ".(empty($_SERVER[
"SERVER_ADDR"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_ADDR"])), LOG_DEBUG, 0,
'_payment');
834 dol_syslog(
"Now call the redirect to paymentok or paymentko, URL = ".($error ? $urlko : $urlok), LOG_DEBUG, 0,
'_payment');
837 header(
"Location: ".$urlko);
840 header(
"Location: ".$urlok);
847 'paymentmethod' => $paymentmethod,
848 'validpaymentmethod' => &$validpaymentmethod
850$reshook = $hookmanager->executeHooks(
'doPayment', $parameters,
$object, $action);
853} elseif ($reshook > 0) {
854 print $hookmanager->resPrint;
863$form =
new Form($db);
867 $head =
'<link rel="stylesheet" type="text/css" href="' .
getDolGlobalString(
'ONLINE_PAYMENT_CSS_URL').
'?lang='.(!empty($getpostlang) ? $getpostlang : $langs->defaultlang).
'">'.
"\n";
870$conf->dol_hide_topmenu = 1;
871$conf->dol_hide_leftmenu = 1;
873$replacemainarea = (empty($conf->dol_hide_leftmenu) ?
'<div>' :
'').
'<div>';
874llxHeader($head, $langs->trans(
"PaymentForm"),
'',
'', 0, 0,
'',
'',
'',
'onlinepaymentbody', $replacemainarea);
876dol_syslog(
"newpayment.php show page source=".$source.
" paymentmethod=".$paymentmethod.
' amount='.$amount.
' newamount='.
GETPOST(
"newamount",
'alpha').
" ref=".$ref, LOG_DEBUG, 0,
'_payment');
877dol_syslog(
"_SERVER[SERVER_NAME] = ".(empty($_SERVER[
"SERVER_NAME"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_NAME"])), LOG_DEBUG, 0,
'_payment');
878dol_syslog(
"_SERVER[SERVER_ADDR] = ".(empty($_SERVER[
"SERVER_ADDR"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_ADDR"])), LOG_DEBUG, 0,
'_payment');
881if ($source && in_array($ref, array(
'member_ref',
'contractline_ref',
'invoice_ref',
'order_ref',
'donation_ref',
''))) {
882 $langs->load(
"errors");
883 dol_print_error_email(
'BADREFINPAYMENTFORM', $langs->trans(
"ErrorBadLinkSourceSetButBadValueForRef", $source, $ref));
892if ((empty($paymentmethod) || $paymentmethod ==
'paypal') && isModEnabled(
'paypal') && (
getDolGlobalString(
'PAYPAL_API_SANDBOX') ||
GETPOSTINT(
'forcesandbox'))) {
893 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Paypal'), array(),
'warning');
895if ((empty($paymentmethod) || $paymentmethod ==
'stripe') && isModEnabled(
'stripe') && (!
getDolGlobalString(
'STRIPE_LIVE') ||
GETPOSTINT(
'forcesandbox'))) {
896 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Stripe'), array(),
'warning');
900print
'<span id="dolpaymentspan"></span>'.
"\n";
901print
'<div class="center">'.
"\n";
902print
'<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
903print
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
904print
'<input type="hidden" name="action" value="dopayment">'.
"\n";
905print
'<input type="hidden" name="tag" value="'.GETPOST(
"tag",
'alpha').
'">'.
"\n";
906print
'<input type="hidden" name="suffix" value="'.dol_escape_htmltag($suffix).
'">'.
"\n";
907print
'<input type="hidden" name="securekey" value="'.dol_escape_htmltag($SECUREKEY).
'">'.
"\n";
908print
'<input type="hidden" name="e" value="'.$entity.
'" />';
909print
'<input type="hidden" name="forcesandbox" value="'.GETPOSTINT(
'forcesandbox').
'" />';
910print
'<input type="hidden" name="lang" value="'.$getpostlang.
'">';
911print
'<input type="hidden" name="ws" value="'.$ws.
'">';
917$logosmall = $mysoc->logo_small;
919$paramlogo =
'ONLINE_PAYMENT_LOGO_'.$suffix;
929if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.
'/logos/thumbs/'.$logosmall)) {
930 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
931 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
932} elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.
'/logos/'.$logo)) {
933 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
934 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
938if ($urllogo && !$ws) {
939 print
'<div class="backgreypublicpayment">';
940 print
'<div class="logopublicpayment">';
941 print
'<img id="dolpaymentlogo" src="'.$urllogo.
'"';
945 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>';
948} elseif ($creditor && !$ws) {
949 print
'<div class="backgreypublicpayment">';
950 print
'<div class="logopublicpayment">';
956 print
'<div class="backimagepublicpayment">';
957 print
'<img id="idMAIN_IMAGE_PUBLIC_PAYMENT" src="'.getDolGlobalString(
'MAIN_IMAGE_PUBLIC_PAYMENT').
'">';
964print
'<!-- Form to send a payment -->'.
"\n";
965print
'<!-- creditor = '.dol_escape_htmltag($creditor).
' -->'.
"\n";
967if (isModEnabled(
'paypal')) {
968 print
'<!-- PAYPAL_API_SANDBOX = '.getDolGlobalString(
'PAYPAL_API_SANDBOX').
' -->'.
"\n";
969 print
'<!-- PAYPAL_API_INTEGRAL_OR_PAYPALONLY = '.getDolGlobalString(
'PAYPAL_API_INTEGRAL_OR_PAYPALONLY').
' -->'.
"\n";
971if (isModEnabled(
'paybox')) {
972 print
'<!-- PAYBOX_CGI_URL = '.getDolGlobalString(
'PAYBOX_CGI_URL_V2').
' -->'.
"\n";
974if (isModEnabled(
'stripe')) {
975 print
'<!-- STRIPE_LIVE = '.getDolGlobalString(
'STRIPE_LIVE').
' -->'.
"\n";
977print
'<!-- urlok = '.$urlok.
' -->'.
"\n";
978print
'<!-- urlko = '.$urlko.
' -->'.
"\n";
982print
'<table id="dolpublictable" summary="Payment form" class="center">'.
"\n";
987 $langs->load(
"members");
988 if (preg_match(
'/^\((.*)\)$/', $conf->global->PAYMENT_NEWFORM_TEXT, $reg)) {
989 $text .= $langs->trans($reg[1]).
"<br>\n";
993 $text =
'<tr><td align="center"><br>'.$text.
'<br></td></tr>'.
"\n";
996 $text .=
'<tr><td class="textpublicpayment"><br><strong>'.$langs->trans(
"WelcomeOnPaymentPage").
'</strong></td></tr>'.
"\n";
997 $text .=
'<tr><td class="textpublicpayment"><span class="opacitymedium">'.$langs->trans(
"ThisScreenAllowsYouToPay", $creditor).
'</span><br><br></td></tr>'.
"\n";
1002print
'<tr><td align="center">';
1003print
'<table class="centpercent left" id="tablepublicpayment">';
1004print
'<tr class="hideonsmartphone"><td colspan="2" align="left" class="opacitymedium">'.$langs->trans(
"ThisIsInformationOnPayment").
' :</td></tr>'.
"\n";
1017 $tag =
GETPOST(
"tag",
'alpha');
1018 if (
GETPOST(
'fulltag',
'alpha')) {
1019 $fulltag =
GETPOST(
'fulltag',
'alpha');
1021 $fulltag =
"TAG=".$tag;
1025 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
1026 print
'</td><td class="CTableRow2">';
1027 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1028 print
'<b>'.$creditor.
'</b>';
1029 print
'<input type="hidden" name="creditor" value="'.$creditor.
'">';
1030 print
'</td></tr>'.
"\n";
1033 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Amount");
1034 if (empty($amount)) {
1035 print
' ('.$langs->trans(
"ToComplete").
')';
1037 print
'</td><td class="CTableRow2">';
1038 if (empty($amount) || !is_numeric($amount)) {
1039 print
'<input type="hidden" name="amount" value="'.price2num(
GETPOST(
"amount",
'alpha'),
'MT').
'">';
1040 print
'<input class="flat maxwidth75" type="text" name="newamount" value="'.price2num(
GETPOST(
"newamount",
"alpha"),
'MT').
'">';
1042 print
' <b>'.$langs->trans(
"Currency".$currency).
'</b>';
1044 print
'<b class="amount">'.price($amount, 1, $langs, 1, -1, -1, $currency).
'</b>';
1045 print
'<input type="hidden" name="amount" value="'.$amount.
'">';
1046 print
'<input type="hidden" name="newamount" value="'.$amount.
'">';
1048 print
'<input type="hidden" name="currency" value="'.$currency.
'">';
1049 print
'</td></tr>'.
"\n";
1052 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentCode");
1053 print
'</td><td class="CTableRow2"><b style="word-break: break-all;">'.$fulltag.
'</b>';
1054 print
'<input type="hidden" name="tag" value="'.$tag.
'">';
1055 print
'<input type="hidden" name="fulltag" value="'.$fulltag.
'">';
1056 print
'</td></tr>'.
"\n";
1064if ($source ==
'order') {
1066 $langs->load(
"orders");
1068 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
1071 $result = $order->fetch(0, $ref);
1073 $mesg = $order->error;
1076 $result = $order->fetch_thirdparty($order->socid);
1080 if ($action !=
'dopayment') {
1081 $amount = $order->total_ttc;
1082 if (
GETPOST(
"amount",
'alpha')) {
1083 $amount =
GETPOST(
"amount",
'alpha');
1089 if (
GETPOST(
'fulltag',
'alpha')) {
1090 $fulltag =
GETPOST(
'fulltag',
'alpha');
1092 $fulltag =
'ORD='.$order->id.
'.CUS='.$order->thirdparty->id;
1095 $fulltag .=
'.TAG='.$TAG;
1101 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
1102 print
'</td><td class="CTableRow2">';
1103 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1104 print
'<b>'.$creditor.
'</b>';
1105 print
'<input type="hidden" name="creditor" value="'.$creditor.
'">';
1106 print
'</td></tr>'.
"\n";
1109 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"ThirdParty");
1110 print
'</td><td class="CTableRow2">';
1111 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1112 print
'<b>'.$order->thirdparty->name.
'</b>';
1113 print
'</td></tr>'.
"\n";
1116 $text =
'<b>'.$langs->trans(
"PaymentOrderRef", $order->ref).
'</b>';
1117 if (
GETPOST(
'desc',
'alpha')) {
1118 $text =
'<b>'.$langs->trans(
GETPOST(
'desc',
'alpha')).
'</b>';
1120 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Designation");
1121 print
'</td><td class="CTableRow2">'.$text;
1122 print
'<input type="hidden" name="s" value="'.dol_escape_htmltag($source).
'">';
1123 print
'<input type="hidden" name="ref" value="'.dol_escape_htmltag($order->ref).
'">';
1124 print
'<input type="hidden" name="dol_id" value="'.dol_escape_htmltag((
string) $order->id).
'">';
1125 $directdownloadlink = $order->getLastMainDocLink(
'commande');
1126 if ($directdownloadlink) {
1127 print
'<br><a href="'.$directdownloadlink.
'" rel="nofollow noopener">';
1128 print
img_mime($order->last_main_doc,
'');
1129 print $langs->trans(
"DownloadDocument").
'</a>';
1131 print
'</td></tr>'.
"\n";
1134 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Amount");
1135 if (empty($amount)) {
1136 print
' ('.$langs->trans(
"ToComplete").
')';
1138 print
'</td><td class="CTableRow2">';
1139 if (empty($amount) || !is_numeric($amount)) {
1140 print
'<input type="hidden" name="amount" value="'.price2num(
GETPOST(
"amount",
'alpha'),
'MT').
'">';
1141 print
'<input class="flat maxwidth75" type="text" name="newamount" value="'.price2num(
GETPOST(
"newamount",
"alpha"),
'MT').
'">';
1143 print
' <b>'.$langs->trans(
"Currency".$currency).
'</b>';
1145 print
'<b class="amount">'.price($amount, 1, $langs, 1, -1, -1, $currency).
'</b>';
1146 print
'<input type="hidden" name="amount" value="'.$amount.
'">';
1147 print
'<input type="hidden" name="newamount" value="'.$amount.
'">';
1149 print
'<input type="hidden" name="currency" value="'.$currency.
'">';
1150 print
'</td></tr>'.
"\n";
1153 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentCode");
1154 print
'</td><td class="CTableRow2"><b style="word-break: break-all;">'.$fulltag.
'</b>';
1155 print
'<input type="hidden" name="tag" value="'.dol_escape_htmltag($tag).
'">';
1156 print
'<input type="hidden" name="fulltag" value="'.dol_escape_htmltag($fulltag).
'">';
1157 print
'</td></tr>'.
"\n";
1160 $shipToName = $order->thirdparty->name;
1161 $shipToStreet = $order->thirdparty->address;
1162 $shipToCity = $order->thirdparty->town;
1163 $shipToState = $order->thirdparty->state_code;
1164 $shipToCountryCode = $order->thirdparty->country_code;
1165 $shipToZip = $order->thirdparty->zip;
1166 $shipToStreet2 =
'';
1167 $phoneNum = $order->thirdparty->phone;
1168 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1169 print
'<input type="hidden" name="shipToName" value="'.dol_escape_htmltag($shipToName).
'">'.
"\n";
1170 print
'<input type="hidden" name="shipToStreet" value="'.dol_escape_htmltag($shipToStreet).
'">'.
"\n";
1171 print
'<input type="hidden" name="shipToCity" value="'.dol_escape_htmltag($shipToCity).
'">'.
"\n";
1172 print
'<input type="hidden" name="shipToState" value="'.dol_escape_htmltag($shipToState).
'">'.
"\n";
1173 print
'<input type="hidden" name="shipToCountryCode" value="'.dol_escape_htmltag($shipToCountryCode).
'">'.
"\n";
1174 print
'<input type="hidden" name="shipToZip" value="'.dol_escape_htmltag($shipToZip).
'">'.
"\n";
1175 print
'<input type="hidden" name="shipToStreet2" value="'.dol_escape_htmltag($shipToStreet2).
'">'.
"\n";
1176 print
'<input type="hidden" name="phoneNum" value="'.dol_escape_htmltag($phoneNum).
'">'.
"\n";
1178 print
'<!-- Shipping address not complete, so we don t use it -->'.
"\n";
1180 if (is_object($order->thirdparty)) {
1181 print
'<input type="hidden" name="thirdparty_id" value="'.$order->thirdparty->id.
'">'.
"\n";
1183 print
'<input type="hidden" name="email" value="'.$order->thirdparty->email.
'">'.
"\n";
1184 print
'<input type="hidden" name="vatnumber" value="'.dol_escape_htmltag($order->thirdparty->tva_intra).
'">'.
"\n";
1185 $labeldesc = $langs->trans(
"Order").
' '.$order->ref;
1186 if (
GETPOST(
'desc',
'alpha')) {
1187 $labeldesc =
GETPOST(
'desc',
'alpha');
1189 print
'<input type="hidden" name="desc" value="'.dol_escape_htmltag($labeldesc).
'">'.
"\n";
1194if ($source ==
'invoice') {
1196 $langs->load(
"bills");
1197 $form->load_cache_types_paiements();
1199 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1202 $result = $invoice->fetch(0, $ref);
1204 $mesg = $invoice->error;
1207 $result = $invoice->fetch_thirdparty($invoice->socid);
1211 if ($action !=
'dopayment') {
1212 $amount =
price2num($invoice->total_ttc - ($invoice->getSommePaiement() + $invoice->getSumCreditNotesUsed() + $invoice->getSumDepositsUsed()));
1213 if (
GETPOST(
"amount",
'alpha')) {
1214 $amount =
GETPOST(
"amount",
'alpha');
1219 if (
GETPOST(
'fulltag',
'alpha')) {
1220 $fulltag =
GETPOST(
'fulltag',
'alpha');
1222 $fulltag =
'INV='.$invoice->id.
'.CUS='.$invoice->thirdparty->id;
1225 $fulltag .=
'.TAG='.$TAG;
1231 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
1232 print
'</td><td class="CTableRow2">';
1233 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1234 print
'<b>'.$creditor.
'</b>';
1235 print
'<input type="hidden" name="creditor" value="'.dol_escape_htmltag($creditor).
'">';
1236 print
'</td></tr>'.
"\n";
1239 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"ThirdParty");
1240 print
'</td><td class="CTableRow2">';
1241 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1242 print
'<b>'.$invoice->thirdparty->name.
'</b>';
1243 print
'</td></tr>'.
"\n";
1246 $text =
'<b>'.$langs->trans(
"PaymentInvoiceRef", $invoice->ref).
'</b>';
1247 if (
GETPOST(
'desc',
'alpha')) {
1248 $text =
'<b>'.$langs->trans(
GETPOST(
'desc',
'alpha')).
'</b>';
1250 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Designation");
1251 print
'</td><td class="CTableRow2">'.$text;
1252 print
'<input type="hidden" name="s" value="'.dol_escape_htmltag($source).
'">';
1253 print
'<input type="hidden" name="ref" value="'.dol_escape_htmltag($invoice->ref).
'">';
1254 print
'<input type="hidden" name="dol_id" value="'.dol_escape_htmltag((
string) $invoice->id).
'">';
1255 $directdownloadlink = $invoice->getLastMainDocLink(
'facture');
1256 if ($directdownloadlink) {
1257 print
'<br><a href="'.$directdownloadlink.
'">';
1258 print
img_mime($invoice->last_main_doc,
'');
1259 print $langs->trans(
"DownloadDocument").
'</a>';
1261 print
'</td></tr>'.
"\n";
1264 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentAmount");
1265 if (empty($amount) && empty(
$object->paye)) {
1266 print
' ('.$langs->trans(
"ToComplete").
')';
1268 print
'</td><td class="CTableRow2">';
1269 if (
$object->type == $object::TYPE_CREDIT_NOTE) {
1270 print
'<b>'.$langs->trans(
"CreditNote").
'</b>';
1271 } elseif (empty(
$object->paye)) {
1272 if (empty($amount) || !is_numeric($amount)) {
1273 print
'<input type="hidden" name="amount" value="'.price2num(
GETPOST(
"amount",
'alpha'),
'MT').
'">';
1274 print
'<input class="flat maxwidth75" type="text" name="newamount" value="'.price2num(
GETPOST(
"newamount",
"alpha"),
'MT').
'">';
1275 print
' <b>'.$langs->trans(
"Currency".$currency).
'</b>';
1277 print
'<b class="amount">'.price($amount, 1, $langs, 1, -1, -1, $currency).
'</b>';
1278 print
'<input type="hidden" name="amount" value="'.$amount.
'">';
1279 print
'<input type="hidden" name="newamount" value="'.$amount.
'">';
1282 print
'<b class="amount">'.price(
$object->total_ttc, 1, $langs, 1, -1, -1, $currency).
'</b>';
1284 print
'<input type="hidden" name="currency" value="'.$currency.
'">';
1285 print
'</td></tr>'.
"\n";
1288 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentCode");
1289 print
'</td><td class="CTableRow2"><b style="word-break: break-all;">'.$fulltag.
'</b>';
1290 print
'<input type="hidden" name="tag" value="'.(empty($tag) ?
'' : $tag).
'">';
1291 print
'<input type="hidden" name="fulltag" value="'.$fulltag.
'">';
1292 print
'</td></tr>'.
"\n";
1295 if ($invoice->status == $invoice::STATUS_VALIDATED && $invoice->mode_reglement_id > 0 && $form->cache_types_paiements[$invoice->mode_reglement_id][
"code"] ==
"VIR") {
1296 print
'<tr class="CTableRow2 center"><td class="CTableRow2" colspan="2">';
1297 print
'<div class="warning maxwidth1000">';
1298 print $langs->trans(
"PayOfBankTransferInvoice");
1300 print
'</td></tr>'.
"\n";
1304 $shipToName = $invoice->thirdparty->name;
1305 $shipToStreet = $invoice->thirdparty->address;
1306 $shipToCity = $invoice->thirdparty->town;
1307 $shipToState = $invoice->thirdparty->state_code;
1308 $shipToCountryCode = $invoice->thirdparty->country_code;
1309 $shipToZip = $invoice->thirdparty->zip;
1310 $shipToStreet2 =
'';
1311 $phoneNum = $invoice->thirdparty->phone;
1312 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1313 print
'<input type="hidden" name="shipToName" value="'.$shipToName.
'">'.
"\n";
1314 print
'<input type="hidden" name="shipToStreet" value="'.$shipToStreet.
'">'.
"\n";
1315 print
'<input type="hidden" name="shipToCity" value="'.$shipToCity.
'">'.
"\n";
1316 print
'<input type="hidden" name="shipToState" value="'.$shipToState.
'">'.
"\n";
1317 print
'<input type="hidden" name="shipToCountryCode" value="'.$shipToCountryCode.
'">'.
"\n";
1318 print
'<input type="hidden" name="shipToZip" value="'.$shipToZip.
'">'.
"\n";
1319 print
'<input type="hidden" name="shipToStreet2" value="'.$shipToStreet2.
'">'.
"\n";
1320 print
'<input type="hidden" name="phoneNum" value="'.$phoneNum.
'">'.
"\n";
1322 print
'<!-- Shipping address not complete, so we don t use it -->'.
"\n";
1324 if (is_object($invoice->thirdparty)) {
1325 print
'<input type="hidden" name="thirdparty_id" value="'.$invoice->thirdparty->id.
'">'.
"\n";
1327 print
'<input type="hidden" name="email" value="'.$invoice->thirdparty->email.
'">'.
"\n";
1328 print
'<input type="hidden" name="vatnumber" value="'.$invoice->thirdparty->tva_intra.
'">'.
"\n";
1329 $labeldesc = $langs->trans(
"Invoice").
' '.$invoice->ref;
1330 if (
GETPOST(
'desc',
'alpha')) {
1331 $labeldesc =
GETPOST(
'desc',
'alpha');
1333 print
'<input type="hidden" name="desc" value="'.dol_escape_htmltag($labeldesc).
'">'.
"\n";
1337if ($source ==
'contractline') {
1339 $langs->load(
"contracts");
1341 require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
1346 $result = $contractline->fetch(0, $ref);
1348 $mesg = $contractline->error;
1351 if ($contractline->fk_contrat > 0) {
1352 $result = $contract->fetch($contractline->fk_contrat);
1354 $result = $contract->fetch_thirdparty($contract->socid);
1356 $mesg = $contract->error;
1360 $mesg =
'ErrorRecordNotFound';
1366 if ($action !=
'dopayment') {
1367 $amount = $contractline->total_ttc;
1369 if ($contractline->fk_product &&
getDolGlobalString(
'PAYMENT_USE_NEW_PRICE_FOR_CONTRACTLINES')) {
1371 $result = $product->fetch($contractline->fk_product);
1375 $pu_ht = $product->multiprices[$contract->thirdparty->price_level];
1376 $pu_ttc = $product->multiprices_ttc[$contract->thirdparty->price_level];
1377 $price_base_type = $product->multiprices_base_type[$contract->thirdparty->price_level];
1379 $pu_ht = $product->price;
1380 $pu_ttc = $product->price_ttc;
1381 $price_base_type = $product->price_base_type;
1385 if (empty($amount)) {
1391 if (
GETPOST(
"amount",
'alpha')) {
1392 $amount =
GETPOST(
"amount",
'alpha');
1397 if (
GETPOST(
'fulltag',
'alpha')) {
1398 $fulltag =
GETPOST(
'fulltag',
'alpha');
1400 $fulltag =
'COL='.$contractline->id.
'.CON='.$contract->id.
'.CUS='.$contract->thirdparty->id.
'.DAT='.
dol_print_date(
dol_now(),
'%Y%m%d%H%M%S');
1403 $fulltag .=
'.TAG='.$TAG;
1414 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
1415 print
'</td><td class="CTableRow2"><b>'.$creditor.
'</b>';
1416 print
'<input type="hidden" name="creditor" value="'.$creditor.
'">';
1417 print
'</td></tr>'.
"\n";
1420 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"ThirdParty");
1421 print
'</td><td class="CTableRow2"><b>'.$contract->thirdparty->name.
'</b>';
1422 print
'</td></tr>'.
"\n";
1425 $text =
'<b>'.$langs->trans(
"PaymentRenewContractId", $contract->ref, $contractline->ref).
'</b>';
1426 if ($contractline->fk_product > 0) {
1427 $contractline->fetch_product();
1428 $text .=
'<br>'.$contractline->product->ref.($contractline->product->label ?
' - '.$contractline->product->label :
'');
1430 if ($contractline->description) {
1431 $text .=
'<br>'.dol_htmlentitiesbr($contractline->description);
1433 if ($contractline->date_end) {
1434 $text .=
'<br>'.$langs->trans(
"ExpiredSince").
': '.
dol_print_date($contractline->date_end);
1436 if (
GETPOST(
'desc',
'alpha')) {
1437 $text =
'<b>'.$langs->trans(
GETPOST(
'desc',
'alpha')).
'</b>';
1439 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Designation");
1440 print
'</td><td class="CTableRow2">'.$text;
1441 print
'<input type="hidden" name="source" value="'.dol_escape_htmltag($source).
'">';
1442 print
'<input type="hidden" name="ref" value="'.dol_escape_htmltag($contractline->ref).
'">';
1443 print
'<input type="hidden" name="dol_id" value="'.dol_escape_htmltag((
string) $contractline->id).
'">';
1444 $directdownloadlink = $contract->getLastMainDocLink(
'contract');
1445 if ($directdownloadlink) {
1446 print
'<br><a href="'.$directdownloadlink.
'">';
1447 print
img_mime($contract->last_main_doc,
'');
1448 print $langs->trans(
"DownloadDocument").
'</a>';
1450 print
'</td></tr>'.
"\n";
1453 $label = $langs->trans(
"Quantity");
1456 if ($contractline->fk_product) {
1457 if ($contractline->product->isService() && $contractline->product->duration_value > 0) {
1458 $label = $langs->trans(
"Duration");
1461 if ($contractline->product->duration_value > 1) {
1462 $dur = array(
"h" => $langs->trans(
"Hours"),
"d" => $langs->trans(
"DurationDays"),
"w" => $langs->trans(
"DurationWeeks"),
"m" => $langs->trans(
"DurationMonths"),
"y" => $langs->trans(
"DurationYears"));
1464 $dur = array(
"h" => $langs->trans(
"Hour"),
"d" => $langs->trans(
"DurationDay"),
"w" => $langs->trans(
"DurationWeek"),
"m" => $langs->trans(
"DurationMonth"),
"y" => $langs->trans(
"DurationYear"));
1466 $duration = $contractline->product->duration_value.
' '.$dur[$contractline->product->duration_unit];
1469 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$label.
'</td>';
1470 print
'<td class="CTableRow2"><b>'.($duration ? $duration : $qty).
'</b>';
1471 print
'<input type="hidden" name="newqty" value="'.dol_escape_htmltag((
string) $qty).
'">';
1472 print
'</b></td></tr>'.
"\n";
1475 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Amount");
1476 if (empty($amount)) {
1477 print
' ('.$langs->trans(
"ToComplete").
')';
1479 print
'</td><td class="CTableRow2">';
1480 if (empty($amount) || !is_numeric($amount)) {
1481 print
'<input type="hidden" name="amount" value="'.price2num(
GETPOST(
"amount",
'alpha'),
'MT').
'">';
1482 print
'<input class="flat maxwidth75" type="text" name="newamount" value="'.price2num(
GETPOST(
"newamount",
"alpha"),
'MT').
'">';
1484 print
' <b>'.$langs->trans(
"Currency".$currency).
'</b>';
1486 print
'<b class="amount">'.price($amount, 1, $langs, 1, -1, -1, $currency).
'</b>';
1487 print
'<input type="hidden" name="amount" value="'.$amount.
'">';
1488 print
'<input type="hidden" name="newamount" value="'.$amount.
'">';
1490 print
'<input type="hidden" name="currency" value="'.$currency.
'">';
1491 print
'</td></tr>'.
"\n";
1494 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"PaymentCode");
1495 print
'</td><td class="CTableRow2"><b style="word-break: break-all;">'.$fulltag.
'</b>';
1496 print
'<input type="hidden" name="tag" value="'.$tag.
'">';
1497 print
'<input type="hidden" name="fulltag" value="'.$fulltag.
'">';
1498 print
'</td></tr>'.
"\n";
1501 $shipToName = $contract->thirdparty->name;
1502 $shipToStreet = $contract->thirdparty->address;
1503 $shipToCity = $contract->thirdparty->town;
1504 $shipToState = $contract->thirdparty->state_code;
1505 $shipToCountryCode = $contract->thirdparty->country_code;
1506 $shipToZip = $contract->thirdparty->zip;
1507 $shipToStreet2 =
'';
1508 $phoneNum = $contract->thirdparty->phone;
1509 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1510 print
'<input type="hidden" name="shipToName" value="'.$shipToName.
'">'.
"\n";
1511 print
'<input type="hidden" name="shipToStreet" value="'.$shipToStreet.
'">'.
"\n";
1512 print
'<input type="hidden" name="shipToCity" value="'.$shipToCity.
'">'.
"\n";
1513 print
'<input type="hidden" name="shipToState" value="'.$shipToState.
'">'.
"\n";
1514 print
'<input type="hidden" name="shipToCountryCode" value="'.$shipToCountryCode.
'">'.
"\n";
1515 print
'<input type="hidden" name="shipToZip" value="'.$shipToZip.
'">'.
"\n";
1516 print
'<input type="hidden" name="shipToStreet2" value="'.$shipToStreet2.
'">'.
"\n";
1517 print
'<input type="hidden" name="phoneNum" value="'.$phoneNum.
'">'.
"\n";
1519 print
'<!-- Shipping address not complete, so we don t use it -->'.
"\n";
1521 if (is_object($contract->thirdparty)) {
1522 print
'<input type="hidden" name="thirdparty_id" value="'.$contract->thirdparty->id.
'">'.
"\n";
1524 print
'<input type="hidden" name="email" value="'.$contract->thirdparty->email.
'">'.
"\n";
1525 print
'<input type="hidden" name="vatnumber" value="'.$contract->thirdparty->tva_intra.
'">'.
"\n";
1526 $labeldesc = $langs->trans(
"Contract").
' '.$contract->ref;
1527 if (
GETPOST(
'desc',
'alpha')) {
1528 $labeldesc =
GETPOST(
'desc',
'alpha');
1530 print
'<input type="hidden" name="desc" value="'.dol_escape_htmltag($labeldesc).
'">'.
"\n";
1534if ($source ==
'member' || $source ==
'membersubscription') {
1535 $newsource =
'member';
1539 $langs->load(
"members");
1541 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
1542 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent_type.class.php';
1543 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
1549 $result = $member->fetch(0, $ref);
1551 $mesg = $member->error;
1554 $member->fetch_thirdparty();
1556 $adht->fetch($member->typeid);
1560 if ($action !=
'dopayment') {
1561 $amount = $subscription->total_ttc;
1562 if (
GETPOST(
"amount",
'alpha')) {
1566 if (empty($amount)) {
1567 $amount = $adht->amount;
1570 $amount = max(0,
price2num($amount,
'MT'));
1573 if (
GETPOST(
'fulltag',
'alpha')) {
1574 $fulltag =
GETPOST(
'fulltag',
'alpha');
1579 $fulltag .=
'.TAG='.$TAG;
1585 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Creditor");
1586 print
'</td><td class="CTableRow2"><b>'.$creditor.
'</b>';
1587 print
'<input type="hidden" name="creditor" value="'.$creditor.
'">';
1588 print
'</td></tr>'.
"\n";
1591 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Member");
1592 print
'</td><td class="CTableRow2">';
1594 if ($member->morphy ==
'mor' && !empty($member->company)) {
1595 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1596 print $member->company;
1598 print
img_picto(
'',
'member',
'class="pictofixedwidth"');
1599 print $member->getFullName($langs);
1602 print
'</td></tr>'.
"\n";
1605 $text =
'<b>'.$langs->trans(
"PaymentSubscription").
'</b>';
1606 if (
GETPOST(
'desc',
'alpha')) {
1607 $text =
'<b>'.$langs->trans(
GETPOST(
'desc',
'alpha')).
'</b>';
1609 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"Designation");
1610 print
'</td><td class="CTableRow2">'.$text;
1611 print
'<input type="hidden" name="source" value="'.dol_escape_htmltag($newsource).
'">';
1612 print
'<input type="hidden" name="ref" value="'.dol_escape_htmltag($member->ref).
'">';
1613 print
'</td></tr>'.
"\n";
1616 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"DateEndSubscription");
1617 print
'</td><td class="CTableRow2">'.dol_print_date($member->datefin,
'day');
1618 print
'</td></tr>'.
"\n";
1621 if ($member->last_subscription_date || $member->last_subscription_amount) {
1624 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"LastSubscriptionDate");
1625 print
'</td><td class="CTableRow2">'.dol_print_date($member->last_subscription_date,
'day');
1626 print
'</td></tr>'.
"\n";
1630 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"LastSubscriptionAmount");
1631 print
'</td><td class="CTableRow2">'.price($member->last_subscription_amount);
1632 print
'</td></tr>'.
"\n";
1634 if (empty($amount) && !
GETPOST(
'newamount',
'alpha')) {
1635 $_GET[
'newamount'] = $member->last_subscription_amount;
1636 $_GET[
'amount'] = $member->last_subscription_amount;
1638 if (!empty($member->last_subscription_amount) && !GETPOSTISSET(
'newamount') && is_numeric($amount)) {
1639 $amount = max($member->last_subscription_amount, $amount);
1643 $amountbytype = $adht->amountByType(1);
1645 $typeid = $adht->id;
1646 $caneditamount = $adht->caneditamount;
1648 if ($member->type) {
1649 $oldtypeid = $member->typeid;
1650 $newtypeid = (int) (GETPOSTISSET(
"typeid") ?
GETPOSTINT(
"typeid") : $member->typeid);
1652 $typeid = $newtypeid;
1653 $adht->fetch($typeid);
1656 $caneditamount = $adht->caneditamount;
1660 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"LastMemberType");
1661 print
'</td><td class="CTableRow2">'.dol_escape_htmltag($member->type);
1662 print
"</td></tr>\n";
1665 $member->typeid = $newtypeid;
1666 $member->type = (string)
dol_getIdFromCode($db, $newtypeid,
'adherent_type',
'rowid',
'libelle');
1672 $amount = (!empty($amountbytype[$member->typeid])) ? $amountbytype[$member->typeid] : $member->last_subscription_amount;
1674 print
'<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans(
"NewSubscription");
1675 print
'</td><td class="CTableRow2">';
1676 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);
1677 print "</td></tr>\n
";
1678 } elseif ($action == 'dopayment') {
1679 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("NewMemberType
");
1680 print '</td><td class="CTableRow2
">'.dol_escape_htmltag($member->type);
1681 print '<input type="hidden
" name="membertypeid
" value="'.$member->typeid.'">';
1682 print "</td></tr>\n
";
1685 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("MemberType
");
1686 print '</td><td class="CTableRow2
">'.dol_escape_htmltag($member->type);
1687 print "</td></tr>\n
";
1691 // Set amount for the subscription from the the type and options:
1692 // - First check the amount of the member type if not previous payment.
1693 $amount = ($member->last_subscription_amount ? $member->last_subscription_amount : (empty($amountbytype[$typeid]) ? 0 : $amountbytype[$typeid]));
1694 // - If not found, take the default amount
1695 if (empty($amount) && getDolGlobalString('MEMBER_NEWFORM_AMOUNT')) {
1696 $amount = getDolGlobalString('MEMBER_NEWFORM_AMOUNT');
1698 // - If not set, we accept to have amount defined as parameter (for backward compatibility).
1699 //if (empty($amount)) {
1700 // $amount = (GETPOST('amount') ? price2num(GETPOST('amount', 'alpha'), 'MT', 2) : '');
1702 // - If a min is set, we take it into account
1703 $amount = max(0, (float) $amount, (float) getDolGlobalInt("MEMBER_MIN_AMOUNT
"));
1706 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Amount
");
1707 // This place no longer allows amount edition
1708 if (getDolGlobalString('MEMBER_EXT_URL_SUBSCRIPTION_INFO')) {
1709 print ' - <a href="' . getDolGlobalString('MEMBER_EXT_URL_SUBSCRIPTION_INFO
').'" rel="external
" target="_blank
" rel="noopener noreferrer
">'.$langs->trans("SeeHere
").'</a>';
1711 print '</td><td class="CTableRow2
">';
1713 $caneditamount = $adht->caneditamount;
1714 $minimumamount = !getDolGlobalString('MEMBER_MIN_AMOUNT') ? $adht->amount : max(getDolGlobalString('MEMBER_MIN_AMOUNT'), $adht->amount, $amount);
1716 if ($caneditamount && $action != 'dopayment') {
1717 if (GETPOSTISSET('newamount')) {
1718 print '<input type="text
" class="width75
" name="newamount
" value="'.price(price2num(GETPOST('newamount
'), '', 2), 1, $langs, 1, -1, -1).'">';
1720 print '<input type="text
" class="width75
" name="newamount
" value="'.price($amount, 1, $langs, 1, -1, -1).'">';
1723 print '<b class="amount
">'.price($amount, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
1724 if ($minimumamount > $amount) {
1725 print ' <span class="opacitymedium small
">'. $langs->trans("AmountIsLowerToMinimumNotice
", price($minimumamount, 1, $langs, 1, -1, -1, $currency)).'</span>';
1727 print '<input type="hidden
" name="newamount
" value="'.$amount.'">';
1729 print '<input type="hidden
" name="amount
" value="'.$amount.'">';
1730 print '<input type="hidden
" name="currency
" value="'.$currency.'">';
1731 print '</td></tr>'."\n
";
1734 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("PaymentCode
");
1735 print '</td><td class="CTableRow2
"><b style="word-
break:
break-all;
">'.$fulltag.'</b>';
1736 print '<input type="hidden
" name="tag
" value="'.$tag.'">';
1737 print '<input type="hidden
" name="fulltag
" value="'.$fulltag.'">';
1738 print '</td></tr>'."\n
";
1741 $shipToName = $member->getFullName($langs);
1742 $shipToStreet = $member->address;
1743 $shipToCity = $member->town;
1744 $shipToState = $member->state_code;
1745 $shipToCountryCode = $member->country_code;
1746 $shipToZip = $member->zip;
1747 $shipToStreet2 = '';
1748 $phoneNum = $member->phone;
1749 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1750 print '<!-- Shipping address information -->';
1751 print '<input type="hidden
" name="shipToName
" value="'.$shipToName.'">'."\n
";
1752 print '<input type="hidden
" name="shipToStreet
" value="'.$shipToStreet.'">'."\n
";
1753 print '<input type="hidden
" name="shipToCity
" value="'.$shipToCity.'">'."\n
";
1754 print '<input type="hidden
" name="shipToState
" value="'.$shipToState.'">'."\n
";
1755 print '<input type="hidden
" name="shipToCountryCode
" value="'.$shipToCountryCode.'">'."\n
";
1756 print '<input type="hidden
" name="shipToZip
" value="'.$shipToZip.'">'."\n
";
1757 print '<input type="hidden
" name="shipToStreet2
" value="'.$shipToStreet2.'">'."\n
";
1758 print '<input type="hidden
" name="phoneNum
" value="'.$phoneNum.'">'."\n
";
1760 print '<!-- Shipping address not complete, so we don t use it -->'."\n
";
1762 if (is_object($member->thirdparty)) {
1763 print '<input type="hidden
" name="thirdparty_id
" value="'.$member->thirdparty->id.'">'."\n
";
1765 print '<input type="hidden
" name="email" value="'.$member->email.'">'."\n
";
1766 $labeldesc = $langs->trans("PaymentSubscription
");
1767 if (GETPOST('desc', 'alpha')) {
1768 $labeldesc = GETPOST('desc', 'alpha');
1770 print '<input type="hidden
" name="desc
" value="'.dol_escape_htmltag($labeldesc).'">'."\n
";
1773// Payment on donation
1774if ($source == 'donation') {
1776 $langs->load("don
");
1778 require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
1780 $don = new Don($db);
1781 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
1782 $result = $don->fetch($ref);
1784 $mesg = $don->error;
1787 $don->fetch_thirdparty();
1791 if ($action != 'dopayment') { // Do not change amount if we just click on first dopayment
1792 if (GETPOST("amount
", 'alpha')) {
1793 $amount = GETPOST("amount
", 'alpha');
1795 $amount = $don->getRemainToPay();
1797 $amount = price2num($amount);
1800 if (GETPOST('fulltag', 'alpha')) {
1801 $fulltag = GETPOST('fulltag', 'alpha');
1803 $fulltag = 'DON='.$don->ref.'.DAT='.dol_print_date(dol_now(), '%Y%m%d%H%M%S');
1806 $fulltag .= '.TAG='.$TAG;
1809 $fulltag = dol_string_unaccent($fulltag);
1812 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Creditor
");
1813 print '</td><td class="CTableRow2
"><b>'.$creditor.'</b>';
1814 print '<input type="hidden
" name="creditor
" value="'.$creditor.'">';
1815 print '</td></tr>'."\n
";
1818 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("ThirdParty
");
1819 print '</td><td class="CTableRow2
"><b>';
1820 if ($don->morphy == 'mor' && !empty($don->societe)) {
1821 print $don->societe;
1823 print $don->getFullName($langs);
1826 print '</td></tr>'."\n
";
1830 if (GETPOST('desc', 'alpha')) {
1831 $text = '<b>'.$langs->trans(GETPOST('desc', 'alpha')).'</b>';
1833 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Designation
");
1834 print '</td><td class="CTableRow2
">'.$text;
1835 print '<input type="hidden
" name="source
" value="'.dol_escape_htmltag($source).'">';
1836 print '<input type="hidden
" name="ref" value="'.dol_escape_htmltag($don->ref).'">';
1837 print '</td></tr>'."\n
";
1840 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Amount
");
1841 if (empty($amount)) {
1842 if (!getDolGlobalString('DONATION_NEWFORM_AMOUNT')) {
1843 print ' ('.$langs->trans("ToComplete
");
1845 if (getDolGlobalString('DONATION_EXT_URL_SUBSCRIPTION_INFO')) {
1846 print ' - <a href="' . getDolGlobalString('DONATION_EXT_URL_SUBSCRIPTION_INFO
').'" rel="external
" target="_blank
" rel="noopener noreferrer
">'.$langs->trans("SeeHere
").'</a>';
1848 if (!getDolGlobalString('DONATION_NEWFORM_AMOUNT')) {
1852 print '</td><td class="CTableRow2
">';
1854 if (empty($amount) || !is_numeric($amount)) {
1855 $valtoshow = price2num(GETPOST("newamount
", 'alpha'), 'MT');
1856 // force default subscription amount to value defined into constant...
1857 if (empty($valtoshow)) {
1858 if (getDolGlobalString('DONATION_NEWFORM_EDITAMOUNT')) {
1859 if (getDolGlobalString('DONATION_NEWFORM_AMOUNT')) {
1860 $valtoshow = getDolGlobalString('DONATION_NEWFORM_AMOUNT');
1863 if (getDolGlobalString('DONATION_NEWFORM_AMOUNT')) {
1864 $amount = getDolGlobalString('DONATION_NEWFORM_AMOUNT');
1869 if (empty($amount) || !is_numeric($amount)) {
1870 //$valtoshow=price2num(GETPOST("newamount
",'alpha'),'MT');
1871 if (getDolGlobalString('DONATION_MIN_AMOUNT') && $valtoshow) {
1872 $valtoshow = max(getDolGlobalString('DONATION_MIN_AMOUNT'), $valtoshow);
1874 print '<input type="hidden
" name="amount
" value="'.price2num(GETPOST("amount", 'alpha
'), 'MT
').'">';
1875 print '<input class="flat maxwidth75
" type="text
" name="newamount
" value="'.$valtoshow.'">';
1877 print ' <b>'.$langs->trans("Currency
".$currency).'</b>';
1879 $valtoshow = $amount;
1880 if (getDolGlobalString('DONATION_MIN_AMOUNT') && $valtoshow) {
1881 $valtoshow = max(getDolGlobalString('DONATION_MIN_AMOUNT'), $valtoshow);
1882 $amount = $valtoshow;
1884 print '<b class="amount
">'.price($valtoshow, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
1885 print '<input type="hidden
" name="amount
" value="'.$valtoshow.'">';
1886 print '<input type="hidden
" name="newamount
" value="'.$valtoshow.'">';
1888 print '<input type="hidden
" name="currency
" value="'.$currency.'">';
1889 print '</td></tr>'."\n
";
1892 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("PaymentCode
");
1893 print '</td><td class="CTableRow2
"><b style="word-
break:
break-all;
">'.$fulltag.'</b>';
1894 print '<input type="hidden
" name="tag
" value="'.$tag.'">';
1895 print '<input type="hidden
" name="fulltag
" value="'.$fulltag.'">';
1896 print '</td></tr>'."\n
";
1899 $shipToName = $don->getFullName($langs);
1900 $shipToStreet = $don->address;
1901 $shipToCity = $don->town;
1902 $shipToState = $don->state_code;
1903 $shipToCountryCode = $don->country_code;
1904 $shipToZip = $don->zip;
1905 $shipToStreet2 = '';
1906 $phoneNum = $don->phone;
1907 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
1908 print '<!-- Shipping address information -->';
1909 print '<input type="hidden
" name="shipToName
" value="'.$shipToName.'">'."\n
";
1910 print '<input type="hidden
" name="shipToStreet
" value="'.$shipToStreet.'">'."\n
";
1911 print '<input type="hidden
" name="shipToCity
" value="'.$shipToCity.'">'."\n
";
1912 print '<input type="hidden
" name="shipToState
" value="'.$shipToState.'">'."\n
";
1913 print '<input type="hidden
" name="shipToCountryCode
" value="'.$shipToCountryCode.'">'."\n
";
1914 print '<input type="hidden
" name="shipToZip
" value="'.$shipToZip.'">'."\n
";
1915 print '<input type="hidden
" name="shipToStreet2
" value="'.$shipToStreet2.'">'."\n
";
1916 print '<input type="hidden
" name="phoneNum
" value="'.$phoneNum.'">'."\n
";
1918 print '<!-- Shipping address not complete, so we don t use it -->'."\n
";
1920 if (is_object($don->thirdparty)) {
1921 print '<input type="hidden
" name="thirdparty_id
" value="'.$don->thirdparty->id.'">'."\n
";
1923 print '<input type="hidden
" name="email" value="'.$don->email.'">'."\n
";
1924 $labeldesc = $langs->trans("PaymentSubscription
");
1925 if (GETPOST('desc', 'alpha')) {
1926 $labeldesc = GETPOST('desc', 'alpha');
1928 print '<input type="hidden
" name="desc
" value="'.dol_escape_htmltag($labeldesc).'">'."\n
";
1931if ($source == 'organizedeventregistration' && is_object($thirdparty)) {
1933 $langs->loadLangs(array("members
", "eventorganization
"));
1935 if (GETPOST('fulltag', 'alpha')) {
1936 $fulltag = GETPOST('fulltag', 'alpha');
1938 $fulltag = 'ATT='.$attendee->id.'.DAT='.dol_print_date(dol_now(), '%Y%m%d%H%M%S');
1941 $fulltag .= '.TAG='.$TAG;
1944 $fulltag = dol_string_unaccent($fulltag);
1947 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Creditor
");
1948 print '</td><td class="CTableRow2
"><b>'.$creditor.'</b>';
1949 print '<input type="hidden
" name="creditor
" value="'.$creditor.'">';
1950 print '</td></tr>'."\n
";
1953 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Attendee
");
1954 print '</td><td class="CTableRow2
"><b>';
1955 print $attendee->email;
1956 print($thirdparty->name ? ' ('.$thirdparty->name.')' : '');
1958 print '</td></tr>'."\n
";
1960 if (! is_object($attendee->project)) {
1961 $text = 'ErrorProjectNotFound';
1963 $text = $langs->trans("PaymentEvent
").' - '.$attendee->project->title;
1967 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Designation
");
1968 print '</td><td class="CTableRow2
"><b>'.$text.'</b>';
1969 print '<input type="hidden
" name="source
" value="'.dol_escape_htmltag($source).'">';
1970 print '<input type="hidden
" name="ref" value="'.dol_escape_htmltag($invoice->id).'">';
1971 print '</td></tr>'."\n
";
1974 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Amount
");
1975 print '</td><td class="CTableRow2
">';
1976 $valtoshow = $amount;
1977 print '<b class="amount
">'.price($valtoshow, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
1978 print '<input type="hidden
" name="amount
" value="'.$valtoshow.'">';
1979 print '<input type="hidden
" name="newamount
" value="'.$valtoshow.'">';
1980 print '<input type="hidden
" name="currency
" value="'.$currency.'">';
1981 print '</td></tr>'."\n
";
1984 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("PaymentCode
");
1985 print '</td><td class="CTableRow2
"><b style="word-
break:
break-all;
">'.$fulltag.'</b>';
1986 print '<input type="hidden
" name="tag
" value="'.$tag.'">';
1987 print '<input type="hidden
" name="fulltag
" value="'.$fulltag.'">';
1988 print '</td></tr>'."\n
";
1991 $shipToName = $thirdparty->getFullName($langs);
1992 $shipToStreet = $thirdparty->address;
1993 $shipToCity = $thirdparty->town;
1994 $shipToState = $thirdparty->state_code;
1995 $shipToCountryCode = $thirdparty->country_code;
1996 $shipToZip = $thirdparty->zip;
1997 $shipToStreet2 = '';
1998 $phoneNum = $thirdparty->phone;
1999 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
2000 print '<!-- Shipping address information -->';
2001 print '<input type="hidden
" name="shipToName
" value="'.$shipToName.'">'."\n
";
2002 print '<input type="hidden
" name="shipToStreet
" value="'.$shipToStreet.'">'."\n
";
2003 print '<input type="hidden
" name="shipToCity
" value="'.$shipToCity.'">'."\n
";
2004 print '<input type="hidden
" name="shipToState
" value="'.$shipToState.'">'."\n
";
2005 print '<input type="hidden
" name="shipToCountryCode
" value="'.$shipToCountryCode.'">'."\n
";
2006 print '<input type="hidden
" name="shipToZip
" value="'.$shipToZip.'">'."\n
";
2007 print '<input type="hidden
" name="shipToStreet2
" value="'.$shipToStreet2.'">'."\n
";
2008 print '<input type="hidden
" name="phoneNum
" value="'.$phoneNum.'">'."\n
";
2010 print '<!-- Shipping address not complete, so we don t use it -->'."\n
";
2012 print '<input type="hidden
" name="thirdparty_id
" value="'.$thirdparty->id.'">'."\n
";
2013 print '<input type="hidden
" name="email" value="'.$thirdparty->email.'">'."\n
";
2014 $labeldesc = $langs->trans("PaymentSubscription
");
2015 if (GETPOST('desc', 'alpha')) {
2016 $labeldesc = GETPOST('desc', 'alpha');
2018 print '<input type="hidden
" name="desc
" value="'.dol_escape_htmltag($labeldesc).'">'."\n
";
2021if ($source == 'boothlocation') {
2023 $langs->load("members
");
2025 if (GETPOST('fulltag', 'alpha')) {
2026 $fulltag = GETPOST('fulltag', 'alpha');
2028 $fulltag = 'BOO='.GETPOST("booth
").'.DAT='.dol_print_date(dol_now(), '%Y%m%d%H%M%S');
2031 $fulltag .= '.TAG='.$TAG;
2034 $fulltag = dol_string_unaccent($fulltag);
2037 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Creditor
");
2038 print '</td><td class="CTableRow2
"><b>'.$creditor.'</b>';
2039 print '<input type="hidden
" name="creditor
" value="'.$creditor.'">';
2040 print '</td></tr>'."\n
";
2043 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Attendee
");
2044 print '</td><td class="CTableRow2
"><b>';
2045 print $thirdparty->name;
2047 print '</td></tr>'."\n
";
2050 $text = '<b>'.$langs->trans("PaymentBoothLocation
").'</b>';
2051 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Designation
");
2052 print '</td><td class="CTableRow2
">'.$text;
2053 print '<input type="hidden
" name="source
" value="'.dol_escape_htmltag($source).'">';
2054 print '<input type="hidden
" name="ref" value="'.dol_escape_htmltag($invoice->id).'">';
2055 print '</td></tr>'."\n
";
2058 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("Amount
");
2059 print '</td><td class="CTableRow2
">';
2060 $valtoshow = $amount;
2061 print '<b class="amount
">'.price($valtoshow, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
2062 print '<input type="hidden
" name="amount
" value="'.$valtoshow.'">';
2063 print '<input type="hidden
" name="newamount
" value="'.$valtoshow.'">';
2064 print '<input type="hidden
" name="currency
" value="'.$currency.'">';
2065 print '</td></tr>'."\n
";
2068 print '<tr class="CTableRow2
"><td class="CTableRow2
">'.$langs->trans("PaymentCode
");
2069 print '</td><td class="CTableRow2
"><b style="word-
break:
break-all;
">'.$fulltag.'</b>';
2070 print '<input type="hidden
" name="tag
" value="'.$tag.'">';
2071 print '<input type="hidden
" name="fulltag
" value="'.$fulltag.'">';
2072 print '</td></tr>'."\n
";
2075 $shipToName = $thirdparty->getFullName($langs);
2076 $shipToStreet = $thirdparty->address;
2077 $shipToCity = $thirdparty->town;
2078 $shipToState = $thirdparty->state_code;
2079 $shipToCountryCode = $thirdparty->country_code;
2080 $shipToZip = $thirdparty->zip;
2081 $shipToStreet2 = '';
2082 $phoneNum = $thirdparty->phone;
2083 if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
2084 print '<!-- Shipping address information -->';
2085 print '<input type="hidden
" name="shipToName
" value="'.$shipToName.'">'."\n
";
2086 print '<input type="hidden
" name="shipToStreet
" value="'.$shipToStreet.'">'."\n
";
2087 print '<input type="hidden
" name="shipToCity
" value="'.$shipToCity.'">'."\n
";
2088 print '<input type="hidden
" name="shipToState
" value="'.$shipToState.'">'."\n
";
2089 print '<input type="hidden
" name="shipToCountryCode
" value="'.$shipToCountryCode.'">'."\n
";
2090 print '<input type="hidden
" name="shipToZip
" value="'.$shipToZip.'">'."\n
";
2091 print '<input type="hidden
" name="shipToStreet2
" value="'.$shipToStreet2.'">'."\n
";
2092 print '<input type="hidden
" name="phoneNum
" value="'.$phoneNum.'">'."\n
";
2094 print '<!-- Shipping address not complete, so we don t use it -->'."\n
";
2096 print '<input type="hidden
" name="thirdparty_id
" value="'.$thirdparty->id.'">'."\n
";
2097 print '<input type="hidden
" name="email" value="'.$thirdparty->email.'">'."\n
";
2098 $labeldesc = $langs->trans("PaymentSubscription
");
2099 if (GETPOST('desc', 'alpha')) {
2100 $labeldesc = GETPOST('desc', 'alpha');
2102 print '<input type="hidden
" name="desc
" value="'.dol_escape_htmltag($labeldesc).'">'."\n
";
2105if (!$found && !$mesg) {
2106 $mesg = $langs->trans("ErrorBadParameters
");
2110 print '<tr><td align="center
" colspan="2
"><br><div class="warning
">'.dol_escape_htmltag($mesg, 1, 1, 'br').'</div></td></tr>'."\n
";
2113print '</table>'."\n
";
2117// Show all payment mode buttons (Stripe, Paypal, ...)
2118if ($action != 'dopayment') {
2119 if ($found && !$error) { // We are in a management option and no error
2120 // Check status of the object (Invoice) to verify if it is paid by external payment modules (ie Payzen, ...)
2122 'source' => $source,
2125 $reshook = $hookmanager->executeHooks('doCheckStatus', $parameters, $object, $action);
2127 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2128 } elseif ($reshook > 0) {
2129 print $hookmanager->resPrint;
2132 if ($source == 'order' && $object->billed) {
2133 print '<br><br><span class="amountpaymentcomplete size12x
">'.$langs->trans("OrderBilled
").'</span>';
2134 } elseif ($source == 'invoice' && $object->paye) {
2135 print '<br><br><span class="amountpaymentcomplete size12x
">'.$langs->trans("InvoicePaid
").'</span>';
2136 } elseif ($source == 'donation' && $object->paid) {
2137 print '<br><br><span class="amountpaymentcomplete size12x
">'.$langs->trans("DonationPaid
").'</span>';
2139 // Membership can be paid and we still allow to make renewal
2140 if (($source == 'member' || $source == 'membersubscription') && $object->datefin > dol_now()) {
2141 $langs->load("members
");
2142 print '<br><span class="amountpaymentcomplete size12x
">';
2143 $s = $langs->trans("MembershipPaid
", '{s1}');
2144 print str_replace('{s1}', '<span class="nobold
">'.dol_print_date($object->datefin, 'day').'</span>', $s);
2145 print '</span><br>';
2146 print '<div class="opacitymedium margintoponly
">'.$langs->trans("PaymentWillBeRecordedForNextPeriod
").'</div>';
2150 // Buttons for all payments registration methods
2152 // This hook is used to add Button to newpayment.php for external payment modules (ie Payzen, ...)
2154 'paymentmethod' => $paymentmethod
2156 $reshook = $hookmanager->executeHooks('doAddButton', $parameters, $object, $action);
2158 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2159 } elseif ($reshook > 0) {
2160 print $hookmanager->resPrint;
2163 if ((empty($paymentmethod) || $paymentmethod == 'paybox') && isModEnabled('paybox')) {
2164 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").'">';
2166 print '<span class="buttonpaymentsmall
">'.$langs->trans("CreditOrDebitCard
").'</span>';
2169 $( document ).ready(function() {
2170 $("#div_dopayment_paybox
").click(function(){
2171 $("#dopayment_paybox
").click();
2173 $("#dopayment_paybox
").click(function(e){
2174 $("#div_dopayment_paybox
").css( \'cursor\', \'wait\' );
2175 e.stopPropagation();
2182 if ((empty($paymentmethod) || $paymentmethod == 'stripe') && isModEnabled('stripe')) {
2184 if (getDolGlobalString(strtoupper($source).'_FORCE_DISABLE_STRIPE')) { // Example: MEMBER_FORCE_DISABLE_STRIPE
2189 // 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.
2190 // 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).
2191 $noidempotency_key = (GETPOSTISSET('noidempotency') ? GETPOSTINT('noidempotency') : (getDolGlobalInt('STRIPE_USE_IDEMPOTENCY_BY_DEFAULT') ? 0 : 1));
2193 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").'">';
2194 print '<input type="hidden
" name="noidempotency
" value="'.$noidempotency_key.'">';
2196 print '<span class="buttonpaymentsmall
">'.$langs->trans("CreditOrDebitCard
").'</span>';
2199 $( document ).ready(function() {
2200 $("#div_dopayment_stripe
").click(function(){
2201 $("#dopayment_stripe
").click();
2203 $("#dopayment_stripe
").click(function(e){
2204 $("#div_dopayment_stripe
").css( \'cursor\', \'wait\' );
2205 e.stopPropagation();
2214 if ((empty($paymentmethod) || $paymentmethod == 'paypal') && isModEnabled('paypal')) {
2215 if (!getDolGlobalString('PAYPAL_API_INTEGRAL_OR_PAYPALONLY')) {
2216 $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY = 'integral';
2220 if (getDolGlobalString(strtoupper($source).'_FORCE_DISABLE_PAYPAL')) { // Example: MEMBER_FORCE_DISABLE_PAYPAL
2225 print '<div class="button buttonpayment
" id="div_dopayment_paypal
">';
2226 if (getDolGlobalString('PAYPAL_API_INTEGRAL_OR_PAYPALONLY') != 'integral') {
2227 print '<div style="line-height: 1em
"> </div>';
2229 print '<span class="fab fa-paypal
"></span> <input class="" type="submit
" id="dopayment_paypal
" name="dopayment_paypal
" value="'.$langs->trans("PaypalDoPayment").'">';
2230 if (getDolGlobalString('PAYPAL_API_INTEGRAL_OR_PAYPALONLY') == 'integral') {
2232 print '<span class="buttonpaymentsmall
">'.$langs->trans("CreditOrDebitCard
").'</span><span class="buttonpaymentsmall
"> - </span>';
2233 print '<span class="buttonpaymentsmall
">'.$langs->trans("PayPalBalance
").'</span>';
2235 //if (getDolGlobalString('PAYPAL_API_INTEGRAL_OR_PAYPALONLY') == 'paypalonly') {
2237 //print '<span class="buttonpaymentsmall
">'.$langs->trans("PayPalBalance
").'"></span>
';
2241 $( document ).ready(
function() {
2242 $(
"#div_dopayment_paypal").click(
function(){
2243 $(
"#dopayment_paypal").click();
2245 $(
"#dopayment_paypal").click(
function(e){
2246 $(
"#div_dopayment_paypal").css( \
'cursor\', \'wait\' );
2247 e.stopPropagation();
2263print
'</td></tr>'.
"\n";
2265print
'</table>'.
"\n";
2267print
'</form>'.
"\n";
2275if (preg_match(
'/^dopayment/', $action)) {
2278 $_SESSION[
"currencyCodeType"] = $currency;
2279 $_SESSION[
"FinalPaymentAmt"] = $amount;
2280 $_SESSION[
'ipaddress'] = ($remoteip ? $remoteip :
'unknown');
2281 $_SESSION[
"paymentType"] =
'';
2286 if (
GETPOST(
'dopayment_stripe',
'alpha')) {
2294 background-color: white;
2297 border: 1px solid transparent;
2298 box-shadow: 0 1px 3px 0 #e6ebf1;
2299 -webkit-transition: box-shadow 150ms ease;
2300 transition: box-shadow 150ms ease;
2303 .StripeElement--focus {
2304 box-shadow: 0 1px 3px 0 #cfd7df;
2307 .StripeElement--invalid {
2308 border-color: #fa755a;
2311 .StripeElement--webkit-autofill {
2312 background-color: #fefde5 !important;
2318 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";
2319 print
'<form action="'.$_SERVER[
'REQUEST_URI'].
'" method="POST" id="payment-form">'.
"\n";
2321 print
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
2322 print
'<input type="hidden" name="dopayment_stripe" value="1">'.
"\n";
2323 print
'<input type="hidden" name="action" value="charge">'.
"\n";
2324 print
'<input type="hidden" name="tag" value="'.$TAG.
'">'.
"\n";
2325 print
'<input type="hidden" name="s" value="'.$source.
'">'.
"\n";
2326 print
'<input type="hidden" name="ref" value="'.$REF.
'">'.
"\n";
2327 print
'<input type="hidden" name="fulltag" value="'.$FULLTAG.
'">'.
"\n";
2328 print
'<input type="hidden" name="suffix" value="'.$suffix.
'">'.
"\n";
2329 print
'<input type="hidden" name="securekey" value="'.$SECUREKEY.
'">'.
"\n";
2330 print
'<input type="hidden" name="e" value="'.$entity.
'" />';
2331 print
'<input type="hidden" name="amount" value="'.$amount.
'">'.
"\n";
2332 print
'<input type="hidden" name="currency" value="'.$currency.
'">'.
"\n";
2333 print
'<input type="hidden" name="forcesandbox" value="'.GETPOSTINT(
'forcesandbox').
'" />';
2334 print
'<input type="hidden" name="email" value="'.GETPOST(
'email',
'alpha').
'" />';
2335 print
'<input type="hidden" name="thirdparty_id" value="'.GETPOSTINT(
'thirdparty_id').
'" />';
2336 print
'<input type="hidden" name="lang" value="'.$getpostlang.
'">';
2339 require_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
2341 $service =
'StripeLive';
2344 $service =
'StripeTest';
2348 $stripe =
new Stripe($db);
2349 $stripeacc = $stripe->getStripeAccount($service);
2351 $stripecu = $stripe->customerStripe(
$object->thirdparty, $stripeacc, $servicestatus, 1);
2357 $noidempotency_key = (GETPOSTISSET(
'noidempotency') ?
GETPOSTINT(
'noidempotency') : (
getDolGlobalInt(
'STRIPE_USE_IDEMPOTENCY_BY_DEFAULT') ? 0 : 1));
2359 $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);
2362 if ($stripe->error) {
2373 <table id="dolpaymenttable" summary="Payment form" class="center centpercent">
2374 <tbody><tr><td class="textpublicpayment">';
2377 print
'<div id="payment-request-button"><!-- A Stripe Element will be inserted here. --></div>';
2380 print
'<div class="form-row '.(getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 2 ?
'center' :
'left').
'">';
2381 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 1) {
2382 print
'<label for="card-element">'.$langs->trans(
"CreditOrDebitCard").
'</label>';
2383 print
'<br><input id="cardholder-name" class="marginbottomonly" name="cardholder-name" value="" type="text" placeholder="'.$langs->trans(
"CardOwner").
'" autocomplete="off" autofocus required>';
2386 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 1) {
2387 print
'<div id="card-element">
2388 <!-- a Stripe Element will be inserted here. -->
2391 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 2) {
2392 print
'<div id="payment-element">
2393 <!-- a Stripe Element will be inserted here. -->
2397 print
'<!-- Used to display form errors -->
2398 <div id="card-errors" role="alert"></div>
2402 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>';
2403 print
'<img id="hourglasstopay" class="hidden" src="'.DOL_URL_ROOT.
'/theme/'.$conf->theme.
'/img/working.gif">';
2405 print
'</td></tr></tbody>';
2410 if (empty($paymentintent)) {
2411 print
'<center>'.$langs->trans(
"Error").
'</center>';
2413 print
'<input type="hidden" name="paymentintent_id" value="'.$paymentintent->id.
'">';
2418 print
'</form>'.
"\n";
2422 if (empty($stripearrayofkeys[
'publishable_key'])) {
2423 $langs->load(
"errors");
2424 print
info_admin($langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv(
"Stripe")), 0, 0,
'error');
2426 print
'<!-- JS Code for Stripe components -->';
2427 print
'<script src="https://js.stripe.com/v3/"></script>'.
"\n";
2428 print
'<!-- urllogofull = '.$urllogofull.
' -->'.
"\n";
2431 print
'<script type="text/javascript">'.
"\n";
2434 $amountstripe = $amount;
2438 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
2439 if (!in_array($currency, $arrayzerounitcurrency)) {
2440 $amountstripe *= 100;
2444 $metadata = array(
'dol_version' => DOL_VERSION,
'dol_entity' => $conf->entity,
'ipaddress' => $ipaddress);
2446 $metadata[
'dol_type'] =
$object->element;
2447 $metadata[
'dol_id'] =
$object->id;
2453 $arrayforpaymentintent = array(
2454 'description' =>
'Stripe payment: '.$FULLTAG.($ref ?
' ref='.$ref :
''),
2455 "metadata" => $metadata
2458 $arrayforpaymentintent[
"statement_descriptor"] =
dol_trunc($TAG, 10,
'right',
'UTF-8', 1);
2461 $arrayforcheckout = array(
2462 'payment_method_types' => array(
'card'),
2463 'line_items' => array(array(
2464 'price_data' => array(
2465 'currency' => $currency,
2466 'unit_amount' => $amountstripe,
2467 'product_data' => array(
2468 'name' => $langs->transnoentitiesnoconv(
"Payment").
' '.$TAG,
2469 'description' =>
'Stripe payment: '.$FULLTAG.($ref ?
' ref='.$ref :
''),
2475 'mode' =>
'payment',
2476 'client_reference_id' => $FULLTAG,
2477 'success_url' => $urlok,
2478 'cancel_url' => $urlko,
2479 'payment_intent_data' => $arrayforpaymentintent
2482 $arrayforcheckout[
'customer'] = $stripecu;
2484 $arrayforcheckout[
'customer_email'] =
GETPOST(
'email',
'alpha');
2486 $sessionstripe = \Stripe\Checkout\Session::create($arrayforcheckout);
2491 $_SESSION[
"currencyCodeType"] = $currency;
2492 $_SESSION[
"paymentType"] =
'';
2493 $_SESSION[
"FinalPaymentAmt"] = $amount;
2494 $_SESSION[
'ipaddress'] = ($remoteip ? $remoteip :
'unknown');
2495 $_SESSION[
'payerID'] = is_object($stripecu) ? $stripecu->id :
'';
2496 $_SESSION[
'TRANSACTIONID'] = $sessionstripe->id;
2498 print $e->getMessage();
2504 if (empty($stripeacc)) {
2506 var stripe =
Stripe(
'<?php echo $stripearrayofkeys['publishable_key
']; // Defined into config.php?>');
2510 var stripe =
Stripe(
'<?php echo $stripearrayofkeys['publishable_key
']; // Defined into config.php?>', { stripeAccount:
'<?php echo $stripeacc; ?>' });
2515 var elements = stripe.elements();
2523 fontFamily:
'"Helvetica Neue", Helvetica, sans-serif',
2524 fontSmoothing:
'antialiased',
2532 iconColor:
'#fa755a'
2536 var cardElement = elements.create(
'card', {style: style});
2539 stripe.redirectToCheckout({
2543 sessionId:
'<?php print $sessionstripe->id; ?>'
2544 }).then(
function (result) {
2558 if (empty($stripeacc)) {
2560 var stripe =
Stripe(
'<?php echo $stripearrayofkeys['publishable_key
']; // Defined into config.php?>');
2564 var stripe =
Stripe(
'<?php echo $stripearrayofkeys['publishable_key
']; // Defined into config.php?>', { stripeAccount:
'<?php echo $stripeacc; ?>' });
2569 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 2) {
2571 var cardButton = document.getElementById(
'buttontopay');
2572 var clientSecret = cardButton.dataset.secret;
2573 var options = { clientSecret: clientSecret };
2576 var elements = stripe.elements(options);
2581 var elements = stripe.elements();
2591 fontFamily:
'"Helvetica Neue", Helvetica, sans-serif',
2592 fontSmoothing:
'antialiased',
2600 iconColor:
'#fa755a'
2605 if (
getDolGlobalInt(
'STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') == 2) {
2607 var paymentElement = elements.create(
"payment");
2610 paymentElement.mount(
"#payment-element");
2613 var cardButton = document.getElementById(
'buttontopay');
2615 cardButton.addEventListener(
'click',
function(event) {
2616 console.log(
"We click on buttontopay");
2617 event.preventDefault();
2620 jQuery(
'#hourglasstopay').show();
2621 jQuery(
'#buttontopay').hide();
2623 stripe.confirmPayment({
2624 elements,confirmParams: {
2625 return_url:
'<?php echo $urlok; ?>',
2626 payment_method_data: {
2630 ?>, email:
'<?php echo dol_escape_js(GETPOST('email
', 'alpha
') ? GETPOST('email
', 'alpha
') : $object->thirdparty->email); ?>'<?php
2633 ?>, phone:
'<?php echo dol_escape_js($object->thirdparty->phone); ?>'<?php
2637 city:
'<?php echo dol_escape_js($object->thirdparty->town); ?>',
2638 <?php if ($object->thirdparty->country_code) {
2639 ?>country:
'<?php echo dol_escape_js($object->thirdparty->country_code); ?>',<?php
2641 line1:
'<?php echo dol_escape_js(preg_replace('/\s\s+/
', ' ', $object->thirdparty->address)); ?>',
2642 postal_code:
'<?php echo dol_escape_js($object->thirdparty->zip); ?>'
2648 save_payment_method:<?php
if ($stripecu) {
2655 ).then(
function(result) {
2656 console.log(result);
2658 console.log(
"Error on result of handleCardPayment");
2659 jQuery(
'#buttontopay').show();
2660 jQuery(
'#hourglasstopay').hide();
2662 var errorElement = document.getElementById(
'card-errors');
2663 console.log(result);
2664 errorElement.textContent = result.error.message;
2667 console.log(
"No error on result of handleCardPayment, so we submit the form");
2669 jQuery(
'#buttontopay').hide();
2670 jQuery(
'#hourglasstopay').show();
2672 jQuery(
'#payment-form').submit();
2680 var cardElement = elements.create(
'card', {style: style});
2683 cardElement.mount(
'#card-element');
2686 cardElement.addEventListener(
'change',
function(event) {
2687 var displayError = document.getElementById(
'card-errors');
2689 console.log(
"Show event error (like 'Incorrect card number', ...)");
2690 displayError.textContent =
event.error.message;
2692 console.log(
"Reset error message");
2693 displayError.textContent =
'';
2698 var cardholderName = document.getElementById(
'cardholder-name');
2699 var cardButton = document.getElementById(
'buttontopay');
2700 var clientSecret = cardButton.dataset.secret;
2702 cardButton.addEventListener(
'click',
function(event) {
2703 console.log(
"We click on buttontopay");
2704 event.preventDefault();
2706 if (cardholderName.value ==
'')
2708 console.log(
"Field Card holder is empty");
2709 var displayError = document.getElementById(
'card-errors');
2710 displayError.textContent =
'<?php print dol_escape_js($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardOwner"))); ?>';
2715 jQuery(
'#hourglasstopay').show();
2716 jQuery(
'#buttontopay').hide();
2718 stripe.handleCardPayment(
2719 clientSecret, cardElement, {
2720 payment_method_data: {
2722 name: cardholderName.value
2724 ?>, email:
'<?php echo dol_escape_js(GETPOST('email
', 'alpha
') ? GETPOST('email
', 'alpha
') : $object->thirdparty->email); ?>'<?php
2727 ?>, phone:
'<?php echo dol_escape_js($object->thirdparty->phone); ?>'<?php
2731 city:
'<?php echo dol_escape_js($object->thirdparty->town); ?>',
2732 <?php if ($object->thirdparty->country_code) {
2733 ?>country:
'<?php echo dol_escape_js($object->thirdparty->country_code); ?>',<?php
2735 line1:
'<?php echo dol_escape_js(preg_replace('/\s\s+/
', ' ', $object->thirdparty->address)); ?>',
2736 postal_code:
'<?php echo dol_escape_js($object->thirdparty->zip); ?>'
2742 save_payment_method:<?php
if ($stripecu) {
2748 ).then(
function(result) {
2749 console.log(result);
2751 console.log(
"Error on result of handleCardPayment");
2752 jQuery(
'#buttontopay').show();
2753 jQuery(
'#hourglasstopay').hide();
2755 var errorElement = document.getElementById(
'card-errors');
2756 errorElement.textContent = result.error.message;
2759 console.log(
"No error on result of handleCardPayment, so we submit the form");
2761 jQuery(
'#buttontopay').hide();
2762 jQuery(
'#hourglasstopay').show();
2764 jQuery(
'#payment-form').submit();
2782 'paymentmethod' => $paymentmethod,
2783 'amount' => $amount,
2784 'currency' => $currency,
2785 'tag' =>
GETPOST(
"tag",
'alpha'),
2786 'dopayment' =>
GETPOST(
'dopayment',
'alpha')
2788 $reshook = $hookmanager->executeHooks(
'doPayment', $parameters,
$object, $action);
2791 } elseif ($reshook > 0) {
2792 print $hookmanager->resPrint;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage members of a foundation.
Class to manage members type.
Class to manage customers orders.
Class for ConferenceOrBoothAttendee.
Class to manage lines of contracts.
Class to manage invoices.
Class to manage payments of donations.
Class to manage products or services.
Class to manage third parties objects (customers, suppliers, prospects...)
Stripe class @TODO No reason to extends CommonObject.
Class to manage subscriptions of foundation members.
htmlPrintOnlineFooter($fromcompany, $langs, $addformmessage=0, $suffix='', $object=null)
Show footer of company in HTML pages.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as p label as s rowid as s nom as s email
Sender: Who sends the email ("Sender" has sent emails on behalf of "From").
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_now($mode='auto')
Return date for now.
img_mime($file, $titlealt='', $morecss='')
Show MIME img of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_string_unaccent($str)
Clean a string from all accent characters to be used as ref, login or by dol_sanitizeFileName.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error_email($prefixcode, $errormessage='', $errormessages=array(), $morecss='error', $email='')
Show a public email and error code to contact if technical error.
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formatted messages to output (Used to show messages on html output).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
getUserRemoteIP()
Return the IP of remote user.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
ui state ui widget content ui state ui widget header ui state a ui button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
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,...