/** 
 * Calls the STATUS request
 **/
function ideal_payment_api_statreq_call($order)
{
    //include connector
    $path_module = drupal_get_path('module', 'ideal_payment_api');
    require_once $path_module . '/lib/iDEALConnector.php';
    //Initialise connector
    $iDEALConnector = new iDEALConnector();
    //Create StatusRequest
    $response = $iDEALConnector->RequestTransactionStatus($order['transaction_id']);
    //$transID = str_pad($transaction_id, 16, "0"); //Delete??
    return $response;
}
Ejemplo n.º 2
0
	public function VerifyOrderPayment()
	{
		// verify the transaction status
		if (!isset($_SESSION['IdealTransactionID'])) {
			return false;
		}

		// couldn't authenticate redirect, we shouldn't proceed
		if (!isset($_GET["ec"]) || $_GET["ec"] != md5(GetConfig('EncryptionToken').$_COOKIE['SHOP_ORDER_TOKEN'])) {
			return false;
		}

		$transactionID = $_SESSION['IdealTransactionID'];

		// instantiate the ideal connector
		$iDEALConnector = new iDEALConnector();

		// request the status of the transaction
		$request = $iDEALConnector->RequestTransactionStatus($transactionID);

		if ($request === false) {
			$request = $iDEALConnector->getError();
		}

		if ($request->IsResponseError()) {
			$error = GetLang('IdealErrorTransactionRequest', array('code' => $request->getErrorCode(), "message" => $request->getErrorMessage()));
			$GLOBALS['ISC_CLASS_LOG']->LogSystemError(array('payment', $this->GetName()), $error, $request->getErrorDetail());

			$this->SetError($error);

			return false;
		}

		// get consumer details and status of transaction
		$consumerName = $request->getConsumerName();
		$consumerAccountNumber = $request->getConsumerAccountNumber();
		$consumerCity = $request->getConsumerCity();
		$status = $request->getStatus();

		$friendlyStatus = GetLang('IdealStatus' . $this->GetStatusName($status));

		$details = GetLang('IdealTransactionDetails', array(
			"status" 			=> $friendlyStatus,
			"transactionID"		=> $transactionID
		));

		if ($consumerName) {
			$details .= GetLang('IdealConsumerDetails', array(
				"consumerName"		=> $consumerName,
				"consumerCity"		=> $consumerCity,
				"consumerAccount"	=> $consumerAccountNumber
			));
		}

		if ($status == IDEAL_TX_STATUS_SUCCESS) {
			$this->SetPaymentStatus(PAYMENT_STATUS_PAID);

			$updatedOrder = array(
				'ordpayproviderid' => $transactionID
			);
			$this->UpdateOrders($updatedOrder);

			// log successfull transaction
			$GLOBALS['ISC_CLASS_LOG']->LogSystemSuccess(
				array('payment', $this->GetName()),
				GetLang('IdealTransactionSuccess', array("transactionID" => $transactionID)),
				$details
			);

			return true;
		}

		// log failed transaction
		$GLOBALS['ISC_CLASS_LOG']->LogSystemError(
			array('payment', $this->GetName()),
			GetLang('IdealTransactionFailure', array("transactionID" => $transactionID, "status" => $friendlyStatus)),
			$details
		);

		// redirect to cart if cancelled
		if ($status == IDEAL_TX_STATUS_CANCELLED) {
			ob_end_clean();
			header("Location: " . GetConfig('ShopPathSSL') . "/cart.php");
			exit;
		}

		// transaction has expired, we inform the customer and they can try again
		if ($status == IDEAL_TX_STATUS_EXPIRED) {
			$_SESSION['IdealError'] = GetLang('IdealTransactionExpired');
			ob_end_clean();
			header("Location: " . GetConfig('ShopPathSSL') . "/checkout.php?action=process_payment");
			exit;
		}

		return false;
	}