FIX Better PHP compatibility
This commit is contained in:
parent
e0095871aa
commit
2a05164bb1
@ -734,7 +734,7 @@ if (empty($reshook))
|
|||||||
|
|
||||||
if (empty($labeltouse) || (int) $labeltouse === -1) {
|
if (empty($labeltouse) || (int) $labeltouse === -1) {
|
||||||
//fallback on the old configuration.
|
//fallback on the old configuration.
|
||||||
setEventMessages('WarningMandatorySetupNotComplete', [], 'errors');
|
setEventMessages('WarningMandatorySetupNotComplete', null, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@ -144,7 +144,7 @@ class DolLogsCollector extends MessagesCollector
|
|||||||
$linecounter = $lines;
|
$linecounter = $lines;
|
||||||
$pos = -2;
|
$pos = -2;
|
||||||
$beginning = false;
|
$beginning = false;
|
||||||
$text = [];
|
$text = array();
|
||||||
while ($linecounter > 0) {
|
while ($linecounter > 0) {
|
||||||
$t = " ";
|
$t = " ";
|
||||||
while ($t != "\n") {
|
while ($t != "\n") {
|
||||||
@ -179,12 +179,12 @@ class DolLogsCollector extends MessagesCollector
|
|||||||
$pattern = "/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.*/";
|
$pattern = "/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.*/";
|
||||||
$log_levels = $this->getLevels();
|
$log_levels = $this->getLevels();
|
||||||
preg_match_all($pattern, $file, $matches);
|
preg_match_all($pattern, $file, $matches);
|
||||||
$log = [];
|
$log = array();
|
||||||
foreach ($matches as $lines) {
|
foreach ($matches as $lines) {
|
||||||
foreach ($lines as $line) {
|
foreach ($lines as $line) {
|
||||||
foreach ($log_levels as $level_key => $level) {
|
foreach ($log_levels as $level_key => $level) {
|
||||||
if (strpos(strtolower($line), strtolower($level_key)) == 20) {
|
if (strpos(strtolower($line), strtolower($level_key)) == 20) {
|
||||||
$log[] = ['level' => $level, 'line' => $line];
|
$log[] = array('level' => $level, 'line' => $line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,6 +15,8 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// TODO Do we really need this page. We alread have a ipn.php page !
|
||||||
|
|
||||||
define("NOLOGIN", 1); // This means this output page does not require to be logged.
|
define("NOLOGIN", 1); // This means this output page does not require to be logged.
|
||||||
define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
|
define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
|
||||||
|
|
||||||
@ -105,13 +107,13 @@ $intent = null;
|
|||||||
try {
|
try {
|
||||||
if (isset($json_obj->payment_method_id)) {
|
if (isset($json_obj->payment_method_id)) {
|
||||||
// Create the PaymentIntent
|
// Create the PaymentIntent
|
||||||
$intent = \Stripe\PaymentIntent::create([
|
$intent = \Stripe\PaymentIntent::create(array(
|
||||||
'payment_method' => $json_obj->payment_method_id,
|
'payment_method' => $json_obj->payment_method_id,
|
||||||
'amount' => 1099,
|
'amount' => 1099,
|
||||||
'currency' => 'eur',
|
'currency' => 'eur',
|
||||||
'confirmation_method' => 'manual',
|
'confirmation_method' => 'manual',
|
||||||
'confirm' => true,
|
'confirm' => true,
|
||||||
]);
|
));
|
||||||
}
|
}
|
||||||
if (isset($json_obj->payment_intent_id)) {
|
if (isset($json_obj->payment_intent_id)) {
|
||||||
$intent = \Stripe\PaymentIntent::retrieve(
|
$intent = \Stripe\PaymentIntent::retrieve(
|
||||||
@ -122,9 +124,9 @@ try {
|
|||||||
generatePaymentResponse($intent);
|
generatePaymentResponse($intent);
|
||||||
} catch (\Stripe\Error\Base $e) {
|
} catch (\Stripe\Error\Base $e) {
|
||||||
// Display error on client
|
// Display error on client
|
||||||
echo json_encode([
|
echo json_encode(array(
|
||||||
'error' => $e->getMessage()
|
'error' => $e->getMessage()
|
||||||
]);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -138,22 +140,22 @@ function generatePaymentResponse($intent)
|
|||||||
if ($intent->status == 'requires_source_action' &&
|
if ($intent->status == 'requires_source_action' &&
|
||||||
$intent->next_action->type == 'use_stripe_sdk') {
|
$intent->next_action->type == 'use_stripe_sdk') {
|
||||||
// Tell the client to handle the action
|
// Tell the client to handle the action
|
||||||
echo json_encode([
|
echo json_encode(array(
|
||||||
'requires_action' => true,
|
'requires_action' => true,
|
||||||
'payment_intent_client_secret' => $intent->client_secret
|
'payment_intent_client_secret' => $intent->client_secret
|
||||||
]);
|
));
|
||||||
} elseif ($intent->status == 'succeeded') {
|
} elseif ($intent->status == 'succeeded') {
|
||||||
// The payment didn’t need any additional actions and completed!
|
// The payment didn’t need any additional actions and completed!
|
||||||
// Handle post-payment fulfillment
|
// Handle post-payment fulfillment
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
echo json_encode([
|
echo json_encode(array(
|
||||||
"success" => true
|
"success" => true
|
||||||
]);
|
));
|
||||||
} else {
|
} else {
|
||||||
// Invalid status
|
// Invalid status
|
||||||
http_response_code(500);
|
http_response_code(500);
|
||||||
echo json_encode(['error' => 'Invalid PaymentIntent status']);
|
echo json_encode(array('error' => 'Invalid PaymentIntent status'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1041,7 +1041,7 @@ $reshook = $hookmanager->executeHooks('replaceThirdparty', array(
|
|||||||
|
|
||||||
$i=0;
|
$i=0;
|
||||||
|
|
||||||
$accounts =[];
|
$accounts = array();
|
||||||
|
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
@ -1061,12 +1061,12 @@ $reshook = $hookmanager->executeHooks('replaceThirdparty', array(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$fields = ['socid', 'default_rib', 'frstrecur', '1000110000001', 'datec', 'datem', 'label', 'bank', 'bic', 'iban', 'id', 'rum'];
|
$fields = array('socid', 'default_rib', 'frstrecur', '1000110000001', 'datec', 'datem', 'label', 'bank', 'bic', 'iban', 'id', 'rum');
|
||||||
|
|
||||||
$returnAccounts = [];
|
$returnAccounts = array();
|
||||||
|
|
||||||
foreach($accounts as $account){
|
foreach($accounts as $account){
|
||||||
$object= [];
|
$object= array();
|
||||||
foreach($account as $key => $value)
|
foreach($account as $key => $value)
|
||||||
if(in_array($key, $fields)){
|
if(in_array($key, $fields)){
|
||||||
$object[$key] = $value;
|
$object[$key] = $value;
|
||||||
@ -1308,7 +1308,7 @@ $reshook = $hookmanager->executeHooks('replaceThirdparty', array(
|
|||||||
|
|
||||||
$i=0;
|
$i=0;
|
||||||
|
|
||||||
$accounts =[];
|
$accounts = array();
|
||||||
|
|
||||||
$num = $db->num_rows($result);
|
$num = $db->num_rows($result);
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
@ -1322,12 +1322,12 @@ $reshook = $hookmanager->executeHooks('replaceThirdparty', array(
|
|||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = ['id', 'fk_soc', 'key_account', 'site', 'date_creation', 'tms'];
|
$fields = array('id', 'fk_soc', 'key_account', 'site', 'date_creation', 'tms');
|
||||||
|
|
||||||
$returnAccounts = [];
|
$returnAccounts = array();
|
||||||
|
|
||||||
foreach($accounts as $account){
|
foreach($accounts as $account){
|
||||||
$object= [];
|
$object= array();
|
||||||
foreach($account as $key => $value)
|
foreach($account as $key => $value)
|
||||||
if(in_array($key, $fields)){
|
if(in_array($key, $fields)){
|
||||||
$object[$key] = $value;
|
$object[$key] = $value;
|
||||||
|
|||||||
@ -639,7 +639,7 @@ if (empty($reshook))
|
|||||||
try {
|
try {
|
||||||
if (preg_match('/pm_/', $source))
|
if (preg_match('/pm_/', $source))
|
||||||
{
|
{
|
||||||
$payment_method = \Stripe\PaymentMethod::retrieve($source, ["stripe_account" => $stripeacc]);
|
$payment_method = \Stripe\PaymentMethod::retrieve($source, array("stripe_account" => $stripeacc));
|
||||||
if ($payment_method)
|
if ($payment_method)
|
||||||
{
|
{
|
||||||
$payment_method->detach();
|
$payment_method->detach();
|
||||||
|
|||||||
@ -389,7 +389,7 @@ class Stripe extends CommonObject
|
|||||||
"confirmation_method" => $mode,
|
"confirmation_method" => $mode,
|
||||||
"amount" => $stripeamount,
|
"amount" => $stripeamount,
|
||||||
"currency" => $currency_code,
|
"currency" => $currency_code,
|
||||||
"payment_method_types" => ["card"],
|
"payment_method_types" => array("card"),
|
||||||
"description" => $description,
|
"description" => $description,
|
||||||
"statement_descriptor" => dol_trunc($tag, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description)
|
"statement_descriptor" => dol_trunc($tag, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description)
|
||||||
//"save_payment_method" => true,
|
//"save_payment_method" => true,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user