30require_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/commonhookactions.class.php';
44 private $config = array();
71 $service =
'StripeTest';
72 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Stripe'),
'',
'warning');
74 $service =
'StripeLive';
77 if (is_array($parameters) && !empty($parameters)) {
78 foreach ($parameters as $key => $value) {
84 $this->resprints .=
'<tr><td>';
85 $this->resprints .=
'<table width="100%" class="nobordernopadding"><tr><td>';
86 $this->resprints .= $langs->trans(
'StripeCustomer');
87 $this->resprints .=
'<td><td class="right">';
89 $this->resprints .=
'</td></tr></table>';
90 $this->resprints .=
'</td>';
91 $this->resprints .=
'<td colspan="3">';
92 $stripe =
new Stripe($this->db);
93 if ($stripe->getStripeAccount($service) &&
$object->client != 0) {
94 $customer = $stripe->customerStripe(
$object, $stripe->getStripeAccount($service));
95 $this->resprints .= $customer->id;
97 $this->resprints .= $langs->trans(
"NoStripe");
99 $this->resprints .=
'</td></tr>';
101 $this->resprints .=
'<tr><td>';
102 $this->resprints .=
'<table width="100%" class="nobordernopadding"><tr><td>';
103 $this->resprints .= $langs->trans(
'StripeCustomer');
104 $this->resprints .=
'<td><td class="right">';
105 $this->resprints .=
'</td></tr></table>';
106 $this->resprints .=
'</td>';
107 $this->resprints .=
'<td colspan="3">';
108 $stripe =
new Stripe($this->db);
109 if ($stripe->getStripeAccount($service) &&
$object->fk_soc > 0) {
111 $customer = $stripe->customerStripe(
$object->thirdparty, $stripe->getStripeAccount($service));
112 $this->resprints .= $customer->id;
114 $this->resprints .= $langs->trans(
"NoStripe");
116 $this->resprints .=
'</td></tr>';
118 $this->resprints .=
'<tr><td>';
119 $this->resprints .=
'<table width="100%" class="nobordernopadding"><tr><td>';
120 $this->resprints .= $langs->trans(
'SubscriptionStripe');
121 $this->resprints .=
'<td><td class="right">';
122 $this->resprints .=
'</td></tr></table>';
123 $this->resprints .=
'</td>';
124 $this->resprints .=
'<td colspan="3">';
125 $stripe =
new Stripe($this->db);
128 $customer = $stripe->customerStripe(
$object, $stripe->getStripeAccount($service));
129 $this->resprints .= $customer->id;
131 $this->resprints .= $langs->trans(
"NoStripe");
133 $this->resprints .=
'</td></tr>';
135 $this->resprints .=
'<tr><td>';
136 $this->resprints .=
'<table width="100%" class="nobordernopadding"><tr><td>';
137 $this->resprints .= $langs->trans(
'PlanStripe');
138 $this->resprints .=
'<td><td class="right">';
140 $this->resprints .=
'</td></tr></table>';
141 $this->resprints .=
'</td>';
142 $this->resprints .=
'<td colspan="3">';
143 $stripe =
new Stripe($this->db);
146 $customer = $stripe->customerStripe(
$object, $stripe->getStripeAccount($service));
147 $this->resprints .= $customer->id;
149 $this->resprints .= $langs->trans(
"NoStripe");
151 $this->resprints .=
'</td></tr>';
166 global $conf, $langs;
170 $sql =
'SELECT pf.amount';
171 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiement_facture as pf';
172 $sql .=
' WHERE pf.fk_facture = '.((int)
$object->id);
176 $result = $this->db->query($sql);
179 $num = $this->db->num_rows($result);
182 $objp = $this->db->fetch_object($result);
183 $totalpaid += $objp->amount;
190 $resteapayer =
$object->total_ttc - $totalpaid;
193 $stripe =
new Stripe($this->db);
194 if ($resteapayer > 0) {
195 if ($stripe->getStripeAccount($conf->entity)) {
196 $langs->load(
"withdrawals");
197 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>';
199 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$langs->trans(
"StripeConnectPay").
'</a>';
201 } elseif ($resteapayer == 0) {
202 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$langs->trans(
"StripeConnectPay").
'</a>';
205 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$langs->trans(
"StripeConnectPay").
'</a>';
207 } elseif (is_object(
$object) &&
$object->element ==
'invoice_supplier') {
208 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"StripeConnectPay")).
'">'.$langs->trans(
"StripeConnectPay").
'</a>';
210 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 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...