diff --git a/htdocs/langs/en_US/stripe.lang b/htdocs/langs/en_US/stripe.lang index f19b4e44a5273660486fca8aa100fcc67a25f6f9..3f85dc2d544f582c457cbf49a87a9a6721d9ba79 100644 --- a/htdocs/langs/en_US/stripe.lang +++ b/htdocs/langs/en_US/stripe.lang @@ -37,4 +37,5 @@ 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 \ No newline at end of file +STRIPE_LIVE_PUBLISHABLE_KEY=Publishable live key +StripeLiveEnabled=Stripe live enabled \ No newline at end of file diff --git a/htdocs/public/stripe/config.php b/htdocs/public/stripe/config.php index b94617b4c69ad495e34a8bc7fd3836477c7f6987..dfd0ea6aa1adf99028e369d1e5e442be6fa2fada 100644 --- a/htdocs/public/stripe/config.php +++ b/htdocs/public/stripe/config.php @@ -29,9 +29,21 @@ require_once DOL_DOCUMENT_ROOT.'/stripe/lib/stripe.lib.php'; require_once DOL_DOCUMENT_ROOT.'/includes/stripe/init.php'; //use \includes\stripe as stripe; -$stripe = array( - "secret_key" => $conf->global->STRIPE_TEST_SECRET_KEY, - "publishable_key" => $conf->global->STRIPE_TEST_PUBLISHABLE_KEY -); +$stripe = array(); + +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']); \ No newline at end of file diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 1882d1065b044df4d05d28cf0681dc1f021a72ce..6274197a30152507f52a492d1fa9086cad5110ad 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -1,5 +1,6 @@ <?php /* Copyright (C) 2017 Alexandre Spangaro <aspangaro@zendsi.com> + * Copyright (C) 2017 Olivier Geffroy <jeff@jeffinfo.com> * Copyright (C) 2017 Saasprov <saasprov@gmail.com> * * This program is free software; you can redistribute it and/or modify @@ -45,7 +46,7 @@ if ($action == 'setvalue' && $user->admin) { $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++; $result=dolibarr_set_const($db, "STRIPE_TEST_SECRET_KEY",GETPOST('STRIPE_TEST_SECRET_KEY','alpha'),'chaine',0,'',$conf->entity); 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 @@ -119,9 +134,19 @@ print '<td>'.$langs->trans("Value").'</td>'; print "</tr>\n"; $var=!$var; -print '<tr '.$bc[$var].'><td class="fieldrequired">'; -print $langs->trans("STRIPE_TEST").'</td><td>'; -print $form->selectyesno("STRIPE_TEST",$conf->global->STRIPE_TEST,1); +print '<tr '.$bc[$var].'>'; +print '<td class="titlefield fieldrequired">'; +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>'; $var=!$var;