Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
freerk-mpluskassa committed Sep 18, 2018
2 parents 3ff3c52 + 72c3251 commit 0149bc4
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 41 deletions.
96 changes: 94 additions & 2 deletions Mplusqapiclient.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class MplusQAPIclient
{
const CLIENT_VERSION = '1.8.1';
const CLIENT_VERSION = '1.8.2';


var $MIN_API_VERSION_MAJOR = 0;
Expand Down Expand Up @@ -1470,6 +1470,34 @@ public function payOrder($orderId, $prepay, $paymentList)

//----------------------------------------------------------------------------

public function payTableOrder($terminal, $order, $paymentList, $keepTableName = null, $releaseTable = null)
{
try {
$result = $this->client->payTableOrderV2($this->parser->convertPayTableOrderRequest($terminal, $order, $paymentList, $keepTableName, $releaseTable));
return $this->parser->parsePayTableOrderResult($result);
} catch (SoapFault $e) {
throw new MplusQAPIException('SoapFault occurred: '.$e->getMessage(), 0, $e);
} catch (Exception $e) {
throw new MplusQAPIException('Exception occurred: '.$e->getMessage(), 0, $e);
}
} // END payTableOrder()

//----------------------------------------------------------------------------

public function prepayTableOrder($terminal, $order, $paymentList, $prepayAmount, $releaseTable = null)
{
try {
$result = $this->client->prepayTableOrderV2($this->parser->convertPrepayTableOrderRequest($terminal, $order, $paymentList, $prepayAmount, $releaseTable));
return $this->parser->parsePrepayTableOrderResult($result);
} catch (SoapFault $e) {
throw new MplusQAPIException('SoapFault occurred: '.$e->getMessage(), 0, $e);
} catch (Exception $e) {
throw new MplusQAPIException('Exception occurred: '.$e->getMessage(), 0, $e);
}
} // END prepayTableOrder()

//----------------------------------------------------------------------------

public function payInvoice($invoiceId, $paymentList)
{
try {
Expand Down Expand Up @@ -3602,6 +3630,32 @@ public function parsePayOrderResult($soapPayOrderResult) {

//----------------------------------------------------------------------------

public function parsePayTableOrderResult($soapPayTableOrderResult) {
if (isset($soapPayTableOrderResult->result) and $soapPayTableOrderResult->result == 'PAY-ORDER-RESULT-OK') {
if (isset($soapPayTableOrderResult->receiptId)) {
return $soapPayTableOrderResult->receiptId;
} else {
return true;
}
}
return false;
} // END parsePayTableOrderResult()

//----------------------------------------------------------------------------

public function parsePrepayTableOrderResult($soapPrepayTableOrderResult) {
if (isset($soapPrepayTableOrderResult->result) and $soapPrepayTableOrderResult->result == 'PAY-ORDER-RESULT-OK') {
if (isset($soapPrepayTableOrderResult->receiptId)) {
return $soapPrepayTableOrderResult->receiptId;
} else {
return true;
}
}
return false;
} // END parsePrepayTableOrderResult()

//----------------------------------------------------------------------------

public function parseDeliverOrderResult($soapDeliverOrderResult) {
if (isset($soapDeliverOrderResult->result)) {
if ($soapDeliverOrderResult->result == 'DELIVER-ORDER-RESULT-OK') {
Expand Down Expand Up @@ -4527,6 +4581,8 @@ public function parseSaveOrderResult($soapSaveOrderResult)
} else {
return true;
}
} else if (isset($soapSaveOrderResult->result) and $soapSaveOrderResult->result == 'SAVE-ORDER-RESULT-FAILED' and $soapSaveOrderResult->errorMessage == 'Order not saved because there were no changes in the order.') {
return true;
} else {
if ( ! empty($soapSaveOrderResult->errorMessage)) {
$this->lastErrorMessage = $soapSaveOrderResult->errorMessage;
Expand Down Expand Up @@ -5734,6 +5790,42 @@ public function convertPayOrderRequest($orderId, $prepay, $paymentList)

//----------------------------------------------------------------------------

public function convertPayTableOrderRequest($terminal, $order, $paymentList, $keepTableName, $releaseTable)
{
$terminal = $this->convertTerminal($terminal);
$order = $this->convertOrder($order);
$array = array(
'terminal'=>$terminal->terminal,
'request'=>array(
'order'=>$order->order,
'paymentList'=>$this->convertPaymentList($paymentList),
'keepTableName'=>$keepTableName,
'releaseTable'=>$releaseTable,
));
$object = arrayToObject($array);
return $object;
} // END convertPayTableOrderRequest()

//----------------------------------------------------------------------------

public function convertPrepayTableOrderRequest($terminal, $order, $paymentList, $prepayAmount, $releaseTable)
{
$terminal = $this->convertTerminal($terminal);
$order = $this->convertOrder($order);
$array = array(
'terminal'=>$terminal->terminal,
'request'=>array(
'order'=>$order->order,
'paymentList'=>$this->convertPaymentList($paymentList),
'prepayAmount'=>$prepayAmount,
'releaseTable'=>$releaseTable,
));
$object = arrayToObject($array);
return $object;
} // END convertPrepayTableOrderRequest()

//----------------------------------------------------------------------------

public function convertDeliverOrderRequest($orderId)
{
$array = array('request'=>array(
Expand Down Expand Up @@ -6977,7 +7069,7 @@ public function convertButtonLayoutRequest($terminal)

//------------------------------------------------------------------------------

if ( ! class_exists('MplusQAPIException')) {
if ( ! class_exists('MplusQAPIException', false)) {
class MplusQAPIException extends Exception
{

Expand Down
Empty file modified Mplusqapiclient_versiontester.php
100644 → 100755
Empty file.
78 changes: 39 additions & 39 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
mplus-api-client-php
====================

PHP client for the Mplus Q-line API.

### Example of usage:

The following script will connect to the API with your credentials and try to request the currently running version of the API.

```php
<?php

require_once('Mplusqapiclient.php');

$mplusqapiclient = new Mplusqapiclient();
$mplusqapiclient->setApiServer($your_api_url);
$mplusqapiclient->setApiPort($your_api_port);
$mplusqapiclient->setApiFingerprint($certificate_fingerprint);
$mplusqapiclient->setApiIdent($your_api_ident);
$mplusqapiclient->setApiSecret($your_api_secret);

try {
$mplusqapiclient->initClient();
} catch (MplusQAPIException $e) {
exit($e->getMessage());
}

try {
$api_version = $mplusqapiclient->getApiVersion();
echo sprintf('Current API version: %d.%d.%d',
$api_version['majorNumber'],
$api_version['minorNumber'],
$api_version['revisionNumber']);
} catch (MplusQAPIException $e) {
exit($e->getMessage());
}
```

Visit the [Mplus Developers website](http://developers.mpluskassa.nl/php/) for more information.
mplus-api-client-php
====================

PHP client for the Mplus Q-line API.

### Example of usage:

The following script will connect to the API with your credentials and try to request the currently running version of the API.

```php
<?php

require_once('Mplusqapiclient.php');

$mplusqapiclient = new Mplusqapiclient();
$mplusqapiclient->setApiServer($your_api_url);
$mplusqapiclient->setApiPort($your_api_port);
$mplusqapiclient->setApiFingerprint($certificate_fingerprint);
$mplusqapiclient->setApiIdent($your_api_ident);
$mplusqapiclient->setApiSecret($your_api_secret);

try {
$mplusqapiclient->initClient();
} catch (MplusQAPIException $e) {
exit($e->getMessage());
}

try {
$api_version = $mplusqapiclient->getApiVersion();
echo sprintf('Current API version: %d.%d.%d',
$api_version['majorNumber'],
$api_version['minorNumber'],
$api_version['revisionNumber']);
} catch (MplusQAPIException $e) {
exit($e->getMessage());
}
```

Visit the [Mplus Developers website](http://developers.mpluskassa.nl/php/) for more information.
Empty file modified composer.json
100644 → 100755
Empty file.

0 comments on commit 0149bc4

Please sign in to comment.