--- /tmp/dsg/dolibarr/htdocs/stripe/github_19.0.3_charge.php +++ /tmp/dsg/dolibarr/htdocs/stripe/client_charge.php @@ -2 +2 @@ -/* Copyright (C) 2018-2022 Thibault FOUCART +/* Copyright (C) 2018 Thibault FOUCART @@ -21 +20,0 @@ -// Load Dolibarr environment @@ -30,3 +29 @@ -if (isModEnabled('accounting')) { - require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; -} +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; @@ -39,3 +36 @@ -if ($user->socid) { - $socid = $user->socid; -} +if ($user->socid) $socid = $user->socid; @@ -46,2 +41,2 @@ -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -49,3 +44 @@ -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -56,2 +49 @@ -$result = restrictedArea($user, 'banque'); -$optioncss = GETPOST('optioncss', 'alpha'); + @@ -71 +63,2 @@ -if (isModEnabled('stripe') && (!getDolGlobalString('STRIPE_LIVE') || GETPOST('forcesandbox', 'alpha'))) { +if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) +{ @@ -75 +68,3 @@ -} else { +} +else +{ @@ -86 +81,2 @@ -if (!$rowid) { +if (!$rowid) +{ @@ -88 +84,12 @@ - $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 = ''; @@ -91 +98,5 @@ - $totalnboflines = ''; + //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; + @@ -93,4 +104 @@ - $list = null; - if (GETPOSTISSET('starting_after_'.$page)) { - $option['starting_after'] = GETPOST('starting_after_'.$page, 'alphanohtml'); - } + @@ -98,5 +106,2 @@ - if ($optioncss != '') { - print ''; - } - - print ''; + if ($optioncss != '') print ''; + print ''; @@ -104,7 +109,7 @@ - print ''; - print ''; - print ''; - print ''; - - $title = $langs->trans("StripeChargeList"); - $title .= ($stripeacc ? ' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)'); + print ''; + print ''; + print ''; + print ''; + + $title = $langs->trans("StripeChargeList"); + $title .= ($stripeacc ? ' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)'); @@ -114,33 +119,13 @@ - print '
'; - print ''."\n"; - - print ''; - print_liste_field_titre("StripePaymentId", $_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 "\n"; - - try { - if ($stripeacc) { - $list = \Stripe\Charge::all($option, array("stripe_account" => $stripeacc)); - } else { - $list = \Stripe\Charge::all($option); - } - - $num = count($list->data); - - - //if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.((int) $limit); - } - $param .= '&starting_after_'.($page + 1).'='.$list->data[($limit - 1)]->id; - //$param.='&ending_before_'.($page+1).'='.$list->data[($limit-1)]->id; - } catch (Exception $e) { - print ''; - } + print '
'; + print '
'.$e->getMessage().'
'."\n"; + + print ''; + 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 "\n"; @@ -150,4 +135,35 @@ - if (!empty($list)) { - foreach ($list->data as $charge) { - if ($i >= $limit) { - break; + 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."
"; + $label .= $langs->trans("Network").": ".$charge->outcome->network_status."
"; + $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)); @@ -155,114 +171,87 @@ - - 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."
"; - $label .= $langs->trans("Network").": ".$charge->outcome->network_status."
"; - $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 (isset($charge->payment_method_details->type) && $charge->payment_method_details->type == 'card') { - $type = $langs->trans("card"); - } elseif (isset($charge->source->type) && $charge->source->type == 'card') { - $type = $langs->trans("card"); - } elseif (isset($charge->payment_method_details->type) && $charge->payment_method_details->type == 'three_d_secure') { - $type = $langs->trans("card3DS"); - } elseif (isset($charge->payment_method_details->type) && $charge->payment_method_details->type == 'sepa_debit') { - $type = $langs->trans("sepadebit"); - } elseif (isset($charge->payment_method_details->type) && $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 ''; - - if (!empty($stripeacc)) { - $connect = $stripeacc.'/'; - } else { - $connect = ''; - } - - // Ref - $url = 'https://dashboard.stripe.com/'.$connect.'test/payments/'.$charge->id; - if ($servicestatus) { - $url = 'https://dashboard.stripe.com/'.$connect.'payments/'.$charge->id; - } - print "\n"; - - // Stripe customer - print "\n"; - - // Link - print "\n"; - - // Origin - print "'; + + 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 "\n"; + + // Stripe customer + print "\n"; + + // Link + print "\n"; + + // Origin + print "\n"; - - // Date payment - print '\n"; - // Type - print ''; - // Amount - print '"; - // Status - print '\n"; - - print "\n"; - - $i++; - } + } else { + print $FULLTAG; + } + print "\n"; + + // Date payment + print '\n"; + // Type + print ''; + // Amount + print '"; + // Status + print '\n"; + + print "\n"; + + $i++; @@ -291,4 +281,0 @@ - - print '
"; - print "".img_picto($langs->trans('ShowInStripe'), 'globe')." ".$charge->id.""; - if ($charge->payment_intent) { - print '
'.$charge->payment_intent.''; - } - print "
"; - if (isModEnabled('stripe') && !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 ''.img_picto($langs->trans('ShowInStripe'), 'globe').' '.$charge->customer.''; - } - print ""; - if ($societestatic->id > 0) { - print $societestatic->getNomUrl(1); - } elseif ($memberstatic->id > 0) { - print $memberstatic->getNomUrl(1); - } - print ""; - 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 "".img_picto('', 'order')." ".$object->ref.""; - } else { - print $FULLTAG; - } - } elseif ($charge->metadata->dol_type == "invoice" || $charge->metadata->dol_type == "facture") { - $object = new Facture($db); - $object->fetch($charge->metadata->dol_id); - if ($object->id > 0) { - print "".img_picto('', 'bill')." ".$object->ref.""; - } else { - print $FULLTAG; - } - } else { + }*/ + + // 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 '
"; + print "".img_picto($langs->trans('ShowInStripe'), 'globe')." ".$charge->id.""; + if ($charge->payment_intent) print '
'.$charge->payment_intent.''; + print "
"; + 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 ''.img_picto($langs->trans('ShowInStripe'), 'globe').' '.$charge->customer.''; + } + print ""; + if ($societestatic->id > 0) + { + print $societestatic->getNomUrl(1); + } + elseif ($memberstatic->id > 0) + { + print $memberstatic->getNomUrl(1); + } + print ""; + 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 "".img_picto('', 'object_order')." ".$object->ref.""; + } 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 "".img_picto('', 'object_invoice')." ".$object->ref.""; + } else { @@ -271,19 +260,21 @@ - print "'.dol_print_date($charge->created, 'dayhour')."'; - print $type; - print ''.price(($charge->amount - $charge->amount_refunded) / 100, 0, '', 1, - 1, - 1, strtoupper($charge->currency))."'; - print $status; - print "
'.dol_print_date($charge->created, '%d/%m/%Y %H:%M')."'; + print $type; + print ''.price(($charge->amount - $charge->amount_refunded) / 100, 0, '', 1, - 1, - 1, strtoupper($charge->currency))."'; + print $status; + print "
'; - print '
'; - print ''; --- /tmp/dsg/dolibarr/htdocs/stripe/github_19.0.3_config.php +++ /tmp/dsg/dolibarr/htdocs/stripe/client_config.php @@ -37,2 +37,2 @@ - "secret_key" => !getDolGlobalString('STRIPE_TEST_SECRET_KEY') ? '' : $conf->global->STRIPE_TEST_SECRET_KEY, - "publishable_key" => !getDolGlobalString('STRIPE_TEST_PUBLISHABLE_KEY') ? '' : $conf->global->STRIPE_TEST_PUBLISHABLE_KEY + "secret_key" => $conf->global->STRIPE_TEST_SECRET_KEY, + "publishable_key" => $conf->global->STRIPE_TEST_PUBLISHABLE_KEY @@ -41,2 +41,2 @@ - "secret_key" => !getDolGlobalString('STRIPE_LIVE_SECRET_KEY') ? '' : $conf->global->STRIPE_LIVE_SECRET_KEY, - "publishable_key" => !getDolGlobalString('STRIPE_LIVE_PUBLISHABLE_KEY') ? '' : $conf->global->STRIPE_LIVE_PUBLISHABLE_KEY + "secret_key" => $conf->global->STRIPE_LIVE_SECRET_KEY, + "publishable_key" => $conf->global->STRIPE_LIVE_PUBLISHABLE_KEY @@ -47 +47,2 @@ -if (!getDolGlobalString('STRIPE_LIVE') || GETPOST('forcesandbox', 'alpha')) { +if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha')) +{ @@ -49 +50,3 @@ -} else { +} +else +{ @@ -55 +58 @@ -\Stripe\Stripe::setApiVersion(getDolGlobalString('STRIPE_FORCE_VERSION', "2022-11-15")); // force version API +\Stripe\Stripe::setApiVersion(empty($conf->global->STRIPE_FORCE_VERSION) ? "2019-09-09" : $conf->global->STRIPE_FORCE_VERSION); // force version API --- /tmp/dsg/dolibarr/htdocs/stripe/github_19.0.3_payout.php +++ /tmp/dsg/dolibarr/htdocs/stripe/client_payout.php @@ -2 +2 @@ -/* Copyright (C) 2018-2023 Thibault FOUCART +/* Copyright (C) 2018-2019 Thibault FOUCART @@ -21 +20,0 @@ -// Load Dolibarr environment @@ -30,3 +29 @@ -if (isModEnabled('accounting')) { - require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; -} +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; @@ -39,3 +36 @@ -if ($user->socid) { - $socid = $user->socid; -} +if ($user->socid) $socid = $user->socid; @@ -46,2 +41,2 @@ -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -49,3 +44 @@ -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -55,5 +48 @@ -$optioncss = GETPOST('optioncss', 'alpha'); -$param = ""; -$num = 0; - -$result = restrictedArea($user, 'banque'); + @@ -66,0 +56,2 @@ +$societestatic = new Societe($db); +$memberstatic = new Adherent($db); @@ -72 +63 @@ -if (isModEnabled('stripe') && (!getDolGlobalString('STRIPE_LIVE') || GETPOST('forcesandbox', 'alpha'))) { +if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) { @@ -76 +67,3 @@ -} else { +} +else +{ @@ -87,3 +79,0 @@ -$moreforfilter = ''; -$totalnboflines = -1; - @@ -93,2 +83,2 @@ - print ''; - } + print ''; + } @@ -103 +93 @@ - $title .= ($stripeacc ? ' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)'); + $title .= ($stripeaccount ? ' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)'); @@ -108 +98 @@ - print ''."\n"; + print '
'."\n"; @@ -111,0 +102,3 @@ + //print_liste_field_titre("StripeCustomerId",$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder); + //print_liste_field_titre("CustomerId", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); + //print_liste_field_titre("Origin", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); @@ -113 +106 @@ - print_liste_field_titre("DateOperation", $_SERVER["PHP_SELF"], "", "", "", '', $sortfield, $sortorder, 'center '); + print_liste_field_titre("DateOperation", $_SERVER["PHP_SELF"], "", "", "", '', $sortfield, $sortorder, 'center '); @@ -121,50 +114,107 @@ - try { - 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) { - print ''; - - // Ref - if (!empty($stripeacc)) { - $connect = $stripeacc.'/'; - } else { - $connect = null; - } - - $url = 'https://dashboard.stripe.com/'.$connect.'test/payouts/'.$payout->id; - if ($servicestatus) { - $url = 'https://dashboard.stripe.com/'.$connect.'payouts/'.$payout->id; - } - - print "\n"; - - // Date payment - print '\n"; - // Date payment - print '\n"; - // Type - print ''; - // Amount - print '"; - // Status - print "'; - print "\n"; - } - } catch (Exception $e) { - print ''; + 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'])) + { + $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 ''; + + // 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 "\n"; + + + // Stripe customer + //print "\n"; + // Link + /*print "\n";*/ + // Origine + //print "\n"; + // Date payment + print '\n"; + // Date payment + print '\n"; + // Type + print ''; + // Amount + print '"; + // Status + print "'; + print "\n"; --- /tmp/dsg/dolibarr/htdocs/stripe/github_19.0.3_transaction.php +++ /tmp/dsg/dolibarr/htdocs/stripe/client_transaction.php @@ -3 +3 @@ - * Copyright (C) 2018-2021 Frédéric France + * Copyright (C) 2018 Frédéric France @@ -21 +20,0 @@ -// Load Dolibarr environment @@ -30,3 +29 @@ -if (isModEnabled('accounting')) { - require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; -} +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; @@ -39,3 +36 @@ -if ($user->socid) { - $socid = $user->socid; -} +if ($user->socid) $socid = $user->socid; @@ -46,2 +41,2 @@ -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -49,3 +44 @@ -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -55,5 +48 @@ -$optioncss = GETPOST('optioncss', 'alpha'); -$param = ""; -$num = 0; -$totalnboflines = 0; -$result = restrictedArea($user, 'banque'); + @@ -74 +63,2 @@ -if (isModEnabled('stripe') && (!getDolGlobalString('STRIPE_LIVE') || GETPOST('forcesandbox', 'alpha'))) { +if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) +{ @@ -78 +68,3 @@ -} else { +} +else +{ @@ -90 +82 @@ - if ($optioncss != '') { + if ($optioncss != '') @@ -92 +83,0 @@ - } @@ -101 +92 @@ - $title .= (!empty($stripeacc) ? ' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)'); + $title .= ($stripeaccount ? ' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)'); @@ -106 +97 @@ - print '
".img_picto($langs->trans('ShowInStripe'), 'globe')." ".$payout->id."'.dol_print_date($payout->created, 'dayhour')."'.dol_print_date($payout->arrival_date, 'dayhour')."'.$payout->description.''.price(($payout->amount) / 100, 0, '', 1, -1, -1, strtoupper($payout->currency)).""; - 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 '
'.$e->getMessage().'
".img_picto($langs->trans('ShowInStripe'), 'globe')." ".$payout->id."".$charge->customer.""; + if ($societestatic->id > 0) + { + print $societestatic->getNomUrl(1); + } + if ($memberstatic->id > 0) + { + print $memberstatic->getNomUrl(1); + } + print ""; + ////if ($charge->metadata->dol_type=="order"){ + // $object = new Commande($db); + // $object->fetch($charge->metadata->dol_id); + // print "".img_picto('', 'object_order')." ".$object->ref.""; + //} elseif ($charge->metadata->dol_type=="invoice"){ + // $object = new Facture($db); + // $object->fetch($charge->metadata->dol_id); + // print "".img_picto('', 'object_invoice')." ".$object->ref.""; + //} + //print "'.dol_print_date($payout->created, '%d/%m/%Y %H:%M')."'.dol_print_date($payout->arrival_date, '%d/%m/%Y %H:%M')."'.$payout->description.''.price(($payout->amount) / 100, 0, '', 1, -1, -1, strtoupper($payout->currency)).""; + 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 '
'."\n"; + print '
'."\n"; @@ -109,0 +101,3 @@ + //print_liste_field_titre("StripeCustomerId",$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder); + //print_liste_field_titre("CustomerId", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); + //print_liste_field_titre("Origin", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); @@ -116,115 +110,116 @@ - $connect = ""; - - try { - 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'])) - { - $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 ''; - - // 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 ""; - } else { - print "\n"; - } - - // Stripe customer - //print "\n"; - // Link - /*print "\n";*/ - // Origine - //print "\n"; - // Date payment - print '\n"; - // Type - print ''; - // Amount - print '"; - print '"; - // Status - print "'; - print "\n"; - } - } catch (Exception $e) { - print ''; + + print "\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'])) + { + $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 ''; + + // 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 ""; + } else { + print "\n"; + } + + // Stripe customer + //print "\n"; + // Link + /*print "\n";*/ + // Origine + //print "\n"; + // Date payment + print '\n"; + // Type + print ''; + // Amount + print '"; + print '"; + // Status + print "'; + print "\n";
".$txn->type."".img_picto($langs->trans('ShowInStripe'), 'globe')." ".$txn->source."".$charge->customer.""; - if ($societestatic->id > 0) { - print $societestatic->getNomUrl(1); - } - if ($memberstatic->id > 0) { - print $memberstatic->getNomUrl(1); - } - print ""; - ////if ($charge->metadata->dol_type=="order"){ - // $object = new Commande($db); - // $object->fetch($charge->metadata->dol_id); - // print "".img_picto('', 'object_order')." ".$object->ref.""; - //} elseif ($charge->metadata->dol_type=="invoice"){ - // $object = new Facture($db); - // $object->fetch($charge->metadata->dol_id); - // print "".img_picto('', 'object_invoice')." ".$object->ref.""; - //} - //print "'.dol_print_date($txn->created, 'dayhour')."'.$txn->type.''.price(($txn->amount) / 100, 0, '', 1, - 1, - 1, strtoupper($txn->currency))."'.price(($txn->fee) / 100, 0, '', 1, - 1, - 1, strtoupper($txn->currency)).""; - 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 '
'.$e->getMessage().'
".$txn->type."".img_picto($langs->trans('ShowInStripe'), 'globe')." ".$txn->source."".$charge->customer.""; + if ($societestatic->id > 0) + { + print $societestatic->getNomUrl(1); + } + if ($memberstatic->id > 0) + { + print $memberstatic->getNomUrl(1); + } + print ""; + ////if ($charge->metadata->dol_type=="order"){ + // $object = new Commande($db); + // $object->fetch($charge->metadata->dol_id); + // print "".img_picto('', 'object_order')." ".$object->ref.""; + //} elseif ($charge->metadata->dol_type=="invoice"){ + // $object = new Facture($db); + // $object->fetch($charge->metadata->dol_id); + // print "".img_picto('', 'object_invoice')." ".$object->ref.""; + //} + //print "'.dol_print_date($txn->created, '%d/%m/%Y %H:%M')."'.$txn->type.''.price(($txn->amount) / 100, 0, '', 1, - 1, - 1, strtoupper($txn->currency))."'.price(($txn->fee) / 100, 0, '', 1, - 1, - 1, strtoupper($txn->currency)).""; + 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 '