Skip to content

Commit ed0f24e

Browse files
committed
Merge branch 'master' of [email protected]:/DoliCloud/dolimods
2 parents cc84f60 + 9d8a972 commit ed0f24e

File tree

2 files changed

+59
-13
lines changed

2 files changed

+59
-13
lines changed

SECURITY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ Reports are processed around once a month.
5454

5555
## Scope for qualified vulnerabilities
5656

57+
Security report are valid only for modules with the status 'Stable'. A module is stable when its version is a number x.y instead of the key 'experimental' or 'development' See the file htdocs/modulename/core/modules/modModuleName.class.php, line $this->version = '...';
58+
5759
ONLY vulnerabilities discovered, when the following setup on test platform is used, are "valid":
5860

5961
* The version to analyze must be the last version available in the "develop" branch or in the last stable "vX.Y" released version. Reports on vulnerabilities already fixed (so already reported) in the develop branch will not be validated.

htdocs/stancerdolicloud/class/actions_stancerdolicloud.class.php

Lines changed: 57 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,9 @@ public function isPaymentOK($parameters, &$object, &$action, $hookmanager)
558558
{
559559
global $langs;
560560

561+
require_once DOL_DOCUMENT_ROOT."/core/lib/geturl.lib.php";
562+
include_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
563+
561564
$error = 0; // Error counter
562565
$ispaymentok = false;
563566

@@ -568,21 +571,62 @@ public function isPaymentOK($parameters, &$object, &$action, $hookmanager)
568571
$ispaymentok = false;
569572
$error ++;
570573
} else {
571-
// TODO Do a check with payplug api call
572-
573-
574-
575-
$ispaymentok = true;
574+
$stancerurlapi = "api.stancer.com";
575+
$stancerurlpayment = "payment.stancer.com";
576+
if (getDolGlobalInt("STANCER_DOLICLOUD_LIVE")) {
577+
$secretapikey = getDolGlobalString("STANCER_DOLICLOUD_PROD_SECRET_API_KEY");
578+
} else {
579+
$secretapikey = getDolGlobalString("STANCER_DOLICLOUD_TEST_SECRET_API_KEY");
580+
}
581+
$encodedkey = dol_encode($secretapikey, 0);
582+
$headers = array();
583+
$headers[] = "accept: application/json";
584+
$headers[] = "Authorization: Basic ".$encodedkey;
585+
$headers[] = "Content-Type: application/json";
586+
587+
$FinalPaymentID = $_SESSION["STANCER_DOLICLOUD_PAYMENT_ID"];
588+
$urlforcheckout = "https://".urlencode($stancerurlapi)."/v2/payment_intents/".$FinalPaymentID;
589+
dol_syslog("Send Get to url=".$urlforcheckout." with session STANCER_DOLICLOUD_PAYMENT_ID = ".$FinalPaymentID, LOG_DEBUG);
590+
$ret1 = getURLContent($urlforcheckout, 'GET', "", 1, $headers);
591+
if ($ret1["http_code"] == 200) {
592+
$result1 = $ret1["content"];
593+
$json = json_decode($result1);
594+
if (in_array($json->status, array("captured", "authorized", "capture_sent", "to_capture"))) {
595+
$ispaymentok = true;
596+
}
597+
} else {
598+
$arrayofmessage = array();
599+
if (!empty($ret1['content'])) {
600+
$arrayofmessage = json_decode($ret1['content'], true);
601+
}
602+
if (!empty($arrayofmessage['message'])) {
603+
$this->errors[] = $arrayofmessage['message'];
604+
} else {
605+
if (!empty($arrayofmessage['errors']) && is_array($arrayofmessage['errors'])) {
606+
foreach($arrayofmessage['errors'] as $tmpkey => $tmpmessage) {
607+
if (!empty($tmpmessage['message'])) {
608+
$this->errors[] = $langs->trans("Error").' - '.$tmpmessage['message'];
609+
} else {
610+
$this->errors[] = $langs->trans("UnkownError").' - HTTP code = '.$ret1["http_code"];
611+
}
612+
}
613+
} else {
614+
$this->errors[] = $langs->trans("UnkownError").' - HTTP code = '.$ret1["http_code"];
615+
}
616+
}
617+
$error++;
618+
$ispaymentok = false;
619+
}
620+
}
621+
if (!$error) {
622+
$this->results["ispaymentok"] = $ispaymentok;
623+
return 1;
624+
} else {
625+
$this->errors[] = $langs->trans("PaymentRefused");
626+
return -1;
576627
}
577628
}
578-
579-
if (!$error) {
580-
$this->results["ispaymentok"] = $ispaymentok;
581-
return 1;
582-
} else {
583-
$this->errors[] = $langs->trans("PaymentRefused");
584-
return -1;
585-
}
629+
return 0;
586630
}
587631

588632
/**

0 commit comments

Comments
 (0)