Prepare database to store payment modes of customers
This commit is contained in:
parent
7a277a8d2b
commit
489dde4db4
@ -97,3 +97,23 @@ ALTER TABLE llx_c_payment_term CHANGE COLUMN rowid rowid INTEGER AUTO_INCREMENT
|
|||||||
ALTER TABLE llx_c_payment_term ADD UNIQUE INDEX uk_c_payment_term_code(entity, code);
|
ALTER TABLE llx_c_payment_term ADD UNIQUE INDEX uk_c_payment_term_code(entity, code);
|
||||||
|
|
||||||
ALTER TABLE llx_oauth_token ADD COLUMN tokenstring text;
|
ALTER TABLE llx_oauth_token ADD COLUMN tokenstring text;
|
||||||
|
|
||||||
|
-- Add field for payment modes
|
||||||
|
ALTER TABLE llx_societe_rib ADD COLUMN type varchar(32) DEFAULT 'ban' after rowid;
|
||||||
|
ALTER TABLE llx_societe_rib ADD COLUMN last_four varchar(4);
|
||||||
|
ALTER TABLE llx_societe_rib ADD COLUMN card_type varchar(255);
|
||||||
|
ALTER TABLE llx_societe_rib ADD COLUMN cvn varchar(255);
|
||||||
|
ALTER TABLE llx_societe_rib ADD COLUMN exp_date_month INTEGER;
|
||||||
|
ALTER TABLE llx_societe_rib ADD COLUMN exp_date_year INTEGER;
|
||||||
|
ALTER TABLE llx_societe_rib ADD COLUMN country_code varchar(10);
|
||||||
|
ALTER TABLE llx_societe_rib ADD COLUMN approved integer DEFAULT 0;
|
||||||
|
ALTER TABLE llx_societe_rib ADD COLUMN email varchar(255);
|
||||||
|
ALTER TABLE llx_societe_rib ADD COLUMN ending_date date;
|
||||||
|
ALTER TABLE llx_societe_rib ADD COLUMN max_total_amount_of_all_payments double(24,8);
|
||||||
|
ALTER TABLE llx_societe_rib ADD COLUMN preapproval_key varchar(255);
|
||||||
|
ALTER TABLE llx_societe_rib ADD COLUMN starting_date date;
|
||||||
|
ALTER TABLE llx_societe_rib ADD COLUMN total_amount_of_all_payments double(24,8);
|
||||||
|
ALTER TABLE llx_societe_rib ADD COLUMN stripe_card_ref varchar(128);
|
||||||
|
ALTER TABLE llx_societe_rib ADD COLUMN status integer NOT NULL DEFAULT 1;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -17,15 +17,19 @@
|
|||||||
-- You should have received a copy of the GNU General Public License
|
-- You should have received a copy of the GNU General Public License
|
||||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
--
|
--
|
||||||
|
-- Table with the payment modes of a thirdparty (BAN, Paypal, Card, ...)
|
||||||
-- =============================================================================
|
-- =============================================================================
|
||||||
|
|
||||||
create table llx_societe_rib
|
create table llx_societe_rib
|
||||||
(
|
(
|
||||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
type varchar(32) DEFAULT 'ban', -- 'ban' or 'paypal' or 'card' or 'stripe'
|
||||||
|
label varchar(30),
|
||||||
fk_soc integer NOT NULL,
|
fk_soc integer NOT NULL,
|
||||||
datec datetime,
|
datec datetime,
|
||||||
tms timestamp,
|
tms timestamp,
|
||||||
label varchar(30),
|
|
||||||
|
-- For BAN
|
||||||
bank varchar(255), -- bank name
|
bank varchar(255), -- bank name
|
||||||
code_banque varchar(128), -- bank code
|
code_banque varchar(128), -- bank code
|
||||||
code_guichet varchar(6), -- desk code
|
code_guichet varchar(6), -- desk code
|
||||||
@ -37,10 +41,28 @@ create table llx_societe_rib
|
|||||||
proprio varchar(60),
|
proprio varchar(60),
|
||||||
owner_address varchar(255),
|
owner_address varchar(255),
|
||||||
default_rib smallint NOT NULL DEFAULT 0,
|
default_rib smallint NOT NULL DEFAULT 0,
|
||||||
|
-- For BAN direct debit feature
|
||||||
rum varchar(32), -- RUM value to use for SEPA generation
|
rum varchar(32), -- RUM value to use for SEPA generation
|
||||||
date_rum date, -- Date of mandate
|
date_rum date, -- Date of mandate
|
||||||
frstrecur varchar(16) default 'FRST', -- 'FRST' or 'RECUR'
|
frstrecur varchar(16) default 'FRST', -- 'FRST' or 'RECUR'
|
||||||
|
--For credit card
|
||||||
|
last_four varchar(4), -- last 4
|
||||||
|
card_type varchar(255), -- card type 'VISA', 'MC' , ...
|
||||||
|
cvn varchar(255),
|
||||||
|
exp_date_month INTEGER,
|
||||||
|
exp_date_year INTEGER,
|
||||||
|
country_code varchar(10),
|
||||||
|
--For Paypal
|
||||||
|
approved INTEGER DEFAULT 0,
|
||||||
|
email varchar(255),
|
||||||
|
ending_date date,
|
||||||
|
max_total_amount_of_all_payments double(24,8),
|
||||||
|
preapproval_key varchar(255),
|
||||||
|
starting_date date,
|
||||||
|
total_amount_of_all_payments double(24,8),
|
||||||
|
--For Stripe
|
||||||
|
stripe_card_ref varchar(128), -- 'card_...'
|
||||||
|
|
||||||
|
status integer NOT NULL DEFAULT 1, -- 1=ACTIVE, 0=IN_TRASH
|
||||||
import_key varchar(14) -- import key
|
import_key varchar(14) -- import key
|
||||||
)ENGINE=innodb;
|
)ENGINE=innodb;
|
||||||
|
|||||||
@ -185,7 +185,7 @@ for ($i=1; $i<=4; $i++) {
|
|||||||
<td><?php echo $langs->trans('RIB'); ?></td>
|
<td><?php echo $langs->trans('RIB'); ?></td>
|
||||||
<td align="right">
|
<td align="right">
|
||||||
<?php if ($user->rights->societe->creer) { ?>
|
<?php if ($user->rights->societe->creer) { ?>
|
||||||
<a href="<?php echo DOL_URL_ROOT.'/societe/rib.php?socid='.$this->control->tpl['id']; ?>"><?php echo $this->control->tpl['image_edit']; ?></a>
|
<a href="<?php echo DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$this->control->tpl['id']; ?>"><?php echo $this->control->tpl['image_edit']; ?></a>
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|||||||
@ -144,7 +144,7 @@ dol_fiche_head($head, 'card', $langs->trans("ThirdParty"),0,'company');
|
|||||||
<td><?php echo $langs->trans('RIB'); ?></td>
|
<td><?php echo $langs->trans('RIB'); ?></td>
|
||||||
<td align="right">
|
<td align="right">
|
||||||
<?php if ($user->rights->societe->creer) { ?>
|
<?php if ($user->rights->societe->creer) { ?>
|
||||||
<a href="<?php echo DOL_URL_ROOT.'/societe/rib.php?socid='.$this->control->tpl['id']; ?>"><?php echo $this->control->tpl['image_edit']; ?></a>
|
<a href="<?php echo DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$this->control->tpl['id']; ?>"><?php echo $this->control->tpl['image_edit']; ?></a>
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|||||||
@ -2037,7 +2037,7 @@ class Societe extends CommonObject
|
|||||||
else if ($option == 'ban')
|
else if ($option == 'ban')
|
||||||
{
|
{
|
||||||
$label.= '<u>' . $langs->trans("ShowBan") . '</u>';
|
$label.= '<u>' . $langs->trans("ShowBan") . '</u>';
|
||||||
$linkstart = '<a href="'.DOL_URL_ROOT.'/societe/rib.php?socid='.$this->id;
|
$linkstart = '<a href="'.DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// By default
|
// By default
|
||||||
|
|||||||
@ -23,9 +23,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file htdocs/societe/rib.php
|
* \file htdocs/societe/paymentmodes.php
|
||||||
* \ingroup societe
|
* \ingroup societe
|
||||||
* \brief BAN tab for companies
|
* \brief Tab of payment modes for the customer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require '../main.inc.php';
|
require '../main.inc.php';
|
||||||
@ -162,7 +162,7 @@ if (empty($reshook))
|
|||||||
$account->setAsDefault($id); // This will make sure there is only one default rib
|
$account->setAsDefault($id); // This will make sure there is only one default rib
|
||||||
}
|
}
|
||||||
|
|
||||||
$url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id;
|
$url=$_SERVER["PHP_SELF"].'?socid='.$object->id;
|
||||||
header('Location: '.$url);
|
header('Location: '.$url);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -261,7 +261,7 @@ if (empty($reshook))
|
|||||||
{
|
{
|
||||||
$db->commit();
|
$db->commit();
|
||||||
|
|
||||||
$url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id;
|
$url=$_SERVER["PHP_SELF"].'?socid='.$object->id;
|
||||||
header('Location: '.$url);
|
header('Location: '.$url);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -332,10 +332,14 @@ if (empty($reshook))
|
|||||||
$id = $savid;
|
$id = $savid;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (class_exists('Stripe'))
|
if (! empty($conf->stripe->enabled) && class_exists('Stripe'))
|
||||||
{
|
{
|
||||||
$stripe=new Stripe($db);
|
$stripe=new Stripe($db);
|
||||||
$customerstripe=$stripe->CustomerStripe($socid,$stripe->GetStripeAccount($conf->entity));
|
|
||||||
|
if (empty($conf->global->STRIPE_LIVE) || empty($conf->global->STRIPECONNECT_LIVE) || GETPOST('forcesandbox','alpha')) $service = 'StripeTest';
|
||||||
|
else $service = 'StripeLive';
|
||||||
|
|
||||||
|
$customerstripe=$stripe->customerStripe($socid, $stripe->getStripeAccount($service));
|
||||||
if ($customerstripe->id) {
|
if ($customerstripe->id) {
|
||||||
$cu = \Stripe\Customer::retrieve("".$customerstripe->id."");}
|
$cu = \Stripe\Customer::retrieve("".$customerstripe->id."");}
|
||||||
|
|
||||||
@ -381,14 +385,14 @@ if (empty($account->socid)) $account->socid=$object->id;
|
|||||||
|
|
||||||
if ($socid && $action == 'edit' && $user->rights->societe->creer)
|
if ($socid && $action == 'edit' && $user->rights->societe->creer)
|
||||||
{
|
{
|
||||||
print '<form action="rib.php?socid='.$object->id.'" method="post">';
|
print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="post">';
|
||||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
print '<input type="hidden" name="action" value="update">';
|
print '<input type="hidden" name="action" value="update">';
|
||||||
print '<input type="hidden" name="id" value="'.GETPOST("id","int").'">';
|
print '<input type="hidden" name="id" value="'.GETPOST("id","int").'">';
|
||||||
}
|
}
|
||||||
if ($socid && $action == 'create' && $user->rights->societe->creer)
|
if ($socid && $action == 'create' && $user->rights->societe->creer)
|
||||||
{
|
{
|
||||||
print '<form action="rib.php?socid='.$object->id.'" method="post">';
|
print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="post">';
|
||||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
print '<input type="hidden" name="action" value="add">';
|
print '<input type="hidden" name="action" value="add">';
|
||||||
}
|
}
|
||||||
@ -414,9 +418,12 @@ if ($socid && $action != 'edit' && $action != "create")
|
|||||||
{
|
{
|
||||||
print load_fiche_titre($langs->trans('StripeGateways'), '', '');
|
print load_fiche_titre($langs->trans('StripeGateways'), '', '');
|
||||||
|
|
||||||
if (is_object($stripe) && $stripe->GetStripeAccount($conf->entity))
|
if (empty($conf->global->STRIPE_LIVE) || empty($conf->global->STRIPECONNECT_LIVE) || GETPOST('forcesandbox','alpha')) $service = 'StripeTest';
|
||||||
|
else $service = 'StripeLive';
|
||||||
|
|
||||||
|
if (is_object($stripe) && $stripe->getStripeAccount($service))
|
||||||
{
|
{
|
||||||
$customerstripe=$stripe->CustomerStripe($object->id,$stripe->GetStripeAccount($conf->entity));
|
$customerstripe=$stripe->customerStripe($object->id,$stripe->getStripeAccount($service));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($customerstripe->id) {
|
if ($customerstripe->id) {
|
||||||
@ -538,7 +545,7 @@ if ($socid && $action != 'edit' && $action != "create")
|
|||||||
|
|
||||||
// List of bank accounts
|
// List of bank accounts
|
||||||
|
|
||||||
$morehtmlright='<a href="rib.php?socid='.$object->id.'&action=create">'.$langs->trans("Add").'</a>';
|
$morehtmlright='<a href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=create">'.$langs->trans("Add").'</a>';
|
||||||
|
|
||||||
print load_fiche_titre($langs->trans("AllRIB"), $morehtmlright, '');
|
print load_fiche_titre($langs->trans("AllRIB"), $morehtmlright, '');
|
||||||
|
|
||||||
@ -636,7 +643,7 @@ if ($socid && $action != 'edit' && $action != "create")
|
|||||||
// Default
|
// Default
|
||||||
print '<td align="center" width="70">';
|
print '<td align="center" width="70">';
|
||||||
if (!$rib->default_rib) {
|
if (!$rib->default_rib) {
|
||||||
print '<a href="'.DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id.'&ribid='.$rib->id.'&action=setasbankdefault">';
|
print '<a href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&ribid='.$rib->id.'&action=setasbankdefault">';
|
||||||
print img_picto($langs->trans("Disabled"),'off');
|
print img_picto($langs->trans("Disabled"),'off');
|
||||||
print '</a>';
|
print '</a>';
|
||||||
} else {
|
} else {
|
||||||
@ -704,13 +711,13 @@ if ($socid && $action != 'edit' && $action != "create")
|
|||||||
print '<td align="right">';
|
print '<td align="right">';
|
||||||
if ($user->rights->societe->creer)
|
if ($user->rights->societe->creer)
|
||||||
{
|
{
|
||||||
print '<a href="'.DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id.'&id='.$rib->id.'&action=edit">';
|
print '<a href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&id='.$rib->id.'&action=edit">';
|
||||||
print img_picto($langs->trans("Modify"),'edit');
|
print img_picto($langs->trans("Modify"),'edit');
|
||||||
print '</a>';
|
print '</a>';
|
||||||
|
|
||||||
print ' ';
|
print ' ';
|
||||||
|
|
||||||
print '<a href="'.DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id.'&id='.$rib->id.'&action=delete">';
|
print '<a href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&id='.$rib->id.'&action=delete">';
|
||||||
print img_picto($langs->trans("Delete"),'delete');
|
print img_picto($langs->trans("Delete"),'delete');
|
||||||
print '</a>';
|
print '</a>';
|
||||||
}
|
}
|
||||||
@ -741,7 +748,7 @@ if ($socid && $action != 'edit' && $action != "create")
|
|||||||
|
|
||||||
if ($user->rights->societe->creer)
|
if ($user->rights->societe->creer)
|
||||||
{
|
{
|
||||||
print '<a class="butAction" href="rib.php?socid='.$object->id.'&action=create">'.$langs->trans("Add").'</a>';
|
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=create">'.$langs->trans("Add").'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
@ -879,7 +886,7 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer)
|
|||||||
|
|
||||||
print '<tr><td>'.$langs->trans("WithdrawMode").'</td><td>';
|
print '<tr><td>'.$langs->trans("WithdrawMode").'</td><td>';
|
||||||
$tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR"));
|
$tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR"));
|
||||||
print $form->selectarray("frstrecur", $tblArraychoice, dol_escape_htmltag(GETPOST('frstrecur')?GETPOST('frstrecur'):$account->frstrecur), 0);
|
print $form->selectarray("frstrecur", $tblArraychoice, dol_escape_htmltag(GETPOST('frstrecur','alpha')?GETPOST('frstrecur','alpha'):$account->frstrecur), 0);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|||||||
@ -200,6 +200,7 @@ class Stripe extends CommonObject
|
|||||||
public function createPaymentStripe($amount, $currency, $origin, $item, $source, $customer, $account)
|
public function createPaymentStripe($amount, $currency, $origin, $item, $source, $customer, $account)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
if (empty($conf->global->STRIPECONNECT_LIVE)) {
|
if (empty($conf->global->STRIPECONNECT_LIVE)) {
|
||||||
$mode = 0;
|
$mode = 0;
|
||||||
} else {
|
} else {
|
||||||
@ -292,6 +293,9 @@ class Stripe extends CommonObject
|
|||||||
if (isset($charge->id)) {}
|
if (isset($charge->id)) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($conf->global->STRIPE_LIVE) || empty($conf->global->STRIPECONNECT_LIVE) || GETPOST('forcesandbox','alpha')) $service = 'StripeTest';
|
||||||
|
else $service = 'StripeLive';
|
||||||
|
|
||||||
$return->statut = 'success';
|
$return->statut = 'success';
|
||||||
$return->id = $charge->id;
|
$return->id = $charge->id;
|
||||||
if ($charge->source->type == 'card') {
|
if ($charge->source->type == 'card') {
|
||||||
@ -299,7 +303,7 @@ class Stripe extends CommonObject
|
|||||||
} elseif ($charge->source->type == 'three_d_secure') {
|
} elseif ($charge->source->type == 'three_d_secure') {
|
||||||
$stripe = new Stripe($this->db);
|
$stripe = new Stripe($this->db);
|
||||||
$src = \Stripe\Source::retrieve("" . $charge->source->three_d_secure->card . "", array(
|
$src = \Stripe\Source::retrieve("" . $charge->source->three_d_secure->card . "", array(
|
||||||
"stripe_account" => $stripe->getStripeAccount($conf->entity)
|
"stripe_account" => $stripe->getStripeAccount($service)
|
||||||
));
|
));
|
||||||
$return->message = $src->card->brand . " ****" . $src->card->last4;
|
$return->message = $src->card->brand . " ****" . $src->card->last4;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user