Skip to content

Commit 7457d55

Browse files
author
Mplus Software
committed
Update to client v0.9.4
New function: getDatabaseVersion() New function: getActiveEmployeeList() New function: payInvoice() New function: encryptString()
1 parent 788388f commit 7457d55

1 file changed

Lines changed: 128 additions & 16 deletions

File tree

Mplusqapiclient.php

Lines changed: 128 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class MplusQAPIclient
44
{
5-
const CLIENT_VERSION = '0.9.2';
5+
const CLIENT_VERSION = '0.9.4';
66

77
var $MIN_API_VERSION_MAJOR = 0;
88
var $MIN_API_VERSION_MINOR = 9;
@@ -347,6 +347,20 @@ public function getApiVersion()
347347

348348
//----------------------------------------------------------------------------
349349

350+
public function getDatabaseVersion()
351+
{
352+
try {
353+
$result = $this->client->getDatabaseVersion();
354+
return $this->parser->parseDatabaseVersion($result);
355+
} catch (SoapFault $e) {
356+
throw new MplusQAPIException('SoapFault occurred: '.$e->getMessage(), 0, $e);
357+
} catch (Exception $e) {
358+
throw new MplusQAPIException('Exception occurred: '.$e->getMessage(), 0, $e);
359+
}
360+
} // END getDatabaseVersion()
361+
362+
//----------------------------------------------------------------------------
363+
350364
public function getAvailableTerminalList()
351365
{
352366
try {
@@ -392,6 +406,20 @@ public function getArticlesInLayout($terminal)
392406

393407
//----------------------------------------------------------------------------
394408

409+
public function getActiveEmployeeList($terminal)
410+
{
411+
try {
412+
$result = $this->client->getActiveEmployeeList($this->parser->convertTerminal($terminal));
413+
return $this->parser->parseActiveEmployeeList($result);
414+
} catch (SoapFault $e) {
415+
throw new MplusQAPIException('SoapFault occurred: '.$e->getMessage(), 0, $e);
416+
} catch (Exception $e) {
417+
throw new MplusQAPIException('Exception occurred: '.$e->getMessage(), 0, $e);
418+
}
419+
} // END getActiveEmployeeList()
420+
421+
//----------------------------------------------------------------------------
422+
395423
public function getVatGroupList()
396424
{
397425
try {
@@ -590,6 +618,20 @@ public function payOrder($orderId, $prepay, $paymentList)
590618

591619
//----------------------------------------------------------------------------
592620

621+
public function payInvoice($invoiceId, $paymentList)
622+
{
623+
try {
624+
$result = $this->client->payInvoice($this->parser->convertPayInvoiceRequest($invoiceId, $paymentList));
625+
return $this->parser->parsePayInvoiceResult($result);
626+
} catch (SoapFault $e) {
627+
throw new MplusQAPIException('SoapFault occurred: '.$e->getMessage(), 0, $e);
628+
} catch (Exception $e) {
629+
throw new MplusQAPIException('Exception occurred: '.$e->getMessage(), 0, $e);
630+
}
631+
} // END payInvoice()
632+
633+
//----------------------------------------------------------------------------
634+
593635
public function deliverOrder($orderId)
594636
{
595637
try {
@@ -716,20 +758,6 @@ public function findInvoice($extInvoiceId)
716758

717759
//----------------------------------------------------------------------------
718760

719-
public function payInvoice($orderId, $prepay, $paymentList)
720-
{
721-
try {
722-
$result = $this->client->payInvoice($this->parser->convertPayInvoiceRequest($orderId, $prepay, $paymentList));
723-
return $this->parser->parsePayOrderResult($result);
724-
} catch (SoapFault $e) {
725-
throw new MplusQAPIException('SoapFault occurred: '.$e->getMessage(), 0, $e);
726-
} catch (Exception $e) {
727-
throw new MplusQAPIException('Exception occurred: '.$e->getMessage(), 0, $e);
728-
}
729-
} // END payInvoice()
730-
731-
//----------------------------------------------------------------------------
732-
733761
public function getJournals($fromFinancialDate, $throughFinancialDate, $branchNumbers, $journalFilterList = array())
734762
{
735763
try {
@@ -1019,6 +1047,22 @@ public function sendMessage($branchNumber, $terminalNumber, $text)
10191047
}
10201048
} // END sendMessage()
10211049

1050+
//----------------------------------------------------------------------------
1051+
1052+
public function encryptString($plainString, $encryptionKey)
1053+
{
1054+
try {
1055+
$result = $this->client->encryptString($this->parser->convertEncryptStringRequest($plainString, $encryptionKey));
1056+
return $this->parser->parseEncryptStringResult($result);
1057+
} catch (SoapFault $e) {
1058+
throw new MplusQAPIException('SoapFault occurred: '.$e->getMessage(), 0, $e);
1059+
} catch (Exception $e) {
1060+
throw new MplusQAPIException('Exception occurred: '.$e->getMessage(), 0, $e);
1061+
}
1062+
} // END encryptString()
1063+
1064+
//----------------------------------------------------------------------------
1065+
10221066
}
10231067

10241068
//==============================================================================
@@ -1051,6 +1095,20 @@ public function parseApiVersion($soapApiVersion)
10511095

10521096
//----------------------------------------------------------------------------
10531097

1098+
public function parseDatabaseVersion($soapdatabaseVersion)
1099+
{
1100+
$databaseVersion = false;
1101+
if (isset($soapdatabaseVersion->majorNumber)) {
1102+
$databaseVersion = objectToArray($soapdatabaseVersion);
1103+
}
1104+
else if (isset($soapdatabaseVersion['majorNumber'])) {
1105+
$databaseVersion = $soapdatabaseVersion;
1106+
}
1107+
return $databaseVersion;
1108+
} // END parseDatabaseVersion()
1109+
1110+
//----------------------------------------------------------------------------
1111+
10541112
public function parseTerminalList($soapTerminalList) {
10551113
if (isset($soapTerminalList->return)) {
10561114
$soapTerminalList = $soapTerminalList->return;
@@ -1076,6 +1134,20 @@ public function parseTerminalList($soapTerminalList) {
10761134

10771135
//----------------------------------------------------------------------------
10781136

1137+
public function parseActiveEmployeeList($soapActiveEmployeeList)
1138+
{
1139+
if (isset($soapActiveEmployeeList->return)) {
1140+
$soapActiveEmployeeList = $soapActiveEmployeeList->return;
1141+
}
1142+
$active_employees = array();
1143+
foreach ($soapActiveEmployeeList as $soapActiveEmployee) {
1144+
$active_employees[] = objectToArray($soapActiveEmployee);
1145+
}
1146+
return $active_employees;
1147+
} // END parseActiveEmployeeList()
1148+
1149+
//----------------------------------------------------------------------------
1150+
10791151
public function parseVatGroupList($soapVatGroupList)
10801152
{
10811153
if (isset($soapVatGroupList->vatGroup)) {
@@ -1356,6 +1428,15 @@ public function parseOrderCategories($soapOrderCategories)
13561428
}
13571429
return false;
13581430
} // END parseOrderCategories()
1431+
1432+
//----------------------------------------------------------------------------
1433+
1434+
public function parsePayInvoiceResult($soapPayInvoiceResult) {
1435+
if (isset($soapPayInvoiceResult->result) and $soapPayInvoiceResult->result == 'PAY-INVOICE-RESULT-OK') {
1436+
return true;
1437+
}
1438+
return false;
1439+
} // END parsePayInvoiceResult()
13591440

13601441
//----------------------------------------------------------------------------
13611442

@@ -1831,7 +1912,16 @@ public function parseSendMessageResult($soapSendMessageResult) {
18311912
return strtolower($soapSendMessageResult->response) == 'true';
18321913
}
18331914
return false;
1834-
} // END parseSendMessageResult())
1915+
} // END parseSendMessageResult()
1916+
1917+
//----------------------------------------------------------------------------
1918+
1919+
public function parseEncryptStringResult($soapEncryptStringResult) {
1920+
if (isset($soapEncryptStringResult->encryptedString)) {
1921+
return $soapEncryptStringResult->encryptedString;
1922+
}
1923+
return false;
1924+
} // END parseEncryptStringResult()
18351925

18361926
//----------------------------------------------------------------------------
18371927

@@ -2170,6 +2260,18 @@ public function convertGetCashCountListRequest($fromFinancialDate, $throughFinan
21702260

21712261
//----------------------------------------------------------------------------
21722262

2263+
public function convertPayInvoiceRequest($invoiceId, $paymentList)
2264+
{
2265+
$array = array('request'=>array(
2266+
'invoiceId'=>$invoiceId,
2267+
'paymentList'=>$this->convertPaymentList($paymentList),
2268+
));
2269+
$object = arrayToObject($array);
2270+
return $object;
2271+
} // END convertPayInvoiceRequest()
2272+
2273+
//----------------------------------------------------------------------------
2274+
21732275
public function convertPayOrderRequest($orderId, $prepay, $paymentList)
21742276
{
21752277
$array = array('request'=>array(
@@ -2282,6 +2384,16 @@ public function convertSendMessageRequest($branchNumber, $terminalNumber, $text)
22822384

22832385
//----------------------------------------------------------------------------
22842386

2387+
public function convertEncryptStringRequest($plainString, $encryptionKey)
2388+
{
2389+
$object = arrayToObject(array('request'=>array(
2390+
'plainString'=>$plainString,
2391+
'encryptionKey'=>$encryptionKey)));
2392+
return $object;
2393+
} // END convertEncryptStringRequest()
2394+
2395+
//----------------------------------------------------------------------------
2396+
22852397
public function convertExtOrderId($extOrderId) {
22862398
return arrayToObject(array('extOrderId'=>$extOrderId));
22872399
} // END convertExtOrderId()

0 commit comments

Comments
 (0)