From 6e2a9dc0c91f883a2519f5181762adecb3c84ef1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 24 Sep 2020 21:54:21 +0200 Subject: [PATCH] Fix error management in Stripe --- htdocs/core/tpl/onlinepaymentlinks.tpl.php | 10 + htdocs/paybox/admin/paybox.php | 2 +- htdocs/stripe/admin/stripe.php | 2 +- htdocs/stripe/charge.php | 360 +++++++++++---------- htdocs/stripe/payout.php | 202 ++++++------ htdocs/stripe/transaction.php | 218 +++++++------ htdocs/variants/admin/admin.php | 4 +- 7 files changed, 415 insertions(+), 383 deletions(-) diff --git a/htdocs/core/tpl/onlinepaymentlinks.tpl.php b/htdocs/core/tpl/onlinepaymentlinks.tpl.php index d34b2da6b29..dcf8e712709 100644 --- a/htdocs/core/tpl/onlinepaymentlinks.tpl.php +++ b/htdocs/core/tpl/onlinepaymentlinks.tpl.php @@ -39,6 +39,8 @@ if (!empty($conf->commande->enabled)) { $langs->load("orders"); print '
'; + print ''; + print $langs->trans("EnterRefToBuildUrl", $langs->transnoentitiesnoconv("Order")).': '; print ''; print ''; @@ -62,6 +64,8 @@ if (!empty($conf->facture->enabled)) { $langs->load("bills"); print ''; + print ''; + print $langs->trans("EnterRefToBuildUrl", $langs->transnoentitiesnoconv("Invoice")).': '; print ''; print ''; @@ -85,6 +89,8 @@ if (!empty($conf->contrat->enabled)) { $langs->load("contracts"); print ''; + print ''; + print $langs->trans("EnterRefToBuildUrl", $langs->transnoentitiesnoconv("ContractLine")).': '; print ''; print ''; @@ -108,6 +114,8 @@ if (!empty($conf->adherent->enabled)) { $langs->load("members"); print ''; + print ''; + print $langs->trans("EnterRefToBuildUrl", $langs->transnoentitiesnoconv("Member")).': '; print ''; print ''; @@ -131,6 +139,8 @@ if (!empty($conf->don->enabled)) { $langs->load("members"); print ''; + print ''; + print $langs->trans("EnterRefToBuildUrl", $langs->transnoentitiesnoconv("Don")).': '; print ''; print ''; diff --git a/htdocs/paybox/admin/paybox.php b/htdocs/paybox/admin/paybox.php index 68d55558c9f..a1ceb3e4810 100644 --- a/htdocs/paybox/admin/paybox.php +++ b/htdocs/paybox/admin/paybox.php @@ -110,7 +110,7 @@ $head[$h][1] = $langs->trans("PayBox"); $head[$h][2] = 'payboxaccount'; $h++; -print ''; +print ''; print ''; print ''; diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 46f59039c36..efcef759da4 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -157,7 +157,7 @@ print load_fiche_titre($langs->trans("ModuleSetup").' Stripe', $linkback); $head = stripeadmin_prepare_head(); -print ''; +print ''; print ''; print ''; diff --git a/htdocs/stripe/charge.php b/htdocs/stripe/charge.php index 5672176168a..128a2539b75 100644 --- a/htdocs/stripe/charge.php +++ b/htdocs/stripe/charge.php @@ -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 ''; - if ($optioncss != '') print ''; - print ''; - print ''; - 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_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'title_accountancy.png', 0, '', 'hidepaginationprevious', $limit); - - print '
'; - print ''."\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"; - - //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."
"; - $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)); - } - }*/ - - // 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 ''; + $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 "\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 "\n"; + $moreforfilter = ''; - // Link - print "\n"; + print ''; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - // Origin - print "\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 '\n"; - // Type - print ''; - // Amount - print '"; - // Status - print '\n"; + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'title_accountancy.png', 0, '', 'hidepaginationprevious', $limit); + print '
'; + 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 { - print $FULLTAG; - } - } else { - print $FULLTAG; - } - 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 "
'."\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"; - $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."
"; + $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)); + } + }*/ + + // 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.'/'; + + // 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++; + } + + 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 { + print $FULLTAG; + } + } else { + print $FULLTAG; + } + 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 '
'; + } catch(Exception $e) { + print $e->getMessage(); } } diff --git a/htdocs/stripe/payout.php b/htdocs/stripe/payout.php index 6823c32c0b7..07b6b696f2b 100644 --- a/htdocs/stripe/payout.php +++ b/htdocs/stripe/payout.php @@ -109,111 +109,115 @@ if (!$rowid) { print "\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 ''; - - // 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 "".img_picto($langs->trans('ShowInStripe'), 'globe')." ".$payout->id."\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 ''; + + // 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 "".img_picto($langs->trans('ShowInStripe'), 'globe')." ".$payout->id."\n"; - // Stripe customer - //print "".$charge->customer."\n"; - // Link - /*print ""; - if ($societestatic->id > 0) - { - print $societestatic->getNomUrl(1); + // Stripe customer + //print "".$charge->customer."\n"; + // Link + /*print ""; + if ($societestatic->id > 0) + { + print $societestatic->getNomUrl(1); + } + if ($memberstatic->id > 0) + { + print $memberstatic->getNomUrl(1); + } + print "\n";*/ + // Origine + //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 "\n"; + // Date payment + print ''.dol_print_date($payout->created, '%d/%m/%Y %H:%M')."\n"; + // Date payment + print ''.dol_print_date($payout->arrival_date, '%d/%m/%Y %H:%M')."\n"; + // Type + print ''.$payout->description.''; + // Amount + print ''.price(($payout->amount) / 100, 0, '', 1, -1, -1, strtoupper($payout->currency)).""; + // Status + print ""; + 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 ''; + print "\n"; } - if ($memberstatic->id > 0) - { - print $memberstatic->getNomUrl(1); - } - print "\n";*/ - // Origine - //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 "\n"; - // Date payment - print ''.dol_print_date($payout->created, '%d/%m/%Y %H:%M')."\n"; - // Date payment - print ''.dol_print_date($payout->arrival_date, '%d/%m/%Y %H:%M')."\n"; - // Type - print ''.$payout->description.''; - // Amount - print ''.price(($payout->amount) / 100, 0, '', 1, -1, -1, strtoupper($payout->currency)).""; - // Status - print ""; - 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 ''; - print "\n"; + } catch(Exception $e) { + print ''.$e->getMessage().''; } print ""; print ''; diff --git a/htdocs/stripe/transaction.php b/htdocs/stripe/transaction.php index 6f74d1a48c0..cd75fec476c 100644 --- a/htdocs/stripe/transaction.php +++ b/htdocs/stripe/transaction.php @@ -108,117 +108,121 @@ if (!$rowid) { 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'])) + 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 ''; + + // 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 "".$txn->type.""; + } else { + print "".img_picto($langs->trans('ShowInStripe'), 'globe')." ".$txn->source."\n"; + } + + // Stripe customer + //print "".$charge->customer."\n"; + // Link + /*print ""; + if ($societestatic->id > 0) + { + print $societestatic->getNomUrl(1); + } + if ($memberstatic->id > 0) + { + print $memberstatic->getNomUrl(1); + } + print "\n";*/ + // Origine + //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 "\n"; + // Date payment + print ''.dol_print_date($txn->created, '%d/%m/%Y %H:%M')."\n"; + // Type + print ''.$txn->type.''; + // Amount + print ''.price(($txn->amount) / 100, 0, '', 1, - 1, - 1, strtoupper($txn->currency)).""; + print ''.price(($txn->fee) / 100, 0, '', 1, - 1, - 1, strtoupper($txn->currency)).""; + // Status + print ""; + 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 ''; + print "\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 ''; - - // 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 "".$txn->type.""; - } else { - print "".img_picto($langs->trans('ShowInStripe'), 'globe')." ".$txn->source."\n"; - } - - // Stripe customer - //print "".$charge->customer."\n"; - // Link - /*print ""; - if ($societestatic->id > 0) - { - print $societestatic->getNomUrl(1); - } - if ($memberstatic->id > 0) - { - print $memberstatic->getNomUrl(1); - } - print "\n";*/ - // Origine - //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 "\n"; - // Date payment - print ''.dol_print_date($txn->created, '%d/%m/%Y %H:%M')."\n"; - // Type - print ''.$txn->type.''; - // Amount - print ''.price(($txn->amount) / 100, 0, '', 1, - 1, - 1, strtoupper($txn->currency)).""; - print ''.price(($txn->fee) / 100, 0, '', 1, - 1, - 1, strtoupper($txn->currency)).""; - // Status - print ""; - 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 ''; - print "\n"; + } catch (Exception $e) { + print ''.$e->getMessage().''; } print ""; print ''; diff --git a/htdocs/variants/admin/admin.php b/htdocs/variants/admin/admin.php index 86342664c35..d97211d46bf 100644 --- a/htdocs/variants/admin/admin.php +++ b/htdocs/variants/admin/admin.php @@ -50,7 +50,9 @@ print load_fiche_titre($title, $linkback, 'title_setup'); dol_fiche_head(array(), 'general', $tab, 0, 'product'); -print '
'; +print ''; +print ''; + print ''; print ''; print '
'.$langs->trans("Parameters").''."\n";