From 942b58efaf3d0091b33d1a12d7e1d7b9880e6deb Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 22 Feb 2017 06:33:52 +0100 Subject: [PATCH] New : Integration of Stripe --- .tx/config | 6 + build/rpm/dolibarr_fedora.spec | 1 + build/rpm/dolibarr_generic.spec | 1 + build/rpm/dolibarr_mandriva.spec | 1 + build/rpm/dolibarr_opensuse.spec | 1 + htdocs/adherents/admin/public.php | 5 +- htdocs/adherents/subscription.php | 7 + htdocs/compta/facture.php | 6 + htdocs/core/modules/modStripe.class.php | 103 ++ ...face_20_modStripe_StripeWorkflow.class.php | 113 ++ .../interface_90_all_Demo.class.php-NORUN | 1 + htdocs/langs/en_US/stripe.lang | 40 + htdocs/public/demo/index.php | 2 +- htdocs/public/members/new.php | 16 +- htdocs/public/paybox/paymentko.php | 1 + htdocs/public/paybox/paymentok.php | 1 + htdocs/public/paypal/newpayment.php | 1 + htdocs/public/paypal/paymentko.php | 1 + htdocs/public/paypal/paymentok.php | 1 + htdocs/public/stripe/index.php | 28 + htdocs/public/stripe/newpayment.php | 977 ++++++++++++++++++ htdocs/public/stripe/paymentko.php | 115 +++ htdocs/public/stripe/paymentok.php | 172 +++ htdocs/stripe/admin/index.html | 0 htdocs/stripe/admin/stripe.php | 225 ++++ htdocs/stripe/img/index.html | 0 htdocs/stripe/img/object_stripe.png | Bin 0 -> 819 bytes htdocs/stripe/index.html | 0 htdocs/stripe/lib/index.html | 0 htdocs/stripe/lib/stripe.lib.php | 445 ++++++++ htdocs/theme/eldy/style.css.php | 2 +- htdocs/theme/md/style.css.php | 2 +- 32 files changed, 2267 insertions(+), 7 deletions(-) create mode 100644 htdocs/core/modules/modStripe.class.php create mode 100644 htdocs/core/triggers/interface_20_modStripe_StripeWorkflow.class.php create mode 100644 htdocs/langs/en_US/stripe.lang create mode 100644 htdocs/public/stripe/index.php create mode 100644 htdocs/public/stripe/newpayment.php create mode 100644 htdocs/public/stripe/paymentko.php create mode 100644 htdocs/public/stripe/paymentok.php create mode 100644 htdocs/stripe/admin/index.html create mode 100644 htdocs/stripe/admin/stripe.php create mode 100644 htdocs/stripe/img/index.html create mode 100644 htdocs/stripe/img/object_stripe.png create mode 100644 htdocs/stripe/index.html create mode 100644 htdocs/stripe/lib/index.html create mode 100644 htdocs/stripe/lib/stripe.lib.php diff --git a/.tx/config b/.tx/config index 010227f6e61..ae2741c9852 100644 --- a/.tx/config +++ b/.tx/config @@ -326,6 +326,12 @@ source_file = htdocs/langs/en_US/stocks.lang source_lang = en_US type = MOZILLAPROPERTIES +[dolibarr.stripe] +file_filter = htdocs/langs//stripe.lang +source_file = htdocs/langs/en_US/stripe.lang +source_lang = en_US +type = MOZILLAPROPERTIES + [dolibarr.suppliers] file_filter = htdocs/langs//suppliers.lang source_file = htdocs/langs/en_US/suppliers.lang diff --git a/build/rpm/dolibarr_fedora.spec b/build/rpm/dolibarr_fedora.spec index e65e6bc3b7d..c0119e54e9e 100755 --- a/build/rpm/dolibarr_fedora.spec +++ b/build/rpm/dolibarr_fedora.spec @@ -202,6 +202,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/public %_datadir/dolibarr/htdocs/resource %_datadir/dolibarr/htdocs/societe +%_datadir/dolibarr/htdocs/stripe %_datadir/dolibarr/htdocs/supplier_proposal %_datadir/dolibarr/htdocs/support %_datadir/dolibarr/htdocs/theme diff --git a/build/rpm/dolibarr_generic.spec b/build/rpm/dolibarr_generic.spec index 655ef87f925..54ff3b6cac8 100755 --- a/build/rpm/dolibarr_generic.spec +++ b/build/rpm/dolibarr_generic.spec @@ -282,6 +282,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/public %_datadir/dolibarr/htdocs/resource %_datadir/dolibarr/htdocs/societe +%_datadir/dolibarr/htdocs/stripe %_datadir/dolibarr/htdocs/supplier_proposal %_datadir/dolibarr/htdocs/support %_datadir/dolibarr/htdocs/theme diff --git a/build/rpm/dolibarr_mandriva.spec b/build/rpm/dolibarr_mandriva.spec index 55fb7183734..7237de58a70 100755 --- a/build/rpm/dolibarr_mandriva.spec +++ b/build/rpm/dolibarr_mandriva.spec @@ -199,6 +199,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/public %_datadir/dolibarr/htdocs/resource %_datadir/dolibarr/htdocs/societe +%_datadir/dolibarr/htdocs/stripe %_datadir/dolibarr/htdocs/supplier_proposal %_datadir/dolibarr/htdocs/support %_datadir/dolibarr/htdocs/theme diff --git a/build/rpm/dolibarr_opensuse.spec b/build/rpm/dolibarr_opensuse.spec index f7e29927ebb..9e12a96e054 100755 --- a/build/rpm/dolibarr_opensuse.spec +++ b/build/rpm/dolibarr_opensuse.spec @@ -210,6 +210,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/public %_datadir/dolibarr/htdocs/resource %_datadir/dolibarr/htdocs/societe +%_datadir/dolibarr/htdocs/stripe %_datadir/dolibarr/htdocs/supplier_proposal %_datadir/dolibarr/htdocs/support %_datadir/dolibarr/htdocs/theme diff --git a/htdocs/adherents/admin/public.php b/htdocs/adherents/admin/public.php index a23c1f40def..488b1bc542b 100644 --- a/htdocs/adherents/admin/public.php +++ b/htdocs/adherents/admin/public.php @@ -179,7 +179,7 @@ print ''; print $form->selectyesno("MEMBER_NEWFORM_EDITAMOUNT",(! empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)?$conf->global->MEMBER_NEWFORM_EDITAMOUNT:0),1); print "\n"; -if (! empty($conf->paybox->enabled) || ! empty($conf->paypal->enabled)) +if (! empty($conf->paybox->enabled) || ! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled)) { // Jump to an online payment page $var=! $var; @@ -189,11 +189,12 @@ if (! empty($conf->paybox->enabled) || ! empty($conf->paypal->enabled)) $listofval=array(); if (! empty($conf->paybox->enabled)) $listofval['paybox']='Paybox'; if (! empty($conf->paypal->enabled)) $listofval['paypal']='PayPal'; + if (! empty($conf->stripe->enabled)) $listofval['stripe']='Stripe'; print $form->selectarray("MEMBER_NEWFORM_PAYONLINE",$listofval,(! empty($conf->global->MEMBER_NEWFORM_PAYONLINE)?$conf->global->MEMBER_NEWFORM_PAYONLINE:''),1); print "\n"; } -if (! empty($conf->paybox->enabled) || ! empty($conf->paypal->enabled)) +if (! empty($conf->paybox->enabled) || ! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled)) { // Jump to an online payment page $var=! $var; diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 0c9c8467f1f..ba33c1c73b6 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -871,6 +871,13 @@ if ($rowid > 0) print showPaypalPaymentUrl('membersubscription',$object->ref); } + // Link for stripe payment + if (! empty($conf->stripe->enabled)) + { + include_once DOL_DOCUMENT_ROOT.'/stripe/lib/stripe.lib.php'; + print showStripePaymentUrl('membersubscription',$object->ref); + } + } /* diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 29cbe624fca..34ce3226c7e 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -4207,6 +4207,12 @@ else if ($id > 0 || ! empty($ref)) print showPaypalPaymentUrl('invoice', $object->ref); } + // Link for stripe payment + if (! empty($conf->stripe->enabled) && $object->statut != 0) { + include_once DOL_DOCUMENT_ROOT . '/stripe/lib/stripe.lib.php'; + print showStripePaymentUrl('invoice', $object->ref); + } + print '
'; // List of actions on element diff --git a/htdocs/core/modules/modStripe.class.php b/htdocs/core/modules/modStripe.class.php new file mode 100644 index 00000000000..11dd6ee68e4 --- /dev/null +++ b/htdocs/core/modules/modStripe.class.php @@ -0,0 +1,103 @@ + + * Copyright (C) 2004-2009 Laurent Destailleur + * Copyright (C) 2016 Alexandre Spangaro + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \defgroup stripe Module stripe + * \brief Add integration with Stripe online payment system. + * \file htdocs/core/modules/modStripe.class.php + * \ingroup stripe + * \brief Description and activation file for module Stripe + */ +include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; + + +/** + * Description and activation class for module Paybox + */ +class modStripe extends DolibarrModules +{ + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + $this->db = $db; + + // Id for module (must be unique). + // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). + $this->numero = 50300; + // Key text used to identify module (for permissions, menus, etc...) + $this->rights_class = 'stripe'; + + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' + // It is used to group modules in module setup page + $this->family = "other"; + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i','',get_class($this)); + // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) + $this->description = "Module to offer an online payment page by credit card with Stripe"; + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'dolibarr'; + // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Where to store the module in setup page (0=common,1=interface,2=other) + $this->special = 1; + // Name of image file used for this module. + // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' + // If file is in module/img directory, use this->picto=DOL_URL_ROOT.'/module/img/file.png' + $this->picto='stripe@stripe'; + + // Data directories to create when module is enabled. + $this->dirs = array('/stripe/temp'); + + // Config pages. Put here list of php page names stored in admmin directory used to setup module. + $this->config_page_url = array("stripe.php@stripe"); + + // Dependencies + $this->depends = array(); // List of modules id that must be enabled if this module is enabled + $this->requiredby = array(); // List of modules id to disable if this one is disabled + $this->phpmin = array(4,1); // Minimum version of PHP required by module + $this->need_dolibarr_version = array(2,6); // Minimum version of Dolibarr required by module + $this->langfiles = array("stripe"); + + // Constants + $this->const = array(); // List of particular constants to add when module is enabled + + // New pages on tabs + $this->tabs = array(); + + // Boxes + $this->boxes = array(); // List of boxes + $r=0; + + // Permissions + $this->rights = array(); // Permission array used by this module + $r=0; + + // Main menu entries + $this->menus = array(); // List of menus to add + $r=0; + + // Exports + $r=1; + } +} + diff --git a/htdocs/core/triggers/interface_20_modStripe_StripeWorkflow.class.php b/htdocs/core/triggers/interface_20_modStripe_StripeWorkflow.class.php new file mode 100644 index 00000000000..4fbf29c7b07 --- /dev/null +++ b/htdocs/core/triggers/interface_20_modStripe_StripeWorkflow.class.php @@ -0,0 +1,113 @@ + + * Copyright (C) 2014 Marcos GarcĂ­a + * Copyright (C) 2017 Alexandre Spangaro + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file /htdocs/core/triggers/interface_20_modStripe_StripeWorkflow.class.php + * \ingroup stripe + * \brief Trigger file for stripe workflow + */ + +require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; + + +/** + * Class of triggers for stripe module + */ +class InterfaceStripeWorkflow extends DolibarrTriggers +{ + public $picto = 'stripe@stripe'; + public $family = 'stripe'; + public $description = "Triggers of this module allows to manage stripe workflow"; + public $version = self::VERSION_DOLIBARR; + + /** + * Function called when a Dolibarrr business event is done. + * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared) + * + * @param string $action Event action code + * @param Object $object Object + * @param User $user Object user + * @param Translate $langs Object langs + * @param conf $conf Object conf + * @return int <0 if KO, 0 if no triggered ran, >0 if OK + */ + public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) + { + // Mettre ici le code a executer en reaction de l'action + // Les donnees de l'action sont stockees dans $object + + if ($action == 'STRIPE_PAYMENT_OK') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". source=".$object->source." ref=".$object->ref); + + if (! empty($object->source)) + { + if ($object->source == 'membersubscription') + { + //require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherents.class.php'; + + // TODO add subscription treatment + } + else + { + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + + $soc = new Societe($this->db); + + // Parse element/subelement (ex: project_task) + $element = $path = $filename = $object->source; + if (preg_match('/^([^_]+)_([^_]+)/i',$object->source,$regs)) + { + $element = $path = $regs[1]; + $filename = $regs[2]; + } + // For compatibility + if ($element == 'order') { + $path = $filename = 'commande'; + } + if ($element == 'invoice') { + $path = 'compta/facture'; $filename = 'facture'; + } + + dol_include_once('/'.$path.'/class/'.$filename.'.class.php'); + + $classname = ucfirst($filename); + $obj = new $classname($this->db); + + $ret = $obj->fetch('',$object->ref); + if ($ret < 0) return -1; + + // Add payer id + $soc->setValueFrom('ref_int', $object->payerID, 'societe', $obj->socid); + + // Add transaction id + $obj->setValueFrom('ref_int',$object->resArray["TRANSACTIONID"]); + } + } + else + { + // TODO add free tag treatment + } + + } + + return 0; + } + +} diff --git a/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN b/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN index 717ef6585f5..5a36bf1069a 100644 --- a/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN +++ b/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN @@ -209,6 +209,7 @@ class InterfaceDemo extends DolibarrTriggers // Online case 'PAYMENT_PAYBOX_OK': case 'PAYMENT_PAYPAL_OK': + case 'PAYMENT_STRIPE_OK': // Donation case 'DON_CREATE': diff --git a/htdocs/langs/en_US/stripe.lang b/htdocs/langs/en_US/stripe.lang new file mode 100644 index 00000000000..f19b4e44a52 --- /dev/null +++ b/htdocs/langs/en_US/stripe.lang @@ -0,0 +1,40 @@ +# Dolibarr language file - Source file is en_US - stripe +StripeSetup=Stripe module setup +StripeDesc=This module offer pages to allow payment on Stripe by customers. This can be used for a free payment or for a payment on a particular Dolibarr object (invoice, order, ...) +StripeOrCBDoPayment=Pay with credit card or Stripe +FollowingUrlAreAvailableToMakePayments=Following URLs are available to offer a page to a customer to make a payment on Dolibarr objects +PaymentForm=Payment form +WelcomeOnPaymentPage=Welcome on our online payment service +ThisScreenAllowsYouToPay=This screen allow you to make an online payment to %s. +ThisIsInformationOnPayment=This is information on payment to do +ToComplete=To complete +YourEMail=Email to receive payment confirmation +Creditor=Creditor +PaymentCode=Payment code +StripeDoPayment=Go on payment +YouWillBeRedirectedOnStripe=You will be redirected on secured Stripe page to input you credit card information +Continue=Next +ToOfferALinkForOnlinePayment=URL for %s payment +ToOfferALinkForOnlinePaymentOnOrder=URL to offer a %s online payment user interface for a customer order +ToOfferALinkForOnlinePaymentOnInvoice=URL to offer a %s online payment user interface for a customer invoice +ToOfferALinkForOnlinePaymentOnContractLine=URL to offer a %s online payment user interface for a contract line +ToOfferALinkForOnlinePaymentOnFreeAmount=URL to offer a %s online payment user interface for a free amount +ToOfferALinkForOnlinePaymentOnMemberSubscription=URL to offer a %s online payment user interface for a member subscription +YouCanAddTagOnUrl=You can also add url parameter &tag=value to any of those URL (required only for free payment) to add your own payment comment tag. +SetupStripeToHavePaymentCreatedAutomatically=Setup your Stripe with url %s to have payment created automatically when validated by Stripe. +YourPaymentHasBeenRecorded=This page confirms that your payment has been recorded. Thank you. +YourPaymentHasNotBeenRecorded=You payment has not been recorded and transaction has been canceled. Thank you. +AccountParameter=Account parameters +UsageParameter=Usage parameters +InformationToFindParameters=Help to find your %s account information +STRIPE_CGI_URL_V2=Url of Stripe CGI module for payment +VendorName=Name of vendor +CSSUrlForPaymentForm=CSS style sheet url for payment form +MessageOK=Message on validated payment return page +MessageKO=Message on canceled payment return page +NewStripePaymentReceived=New Stripe payment received +NewStripePaymentFailed=New Stripe payment tried but failed +STRIPE_TEST_SECRET_KEY=Secret test key +STRIPE_TEST_PUBLISHABLE_KEY=Publishable test key +STRIPE_LIVE_SECRET_KEY=Secret live key +STRIPE_LIVE_PUBLISHABLE_KEY=Publishable live key \ No newline at end of file diff --git a/htdocs/public/demo/index.php b/htdocs/public/demo/index.php index bcca53e9245..3c3353e5eb6 100644 --- a/htdocs/public/demo/index.php +++ b/htdocs/public/demo/index.php @@ -107,7 +107,7 @@ if (empty($reshook)) // Visible $alwayscheckedmodules=array('barcode','bookmark','categorie','externalrss','fckeditor','geoipmaxmind','gravatar','memcached','syslog','user','webservices'); // Technical module we always want - $alwaysuncheckedmodules=array('dynamicprices','loan','multicurrency','paybox','paypal','google','printing','scanner','workflow'); // Module we never want + $alwaysuncheckedmodules=array('dynamicprices','loan','multicurrency','paybox','paypal','stripe','google','printing','scanner','workflow'); // Module we never want // Not visible $alwayshiddencheckedmodules=array('accounting','api','barcode','bookmark','clicktodial','comptabilite','cron','document','domain','externalrss','externalsite','fckeditor','geoipmaxmind','gravatar','label','ldap', 'mailmanspip','notification','oauth','syslog','user','webservices', diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index b101e656f67..104dec7ca09 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -27,7 +27,7 @@ * Note that you can add following constant to change behaviour of page * MEMBER_NEWFORM_AMOUNT Default amount for auto-subscribe form * MEMBER_NEWFORM_EDITAMOUNT Amount can be edited - * MEMBER_NEWFORM_PAYONLINE Suggest payment with paypal of paybox + * MEMBER_NEWFORM_PAYONLINE Suggest payment with paypal, paybox or stripe * MEMBER_NEWFORM_DOLIBARRTURNOVER Show field turnover (specific for dolibarr foundation) * MEMBER_URL_REDIRECT_SUBSCRIPTION Url to redirect once subscribe submitted * MEMBER_NEWFORM_FORCETYPE Force type of member @@ -314,6 +314,18 @@ if ($action == 'add') $urlback.='&securekey='.dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'membersubscription' . $adh->ref, 2); } + } + else if ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'stripe') + { + $urlback=DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?from=membernewform&source=membersubscription&ref='.$adh->ref; + if (price2num(GETPOST('amount'))) $urlback.='&amount='.price2num(GETPOST('amount')); + if (GETPOST('email')) $urlback.='&email='.urlencode(GETPOST('email')); + /* + if (! empty($conf->global->PAYPAL_SECURITY_TOKEN) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) + { + $urlback.='&securekey='.dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'membersubscription' . $adh->ref, 2); + } + */ } else { @@ -579,7 +591,7 @@ if (! empty($conf->global->MEMBER_NEWFORM_AMOUNT) { $amount=GETPOST('amount')?GETPOST('amount'):$conf->global->MEMBER_NEWFORM_AMOUNT; } - // $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal' or 'paybox' + // $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe' print ''.$langs->trans("Subscription").''; if (! empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { diff --git a/htdocs/public/paybox/paymentko.php b/htdocs/public/paybox/paymentko.php index 09de4525b39..77c8e982a09 100644 --- a/htdocs/public/paybox/paymentko.php +++ b/htdocs/public/paybox/paymentko.php @@ -46,6 +46,7 @@ $langs->load("bills"); $langs->load("companies"); $langs->load("paybox"); $langs->load("paypal"); +$langs->load("stripe"); diff --git a/htdocs/public/paybox/paymentok.php b/htdocs/public/paybox/paymentok.php index 9c3030a86ba..1d5c178f05f 100644 --- a/htdocs/public/paybox/paymentok.php +++ b/htdocs/public/paybox/paymentok.php @@ -46,6 +46,7 @@ $langs->load("bills"); $langs->load("companies"); $langs->load("paybox"); $langs->load("paypal"); +$langs->load("stripe"); /*$source=GETPOST('source'); $ref=GETPOST('ref'); diff --git a/htdocs/public/paypal/newpayment.php b/htdocs/public/paypal/newpayment.php index b5d105d6cf6..02e1e6ec8ad 100644 --- a/htdocs/public/paypal/newpayment.php +++ b/htdocs/public/paypal/newpayment.php @@ -53,6 +53,7 @@ $langs->load("companies"); $langs->load("errors"); $langs->load("paybox"); $langs->load("paypal"); +$langs->load("stripe"); // Input are: // type ('invoice','order','contractline'), diff --git a/htdocs/public/paypal/paymentko.php b/htdocs/public/paypal/paymentko.php index 4bad572ed8b..d7724a8fd6c 100644 --- a/htdocs/public/paypal/paymentko.php +++ b/htdocs/public/paypal/paymentko.php @@ -50,6 +50,7 @@ $langs->load("bills"); $langs->load("companies"); $langs->load("paybox"); $langs->load("paypal"); +$langs->load("stripe"); $PAYPALTOKEN=GETPOST('TOKEN'); if (empty($PAYPALTOKEN)) $PAYPALTOKEN=GETPOST('token'); diff --git a/htdocs/public/paypal/paymentok.php b/htdocs/public/paypal/paymentok.php index 90f13aa6f17..1913ab05879 100644 --- a/htdocs/public/paypal/paymentok.php +++ b/htdocs/public/paypal/paymentok.php @@ -50,6 +50,7 @@ $langs->load("bills"); $langs->load("companies"); $langs->load("paybox"); $langs->load("paypal"); +$langs->load("stripe"); // Clean parameters $PAYPAL_API_USER=""; diff --git a/htdocs/public/stripe/index.php b/htdocs/public/stripe/index.php new file mode 100644 index 00000000000..0b7ad1c82e4 --- /dev/null +++ b/htdocs/public/stripe/index.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/public/paybox/index.php + * \ingroup core + * \brief A redirect page to an error + * \author Laurent Destailleur + */ + +require '../../master.inc.php'; + +header("Location: ".DOL_URL_ROOT.'/public/error-404.php'); + diff --git a/htdocs/public/stripe/newpayment.php b/htdocs/public/stripe/newpayment.php new file mode 100644 index 00000000000..33499fe7098 --- /dev/null +++ b/htdocs/public/stripe/newpayment.php @@ -0,0 +1,977 @@ + + * Copyright (C) 2006-2012 Laurent Destailleur + * Copyright (C) 2009-2012 Regis Houssin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * For test: https://stripe.com/docs + */ + +/** + * \file htdocs/public/stripe/newpayment.php + * \ingroup stripe + * \brief File to offer a way to make a payment for a particular Dolibarr entity + */ + +define("NOLOGIN",1); // This means this output page does not require to be logged. +define("NOCSRFCHECK",1); // We accept to go on this page from external web site. + +// For MultiCompany module. +// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +// TODO This should be useless. Because entity must be retreive from object ref and not from url. +$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +if (is_numeric($entity)) define("DOLENTITY", $entity); + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/stripe/lib/stripe.lib.php'; +// require_once DOL_DOCUMENT_ROOT.'/stripe/lib/stripefunctions.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + +// Security check +if (empty($conf->stripe->enabled)) accessforbidden('',0,0,1); + +$langs->load("main"); +$langs->load("other"); +$langs->load("dict"); +$langs->load("bills"); +$langs->load("companies"); +$langs->load("errors"); +$langs->load("paybox"); +$langs->load("paypal"); +$langs->load("stripe"); + +// Input are: +// type ('invoice','order','contractline'), +// id (object id), +// amount (required if id is empty), +// tag (a free text, required if type is empty) +// currency (iso code) + +$suffix=GETPOST("suffix",'alpha'); +$amount=price2num(GETPOST("amount")); +if (! GETPOST("currency",'alpha')) $currency=$conf->currency; +else $currency=GETPOST("currency",'alpha'); + +if (! GETPOST("action")) +{ + if (! GETPOST("amount") && ! GETPOST("source")) + { + dol_print_error('',$langs->trans('ErrorBadParameters')." - amount or source"); + exit; + } + if (is_numeric($amount) && ! GETPOST("tag") && ! GETPOST("source")) + { + dol_print_error('',$langs->trans('ErrorBadParameters')." - tag or source"); + exit; + } + if (GETPOST("source") && ! GETPOST("ref")) + { + dol_print_error('',$langs->trans('ErrorBadParameters')." - ref"); + exit; + } +} + +// Define $urlwithroot +//$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); +//$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file +$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + +$urlok=$urlwithroot.'/public/stripe/paymentok.php?'; +$urlko=$urlwithroot.'/public/stripe/paymentko.php?'; + +// Complete urls for post treatment +$SOURCE=GETPOST("source",'alpha'); +$ref=$REF=GETPOST('ref','alpha'); +$TAG=GETPOST("tag",'alpha'); +$FULLTAG=GETPOST("fulltag",'alpha'); // fulltag is tag with more informations +$SECUREKEY=GETPOST("securekey"); // Secure key + +if (! empty($SOURCE)) +{ + $urlok.='source='.urlencode($SOURCE).'&'; + $urlko.='source='.urlencode($SOURCE).'&'; +} +if (! empty($REF)) +{ + $urlok.='ref='.urlencode($REF).'&'; + $urlko.='ref='.urlencode($REF).'&'; +} +if (! empty($TAG)) +{ + $urlok.='tag='.urlencode($TAG).'&'; + $urlko.='tag='.urlencode($TAG).'&'; +} +if (! empty($FULLTAG)) +{ + $urlok.='fulltag='.urlencode($FULLTAG).'&'; + $urlko.='fulltag='.urlencode($FULLTAG).'&'; +} +if (! empty($SECUREKEY)) +{ + $urlok.='securekey='.urlencode($SECUREKEY).'&'; + $urlko.='securekey='.urlencode($SECUREKEY).'&'; +} +if (! empty($entity)) +{ + $urlok.='entity='.urlencode($entity).'&'; + $urlko.='entity='.urlencode($entity).'&'; +} +$urlok=preg_replace('/&$/','',$urlok); // Remove last & +$urlko=preg_replace('/&$/','',$urlko); // Remove last & + +// Check parameters +$PAYPAL_API_OK=""; +if ($urlok) $PAYPAL_API_OK=$urlok; +$PAYPAL_API_KO=""; +if ($urlko) $PAYPAL_API_KO=$urlko; +/* +if (empty($PAYPAL_API_USER)) +{ + dol_print_error('',"Paypal setup param PAYPAL_API_USER not defined"); + return -1; +} +if (empty($PAYPAL_API_PASSWORD)) +{ + dol_print_error('',"Paypal setup param PAYPAL_API_PASSWORD not defined"); + return -1; +} +if (empty($PAYPAL_API_SIGNATURE)) +{ + dol_print_error('',"Paypal setup param PAYPAL_API_SIGNATURE not defined"); + return -1; +} +*/ + +// Check security token +$valid=true; +if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) +{ + if (! empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) + { + if ($SOURCE && $REF) $token = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $SOURCE . $REF, 2); // Use the source in the hash to avoid duplicates if the references are identical + else $token = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + } + else + { + $token = $conf->global->PAYPAL_SECURITY_TOKEN; + } + if ($SECUREKEY != $token) $valid=false; + + if (! $valid) + { + print '
Bad value for key.
'; + //print 'SECUREKEY='.$SECUREKEY.' token='.$token.' valid='.$valid; + exit; + } +} + + + +/* + * Actions + */ + +if (GETPOST("action") == 'dopayment') +{ + $PAYPAL_API_PRICE=price2num(GETPOST("newamount"),'MT'); + $PAYPAL_PAYMENT_TYPE='Sale'; + + $shipToName=GETPOST("shipToName"); + $shipToStreet=GETPOST("shipToStreet"); + $shipToCity=GETPOST("shipToCity"); + $shipToState=GETPOST("shipToState"); + $shipToCountryCode=GETPOST("shipToCountryCode"); + $shipToZip=GETPOST("shipToZip"); + $shipToStreet2=GETPOST("shipToStreet2"); + $phoneNum=GETPOST("phoneNum"); + $email=GETPOST("email"); + $desc=GETPOST("desc"); + + $mesg=''; + if (empty($PAYPAL_API_PRICE) || ! is_numeric($PAYPAL_API_PRICE)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Amount")); + //elseif (empty($EMAIL)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("YourEMail")); + //elseif (! isValidEMail($EMAIL)) $mesg=$langs->trans("ErrorBadEMail",$EMAIL); + elseif (empty($FULLTAG)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("PaymentCode")); + + //var_dump($_POST); + if (empty($mesg)) + { + dol_syslog("newpayment.php call paypal api and do redirect", LOG_DEBUG); + + // Other + $PAYPAL_API_DEVISE="USD"; + //if ($currency == 'EUR') $PAYPAL_API_DEVISE="EUR"; + //if ($currency == 'USD') $PAYPAL_API_DEVISE="USD"; + if (! empty($currency)) $PAYPAL_API_DEVISE=$currency; + + dol_syslog("Submit Paypal form", LOG_DEBUG); + dol_syslog("PAYPAL_API_USER: $PAYPAL_API_USER", LOG_DEBUG); + //dol_syslog("PAYPAL_API_PASSWORD: $PAYPAL_API_PASSWORD", LOG_DEBUG); // No password into log files + dol_syslog("PAYPAL_API_SIGNATURE: $PAYPAL_API_SIGNATURE", LOG_DEBUG); + dol_syslog("PAYPAL_API_SANDBOX: $PAYPAL_API_SANDBOX", LOG_DEBUG); + dol_syslog("PAYPAL_API_OK: $PAYPAL_API_OK", LOG_DEBUG); + dol_syslog("PAYPAL_API_KO: $PAYPAL_API_KO", LOG_DEBUG); + dol_syslog("PAYPAL_API_PRICE: $PAYPAL_API_PRICE", LOG_DEBUG); + dol_syslog("PAYPAL_API_DEVISE: $PAYPAL_API_DEVISE", LOG_DEBUG); + dol_syslog("shipToName: $shipToName", LOG_DEBUG); + dol_syslog("shipToStreet: $shipToStreet", LOG_DEBUG); + dol_syslog("shipToCity: $shipToCity", LOG_DEBUG); + dol_syslog("shipToState: $shipToState", LOG_DEBUG); + dol_syslog("shipToCountryCode: $shipToCountryCode", LOG_DEBUG); + dol_syslog("shipToZip: $shipToZip", LOG_DEBUG); + dol_syslog("shipToStreet2: $shipToStreet2", LOG_DEBUG); + dol_syslog("phoneNum: $phoneNum", LOG_DEBUG); + dol_syslog("email: $email", LOG_DEBUG); + dol_syslog("desc: $desc", LOG_DEBUG); + + dol_syslog("SCRIPT_URI: ".(empty($_SERVER["SCRIPT_URI"])?'':$_SERVER["SCRIPT_URI"]), LOG_DEBUG); // If defined script uri must match domain of PAYPAL_API_OK and PAYPAL_API_KO + //$_SESSION["PaymentType"]=$PAYPAL_PAYMENT_TYPE; + //$_SESSION["currencyCodeType"]=$PAYPAL_API_DEVISE; + //$_SESSION["Payment_Amount"]=$PAYPAL_API_PRICE; + + // A redirect is added if API call successfull + print_paypal_redirect($PAYPAL_API_PRICE,$PAYPAL_API_DEVISE,$PAYPAL_PAYMENT_TYPE,$PAYPAL_API_OK,$PAYPAL_API_KO, $FULLTAG); + + exit; + } +} + + + +/* + * View + */ + +llxHeaderStripe($langs->trans("PaymentForm")); + +if (! empty($PAYPAL_API_SANDBOX)) +{ + dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode'),'','warning'); +} + +// Common variables +$creditor=$mysoc->name; +$paramcreditor='PAYPAL_CREDITOR_'.$suffix; +if (! empty($conf->global->$paramcreditor)) $creditor=$conf->global->$paramcreditor; +else if (! empty($conf->global->PAYPAL_CREDITOR)) $creditor=$conf->global->PAYPAL_CREDITOR; + +print ''."\n"; +print '
'."\n"; +print '
'."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''; +print "\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print "\n"; + +print ''."\n"; + +// Show logo (search order: logo defined by PAYBOX_LOGO_suffix, then PAYBOX_LOGO, then small company logo, large company logo, theme logo, common logo) +$width=0; +// Define logo and logosmall +$logosmall=$mysoc->logo_small; +$logo=$mysoc->logo; +$paramlogo='PAYBOX_LOGO_'.$suffix; +if (! empty($conf->global->$paramlogo)) $logosmall=$conf->global->$paramlogo; +else if (! empty($conf->global->PAYBOX_LOGO)) $logosmall=$conf->global->PAYBOX_LOGO; +//print ''."\n"; +// Define urllogo +$urllogo=''; +if (! empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) +{ + $urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=companylogo&file='.urlencode('thumbs/'.$logosmall); +} +elseif (! empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) +{ + $urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=companylogo&file='.urlencode($logo); + $width=96; +} +// Output html code for logo +if ($urllogo) +{ + print ''; + print ''; + print ''."\n"; +} + +// Output introduction text +$text=''; +if (! empty($conf->global->PAYPAL_NEWFORM_TEXT)) +{ + $langs->load("members"); + if (preg_match('/^\((.*)\)$/',$conf->global->PAYPAL_NEWFORM_TEXT,$reg)) $text.=$langs->trans($reg[1])."
\n"; + else $text.=$conf->global->PAYPAL_NEWFORM_TEXT."
\n"; + $text=''."\n"; +} +if (empty($text)) +{ + $text.=''."\n"; + $text.=''."\n"; +} +print $text; + +// Output payment summary form +print ''."\n"; + +print '

'.$text.'

'.$langs->trans("WelcomeOnPaymentPage").'

'.$langs->trans("ThisScreenAllowsYouToPay",$creditor).'

'; +print ''; +print ''."\n"; + +$found=false; +$error=0; +$var=false; + +// Free payment +if (! GETPOST("source") && $valid) +{ + $found=true; + $tag=GETPOST("tag"); + $fulltag=$tag; + + // Creditor + $var=!$var; + print ''."\n"; + + // Amount + $var=!$var; + print ''."\n"; + + // Tag + $var=!$var; + print ''."\n"; + + // We do not add fields shipToName, shipToStreet, shipToCity, shipToState, shipToCountryCode, shipToZip, shipToStreet2, phoneNum + // as they don't exists (buyer is unknown, tag is free). +} + + +// Payment on customer order +if (GETPOST("source") == 'order' && $valid) +{ + $found=true; + $langs->load("orders"); + + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + + $order=new Commande($db); + $result=$order->fetch('',$ref); + if ($result < 0) + { + $mesg=$order->error; + $error++; + } + else + { + $result=$order->fetch_thirdparty($order->socid); + } + + $amount=$order->total_ttc; + if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int'); + $amount=price2num($amount); + + $fulltag='ORD='.$order->ref.'.CUS='.$order->thirdparty->id; + //$fulltag.='.NAM='.strtr($order->thirdparty->name,"-"," "); + if (! empty($TAG)) { $tag=$TAG; $fulltag.='.TAG='.$TAG; } + $fulltag=dol_string_unaccent($fulltag); + + // Creditor + $var=!$var; + print ''."\n"; + + // Debitor + $var=!$var; + print ''."\n"; + + // Amount + $var=!$var; + print ''."\n"; + + // Tag + $var=!$var; + print ''."\n"; + + // Shipping address + $shipToName=$order->thirdparty->name; + $shipToStreet=$order->thirdparty->address; + $shipToCity=$order->thirdparty->town; + $shipToState=$order->thirdparty->state_code; + $shipToCountryCode=$order->thirdparty->country_code; + $shipToZip=$order->thirdparty->zip; + $shipToStreet2=''; + $phoneNum=$order->thirdparty->phone; + if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) + { + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + } + else + { + print ''."\n"; + } + print ''."\n"; + print 'ref.'">'."\n"; +} + + +// Payment on customer invoice +if (GETPOST("source") == 'invoice' && $valid) +{ + $found=true; + $langs->load("bills"); + + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + + $invoice=new Facture($db); + $result=$invoice->fetch('',$ref); + if ($result < 0) + { + $mesg=$invoice->error; + $error++; + } + else + { + $result=$invoice->fetch_thirdparty($invoice->socid); + } + + $amount=price2num($invoice->total_ttc - $invoice->getSommePaiement()); + if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int'); + $amount=price2num($amount); + + $fulltag='INV='.$invoice->ref.'.CUS='.$invoice->thirdparty->id; + //$fulltag.='.NAM='.strtr($invoice->thirdparty->name,"-"," "); + if (! empty($TAG)) { $tag=$TAG; $fulltag.='.TAG='.$TAG; } + $fulltag=dol_string_unaccent($fulltag); + + // Creditor + $var=!$var; + print ''."\n"; + + // Debitor + $var=!$var; + print ''."\n"; + + // Amount + $var=!$var; + print ''."\n"; + + // Tag + $var=!$var; + print ''."\n"; + + // Shipping address + $shipToName=$invoice->thirdparty->name; + $shipToStreet=$invoice->thirdparty->address; + $shipToCity=$invoice->thirdparty->town; + $shipToState=$invoice->thirdparty->state_code; + $shipToCountryCode=$invoice->thirdparty->country_code; + $shipToZip=$invoice->thirdparty->zip; + $shipToStreet2=''; + $phoneNum=$invoice->thirdparty->phone; + if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) + { + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + } + else + { + print ''."\n"; + } + print ''."\n"; + print 'ref.'">'."\n"; +} + +// Payment on contract line +if (GETPOST("source") == 'contractline' && $valid) +{ + $found=true; + $langs->load("contracts"); + + require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; + + $contractline=new ContratLigne($db); + $result=$contractline->fetch('',$ref); + if ($result < 0) + { + $mesg=$contractline->error; + $error++; + } + else + { + if ($contractline->fk_contrat > 0) + { + $contract=new Contrat($db); + $result=$contract->fetch($contractline->fk_contrat); + if ($result > 0) + { + $result=$contract->fetch_thirdparty($contract->socid); + } + else + { + $mesg=$contract->error; + $error++; + } + } + else + { + $mesg='ErrorRecordNotFound'; + $error++; + } + } + + $amount=$contractline->total_ttc; + if ($contractline->fk_product) + { + $product=new Product($db); + $result=$product->fetch($contractline->fk_product); + + // We define price for product (TODO Put this in a method in product class) + if (! empty($conf->global->PRODUIT_MULTIPRICES)) + { + $pu_ht = $product->multiprices[$contract->thirdparty->price_level]; + $pu_ttc = $product->multiprices_ttc[$contract->thirdparty->price_level]; + $price_base_type = $product->multiprices_base_type[$contract->thirdparty->price_level]; + } + else + { + $pu_ht = $product->price; + $pu_ttc = $product->price_ttc; + $price_base_type = $product->price_base_type; + } + + $amount=$pu_ttc; + if (empty($amount)) + { + dol_print_error('','ErrorNoPriceDefinedForThisProduct'); + exit; + } + } + if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int'); + $amount=price2num($amount); + + $fulltag='COL='.$contractline->ref.'.CON='.$contract->ref.'.CUS='.$contract->thirdparty->id.'.DAT='.dol_print_date(dol_now(),'%Y%m%d%H%M'); + //$fulltag.='.NAM='.strtr($contract->thirdparty->name,"-"," "); + if (! empty($TAG)) { $tag=$TAG; $fulltag.='.TAG='.$TAG; } + $fulltag=dol_string_unaccent($fulltag); + + $qty=1; + if (GETPOST('qty')) $qty=GETPOST('qty'); + + // Creditor + $var=!$var; + print ''."\n"; + + // Debitor + $var=!$var; + print ''."\n"; + + // Quantity + $var=!$var; + $label=$langs->trans("Quantity"); + $qty=1; + $duration=''; + if ($contractline->fk_product) + { + if ($product->isService() && $product->duration_value > 0) + { + $label=$langs->trans("Duration"); + + // TODO Put this in a global method + if ($product->duration_value > 1) + { + $dur=array("h"=>$langs->trans("Hours"),"d"=>$langs->trans("DurationDays"),"w"=>$langs->trans("DurationWeeks"),"m"=>$langs->trans("DurationMonths"),"y"=>$langs->trans("DurationYears")); + } + else + { + $dur=array("h"=>$langs->trans("Hour"),"d"=>$langs->trans("DurationDay"),"w"=>$langs->trans("DurationWeek"),"m"=>$langs->trans("DurationMonth"),"y"=>$langs->trans("DurationYear")); + } + $duration=$product->duration_value.' '.$dur[$product->duration_unit]; + } + } + print ''; + print ''."\n"; + + // Amount + $var=!$var; + print ''."\n"; + + // Tag + $var=!$var; + print ''."\n"; + + // Shipping address + $shipToName=$contract->thirdparty->name; + $shipToStreet=$contract->thirdparty->address; + $shipToCity=$contract->thirdparty->town; + $shipToState=$contract->thirdparty->state_code; + $shipToCountryCode=$contract->thirdparty->country_code; + $shipToZip=$contract->thirdparty->zip; + $shipToStreet2=''; + $phoneNum=$contract->thirdparty->phone; + if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) + { + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + } + else + { + print ''."\n"; + } + print ''."\n"; + print 'ref.'">'."\n"; +} + +// Payment on member subscription +if (GETPOST("source") == 'membersubscription' && $valid) +{ + $found=true; + $langs->load("members"); + + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; + + $member=new Adherent($db); + $result=$member->fetch('',$ref); + if ($result < 0) + { + $mesg=$member->error; + $error++; + } + else + { + $subscription=new Subscription($db); + } + + $amount=$subscription->total_ttc; + if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int'); + $amount=price2num($amount); + + $fulltag='MEM='.$member->id.'.DAT='.dol_print_date(dol_now(),'%Y%m%d%H%M'); + if (! empty($TAG)) { $tag=$TAG; $fulltag.='.TAG='.$TAG; } + $fulltag=dol_string_unaccent($fulltag); + + // Creditor + $var=!$var; + print ''."\n"; + + // Debitor + $var=!$var; + print ''."\n"; + + if ($member->last_subscription_date || $member->last_subscription_amount) + { + // Last subscription date + $var=!$var; + print ''."\n"; + + // Last subscription amount + $var=!$var; + print ''."\n"; + + if (empty($amount) && ! GETPOST('newamount')) $_GET['newamount']=$member->last_subscription_amount; + } + + // Amount + $var=!$var; + print ''."\n"; + + // Tag + $var=!$var; + print ''."\n"; + + // Shipping address + $shipToName=$member->getFullName($langs); + $shipToStreet=$member->address; + $shipToCity=$member->town; + $shipToState=$member->state_code; + $shipToCountryCode=$member->country_code; + $shipToZip=$member->zip; + $shipToStreet2=''; + $phoneNum=$member->phone; + if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) + { + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + } + else + { + print ''."\n"; + } + print ''."\n"; + print ''."\n"; +} + + + + +if (! $found && ! $mesg) $mesg=$langs->trans("ErrorBadParameters"); + +if ($mesg) print ''."\n"; + +print '
'.$langs->trans("ThisIsInformationOnPayment").' :
'.$langs->trans("Creditor"); + print ''.$creditor.''; + print ''; + print '
'.$langs->trans("Amount"); + if (empty($amount)) print ' ('.$langs->trans("ToComplete").')'; + print ''; + if (empty($amount) || ! is_numeric($amount)) + { + print ''; + print ''; + } + else { + print ''.price($amount).''; + print ''; + print ''; + } + // Currency + print ' '.$langs->trans("Currency".$currency).''; + print ''; + print '
'.$langs->trans("PaymentCode"); + print ''.$fulltag.''; + print ''; + print ''; + print '
'.$langs->trans("Creditor"); + print ''.$creditor.''; + print ''; + print '
'.$langs->trans("ThirdParty"); + print ''.$order->thirdparty->name.''; + + // Object + $var=!$var; + $text=''.$langs->trans("PaymentOrderRef",$order->ref).''; + print '
'.$langs->trans("Designation"); + print ''.$text; + print ''; + print ''; + print '
'.$langs->trans("Amount"); + if (empty($amount)) print ' ('.$langs->trans("ToComplete").')'; + print ''; + if (empty($amount) || ! is_numeric($amount)) + { + print ''; + print ''; + } + else { + print ''.price($amount).''; + print ''; + print ''; + } + // Currency + print ' '.$langs->trans("Currency".$currency).''; + print ''; + print '
'.$langs->trans("PaymentCode"); + print ''.$fulltag.''; + print ''; + print ''; + print '
'.$langs->trans("Creditor"); + print ''.$creditor.''; + print ''; + print '
'.$langs->trans("ThirdParty"); + print ''.$invoice->thirdparty->name.''; + + // Object + $var=!$var; + $text=''.$langs->trans("PaymentInvoiceRef",$invoice->ref).''; + print '
'.$langs->trans("Designation"); + print ''.$text; + print ''; + print ''; + print '
'.$langs->trans("Amount"); + if (empty($amount)) print ' ('.$langs->trans("ToComplete").')'; + print ''; + if (empty($amount) || ! is_numeric($amount)) + { + print ''; + print ''; + } + else { + print ''.price($amount).''; + print ''; + print ''; + } + // Currency + print ' '.$langs->trans("Currency".$currency).''; + print ''; + print '
'.$langs->trans("PaymentCode"); + print ''.$fulltag.''; + print ''; + print ''; + print '
'.$langs->trans("Creditor"); + print ''.$creditor.''; + print ''; + print '
'.$langs->trans("ThirdParty"); + print ''.$contract->thirdparty->name.''; + + // Object + $var=!$var; + $text=''.$langs->trans("PaymentRenewContractId",$contract->ref,$contractline->ref).''; + if ($contractline->fk_product) + { + $text.='
'.$product->ref.($product->label?' - '.$product->label:''); + } + if ($contractline->description) $text.='
'.dol_htmlentitiesbr($contractline->description); + //if ($contractline->date_fin_validite) { + // $text.='
'.$langs->trans("DateEndPlanned").': '; + // $text.=dol_print_date($contractline->date_fin_validite); + //} + if ($contractline->date_fin_validite) + { + $text.='
'.$langs->trans("ExpiredSince").': '.dol_print_date($contractline->date_fin_validite); + } + + print '
'.$langs->trans("Designation"); + print ''.$text; + print ''; + print ''; + print '
'.$label.''.($duration?$duration:$qty).''; + print ''; + print '
'.$langs->trans("Amount"); + if (empty($amount)) print ' ('.$langs->trans("ToComplete").')'; + print ''; + if (empty($amount) || ! is_numeric($amount)) + { + print ''; + print ''; + } + else { + print ''.price($amount).''; + print ''; + print ''; + } + // Currency + print ' '.$langs->trans("Currency".$currency).''; + print ''; + print '
'.$langs->trans("PaymentCode"); + print ''.$fulltag.''; + print ''; + print ''; + print '
'.$langs->trans("Creditor"); + print ''.$creditor.''; + print ''; + print '
'.$langs->trans("Member"); + print ''; + if ($member->morphy == 'mor' && ! empty($member->societe)) print $member->societe; + else print $member->getFullName($langs); + print ''; + + // Object + $var=!$var; + $text=''.$langs->trans("PaymentSubscription").''; + print '
'.$langs->trans("Designation"); + print ''.$text; + print ''; + print ''; + print '
'.$langs->trans("LastSubscriptionDate"); + print ''.dol_print_date($member->last_subscription_date,'day'); + print '
'.$langs->trans("LastSubscriptionAmount"); + print ''.price($member->last_subscription_amount); + print '
'.$langs->trans("Amount"); + if (empty($amount)) + { + print ' ('.$langs->trans("ToComplete"); + if (! empty($conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO)) print ' - '.$langs->trans("SeeHere").''; + print ')'; + } + print ''; + if (empty($amount) || ! is_numeric($amount)) + { + $valtoshow=GETPOST("newamount",'int'); + if (! empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) $valtoshow=max($conf->global->MEMBER_MIN_AMOUNT,$valtoshow); + print ''; + print ''; + } + else { + $valtoshow=$amount; + if (! empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) $valtoshow=max($conf->global->MEMBER_MIN_AMOUNT,$valtoshow); + print ''.price($valtoshow).''; + print ''; + print ''; + } + // Currency + print ' '.$langs->trans("Currency".$currency).''; + print ''; + print '
'.$langs->trans("PaymentCode"); + print ''.$fulltag.''; + print ''; + print ''; + print '

