diff --git a/htdocs/langs/en_US/paypal.lang b/htdocs/langs/en_US/paypal.lang index 63999f31234..a0cadc88096 100644 --- a/htdocs/langs/en_US/paypal.lang +++ b/htdocs/langs/en_US/paypal.lang @@ -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 diff --git a/htdocs/langs/en_US/stripe.lang b/htdocs/langs/en_US/stripe.lang index 68b853ac25b..c115a76603c 100644 --- a/htdocs/langs/en_US/stripe.lang +++ b/htdocs/langs/en_US/stripe.lang @@ -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 diff --git a/htdocs/paypal/admin/paypal.php b/htdocs/paypal/admin/paypal.php index 36c8df9d0d6..2d0be83c80d 100644 --- a/htdocs/paypal/admin/paypal.php +++ b/htdocs/paypal/admin/paypal.php @@ -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 ''.$langs->trans("AccountParameter").''; print ''.$langs->trans("Value").''; print "\n"; - -print ''; -print $langs->trans("PAYPAL_API_SANDBOX").''; -print $form->selectyesno("PAYPAL_API_SANDBOX",$conf->global->PAYPAL_API_SANDBOX,1); +print ''; +print ''; +print $langs->trans("PaypalLiveEnabled").''; +if (empty($conf->global->PAYPAL_API_SANDBOX)) +{ + print ''; + print img_picto($langs->trans("Activated"),'switch_on'); +} +else +{ + print ''; + print img_picto($langs->trans("Disabled"),'switch_off'); +} print ''; - print ''; print $langs->trans("PAYPAL_API_USER").''; print ''; diff --git a/htdocs/public/paypal/newpayment.php b/htdocs/public/paypal/newpayment.php index c9cedcfd32d..08bf0c4faed 100644 --- a/htdocs/public/paypal/newpayment.php +++ b/htdocs/public/paypal/newpayment.php @@ -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'); } diff --git a/htdocs/public/stripe/newpayment.php b/htdocs/public/stripe/newpayment.php index 5975d349fe4..64ea70cfbeb 100644 --- a/htdocs/public/stripe/newpayment.php +++ b/htdocs/public/stripe/newpayment.php @@ -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'); } diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 6ca9073a9df..056e43690b2 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -93,6 +93,7 @@ if ($action=="setlive") } } + /* * View */