Skip to content

Commit

Permalink
Merge pull request #31 from Kajakaran/master
Browse files Browse the repository at this point in the history
Display errors and redirection fix in smart debit import
  • Loading branch information
veda-consulting committed Oct 29, 2015
2 parents 508a913 + 03736ad commit 385365f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
23 changes: 21 additions & 2 deletions CRM/DirectDebit/Form/DataSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,19 +163,25 @@ static function getSmartDebitPayments( $dateOfCollection ) {
CRM_Core_Session::setStatus(ts('Please Select the Date of Collection'), Error, 'error');
return false;
}

$userDetails = self::getSmartDebitUserDetails();
$username = CRM_Utils_Array::value('username', $userDetails);
$password = CRM_Utils_Array::value('password', $userDetails);
$pslid = CRM_Utils_Array::value('pslid', $userDetails);

$collections = array();
$url = "https://secure.ddprocessing.co.uk/api/get_collection_report?query[service_user][pslid]=$pslid&query[debit_date]=$dateOfCollection";
$response = CRM_DirectDebit_Form_SyncSd::requestPost( $url, $username, $password );
$response = CRM_DirectDebit_Form_SyncSd::requestPost( $url, $username, $password );

// Take action based upon the response status
switch ( strtoupper( $response["Status"] ) ) {
case 'OK':
if (!isset($response['Successes']) || !isset($response['Rejects'])) {
$url = CRM_Utils_System::url('civicrm/directdebit/syncsd/import');
CRM_Core_Session::setStatus($response['Summary'], ts('Sorry'), 'error');
CRM_Utils_System::redirect($url);
return FALSE;
}

$collections = array();

Expand All @@ -188,6 +194,19 @@ static function getSmartDebitPayments( $dateOfCollection ) {
}
}
return $collections;
case 'INVALID':
$msg = "<ul>";
$msg .= "<li>";
$msg .= $response['body']['div']['h1'];
$msg .= "</li>";
$msg .= "<li>";
$msg .= $response['body']['div']['p'];
$msg .= "</li>";
$msg .= "</ul>";
$url = CRM_Utils_System::url('civicrm/directdebit/syncsd/import');
CRM_Core_Session::setStatus($msg, ts('Sorry'), 'error');
CRM_Utils_System::redirect($url);
return FALSE;

default:
return false;
Expand Down
4 changes: 2 additions & 2 deletions info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<url desc="Licensing"></url>
</urls>
<license>AGPL</license>
<releaseDate>2015-10-09</releaseDate>
<version>2.3</version>
<releaseDate>2015-10-29</releaseDate>
<version>2.3.1</version>
<develStage>stable</develStage>
<compatibility><ver>4.6</ver></compatibility>
<comments></comments>
Expand Down

0 comments on commit 385365f

Please sign in to comment.