'.$mesg.'
'."\n"; +print "\n"; + +if ($found && ! $error) // We are in a management option and no error +{ + if (empty($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY)) $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY='integral'; + + if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'integral') + { + print '
'; + } + if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'stripeonly') + { + print '
'; + } +} +else +{ + dol_print_error_email('ERRORNEWPAYMENTPAYPAL'); +} + +print '
'."\n"; +print '
'."\n"; +print '
'."\n"; +print '
'; + + +html_print_stripe_footer($mysoc,$langs); + +llxFooterStripe(); + +$db->close(); diff --git a/htdocs/public/stripe/paymentko.php b/htdocs/public/stripe/paymentko.php new file mode 100644 index 00000000000..09de4525b39 --- /dev/null +++ b/htdocs/public/stripe/paymentko.php @@ -0,0 +1,115 @@ + + * Copyright (C) 2006-2013 Laurent Destailleur + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/public/paybox/paymentko.php + * \ingroup paybox + * \brief File to show page after a failed payment + * \author Laurent Destailleur + */ + +define("NOLOGIN",1); // This means this output page does not require to be logged. +define("NOCSRFCHECK",1); // We accept to go on this page from external web site. + +// For MultiCompany module. +// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +// TODO This should be useless. Because entity must be retreive from object ref and not from url. +$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +if (is_numeric($entity)) define("DOLENTITY", $entity); + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/paybox/lib/paybox.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; + +// Security check +if (empty($conf->paybox->enabled)) accessforbidden('',0,0,1); + +$langs->load("main"); +$langs->load("other"); +$langs->load("dict"); +$langs->load("bills"); +$langs->load("companies"); +$langs->load("paybox"); +$langs->load("paypal"); + + + + +/* + * Actions + */ + + + + + +/* + * View + */ + +dol_syslog("Callback url when a PayBox payment was canceled. query_string=".(empty($_SERVER["QUERY_STRING"])?'':$_SERVER["QUERY_STRING"])." script_uri=".(empty($_SERVER["SCRIPT_URI"])?'':$_SERVER["SCRIPT_URI"]), LOG_DEBUG, 0, '_paybox'); + +$tracepost = ""; +foreach($_POST as $k => $v) $tracepost .= "{$k} - {$v}\n"; +dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_paybox'); + + +// Send an email +if (! empty($conf->global->PAYBOX_PAYONLINE_SENDEMAIL)) +{ + $sendto=$conf->global->PAYBOX_PAYONLINE_SENDEMAIL; + $from=$conf->global->MAILING_EMAIL_FROM; + + $urlback=$_SERVER["REQUEST_URI"]; + $topic='['.$conf->global->MAIN_APPLICATION_TITLE.'] '.$langs->transnoentitiesnoconv("NewPayboxPaymentFailed"); + $content=$langs->transnoentitiesnoconv("NewPayboxPaymentFailed")."\n".$fulltag; + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($topic, $sendto, $from, $content); + + $result=$mailfile->sendfile(); + if ($result) + { + dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_paybox'); + } + else + { + dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_paybox'); + } +} + + +llxHeaderPayBox($langs->trans("PaymentForm")); + + +// Show message +print ''."\n"; +print '
'."\n"; + +print $langs->trans("YourPaymentHasNotBeenRecorded")."

