Fix error management in Stripe

This commit is contained in:
Laurent Destailleur 2020-09-24 21:54:21 +02:00
parent bc7b5b1468
commit 6e2a9dc0c9
7 changed files with 415 additions and 383 deletions

View File

@ -39,6 +39,8 @@ if (!empty($conf->commande->enabled))
{
$langs->load("orders");
print '<form action="'.$_SERVER["PHP_SELF"].'#order" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print $langs->trans("EnterRefToBuildUrl", $langs->transnoentitiesnoconv("Order")).': ';
print '<input type="text class="flat" id="generate_order_ref" name="generate_order_ref" value="'.GETPOST('generate_order_ref', 'alpha').'" size="10">';
print '<input type="submit" class="none button" value="'.$langs->trans("GetSecuredUrl").'">';
@ -62,6 +64,8 @@ if (!empty($conf->facture->enabled))
{
$langs->load("bills");
print '<form action="'.$_SERVER["PHP_SELF"].'#invoice" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print $langs->trans("EnterRefToBuildUrl", $langs->transnoentitiesnoconv("Invoice")).': ';
print '<input type="text class="flat" id="generate_invoice_ref" name="generate_invoice_ref" value="'.GETPOST('generate_invoice_ref', 'alpha').'" size="10">';
print '<input type="submit" class="none button" value="'.$langs->trans("GetSecuredUrl").'">';
@ -85,6 +89,8 @@ if (!empty($conf->contrat->enabled))
{
$langs->load("contracts");
print '<form action="'.$_SERVER["PHP_SELF"].'#contractline" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print $langs->trans("EnterRefToBuildUrl", $langs->transnoentitiesnoconv("ContractLine")).': ';
print '<input type="text class="flat" id="generate_contract_ref" name="generate_contract_ref" value="'.GETPOST('generate_contract_ref', 'alpha').'" size="10">';
print '<input type="submit" class="none button" value="'.$langs->trans("GetSecuredUrl").'">';
@ -108,6 +114,8 @@ if (!empty($conf->adherent->enabled))
{
$langs->load("members");
print '<form action="'.$_SERVER["PHP_SELF"].'#membersubscription" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print $langs->trans("EnterRefToBuildUrl", $langs->transnoentitiesnoconv("Member")).': ';
print '<input type="text class="flat" id="generate_member_ref" name="generate_member_ref" value="'.GETPOST('generate_member_ref', 'alpha').'" size="10">';
print '<input type="submit" class="none reposition button" value="'.$langs->trans("GetSecuredUrl").'">';
@ -131,6 +139,8 @@ if (!empty($conf->don->enabled))
{
$langs->load("members");
print '<form action="'.$_SERVER["PHP_SELF"].'#donation" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print $langs->trans("EnterRefToBuildUrl", $langs->transnoentitiesnoconv("Don")).': ';
print '<input type="text class="flat" id="generate_donation_ref" name="generate_donation_ref" value="'.GETPOST('generate_donation_ref', 'alpha').'" size="10">';
print '<input type="submit" class="none reposition button" value="'.$langs->trans("GetSecuredUrl").'">';

View File

@ -110,7 +110,7 @@ $head[$h][1] = $langs->trans("PayBox");
$head[$h][2] = 'payboxaccount';
$h++;
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setvalue">';

View File

@ -157,7 +157,7 @@ print load_fiche_titre($langs->trans("ModuleSetup").' Stripe', $linkback);
$head = stripeadmin_prepare_head();
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setvalue">';

View File

@ -79,195 +79,207 @@ $stripeacc = $stripe->getStripeAccount($service);
if (!$rowid)
{
$option = array('limit' => $limit + 1);
$num = 0;
if (GETPOSTISSET('starting_after_'.$page)) $option['starting_after'] = GETPOST('starting_after_'.$page, 'alphanohtml');
if ($stripeacc)
{
$list = \Stripe\Charge::all($option, array("stripe_account" => $stripeacc));
} else {
$list = \Stripe\Charge::all($option);
}
$num = count($list->data);
$totalnboflines = '';
$param = '';
//if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
$param .= '&starting_after_'.($page + 1).'='.$list->data[($limit - 1)]->id;
//$param.='&ending_before_'.($page+1).'='.$list->data[($limit-1)]->id;
$moreforfilter = '';
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
$title = $langs->trans("StripeChargeList");
$title .= ($stripeacc ? ' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)');
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'title_accountancy.png', 0, '', 'hidepaginationprevious', $limit);
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
print '<tr class="liste_titre">';
print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder);
print_liste_field_titre("StripeCustomerId", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder);
print_liste_field_titre("Customer", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder);
print_liste_field_titre("Origin", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder);
print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "", "", "", '', $sortfield, $sortorder, 'center ');
print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "", "", "", '', $sortfield, $sortorder, 'left ');
print_liste_field_titre("Paid", $_SERVER["PHP_SELF"], "", "", "", '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "", "", "", '', '', '', 'right ');
print "</tr>\n";
//print $list;
$i = 0;
foreach ($list->data as $charge)
{
if ($i >= $limit) {
break;
}
if ($charge->refunded == '1') {
$status = img_picto($langs->trans("refunded"), 'statut6');
} elseif ($charge->paid == '1') {
$status = img_picto($langs->trans((string) $charge->status), 'statut4');
} else {
$label = $langs->trans("Message").": ".$charge->failure_message."<br>";
$label .= $langs->trans("Network").": ".$charge->outcome->network_status."<br>";
$label .= $langs->trans("Status").": ".$langs->trans((string) $charge->outcome->seller_message);
$status = $form->textwithpicto(img_picto($langs->trans((string) $charge->status), 'statut8'), $label, -1);
}
if ($charge->payment_method_details->type == 'card') {
$type = $langs->trans("card");
} elseif ($charge->source->type == 'card') {
$type = $langs->trans("card");
} elseif ($charge->payment_method_details->type == 'three_d_secure') {
$type = $langs->trans("card3DS");
} elseif ($charge->payment_method_details->type == 'sepa_debit') {
$type = $langs->trans("sepadebit");
} elseif ($charge->payment_method_details->type == 'ideal') {
$type = $langs->trans("iDEAL");
}
// Why this ?
/*if (! empty($charge->payment_intent)) {
if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage
$charge = \Stripe\PaymentIntent::retrieve($charge->payment_intent);
} else {
$charge = \Stripe\PaymentIntent::retrieve($charge->payment_intent, array("stripe_account" => $stripeacc));
}
}*/
// The metadata FULLTAG is defined by the online payment page
$FULLTAG = $charge->metadata->FULLTAG;
// Save into $tmparray all metadata
$tmparray = dolExplodeIntoArray($FULLTAG, '.', '=');
// Load origin object according to metadata
if (!empty($tmparray['CUS']) && $tmparray['CUS'] > 0)
try {
if ($stripeacc)
{
$societestatic->fetch($tmparray['CUS']);
} elseif (!empty($charge->metadata->dol_thirdparty_id) && $charge->metadata->dol_thirdparty_id > 0)
{
$societestatic->fetch($charge->metadata->dol_thirdparty_id);
$list = \Stripe\Charge::all($option, array("stripe_account" => $stripeacc));
} else {
$societestatic->id = 0;
}
if (!empty($tmparray['MEM']) && $tmparray['MEM'] > 0)
{
$memberstatic->fetch($tmparray['MEM']);
} else {
$memberstatic->id = 0;
$list = \Stripe\Charge::all($option);
}
print '<tr class="oddeven">';
$num = count($list->data);
if (!empty($stripeacc)) $connect = $stripeacc.'/';
$totalnboflines = '';
// Ref
$url = 'https://dashboard.stripe.com/'.$connect.'test/payments/'.$charge->id;
if ($servicestatus)
{
$url = 'https://dashboard.stripe.com/'.$connect.'payments/'.$charge->id;
}
print "<td>";
print "<a href='".$url."' target='_stripe'>".img_picto($langs->trans('ShowInStripe'), 'globe')." ".$charge->id."</a>";
if ($charge->payment_intent) print '<br><span class="opacitymedium">'.$charge->payment_intent.'</span>';
print "</td>\n";
$param = '';
//if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
$param .= '&starting_after_'.($page + 1).'='.$list->data[($limit - 1)]->id;
//$param.='&ending_before_'.($page+1).'='.$list->data[($limit-1)]->id;
// Stripe customer
print "<td>";
if (!empty($conf->stripe->enabled) && !empty($stripeacc)) $connect = $stripeacc.'/';
$url = 'https://dashboard.stripe.com/'.$connect.'test/customers/'.$charge->customer;
if ($servicestatus)
{
$url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$charge->customer;
}
if (!empty($charge->customer))
{
print '<a href="'.$url.'" target="_stripe">'.img_picto($langs->trans('ShowInStripe'), 'globe').' '.$charge->customer.'</a>';
}
print "</td>\n";
$moreforfilter = '';
// Link
print "<td>";
if ($societestatic->id > 0)
{
print $societestatic->getNomUrl(1);
} elseif ($memberstatic->id > 0)
{
print $memberstatic->getNomUrl(1);
}
print "</td>\n";
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
// Origin
print "<td>";
if ($charge->metadata->dol_type == "order" || $charge->metadata->dol_type == "commande") {
$object = new Commande($db);
$object->fetch($charge->metadata->dol_id);
if ($object->id > 0) {
print "<a href='".DOL_URL_ROOT."/commande/card.php?id=".$object->id."'>".img_picto('', 'object_order')." ".$object->ref."</a>";
} else {
print $FULLTAG;
}
} elseif ($charge->metadata->dol_type == "invoice" || $charge->metadata->dol_type == "facture") {
print $charge->metadata->dol_type.' '.$charge->metadata->dol_id.' - ';
$object = new Facture($db);
$object->fetch($charge->metadata->dol_id);
if ($object->id > 0) {
print "<a href='".DOL_URL_ROOT."/compta/facture/card.php?facid=".$charge->metadata->dol_id."'>".img_picto('', 'object_invoice')." ".$object->ref."</a>";
} else {
print $FULLTAG;
}
} else {
print $FULLTAG;
}
print "</td>\n";
$title = $langs->trans("StripeChargeList");
$title .= ($stripeacc ? ' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)');
// Date payment
print '<td class="center">'.dol_print_date($charge->created, '%d/%m/%Y %H:%M')."</td>\n";
// Type
print '<td>';
print $type;
print '</td>';
// Amount
print '<td class="right">'.price(($charge->amount - $charge->amount_refunded) / 100, 0, '', 1, - 1, - 1, strtoupper($charge->currency))."</td>";
// Status
print '<td class="right">';
print $status;
print "</td>\n";
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'title_accountancy.png', 0, '', 'hidepaginationprevious', $limit);
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
print '<tr class="liste_titre">';
print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder);
print_liste_field_titre("StripeCustomerId", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder);
print_liste_field_titre("Customer", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder);
print_liste_field_titre("Origin", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder);
print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "", "", "", '', $sortfield, $sortorder, 'center ');
print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "", "", "", '', $sortfield, $sortorder, 'left ');
print_liste_field_titre("Paid", $_SERVER["PHP_SELF"], "", "", "", '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "", "", "", '', '', '', 'right ');
print "</tr>\n";
$i++;
//print $list;
$i = 0;
foreach ($list->data as $charge)
{
if ($i >= $limit) {
break;
}
if ($charge->refunded == '1') {
$status = img_picto($langs->trans("refunded"), 'statut6');
} elseif ($charge->paid == '1') {
$status = img_picto($langs->trans((string) $charge->status), 'statut4');
} else {
$label = $langs->trans("Message").": ".$charge->failure_message."<br>";
$label .= $langs->trans("Network").": ".$charge->outcome->network_status."<br>";
$label .= $langs->trans("Status").": ".$langs->trans((string) $charge->outcome->seller_message);
$status = $form->textwithpicto(img_picto($langs->trans((string) $charge->status), 'statut8'), $label, -1);
}
if ($charge->payment_method_details->type == 'card') {
$type = $langs->trans("card");
} elseif ($charge->source->type == 'card') {
$type = $langs->trans("card");
} elseif ($charge->payment_method_details->type == 'three_d_secure') {
$type = $langs->trans("card3DS");
} elseif ($charge->payment_method_details->type == 'sepa_debit') {
$type = $langs->trans("sepadebit");
} elseif ($charge->payment_method_details->type == 'ideal') {
$type = $langs->trans("iDEAL");
}
// Why this ?
/*if (! empty($charge->payment_intent)) {
if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage
$charge = \Stripe\PaymentIntent::retrieve($charge->payment_intent);
} else {
$charge = \Stripe\PaymentIntent::retrieve($charge->payment_intent, array("stripe_account" => $stripeacc));
}
}*/
// The metadata FULLTAG is defined by the online payment page
$FULLTAG = $charge->metadata->FULLTAG;
// Save into $tmparray all metadata
$tmparray = dolExplodeIntoArray($FULLTAG, '.', '=');
// Load origin object according to metadata
if (!empty($tmparray['CUS']) && $tmparray['CUS'] > 0)
{
$societestatic->fetch($tmparray['CUS']);
} elseif (!empty($charge->metadata->dol_thirdparty_id) && $charge->metadata->dol_thirdparty_id > 0)
{
$societestatic->fetch($charge->metadata->dol_thirdparty_id);
} else {
$societestatic->id = 0;
}
if (!empty($tmparray['MEM']) && $tmparray['MEM'] > 0)
{
$memberstatic->fetch($tmparray['MEM']);
} else {
$memberstatic->id = 0;
}
print '<tr class="oddeven">';
if (!empty($stripeacc)) $connect = $stripeacc.'/';
// Ref
$url = 'https://dashboard.stripe.com/'.$connect.'test/payments/'.$charge->id;
if ($servicestatus)
{
$url = 'https://dashboard.stripe.com/'.$connect.'payments/'.$charge->id;
}
print "<td>";
print "<a href='".$url."' target='_stripe'>".img_picto($langs->trans('ShowInStripe'), 'globe')." ".$charge->id."</a>";
if ($charge->payment_intent) print '<br><span class="opacitymedium">'.$charge->payment_intent.'</span>';
print "</td>\n";
// Stripe customer
print "<td>";
if (!empty($conf->stripe->enabled) && !empty($stripeacc)) $connect = $stripeacc.'/';
$url = 'https://dashboard.stripe.com/'.$connect.'test/customers/'.$charge->customer;
if ($servicestatus)
{
$url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$charge->customer;
}
if (!empty($charge->customer))
{
print '<a href="'.$url.'" target="_stripe">'.img_picto($langs->trans('ShowInStripe'), 'globe').' '.$charge->customer.'</a>';
}
print "</td>\n";
// Link
print "<td>";
if ($societestatic->id > 0)
{
print $societestatic->getNomUrl(1);
} elseif ($memberstatic->id > 0)
{
print $memberstatic->getNomUrl(1);
}
print "</td>\n";
// Origin
print "<td>";
if ($charge->metadata->dol_type == "order" || $charge->metadata->dol_type == "commande") {
$object = new Commande($db);
$object->fetch($charge->metadata->dol_id);
if ($object->id > 0) {
print "<a href='".DOL_URL_ROOT."/commande/card.php?id=".$object->id."'>".img_picto('', 'object_order')." ".$object->ref."</a>";
} else {
print $FULLTAG;
}
} elseif ($charge->metadata->dol_type == "invoice" || $charge->metadata->dol_type == "facture") {
print $charge->metadata->dol_type.' '.$charge->metadata->dol_id.' - ';
$object = new Facture($db);
$object->fetch($charge->metadata->dol_id);
if ($object->id > 0) {
print "<a href='".DOL_URL_ROOT."/compta/facture/card.php?facid=".$charge->metadata->dol_id."'>".img_picto('', 'object_invoice')." ".$object->ref."</a>";
} else {
print $FULLTAG;
}
} else {
print $FULLTAG;
}
print "</td>\n";
// Date payment
print '<td class="center">'.dol_print_date($charge->created, '%d/%m/%Y %H:%M')."</td>\n";
// Type
print '<td>';
print $type;
print '</td>';
// Amount
print '<td class="right">'.price(($charge->amount - $charge->amount_refunded) / 100, 0, '', 1, - 1, - 1, strtoupper($charge->currency))."</td>";
// Status
print '<td class="right">';
print $status;
print "</td>\n";
print "</tr>\n";
$i++;
}
print '</table>';
print '</div>';
print '</form>';
} catch(Exception $e) {
print $e->getMessage();
}
}

