Skip to content
Snippets Groups Projects
Commit caae7e41 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

NEW It's easier to switch between sandbox and live for paypal

parent 998254d9
No related branches found
No related tags found
No related merge requests found
......@@ -28,4 +28,5 @@ DetailedErrorMessage=Detailed Error Message
ShortErrorMessage=Short Error Message
ErrorCode=Error Code
ErrorSeverityCode=Error Severity Code
OnlinePaymentSystem=Online payment system
\ No newline at end of file
OnlinePaymentSystem=Online payment system
PaypalLiveEnabled=Paypal live enabled (otherwise test/sandbox mode)
\ No newline at end of file
......@@ -39,4 +39,4 @@ 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
StripeLiveEnabled=Stripe live enabled
\ No newline at end of file
StripeLiveEnabled=Stripe live enabled (otherwise test/sandbox mode)
\ No newline at end of file
......@@ -44,8 +44,6 @@ 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);
if (! $result > 0) $error++;
$result=dolibarr_set_const($db, "PAYPAL_API_PASSWORD",GETPOST('PAYPAL_API_PASSWORD','alpha'),'chaine',0,'',$conf->entity);
......@@ -85,6 +83,21 @@ if ($action == 'setvalue' && $user->admin)
}
}
if ($action=="setlive")
{
$liveenable = GETPOST('value','int')?0:1;
$res = dolibarr_set_const($db, "PAYPAL_API_SANDBOX", $liveenable,'yesno',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
/*
* View
......@@ -127,13 +140,21 @@ print '<td>'.$langs->trans("AccountParameter").'</td>';
print '<td>'.$langs->trans("Value").'</td>';
print "</tr>\n";
print '<tr class="oddeven"><td class="fieldrequired">';
print $langs->trans("PAYPAL_API_SANDBOX").'</td><td>';
print $form->selectyesno("PAYPAL_API_SANDBOX",$conf->global->PAYPAL_API_SANDBOX,1);
print '<tr class="oddeven">';
print '<td class="titlefield fieldrequired">';
print $langs->trans("PaypalLiveEnabled").'</td><td>';
if (empty($conf->global->PAYPAL_API_SANDBOX))
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=setlive&value=0">';
print img_picto($langs->trans("Activated"),'switch_on');
}
else
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=setlive&value=1">';
print img_picto($langs->trans("Disabled"),'switch_off');
}
print '</td></tr>';
print '<tr class="oddeven"><td class="fieldrequired">';
print $langs->trans("PAYPAL_API_USER").'</td><td>';
print '<input size="32" type="text" name="PAYPAL_API_USER" value="'.$conf->global->PAYPAL_API_USER.'">';
......
......@@ -265,7 +265,7 @@ $conf->dol_hide_leftmenu=1;
llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody');
if (! empty($PAYPAL_API_SANDBOX))
if (! empty($conf->global->PAYPAL_API_SANDBOX))
{
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode'),'','warning');
}
......
......@@ -49,6 +49,7 @@ $langs->load("main");
$langs->load("companies");
$langs->load("other");
$langs->load("paybox"); // File with generic data
$langs->load("paypal");
$langs->load("stripe");
$action=GETPOST('action','alpha');
......@@ -300,12 +301,12 @@ if ($action == 'charge')
if ($error)
{
header("Location: ".DOL_URL_ROOT.'/public/stripe/paymentko.php?FULLTAG='.urlencode($FULLTAG));
header("Location: ".$urlko);
exit;
}
else
{
header("Location: ".DOL_URL_ROOT.'/public/stripe/paymentok.php?FULLTAG='.urlencode($FULLTAG));
header("Location: ".$urlok);
exit;
}
......@@ -324,7 +325,7 @@ $conf->dol_hide_leftmenu=1;
llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody');
if (! empty($STRIPE_API_SANDBOX))
if (empty($conf->global->STRIPE_LIVE))
{
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode'),'','warning');
}
......
......@@ -93,6 +93,7 @@ if ($action=="setlive")
}
}
/*
* View
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment