From 47089a4d550517aef1a166848151f9996cac641e Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 29 Apr 2017 07:04:34 +0200 Subject: [PATCH] Modle Stripe : Work in progress --- htdocs/core/lib/stripe.lib.php | 147 ---- htdocs/{ => public}/stripe/checkout.php | 31 +- htdocs/{ => public}/stripe/config.php | 6 +- htdocs/public/stripe/newpayment.php | 977 ------------------------ htdocs/public/stripe/paymentko.php | 115 --- htdocs/public/stripe/paymentok.php | 172 ----- htdocs/stripe/admin/stripe.php | 22 +- 7 files changed, 27 insertions(+), 1443 deletions(-) rename htdocs/{ => public}/stripe/checkout.php (94%) rename htdocs/{ => public}/stripe/config.php (88%) delete mode 100644 htdocs/public/stripe/newpayment.php delete mode 100644 htdocs/public/stripe/paymentko.php delete mode 100644 htdocs/public/stripe/paymentok.php diff --git a/htdocs/core/lib/stripe.lib.php b/htdocs/core/lib/stripe.lib.php index d2d138cc8b3..175df3554ce 100644 --- a/htdocs/core/lib/stripe.lib.php +++ b/htdocs/core/lib/stripe.lib.php @@ -229,153 +229,6 @@ function getStripePaymentUrl($mode,$type,$ref='',$amount='9.99',$freetag='your_f } -/** - * 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 * diff --git a/htdocs/stripe/checkout.php b/htdocs/public/stripe/checkout.php similarity index 94% rename from htdocs/stripe/checkout.php rename to htdocs/public/stripe/checkout.php index f7f547afae9..4bea80bce6c 100644 --- a/htdocs/stripe/checkout.php +++ b/htdocs/public/stripe/checkout.php @@ -16,15 +16,17 @@ * along with this program. If not, see . */ -require '../main.inc.php'; - -// Load Dolibarr environment -require_once DOL_DOCUMENT_ROOT.'/stripe/config.php'); -require_once DOL_DOCUMENT_ROOT.'/includes/stripe/init.php'); - define("NOLOGIN",1); define("NOCSRFCHECK",1); +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/stripe.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/public/stripe/config.php'; +require_once DOL_DOCUMENT_ROOT.'/includes/stripe/init.php'; + +// Security check +if (empty($conf->paypal->enabled)) accessforbidden('',0,0,1); + $langs->load("main"); $langs->load("other"); $langs->load("stripe"); @@ -34,19 +36,6 @@ $ref=GETPOST('ref','alpha'); $form = new Form($db); -/** - * Header empty - * - * @return void - */ -function llxHeader() {} -/** - * Footer empty - * - * @return void - */ -function llxFooter() {} - $invoice = null; // Payment on customer invoice @@ -68,8 +57,6 @@ if ($source == 'invoice') { $result=$invoice->fetch_thirdparty($invoice->socid); } - - } $pay = false; @@ -225,7 +212,7 @@ if (GETPOST("action") == 'charge') - + diff --git a/htdocs/stripe/config.php b/htdocs/public/stripe/config.php similarity index 88% rename from htdocs/stripe/config.php rename to htdocs/public/stripe/config.php index 78d394feb53..ac315762b29 100644 --- a/htdocs/stripe/config.php +++ b/htdocs/public/stripe/config.php @@ -22,11 +22,11 @@ * \brief Page to move config in api */ -require '../main.inc.php'; +require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -dol_include_once('/stripe/lib/stripe.lib.php'); -require_once DOL_DOCUMENT_ROOT.'/includes/stripe/init.php'); +require_once DOL_DOCUMENT_ROOT.'/core/lib/stripe.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/includes/stripe/init.php'; //use \includes\stripe as stripe; $stripe = array( diff --git a/htdocs/public/stripe/newpayment.php b/htdocs/public/stripe/newpayment.php deleted file mode 100644 index 33499fe7098..00000000000 --- a/htdocs/public/stripe/newpayment.php +++ /dev/null @@ -1,977 +0,0 @@ - - * 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 deleted file mode 100644 index 09de4525b39..00000000000 --- a/htdocs/public/stripe/paymentko.php +++ /dev/null @@ -1,115 +0,0 @@ - - * 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 deleted file mode 100644 index 9c3030a86ba..00000000000 --- a/htdocs/public/stripe/paymentok.php +++ /dev/null @@ -1,172 +0,0 @@ - - * 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/stripe.php b/htdocs/stripe/admin/stripe.php index 719c623e146..4da06e61de8 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -23,7 +23,7 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/stripe/lib/stripe.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/stripe.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -31,6 +31,8 @@ $servicename='Stripe'; $langs->load("admin"); $langs->load("other"); +$langs->load("paypal"); +$langs->load("paybox"); $langs->load("stripe"); if (!$user->admin) @@ -43,7 +45,7 @@ if ($action == 'setvalue' && $user->admin) { $db->begin(); - $result=dolibarr_set_const($db, "STRIPE_API_SANDBOX",GETPOST('STRIPE_API_SANDBOX','alpha'),'chaine',0,'',$conf->entity); + $result=dolibarr_set_const($db, "STRIPE_TEST",GETPOST('STRIPE_TEST','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++; @@ -118,8 +120,8 @@ print "\n"; $var=!$var; print ''; -print $langs->trans("STRIPE_API_SANDBOX").''; -print $form->selectyesno("STRIPE_API_SANDBOX",$conf->global->STRIPE_API_SANDBOX,1); +print $langs->trans("STRIPE_TEST").''; +print $form->selectyesno("STRIPE_TEST",$conf->global->STRIPE_TEST,1); print ''; $var=!$var; @@ -150,7 +152,11 @@ print ''; -$var=true; +print ''; + +print '
'; + +print ''; print ''; print ''; print ''; @@ -173,14 +179,14 @@ print ''; $var=!$var; print ''; $var=!$var; print ''; @@ -194,6 +200,7 @@ 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"; @@ -220,6 +227,7 @@ if (! empty($conf->adherent->enabled)) print "
"; print info_admin($langs->trans("YouCanAddTagOnUrl")); +*/ llxFooter();
'.$langs->trans("UsageParameter").''.$langs->trans("Value").'
'; 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=new DolEditor('STRIPE_MESSAGE_OK',$conf->global->STRIPE_MESSAGE_OK,'',100,'dolibarr_details','In',false,true,true,ROWS_2,'90%'); $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=new DolEditor('STRIPE_MESSAGE_KO',$conf->global->STRIPE_MESSAGE_KO,'',100,'dolibarr_details','In',false,true,true,ROWS_2,'90%'); $doleditor->Create(); print '