* Copyright (C) 2005-2013 Laurent Destailleur * Copyright (C) 2011-2012 Regis Houssin * Copyright (C) 2011-2012 Juanjo Menent * * 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/paypal/admin/paypal.php * \ingroup paypal * \brief Page to setup paypal module */ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $servicename='PayPal'; $langs->load("admin"); $langs->load("other"); $langs->load("paypal"); $langs->load("paybox"); if (! $user->admin) accessforbidden(); $action = GETPOST('action','alpha'); 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); if (! $result > 0) $error++; $result=dolibarr_set_const($db, "PAYPAL_API_SIGNATURE",GETPOST('PAYPAL_API_SIGNATURE','alpha'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; $result=dolibarr_set_const($db, "PAYPAL_CREDITOR",GETPOST('PAYPAL_CREDITOR','alpha'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; $result=dolibarr_set_const($db, "PAYPAL_API_INTEGRAL_OR_PAYPALONLY",GETPOST('PAYPAL_API_INTEGRAL_OR_PAYPALONLY','alpha'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; $result=dolibarr_set_const($db, "PAYPAL_CSS_URL",GETPOST('PAYPAL_CSS_URL','alpha'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; $result=dolibarr_set_const($db, "PAYPAL_SECURITY_TOKEN",GETPOST('PAYPAL_SECURITY_TOKEN','alpha'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; $result=dolibarr_set_const($db, "PAYPAL_SECURITY_TOKEN_UNIQUE",GETPOST('PAYPAL_SECURITY_TOKEN_UNIQUE','alpha'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; $result=dolibarr_set_const($db, "PAYPAL_ADD_PAYMENT_URL",GETPOST('PAYPAL_ADD_PAYMENT_URL','alpha'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; $result=dolibarr_set_const($db, "PAYPAL_MESSAGE_OK",GETPOST('PAYPAL_MESSAGE_OK'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; $result=dolibarr_set_const($db, "PAYPAL_MESSAGE_KO",GETPOST('PAYPAL_MESSAGE_KO'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; $result=dolibarr_set_const($db, "PAYPAL_PAYONLINE_SENDEMAIL",GETPOST('PAYPAL_PAYONLINE_SENDEMAIL'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; if (! $error) { $db->commit(); setEventMessage($langs->trans("SetupSaved")); } else { $db->rollback(); dol_print_error($db); } } /* * View */ $form=new Form($db); llxHeader('',$langs->trans("PaypalSetup")); $linkback=''.$langs->trans("BackToModuleList").''; print_fiche_titre($langs->trans("ModuleSetup").' PayPal',$linkback); print '
'; $head=paypaladmin_prepare_head(); print '
'; print ''; print ''; dol_fiche_head($head, 'paypalaccount', ''); print $langs->trans("PaypalDesc")."
\n"; // Test if php curl exist if (! function_exists('curl_version')) { $langs->load("errors"); setEventMessage($langs->trans("ErrorPhpCurlNotInstalled"), 'errors'); } print '
'; print ''; $var=true; print ''; print ''; print ''; print "\n"; $var=!$var; print ''; $var=!$var; print ''; $var=!$var; print ''; $var=!$var; print ''; $var=true; print ''; print ''; print ''; print "\n"; $var=!$var; print ''; /*$var=!$var; print ''; */ $var=!$var; print ''; $var=!$var; print ''; $var=!$var; print ''; $var=!$var; print ''; $var=!$var; print ''; $var=!$var; print ''; $var=true; print ''; print ''; print ''; print "\n"; $var=!$var; print ''; $var=!$var; print ''; print '
'.$langs->trans("AccountParameter").''.$langs->trans("Value").'
'; print $langs->trans("PAYPAL_API_SANDBOX").''; print $form->selectyesno("PAYPAL_API_SANDBOX",$conf->global->PAYPAL_API_SANDBOX,1); print '
'; print $langs->trans("PAYPAL_API_USER").''; print ''; print '   '.$langs->trans("Example").': paypal_api1.mywebsite.com'; print '
'; print $langs->trans("PAYPAL_API_PASSWORD").''; print ''; print '
'; print $langs->trans("PAYPAL_API_SIGNATURE").''; print ''; print '
'.$langs->trans("Example").': ASsqXEmw4KzmX-CPChWSVDNCNfd.A3YNR7uz-VncXXAERFDFDFDF'; print '
'.$langs->trans("UsageParameter").''.$langs->trans("Value").'
'; print $langs->trans("PAYPAL_API_INTEGRAL_OR_PAYPALONLY").''; print $form->selectarray("PAYPAL_API_INTEGRAL_OR_PAYPALONLY",array('integral'=> $langs->trans('PaypalModeIntegral'),'paypalonly'=> $langs->trans('PaypalModeOnlyPaypal')),$conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY); print '
'; print ''.$langs->trans("PAYPAL_API_EXPRESS").''; print $form->selectyesno("PAYPAL_API_EXPRESS",$conf->global->PAYPAL_API_EXPRESS); print '
'; 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("PAYPAL_ADD_PAYMENT_URL").''; print $form->selectyesno("PAYPAL_ADD_PAYMENT_URL",$conf->global->PAYPAL_ADD_PAYMENT_URL,1); print '
'; print $langs->trans("MessageOK").''; $doleditor=new DolEditor('PAYPAL_MESSAGE_OK',$conf->global->PAYPAL_MESSAGE_OK,'',100,'dolibarr_details','In',false,true,true,ROWS_4,60); $doleditor->Create(); print '
'; print $langs->trans("MessageKO").''; $doleditor=new DolEditor('PAYPAL_MESSAGE_KO',$conf->global->PAYPAL_MESSAGE_KO,'',100,'dolibarr_details','In',false,true,true,ROWS_4,60); $doleditor->Create(); print '
'; print $langs->trans("PAYPAL_PAYONLINE_SENDEMAIL").''; print ''; print '   '.$langs->trans("Example").': myemail@myserver.com'; print '
'.$langs->trans("UrlGenerationParameters").''.$langs->trans("Value").'
'; print $langs->trans("SecurityToken").''; print ''; if (! empty($conf->use_javascript_ajax)) print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"'); print '
'; print $langs->trans("SecurityTokenIsUnique").''; print $form->selectyesno("PAYPAL_SECURITY_TOKEN_UNIQUE",(empty($conf->global->PAYPAL_SECURITY_TOKEN)?0:$conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE),1); print '
'; dol_fiche_end(); print '
'; print '
'; print '

'; // Help doc print ''.$langs->trans("InformationToFindParameters","Paypal").':
'; if (! empty($conf->use_javascript_ajax)) print ''.$langs->trans("ClickHere").'...'; $realpaypalurl='www.paypal.com'; $sandboxpaypalurl='developer.paypal.com'; print '
'; print 'Your API authentication information can be found with following steps. We recommend that you open a separate Web browser session when carrying out this procedure.
1. Log in to your PayPal account (on real paypal '.$realpaypalurl.' (or sandbox '.$sandboxpaypalurl.').
2. Click the "Profile" or "Preferencies" subtab located under the My Account heading.
3. Click the link "API Access".
4. Click the View API Certificate link in the right column.
5. Click the Request API signature radio button on the Request API Credentials page.
6. Complete the Request API Credential Request form by clicking the agreement checkbox and clicking Submit.
7. Save the values for API Username, Password and Signature (make sure this long character signature is copied).
8. Click the "Modify" button after copying your API Username, Password, and Signature. '; print '
'; print '

'; $token=''; // Url list print ''.$langs->trans("FollowingUrlAreAvailableToMakePayments").':
'; print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnFreeAmount",$servicename).':
'; print ''.getPaypalPaymentUrl(1,'free')."

\n"; if (! empty($conf->commande->enabled)) { print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnOrder",$servicename).':
'; print ''.getPaypalPaymentUrl(1,'order')."
\n"; if (! empty($conf->global->PAYPAL_SECURITY_TOKEN) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) { $langs->load("orders"); print '
'; print $langs->trans("EnterRefToBuildUrl",$langs->transnoentitiesnoconv("Order")).': '; print ''; print ''; if (GETPOST('generate_order_ref','alpha')) { print '
-> '; $url=getPaypalPaymentUrl(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 ''.getPaypalPaymentUrl(1,'invoice')."
\n"; if (! empty($conf->global->PAYPAL_SECURITY_TOKEN) && ! empty($conf->global->PAYPAL_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 ''.getPaypalPaymentUrl(1,'contractline')."
\n"; if (! empty($conf->global->PAYPAL_SECURITY_TOKEN) && ! empty($conf->global->PAYPAL_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 ''.getPaypalPaymentUrl(1,'membersubscription')."
\n"; if (! empty($conf->global->PAYPAL_SECURITY_TOKEN) && ! empty($conf->global->PAYPAL_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();