Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into 11.0_accountancy…
Browse files Browse the repository at this point in the history
…_portal
  • Loading branch information
aspangaro committed Sep 23, 2019
2 parents a005408 + 1584a4b commit 6d4c0c3
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 36 deletions.
24 changes: 0 additions & 24 deletions htdocs/core/class/events.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,33 +87,9 @@ class Events // extends CommonObject
array('id'=>'USER_NEW_PASSWORD', 'test'=>1),
array('id'=>'USER_ENABLEDISABLE', 'test'=>1),
array('id'=>'USER_DELETE', 'test'=>1),
/* array('id'=>'USER_SETINGROUP', 'test'=>1), deprecated. Replace with USER_MODIFY
array('id'=>'USER_REMOVEFROMGROUP', 'test'=>1), deprecated. Replace with USER_MODIFY */
array('id'=>'GROUP_CREATE', 'test'=>1),
array('id'=>'GROUP_MODIFY', 'test'=>1),
array('id'=>'GROUP_DELETE', 'test'=>1),
/* array('id'=>'ACTION_CREATE', 'test'=>$conf->societe->enabled),
array('id'=>'COMPANY_CREATE', 'test'=>$conf->societe->enabled),
array('id'=>'CONTRACT_VALIDATE', 'test'=>$conf->contrat->enabled),
array('id'=>'PROPAL_VALIDATE', 'test'=>$conf->propal->enabled),
array('id'=>'PROPAL_CLOSE_SIGNED', 'test'=>$conf->propal->enabled),
array('id'=>'PROPAL_CLOSE_REFUSED', 'test'=>$conf->propal->enabled),
array('id'=>'PROPAL_SENTBYMAIL', 'test'=>$conf->propal->enabled),
array('id'=>'ORDER_VALIDATE', 'test'=>$conf->commande->enabled),
array('id'=>'ORDER_SENTBYMAIL', 'test'=>$conf->commande->enabled),
array('id'=>'BILL_VALIDATE', 'test'=>$conf->facture->enabled),
array('id'=>'BILL_PAYED', 'test'=>$conf->facture->enabled),
array('id'=>'BILL_CANCEL', 'test'=>$conf->facture->enabled),
array('id'=>'BILL_SENTBYMAIL', 'test'=>$conf->facture->enabled),
array('id'=>'PAYMENT_CUSTOMER_CREATE','test'=>$conf->facture->enabled),
array('id'=>'PAYMENT_SUPPLIER_CREATE','test'=>$conf->fournisseur->enabled),
array('id'=>'MEMBER_CREATE', 'test'=>$conf->adherent->enabled),
array('id'=>'MEMBER_VALIDATE', 'test'=>$conf->adherent->enabled),
array('id'=>'MEMBER_SUBSCRIPTION', 'test'=>$conf->adherent->enabled),
array('id'=>'MEMBER_MODIFY', 'test'=>$conf->adherent->enabled),
array('id'=>'MEMBER_RESILIATE', 'test'=>$conf->adherent->enabled),
array('id'=>'MEMBER_DELETE', 'test'=>$conf->adherent->enabled),
*/
);


Expand Down
3 changes: 2 additions & 1 deletion htdocs/install/mysql/data/llx_c_action_trigger.sql
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,13 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_CLOSE','Ticket closed','Executed when a ticket is closed','ticket',165);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_SENTBYMAIL','Ticket message sent by email','Executed when a message is sent from the ticket record','ticket',166);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_DELETE','Ticket deleted','Executed when a ticket is deleted','ticket',167);
-- actions not enabled by default (no constant created for that) when we enable module agenda
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('USER_SENTBYMAIL','Email sent','Executed when an email is sent from user card','user',300);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_MODIFY','Product or service modified','Executed when a product or sevice is modified','product',41);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_MODIFY','Member modified','Executed when a member is modified','member',23);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('FICHINTER_MODIFY','Intervention modified','Executed when a intervention is modified','ficheinter',19);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROJECT_CREATE','Project creation','Executed when a project is created','project',140);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROJECT_MODIFY','Project modified','Executed when a project is modified','project',142);
-- actions not enabled by default : they are excluded when we enable the module Agenda (except TASK_...)
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TASK_CREATE','Task created','Executed when a project task is created','project',150);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TASK_MODIFY','Task modified','Executed when a project task is modified','project',151);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TASK_DELETE','Task deleted','Executed when a project task is deleted','project',152);
5 changes: 5 additions & 0 deletions htdocs/install/mysql/migration/10.0.0-11.0.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ ALTER TABLE llx_account_bookkeeping ADD COLUMN date_export datetime DEFAULT NULL
ALTER TABLE llx_expensereport ADD COLUMN paid smallint default 0 NOT NULL;
UPDATE llx_expensereport set paid = 1 WHERE fk_statut = 6 and paid = 0;


-- For v11

insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('USER_SENTBYMAIL','Email sent','Executed when an email is sent from user card','user',300);

