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 '@phan-var-force Societe $object';
86 $this->resprints .=
'<tr><td>';
87 $this->resprints .=
'<table width="100%" class="nobordernopadding"><tr><td>';
88 $this->resprints .= $langs->trans(
'StripeCustomer');
89 $this->resprints .=
'<td><td class="right">';
91 $this->resprints .=
'</td></tr></table>';
92 $this->resprints .=
'</td>';
93 $this->resprints .=
'<td colspan="3">';
94 $stripe =
new Stripe($this->db);
95 if ($stripe->getStripeAccount($service) &&
$object->client != 0) {
96 $customer = $stripe->customerStripe(
$object, $stripe->getStripeAccount($service));
97 $this->resprints .= $customer->id;
99 $this->resprints .= $langs->trans(
"NoStripe");
101 $this->resprints .=
'</td></tr>';
103 '@phan-var-force Adherent $object';
104 $this->resprints .=
'<tr><td>';
105 $this->resprints .=
'<table width="100%" class="nobordernopadding"><tr><td>';
106 $this->resprints .= $langs->trans(
'StripeCustomer');
107 $this->resprints .=
'<td><td class="right">';
108 $this->resprints .=
'</td></tr></table>';
109 $this->resprints .=
'</td>';
110 $this->resprints .=
'<td colspan="3">';
111 $stripe =
new Stripe($this->db);
112 if ($stripe->getStripeAccount($service) &&
$object->fk_soc > 0) {
114 $customer = $stripe->customerStripe(
$object->thirdparty, $stripe->getStripeAccount($service));
115 $this->resprints .= $customer->id;
117 $this->resprints .= $langs->trans(
"NoStripe");
119 $this->resprints .=
'</td></tr>';
121 $this->resprints .=
'<tr><td>';
122 $this->resprints .=
'<table width="100%" class="nobordernopadding"><tr><td>';
123 $this->resprints .= $langs->trans(
'SubscriptionStripe');
124 $this->resprints .=
'<td><td class="right">';
125 $this->resprints .=
'</td></tr></table>';
126 $this->resprints .=
'</td>';
127 $this->resprints .=
'<td colspan="3">';
128 $stripe =
new Stripe($this->db);
131 $customer = $stripe->customerStripe(
$object, $stripe->getStripeAccount($service));
132 $this->resprints .= $customer->id;
134 $this->resprints .= $langs->trans(
"NoStripe");
136 $this->resprints .=
'</td></tr>';
138 '@phan-var-force Adherent $object';
139 $this->resprints .=
'<tr><td>';
140 $this->resprints .=
'<table width="100%" class="nobordernopadding"><tr><td>';
141 $this->resprints .= $langs->trans(
'PlanStripe');
142 $this->resprints .=
'<td><td class="right">';
144 $this->resprints .=
'</td></tr></table>';
145 $this->resprints .=
'</td>';
146 $this->resprints .=
'<td colspan="3">';
147 $stripe =
new Stripe($this->db);
150 $customer = $stripe->customerStripe(
$object, $stripe->getStripeAccount($service));
151 $this->resprints .= $customer->id;
153 $this->resprints .= $langs->trans(
"NoStripe");
155 $this->resprints .=
'</td></tr>';
170 global $conf, $langs;
174 $sql =
'SELECT pf.amount';
175 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiement_facture as pf';
176 $sql .=
' WHERE pf.fk_facture = '.((int)
$object->id);
180 $result = $this->db->query($sql);
183 $num = $this->db->num_rows($result);
186 $objp = $this->db->fetch_object($result);
187 $totalpaid += $objp->amount;
194 $resteapayer =
$object->total_ttc - $totalpaid;
197 $stripe =
new Stripe($this->db);
198 if ($resteapayer > 0) {
199 if ($stripe->getStripeAccount($conf->entity)) {
200 $langs->load(
"withdrawals");
201 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>';
203 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$langs->trans(
"StripeConnectPay").
'</a>';
205 } elseif ($resteapayer == 0) {
206 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$langs->trans(
"StripeConnectPay").
'</a>';
209 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$langs->trans(
"StripeConnectPay").
'</a>';
211 } elseif (is_object(
$object) &&
$object->element ==
'invoice_supplier') {
212 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"StripeConnectPay")).
'">'.$langs->trans(
"StripeConnectPay").
'</a>';
214 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...