\n"; + +if (! empty($conf->global->PAYBOX_MESSAGE_KO)) print $conf->global->PAYBOX_MESSAGE_KO; + +print "\n
\n"; + + +html_print_paybox_footer($mysoc,$langs); + + +llxFooterPayBox(); + +$db->close(); diff --git a/htdocs/public/stripe/paymentok.php b/htdocs/public/stripe/paymentok.php new file mode 100644 index 00000000000..9c3030a86ba --- /dev/null +++ b/htdocs/public/stripe/paymentok.php @@ -0,0 +1,172 @@ + + * Copyright (C) 2006-2013 Laurent Destailleur + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/public/paybox/paymentok.php + * \ingroup paybox + * \brief File to show page after a successful payment + * \author Laurent Destailleur + */ + +define("NOLOGIN",1); // This means this output page does not require to be logged. +define("NOCSRFCHECK",1); // We accept to go on this page from external web site. + +// For MultiCompany module. +// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +// TODO This should be useless. Because entity must be retreive from object ref and not from url. +$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +if (is_numeric($entity)) define("DOLENTITY", $entity); + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/paybox/lib/paybox.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; + +// Security check +if (empty($conf->paybox->enabled)) accessforbidden('',0,0,1); + +$langs->load("main"); +$langs->load("other"); +$langs->load("dict"); +$langs->load("bills"); +$langs->load("companies"); +$langs->load("paybox"); +$langs->load("paypal"); + +/*$source=GETPOST('source'); +$ref=GETPOST('ref'); +$PAYBOXTOKEN=GETPOST('TOKEN'); +if (empty($PAYBOXTOKEN)) $PAYBOXTOKEN=GETPOST('token'); +$PAYBOXPAYERID=GETPOST('PAYERID'); +if (empty($PAYBOXPAYERID)) $PAYBOXPAYERID=GETPOST('PayerID'); +*/ +$PAYBOXFULLTAG=GETPOST('FULLTAG'); +if (empty($PAYBOXFULLTAG)) $PAYBOXFULLTAG=GETPOST('fulltag'); + + +/* + * Actions + */ + + + + + +/* + * View + */ + +dol_syslog("Callback url when a PayBox payment was done. query_string=".(empty($_SERVER["QUERY_STRING"])?'':$_SERVER["QUERY_STRING"])." script_uri=".(empty($_SERVER["SCRIPT_URI"])?'':$_SERVER["SCRIPT_URI"]), LOG_DEBUG, 0, '_paybox'); + +$tracepost = ""; +foreach($_POST as $k => $v) $tracepost .= "{$k} - {$v}\n"; +dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_paybox'); + +llxHeaderPayBox($langs->trans("PaymentForm")); + + +// Show message +print ''."\n"; +print '
'."\n"; + +// Get on url call +/* +$token = $PAYBOXTOKEN; +*/ +$fulltag = $PAYBOXFULLTAG; +/*$payerID = $PAYBOXPAYERID; +// Set by newpayment.php +$paymentType = $_SESSION['PaymentType']; +$currencyCodeType = $_SESSION['currencyCodeType']; +$FinalPaymentAmt = $_SESSION["Payment_Amount"]; +// From env +$ipaddress = $_SESSION['ipaddress']; + +dol_syslog("Call newpaymentok with token=".$token." paymentType=".$paymentType." currencyCodeType=".$currencyCodeType." payerID=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt." fulltag=".$fulltag); +*/ + + +print $langs->trans("YourPaymentHasBeenRecorded")."

