Add mode live
This commit is contained in:
parent
16a41242d3
commit
b05d2c50e8
@ -37,4 +37,5 @@ NewStripePaymentFailed=New Stripe payment tried but failed
|
|||||||
STRIPE_TEST_SECRET_KEY=Secret test key
|
STRIPE_TEST_SECRET_KEY=Secret test key
|
||||||
STRIPE_TEST_PUBLISHABLE_KEY=Publishable test key
|
STRIPE_TEST_PUBLISHABLE_KEY=Publishable test key
|
||||||
STRIPE_LIVE_SECRET_KEY=Secret live key
|
STRIPE_LIVE_SECRET_KEY=Secret live key
|
||||||
STRIPE_LIVE_PUBLISHABLE_KEY=Publishable live key
|
STRIPE_LIVE_PUBLISHABLE_KEY=Publishable live key
|
||||||
|
StripeLiveEnabled=Stripe live enabled
|
||||||
@ -29,9 +29,21 @@ require_once DOL_DOCUMENT_ROOT.'/stripe/lib/stripe.lib.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/includes/stripe/init.php';
|
require_once DOL_DOCUMENT_ROOT.'/includes/stripe/init.php';
|
||||||
|
|
||||||
//use \includes\stripe as stripe;
|
//use \includes\stripe as stripe;
|
||||||
$stripe = array(
|
$stripe = array();
|
||||||
"secret_key" => $conf->global->STRIPE_TEST_SECRET_KEY,
|
|
||||||
"publishable_key" => $conf->global->STRIPE_TEST_PUBLISHABLE_KEY
|
if(empty($conf->global->SKYPE_LIVE))
|
||||||
);
|
{
|
||||||
|
$stripe = array(
|
||||||
|
"secret_key" => $conf->global->STRIPE_TEST_SECRET_KEY,
|
||||||
|
"publishable_key" => $conf->global->STRIPE_TEST_PUBLISHABLE_KEY
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$stripe = array(
|
||||||
|
"secret_key" => $conf->global->STRIPE_LIVE_SECRET_KEY,
|
||||||
|
"publishable_key" => $conf->global->STRIPE_LIVE_PUBLISHABLE_KEY
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
\includes\stripe::setApiKey($stripe['secret_key']);
|
\includes\stripe::setApiKey($stripe['secret_key']);
|
||||||
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2017 Alexandre Spangaro <aspangaro@zendsi.com>
|
/* Copyright (C) 2017 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||||
|
* Copyright (C) 2017 Olivier Geffroy <jeff@jeffinfo.com>
|
||||||
* Copyright (C) 2017 Saasprov <saasprov@gmail.com>
|
* Copyright (C) 2017 Saasprov <saasprov@gmail.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
|
||||||
@ -45,7 +46,7 @@ if ($action == 'setvalue' && $user->admin)
|
|||||||
{
|
{
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
$result=dolibarr_set_const($db, "STRIPE_TEST",GETPOST('STRIPE_TEST','alpha'),'chaine',0,'',$conf->entity);
|
$result=dolibarr_set_const($db, "STRIPE_LIVE",GETPOST('STRIPE_LIVE','alpha'),'chaine',0,'',$conf->entity);
|
||||||
if (! $result > 0) $error++;
|
if (! $result > 0) $error++;
|
||||||
$result=dolibarr_set_const($db, "STRIPE_TEST_SECRET_KEY",GETPOST('STRIPE_TEST_SECRET_KEY','alpha'),'chaine',0,'',$conf->entity);
|
$result=dolibarr_set_const($db, "STRIPE_TEST_SECRET_KEY",GETPOST('STRIPE_TEST_SECRET_KEY','alpha'),'chaine',0,'',$conf->entity);
|
||||||
if (! $result > 0) $error++;
|
if (! $result > 0) $error++;
|
||||||
@ -76,6 +77,20 @@ if ($action == 'setvalue' && $user->admin)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($action=="setlive")
|
||||||
|
{
|
||||||
|
$liveenable = GETPOST('value','int');
|
||||||
|
$res = dolibarr_set_const($db, "STRIPE_LIVE", $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
|
* View
|
||||||
@ -119,9 +134,19 @@ print '<td>'.$langs->trans("Value").'</td>';
|
|||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'><td class="fieldrequired">';
|
print '<tr '.$bc[$var].'>';
|
||||||
print $langs->trans("STRIPE_TEST").'</td><td>';
|
print '<td class="titlefield fieldrequired">';
|
||||||
print $form->selectyesno("STRIPE_TEST",$conf->global->STRIPE_TEST,1);
|
print $langs->trans("StripeLiveEnabled").'</td><td>';
|
||||||
|
if (!empty($conf->global->STRIPE_LIVE))
|
||||||
|
{
|
||||||
|
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 '</td></tr>';
|
||||||
|
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user