New : Integration of Stripe

This commit is contained in:
Alexandre SPANGARO 2017-02-22 06:33:52 +01:00
parent 2dbae7b808
commit 942b58efaf
32 changed files with 2267 additions and 7 deletions

View File

@ -326,6 +326,12 @@ source_file = htdocs/langs/en_US/stocks.lang
source_lang = en_US
type = MOZILLAPROPERTIES
[dolibarr.stripe]
file_filter = htdocs/langs/<lang>/stripe.lang
source_file = htdocs/langs/en_US/stripe.lang
source_lang = en_US
type = MOZILLAPROPERTIES
[dolibarr.suppliers]
file_filter = htdocs/langs/<lang>/suppliers.lang
source_file = htdocs/langs/en_US/suppliers.lang

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -179,7 +179,7 @@ print '</td><td align="right">';
print $form->selectyesno("MEMBER_NEWFORM_EDITAMOUNT",(! empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)?$conf->global->MEMBER_NEWFORM_EDITAMOUNT:0),1);
print "</td></tr>\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 "</td></tr>\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;

View File

@ -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);
}
}
/*

View File

@ -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 '</div><div class="fichehalfright"><div class="ficheaddleft">';
// List of actions on element

View File

@ -0,0 +1,103 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
/**
* \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;
}
}

View File

@ -0,0 +1,113 @@
<?php
/* Copyright (C) 2011-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2017 Alexandre Spangaro <aspangaro@zendsi.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
/**
* \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;
}
}

View File

@ -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':

View File

@ -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 <a href="http://www.stripe.com" target="_blank">Stripe</a> 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 <b>&tag=<i>value</i></b> to any of those URL (required only for free payment) to add your own payment comment tag.
SetupStripeToHavePaymentCreatedAutomatically=Setup your Stripe with url <b>%s</b> 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

View File

@ -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',

View File

@ -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 '<tr><td>'.$langs->trans("Subscription").'</td><td class="nowrap">';
if (! empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT))
{

View File

@ -46,6 +46,7 @@ $langs->load("bills");
$langs->load("companies");
$langs->load("paybox");
$langs->load("paypal");
$langs->load("stripe");

View File

@ -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');

View File

@ -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'),

View File

@ -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');

View File

@ -50,6 +50,7 @@ $langs->load("bills");
$langs->load("companies");
$langs->load("paybox");
$langs->load("paypal");
$langs->load("stripe");
// Clean parameters
$PAYPAL_API_USER="";

View File

@ -0,0 +1,28 @@
<?php
/* Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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 <http://www.gnu.org/licenses/>.
*/
/**
* \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');

View File

@ -0,0 +1,977 @@
<?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009-2012 Regis Houssin <regis.houssin@capnetworks.com>
*
* 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 <http://www.gnu.org/licenses/>.
*
* 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 '<div class="error">Bad value for key.</div>';
//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 '<span id="dolpaymentspan"></span>'."\n";
print '<div class="center">'."\n";
print '<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'."\n";
print '<input type="hidden" name="action" value="dopayment">'."\n";
print '<input type="hidden" name="tag" value="'.GETPOST("tag",'alpha').'">'."\n";
print '<input type="hidden" name="suffix" value="'.GETPOST("suffix",'alpha').'">'."\n";
print '<input type="hidden" name="securekey" value="'.$SECUREKEY.'">'."\n";
print '<input type="hidden" name="entity" value="'.$entity.'" />';
print "\n";
print '<!-- Form to send a Paypal payment -->'."\n";
print '<!-- PAYPAL_API_SANDBOX = '.$conf->global->PAYPAL_API_SANDBOX.' -->'."\n";
print '<!-- PAYPAL_API_INTEGRAL_OR_PAYPALONLY = '.$conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY.' -->'."\n";
print '<!-- creditor = '.$creditor.' -->'."\n";
print '<!-- urlok = '.$urlok.' -->'."\n";
print '<!-- urlko = '.$urlko.' -->'."\n";
print "\n";
print '<table id="dolpaymenttable" summary="Payment form" class="center">'."\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 '<!-- Show logo (logosmall='.$logosmall.' logo='.$logo.') -->'."\n";
// Define urllogo
$urllogo='';
if (! empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall))
{
$urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=companylogo&amp;file='.urlencode('thumbs/'.$logosmall);
}
elseif (! empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo))
{
$urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=companylogo&amp;file='.urlencode($logo);
$width=96;
}
// Output html code for logo
if ($urllogo)
{
print '<tr>';
print '<td align="center"><img id="dolpaymentlogo" title="'.$title.'" src="'.$urllogo.'"';
if ($width) print ' width="'.$width.'"';
print '></td>';
print '</tr>'."\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])."<br>\n";
else $text.=$conf->global->PAYPAL_NEWFORM_TEXT."<br>\n";
$text='<tr><td align="center"><br>'.$text.'<br></td></tr>'."\n";
}
if (empty($text))
{
$text.='<tr><td class="textpublicpayment"><br><strong>'.$langs->trans("WelcomeOnPaymentPage").'</strong><br></td></tr>'."\n";
$text.='<tr><td class="textpublicpayment"><br>'.$langs->trans("ThisScreenAllowsYouToPay",$creditor).'<br><br></td></tr>'."\n";
}
print $text;
// Output payment summary form
print '<tr><td align="center">';
print '<table with="100%" id="tablepublicpayment">';
print '<tr class="liste_total"><td align="left" colspan="2">'.$langs->trans("ThisIsInformationOnPayment").' :</td></tr>'."\n";
$found=false;
$error=0;
$var=false;
// Free payment
if (! GETPOST("source") && $valid)
{
$found=true;
$tag=GETPOST("tag");
$fulltag=$tag;
// Creditor
$var=!$var;
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Creditor");
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$creditor.'</b>';
print '<input type="hidden" name="creditor" value="'.$creditor.'">';
print '</td></tr>'."\n";
// Amount
$var=!$var;
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Amount");
if (empty($amount)) print ' ('.$langs->trans("ToComplete").')';
print '</td><td class="CTableRow'.($var?'1':'2').'">';
if (empty($amount) || ! is_numeric($amount))
{
print '<input type="hidden" name="amount" value="'.GETPOST("amount",'int').'">';
print '<input class="flat" size=8 type="text" name="newamount" value="'.GETPOST("newamount","int").'">';
}
else {
print '<b>'.price($amount).'</b>';
print '<input type="hidden" name="amount" value="'.$amount.'">';
print '<input type="hidden" name="newamount" value="'.$amount.'">';
}
// Currency
print ' <b>'.$langs->trans("Currency".$currency).'</b>';
print '<input type="hidden" name="currency" value="'.$currency.'">';
print '</td></tr>'."\n";
// Tag
$var=!$var;
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("PaymentCode");
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$fulltag.'</b>';
print '<input type="hidden" name="tag" value="'.$tag.'">';
print '<input type="hidden" name="fulltag" value="'.$fulltag.'">';
print '</td></tr>'."\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 '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Creditor");
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$creditor.'</b>';
print '<input type="hidden" name="creditor" value="'.$creditor.'">';
print '</td></tr>'."\n";
// Debitor
$var=!$var;
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("ThirdParty");
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$order->thirdparty->name.'</b>';
// Object
$var=!$var;
$text='<b>'.$langs->trans("PaymentOrderRef",$order->ref).'</b>';
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Designation");
print '</td><td class="CTableRow'.($var?'1':'2').'">'.$text;
print '<input type="hidden" name="source" value="'.GETPOST("source",'alpha').'">';
print '<input type="hidden" name="ref" value="'.$order->ref.'">';
print '</td></tr>'."\n";
// Amount
$var=!$var;
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Amount");
if (empty($amount)) print ' ('.$langs->trans("ToComplete").')';
print '</td><td class="CTableRow'.($var?'1':'2').'">';
if (empty($amount) || ! is_numeric($amount))
{
print '<input type="hidden" name="amount" value="'.GETPOST("amount",'int').'">';
print '<input class="flat" size=8 type="text" name="newamount" value="'.GETPOST("newamount","int").'">';
}
else {
print '<b>'.price($amount).'</b>';
print '<input type="hidden" name="amount" value="'.$amount.'">';
print '<input type="hidden" name="newamount" value="'.$amount.'">';
}
// Currency
print ' <b>'.$langs->trans("Currency".$currency).'</b>';
print '<input type="hidden" name="currency" value="'.$currency.'">';
print '</td></tr>'."\n";
// Tag
$var=!$var;
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("PaymentCode");
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$fulltag.'</b>';
print '<input type="hidden" name="tag" value="'.$tag.'">';
print '<input type="hidden" name="fulltag" value="'.$fulltag.'">';
print '</td></tr>'."\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 '<input type="hidden" name="shipToName" value="'.$shipToName.'">'."\n";
print '<input type="hidden" name="shipToStreet" value="'.$shipToStreet.'">'."\n";
print '<input type="hidden" name="shipToCity" value="'.$shipToCity.'">'."\n";
print '<input type="hidden" name="shipToState" value="'.$shipToState.'">'."\n";
print '<input type="hidden" name="shipToCountryCode" value="'.$shipToCountryCode.'">'."\n";
print '<input type="hidden" name="shipToZip" value="'.$shipToZip.'">'."\n";
print '<input type="hidden" name="shipToStreet2" value="'.$shipToStreet2.'">'."\n";
print '<input type="hidden" name="phoneNum" value="'.$phoneNum.'">'."\n";
}
else
{
print '<!-- Shipping address not complete, so we don t use it -->'."\n";
}
print '<input type="hidden" name="email" value="'.$order->thirdparty->email.'">'."\n";
print '<input type="hidden" name="desc" value="'.$langs->trans("Order").' '.$order->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 '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Creditor");
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$creditor.'</b>';
print '<input type="hidden" name="creditor" value="'.$creditor.'">';
print '</td></tr>'."\n";
// Debitor
$var=!$var;
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("ThirdParty");
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$invoice->thirdparty->name.'</b>';
// Object
$var=!$var;
$text='<b>'.$langs->trans("PaymentInvoiceRef",$invoice->ref).'</b>';
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Designation");
print '</td><td class="CTableRow'.($var?'1':'2').'">'.$text;
print '<input type="hidden" name="source" value="'.GETPOST("source",'alpha').'">';
print '<input type="hidden" name="ref" value="'.$invoice->ref.'">';
print '</td></tr>'."\n";
// Amount
$var=!$var;
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Amount");
if (empty($amount)) print ' ('.$langs->trans("ToComplete").')';
print '</td><td class="CTableRow'.($var?'1':'2').'">';
if (empty($amount) || ! is_numeric($amount))
{
print '<input type="hidden" name="amount" value="'.GETPOST("amount",'int').'">';
print '<input class="flat" size=8 type="text" name="newamount" value="'.GETPOST("newamount","int").'">';
}
else {
print '<b>'.price($amount).'</b>';
print '<input type="hidden" name="amount" value="'.$amount.'">';
print '<input type="hidden" name="newamount" value="'.$amount.'">';
}
// Currency
print ' <b>'.$langs->trans("Currency".$currency).'</b>';
print '<input type="hidden" name="currency" value="'.$currency.'">';
print '</td></tr>'."\n";
// Tag
$var=!$var;
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("PaymentCode");
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$fulltag.'</b>';
print '<input type="hidden" name="tag" value="'.$tag.'">';
print '<input type="hidden" name="fulltag" value="'.$fulltag.'">';
print '</td></tr>'."\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 '<input type="hidden" name="shipToName" value="'.$shipToName.'">'."\n";
print '<input type="hidden" name="shipToStreet" value="'.$shipToStreet.'">'."\n";
print '<input type="hidden" name="shipToCity" value="'.$shipToCity.'">'."\n";
print '<input type="hidden" name="shipToState" value="'.$shipToState.'">'."\n";
print '<input type="hidden" name="shipToCountryCode" value="'.$shipToCountryCode.'">'."\n";
print '<input type="hidden" name="shipToZip" value="'.$shipToZip.'">'."\n";
print '<input type="hidden" name="shipToStreet2" value="'.$shipToStreet2.'">'."\n";
print '<input type="hidden" name="phoneNum" value="'.$phoneNum.'">'."\n";
}
else
{
print '<!-- Shipping address not complete, so we don t use it -->'."\n";
}
print '<input type="hidden" name="email" value="'.$invoice->thirdparty->email.'">'."\n";
print '<input type="hidden" name="desc" value="'.$langs->trans("Invoice").' '.$invoice->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 '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Creditor");
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$creditor.'</b>';
print '<input type="hidden" name="creditor" value="'.$creditor.'">';
print '</td></tr>'."\n";
// Debitor
$var=!$var;
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("ThirdParty");
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$contract->thirdparty->name.'</b>';
// Object
$var=!$var;
$text='<b>'.$langs->trans("PaymentRenewContractId",$contract->ref,$contractline->ref).'</b>';
if ($contractline->fk_product)
{
$text.='<br>'.$product->ref.($product->label?' - '.$product->label:'');
}
if ($contractline->description) $text.='<br>'.dol_htmlentitiesbr($contractline->description);
//if ($contractline->date_fin_validite) {
// $text.='<br>'.$langs->trans("DateEndPlanned").': ';
// $text.=dol_print_date($contractline->date_fin_validite);
//}
if ($contractline->date_fin_validite)
{
$text.='<br>'.$langs->trans("ExpiredSince").': '.dol_print_date($contractline->date_fin_validite);
}
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Designation");
print '</td><td class="CTableRow'.($var?'1':'2').'">'.$text;
print '<input type="hidden" name="source" value="'.GETPOST("source",'alpha').'">';
print '<input type="hidden" name="ref" value="'.$contractline->ref.'">';
print '</td></tr>'."\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 '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$label.'</td>';
print '<td class="CTableRow'.($var?'1':'2').'"><b>'.($duration?$duration:$qty).'</b>';
print '<input type="hidden" name="newqty" value="'.dol_escape_htmltag($qty).'">';
print '</b></td></tr>'."\n";
// Amount
$var=!$var;
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Amount");
if (empty($amount)) print ' ('.$langs->trans("ToComplete").')';
print '</td><td class="CTableRow'.($var?'1':'2').'">';
if (empty($amount) || ! is_numeric($amount))
{
print '<input type="hidden" name="amount" value="'.GETPOST("amount",'int').'">';
print '<input class="flat" size=8 type="text" name="newamount" value="'.GETPOST("newamount","int").'">';
}
else {
print '<b>'.price($amount).'</b>';
print '<input type="hidden" name="amount" value="'.$amount.'">';
print '<input type="hidden" name="newamount" value="'.$amount.'">';
}
// Currency
print ' <b>'.$langs->trans("Currency".$currency).'</b>';
print '<input type="hidden" name="currency" value="'.$currency.'">';
print '</td></tr>'."\n";
// Tag
$var=!$var;
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("PaymentCode");
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$fulltag.'</b>';
print '<input type="hidden" name="tag" value="'.$tag.'">';
print '<input type="hidden" name="fulltag" value="'.$fulltag.'">';
print '</td></tr>'."\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 '<input type="hidden" name="shipToName" value="'.$shipToName.'">'."\n";
print '<input type="hidden" name="shipToStreet" value="'.$shipToStreet.'">'."\n";
print '<input type="hidden" name="shipToCity" value="'.$shipToCity.'">'."\n";
print '<input type="hidden" name="shipToState" value="'.$shipToState.'">'."\n";
print '<input type="hidden" name="shipToCountryCode" value="'.$shipToCountryCode.'">'."\n";
print '<input type="hidden" name="shipToZip" value="'.$shipToZip.'">'."\n";
print '<input type="hidden" name="shipToStreet2" value="'.$shipToStreet2.'">'."\n";
print '<input type="hidden" name="phoneNum" value="'.$phoneNum.'">'."\n";
}
else
{
print '<!-- Shipping address not complete, so we don t use it -->'."\n";
}
print '<input type="hidden" name="email" value="'.$contract->thirdparty->email.'">'."\n";
print '<input type="hidden" name="desc" value="'.$langs->trans("Contract").' '.$contract->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 '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Creditor");
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$creditor.'</b>';
print '<input type="hidden" name="creditor" value="'.$creditor.'">';
print '</td></tr>'."\n";
// Debitor
$var=!$var;
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Member");
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>';
if ($member->morphy == 'mor' && ! empty($member->societe)) print $member->societe;
else print $member->getFullName($langs);
print '</b>';
// Object
$var=!$var;
$text='<b>'.$langs->trans("PaymentSubscription").'</b>';
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Designation");
print '</td><td class="CTableRow'.($var?'1':'2').'">'.$text;
print '<input type="hidden" name="source" value="'.GETPOST("source",'alpha').'">';
print '<input type="hidden" name="ref" value="'.$member->ref.'">';
print '</td></tr>'."\n";
if ($member->last_subscription_date || $member->last_subscription_amount)
{
// Last subscription date
$var=!$var;
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("LastSubscriptionDate");
print '</td><td class="CTableRow'.($var?'1':'2').'">'.dol_print_date($member->last_subscription_date,'day');
print '</td></tr>'."\n";
// Last subscription amount
$var=!$var;
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("LastSubscriptionAmount");
print '</td><td class="CTableRow'.($var?'1':'2').'">'.price($member->last_subscription_amount);
print '</td></tr>'."\n";
if (empty($amount) && ! GETPOST('newamount')) $_GET['newamount']=$member->last_subscription_amount;
}
// Amount
$var=!$var;
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Amount");
if (empty($amount))
{
print ' ('.$langs->trans("ToComplete");
if (! empty($conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO)) print ' - <a href="'.$conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO.'" rel="external" target="_blank">'.$langs->trans("SeeHere").'</a>';
print ')';
}
print '</td><td class="CTableRow'.($var?'1':'2').'">';
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 '<input type="hidden" name="amount" value="'.GETPOST("amount",'int').'">';
print '<input class="flat" size="8" type="text" name="newamount" value="'.$valtoshow.'">';
}
else {
$valtoshow=$amount;
if (! empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) $valtoshow=max($conf->global->MEMBER_MIN_AMOUNT,$valtoshow);
print '<b>'.price($valtoshow).'</b>';
print '<input type="hidden" name="amount" value="'.$valtoshow.'">';
print '<input type="hidden" name="newamount" value="'.$valtoshow.'">';
}
// Currency
print ' <b>'.$langs->trans("Currency".$currency).'</b>';
print '<input type="hidden" name="currency" value="'.$currency.'">';
print '</td></tr>'."\n";
// Tag
$var=!$var;
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("PaymentCode");
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$fulltag.'</b>';
print '<input type="hidden" name="tag" value="'.$tag.'">';
print '<input type="hidden" name="fulltag" value="'.$fulltag.'">';
print '</td></tr>'."\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 '<input type="hidden" name="shipToName" value="'.$shipToName.'">'."\n";
print '<input type="hidden" name="shipToStreet" value="'.$shipToStreet.'">'."\n";
print '<input type="hidden" name="shipToCity" value="'.$shipToCity.'">'."\n";
print '<input type="hidden" name="shipToState" value="'.$shipToState.'">'."\n";
print '<input type="hidden" name="shipToCountryCode" value="'.$shipToCountryCode.'">'."\n";
print '<input type="hidden" name="shipToZip" value="'.$shipToZip.'">'."\n";
print '<input type="hidden" name="shipToStreet2" value="'.$shipToStreet2.'">'."\n";
print '<input type="hidden" name="phoneNum" value="'.$phoneNum.'">'."\n";
}
else
{
print '<!-- Shipping address not complete, so we don t use it -->'."\n";
}
print '<input type="hidden" name="email" value="'.$member->email.'">'."\n";
print '<input type="hidden" name="desc" value="'.$langs->trans("PaymentSubscription").'">'."\n";
}
if (! $found && ! $mesg) $mesg=$langs->trans("ErrorBadParameters");
if ($mesg) print '<tr><td align="center" colspan="2"><br><div class="warning">'.$mesg.'</div></td></tr>'."\n";
print '</table>'."\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 '<br><input class="button" type="submit" name="dopayment" value="'.$langs->trans("StripeOrCBDoPayment").'">';
}
if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'stripeonly')
{
print '<br><input class="button" type="submit" name="dopayment" value="'.$langs->trans("StripeDoPayment").'">';
}
}
else
{
dol_print_error_email('ERRORNEWPAYMENTPAYPAL');
}
print '</td></tr>'."\n";
print '</table>'."\n";
print '</form>'."\n";
print '</div>'."\n";
print '<br>';
html_print_stripe_footer($mysoc,$langs);
llxFooterStripe();
$db->close();

View File

@ -0,0 +1,115 @@
<?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2013 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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 <http://www.gnu.org/licenses/>.
*/
/**
* \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 '<span id="dolpaymentspan"></span>'."\n";
print '<div id="dolpaymentdiv" align="center">'."\n";
print $langs->trans("YourPaymentHasNotBeenRecorded")."<br><br>\n";
if (! empty($conf->global->PAYBOX_MESSAGE_KO)) print $conf->global->PAYBOX_MESSAGE_KO;
print "\n</div>\n";
html_print_paybox_footer($mysoc,$langs);
llxFooterPayBox();
$db->close();

View File

@ -0,0 +1,172 @@
<?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2013 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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 <http://www.gnu.org/licenses/>.
*/
/**
* \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 '<span id="dolpaymentspan"></span>'."\n";
print '<div id="dolpaymentdiv" align="center">'."\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")."<br><br>\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")."<br>\n";
$content.=$langs->trans("MemberId").': '.$tmptag['MEM']."<br>\n";
$content.=$langs->trans("Link").': <a href="'.$url.'">'.$url.'</a>'."<br>\n";
}
else
{
$content.=$langs->transnoentitiesnoconv("NewPayboxPaymentReceived")."<br>\n";
}
$content.="<br>\n";
$content.=$langs->transnoentitiesnoconv("TechnicalInformation").":<br>\n";
$content.=$langs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."<br>\n";
$content.="tag=".$fulltag."<br>\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</div>\n";
html_print_paybox_footer($mysoc,$langs);
llxFooterPayBox();
$db->close();

View File

View File

@ -0,0 +1,225 @@
<?php
/* Copyright (C) 2017 Alexandre Spangaro <aspangaro@zendsi.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
/**
* \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='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("ModuleSetup").' Stripe',$linkback);
print '<br>';
$head=stripeadmin_prepare_head();
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setvalue">';
dol_fiche_head($head, 'stripeaccount', '');
print $langs->trans("StripeDesc")."<br>\n";
print '<br>';
$var=true;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("AccountParameter").'</td>';
print '<td>'.$langs->trans("Value").'</td>';
print "</tr>\n";
$var=!$var;
print '<tr '.$bc[$var].'><td class="fieldrequired">';
print $langs->trans("STRIPE_API_SANDBOX").'</td><td>';
print $form->selectyesno("STRIPE_API_SANDBOX",$conf->global->STRIPE_API_SANDBOX,1);
print '</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td>';
print '<span class="titlefield fieldrequired">'.$langs->trans("STRIPE_TEST_SECRET_KEY").'</span></td><td>';
print '<input size="32" type="text" name="STRIPE_TEST_SECRET_KEY" value="'.$conf->global->STRIPE_TEST_SECRET_KEY.'">';
print '<br>'.$langs->trans("Example").': sk_test_xxxxxxxxxxxxxxxxxxxxxxxx';
print '</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td>';
print '<span class="fieldrequired">'.$langs->trans("STRIPE_TEST_PUBLISHABLE_KEY").'</span></td><td>';
print '<input size="32" type="text" name="STRIPE_TEST_PUBLISHABLE_KEY" value="'.$conf->global->STRIPE_TEST_PUBLISHABLE_KEY.'">';
print '<br>'.$langs->trans("Example").': pk_test_xxxxxxxxxxxxxxxxxxxxxxxx';
print '</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td>';
print '<span class="fieldrequired">'.$langs->trans("STRIPE_LIVE_SECRET_KEY").'</span></td><td>';
print '<input size="32" type="text" name="STRIPE_LIVE_SECRET_KEY" value="'.$conf->global->STRIPE_LIVE_SECRET_KEY.'">';
print '<br>'.$langs->trans("Example").': sk_live_xxxxxxxxxxxxxxxxxxxxxxxx';
print '</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td>';
print '<span class="fieldrequired">'.$langs->trans("STRIPE_LIVE_PUBLISHABLE_KEY").'</span></td><td>';
print '<input size="32" type="text" name="STRIPE_LIVE_PUBLISHABLE_KEY" value="'.$conf->global->STRIPE_LIVE_PUBLISHABLE_KEY.'">';
print '<br>'.$langs->trans("Example").': pk_live_xxxxxxxxxxxxxxxxxxxxxxxx';
print '</td></tr>';
$var=true;
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("UsageParameter").'</td>';
print '<td>'.$langs->trans("Value").'</td>';
print "</tr>\n";
$var=!$var;
print '<tr '.$bc[$var].'><td>';
print $langs->trans("VendorName").'</td><td>';
print '<input size="64" type="text" name="STRIPE_CREDITOR" value="'.$conf->global->STRIPE_CREDITOR.'">';
print '<br>'.$langs->trans("Example").': '.$mysoc->name;
print '</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td>';
print $langs->trans("CSSUrlForPaymentForm").'</td><td>';
print '<input size="64" type="text" name="STRIPE_CSS_URL" value="'.$conf->global->STRIPE_CSS_URL.'">';
print '<br>'.$langs->trans("Example").': http://mysite/mycss.css';
print '</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td>';
print $langs->trans("MessageOK").'</td><td>';
$doleditor=new DolEditor('STRIPE_MESSAGE_OK',$conf->global->STRIPE_MESSAGE_OK,'',100,'dolibarr_details','In',false,true,true,ROWS_2,60);
$doleditor->Create();
print '</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td>';
print $langs->trans("MessageKO").'</td><td>';
$doleditor=new DolEditor('STRIPE_MESSAGE_KO',$conf->global->STRIPE_MESSAGE_KO,'',100,'dolibarr_details','In',false,true,true,ROWS_2,60);
$doleditor->Create();
print '</td></tr>';
print '</table>';
dol_fiche_end();
print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></div>';
print '</form>';
print '<br><br>';
print '<u>'.$langs->trans("FollowingUrlAreAvailableToMakePayments").':</u><br>';
print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnFreeAmount",$servicename).':<br>';
print '<b>'.DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?amount=<i>9.99</i>&tag=<i>your_free_tag</i></b>'."<br>\n";
if (! empty($conf->commande->enabled))
{
print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnOrder",$servicename).':<br>';
print '<b>'.DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?source=order&ref=<i>order_ref</i></b>'."<br>\n";
}
if (! empty($conf->facture->enabled))
{
print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnInvoice",$servicename).':<br>';
print '<b>'.DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?source=invoice&ref=<i>invoice_ref</i></b>'."<br>\n";
}
if (! empty($conf->contrat->enabled))
{
print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnContractLine",$servicename).':<br>';
print '<b>'.DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?source=contractline&ref=<i>contractline_ref</i></b>'."<br>\n";
}
if (! empty($conf->adherent->enabled))
{
print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnMemberSubscription",$servicename).':<br>';
print '<b>'.DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?source=membersubscription&ref=<i>member_ref</i></b>'."<br>\n";
}
print "<br>";
print info_admin($langs->trans("YouCanAddTagOnUrl"));
llxFooter();
$db->close();

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 819 B

0
htdocs/stripe/index.html Normal file
View File

View File

View File

@ -0,0 +1,445 @@
<?php
/* Copyright (C) 2017 Alexandre Spangaro <aspangaro@zendsi.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
/**
* \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 '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
//print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd>';
print "\n";
print "<html>\n";
print "<head>\n";
print '<meta name="robots" content="noindex,nofollow">'."\n";
print '<meta name="keywords" content="dolibarr,payment,online">'."\n";
print '<meta name="description" content="Welcome on Dolibarr online payment form">'."\n";
print "<title>".$title."</title>\n";
if ($head) print $head."\n";
if (! empty($conf->global->STRIPE_CSS_URL)) print '<link rel="stylesheet" type="text/css" href="'.$conf->global->STRIPE_CSS_URL.'?lang='.$langs->defaultlang.'">'."\n";
else
{
print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.$conf->css.'?lang='.$langs->defaultlang.'">'."\n";
print '<style type="text/css">';
print '.CTableRow1 { margin: 1px; padding: 3px; font: 12px verdana,arial; background: #e6E6eE; color: #000000; -moz-border-radius-topleft:6px; -moz-border-radius-topright:6px; -moz-border-radius-bottomleft:6px; -moz-border-radius-bottomright:6px;}';
print '.CTableRow2 { margin: 1px; padding: 3px; font: 12px verdana,arial; background: #FFFFFF; color: #000000; -moz-border-radius-topleft:6px; -moz-border-radius-topright:6px; -moz-border-radius-bottomleft:6px; -moz-border-radius-bottomright:6px;}';
print '</style>';
}
print "</head>\n";
print '<body style="margin: 20px;">'."\n";
}
/**
* Show footer
*
* @return void
*/
function llxFooterStripe()
{
print "</body>\n";
print "</html>\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='<br><br>';
$out.=img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePayment",$servicename).'<br>';
$url=getStripePaymentUrl(0,$type,$ref);
$out.='<input type="text" id="stripeurl" class="quatrevingtpercent" value="'.$url.'"><br>';
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?'<font color="#666666">':'').$amount.($mode?'</font>':'').'&tag='.($mode?'<font color="#666666">':'').$freetag.($mode?'</font>':'');
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?'<font color="#666666">':'');
if ($mode == 1) $out.='order_ref';
if ($mode == 0) $out.=urlencode($ref);
$out.=($mode?'</font>':'');
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?'<font color="#666666">':'');
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?'</font>':'');
}
}
}
if ($type == 'invoice')
{
$out=DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?source=invoice&ref='.($mode?'<font color="#666666">':'');
if ($mode == 1) $out.='invoice_ref';
if ($mode == 0) $out.=urlencode($ref);
$out.=($mode?'</font>':'');
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?'<font color="#666666">':'');
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?'</font>':'');
}
}
}
if ($type == 'contractline')
{
$out=DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?source=contractline&ref='.($mode?'<font color="#666666">':'');
if ($mode == 1) $out.='contractline_ref';
if ($mode == 0) $out.=urlencode($ref);
$out.=($mode?'</font>':'');
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?'<font color="#666666">':'');
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?'</font>':'');
}
}
}
if ($type == 'membersubscription')
{
$out=DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?source=membersubscription&ref='.($mode?'<font color="#666666">':'');
if ($mode == 1) $out.='member_ref';
if ($mode == 0) $out.=urlencode($ref);
$out.=($mode?'</font>':'');
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?'<font color="#666666">':'');
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?'</font>':'');
}
}
}
// 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 '<html>'."\n";
print '<head>'."\n";
print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=".$conf->file->character_set_client."\">\n";
print '</head>'."\n";
print '<body>'."\n";
print "\n";
// Formulaire pour module Paybox
print '<form action="'.$URLPAYBOX.'" NAME="Submit" method="POST">'."\n";
// For Paybox V2 (PBX_xxx)
print '<!-- Param for Paybox v2 -->'."\n";
print '<input type="hidden" name="PBX_IDENTIFIANT" value="'.$PBX_IDENTIFIANT.'">'."\n";
print '<input type="hidden" name="PBX_MODE" value="'.$IBS_MODE.'">'."\n";
print '<input type="hidden" name="PBX_SITE" value="'.$IBS_SITE.'">'."\n";
print '<input type="hidden" name="PBX_RANG" value="'.$IBS_RANG.'">'."\n";
print '<input type="hidden" name="PBX_TOTAL" value="'.$IBS_TOTAL.'">'."\n";
print '<input type="hidden" name="PBX_DEVISE" value="'.$IBS_DEVISE.'">'."\n";
print '<input type="hidden" name="PBX_CMD" value="'.$IBS_CMD.'">'."\n";
print '<input type="hidden" name="PBX_PORTEUR" value="'.$IBS_PORTEUR.'">'."\n";
print '<input type="hidden" name="PBX_RETOUR" value="'.$IBS_RETOUR.'">'."\n";
print '<input type="hidden" name="PBX_EFFECTUE" value="'.$IBS_EFFECTUE.'">'."\n";
print '<input type="hidden" name="PBX_ANNULE" value="'.$IBS_ANNULE.'">'."\n";
print '<input type="hidden" name="PBX_REFUSE" value="'.$IBS_REFUSE.'">'."\n";
print '<input type="hidden" name="PBX_TXT" value="'.$IBS_TXT.'">'."\n";
print '<input type="hidden" name="PBX_BKGD" value="'.$IBS_BKGD.'">'."\n";
print '<input type="hidden" name="PBX_WAIT" value="'.$IBS_WAIT.'">'."\n";
print '<input type="hidden" name="PBX_LANGUE" value="'.$IBS_LANG.'">'."\n";
print '<input type="hidden" name="PBX_OUTPUT" value="'.$IBS_OUTPUT.'">'."\n";
print '<input type="hidden" name="PBX_SOURCE" value="'.$PBX_SOURCE.'">'."\n";
print '<input type="hidden" name="PBX_TYPEPAIEMENT" value="'.$PBX_TYPEPAIEMENT.'">'."\n";
print '</form>'."\n";
print "\n";
print '<script type="text/javascript" language="javascript">'."\n";
print ' document.Submit.submit();'."\n";
print '</script>'."\n";
print "\n";
print '</body></html>'."\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 '<br><br><hr>'."\n";
print '<div class="center"><font style="font-size: 10px;">'."\n";
print $fromcompany->name.'<br>';
print $line1.'<br>';
print $line2;
print '</font></div>'."\n";
}

View File

@ -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)

View File

@ -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)