* Copyright (C) 2017 Olivier Geffroy * Copyright (C) 2017 Saasprov * * 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 * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/stripe/admin/stripe.php * \ingroup stripe * \brief Page to setup stripe module */ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/stripe/lib/stripe.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $servicename='Stripe'; $langs->load("admin"); $langs->load("other"); $langs->load("paypal"); $langs->load("paybox"); $langs->load("stripe"); if (! $user->admin) accessforbidden(); $action = GETPOST('action','alpha'); if ($action == 'setvalue' && $user->admin) { $db->begin(); $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_PUBLISHABLE_KEY",GETPOST('STRIPE_TEST_PUBLISHABLE_KEY','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++; $result=dolibarr_set_const($db, "STRIPE_LIVE_PUBLISHABLE_KEY",GETPOST('STRIPE_LIVE_PUBLISHABLE_KEY','alpha'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; $result=dolibarr_set_const($db, "STRIPE_LIVE_SECRET_KEY",GETPOST('STRIPE_LIVE_SECRET_KEY','alpha'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; $result=dolibarr_set_const($db, "STRIPE_CREDITOR",GETPOST('STRIPE_CREDITOR','alpha'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; $result=dolibarr_set_const($db, "STRIPE_CSS_URL",GETPOST('STRIPE_CSS_URL','alpha'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; $result=dolibarr_set_const($db, "STRIPE_MESSAGE_OK",GETPOST('STRIPE_MESSAGE_OK','alpha'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; $result=dolibarr_set_const($db, "STRIPE_MESSAGE_KO",GETPOST('STRIPE_MESSAGE_KO','alpha'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; $result=dolibarr_set_const($db, "STRIPE_PAYONLINE_SENDEMAIL",GETPOST('STRIPE_PAYONLINE_SENDEMAIL'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; if (! $error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { $db->rollback(); dol_print_error($db); } } 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 */ $form=new Form($db); //$SECRET_TEST_KEY="sk_test_xxxxxxxxxxxxxxxxxxxxxxxx"; // Stripe test secret key //if (empty($conf->global->STRIPE_TEST_SECRET_KEY)) $conf->global->STRIPE_TEST_SECRET_KEY = $SECRET_TEST_KEY; //$PUBLISHABLE_TEST_KEY="pk_test_xxxxxxxxxxxxxxxxxxxxxxxx"; // Stripe test publishable key //if (empty($conf->global->STRIPE_TEST_PUBLISHABLE_KEY)) $conf->global->STRIPE_TEST_PUBLISHABLE_KEY = $PUBLISHABLE_TEST_KEY; //$SECRET_LIVE_KEY="sk_live_xxxxxxxxxxxxxxxxxxxxxxxx"; // Stripe live secret key //if (empty($conf->global->STRIPE_LIVE_SECRET_KEY)) $conf->global->STRIPE_LIVE_SECRET_KEY = $SECRET_LIVE_KEY; //$PUBLISHABLE_LIVE_KEY="pk_live_xxxxxxxxxxxxxxxxxxxxxxxx"; // Stripe live publishable key //if (empty($conf->global->STRIPE_LIVE_PUBLISHABLE_KEY)) $conf->global->STRIPE_LIVE_PUBLISHABLE_KEY = $PUBLISHABLE_LIVE_KEY; llxHeader('',$langs->trans("StripeSetup")); $linkback=''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("ModuleSetup").' Stripe',$linkback); $head=stripeadmin_prepare_head(); print '
'; print ''; print ''; dol_fiche_head($head, 'stripeaccount', '', -1); print $langs->trans("StripeDesc")."
\n"; print '
'; print ''; print ''; print ''; print ''; print "\n"; print ''; print ''; print ''; print ''; print ''; print ''; print '
'.$langs->trans("AccountParameter").''.$langs->trans("Value").'
'; print $langs->trans("StripeLiveEnabled").''; if (!empty($conf->global->STRIPE_LIVE)) { print ''; print img_picto($langs->trans("Activated"),'switch_on'); } else { print ''; print img_picto($langs->trans("Disabled"),'switch_off'); } print '
'; print ''.$langs->trans("STRIPE_TEST_PUBLISHABLE_KEY").''; print ''; print '   '.$langs->trans("Example").': pk_test_xxxxxxxxxxxxxxxxxxxxxxxx'; print '
'; print ''.$langs->trans("STRIPE_TEST_SECRET_KEY").''; print ''; print '   '.$langs->trans("Example").': sk_test_xxxxxxxxxxxxxxxxxxxxxxxx'; print '
'; print ''.$langs->trans("STRIPE_LIVE_PUBLISHABLE_KEY").''; print ''; print '   '.$langs->trans("Example").': pk_live_xxxxxxxxxxxxxxxxxxxxxxxx'; print '
'; print ''.$langs->trans("STRIPE_LIVE_SECRET_KEY").''; print ''; print '   '.$langs->trans("Example").': sk_live_xxxxxxxxxxxxxxxxxxxxxxxx'; print '
'; print '
'; print ''; print ''; print ''; print ''; print "\n"; print ''; print ''; print ''; print ''; print ''; print '
'.$langs->trans("UsageParameter").''.$langs->trans("Value").'
'; print $langs->trans("VendorName").''; print ''; print '   '.$langs->trans("Example").': '.$mysoc->name; print '
'; print $langs->trans("CSSUrlForPaymentForm").''; print ''; print '   '.$langs->trans("Example").': http://mysite/mycss.css'; print '
'; print $langs->trans("MessageOK").''; $doleditor=new DolEditor('STRIPE_MESSAGE_OK',$conf->global->STRIPE_MESSAGE_OK,'',100,'dolibarr_details','In',false,true,true,ROWS_2,'90%'); $doleditor->Create(); print '
'; print $langs->trans("MessageKO").''; $doleditor=new DolEditor('STRIPE_MESSAGE_KO',$conf->global->STRIPE_MESSAGE_KO,'',100,'dolibarr_details','In',false,true,true,ROWS_2,'90%'); $doleditor->Create(); print '
'; print $langs->trans("STRIPE_PAYONLINE_SENDEMAIL").''; print ''; print '   '.$langs->trans("Example").': myemail@myserver.com'; print '
'; dol_fiche_end(); print '
'; print '
'; print '

'; $token=''; // Url list print ''.$langs->trans("FollowingUrlAreAvailableToMakePayments").':

'; print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnFreeAmount",$servicename).':
'; print ''.getStripePaymentUrl(1,'free')."

\n"; if (! empty($conf->commande->enabled)) { print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnOrder",$servicename).':
'; print ''.getStripePaymentUrl(1,'order')."
\n"; if (! empty($conf->global->STRIPE_SECURITY_TOKEN) && ! empty($conf->global->STRIPE_SECURITY_TOKEN_UNIQUE)) { $langs->load("orders"); print '
'; print $langs->trans("EnterRefToBuildUrl",$langs->transnoentitiesnoconv("Order")).': '; print ''; print ''; if (GETPOST('generate_order_ref','alpha')) { print '
-> '; $url=getStripePaymentUrl(0,'order',GETPOST('generate_order_ref','alpha')); print $url; print "
\n"; } print '
'; } print '
'; } if (! empty($conf->facture->enabled)) { print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnInvoice",$servicename).':
'; print ''.getStripePaymentUrl(1,'invoice')."
\n"; if (! empty($conf->global->STRIPE_SECURITY_TOKEN) && ! empty($conf->global->STRIPE_SECURITY_TOKEN_UNIQUE)) { $langs->load("bills"); print '
'; print $langs->trans("EnterRefToBuildUrl",$langs->transnoentitiesnoconv("Invoice")).': '; print ''; print ''; if (GETPOST('generate_invoice_ref','alpha')) { print '
-> '; $url=getPaypalPaymentUrl(0,'invoice',GETPOST('generate_invoice_ref','alpha')); print $url; print "
\n"; } print '
'; } print '
'; } if (! empty($conf->contrat->enabled)) { print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnContractLine",$servicename).':
'; print ''.getStripePaymentUrl(1,'contractline')."
\n"; if (! empty($conf->global->STRIPE_SECURITY_TOKEN) && ! empty($conf->global->STRIPE_SECURITY_TOKEN_UNIQUE)) { $langs->load("contract"); print '
'; print $langs->trans("EnterRefToBuildUrl",$langs->transnoentitiesnoconv("Contract")).': '; print ''; print ''; if (GETPOST('generate_contract_ref')) { print '
-> '; $url=getPaypalPaymentUrl(0,'contractline',GETPOST('generate_contract_ref','alpha')); print $url; print "
\n"; } print '
'; } print '
'; } if (! empty($conf->adherent->enabled)) { print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnMemberSubscription",$servicename).':
'; print ''.getStripePaymentUrl(1,'membersubscription')."
\n"; if (! empty($conf->global->STRIPE_SECURITY_TOKEN) && ! empty($conf->global->STRIPE_SECURITY_TOKEN_UNIQUE)) { $langs->load("members"); print '
'; print $langs->trans("EnterRefToBuildUrl",$langs->transnoentitiesnoconv("Member")).': '; print ''; print ''; if (GETPOST('generate_member_ref')) { print '
-> '; $url=getPaypalPaymentUrl(0,'membersubscription',GETPOST('generate_member_ref','alpha')); print $url; print "
\n"; } print '
'; } print '
'; } print info_admin($langs->trans("YouCanAddTagOnUrl")); if (! empty($conf->use_javascript_ajax)) { print "\n".''; } llxFooter(); $db->close();