Skip to content

Commit 04a3edc

Browse files
Merge branch 'add-queueBranchOrderPayment' into 'master'
queueBranchOrderPayment toegevoegd. See merge request mpluskassa/mplus-api-client!15
2 parents b492fb3 + 157d903 commit 04a3edc

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

Mplusqapiclient.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2583,6 +2583,39 @@ public function queueBranchOrder($order, $attempts=0)
25832583
}
25842584
} // END queueBranchOrder()
25852585

2586+
//----------------------------------------------------------------------------
2587+
private function RetryCall($func)
2588+
{
2589+
$attempts = 0;
2590+
while ($attempts < 3) {
2591+
try {
2592+
return $func();
2593+
} catch (SoapFault $e) {
2594+
$msg = $e->getMessage();
2595+
if (false !== stripos($msg, 'Could not connect to host') and $attempts < 3) {
2596+
sleep(1);
2597+
++$attempts;
2598+
} else {
2599+
throw new MplusQAPIException('SoapFault occurred: '.$msg, 0, $e);
2600+
}
2601+
} catch (Exception $e) {
2602+
throw new MplusQAPIException('Exception occurred: '.$e->getMessage(), 0, $e);
2603+
}
2604+
}
2605+
}
2606+
2607+
public function queueBranchOrderPayment($orderId, $paymentList)
2608+
{
2609+
$request = $this->parser->convertQueueBranchOrderPaymentOrderRequest($orderId, $paymentList);
2610+
return $this->RetryCall(
2611+
function() use ($request) {
2612+
$result = $this->client->queueBranchOrderPayment($request);
2613+
if (false !== $result) {
2614+
return $this->parser->parseQueueBranchOrderPaymentResult($result);
2615+
}
2616+
}
2617+
);
2618+
}
25862619
//----------------------------------------------------------------------------
25872620

25882621
public function cancelOrder($orderId, $attempts=0)
@@ -5248,6 +5281,15 @@ public function parseCancelProposalResult($soapCancelProposalResult)
52485281

52495282
//----------------------------------------------------------------------------
52505283

5284+
public function parseQueueBranchOrderPaymentResult($soapResult)
5285+
{
5286+
if ($soapResult->result == 'QUEUE-BRANCH-ORDER-PAYMENT-RESULT-OK') {
5287+
return true;
5288+
}
5289+
return $soapResult->errorMessage;
5290+
}
5291+
5292+
//----------------------------------------------------------------------------
52515293
public function parseUpdateStockResult($soapUpdateStockResult)
52525294
{
52535295
if (isset($soapUpdateStockResult->result) and $soapUpdateStockResult->result == 'UPDATE-STOCK-RESULT-OK') {
@@ -6631,7 +6673,17 @@ public function convertDeliverOrderV2Request($orderDelivery)
66316673
} // END convertDeliverOrderV2Request()
66326674

66336675
//----------------------------------------------------------------------------
6676+
public function convertQueueBranchOrderPaymentOrderRequest($orderId, $paymentList)
6677+
{
6678+
$array = array('paymentRequest'=>array(
6679+
'orderId'=>$orderId,
6680+
'paymentList'=>$this->convertPaymentList($paymentList),
6681+
));
6682+
$object = arrayToObject($array);
6683+
return $object;
6684+
}
66346685

6686+
//----------------------------------------------------------------------------
66356687
public function convertPaymentList($paymentList)
66366688
{
66376689
if ( ! isset($paymentList['payment'])) {

0 commit comments

Comments
 (0)