Add the external system payment name in list of fields for payment modes

This commit is contained in:
Laurent Destailleur 2023-08-22 11:14:40 +02:00
parent b372286188
commit 30892b7bae
2 changed files with 37 additions and 29 deletions

View File

@ -114,8 +114,9 @@ class CompanyPaymentMode extends CommonObject
'max_total_amount_of_all_payments' =>array('type'=>'double(24,8)', 'label'=>'Max total amount of all payments', 'enabled'=>1, 'visible'=>-2, 'position'=>155),
'preapproval_key' =>array('type'=>'varchar(255)', 'label'=>'Preapproval key', 'enabled'=>1, 'visible'=>-2, 'position'=>160),
'total_amount_of_all_payments' =>array('type'=>'double(24,8)', 'label'=>'Total amount of all payments', 'enabled'=>1, 'visible'=>-2, 'position'=>165),
'stripe_card_ref' =>array('type'=>'varchar(128)', 'label'=>'Stripe card ref', 'enabled'=>1, 'visible'=>-2, 'position'=>170),
'stripe_account' =>array('type'=>'varchar(128)', 'label'=>'Stripe account', 'enabled'=>1, 'visible'=>-2, 'position'=>171),
'stripe_card_ref' =>array('type'=>'varchar(128)', 'label'=>'ExternalSystemID', 'enabled'=>1, 'visible'=>-2, 'position'=>170, 'help'=>'IDOfPaymentInAnExternalSystem'),
'stripe_account' =>array('type'=>'varchar(128)', 'label'=>'ExternalSystemCustomerAccount', 'enabled'=>1, 'visible'=>-2, 'position'=>171, 'help'=>'IDOfCustomerInAnExternalSystem'),
'ext_payment_site' =>array('type'=>'varchar(128)', 'label'=>'ExternalSystem', 'enabled'=>1, 'visible'=>-2, 'position'=>172, 'help'=>'NameOfExternalSystem'),
'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>175),
'starting_date' =>array('type'=>'date', 'label'=>'Starting date', 'enabled'=>1, 'visible'=>-2, 'position'=>180),
'ending_date' =>array('type'=>'date', 'label'=>'Ending date', 'enabled'=>1, 'visible'=>-2, 'position'=>185),
@ -178,8 +179,9 @@ class CompanyPaymentMode extends CommonObject
public $max_total_amount_of_all_payments;
public $preapproval_key;
public $total_amount_of_all_payments;
public $stripe_card_ref;
public $stripe_account;
public $stripe_card_ref; // External system payment mode ID
public $stripe_account; // External system customer ID
public $ext_payment_site; // External system 'StripeLive', 'StripeTest', 'StancerLive', 'StancerTest', ...
/**
* @var int Status

View File

@ -1227,18 +1227,22 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companypaymentmodetemp->label).'">';
print dol_escape_htmltag($companypaymentmodetemp->label);
print '</td>';
// External card ID
print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companypaymentmodetemp->stripe_card_ref.' - Customer and Publishable key = '.$companypaymentmodetemp->stripe_account).'">';
if (!empty($companypaymentmodetemp->stripe_card_ref)) {
$connect = '';
if (!empty($stripeacc)) {
$connect = $stripeacc.'/';
// External system card ID
print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companypaymentmodetemp->stripe_card_ref.(empty($companypaymentmodetemp->stripe_account) ? '' : ' - '.$companypaymentmodetemp->stripe_account)).'">';
if (!empty($companypaymentmodetemp->stripe_card_ref) && !empty($companypaymentmodetemp->ext_payment_site)) {
if (isModEnabled('stripe') && in_array($companypaymentmodetemp->ext_payment_site, array('StripeTest', 'StripeLive'))) {
$connect = '';
if (!empty($stripeacc)) {
$connect = $stripeacc.'/';
}
if ($rib->ext_payment_site == 'StripeLive') {
$url = 'https://dashboard.stripe.com/'.$connect.'search?query='.$companypaymentmodetemp->stripe_card_ref;
} else {
$url = 'https://dashboard.stripe.com/'.$connect.'test/search?query='.$companypaymentmodetemp->stripe_card_ref;
}
print "<a href='".$url."' target='_stripe'>".img_picto($langs->trans('ShowInStripe').' - '.$companypaymentmodetemp->stripe_account, 'globe')."</a> ";
}
$url = 'https://dashboard.stripe.com/'.$connect.'test/search?query='.$companypaymentmodetemp->stripe_card_ref;
if ($servicestatus) {
$url = 'https://dashboard.stripe.com/'.$connect.'search?query='.$companypaymentmodetemp->stripe_card_ref;
}
print '<a href="'.$url.'" target="_stripe">'.img_picto($langs->trans('ShowInStripe').' - Customer and Publishable key = '.$companypaymentmodetemp->stripe_account, 'globe').'</a> ';
// TODO Add hook here for other payment services
}
print dol_escape_htmltag($companypaymentmodetemp->stripe_card_ref);
print '</td>';
@ -1559,22 +1563,24 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
print '<tr class="oddeven">';
// Label
print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($rib->label).'">'.dol_escape_htmltag($rib->label).'</td>';
// Stripe ID
print '<td class="tdoverflowmax150">';
if ($rib->stripe_card_ref) {
$connect = '';
if (!empty($stripeacc)) {
$connect = $stripeacc.'/';
// External system ID
print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($rib->stripe_card_ref.(empty($rib->stripe_account) ? '' : ' - '.$rib->stripe_account)).'">';
if (!empty($rib->stripe_card_ref) && !empty($rib->ext_payment_site)) {
if (isModEnabled('stripe') && in_array($rib->ext_payment_site, array('StripeTest', 'StripeLive'))) {
$connect = '';
if (!empty($stripeacc)) {
$connect = $stripeacc.'/';
}
if ($rib->ext_payment_site == 'StripeLive') {
$url = 'https://dashboard.stripe.com/'.$connect.'search?query='.$rib->stripe_card_ref;
} else {
$url = 'https://dashboard.stripe.com/'.$connect.'test/search?query='.$rib->stripe_card_ref;
}
print "<a href='".$url."' target='_stripe'>".img_picto($langs->trans('ShowInStripe'), 'globe')."</a> ";
}
//$url='https://dashboard.stripe.com/'.$connect.'test/sources/'.$src->id;
$url = 'https://dashboard.stripe.com/'.$connect.'test/search?query='.$rib->stripe_card_ref;
if ($servicestatus) {
//$url='https://dashboard.stripe.com/'.$connect.'sources/'.$src->id;
$url = 'https://dashboard.stripe.com/'.$connect.'search?query='.$rib->stripe_card_ref;
}
print "<a href='".$url."' target='_stripe'>".img_picto($langs->trans('ShowInStripe'), 'globe')."</a> ";
// TODO Add hook here for other payment services
}
print $rib->stripe_card_ref;
print dol_escape_htmltag($rib->stripe_card_ref);
print '</td>';
// Bank name
print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($rib->bank).'">'.dol_escape_htmltag($rib->bank).'</td>';