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) {
|
||||
//fallback on the old configuration.
|
||||
setEventMessages('WarningMandatorySetupNotComplete', [], 'errors');
|
||||
setEventMessages('WarningMandatorySetupNotComplete', null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
else {
|
||||
|
||||
@ -144,7 +144,7 @@ class DolLogsCollector extends MessagesCollector
|
||||
$linecounter = $lines;
|
||||
$pos = -2;
|
||||
$beginning = false;
|
||||
$text = [];
|
||||
$text = array();
|
||||
while ($linecounter > 0) {
|
||||
$t = " ";
|
||||
while ($t != "\n") {
|
||||
@ -179,12 +179,12 @@ class DolLogsCollector extends MessagesCollector
|
||||
$pattern = "/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.*/";
|
||||
$log_levels = $this->getLevels();
|
||||
preg_match_all($pattern, $file, $matches);
|
||||
$log = [];
|
||||
$log = array();
|
||||
foreach ($matches as $lines) {
|
||||
foreach ($lines as $line) {
|
||||
foreach ($log_levels as $level_key => $level) {
|
||||
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/>.
|
||||
*/
|
||||
|
||||
// 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("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
|
||||
|
||||
@ -105,13 +107,13 @@ $intent = null;
|
||||
try {
|
||||
if (isset($json_obj->payment_method_id)) {
|
||||
// Create the PaymentIntent
|
||||
$intent = \Stripe\PaymentIntent::create([
|
||||
$intent = \Stripe\PaymentIntent::create(array(
|
||||
'payment_method' => $json_obj->payment_method_id,
|
||||
'amount' => 1099,
|
||||
'currency' => 'eur',
|
||||
'confirmation_method' => 'manual',
|
||||
'confirm' => true,
|
||||
]);
|
||||
));
|
||||
}
|
||||
if (isset($json_obj->payment_intent_id)) {
|
||||
$intent = \Stripe\PaymentIntent::retrieve(
|
||||
@ -122,9 +124,9 @@ try {
|
||||
generatePaymentResponse($intent);
|
||||
} catch (\Stripe\Error\Base $e) {
|
||||
// Display error on client
|
||||
echo json_encode([
|
||||
echo json_encode(array(
|
||||
'error' => $e->getMessage()
|
||||
]);
|
||||
));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -138,22 +140,22 @@ function generatePaymentResponse($intent)
|
||||
if ($intent->status == 'requires_source_action' &&
|
||||
$intent->next_action->type == 'use_stripe_sdk') {
|
||||
// Tell the client to handle the action
|
||||
echo json_encode([
|
||||
echo json_encode(array(
|
||||
'requires_action' => true,
|
||||
'payment_intent_client_secret' => $intent->client_secret
|
||||
]);
|
||||
));
|
||||
} elseif ($intent->status == 'succeeded') {
|
||||
// The payment didn’t need any additional actions and completed!
|
||||
// Handle post-payment fulfillment
|
||||
|
||||
// TODO
|
||||
|
||||
echo json_encode([
|
||||
echo json_encode(array(
|
||||
"success" => true
|
||||
]);
|
||||
));
|
||||
} else {
|
||||
// Invalid status
|
||||
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;
|
||||
|
||||
$accounts =[];
|
||||
$accounts = array();
|
||||
|
||||
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){
|
||||
$object= [];
|
||||
$object= array();
|
||||
foreach($account as $key => $value)
|
||||
if(in_array($key, $fields)){
|
||||
$object[$key] = $value;
|
||||
@ -1308,7 +1308,7 @@ $reshook = $hookmanager->executeHooks('replaceThirdparty', array(
|
||||
|
||||
$i=0;
|
||||
|
||||
$accounts =[];
|
||||
$accounts = array();
|
||||
|
||||
$num = $db->num_rows($result);
|
||||
while ($i < $num)
|
||||
@ -1322,12 +1322,12 @@ $reshook = $hookmanager->executeHooks('replaceThirdparty', array(
|
||||
$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){
|
||||
$object= [];
|
||||
$object= array();
|
||||
foreach($account as $key => $value)
|
||||
if(in_array($key, $fields)){
|
||||
$object[$key] = $value;
|
||||
|
||||
@ -639,7 +639,7 @@ if (empty($reshook))
|
||||
try {
|
||||
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)
|
||||
{
|
||||
$payment_method->detach();
|
||||
|
||||
@ -389,7 +389,7 @@ class Stripe extends CommonObject
|
||||
"confirmation_method" => $mode,
|
||||
"amount" => $stripeamount,
|
||||
"currency" => $currency_code,
|
||||
"payment_method_types" => ["card"],
|
||||
"payment_method_types" => array("card"),
|
||||
"description" => $description,
|
||||
"statement_descriptor" => dol_trunc($tag, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description)
|
||||
//"save_payment_method" => true,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user