Merge pull request #9946 from ptibogxiv/patch-88

Fix with new stripe payment function
This commit is contained in:
Laurent Destailleur 2018-11-08 19:13:38 +01:00 committed by GitHub
commit a50eb014ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,7 +8,7 @@
* Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
* Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2018 ThibaultFOUCART <support@ptibogxiv.net>
* Copyright (C) 2018 Thibault FOUCART <support@ptibogxiv.net>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -63,21 +63,6 @@ $addwarning=0;
$multicurrency_amounts=array();
$multicurrency_amountsresttopay=array();
if (! empty($conf->stripe->enabled))
{
$service = 'StripeTest';
$servicestatus = 0;
if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox','alpha'))
{
$service = 'StripeLive';
$servicestatus = 0;
}
$stripe = new Stripe($db);
$stripeacc = $stripe->getStripeAccount($service); // Stripe OAuth connect account of dolibarr user (no network access here)
$stripecu = $stripe->getStripeCustomerAccount($object->id, $servicestatus); // Get thirdparty cu_...
}
// Security check
$socid=0;
if ($user->societe_id > 0)
@ -93,6 +78,20 @@ if ($facid > 0)
$ret=$object->fetch($facid);
}
if (! empty($conf->stripe->enabled))
{
$service = 'StripeTest';
$servicestatus = 0;
if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox','alpha'))
{
$service = 'StripeLive';
$servicestatus = 0;
}
$stripe=new Stripe($db);
$stripeacc = $stripe->getStripeAccount($service); // Stripe OAuth connect account of dolibarr user (no network access here)
}
// Initialize technical object to manage hooks of paiements. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('paiementcard','globalcard'));
@ -307,12 +306,16 @@ if (empty($reshook))
$paiementcode ="CB";
}
}
$societe = new Societe($db);
$societe->fetch($facture->socid);
dol_syslog("Create charge", LOG_DEBUG, 0, '_stripe');
dol_syslog("Create charge", LOG_DEBUG, 0, '_stripe');
$stripecu = $stripe->getStripeCustomerAccount($societe->id, $servicestatus); // Get thirdparty cu_...
$charge=$stripe->CreatePaymentStripe($stripeamount,"EUR","invoice",$facid,$source,$customer->id,$stripe->getStripeAccount($conf->entity));
$charge=$stripe->createPaymentStripe($stripeamount,$facture->multicurrency_code,"invoice",$facid,$source,$stripecu,$stripeacc,$servicestatus);
if (!$error)
{
@ -324,6 +327,8 @@ if (empty($reshook))
$paiement->paiementid = dol_getIdFromCode($db,$paiementcode,'c_paiement');
$paiement->num_paiement = $charge->message;
$paiement->note = GETPOST('comment');
$paiement->ext_payment_id = $charge->id;
$paiement->ext_payment_site = $service;
}
if (! $error)
@ -388,8 +393,8 @@ if (empty($reshook))
exit;
}
else
{
$loc = DOL_URL_ROOT.'/stripeconnect/payment.php?facid='.$facid.'&action=create&error='.$e->getMessage();
{
$loc = DOL_URL_ROOT.'/stripe/payment.php?facid='.$facid.'&action=create&error='.$charge->message;
$db->rollback();
header('Location: '.$loc);