Skip to content

Commit

Permalink
Merge pull request #7 from schakelmarketeers/feature/pay-table-order
Browse files Browse the repository at this point in the history
Add functions payTableOrder and prepayTableOrder
  • Loading branch information
mplus-software authored Sep 18, 2018
2 parents 80b646b + b393786 commit 72c3251
Showing 1 changed file with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions Mplusqapiclient.php
Original file line number Diff line number Diff line change
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 @@ -3422,6 +3450,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 @@ -5314,6 +5368,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

0 comments on commit 72c3251

Please sign in to comment.