Skip to content

Commit

Permalink
checkGiftcardPayment
Browse files Browse the repository at this point in the history
registerGiftcardPayment
  • Loading branch information
Dennis van den Heerik committed Feb 7, 2020
1 parent 3ef630f commit 3c140d7
Showing 1 changed file with 74 additions and 1 deletion.
75 changes: 74 additions & 1 deletion Mplusqapiclient.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class MplusQAPIclient
{
const CLIENT_VERSION = '1.27.7';
const CLIENT_VERSION = '1.27.8';
const WSDL_TTL = 300;

var $MIN_API_VERSION_MAJOR = 0;
Expand Down Expand Up @@ -3412,6 +3412,43 @@ public function getProductOverviewFields($attempts=0)
}
} // END getProductOverview()

//----------------------------------------------------------------------------
public function checkGiftcardPayment($cardNumber, $branchNumber, $amount = null, $attempts = 0) {
try {
$result = $this->client->checkGiftcardPayment($this->parser->convertCheckGiftcardPaymentRequest($cardNumber, $branchNumber, $amount));
return $this->parser->parseCheckGiftcardPaymentResult($result);
} catch (SoapFault $e) {
$msg = $e->getMessage();
if (false !== stripos($msg, 'Could not connect to host') and $attempts < 3) {
sleep(1);
return $this->checkGiftcardPayment($cardNumber, $branchNumber, $amount, $attempts + 1);
} else {
throw new MplusQAPIException('SoapFault occurred: ' . $msg, 0, $e);
}
} catch (Exception $e) {
throw new MplusQAPIException('Exception occurred: ' . $e->getMessage(), 0, $e);
}
}
// END checkGiftcardPayment()

//----------------------------------------------------------------------------
public function registerGiftcardPayment($cardNumber, $branchNumber, $employeeNumber, $amount, $externalReference, $attempts = 0) {
try {
$result = $this->client->registerGiftcardPayment($this->parser->convertRegisterGiftcardPaymentRequest($cardNumber, $branchNumber, $employeeNumber, $amount, $externalReference));
return $this->parser->parseRegisterGiftcardPaymentResult($result);
} catch (SoapFault $e) {
$msg = $e->getMessage();
if (false !== stripos($msg, 'Could not connect to host') and $attempts < 3) {
sleep(1);
return $this->registerGiftcardPayment($cardNumber, $branchNumber, $employeeNumber, $amount, $externalReference, $attempts + 1);
} else {
throw new MplusQAPIException('SoapFault occurred: ' . $msg, 0, $e);
}
} catch (Exception $e) {
throw new MplusQAPIException('Exception occurred: ' . $e->getMessage(), 0, $e);
}
}
// END registerGiftcardPayment()
}

//==============================================================================
Expand Down Expand Up @@ -5906,6 +5943,18 @@ public function parseGetProductOverviewFieldsResult($soapGetProductOverviewField
return $productOverviewFields;
} // END parseGetProductOverviewFieldsResult()

//----------------------------------------------------------------------------
public function parseCheckGiftcardPaymentResult($soapCheckGiftcardPaymentResult) {
return objectToArray($soapCheckGiftcardPaymentResult);
}
// END parseCheckGiftcardPaymentResult()

//----------------------------------------------------------------------------
public function parseRegisterGiftcardPaymentResult($soapRegisterGiftcardPaymentResult) {
return objectToArray($soapRegisterGiftcardPaymentResult);
}
// END parseRegisterGiftcardPaymentResult()


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

Expand Down Expand Up @@ -8585,6 +8634,30 @@ public function convertVerifyCredentialsRequest($request)
}

//----------------------------------------------------------------------------
public function convertCheckGiftcardPaymentRequest($cardNumber, $branchNumber, $amount) {
$array = array('request' => array());
$array['request']['cardNumber'] = $cardNumber;
$array['request']['branchNumber'] = $branchNumber;
if ($amount !== null) {
$array['request']['amount'] = $amount;
}
$object = arrayToObject($array);
return $object;
}
// END convertCheckGiftcardPaymentRequest()

//----------------------------------------------------------------------------
public function convertRegisterGiftcardPaymentRequest($cardNumber, $branchNumber, $employeeNumber, $amount, $externalReference) {
$array = array('request' => array());
$array['request']['cardNumber'] = $cardNumber;
$array['request']['branchNumber'] = $branchNumber;
$array['request']['employeeNumber'] = $employeeNumber;
$array['request']['amount'] = $amount;
$array['request']['externalReference'] = $externalReference;
$object = arrayToObject($array);
return $object;
}
// END convertRegisterGiftcardPaymentRequest()
}

//------------------------------------------------------------------------------
Expand Down

0 comments on commit 3c140d7

Please sign in to comment.