21 require
'../main.inc.php';
22 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
23 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
24 require_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
26 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
27 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
29 if (!empty($conf->accounting->enabled)) {
30 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
34 $langs->loadLangs(array(
'compta',
'salaries',
'bills',
'hrm',
'stripe'));
37 $socid =
GETPOST(
"socid",
"int");
39 $socid = $user->socid;
43 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
44 $rowid =
GETPOST(
"rowid",
'alpha');
45 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
46 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
48 if (empty($page) || $page == -1) {
51 $offset = $limit * $page;
52 $pageprev = $page - 1;
53 $pagenext = $page + 1;
56 $optioncss =
GETPOST(
'optioncss',
'alpha');
63 $societestatic =
new Societe($db);
68 llxHeader(
'', $langs->trans(
"StripeChargeList"));
70 if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) ||
GETPOST(
'forcesandbox',
'alpha'))) {
71 $service =
'StripeTest';
73 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Stripe'),
'',
'warning');
75 $service =
'StripeLive';
79 $stripeacc = $stripe->getStripeAccount($service);
86 $option = array(
'limit' => $limit + 1);
90 $option[
'starting_after'] =
GETPOST(
'starting_after_'.$page,
'alphanohtml');
95 $list = \Stripe\Charge::all($option, array(
"stripe_account" => $stripeacc));
97 $list = \Stripe\Charge::all($option);
100 $num = count($list->data);
102 $totalnboflines =
'';
106 if ($limit > 0 && $limit != $conf->liste_limit) {
107 $param .=
'&limit='.urlencode($limit);
109 $param .=
'&starting_after_'.($page + 1).
'='.$list->data[($limit - 1)]->id;
114 print $e->getMessage();
117 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
118 if ($optioncss !=
'') {
119 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
121 print
'<input type="hidden" name="token" value="'.newToken().
'">';
122 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
123 print
'<input type="hidden" name="action" value="list">';
124 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
125 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
126 print
'<input type="hidden" name="page" value="'.$page.
'">';
128 $title = $langs->trans(
"StripeChargeList");
129 $title .= ($stripeacc ?
' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.
')' :
' (Stripe connection with keys from Stripe module setup)');
131 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $totalnboflines,
'title_accountancy.png', 0,
'',
'hidepaginationprevious', $limit);
133 print
'<div class="div-table-responsive">';
134 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
136 print
'<tr class="liste_titre">';
141 print_liste_field_titre(
"DatePayment", $_SERVER[
"PHP_SELF"],
"",
"",
"",
'', $sortfield, $sortorder,
'center ');
149 foreach ($list->data as $charge) {
154 if ($charge->refunded ==
'1') {
155 $status =
img_picto($langs->trans(
"refunded"),
'statut6');
156 } elseif ($charge->paid ==
'1') {
157 $status =
img_picto($langs->trans((
string) $charge->status),
'statut4');
159 $label = $langs->trans(
"Message").
": ".$charge->failure_message.
"<br>";
160 $label .= $langs->trans(
"Network").
": ".$charge->outcome->network_status.
"<br>";
161 $label .= $langs->trans(
"Status").
": ".$langs->trans((
string) $charge->outcome->seller_message);
162 $status =
$form->textwithpicto(
img_picto($langs->trans((
string) $charge->status),
'statut8'), $label, -1);
165 if (isset($charge->payment_method_details->type) && $charge->payment_method_details->type ==
'card') {
166 $type = $langs->trans(
"card");
167 } elseif (isset($charge->source->type) && $charge->source->type ==
'card') {
168 $type = $langs->trans(
"card");
169 } elseif (isset($charge->payment_method_details->type) && $charge->payment_method_details->type ==
'three_d_secure') {
170 $type = $langs->trans(
"card3DS");
171 } elseif (isset($charge->payment_method_details->type) && $charge->payment_method_details->type ==
'sepa_debit') {
172 $type = $langs->trans(
"sepadebit");
173 } elseif (isset($charge->payment_method_details->type) && $charge->payment_method_details->type ==
'ideal') {
174 $type = $langs->trans(
"iDEAL");
187 $FULLTAG = $charge->metadata->FULLTAG;
192 if (!empty($tmparray[
'CUS']) && $tmparray[
'CUS'] > 0) {
193 $societestatic->fetch($tmparray[
'CUS']);
194 } elseif (!empty($charge->metadata->dol_thirdparty_id) && $charge->metadata->dol_thirdparty_id > 0) {
195 $societestatic->fetch($charge->metadata->dol_thirdparty_id);
197 $societestatic->id = 0;
199 if (!empty($tmparray[
'MEM']) && $tmparray[
'MEM'] > 0) {
200 $memberstatic->fetch($tmparray[
'MEM']);
202 $memberstatic->id = 0;
205 print
'<tr class="oddeven">';
207 if (!empty($stripeacc)) {
208 $connect = $stripeacc.
'/';
214 $url =
'https://dashboard.stripe.com/'.$connect.
'test/payments/'.$charge->id;
215 if ($servicestatus) {
216 $url =
'https://dashboard.stripe.com/'.$connect.
'payments/'.$charge->id;
219 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
" ".$charge->id.
"</a>";
220 if ($charge->payment_intent) {
221 print
'<br><span class="opacitymedium">'.$charge->payment_intent.
'</span>';
227 if (!empty($conf->stripe->enabled) && !empty($stripeacc)) {
228 $connect = $stripeacc.
'/';
230 $url =
'https://dashboard.stripe.com/'.$connect.
'test/customers/'.$charge->customer;
231 if ($servicestatus) {
232 $url =
'https://dashboard.stripe.com/'.$connect.
'customers/'.$charge->customer;
234 if (!empty($charge->customer)) {
235 print
'<a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe'),
'globe').
' '.$charge->customer.
'</a>';
241 if ($societestatic->id > 0) {
242 print $societestatic->getNomUrl(1);
243 } elseif ($memberstatic->id > 0) {
244 print $memberstatic->getNomUrl(1);
250 if ($charge->metadata->dol_type ==
"order" || $charge->metadata->dol_type ==
"commande") {
252 $object->fetch($charge->metadata->dol_id);
253 if ($object->id > 0) {
254 print
"<a href='".DOL_URL_ROOT.
"/commande/card.php?id=".$object->id.
"'>".
img_picto(
'',
'order').
" ".$object->ref.
"</a>";
258 } elseif ($charge->metadata->dol_type ==
"invoice" || $charge->metadata->dol_type ==
"facture") {
260 $object->fetch($charge->metadata->dol_id);
261 if ($object->id > 0) {
262 print
"<a href='".DOL_URL_ROOT.
"/compta/facture/card.php?facid=".$charge->metadata->dol_id.
"'>".
img_picto(
'',
'bill').
" ".$object->ref.
"</a>";
272 print
'<td class="center">'.dol_print_date($charge->created,
'dayhour').
"</td>\n";
278 print
'<td class="right"><span class="amount">'.price(($charge->amount - $charge->amount_refunded) / 100, 0,
'', 1, - 1, - 1, strtoupper($charge->currency)).
"</span></td>";
280 print
'<td class="right">';