create table llx_entrepot_extrafields
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
Expand Down
60 changes: 49 additions & 11 deletions htdocs/stripe/class/stripe.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,16 +305,18 @@ public function getPaymentMethodStripe($paymentmethod, $key = '', $status = 0)
* @param string $currency_code Currency code
* @param string $tag Tag
* @param string $description Description
* @param Societe $object Object to pay with Stripe
* @param mixed $object Object to pay with Stripe
* @param string $customer Stripe customer ref 'cus_xxxxxxxxxxxxx' via customerStripe()
* @param string $key ''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect
* @param int $status Status (0=test, 1=live)
* @param int $usethirdpartyemailforreceiptemail 1=use thirdparty email for receipt
* @param int $mode automatic=automatic confirmation/payment when conditions are ok, manual=need to call confirm() on intent
* @param boolean $confirmnow false=default, true=try to confirm immediatly after create (if conditions are ok)
* @param string $payment_method 'pm_....' (if known)
* @param string $off_session If we use an already known payment method to pay off line.
* @return \Stripe\PaymentIntent|null Stripe PaymentIntent or null if not found and failed to create
*/
public function getPaymentIntent($amount, $currency_code, $tag, $description = '', $object = null, $customer = null, $key = null, $status = 0, $usethirdpartyemailforreceiptemail = 0, $mode = 'automatic', $confirmnow = false)
public function getPaymentIntent($amount, $currency_code, $tag, $description = '', $object = null, $customer = null, $key = null, $status = 0, $usethirdpartyemailforreceiptemail = 0, $mode = 'automatic', $confirmnow = false, $payment_method = null, $off_session = 0)
{
global $conf;

Expand All @@ -335,7 +337,7 @@ public function getPaymentIntent($amount, $currency_code, $tag, $description = '
} elseif ($fee < $conf->global->STRIPE_APPLICATION_FEE_MINIMAL) {
$fee = $conf->global->STRIPE_APPLICATION_FEE_MINIMAL;
}
if (! in_array($currency, $arrayzerounitcurrency)) $stripefee = round($fee * 100);
if (! in_array($currency_code, $arrayzerounitcurrency)) $stripefee = round($fee * 100);
else $stripefee = round($fee);

$paymentintent = null;
Expand Down Expand Up @@ -411,6 +413,12 @@ public function getPaymentIntent($amount, $currency_code, $tag, $description = '
// payment_method =
// payment_method_types = array('card')
//var_dump($dataforintent);
if ($off_session)
{
unset($dataforintent['setup_future_usage']);
$dataforintent["off_session"] = true;
}
if (! is_null($payment_method)) $dataforintent["payment_method"] = $payment_method;

if ($conf->entity!=$conf->global->STRIPECONNECT_PRINCIPAL && $stripefee > 0)
{
Expand Down Expand Up @@ -491,7 +499,7 @@ public function getPaymentIntent($amount, $currency_code, $tag, $description = '
}
}

dol_syslog("getPaymentIntent return error=".$error, LOG_INFO, -1);
dol_syslog("getPaymentIntent return error=".$error." this->error=".$this->error, LOG_INFO, -1);

if (! $error)
{
Expand Down Expand Up @@ -654,7 +662,7 @@ public function getSetupIntent($description, $object, $customer, $key, $status,
* @param string $stripeacc ''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect
* @param int $status Status (0=test, 1=live)
* @param int $createifnotlinkedtostripe 1=Create the stripe card and the link if the card is not yet linked to a stripe card
* @return \Stripe\StripeCard|null Stripe Card or null if not found
* @return \Stripe\StripeCard|\Stripe\PaymentMethod|null Stripe Card or null if not found
*/
public function cardStripe($cu, CompanyPaymentMode $object, $stripeacc = '', $status = 0, $createifnotlinkedtostripe = 0)
{
Expand All @@ -680,10 +688,24 @@ public function cardStripe($cu, CompanyPaymentMode $object, $stripeacc = '', $st
{
try {
if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage
$card = $cu->sources->retrieve($cardref);
if (! preg_match('/^pm_/', $cardref))
{
$card = $cu->sources->retrieve($cardref);
}
else
{
$card = \Stripe\PaymentMethod::retrieve($cardref);
}
} else {
//$card = $cu->sources->retrieve($cardref, array("stripe_account" => $stripeacc)); // this API fails when array stripe_account is provided
$card = $cu->sources->retrieve($cardref);
if (! preg_match('/^pm_/', $cardref))
{
//$card = $cu->sources->retrieve($cardref, array("stripe_account" => $stripeacc)); // this API fails when array stripe_account is provided
$card = $cu->sources->retrieve($cardref);
}
else {
//$card = \Stripe\PaymentMethod::retrieve($cardref, array("stripe_account" => $stripeacc)); // Don't know if this works
$card = \Stripe\PaymentMethod::retrieve($cardref);
}
}
}
catch(Exception $e)
Expand All @@ -707,12 +729,28 @@ public function cardStripe($cu, CompanyPaymentMode $object, $stripeacc = '', $st

//$a = \Stripe\Stripe::getApiKey();
//var_dump($a);var_dump($stripeacc);exit;
dol_syslog("Try to create card dataforcard = ".json_encode($dataforcard));
dol_syslog("Try to create card with dataforcard = ".json_encode($dataforcard));
try {
if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage
$card = $cu->sources->create($dataforcard);
if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION))
{
$card = $cu->sources->create($dataforcard);
}
else
{
// TODO
dol_syslog("Error: This case is not supported", LOG_ERR);
}
} else {
$card = $cu->sources->create($dataforcard, array("stripe_account" => $stripeacc));
if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION))
{
$card = $cu->sources->create($dataforcard, array("stripe_account" => $stripeacc));
}
else
{
// TODO
dol_syslog("Error: This case is not supported", LOG_ERR);
}
}

if ($card)
Expand Down

0 comments on commit 6d4c0c3

Please sign in to comment.