NEW Can enter and edit stripe credit card using the Stripe card ID
This commit is contained in:
parent
aa13eb7ac4
commit
52767c4324
@ -162,6 +162,7 @@ class CompanyPaymentMode extends CommonObject
|
|||||||
public $preapproval_key;
|
public $preapproval_key;
|
||||||
public $total_amount_of_all_payments;
|
public $total_amount_of_all_payments;
|
||||||
public $stripe_card_ref;
|
public $stripe_card_ref;
|
||||||
|
public $stripe_account;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int Status
|
* @var int Status
|
||||||
|
|||||||
@ -194,13 +194,13 @@ if (empty($reshook))
|
|||||||
if ($action == 'updatecard')
|
if ($action == 'updatecard')
|
||||||
{
|
{
|
||||||
// Modification
|
// Modification
|
||||||
if (!GETPOST('label', 'alpha') || !GETPOST('proprio', 'alpha') || !GETPOST('cardnumber', 'alpha') || !GETPOST('exp_date_month', 'alpha') || !GETPOST('exp_date_year', 'alpha') || !GETPOST('cvn', 'alpha'))
|
if (!GETPOST('label', 'alpha') || !GETPOST('proprio', 'alpha') || !GETPOST('exp_date_month', 'alpha') || !GETPOST('exp_date_year', 'alpha'))
|
||||||
{
|
{
|
||||||
if (!GETPOST('label', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
|
if (!GETPOST('label', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
|
||||||
if (!GETPOST('proprio', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors');
|
if (!GETPOST('proprio', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors');
|
||||||
if (!GETPOST('cardnumber', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors');
|
//if (!GETPOST('cardnumber', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors');
|
||||||
if (!(GETPOST('exp_date_month', 'alpha') > 0) || !(GETPOST('exp_date_year', 'alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors');
|
if (!(GETPOST('exp_date_month', 'alpha') > 0) || !(GETPOST('exp_date_year', 'alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors');
|
||||||
if (!GETPOST('cvn', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors');
|
//if (!GETPOST('cvn', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors');
|
||||||
$action = 'createcard';
|
$action = 'createcard';
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
@ -220,6 +220,10 @@ if (empty($reshook))
|
|||||||
$companypaymentmode->cvn = GETPOST('cvn', 'alpha');
|
$companypaymentmode->cvn = GETPOST('cvn', 'alpha');
|
||||||
$companypaymentmode->country_code = $object->country_code;
|
$companypaymentmode->country_code = $object->country_code;
|
||||||
|
|
||||||
|
if (GETPOST('stripe_card_ref', 'alpha') && GETPOST('stripe_card_ref', 'alpha') != $companypaymentmode->stripe_card_ref) {
|
||||||
|
// If we set a stripe value that is different than previous one, we also set the stripe account
|
||||||
|
$companypaymentmode->stripe_account = $site_account;
|
||||||
|
}
|
||||||
$companypaymentmode->stripe_card_ref = GETPOST('stripe_card_ref', 'alpha');
|
$companypaymentmode->stripe_card_ref = GETPOST('stripe_card_ref', 'alpha');
|
||||||
|
|
||||||
$result = $companypaymentmode->update($user);
|
$result = $companypaymentmode->update($user);
|
||||||
@ -346,13 +350,13 @@ if (empty($reshook))
|
|||||||
{
|
{
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
if (!GETPOST('label', 'alpha') || !GETPOST('proprio', 'alpha') || !GETPOST('cardnumber', 'alpha') || !GETPOST('exp_date_month', 'alpha') || !GETPOST('exp_date_year', 'alpha') || !GETPOST('cvn', 'alpha'))
|
if (!GETPOST('label', 'alpha') || !GETPOST('proprio', 'alpha') || !GETPOST('exp_date_month', 'alpha') || !GETPOST('exp_date_year', 'alpha'))
|
||||||
{
|
{
|
||||||
if (!GETPOST('label', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
|
if (!GETPOST('label', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
|
||||||
if (!GETPOST('proprio', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors');
|
if (!GETPOST('proprio', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors');
|
||||||
if (!GETPOST('cardnumber', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors');
|
//if (!GETPOST('cardnumber', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors');
|
||||||
if (!(GETPOST('exp_date_month', 'alpha') > 0) || !(GETPOST('exp_date_year', 'alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors');
|
if (!(GETPOST('exp_date_month', 'alpha') > 0) || !(GETPOST('exp_date_year', 'alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors');
|
||||||
if (!GETPOST('cvn', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors');
|
//if (!GETPOST('cvn', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors');
|
||||||
$action = 'createcard';
|
$action = 'createcard';
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
@ -377,6 +381,10 @@ if (empty($reshook))
|
|||||||
$companypaymentmode->country_code = $object->country_code;
|
$companypaymentmode->country_code = $object->country_code;
|
||||||
$companypaymentmode->status = $servicestatus;
|
$companypaymentmode->status = $servicestatus;
|
||||||
|
|
||||||
|
if (GETPOST('stripe_card_ref', 'alpha')) {
|
||||||
|
// If we set a stripe value, we also set the stripe account
|
||||||
|
$companypaymentmode->stripe_account = $site_account;
|
||||||
|
}
|
||||||
$companypaymentmode->stripe_card_ref = GETPOST('stripe_card_ref', 'alpha');
|
$companypaymentmode->stripe_card_ref = GETPOST('stripe_card_ref', 'alpha');
|
||||||
|
|
||||||
$db->begin();
|
$db->begin();
|
||||||
@ -1615,7 +1623,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
|
|||||||
// Edit BAN
|
// Edit BAN
|
||||||
if ($socid && $action == 'edit' && $user->rights->societe->creer)
|
if ($socid && $action == 'edit' && $user->rights->societe->creer)
|
||||||
{
|
{
|
||||||
dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), -1, 'company');
|
dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company');
|
||||||
|
|
||||||
$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||||
|
|
||||||
@ -1721,7 +1729,7 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer)
|
|||||||
// Edit Card
|
// Edit Card
|
||||||
if ($socid && $action == 'editcard' && $user->rights->societe->creer)
|
if ($socid && $action == 'editcard' && $user->rights->societe->creer)
|
||||||
{
|
{
|
||||||
dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), -1, 'company');
|
dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company');
|
||||||
|
|
||||||
$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||||
|
|
||||||
@ -1738,7 +1746,7 @@ if ($socid && $action == 'editcard' && $user->rights->societe->creer)
|
|||||||
print '<tr><td class="fieldrequired">'.$langs->trans("NameOnCard").'</td>';
|
print '<tr><td class="fieldrequired">'.$langs->trans("NameOnCard").'</td>';
|
||||||
print '<td><input class="minwidth200" type="text" name="proprio" value="'.$companypaymentmode->proprio.'"></td></tr>';
|
print '<td><input class="minwidth200" type="text" name="proprio" value="'.$companypaymentmode->proprio.'"></td></tr>';
|
||||||
|
|
||||||
print '<tr><td class="fieldrequired">'.$langs->trans("CardNumber").'</td>';
|
print '<tr><td>'.$langs->trans("CardNumber").'</td>';
|
||||||
print '<td><input class="minwidth200" type="text" name="cardnumber" value="'.$companypaymentmode->number.'"></td></tr>';
|
print '<td><input class="minwidth200" type="text" name="cardnumber" value="'.$companypaymentmode->number.'"></td></tr>';
|
||||||
|
|
||||||
print '<tr><td class="fieldrequired">'.$langs->trans("ExpiryDate").'</td>';
|
print '<tr><td class="fieldrequired">'.$langs->trans("ExpiryDate").'</td>';
|
||||||
@ -1747,7 +1755,7 @@ if ($socid && $action == 'editcard' && $user->rights->societe->creer)
|
|||||||
print $formother->select_year($companypaymentmode->exp_date_year, 'exp_date_year', 1, 5, 10, 0, 0, '', 'marginleftonly');
|
print $formother->select_year($companypaymentmode->exp_date_year, 'exp_date_year', 1, 5, 10, 0, 0, '', 'marginleftonly');
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
print '<tr><td class="fieldrequired">'.$langs->trans("CVN").'</td>';
|
print '<tr><td>'.$langs->trans("CVN").'</td>';
|
||||||
print '<td><input size="8" type="text" name="cvn" value="'.$companypaymentmode->cvn.'"></td></tr>';
|
print '<td><input size="8" type="text" name="cvn" value="'.$companypaymentmode->cvn.'"></td></tr>';
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("StripeID")." ('card_....')</td>";
|
print '<tr><td>'.$langs->trans("StripeID")." ('card_....')</td>";
|
||||||
@ -1769,7 +1777,7 @@ if ($socid && $action == 'editcard' && $user->rights->societe->creer)
|
|||||||
// Create BAN
|
// Create BAN
|
||||||
if ($socid && $action == 'create' && $user->rights->societe->creer)
|
if ($socid && $action == 'create' && $user->rights->societe->creer)
|
||||||
{
|
{
|
||||||
dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), -1, 'company');
|
dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company');
|
||||||
|
|
||||||
$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||||
|
|
||||||
@ -1869,7 +1877,7 @@ if ($socid && $action == 'create' && $user->rights->societe->creer)
|
|||||||
// Create Card
|
// Create Card
|
||||||
if ($socid && $action == 'createcard' && $user->rights->societe->creer)
|
if ($socid && $action == 'createcard' && $user->rights->societe->creer)
|
||||||
{
|
{
|
||||||
dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), -1, 'company');
|
dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company');
|
||||||
|
|
||||||
$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||||
|
|
||||||
@ -1886,7 +1894,7 @@ if ($socid && $action == 'createcard' && $user->rights->societe->creer)
|
|||||||
print '<tr><td class="fieldrequired">'.$langs->trans("NameOnCard").'</td>';
|
print '<tr><td class="fieldrequired">'.$langs->trans("NameOnCard").'</td>';
|
||||||
print '<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST('proprio', 'alpha').'"></td></tr>';
|
print '<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST('proprio', 'alpha').'"></td></tr>';
|
||||||
|
|
||||||
print '<tr><td class="fieldrequired">'.$langs->trans("CardNumber").'</td>';
|
print '<tr><td>'.$langs->trans("CardNumber").'</td>';
|
||||||
print '<td><input class="minwidth200" type="text" name="cardnumber" value="'.GETPOST('cardnumber', 'alpha').'"></td></tr>';
|
print '<td><input class="minwidth200" type="text" name="cardnumber" value="'.GETPOST('cardnumber', 'alpha').'"></td></tr>';
|
||||||
|
|
||||||
print '<tr><td class="fieldrequired">'.$langs->trans("ExpiryDate").'</td>';
|
print '<tr><td class="fieldrequired">'.$langs->trans("ExpiryDate").'</td>';
|
||||||
@ -1895,8 +1903,8 @@ if ($socid && $action == 'createcard' && $user->rights->societe->creer)
|
|||||||
print $formother->select_year(GETPOST('exp_date_year', 'int'), 'exp_date_year', 1, 5, 10, 0, 0, '', 'marginleftonly');
|
print $formother->select_year(GETPOST('exp_date_year', 'int'), 'exp_date_year', 1, 5, 10, 0, 0, '', 'marginleftonly');
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
print '<tr><td class="fieldrequired">'.$langs->trans("CVN").'</td>';
|
print '<tr><td>'.$langs->trans("CVN").'</td>';
|
||||||
print '<td><input size="8" type="text" name="cvn" value="'.GETPOST('cvn', 'alpha').'"></td></tr>';
|
print '<td><input class="width50" type="text" name="cvn" value="'.GETPOST('cvn', 'alpha').'"></td></tr>';
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("StripeID")." ('card_....')</td>";
|
print '<tr><td>'.$langs->trans("StripeID")." ('card_....')</td>";
|
||||||
print '<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST('stripe_card_ref', 'alpha').'"></td></tr>';
|
print '<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST('stripe_card_ref', 'alpha').'"></td></tr>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user