[eluser]Clooner[/eluser]
This is just a simple CI wrapper for the iDeal Advance Library which can be downloaded here
https://ideal.secure-ing.com/ideal/downl...P_Code.zip
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Name: ING iDEAL Advance CI Library
*
* Author: Jeroen Schaftenaar
*
* Created: December 28, 2011
*
* Description: This library is a wrapper for the ING iDEAL Advance connector
*
* Note: This should also work with the Rabobank iDEAL implementation, they are the same.
*
*/
class ideal_lib
{
var $encryption_key = 'Your Secret Key';
function __construct()
{
// Initialize the ideal connector library!
require_once("application/libraries/ideal/iDEALConnector.php");
}
function get_issuer_array()
{
$iDEALConnector = new iDEALConnector();
// Connect to the server and try to get a response
$response = $iDEALConnector->GetIssuerList();
if ($response->IsResponseError())
{
// An error occurred
$errorCode = $response->getErrorCode();
$errorMsg = $response->getErrorMessage();
$consumerMessage = $response->getConsumerMessage();
// Optional: log the errors
return false;
} else {
// Valid response
// Optional: return the $IssuerList for more detail
$IssuerList =& $response->getIssuerFullList();
$result = array();
foreach ($IssuerList as $issuerName => $entry)
$result[$entry->getIssuerID()] = $entry->getIssuerName();
return $result;
}
}
function initiate_ideal($amount, $order_id, $issuer_id, $description, $return_url)
{
$iDEALConnector = new iDEALConnector();
// generate a hash code for this request
$hash_code = $this->generate_hash_code($amount, $order_id);
// Connect to the server and try to get an response
$response = $iDEALConnector->RequestTransaction(
$issuer_id, // which bank
$order_id,
$amount, // the amount in cents
$description,
$hash_code,
null, // Optional: a timeout, default one hour
$return_url
);
if ($response->IsResponseError())
{
// An error occurred
$errorCode = $response->getErrorCode();
$errorMsg = $response->getErrorMessage();
$consumerMessage = $response->getConsumerMessage();
// Optional: log the errors
return false;
}
else
{
// Success
// Optional: return the entire $response for more detail
return array(
'acquirerID' => $response->getAcquirerID(),
'transactionID' => $response->getTransactionID(),
'issuerAuthenticationURL' => $response->getIssuerAuthenticationURL(),
);
}
}
function get_ideal_transaction($transaction_id)
{
$iDEALConnector = new iDEALConnector();
// Connect to server and try to get a response
$response = $iDEALConnector->RequestTransactionStatus($transaction_id);
if ($response->IsResponseError())
{
// An error occurred
$errorCode = $response->getErrorCode();
$errorMsg = $response->getErrorMessage();
$consumerMessage = $response->getConsumerMessage();
//Optional: log the errors
return false;
}
else
{
// Success
// Optional: Return the $response for more detail
return array(
'acquirer_id' => $response->getAcquirerID(),
'consumer' => $response->getConsumerName(),
'account' => $response->getConsumerAccountNumber(),
'city' => $response->getConsumerCity(),
'transaction_id' => $response->getTransactionID(),
'status' => $response->getStatus(),
);
}
}
function generate_hash_code($amount, $order_id)
{
return md5($amount.$order_id.$this->encryption_key);
}
}
/* End of file ideal_lib.php */
/* Location: ./application/libaries/ideal_lib.php */