View File

@ -109,111 +109,115 @@ if (!$rowid) {
print "</tr>\n";
if ($stripeacc)
{
$payout = \Stripe\Payout::all(array("limit" => $limit), array("stripe_account" => $stripeacc));
} else {
$payout = \Stripe\Payout::all(array("limit" => $limit));
}
foreach ($payout->data as $payout)
{
//$charge = $payout;
//var_dump($payout);
// The metadata FULLTAG is defined by the online payment page
/*$FULLTAG=$charge->metadata->FULLTAG;
// Save into $tmparray all metadata
$tmparray = dolExplodeIntoArray($FULLTAG,'.','=');
// Load origin object according to metadata
if (! empty($tmparray['CUS']))
try {
if ($stripeacc)
{
$societestatic->fetch($tmparray['CUS']);
}
else
{
$societestatic->id = 0;
}
if (! empty($tmparray['MEM']))
{
$memberstatic->fetch($tmparray['MEM']);
}
else
{
$memberstatic->id = 0;
}*/
$societestatic->fetch($charge->metadata->idcustomer);
$societestatic->id = $charge->metadata->idcustomer;
$societestatic->lastname = $obj->lastname;
$societestatic->firstname = $obj->firstname;
$societestatic->admin = $obj->admin;
$societestatic->login = $obj->login;
$societestatic->email = $obj->email;
$societestatic->socid = $obj->fk_soc;
print '<tr class="oddeven">';
// Ref
if (!empty($stripeacc)) $connect = $stripeacc.'/';
$url = 'https://dashboard.stripe.com/'.$connect.'test/payouts/'.$payout->id;
if ($servicestatus) {
$url = 'https://dashboard.stripe.com/'.$connect.'payouts/'.$payout->id;
$payout = \Stripe\Payout::all(array("limit" => $limit), array("stripe_account" => $stripeacc));
} else {
$payout = \Stripe\Payout::all(array("limit" => $limit));
}
print "<td><a href='".$url."' target='_stripe'>".img_picto($langs->trans('ShowInStripe'), 'globe')." ".$payout->id."</a></td>\n";
foreach ($payout->data as $payout)
{
//$charge = $payout;
//var_dump($payout);
// The metadata FULLTAG is defined by the online payment page
/*$FULLTAG=$charge->metadata->FULLTAG;
// Save into $tmparray all metadata
$tmparray = dolExplodeIntoArray($FULLTAG,'.','=');
// Load origin object according to metadata
if (! empty($tmparray['CUS']))
{
$societestatic->fetch($tmparray['CUS']);
}
else
{
$societestatic->id = 0;
}
if (! empty($tmparray['MEM']))
{
$memberstatic->fetch($tmparray['MEM']);
}
else
{
$memberstatic->id = 0;
}*/
$societestatic->fetch($charge->metadata->idcustomer);
$societestatic->id = $charge->metadata->idcustomer;
$societestatic->lastname = $obj->lastname;
$societestatic->firstname = $obj->firstname;
$societestatic->admin = $obj->admin;
$societestatic->login = $obj->login;
$societestatic->email = $obj->email;
$societestatic->socid = $obj->fk_soc;
print '<tr class="oddeven">';
// Ref
if (!empty($stripeacc)) $connect = $stripeacc.'/';
$url = 'https://dashboard.stripe.com/'.$connect.'test/payouts/'.$payout->id;
if ($servicestatus) {
$url = 'https://dashboard.stripe.com/'.$connect.'payouts/'.$payout->id;
}
print "<td><a href='".$url."' target='_stripe'>".img_picto($langs->trans('ShowInStripe'), 'globe')." ".$payout->id."</a></td>\n";
// Stripe customer
//print "<td>".$charge->customer."</td>\n";
// Link
/*print "<td>";
if ($societestatic->id > 0)
{
print $societestatic->getNomUrl(1);
// Stripe customer
//print "<td>".$charge->customer."</td>\n";
// Link
/*print "<td>";
if ($societestatic->id > 0)
{
print $societestatic->getNomUrl(1);
}
if ($memberstatic->id > 0)
{
print $memberstatic->getNomUrl(1);
}
print "</td>\n";*/
// Origine
//print "<td>";
////if ($charge->metadata->dol_type=="order"){
// $object = new Commande($db);
// $object->fetch($charge->metadata->dol_id);
// print "<a href='".DOL_URL_ROOT."/commande/card.php?id=".$charge->metadata->dol_id."'>".img_picto('', 'object_order')." ".$object->ref."</a>";
//} elseif ($charge->metadata->dol_type=="invoice"){
// $object = new Facture($db);
// $object->fetch($charge->metadata->dol_id);
// print "<a href='".DOL_URL_ROOT."/compta/facture/card.php?facid=".$charge->metadata->dol_id."'>".img_picto('', 'object_invoice')." ".$object->ref."</a>";
//}
//print "</td>\n";
// Date payment
print '<td class="center">'.dol_print_date($payout->created, '%d/%m/%Y %H:%M')."</td>\n";
// Date payment
print '<td class="center">'.dol_print_date($payout->arrival_date, '%d/%m/%Y %H:%M')."</td>\n";
// Type
print '<td>'.$payout->description.'</td>';
// Amount
print '<td class="right">'.price(($payout->amount) / 100, 0, '', 1, -1, -1, strtoupper($payout->currency))."</td>";
// Status
print "<td class='right'>";
if ($payout->status == 'paid') {
print img_picto($langs->trans("".$payout->status.""), 'statut4');
} elseif ($payout->status == 'pending') {
print img_picto($langs->trans("".$payout->status.""), 'statut7');
} elseif ($payout->status == 'in_transit') {
print img_picto($langs->trans("".$payout->status.""), 'statut7');
} elseif ($payout->status == 'failed') {
print img_picto($langs->trans("".$payout->status.""), 'statut7');
} elseif ($payout->status == 'canceled') {
print img_picto($langs->trans("".$payout->status.""), 'statut8');
}
print '</td>';
print "</tr>\n";
}
if ($memberstatic->id > 0)
{
print $memberstatic->getNomUrl(1);
}
print "</td>\n";*/
// Origine
//print "<td>";
////if ($charge->metadata->dol_type=="order"){
// $object = new Commande($db);
// $object->fetch($charge->metadata->dol_id);
// print "<a href='".DOL_URL_ROOT."/commande/card.php?id=".$charge->metadata->dol_id."'>".img_picto('', 'object_order')." ".$object->ref."</a>";
//} elseif ($charge->metadata->dol_type=="invoice"){
// $object = new Facture($db);
// $object->fetch($charge->metadata->dol_id);
// print "<a href='".DOL_URL_ROOT."/compta/facture/card.php?facid=".$charge->metadata->dol_id."'>".img_picto('', 'object_invoice')." ".$object->ref."</a>";
//}
//print "</td>\n";
// Date payment
print '<td class="center">'.dol_print_date($payout->created, '%d/%m/%Y %H:%M')."</td>\n";
// Date payment
print '<td class="center">'.dol_print_date($payout->arrival_date, '%d/%m/%Y %H:%M')."</td>\n";
// Type
print '<td>'.$payout->description.'</td>';
// Amount
print '<td class="right">'.price(($payout->amount) / 100, 0, '', 1, -1, -1, strtoupper($payout->currency))."</td>";
// Status
print "<td class='right'>";
if ($payout->status == 'paid') {
print img_picto($langs->trans("".$payout->status.""), 'statut4');
} elseif ($payout->status == 'pending') {
print img_picto($langs->trans("".$payout->status.""), 'statut7');
} elseif ($payout->status == 'in_transit') {
print img_picto($langs->trans("".$payout->status.""), 'statut7');
} elseif ($payout->status == 'failed') {
print img_picto($langs->trans("".$payout->status.""), 'statut7');
} elseif ($payout->status == 'canceled') {
print img_picto($langs->trans("".$payout->status.""), 'statut8');
}
print '</td>';
print "</tr>\n";
} catch(Exception $e) {
print '<tr><td colspan="6">'.$e->getMessage().'</td></td>';
}
print "</table>";
print '</div>';

View File

@ -108,117 +108,121 @@ if (!$rowid) {
print "</tr>\n";
if ($stripeacc)
{
$txn = \Stripe\BalanceTransaction::all(array("limit" => $limit), array("stripe_account" => $stripeacc));
} else {
$txn = \Stripe\BalanceTransaction::all(array("limit" => $limit));
}
foreach ($txn->data as $txn)
{
//$charge = $txn;
//var_dump($txn);
// The metadata FULLTAG is defined by the online payment page
/*$FULLTAG=$charge->metadata->FULLTAG;
// Save into $tmparray all metadata
$tmparray = dolExplodeIntoArray($FULLTAG,'.','=');
// Load origin object according to metadata
if (! empty($tmparray['CUS']))
try {
if ($stripeacc)
{
$societestatic->fetch($tmparray['CUS']);
$txn = \Stripe\BalanceTransaction::all(array("limit" => $limit), array("stripe_account" => $stripeacc));
} else {
$txn = \Stripe\BalanceTransaction::all(array("limit" => $limit));
}
else
foreach ($txn->data as $txn)
{
$societestatic->id = 0;
//$charge = $txn;
//var_dump($txn);
// The metadata FULLTAG is defined by the online payment page
/*$FULLTAG=$charge->metadata->FULLTAG;
// Save into $tmparray all metadata
$tmparray = dolExplodeIntoArray($FULLTAG,'.','=');
// Load origin object according to metadata
if (! empty($tmparray['CUS']))
{
$societestatic->fetch($tmparray['CUS']);
}
else
{
$societestatic->id = 0;
}
if (! empty($tmparray['MEM']))
{
$memberstatic->fetch($tmparray['MEM']);
}
else
{
$memberstatic->id = 0;
}*/
$societestatic->fetch($charge->metadata->idcustomer);
$societestatic->id = $charge->metadata->idcustomer;
$societestatic->lastname = $obj->lastname;
$societestatic->firstname = $obj->firstname;
$societestatic->admin = $obj->admin;
$societestatic->login = $obj->login;
$societestatic->email = $obj->email;
$societestatic->societe_id = $obj->fk_soc;
print '<tr class="oddeven">';
// Ref
if (!empty($stripeacc)) $connect = $stripeacc.'/';
// Ref
if (preg_match('/po_/i', $txn->source)) {
$origin = "payouts";
} elseif (preg_match('/fee_/i', $txn->source)) {
$origin = "connect/application_fees";
} else {
$origin = "payments";
}
$url = 'https://dashboard.stripe.com/'.$connect.'test/'.$origin.'/'.$txn->source;
if ($servicestatus) {
$url = 'https://dashboard.stripe.com/'.$connect.$origin.'/'.$txn->source;
}
if ($txn->type == 'stripe_fee' || $txn->type == 'reserve_transaction') {
print "<td>".$txn->type."</td>";
} else {
print "<td><a href='".$url."' target='_stripe'>".img_picto($langs->trans('ShowInStripe'), 'globe')." ".$txn->source."</a></td>\n";
}
// Stripe customer
//print "<td>".$charge->customer."</td>\n";
// Link
/*print "<td>";
if ($societestatic->id > 0)
{
print $societestatic->getNomUrl(1);
}
if ($memberstatic->id > 0)
{
print $memberstatic->getNomUrl(1);
}
print "</td>\n";*/
// Origine
//print "<td>";
////if ($charge->metadata->dol_type=="order"){
// $object = new Commande($db);
// $object->fetch($charge->metadata->dol_id);
// print "<a href='".DOL_URL_ROOT."/commande/card.php?id=".$charge->metadata->dol_id."'>".img_picto('', 'object_order')." ".$object->ref."</a>";
//} elseif ($charge->metadata->dol_type=="invoice"){
// $object = new Facture($db);
// $object->fetch($charge->metadata->dol_id);
// print "<a href='".DOL_URL_ROOT."/compta/facture/card.php?facid=".$charge->metadata->dol_id."'>".img_picto('', 'object_invoice')." ".$object->ref."</a>";
//}
//print "</td>\n";
// Date payment
print '<td class="center">'.dol_print_date($txn->created, '%d/%m/%Y %H:%M')."</td>\n";
// Type
print '<td>'.$txn->type.'</td>';
// Amount
print '<td class="right">'.price(($txn->amount) / 100, 0, '', 1, - 1, - 1, strtoupper($txn->currency))."</td>";
print '<td class="right">'.price(($txn->fee) / 100, 0, '', 1, - 1, - 1, strtoupper($txn->currency))."</td>";
// Status
print "<td class='right'>";
if ($txn->status == 'available') {
print img_picto($langs->trans("".$txn->status.""), 'statut4');
} elseif ($txn->status == 'pending') {
print img_picto($langs->trans("".$txn->status.""), 'statut7');
} elseif ($txn->status == 'failed') {
print img_picto($langs->trans("".$txn->status.""), 'statut8');
}
print '</td>';
print "</tr>\n";
}
if (! empty($tmparray['MEM']))
{
$memberstatic->fetch($tmparray['MEM']);
}
else
{
$memberstatic->id = 0;
}*/
$societestatic->fetch($charge->metadata->idcustomer);
$societestatic->id = $charge->metadata->idcustomer;
$societestatic->lastname = $obj->lastname;
$societestatic->firstname = $obj->firstname;
$societestatic->admin = $obj->admin;
$societestatic->login = $obj->login;
$societestatic->email = $obj->email;
$societestatic->societe_id = $obj->fk_soc;
print '<tr class="oddeven">';
// Ref
if (!empty($stripeacc)) $connect = $stripeacc.'/';
// Ref
if (preg_match('/po_/i', $txn->source)) {
$origin = "payouts";
} elseif (preg_match('/fee_/i', $txn->source)) {
$origin = "connect/application_fees";
} else {
$origin = "payments";
}
$url = 'https://dashboard.stripe.com/'.$connect.'test/'.$origin.'/'.$txn->source;
if ($servicestatus) {
$url = 'https://dashboard.stripe.com/'.$connect.$origin.'/'.$txn->source;
}
if ($txn->type == 'stripe_fee' || $txn->type == 'reserve_transaction') {
print "<td>".$txn->type."</td>";
} else {
print "<td><a href='".$url."' target='_stripe'>".img_picto($langs->trans('ShowInStripe'), 'globe')." ".$txn->source."</a></td>\n";
}
// Stripe customer
//print "<td>".$charge->customer."</td>\n";
// Link
/*print "<td>";
if ($societestatic->id > 0)
{
print $societestatic->getNomUrl(1);
}
if ($memberstatic->id > 0)
{
print $memberstatic->getNomUrl(1);
}
print "</td>\n";*/
// Origine
//print "<td>";
////if ($charge->metadata->dol_type=="order"){
// $object = new Commande($db);
// $object->fetch($charge->metadata->dol_id);
// print "<a href='".DOL_URL_ROOT."/commande/card.php?id=".$charge->metadata->dol_id."'>".img_picto('', 'object_order')." ".$object->ref."</a>";
//} elseif ($charge->metadata->dol_type=="invoice"){
// $object = new Facture($db);
// $object->fetch($charge->metadata->dol_id);
// print "<a href='".DOL_URL_ROOT."/compta/facture/card.php?facid=".$charge->metadata->dol_id."'>".img_picto('', 'object_invoice')." ".$object->ref."</a>";
//}
//print "</td>\n";
// Date payment
print '<td class="center">'.dol_print_date($txn->created, '%d/%m/%Y %H:%M')."</td>\n";
// Type
print '<td>'.$txn->type.'</td>';
// Amount
print '<td class="right">'.price(($txn->amount) / 100, 0, '', 1, - 1, - 1, strtoupper($txn->currency))."</td>";
print '<td class="right">'.price(($txn->fee) / 100, 0, '', 1, - 1, - 1, strtoupper($txn->currency))."</td>";
// Status
print "<td class='right'>";
if ($txn->status == 'available') {
print img_picto($langs->trans("".$txn->status.""), 'statut4');
} elseif ($txn->status == 'pending') {
print img_picto($langs->trans("".$txn->status.""), 'statut7');
} elseif ($txn->status == 'failed') {
print img_picto($langs->trans("".$txn->status.""), 'statut8');
}
print '</td>';
print "</tr>\n";
} catch (Exception $e) {
print '<tr><td colspan="6">'.$e->getMessage().'</td></td>';
}
print "</table>";
print '</div>';

View File

@ -50,7 +50,9 @@ print load_fiche_titre($title, $linkback, 'title_setup');
dol_fiche_head(array(), 'general', $tab, 0, 'product');
print '<form method="post">';
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<th>'.$langs->trans("Parameters").'</td>'."\n";