24require
'../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
44$langs->loadLangs(array(
'compta',
'salaries',
'bills',
'hrm',
'stripe'));
49 $socid = $user->socid;
54$rowid =
GETPOST(
"rowid",
'alpha');
55$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
56$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
58if (empty($page) || $page == -1) {
61$offset = $limit * $page;
66$optioncss =
GETPOST(
'optioncss',
'alpha');
74$societestatic =
new Societe($db);
79llxHeader(
'', $langs->trans(
"StripeChargeList"));
82 $service =
'StripeTest';
84 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Stripe'), [],
'warning');
86 $service =
'StripeLive';
90$stripeacc = $stripe->getStripeAccount($service);
97 $option = array(
'limit' => $limit + 1);
101 $totalnboflines =
'';
105 $option[
'starting_after'] =
GETPOST(
'starting_after_'.$page,
'alphanohtml');
107 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
108 if ($optioncss !=
'') {
109 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
112 print
'<input type="hidden" name="token" value="'.newToken().
'">';
113 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
114 print
'<input type="hidden" name="action" value="list">';
115 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
116 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
117 print
'<input type="hidden" name="page" value="'.$page.
'">';
119 $title = $langs->trans(
"StripeChargeList");
120 $title .= $form->textwithpicto(
'', $stripeacc ?
' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.
')' :
' (Stripe connection with keys from Stripe module setup)');
122 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $totalnboflines,
'title_accountancy.png', 0,
'',
'hidepaginationprevious', $limit);
124 $hookmanager->initHooks(array(
'stripechargelist'));
126 print
'<div class="div-table-responsive">';
127 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
129 print
'<tr class="liste_titre">';
135 print_liste_field_titre(
"DatePayment", $_SERVER[
"PHP_SELF"],
"",
"",
"",
'', $sortfield, $sortorder,
'center ');
143 $list = \Stripe\Charge::all($option, array(
"stripe_account" => $stripeacc));
145 $list = \Stripe\Charge::all($option);
148 '@phan-var-force \Stripe\Charge $list';
149 $num = count($list->data);
153 if ($limit > 0 && $limit !=
$conf->liste_limit) {
154 $param .=
'&limit='.((int) $limit);
156 $param .=
'&starting_after_'.($page + 1).
'='.$list->data[($limit - 1)]->id;
159 print
'<tr><td colspan="9">'.$e->getMessage().
'</td></td>';
165 foreach ($list->data as $charge) {
166 '@phan-var-force \Stripe\Charge $charge';
172 if ($charge->refunded ==
'1') {
173 $status = img_picto($langs->trans(
"refunded"),
'statut6');
174 } elseif ($charge->paid ==
'1') {
175 $status = img_picto($langs->trans((
string) $charge->status),
'statut4');
176 } elseif (empty($charge->failure_message)) {
177 $label .= $langs->trans(
"Network").
": ".$charge->outcome->network_status.
"<br>";
178 $label .= $langs->trans(
"Status").
": ".$langs->trans((
string) $charge->outcome->seller_message);
179 $status = $form->textwithpicto(img_picto($langs->trans((
string) $charge->status),
'statut4'), $label, 1);
181 $label .= $langs->trans(
"Error").
": ".$charge->failure_message.
"<br>";
182 $label .= $langs->trans(
"Network").
": ".$charge->outcome->network_status.
"<br>";
183 $label .= $langs->trans(
"Status").
": ".$langs->trans((
string) $charge->outcome->seller_message);
184 $status = $form->textwithpicto(img_picto($langs->trans((
string) $charge->status),
'statut8'), $label, 1);
187 if (isset($charge->payment_method_details->type) && $charge->payment_method_details->type ==
'card') {
188 $type = $langs->trans(
"card");
189 } elseif (isset($charge->source->type) && $charge->source->type ==
'card') {
190 $type = $langs->trans(
"card");
191 } elseif (isset($charge->payment_method_details->type) && $charge->payment_method_details->type ==
'three_d_secure') {
192 $type = $langs->trans(
"card3DS");
193 } elseif (isset($charge->payment_method_details->type) && $charge->payment_method_details->type ==
'sepa_debit') {
194 $type = $langs->trans(
"sepadebit");
195 } elseif (isset($charge->payment_method_details->type) && $charge->payment_method_details->type ==
'ideal') {
196 $type = $langs->trans(
"iDEAL");
211 $FULLTAG = $charge->metadata->FULLTAG;
216 if (!empty($tmparray[
'CUS']) && (
int) $tmparray[
'CUS'] > 0) {
217 $societestatic->fetch((
int) $tmparray[
'CUS']);
218 } elseif (!empty($charge->metadata->dol_thirdparty_id) && $charge->metadata->dol_thirdparty_id > 0) {
219 $societestatic->fetch($charge->metadata->dol_thirdparty_id);
221 $societestatic->id = 0;
223 if (!empty($tmparray[
'MEM']) && (
int) $tmparray[
'MEM'] > 0) {
224 $memberstatic->fetch((
int) $tmparray[
'MEM']);
226 $memberstatic->id = 0;
229 print
'<tr class="oddeven">';
231 if (!empty($stripeacc)) {
232 $connect = $stripeacc.
'/';
238 $url =
'https://dashboard.stripe.com/'.$connect.
'test/payments/'.$charge->id;
239 if ($servicestatus) {
240 $url =
'https://dashboard.stripe.com/'.$connect.
'payments/'.$charge->id;
242 print
'<td class="tdoverflowmax150">';
243 print
"<a href='".$url.
"' target='_stripe'>".img_picto($langs->trans(
'ShowInStripe'),
'globe').
" ".$charge->id.
"</a>";
244 if ($charge->payment_intent) {
245 print
'<br><span class="opacitymedium">'.$charge->payment_intent.
'</span>';
250 print
'<td class="tdoverflowmax150">';
252 $connect = $stripeacc.
'/';
254 $url =
'https://dashboard.stripe.com/'.$connect.
'test/customers/'.$charge->customer;
255 if ($servicestatus) {
256 $url =
'https://dashboard.stripe.com/'.$connect.
'customers/'.$charge->customer;
258 if (!empty($charge->customer)) {
259 print
'<a href="'.$url.
'" target="_stripe">'.img_picto($langs->trans(
'ShowInStripe'),
'globe').
' '.$charge->customer.
'</a>';
264 print
'<td class="tdoverflowmax200">';
266 $parameters = array(
'charge' => $charge,
'field' =>
'customer');
267 $reshook = $hookmanager->executeHooks(
'printStripeChargeField', $parameters);
268 print $hookmanager->resPrint;
270 if ($societestatic->id > 0) {
271 print $societestatic->getNomUrl(1);
272 } elseif ($memberstatic->id > 0) {
273 print $memberstatic->getNomUrl(1);
279 print
'<td class="nowraponall">';
280 $parameters = array(
'charge' => $charge,
'field' =>
'origin');
281 $reshook = $hookmanager->executeHooks(
'printStripeChargeField', $parameters);
282 print $hookmanager->resPrint;
284 if ($charge->metadata->dol_type ==
"order" || $charge->metadata->dol_type ==
"commande") {
286 $object->fetch($charge->metadata->dol_id);
288 print
"<a href='".DOL_URL_ROOT.
"/commande/card.php?id=".
$object->id.
"'>".img_picto(
'',
'order').
" ".
$object->ref.
"</a>";
292 } elseif ($charge->metadata->dol_type ==
"invoice" || $charge->metadata->dol_type ==
"facture") {
294 $object->fetch($charge->metadata->dol_id);
296 print
"<a href='".DOL_URL_ROOT.
"/compta/facture/card.php?facid=".$charge->metadata->dol_id.
"'>".img_picto(
'',
'bill').
" ".
$object->ref.
"</a>";
307 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($charge->description).
'">'.
dol_escape_htmltag($charge->description).
'</td>'.
"\n";
310 print
'<td class="center nowraponall">'.dol_print_date($charge->created,
'dayhour').
"</td>\n";
316 print
'<td class="right"><span class="amount">'.price(($charge->amount - $charge->amount_refunded) / 100, 0,
'', 1, - 1, - 1, strtoupper($charge->currency)).
"</span></td>";
318 print
'<td class="nowraponall center">';
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage bank accounts.
Class to manage members of a foundation.
Class to manage customers orders.
Class to manage invoices.
Class to manage third parties objects (customers, suppliers, prospects...)
Stripe class @TODO No reason to extend CommonObject.
dolExplodeIntoArray($string, $delimiter=';', $kv='=')
Split a string with 2 keys into key array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formatted messages to output (Used to show messages on html output).
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.