This commit is contained in:
Laurent Destailleur 2018-04-06 14:30:18 +02:00
parent 049b9b2a5f
commit 99d72dc28c

View File

@ -24,8 +24,8 @@
*/ */
/** /**
* \file htdocs/compta/paiement.php * \file htdocs/stripe/payment.php
* \ingroup facture * \ingroup stripe
* \brief Payment page for customers invoices * \brief Payment page for customers invoices
*/ */
@ -273,12 +273,13 @@ if (empty($reshook))
} }
$facture = new Facture($db); $facture = new Facture($db);
$facture->fetch($facid); $facture->fetch($facid);
$facture->fetch_thirdparty();
$error = 0; $error = 0;
if (is_object($stripe) && $stripeacc) if (is_object($stripe) && $stripeacc)
{ {
$customerstripe=$stripe->customerStripe($object->socid, $stripeacc, $servicestatus); $customerstripe=$stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus);
if ($customerstripe->id) { if ($customerstripe->id) {
$listofsources=$customerstripe->sources->data; $listofsources=$customerstripe->sources->data;
@ -403,21 +404,23 @@ $charge=$stripe->CreatePaymentStripe($stripeamount,"EUR","invoice",$facid,$sourc
* View * View
*/ */
$form=new Form($db);
llxHeader(); llxHeader();
if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox','alpha')) if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox','alpha'))
{ {
$service = 'StripeLive'; $service = 'StripeLive';
$servicestatus = 0; $servicestatus = 0;
}
else {
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode','Stripe'),'','warning');
}
$form=new Form($db);
if (GETPOST('error')){
setEventMessages(GETPOST('error'), NULL, 'errors');
} }
else {
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode','Stripe'),'','warning');
}
if (GETPOST('error')){
setEventMessages(GETPOST('error'), NULL, 'errors');
}
if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paiement') if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paiement')
{ {
$facture = new Facture($db); $facture = new Facture($db);
@ -557,7 +560,13 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Third party // Invoice
/*if ($facture->id > 0)
{
print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans('Invoice').'</span></td><td>'.$facture->getNomUrl(4)."</td></tr>\n";
}*/
// Third party
print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans('Company').'</span></td><td>'.$facture->thirdparty->getNomUrl(4)."</td></tr>\n"; print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans('Company').'</span></td><td>'.$facture->thirdparty->getNomUrl(4)."</td></tr>\n";
// Bank account // Bank account
@ -592,27 +601,28 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
// Comments // Comments
print '<tr><td>'.$langs->trans('Comments').'</td>'; print '<tr><td>'.$langs->trans('Comments').'</td>';
print '<td class="tdtop">'; print '<td class="tdtop">';
print '<textarea name="comment" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.'">'.GETPOST('comment').'</textarea></td></tr>'; print '<textarea name="comment" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.'">'.GETPOST('comment','none').'</textarea></td></tr>';
print '</table>'; print '</table>';
dol_fiche_end(); dol_fiche_end();
$customerstripe=$stripe->customerStripe($facture->socid, $stripeacc, $servicestatus); $customerstripe=$stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus);
print '<br>';
print_barre_liste($langs->trans('StripeSourceList').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num, '', '');
print '<table class="liste" width="100%">'."\n"; print '<br>';
// Titles with sort buttons print_barre_liste($langs->trans('StripeSourceList').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num, '', '');
print '<tr class="liste_titre">';
print '<td align="left"></td>'; print '<table class="liste" width="100%">'."\n";
print '<td align="left">'.$langs->trans('Type').'</td>'; // Titles with sort buttons
print '<td align="left">'.$langs->trans('Informations').'</td>'; print '<tr class="liste_titre">';
print '<td align="left"></td>'; print '<td align="left"></td>';
print "<td></td></tr>\n"; print '<td align="left">'.$langs->trans('Type').'</td>';
foreach ($customerstripe->sources->data as $src) { print '<td align="left">'.$langs->trans('Informations').'</td>';
print '<tr>'; print '<td align="left"></td>';
print "<td></td></tr>\n";
foreach ($customerstripe->sources->data as $src) {
print '<tr>';
print '<td align="center" width="20" '; print '<td align="center" width="20" ';
if (($action == 'add_paiement' && $src->id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { print'class="opacitymedium"';} if (($action == 'add_paiement' && $src->id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { print'class="opacitymedium"';}
@ -705,47 +715,49 @@ print '</tr>';
//$account=\Stripe\Account::retrieve("".$stripe->getStripeCustomerAccount($facture->socid).""); //$account=\Stripe\Account::retrieve("".$stripe->getStripeCustomerAccount($facture->socid)."");
//} //}
if (($account->type=='custom' or $account->type=='express') && $entity==1) { if (($account->type=='custom' or $account->type=='express') && $entity==1) {
print '<tr '.$bc[0].'>'; print '<tr '.$bc[0].'>';
print '<td align="center" width="20" '; print '<td align="center" width="20" ';
if ($action == 'add_paiement' && $stripe->getStripeCustomerAccount($facture->socid)!=$source) { print'class="opacitymedium"';} if ($action == 'add_paiement' && $stripe->getStripeCustomerAccount($facture->socid)!=$source) { print'class="opacitymedium"';}
print'><input type="radio" id="source_id" class="flat" name="source_id" value="'.$conf->global->STRIPE_EXTERNAL_ACCOUNT.'"'; print'><input type="radio" id="source_id" class="flat" name="source_id" value="'.$conf->global->STRIPE_EXTERNAL_ACCOUNT.'"';
if ((empty($input) && $action != 'add_paiement') or ($source==$conf->global->STRIPE_EXTERNAL_ACCOUNT && $action == 'add_paiement')) { if ((empty($input) && $action != 'add_paiement') or ($source==$conf->global->STRIPE_EXTERNAL_ACCOUNT && $action == 'add_paiement')) {
print ' checked'; print ' checked';
} elseif ($action == 'add_paiement' && $conf->global->STRIPE_EXTERNAL_ACCOUNT!=$source) { } elseif ($action == 'add_paiement' && $conf->global->STRIPE_EXTERNAL_ACCOUNT!=$source) {
print ' disabled'; print ' disabled';
} }
print '></td><td '; print '></td><td ';
if ($action == 'add_paiement' && $stripe->getStripeCustomerAccount($facture->socid)!=$source) { print'class="opacitymedium"';} if ($action == 'add_paiement' && $stripe->getStripeCustomerAccount($facture->socid)!=$source) { print'class="opacitymedium"';}
print '><span class="fa fa-cc-stripe fa-3x fa-fw"></span></td>'; print '><span class="fa fa-cc-stripe fa-3x fa-fw"></span></td>';
print '<td '; print '<td ';
if ($action == 'add_paiement' && $stripe->getStripeCustomerAccount($facture->socid)!=$source) { print'class="opacitymedium"';} if ($action == 'add_paiement' && $stripe->getStripeCustomerAccount($facture->socid)!=$source) { print'class="opacitymedium"';}
print'>'.$langs->trans('sold'); print'>'.$langs->trans('sold');
print'</td><td '; print'</td><td ';
if ($action == 'add_paiement' && $src->id!=$source) { print'class="opacitymedium"';} if ($action == 'add_paiement' && $src->id!=$source) { print'class="opacitymedium"';}
print'>'; print'>';
print '</td>'; print '</td>';
// Default // Default
print '<td align="center" width="50" '; print '<td align="center" width="50" ';
if ($action == 'add_paiement' && $src->id!=$source) { print'class="opacitymedium"';} if ($action == 'add_paiement' && $src->id!=$source) { print'class="opacitymedium"';}
print'>'; print'>';
// if (($customer->default_source!=$src->id)) { // if (($customer->default_source!=$src->id)) {
// print img_picto($langs->trans("Disabled"),'off'); // print img_picto($langs->trans("Disabled"),'off');
// } else { // } else {
// print img_picto($langs->trans("Default"),'on'); // print img_picto($langs->trans("Default"),'on');
// } // }
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
if (empty($input)&&!$stripe->getStripeCustomerAccount($facture->socid)) if (empty($input)&&!$stripe->getStripeCustomerAccount($facture->socid))
{ {
print '<tr><td class="opacitymedium" colspan="5">'.$langs->trans("NoSource").'</td></tr>'; print '<tr><td class="opacitymedium" colspan="5">'.$langs->trans("None").'</td></tr>';
} }
print "</table>"; print "</table>";
/* /*
* List of unpaid invoices * List of unpaid invoices
*/ */