31require_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/class/commonhookactions.class.php';
45 private $config = array();
72 $service =
'StripeTest';
73 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Stripe'), [],
'warning');
75 $service =
'StripeLive';
78 if (is_array($parameters) && !empty($parameters)) {
79 foreach ($parameters as $key => $value) {
85 $this->resprints .=
'<tr><td>';
86 $this->resprints .=
'<table width="100%" class="nobordernopadding"><tr><td>';
87 $this->resprints .= $langs->trans(
'StripeCustomer');
88 $this->resprints .=
'<td><td class="right">';
90 $this->resprints .=
'</td></tr></table>';
91 $this->resprints .=
'</td>';
92 $this->resprints .=
'<td colspan="3">';
93 $stripe =
new Stripe($this->db);
94 if ($stripe->getStripeAccount($service) &&
$object->client != 0) {
95 $customer = $stripe->customerStripe(
$object, $stripe->getStripeAccount($service));
96 $this->resprints .= $customer->id;
98 $this->resprints .= $langs->trans(
"NoStripe");
100 $this->resprints .=
'</td></tr>';
102 $this->resprints .=
'<tr><td>';
103 $this->resprints .=
'<table width="100%" class="nobordernopadding"><tr><td>';
104 $this->resprints .= $langs->trans(
'StripeCustomer');
105 $this->resprints .=
'<td><td class="right">';
106 $this->resprints .=
'</td></tr></table>';
107 $this->resprints .=
'</td>';
108 $this->resprints .=
'<td colspan="3">';
109 $stripe =
new Stripe($this->db);
110 if ($stripe->getStripeAccount($service) &&
$object->fk_soc > 0) {
112 $customer = $stripe->customerStripe(
$object->thirdparty, $stripe->getStripeAccount($service));
113 $this->resprints .= $customer->id;
115 $this->resprints .= $langs->trans(
"NoStripe");
117 $this->resprints .=
'</td></tr>';
119 $this->resprints .=
'<tr><td>';
120 $this->resprints .=
'<table width="100%" class="nobordernopadding"><tr><td>';
121 $this->resprints .= $langs->trans(
'SubscriptionStripe');
122 $this->resprints .=
'<td><td class="right">';
123 $this->resprints .=
'</td></tr></table>';
124 $this->resprints .=
'</td>';
125 $this->resprints .=
'<td colspan="3">';
126 $stripe =
new Stripe($this->db);
129 $customer = $stripe->customerStripe(
$object, $stripe->getStripeAccount($service));
130 $this->resprints .= $customer->id;
132 $this->resprints .= $langs->trans(
"NoStripe");
134 $this->resprints .=
'</td></tr>';
136 $this->resprints .=
'<tr><td>';
137 $this->resprints .=
'<table width="100%" class="nobordernopadding"><tr><td>';
138 $this->resprints .= $langs->trans(
'PlanStripe');
139 $this->resprints .=
'<td><td class="right">';
141 $this->resprints .=
'</td></tr></table>';
142 $this->resprints .=
'</td>';
143 $this->resprints .=
'<td colspan="3">';
144 $stripe =
new Stripe($this->db);
147 $customer = $stripe->customerStripe(
$object, $stripe->getStripeAccount($service));
148 $this->resprints .= $customer->id;
150 $this->resprints .= $langs->trans(
"NoStripe");
152 $this->resprints .=
'</td></tr>';
167 global $conf, $langs;
171 $sql =
'SELECT pf.amount';
172 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiement_facture as pf';
173 $sql .=
' WHERE pf.fk_facture = '.((int)
$object->id);
177 $result = $this->db->query($sql);
180 $num = $this->db->num_rows($result);
183 $objp = $this->db->fetch_object($result);
184 $totalpaid += $objp->amount;
191 $resteapayer =
$object->total_ttc - $totalpaid;
194 $stripe =
new Stripe($this->db);
195 if ($resteapayer > 0) {
196 if ($stripe->getStripeAccount($conf->entity)) {
197 $langs->load(
"withdrawals");
198 print
'<a class="butActionDelete" href="'.dol_buildpath(
'/stripeconnect/payment.php?facid='.
$object->id.
'&action=create', 1).
'" title="'.
dol_escape_htmltag($langs->trans(
"StripeConnectPay")).
'">'.$langs->trans(
"StripeConnectPay").
'</a>';
200 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$langs->trans(
"StripeConnectPay").
'</a>';
202 } elseif ($resteapayer == 0) {
203 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$langs->trans(
"StripeConnectPay").
'</a>';
206 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$langs->trans(
"StripeConnectPay").
'</a>';
208 } elseif (is_object(
$object) &&
$object->element ==
'invoice_supplier') {
209 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"StripeConnectPay")).
'">'.$langs->trans(
"StripeConnectPay").
'</a>';
211 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"StripeAutoSubscription")).
'">'.$langs->trans(
"StripeAutoSubscription").
'</a>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Class Actions Stripe Connect.
__construct($db)
Constructor.
addMoreActionsButtons($parameters, &$object, &$action)
addMoreActionsButtons
formObjectOptions($parameters, &$object, &$action)
formObjectOptions
Parent class of all other hook actions classes.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
const STATUS_DRAFT
Draft status.
const STATUS_ABANDONED
Classified abandoned and no payment done.
Stripe class @TODO No reason to extends CommonObject.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formatted messages to output (Used to show messages on html output).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...