Skip to content

Commit

Permalink
Standardize code for payment
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed May 13, 2017
1 parent 8dcec30 commit 0ed4b60
Show file tree
Hide file tree
Showing 8 changed files with 195 additions and 47 deletions.
1 change: 1 addition & 0 deletions htdocs/paypal/admin/paypal.php
Expand Up @@ -43,6 +43,7 @@
if ($action == 'setvalue' && $user->admin)
{
$db->begin();

$result=dolibarr_set_const($db, "PAYPAL_API_SANDBOX",GETPOST('PAYPAL_API_SANDBOX','alpha'),'chaine',0,'',$conf->entity);
if (! $result > 0) $error++;
$result=dolibarr_set_const($db, "PAYPAL_API_USER",GETPOST('PAYPAL_API_USER','alpha'),'chaine',0,'',$conf->entity);
Expand Down
15 changes: 14 additions & 1 deletion htdocs/public/paybox/paymentko.php
Expand Up @@ -86,8 +86,21 @@
$sendto=$conf->global->PAYBOX_PAYONLINE_SENDEMAIL;
$from=$conf->global->MAILING_EMAIL_FROM;

// Define link to login card
$appli=constant('DOL_APPLICATION_TITLE');
if (! empty($conf->global->MAIN_APPLICATION_TITLE))
{
$appli=$conf->global->MAIN_APPLICATION_TITLE;
if (preg_match('/\d\.\d/', $appli))
{
if (! preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli.=" (".DOL_VERSION.")"; // If new title contains a version that is different than core
}
else $appli.=" ".DOL_VERSION;
}
else $appli.=" ".DOL_VERSION;

$urlback=$_SERVER["REQUEST_URI"];
$topic='['.$conf->global->MAIN_APPLICATION_TITLE.'] '.$langs->transnoentitiesnoconv("NewPayboxPaymentFailed");
$topic='['.$appli.'] '.$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);
Expand Down
15 changes: 14 additions & 1 deletion htdocs/public/paybox/paymentok.php
Expand Up @@ -135,8 +135,21 @@
$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

// Define link to login card
$appli=constant('DOL_APPLICATION_TITLE');
if (! empty($conf->global->MAIN_APPLICATION_TITLE))
{
$appli=$conf->global->MAIN_APPLICATION_TITLE;
if (preg_match('/\d\.\d/', $appli))
{
if (! preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli.=" (".DOL_VERSION.")"; // If new title contains a version that is different than core
}
else $appli.=" ".DOL_VERSION;
}
else $appli.=" ".DOL_VERSION;

$urlback=$_SERVER["REQUEST_URI"];
$topic='['.$conf->global->MAIN_APPLICATION_TITLE.'] '.$langs->transnoentitiesnoconv("NewPayboxPaymentReceived");
$topic='['.$appli.'] '.$langs->transnoentitiesnoconv("NewPayboxPaymentReceived");
$tmptag=dolExplodeIntoArray($fulltag,'.','=');
$content="";
if (! empty($tmptag['MEM']))
Expand Down
17 changes: 8 additions & 9 deletions htdocs/public/paypal/newpayment.php
@@ -1,11 +1,11 @@
<?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006-2017 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
* 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
* 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,
Expand All @@ -23,7 +23,6 @@
* \file htdocs/public/paypal/newpayment.php
* \ingroup paypal
* \brief File to offer a way to make a payment for a particular Dolibarr entity
* \author Laurent Destailleur
*/

define("NOLOGIN",1); // This means this output page does not require to be logged.
Expand Down Expand Up @@ -353,7 +352,7 @@
$var=false;

// Free payment
if (! GETPOST("source") && $valid)
if (! GETPOST("source"))
{
$found=true;
$tag=GETPOST("tag");
Expand Down Expand Up @@ -400,7 +399,7 @@


// Payment on customer order
if (GETPOST("source") == 'order' && $valid)
if (GETPOST("source") == 'order')
{
$found=true;
$langs->load("orders");
Expand Down Expand Up @@ -507,7 +506,7 @@


// Payment on customer invoice
if (GETPOST("source") == 'invoice' && $valid)
if (GETPOST("source") == 'invoice')
{
$found=true;
$langs->load("bills");
Expand Down Expand Up @@ -613,7 +612,7 @@
}

// Payment on contract line
if (GETPOST("source") == 'contractline' && $valid)
if (GETPOST("source") == 'contractline')
{
$found=true;
$langs->load("contracts");
Expand Down Expand Up @@ -808,7 +807,7 @@
}

// Payment on member subscription
if (GETPOST("source") == 'membersubscription' && $valid)
if (GETPOST("source") == 'membersubscription')
{
$found=true;
$langs->load("members");
Expand Down
15 changes: 14 additions & 1 deletion htdocs/public/paypal/paymentko.php
Expand Up @@ -108,8 +108,21 @@
$sendto=$conf->global->PAYPAL_PAYONLINE_SENDEMAIL;
$from=$conf->global->MAILING_EMAIL_FROM;

// Define link to login card
$appli=constant('DOL_APPLICATION_TITLE');
if (! empty($conf->global->MAIN_APPLICATION_TITLE))
{
$appli=$conf->global->MAIN_APPLICATION_TITLE;
if (preg_match('/\d\.\d/', $appli))
{
if (! preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli.=" (".DOL_VERSION.")"; // If new title contains a version that is different than core
}
else $appli.=" ".DOL_VERSION;
}
else $appli.=" ".DOL_VERSION;

$urlback=$_SERVER["REQUEST_URI"];
$topic='['.$conf->global->MAIN_APPLICATION_TITLE.'] '.$langs->transnoentitiesnoconv("NewPaypalPaymentFailed");
$topic='['.$appli.'] '.$langs->transnoentitiesnoconv("NewPaypalPaymentFailed");
$content=$langs->transnoentitiesnoconv("NewPaypalPaymentFailed")."\ntag=".$fulltag."\ntoken=".$token." paymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt;
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mailfile = new CMailFile($topic, $sendto, $from, $content);
Expand Down
30 changes: 28 additions & 2 deletions htdocs/public/paypal/paymentok.php
Expand Up @@ -188,8 +188,21 @@
$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

// Define link to login card
$appli=constant('DOL_APPLICATION_TITLE');
if (! empty($conf->global->MAIN_APPLICATION_TITLE))
{
$appli=$conf->global->MAIN_APPLICATION_TITLE;
if (preg_match('/\d\.\d/', $appli))
{
if (! preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli.=" (".DOL_VERSION.")"; // If new title contains a version that is different than core
}
else $appli.=" ".DOL_VERSION;
}
else $appli.=" ".DOL_VERSION;

$urlback=$_SERVER["REQUEST_URI"];
$topic='['.$conf->global->MAIN_APPLICATION_TITLE.'] '.$langs->transnoentitiesnoconv("NewPaypalPaymentReceived");
$topic='['.$appli.'] '.$langs->transnoentitiesnoconv("NewPaypalPaymentReceived");
$tmptag=dolExplodeIntoArray($fulltag,'.','=');
$content="";
if (! empty($tmptag['MEM']))
Expand Down Expand Up @@ -258,8 +271,21 @@
$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

// Define link to login card
$appli=constant('DOL_APPLICATION_TITLE');
if (! empty($conf->global->MAIN_APPLICATION_TITLE))
{
$appli=$conf->global->MAIN_APPLICATION_TITLE;
if (preg_match('/\d\.\d/', $appli))
{
if (! preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli.=" (".DOL_VERSION.")"; // If new title contains a version that is different than core
}
else $appli.=" ".DOL_VERSION;
}
else $appli.=" ".DOL_VERSION;

$urlback=$_SERVER["REQUEST_URI"];
$topic='['.$conf->global->MAIN_APPLICATION_TITLE.'] '.$langs->transnoentitiesnoconv("ValidationOfPaypalPaymentFailed");
$topic='['.$appli.'] '.$langs->transnoentitiesnoconv("ValidationOfPaypalPaymentFailed");
$content="";
$content.=$langs->transnoentitiesnoconv("PaypalConfirmPaymentPageWasCalledButFailed")."\n";
$content.="\n";
Expand Down
2 changes: 2 additions & 0 deletions htdocs/public/stripe/newpayment.php
@@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2017 Saasprov <saasprov@gmail.com>
* Copyright (C) 2017 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
Expand Down Expand Up @@ -35,6 +36,7 @@

$langs->load("main");
$langs->load("other");
$langs->load("paybox"); // File with generic data
$langs->load("stripe");

$source=GETPOST("source",'alpha');
Expand Down

0 comments on commit 0ed4b60

Please sign in to comment.