\n"; + +if (! empty($conf->global->PAYBOX_MESSAGE_OK)) print $conf->global->PAYBOX_MESSAGE_OK; + +// Appel des triggers +include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; +$interface=new Interfaces($db); +$result=$interface->run_triggers('PAYBOX_PAYMENT_OK',$object,$user,$langs,$conf); +if ($result < 0) { $error++; $errors=$interface->errors; } +// Fin appel triggers + + +// Send an email +if (! empty($conf->global->PAYBOX_PAYONLINE_SENDEMAIL)) +{ + $sendto=$conf->global->PAYBOX_PAYONLINE_SENDEMAIL; + $from=$conf->global->MAILING_EMAIL_FROM; + // Define $urlwithroot + $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); + $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + + $urlback=$_SERVER["REQUEST_URI"]; + $topic='['.$conf->global->MAIN_APPLICATION_TITLE.'] '.$langs->transnoentitiesnoconv("NewPayboxPaymentReceived"); + $tmptag=dolExplodeIntoArray($fulltag,'.','='); + $content=""; + if (! empty($tmptag['MEM'])) + { + $langs->load("members"); + $url=$urlwithroot."/adherents/card_subscriptions.php?rowid=".$tmptag['MEM']; + $content.=$langs->trans("PaymentSubscription")."
\n"; + $content.=$langs->trans("MemberId").': '.$tmptag['MEM']."
\n"; + $content.=$langs->trans("Link").': '.$url.''."
\n"; + } + else + { + $content.=$langs->transnoentitiesnoconv("NewPayboxPaymentReceived")."
\n"; + } + $content.="
\n"; + $content.=$langs->transnoentitiesnoconv("TechnicalInformation").":
\n"; + $content.=$langs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."
\n"; + $content.="tag=".$fulltag."
\n"; + + $ishtml=dol_textishtml($content); // May contain urls + + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($topic, $sendto, $from, $content, array(), array(), array(), '', '', 0, $ishtml); + + // Send an email + $result=$mailfile->sendfile(); + if ($result) + { + dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_paybox'); + } + else + { + dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_paybox'); + } +} + + + +print "\n
\n"; + +html_print_paybox_footer($mysoc,$langs); + + +llxFooterPayBox(); + +$db->close(); diff --git a/htdocs/stripe/admin/index.html b/htdocs/stripe/admin/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php new file mode 100644 index 00000000000..481f6634227 --- /dev/null +++ b/htdocs/stripe/admin/stripe.php @@ -0,0 +1,225 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/stripe/admin/stripe.php + * \ingroup stripe + * \brief Page to setup stripe module + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/stripe/lib/stripe.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + +$servicename='Stripe'; + +$langs->load("admin"); +$langs->load("other"); +$langs->load("stripe"); + +if (!$user->admin) + accessforbidden(); + +$action = GETPOST('action','alpha'); + + +if ($action == 'setvalue' && $user->admin) +{ + $db->begin(); + + $result=dolibarr_set_const($db, "STRIPE_API_SANDBOX",GETPOST('STRIPE_API_SANDBOX','alpha'),'chaine',0,'',$conf->entity); + if (! $result > 0) $error++; + $result=dolibarr_set_const($db, "STRIPE_TEST_SECRET_KEY",GETPOST('STRIPE_TEST_SECRET_KEY','alpha'),'chaine',0,'',$conf->entity); + if (! $result > 0) $error++; + $result=dolibarr_set_const($db, "STRIPE_TEST_PUBLISHABLE_KEY",GETPOST('STRIPE_TEST_PUBLISHABLE_KEY','alpha'),'chaine',0,'',$conf->entity); + if (! $result > 0) $error++; + $result=dolibarr_set_const($db, "STRIPE_LIVE_SECRET_KEY",GETPOST('STRIPE_LIVE_SECRET_KEY','alpha'),'chaine',0,'',$conf->entity); + if (! $result > 0) $error++; + $result=dolibarr_set_const($db, "STRIPE_LIVE_PUBLISHABLE_KEY",GETPOST('STRIPE_LIVE_PUBLISHABLE_KEY','alpha'),'chaine',0,'',$conf->entity); + if (! $result > 0) $error++; + $result=dolibarr_set_const($db, "STRIPE_CREDITOR",GETPOST('STRIPE_CREDITOR','alpha'),'chaine',0,'',$conf->entity); + if (! $result > 0) $error++; + $result=dolibarr_set_const($db, "STRIPE_CSS_URL",GETPOST('STRIPE_CSS_URL','alpha'),'chaine',0,'',$conf->entity); + if (! $result > 0) $error++; + $result=dolibarr_set_const($db, "STRIPE_MESSAGE_OK",GETPOST('STRIPE_MESSAGE_OK','alpha'),'chaine',0,'',$conf->entity); + if (! $result > 0) $error++; + $result=dolibarr_set_const($db, "STRIPE_MESSAGE_KO",GETPOST('STRIPE_MESSAGE_KO','alpha'),'chaine',0,'',$conf->entity); + if (! $result > 0) $error++; + + if (! $error) + { + $db->commit(); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + else + { + $db->rollback(); + dol_print_error($db); + } +} + + +/* + * View + */ + +$SECRET_TEST_KEY="sk_test_xxxxxxxxxxxxxxxxxxxxxxxx"; // Stripe test secret key +if (empty($conf->global->STRIPE_TEST_SECRET_KEY)) $conf->global->STRIPE_TEST_SECRET_KEY = $SECRET_TEST_KEY; +$PUBLISHABLE_TEST_KEY="pk_test_xxxxxxxxxxxxxxxxxxxxxxxx"; // Stripe test publishable key +if (empty($conf->global->STRIPE_TEST_PUBLISHABLE_KEY)) $conf->global->STRIPE_TEST_PUBLISHABLE_KEY = $PUBLISHABLE_TEST_KEY; + +$SECRET_LIVE_KEY="sk_live_xxxxxxxxxxxxxxxxxxxxxxxx"; // Stripe live secret key +if (empty($conf->global->STRIPE_LIVE_SECRET_KEY)) $conf->global->STRIPE_LIVE_SECRET_KEY = $SECRET_LIVE_KEY; +$PUBLISHABLE_LIVE_KEY="pk_live_xxxxxxxxxxxxxxxxxxxxxxxx"; // Stripe live publishable key +if (empty($conf->global->STRIPE_LIVE_PUBLISHABLE_KEY)) $conf->global->STRIPE_LIVE_PUBLISHABLE_KEY = $PUBLISHABLE_LIVE_KEY; + +llxHeader('',$langs->trans("StripeSetup")); + + +$linkback=''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("ModuleSetup").' Stripe',$linkback); +print '
'; + +$head=stripeadmin_prepare_head(); + +print '
'; +print ''; +print ''; + +dol_fiche_head($head, 'stripeaccount', ''); + +print $langs->trans("StripeDesc")."
\n"; + +print '
'; + +$var=true; + +print ''; +print ''; +print ''; +print ''; +print "\n"; + +$var=!$var; +print ''; + +$var=!$var; +print ''; + +$var=!$var; +print ''; + +$var=!$var; +print ''; + +$var=!$var; +print ''; + +$var=true; +print ''; +print ''; +print ''; +print "\n"; + +$var=!$var; +print ''; + +$var=!$var; +print ''; + +$var=!$var; +print ''; + +$var=!$var; +print ''; + +print '
'.$langs->trans("AccountParameter").''.$langs->trans("Value").'
'; +print $langs->trans("STRIPE_API_SANDBOX").''; +print $form->selectyesno("STRIPE_API_SANDBOX",$conf->global->STRIPE_API_SANDBOX,1); +print '
'; +print ''.$langs->trans("STRIPE_TEST_SECRET_KEY").''; +print ''; +print '
'.$langs->trans("Example").': sk_test_xxxxxxxxxxxxxxxxxxxxxxxx'; +print '
'; +print ''.$langs->trans("STRIPE_TEST_PUBLISHABLE_KEY").''; +print ''; +print '
'.$langs->trans("Example").': pk_test_xxxxxxxxxxxxxxxxxxxxxxxx'; +print '
'; +print ''.$langs->trans("STRIPE_LIVE_SECRET_KEY").''; +print ''; +print '
'.$langs->trans("Example").': sk_live_xxxxxxxxxxxxxxxxxxxxxxxx'; +print '
'; +print ''.$langs->trans("STRIPE_LIVE_PUBLISHABLE_KEY").''; +print ''; +print '
'.$langs->trans("Example").': pk_live_xxxxxxxxxxxxxxxxxxxxxxxx'; +print '
'.$langs->trans("UsageParameter").''.$langs->trans("Value").'
'; +print $langs->trans("VendorName").''; +print ''; +print '
'.$langs->trans("Example").': '.$mysoc->name; +print '
'; +print $langs->trans("CSSUrlForPaymentForm").''; +print ''; +print '
'.$langs->trans("Example").': http://mysite/mycss.css'; +print '
'; +print $langs->trans("MessageOK").''; +$doleditor=new DolEditor('STRIPE_MESSAGE_OK',$conf->global->STRIPE_MESSAGE_OK,'',100,'dolibarr_details','In',false,true,true,ROWS_2,60); +$doleditor->Create(); +print '
'; +print $langs->trans("MessageKO").''; +$doleditor=new DolEditor('STRIPE_MESSAGE_KO',$conf->global->STRIPE_MESSAGE_KO,'',100,'dolibarr_details','In',false,true,true,ROWS_2,60); +$doleditor->Create(); +print '
'; + +dol_fiche_end(); + +print '
'; + +print '
'; + +print '

