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 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 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) {
115 $customer = $stripe->customerStripe(
$object->thirdparty, $stripe->getStripeAccount($service));
116 $this->resprints .= $customer->id;
119 $this->resprints .= $langs->trans(
"NoStripe");
121 $this->resprints .=
'</td></tr>';
123 $this->resprints .=
'<tr><td>';
124 $this->resprints .=
'<table class="nobordernopadding"><tr><td>';
125 $this->resprints .= $langs->trans(
'SubscriptionStripe');
126 $this->resprints .=
'<td><td class="right">';
127 $this->resprints .=
'</td></tr></table>';
128 $this->resprints .=
'</td>';
129 $this->resprints .=
'<td colspan="3">';
130 $stripe =
new Stripe($this->db);
133 $customer = $stripe->customerStripe(
$object, $stripe->getStripeAccount($service));
134 $this->resprints .= $customer->id;
136 $this->resprints .= $langs->trans(
"NoStripe");
138 $this->resprints .=
'</td></tr>';
153 global
$conf, $langs;
157 $sql =
'SELECT pf.amount';
158 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiement_facture as pf';
159 $sql .=
' WHERE pf.fk_facture = '.((int)
$object->id);
163 $result = $this->db->query($sql);
166 $num = $this->db->num_rows($result);
169 $objp = $this->db->fetch_object($result);
170 $totalpaid += $objp->amount;
177 $resteapayer =
$object->total_ttc - $totalpaid;
180 $stripe =
new Stripe($this->db);
181 if ($resteapayer > 0) {
183 $service =
'StripeTest';
184 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Stripe'), [],
'warning');
186 $service =
'StripeLive';
189 if ($stripe->getStripeAccount($service, 0,
$conf->entity)) {
190 $langs->load(
"withdrawals");
191 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>';
193 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$langs->trans(
"StripeConnectPay").
'</a>';
195 } elseif ($resteapayer == 0) {
196 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$langs->trans(
"StripeConnectPay").
'</a>';
199 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$langs->trans(
"StripeConnectPay").
'</a>';
201 } elseif (is_object(
$object) &&
$object->element ==
'invoice_supplier') {
202 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"StripeConnectPay")).
'">'.$langs->trans(
"StripeConnectPay").
'</a>';
204 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"StripeAutoSubscription")).
'">'.$langs->trans(
"StripeAutoSubscription").
'</a>';
if(! $sortfield) if(! $sortorder) $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.
Class to manage third parties objects (customers, suppliers, prospects...)
Stripe class @TODO No reason to extend CommonObject.
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.
isModEnabled($module)
Is Dolibarr module enabled.
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...