From ce62736e6b46e9442d4aa01133339895c9630474 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 29 Apr 2017 07:57:36 +0200 Subject: [PATCH] Correct link and renamed checkout by newpayment --- .../stripe/{checkout.php => newpayment.php} | 14 ++++-- htdocs/stripe/lib/stripe.lib.php | 50 +------------------ 2 files changed, 11 insertions(+), 53 deletions(-) rename htdocs/public/stripe/{checkout.php => newpayment.php} (94%) diff --git a/htdocs/public/stripe/checkout.php b/htdocs/public/stripe/newpayment.php similarity index 94% rename from htdocs/public/stripe/checkout.php rename to htdocs/public/stripe/newpayment.php index 3f0b6f840167d..71f581000b21d 100644 --- a/htdocs/public/stripe/checkout.php +++ b/htdocs/public/stripe/newpayment.php @@ -16,6 +16,12 @@ * along with this program. If not, see . */ +/** +* \file htdocs/public/stripe/newpayment.php +* \ingroup Stripe +* \brief Page to do payment with Stripe +*/ + define("NOLOGIN",1); define("NOCSRFCHECK",1); @@ -25,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/includes/stripe/init.php'; // Security check -if (empty($conf->paypal->enabled)) accessforbidden('',0,0,1); +if (empty($conf->stripe->enabled)) accessforbidden('',0,0,1); $langs->load("main"); $langs->load("other"); @@ -67,13 +73,13 @@ $token = GETPOST("stripeToken"); $email = GETPOST("stripeEmail"); - $customer = \Stripe\Customer::create(array( + $customer = \stripe\Customer::create(array( 'email' => $email, 'card' => $token )); $ttc = round($ttc, 2); - $charge = \Stripe\Charge::create(array( + $charge = \stripe\Charge::create(array( 'customer' => $customer->id, 'amount' => $ttc, 'currency' => $conf->currency, @@ -122,7 +128,7 @@ class="stripe-button" - Invoice #: ref; ?>
+ trans("Invoice") . ' : ' . $invoice->ref; ?>
trans('Date') . ' : ' . dol_print_date($invoice->date, 'day'); ?>
trans('DateMaxPayment') . ' : ' . dol_print_date($invoice->date_validation, 'day'); ?> diff --git a/htdocs/stripe/lib/stripe.lib.php b/htdocs/stripe/lib/stripe.lib.php index 0ab73437e1754..c454296a30468 100644 --- a/htdocs/stripe/lib/stripe.lib.php +++ b/htdocs/stripe/lib/stripe.lib.php @@ -112,6 +112,7 @@ function showStripePaymentUrl($type,$ref) $langs->load("paypal"); $langs->load("paybox"); $langs->load("stripe"); + $servicename='Stripe'; $out='

'; $out.=img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePayment",$servicename).'
'; @@ -139,11 +140,6 @@ function getStripePaymentUrl($mode,$type,$ref='',$amount='9.99',$freetag='your_f if ($type == 'free') { $out=DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?amount='.($mode?'':'').$amount.($mode?'':'').'&tag='.($mode?'':'').$freetag.($mode?'':''); - if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) - { - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; - else $out.='&securekey='.dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); - } } if ($type == 'order') { @@ -151,17 +147,6 @@ function getStripePaymentUrl($mode,$type,$ref='',$amount='9.99',$freetag='your_f if ($mode == 1) $out.='order_ref'; if ($mode == 0) $out.=urlencode($ref); $out.=($mode?'':''); - if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) - { - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; - else - { - $out.='&securekey='.($mode?'':''); - if ($mode == 1) $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + order_ref)"; - if ($mode == 0) $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $type . $ref, 2); - $out.=($mode?'':''); - } - } } if ($type == 'invoice') { @@ -169,17 +154,6 @@ function getStripePaymentUrl($mode,$type,$ref='',$amount='9.99',$freetag='your_f if ($mode == 1) $out.='invoice_ref'; if ($mode == 0) $out.=urlencode($ref); $out.=($mode?'':''); - if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) - { - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; - else - { - $out.='&securekey='.($mode?'':''); - if ($mode == 1) $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + invoice_ref)"; - if ($mode == 0) $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $type . $ref, 2); - $out.=($mode?'':''); - } - } } if ($type == 'contractline') { @@ -187,17 +161,6 @@ function getStripePaymentUrl($mode,$type,$ref='',$amount='9.99',$freetag='your_f if ($mode == 1) $out.='contractline_ref'; if ($mode == 0) $out.=urlencode($ref); $out.=($mode?'':''); - if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) - { - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; - else - { - $out.='&securekey='.($mode?'':''); - if ($mode == 1) $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + contractline_ref)"; - if ($mode == 0) $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $type . $ref, 2); - $out.=($mode?'':''); - } - } } if ($type == 'membersubscription') { @@ -205,17 +168,6 @@ function getStripePaymentUrl($mode,$type,$ref='',$amount='9.99',$freetag='your_f if ($mode == 1) $out.='member_ref'; if ($mode == 0) $out.=urlencode($ref); $out.=($mode?'':''); - if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) - { - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; - else - { - $out.='&securekey='.($mode?'':''); - if ($mode == 1) $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + member_ref)"; - if ($mode == 0) $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $type . $ref, 2); - $out.=($mode?'':''); - } - } } // For multicompany