'; + +print ''.$langs->trans("FollowingUrlAreAvailableToMakePayments").':
'; +print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnFreeAmount",$servicename).':
'; +print ''.DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?amount=9.99&tag=your_free_tag'."
\n"; +if (! empty($conf->commande->enabled)) +{ + print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnOrder",$servicename).':
'; + print ''.DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?source=order&ref=order_ref'."
\n"; +} +if (! empty($conf->facture->enabled)) +{ + print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnInvoice",$servicename).':
'; + print ''.DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?source=invoice&ref=invoice_ref'."
\n"; +} +if (! empty($conf->contrat->enabled)) +{ + print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnContractLine",$servicename).':
'; + print ''.DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?source=contractline&ref=contractline_ref'."
\n"; +} +if (! empty($conf->adherent->enabled)) +{ + print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnMemberSubscription",$servicename).':
'; + print ''.DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?source=membersubscription&ref=member_ref'."
\n"; +} + +print "
"; +print info_admin($langs->trans("YouCanAddTagOnUrl")); + +llxFooter(); + +$db->close(); diff --git a/htdocs/stripe/img/index.html b/htdocs/stripe/img/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/stripe/img/object_stripe.png b/htdocs/stripe/img/object_stripe.png new file mode 100644 index 0000000000000000000000000000000000000000..287bd24910cb0fc86f886d02789f29b993bad530 GIT binary patch literal 819 zcmV-31I+x1P)2`81ATls8IUq4NIxsmpFgGA8FflMNTjFhO00007bV*G`2iXD;69^O^U!ddw z00M_eL_t(IPfb%#NK`=_{$}2L`}XbI#Y*sBfuXLJQs|+mbEhCG$e>Q)sY3?|JV=3r zhax(3=~@s$cInbJItE!FL?o7(MUj}TmTjx+8d^I5p&UgdzdheUcQK3M;T)V+b@tl3*XuCg;3mUOj+e2U zwd2~^!rh)@rLp?c;M;Nxy)ah+d=Dn@;pB4g0=lOp!u2Uak~o9^C6#iSj#&I^pe~$z zZfsma*{F=ym&cj&?dT~oB2$&ib-bP3z`gq=t}DA&glvh4leoChL`!>sv8!F^+ZS50 zjC|g~!2>z&ON_)lfdVBcKuEJB$)Te=k;!n8WBSE!Je(@w>9cjLl%fWyQA$I^CfNSy z!flXcWU?A_^ILfQwv=yCu zeJfyS7UeW*Ay6%_B1;q{E1>aXwT|mIm+)$)f+(_wi=M6wE?;a$bBkx)qpU*gQ_M?C zNI~@=^zgkDSyg78(Ri53(-IKB!LKsGm#2? zUaH~!$0};Ir2eRGFuPd8t*J8BC;~4PkRAZ)(&!gcV>BC8ggDEh#0=Q&O4M+(L?J0u zn;4&$3p;rEx_Z2A@_*4}b0y|Y<6Cg^d?(GkiF-nrVjk$^ygQ5TcCHVf&Z4*1;}ez= xl0Jw_8nqA>;D-U6fJV|l@gnx;>KNIzfxiXLt)E)oqyhi{002ovPDHLkV1kvqX=wle literal 0 HcmV?d00001 diff --git a/htdocs/stripe/index.html b/htdocs/stripe/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/stripe/lib/index.html b/htdocs/stripe/lib/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/stripe/lib/stripe.lib.php b/htdocs/stripe/lib/stripe.lib.php new file mode 100644 index 00000000000..d2d138cc8b3 --- /dev/null +++ b/htdocs/stripe/lib/stripe.lib.php @@ -0,0 +1,445 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/stripe/lib/stripe.lib.php + * \ingroup stripe + * \brief Library for common stripe functions + */ + + + +/** + * Show header + * + * @param string $title Title of page + * @param string $head Head string to add int head section + * @return void + */ +function llxHeaderStripe($title, $head = "") +{ + global $user, $conf, $langs; + + header("Content-type: text/html; charset=".$conf->file->character_set_client); + + print ''; + //print ''; + print "\n"; + print "\n"; + print "\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print "".$title."\n"; + if ($head) print $head."\n"; + if (! empty($conf->global->STRIPE_CSS_URL)) print ''."\n"; + else + { + print ''."\n"; + print ''; + } + print "\n"; + print ''."\n"; +} + +/** + * Show footer + * + * @return void + */ +function llxFooterStripe() +{ + print "\n"; + print "\n"; +} + +/** + * Define head array for tabs of stripe tools setup pages + * + * @return Array of head + */ +function stripeadmin_prepare_head() +{ + global $langs, $conf; + + $h = 0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT."/stripe/admin/stripe.php"; + $head[$h][1] = $langs->trans("Stripe"); + $head[$h][2] = 'stripeaccount'; + $h++; + + $object=new stdClass(); + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname); to remove a tab + complete_head_from_modules($conf,$langs,$object,$head,$h,'stripeadmin'); + + complete_head_from_modules($conf,$langs,$object,$head,$h,'stripeadmin','remove'); + + return $head; +} + + + +/** + * Return string with full Url + * + * @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'membersubscription' ...) + * @param string $ref Ref of object + * @return string Url string + */ +function showStripePaymentUrl($type,$ref) +{ + global $conf, $langs; + + $langs->load("paypal"); + $langs->load("paybox"); + $langs->load("stripe"); + $servicename='Stripe'; + $out='

'; + $out.=img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePayment",$servicename).'
'; + $url=getStripePaymentUrl(0,$type,$ref); + $out.='
'; + return $out; +} + +/** + * Return string with full Url + * + * @param int $mode 0=True url, 1=Url formated with colors + * @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'membersubscription' ...) + * @param string $ref Ref of object + * @param int $amount Amount + * @param string $freetag Free tag + * @return string Url string + */ +function getStripePaymentUrl($mode,$type,$ref='',$amount='9.99',$freetag='your_free_tag') +{ + global $conf; + + $ref=str_replace(' ','',$ref); + + if ($type == 'free') + { + $out=DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?amount='.($mode?'':'').$amount.($mode?'':'').'&tag='.($mode?'':'').$freetag.($mode?'':''); + if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) + { + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; + else $out.='&securekey='.dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + } + } + if ($type == 'order') + { + $out=DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?source=order&ref='.($mode?'':''); + if ($mode == 1) $out.='order_ref'; + if ($mode == 0) $out.=urlencode($ref); + $out.=($mode?'':''); + if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) + { + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; + else + { + $out.='&securekey='.($mode?'':''); + if ($mode == 1) $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + order_ref)"; + if ($mode == 0) $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $type . $ref, 2); + $out.=($mode?'':''); + } + } + } + if ($type == 'invoice') + { + $out=DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?source=invoice&ref='.($mode?'':''); + if ($mode == 1) $out.='invoice_ref'; + if ($mode == 0) $out.=urlencode($ref); + $out.=($mode?'':''); + if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) + { + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; + else + { + $out.='&securekey='.($mode?'':''); + if ($mode == 1) $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + invoice_ref)"; + if ($mode == 0) $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $type . $ref, 2); + $out.=($mode?'':''); + } + } + } + if ($type == 'contractline') + { + $out=DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?source=contractline&ref='.($mode?'':''); + if ($mode == 1) $out.='contractline_ref'; + if ($mode == 0) $out.=urlencode($ref); + $out.=($mode?'':''); + if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) + { + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; + else + { + $out.='&securekey='.($mode?'':''); + if ($mode == 1) $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + contractline_ref)"; + if ($mode == 0) $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $type . $ref, 2); + $out.=($mode?'':''); + } + } + } + if ($type == 'membersubscription') + { + $out=DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?source=membersubscription&ref='.($mode?'':''); + if ($mode == 1) $out.='member_ref'; + if ($mode == 0) $out.=urlencode($ref); + $out.=($mode?'':''); + if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) + { + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; + else + { + $out.='&securekey='.($mode?'':''); + if ($mode == 1) $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + member_ref)"; + if ($mode == 0) $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $type . $ref, 2); + $out.=($mode?'':''); + } + } + } + + // For multicompany + $out.="&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities + + return $out; +} + + +/** + * Create a redirect form to paybox form + * + * @param int $PRICE Price + * @param string $CURRENCY Currency + * @param string $EMAIL EMail + * @param string $urlok Url to go back if payment is OK + * @param string $urlko Url to go back if payment is KO + * @param string $TAG Tag + * @return int 1 if OK, -1 if ERROR + */ +function print_stripe_redirect($PRICE,$CURRENCY,$EMAIL,$urlok,$urlko,$TAG) +{ + global $conf, $langs, $db; + + dol_syslog("Stripe.lib::print_paybox_redirect", LOG_DEBUG); + + // Clean parameters + $PBX_IDENTIFIANT="2"; // Identifiant pour v2 test + if (! empty($conf->global->PAYBOX_PBX_IDENTIFIANT)) $PBX_IDENTIFIANT=$conf->global->PAYBOX_PBX_IDENTIFIANT; + $IBS_SITE="1999888"; // Site test + if (! empty($conf->global->PAYBOX_IBS_SITE)) $IBS_SITE=$conf->global->PAYBOX_IBS_SITE; + $IBS_RANG="99"; // Rang test + if (! empty($conf->global->PAYBOX_IBS_RANG)) $IBS_RANG=$conf->global->PAYBOX_IBS_RANG; + $IBS_DEVISE="840"; // Currency (Dollar US by default) + if ($CURRENCY == 'EUR') $IBS_DEVISE="978"; + if ($CURRENCY == 'USD') $IBS_DEVISE="840"; + + $URLPAYBOX=""; + if ($conf->global->PAYBOX_CGI_URL_V1) $URLPAYBOX=$conf->global->PAYBOX_CGI_URL_V1; + if ($conf->global->PAYBOX_CGI_URL_V2) $URLPAYBOX=$conf->global->PAYBOX_CGI_URL_V2; + + if (empty($IBS_DEVISE)) + { + dol_print_error('',"Paybox setup param PAYBOX_IBS_DEVISE not defined"); + return -1; + } + if (empty($URLPAYBOX)) + { + dol_print_error('',"Paybox setup param PAYBOX_CGI_URL_V1 and PAYBOX_CGI_URL_V2 undefined"); + return -1; + } + if (empty($IBS_SITE)) + { + dol_print_error('',"Paybox setup param PAYBOX_IBS_SITE not defined"); + return -1; + } + if (empty($IBS_RANG)) + { + dol_print_error('',"Paybox setup param PAYBOX_IBS_RANG not defined"); + return -1; + } + + // Definition des parametres vente produit pour paybox + $IBS_CMD=$TAG; + $IBS_TOTAL=$PRICE*100; // En centimes + $IBS_MODE=1; // Mode formulaire + $IBS_PORTEUR=$EMAIL; + $IBS_RETOUR="montant:M;ref:R;auto:A;trans:T"; // Format des parametres du get de validation en reponse (url a definir sous paybox) + $IBS_TXT=' '; // Use a space + $IBS_BOUTPI=$langs->trans("Wait"); + //$IBS_BOUTPI=''; + $IBS_EFFECTUE=$urlok; + $IBS_ANNULE=$urlko; + $IBS_REFUSE=$urlko; + $IBS_BKGD="#FFFFFF"; + $IBS_WAIT="2000"; + $IBS_LANG="GBR"; // By default GBR=english (FRA, GBR, ESP, ITA et DEU...) + if (preg_match('/^FR/i',$langs->defaultlang)) $IBS_LANG="FRA"; + if (preg_match('/^ES/i',$langs->defaultlang)) $IBS_LANG="ESP"; + if (preg_match('/^IT/i',$langs->defaultlang)) $IBS_LANG="ITA"; + if (preg_match('/^DE/i',$langs->defaultlang)) $IBS_LANG="DEU"; + if (preg_match('/^NL/i',$langs->defaultlang)) $IBS_LANG="NLD"; + if (preg_match('/^SE/i',$langs->defaultlang)) $IBS_LANG="SWE"; + $IBS_OUTPUT='E'; + $PBX_SOURCE='HTML'; + $PBX_TYPEPAIEMENT='CARTE'; + + dol_syslog("Soumission Paybox", LOG_DEBUG); + dol_syslog("IBS_MODE: $IBS_MODE", LOG_DEBUG); + dol_syslog("IBS_SITE: $IBS_SITE", LOG_DEBUG); + dol_syslog("IBS_RANG: $IBS_RANG", LOG_DEBUG); + dol_syslog("IBS_TOTAL: $IBS_TOTAL", LOG_DEBUG); + dol_syslog("IBS_DEVISE: $IBS_DEVISE", LOG_DEBUG); + dol_syslog("IBS_CMD: $IBS_CMD", LOG_DEBUG); + dol_syslog("IBS_PORTEUR: $IBS_PORTEUR", LOG_DEBUG); + dol_syslog("IBS_RETOUR: $IBS_RETOUR", LOG_DEBUG); + dol_syslog("IBS_EFFECTUE: $IBS_EFFECTUE", LOG_DEBUG); + dol_syslog("IBS_ANNULE: $IBS_ANNULE", LOG_DEBUG); + dol_syslog("IBS_REFUSE: $IBS_REFUSE", LOG_DEBUG); + dol_syslog("IBS_BKGD: $IBS_BKGD", LOG_DEBUG); + dol_syslog("IBS_WAIT: $IBS_WAIT", LOG_DEBUG); + dol_syslog("IBS_LANG: $IBS_LANG", LOG_DEBUG); + dol_syslog("IBS_OUTPUT: $IBS_OUTPUT", LOG_DEBUG); + dol_syslog("PBX_IDENTIFIANT: $PBX_IDENTIFIANT", LOG_DEBUG); + dol_syslog("PBX_SOURCE: $PBX_SOURCE", LOG_DEBUG); + dol_syslog("PBX_TYPEPAIEMENT: $PBX_TYPEPAIEMENT", LOG_DEBUG); + + header("Content-type: text/html; charset=".$conf->file->character_set_client); + + print ''."\n"; + print ''."\n"; + print "\n"; + print ''."\n"; + print ''."\n"; + print "\n"; + + // Formulaire pour module Paybox + print '
'."\n"; + + // For Paybox V2 (PBX_xxx) + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + + print '
'."\n"; + + + print "\n"; + print ''."\n"; + print "\n"; + print ''."\n"; + print "\n"; + + return; +} + + +/** + * Show footer of company in HTML pages + * + * @param Societe $fromcompany Third party + * @param Translate $langs Output language + * @return void + */ +function html_print_stripe_footer($fromcompany,$langs) +{ + global $conf; + + // Juridical status + $line1=""; + if ($fromcompany->forme_juridique_code) + { + $line1.=($line1?" - ":"").getFormeJuridiqueLabel($fromcompany->forme_juridique_code); + } + // Capital + if ($fromcompany->capital) + { + $line1.=($line1?" - ":"").$langs->transnoentities("CapitalOf",$fromcompany->capital)." ".$langs->transnoentities("Currency".$conf->currency); + } + // Prof Id 1 + if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || ! $fromcompany->idprof2)) + { + $field=$langs->transcountrynoentities("ProfId1",$fromcompany->country_code); + if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; + $line1.=($line1?" - ":"").$field.": ".$fromcompany->idprof1; + } + // Prof Id 2 + if ($fromcompany->idprof2) + { + $field=$langs->transcountrynoentities("ProfId2",$fromcompany->country_code); + if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; + $line1.=($line1?" - ":"").$field.": ".$fromcompany->idprof2; + } + + // Second line of company infos + $line2=""; + // Prof Id 3 + if ($fromcompany->idprof3) + { + $field=$langs->transcountrynoentities("ProfId3",$fromcompany->country_code); + if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; + $line2.=($line2?" - ":"").$field.": ".$fromcompany->idprof3; + } + // Prof Id 4 + if ($fromcompany->idprof4) + { + $field=$langs->transcountrynoentities("ProfId4",$fromcompany->country_code); + if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; + $line2.=($line2?" - ":"").$field.": ".$fromcompany->idprof4; + } + // IntraCommunautary VAT + if ($fromcompany->tva_intra != '') + { + $line2.=($line2?" - ":"").$langs->transnoentities("VATIntraShort").": ".$fromcompany->tva_intra; + } + + print '


'."\n"; + print '
'."\n"; + print $fromcompany->name.'
'; + print $line1.'
'; + print $line2; + print '
'."\n"; +} + diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index c8b18c81987..ef9a08524b3 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1361,7 +1361,7 @@ $mainmenuusedarray=array_unique(explode(',',$mainmenuused)); $generic=1; // Put here list of menu entries when the div.mainmenu.menuentry was previously defined -$divalreadydefined=array('home','companies','products','commercial','externalsite','accountancy','project','tools','members','agenda','ftp','holiday','hrm','bookmark','cashdesk','ecm','geoipmaxmind','gravatar','clicktodial','paypal','webservices','websites'); +$divalreadydefined=array('home','companies','products','commercial','externalsite','accountancy','project','tools','members','agenda','ftp','holiday','hrm','bookmark','cashdesk','ecm','geoipmaxmind','gravatar','clicktodial','paypal','stripe','webservices','websites'); // Put here list of menu entries we are sure we don't want $divnotrequired=array('multicurrency','salaries','margin','opensurvey','paybox','expensereport','incoterm','prelevement','propal','workflow','notification','supplier_proposal','cron','product','productbatch','expedition'); foreach($mainmenuusedarray as $val) diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index ad4ec25df1d..144df2d12f8 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1371,7 +1371,7 @@ $mainmenuusedarray=array_unique(explode(',',$mainmenuused)); $generic=1; // Put here list of menu entries when the div.mainmenu.menuentry was previously defined -$divalreadydefined=array('home','companies','products','commercial','externalsite','accountancy','project','tools','members','agenda','ftp','holiday','hrm','bookmark','cashdesk','ecm','geoipmaxmind','gravatar','clicktodial','paypal','webservices','websites'); +$divalreadydefined=array('home','companies','products','commercial','externalsite','accountancy','project','tools','members','agenda','ftp','holiday','hrm','bookmark','cashdesk','ecm','geoipmaxmind','gravatar','clicktodial','paypal','stripe','webservices','websites'); // Put here list of menu entries we are sure we don't want $divnotrequired=array('multicurrency','salaries','margin','opensurvey','paybox','expensereport','incoterm','prelevement','propal','workflow','notification','supplier_proposal','cron','product','productbatch','expedition'); foreach($mainmenuusedarray as $val)