Skip to content

Commit

Permalink
Correct link and renamed checkout by newpayment
Browse files Browse the repository at this point in the history
  • Loading branch information
aspangaro committed Apr 29, 2017
1 parent d73374c commit ce62736
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 53 deletions.
Expand Up @@ -16,6 +16,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* \file htdocs/public/stripe/newpayment.php
* \ingroup Stripe
* \brief Page to do payment with Stripe
*/

define("NOLOGIN",1);
define("NOCSRFCHECK",1);

Expand All @@ -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");
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -122,7 +128,7 @@ class="stripe-button"
</td>

<td>
Invoice #: <?php echo $invoice->ref; ?><br>
<?php echo $langs->trans("Invoice") . ' : ' . $invoice->ref; ?><br>
<?php echo $langs->trans('Date') . ' : ' . dol_print_date($invoice->date, 'day'); ?><br>
<?php echo $langs->trans('DateMaxPayment') . ' : ' . dol_print_date($invoice->date_validation, 'day'); ?>
</td>
Expand Down
50 changes: 1 addition & 49 deletions htdocs/stripe/lib/stripe.lib.php
Expand Up @@ -112,6 +112,7 @@ function showStripePaymentUrl($type,$ref)
$langs->load("paypal");
$langs->load("paybox");
$langs->load("stripe");

$servicename='Stripe';
$out='<br><br>';
$out.=img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePayment",$servicename).'<br>';
Expand Down Expand Up @@ -139,83 +140,34 @@ 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?'<font color="#666666">':'').$amount.($mode?'</font>':'').'&tag='.($mode?'<font color="#666666">':'').$freetag.($mode?'</font>':'');
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')
{
$out=DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?source=order&ref='.($mode?'<font color="#666666">':'');
if ($mode == 1) $out.='order_ref';
if ($mode == 0) $out.=urlencode($ref);
$out.=($mode?'</font>':'');
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?'<font color="#666666">':'');
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?'</font>':'');
}
}
}
if ($type == 'invoice')
{
$out=DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?source=invoice&ref='.($mode?'<font color="#666666">':'');
if ($mode == 1) $out.='invoice_ref';
if ($mode == 0) $out.=urlencode($ref);
$out.=($mode?'</font>':'');
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?'<font color="#666666">':'');
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?'</font>':'');
}
}
}
if ($type == 'contractline')
{
$out=DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?source=contractline&ref='.($mode?'<font color="#666666">':'');
if ($mode == 1) $out.='contractline_ref';
if ($mode == 0) $out.=urlencode($ref);
$out.=($mode?'</font>':'');
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?'<font color="#666666">':'');
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?'</font>':'');
}
}
}
if ($type == 'membersubscription')
{
$out=DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?source=membersubscription&ref='.($mode?'<font color="#666666">':'');
if ($mode == 1) $out.='member_ref';
if ($mode == 0) $out.=urlencode($ref);
$out.=($mode?'</font>':'');
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?'<font color="#666666">':'');
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?'</font>':'');
}
}
}

// For multicompany
Expand Down

0 comments on commit ce62736

Please sign in to comment.