Skip to content

Commit

Permalink
Cleanup of code; removed unnecessary verbose dumps
Browse files Browse the repository at this point in the history
  • Loading branch information
DaanRijpkema committed Sep 8, 2021
1 parent 1044c94 commit 80a6fb1
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 25 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,6 @@ $request = $bluem->CreateIBANNameCheckRequest(
);

$response = $bluem->PerformRequest($request);
// var_dump($response);

switch ($response->GetIBANResult()) {
case 'INVALID':
Expand Down
2 changes: 0 additions & 2 deletions examples/identity-callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
$transactionID,
$entranceCode
);
// var_dump($statusResponse);


if ($statusResponse->ReceivedResponse()) {

Expand Down
2 changes: 1 addition & 1 deletion examples/mandates.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@

$statusUpdateObject = $response->EMandateStatusUpdate;
$statusCode = $statusUpdateObject->EMandateStatus->Status . "";
// var_dump($statusCode);

if ($statusCode === "Success") {

// Implement: do what you need to do to mark the transaction completed on your end
Expand Down
36 changes: 18 additions & 18 deletions src/Bluem.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,16 +257,17 @@ public function CreatePaymentRequest(
$entranceCode = null,
$debtorReturnURL = ""
): PaymentBluemRequest {

if (is_null($entranceCode)) {
$entranceCode = $this->CreateEntranceCode();
}

// @todo: validate DebtorReference : [0-9a-zA-Z]{1,35}
// @todo: validate Description
// @todo: validate Amount
// @todo: validate Currency
// @todo: Create constants for Currencies
// @todo: sanitize debtorReturnURL?
// create try catch for these validation steps
// @todo: validate Description
// @todo: validate Amount
// @todo: validate Currency
// @todo: Create constants for Currencies
// @todo: sanitize debtorReturnURL

return new PaymentBluemRequest(
$this->_config,
Expand Down Expand Up @@ -494,15 +495,14 @@ public function PerformRequest(BluemRequest $transaction_request)
echo PHP_EOL . "<BR>HEADER// " . 'x-ttrs-filename: ' . $xttrs_filename;
echo "<HR>";
echo PHP_EOL . "BODY: " . $transaction_request->XmlString();
// var_dump(libxml_get_errors());
}

$req->setBody($transaction_request->XmlString());
try {
$http_response = $req->send();
if ($verbose) {
echo PHP_EOL . "<BR>RESPONSE// ";
var_dump($http_response->getBody());
echo($http_response->getBody());
}

switch ($http_response->getStatus()) {
Expand All @@ -516,42 +516,45 @@ public function PerformRequest(BluemRequest $transaction_request)
} catch (\Throwable $th) {
return new ErrorBluemResponse("Error: Could not create Bluem Response object. More details: " . $th->getMessage());
}
echo $transaction_request->transaction_code;
var_dump($response);

if ($response->attributes()['type'].'' === "ErrorResponse") {
switch ($transaction_request->transaction_code) {
case 'SRX':
case 'SUD':
$errmsg = $response->EMandateErrorResponse->Error->ErrorMessage."";
// no break
case 'TRX':
case 'TRS':
$errmsg = $response->EMandateTransactionErrorResponse->Error->ErrorMessage."";
// no break
case 'PSU':
case 'PSX':
$errmsg = $response->EPaymentErrorResponse->Error->ErrorMessage."";
// no break
case 'PTS':
case 'PTX':
$errmsg = $response->EPaymentTransactionErrorResponse->Error->ErrorMessage."";
// no break
case 'ITX':
case 'ITX':
$errmsg = $response->EIdentityTransactionErrorResponse->Error->ErrorMessage."";
// no break
case 'ISU':
case 'ISX':
$errmsg = $response->EIdentityErrorResponse->Error->ErrorMessage."";
// no break
case 'INS':
case 'INX':
$errmsg = $response->EIBANNameCheckErrorResponse->Error->ErrorMessage."";
// no break
default:
throw new Exception("Invalid transaction type requested");
}
// $response = $this->fabricateErrorResponseObject($transaction_request->transaction_code, $http_response->getBody());
// var_dump($response);

return new ErrorBluemResponse("Error: " . ($errmsg));
exit;
}


var_dump($response);
if (!$response->Status()) {
return new ErrorBluemResponse("Error: " . ($response->Error->ErrorMessage));
}
Expand Down Expand Up @@ -629,7 +632,7 @@ public function Webhook()
$xmlObject = new \SimpleXMLElement($postData);
} catch (Exception $e) {
if ($verbose) {
var_dump($e);
echo($e->getMessage());
exit();
}
http_response_code(400); // could not parse XML
Expand All @@ -648,9 +651,6 @@ public function Webhook()
exit;
}

if ($verbose) {
var_dump($xmlObject);
}

// @todo: finish this code
throw new Exception("Not implemented fully yet, please contact the developer or work around this error");
Expand Down
6 changes: 3 additions & 3 deletions src/Requests/BluemRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ protected function XmlRequestInterfaceWrap(
string $element_name,
string $type = "TransactionRequest",
string $rest
): string
{
): string {
return '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><' . $element_name . '
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
type="' . $type . '"
Expand Down Expand Up @@ -409,7 +408,8 @@ public function RequestType()
* @param String $description
* @return void
*/
protected function _sanitizeDescription(String $description) {
protected function _sanitizeDescription(String $description)
{
// filter based on full list of invalid chars for description based on XSD
// Wel toegestaan: -0-9a-zA-ZéëïôóöüúÉËÏÔÓÖÜÚ€ ()+,.@&=%"'/:;?$
$description = preg_replace(
Expand Down
1 change: 1 addition & 0 deletions src/Requests/PaymentBluemRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function __construct(
$this->dueDateTime = Carbon::parse($dueDateTime)->format(BLUEM_LOCAL_DATE_FORMAT) . ".000Z";
}

// @todo: validate DebtorReference : [0-9a-zA-Z]{1,35}
$this->debtorReference = $debtorReference;

$this->amount = $this->parseAmount($amount);
Expand Down

0 comments on commit 80a6fb1

Please sign in to comment.