PHP Classes

File: class.epay.php

Recommend this page to a friend!
  Classes of Kristo Vaher  >  Estonian e-payments solution  >  class.epay.php  >  Download  
File: class.epay.php
Role: Class source
Content type: text/plain
Description: Main class, this file also calls the configuration file and expects the file to be in the same directory as the class.epayments.php file. This file should not be edited, unless necessary for some reason.
Class: Estonian e-payments solution
Submit payments to Estonian and Finnish banks
Author: By
Last change: Minor bug of Nordea EST connection having languages switched (estonian appeared as english and vice versa) is now fixed.

Version number update
Date: 10 years ago
Size: 46,559 bytes
 

Contents

Class file image Download
<?php

	// Estonian e-payments system 1.4
	// Kristo Vaher 2011 http://www.waher.net
	// Licensed under LGPL http://www.gnu.org/licenses/lgpl-3.0.txt
	// Published http://waher.net/archives/852
	
	//It is recommended not to edit this file, unless really necessary
	
	function file_get_contents_with_check($url){
		if(file_exists($url)){
			return file_get_contents($url);
		} else {
			return '';
		}
	}

	class Payment {

		private $config;

		public function __construct($config=array()){
			if(!isset($_POST['epay-final'])){
				$this->config=$config;
				$this->config['this']='http://'.$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"];
			} else {
				unset($_POST['epay-final']);
				unset($_POST['epay-submitbutton']);
				if(isset($_POST['epay-t'])){
					$this->config=$config[$_POST['epay-t']];
					$this->config['this']='http://'.$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"];
				}
			}
		}
		
		public function returnForm(){
			$root='http://'.$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"];
			$return='';
			$return.='<form '.((isset($this->config['form-name']))?'name="'.$this->config['form-name'].'"':'name="epay-form"').' '.((isset($this->config['form-id']))?'id="'.$this->config['form-id'].'"':'id="epay-form"').' action="'.$this->config['gateway-url'].'?epay-t='.$this->config['payment-type'].'" method="post">';
				$return.='<input type="hidden" name="order" value="'.$this->config['order'].'"/>';
				$return.='<input type="hidden" name="amount" value="'.$this->config['amount'].'"/>';
				$return.='<input type="hidden" name="return" value="'.$this->config['return-url'].'"/>';
				if(isset($this->config['message'])){
					$return.='<input type="hidden" name="message" value="'.$this->config['message'].'"/>';
				}
				if(isset($this->config['currency'])){
					$return.='<input type="hidden" name="currency" value="'.$this->config['currency'].'"/>';
				}
				if(isset($this->config['language'])){
					$return.='<input type="hidden" name="language" value="'.$this->config['language'].'"/>';
				}
				if(isset($this->config['submit-button'])){
					$return.=$this->config['submit-button'];
				} else {
					$return.='<input type="submit" name="epay-submitbutton" value="Pay"/>';
				}
			$return.='</form>';
			return $return;
		}
		
		public function validateReturn($data){
			if(empty($data)){
				return false;
			} else if(isset($data['epay-hash'])){
				ksort($data);
				$hash=$this->config['hash'];
				foreach($data as $key=>$d){
					if($key!='epay-hash' && $key!='epay-submitbutton' && $key!='epay-final'){
						$hash.='&'.$key.'='.$d;
					}
				}
				if($data['epay-hash']==md5($hash)){
					return true;
				} else {
					return false;
				}
			} else {
				return false;
			}
		}
		
		public function submitForm(){
			switch ($this->config['payment']) {
				case 'swed-est':
					echo '<form name="epay-form" method="post" action="'.$this->config['settings']['service-url'].'">';
						if(isset($this->config['settings']['VK_ACC']) || isset($this->config['settings']['VK_NAME'])){
							echo '<input type="hidden" name="VK_SERVICE" value="1001"/>'; //service number
						} else {
							echo '<input type="hidden" name="VK_SERVICE" value="1002"/>'; //service number
						}
						echo '<input type="hidden" name="VK_VERSION" value="008"/>'; //crypto algorithm used
						echo '<input type="hidden" name="VK_SND_ID" value="'.$this->config['settings']['VK_SND_ID'].'"/>'; //service provider id
						echo '<input type="hidden" name="VK_STAMP" value="'.$this->config['order']['order-code'].'"/>'; //unique order code in e-shop to eliminate duplicate transactions
						$amount=number_format($this->config['order']['amount'], 2, '.', '');
						echo '<input type="hidden" name="VK_AMOUNT" value="'.$amount.'"/>'; //amount to be transferred
						echo '<input type="hidden" name="VK_CURR" value="'.strtoupper($this->config['order']['currency']).'"/>'; //currency
						if(isset($this->config['settings']['VK_ACC']) || isset($this->config['settings']['VK_NAME'])){
							echo '<input type="hidden" name="VK_ACC" value="'.$this->config['settings']['VK_ACC'].'"/>'; //client account number
							echo '<input type="hidden" name="VK_NAME" value="'.$this->config['settings']['VK_NAME'].'"/>'; //client name
						}
						$reference=@$this->referenceNumber($this->config['order']['order-code']);
						echo '<input type="hidden" name="VK_REF" value="'.$reference.'"/>'; //'standard reference number'?
						echo '<input type="hidden" name="VK_MSG" value="'.$this->config['order']['message'].'"/>'; //custom message
						echo '<input type="hidden" name="VK_ENCODING" value="UTF-8"/>'; //UTF-8 or ISO-8859-1 (default)
						
						if(isset($this->config['settings']['client-private-key-password'])){
							$key=openssl_pkey_get_private($this->config['settings']['client-private-key'],$this->config['settings']['private-key-password']);
						} else {
							$key=openssl_pkey_get_private($this->config['settings']['client-private-key'],'');
						}
						
						$mac='';
						if(isset($this->config['settings']['VK_ACC']) || isset($this->config['settings']['VK_NAME'])){
							$mac.=str_pad(mb_strlen('1001','UTF-8'),3,'0',STR_PAD_LEFT).'1001';
						} else {
							$mac.=str_pad(mb_strlen('1002','UTF-8'),3,'0',STR_PAD_LEFT).'1002';
						}
						$mac.=str_pad(mb_strlen('008','UTF-8'),3,'0',STR_PAD_LEFT).'008';
						$mac.=str_pad(mb_strlen($this->config['settings']['VK_SND_ID'],'UTF-8'),3,'0',STR_PAD_LEFT).$this->config['settings']['VK_SND_ID'];
						$mac.=str_pad(mb_strlen($this->config['order']['order-code'],'UTF-8'),3,'0',STR_PAD_LEFT).$this->config['order']['order-code'];
						$mac.=str_pad(mb_strlen($amount,'UTF-8'),3,'0',STR_PAD_LEFT).$amount;
						$mac.=str_pad(mb_strlen($this->config['order']['currency'],'UTF-8'),3,'0',STR_PAD_LEFT).strtoupper($this->config['order']['currency']);
						if(isset($this->config['settings']['VK_ACC']) || isset($this->config['settings']['VK_NAME'])){
							$mac.=str_pad(mb_strlen($this->config['settings']['VK_ACC'],'UTF-8'),3,'0',STR_PAD_LEFT).$this->config['settings']['VK_ACC'];
							$mac.=str_pad(mb_strlen($this->config['settings']['VK_NAME'],'UTF-8'),3,'0',STR_PAD_LEFT).$this->config['settings']['VK_NAME'];
						}
						$mac.=str_pad(mb_strlen($reference,'UTF-8'),3,'0',STR_PAD_LEFT).$reference;
						$mac.=str_pad(mb_strlen($this->config['order']['message'],'UTF-8'),3,'0',STR_PAD_LEFT).$this->config['order']['message'];
						
						openssl_sign($mac,$signature,$key);
						$mac = base64_encode($signature);
						
						echo '<input type="hidden" name="VK_MAC" value="'.$mac.'"/>'; //security hash
						$returnurl=$this->config['this'].'&epay-rt=return&epay-r='.urlencode($this->config['settings']['return-url']);
						echo '<input type="hidden" name="VK_RETURN" value="'.$returnurl.'"/>'; //url to be returned to, if successful
						if(strlen($returnurl)>150){
							echo $returnurl.'<br/>final return URL is too long ('.strlen($returnurl).'>150 symbols) for Swedbank e-payment<br/>shorten return URL or gateway location URL to fix this';
							die();
						}
						$this->config['settings']['language']=strtolower($this->config['settings']['language']);
						if($this->config['settings']['language']=='estonia' || $this->config['settings']['language']=='estonian' || $this->config['settings']['language']=='et' || $this->config['settings']['language']=='est'){
							$this->config['settings']['language']='est';
						} else if($this->config['settings']['language']=='english' || $this->config['settings']['language']=='en' || $this->config['settings']['language']=='eng'){
							$this->config['settings']['language']='eng';
						} else if($this->config['settings']['language']=='russian' || $this->config['settings']['language']=='ru' || $this->config['settings']['language']=='rus'){
							$this->config['settings']['language']='rus';
						} else {
							$this->config['settings']['language']='eng';
						}
						echo '<input type="hidden" name="VK_LANG" value="'.strtoupper($this->config['settings']['language']).'"/>'; //preferred langauge
						echo '<input type="hidden" name="VK_AUTO" value="Y"/>'; //whether sent automatically
						echo '<input type="submit" name="epay-submitbutton" id="epay-submitbutton" value="click here if you are not being redirected"/>';
					echo '</form>';
					break;
				case 'seb-est':
					echo '<form name="epay-form" method="post" action="'.$this->config['settings']['service-url'].'">';
						if(isset($this->config['settings']['VK_ACC']) || isset($this->config['settings']['VK_NAME'])){
							echo '<input type="hidden" name="VK_SERVICE" value="1001"/>'; //service number
						} else {
							echo '<input type="hidden" name="VK_SERVICE" value="1002"/>'; //service number
						}
						echo '<input type="hidden" name="VK_VERSION" value="008"/>'; //crypto algorithm used
						echo '<input type="hidden" name="VK_SND_ID" value="'.$this->config['settings']['VK_SND_ID'].'"/>'; //service provider id
						echo '<input type="hidden" name="VK_STAMP" value="'.$this->config['order']['order-code'].'"/>'; //unique order code in e-shop to eliminate duplicate transactions
						$amount=number_format($this->config['order']['amount'], 2, '.', '');
						echo '<input type="hidden" name="VK_AMOUNT" value="'.$amount.'"/>'; //amount to be transferred
						echo '<input type="hidden" name="VK_CURR" value="'.strtoupper($this->config['order']['currency']).'"/>'; //currency
						if(isset($this->config['settings']['VK_ACC']) || isset($this->config['settings']['VK_NAME'])){
							echo '<input type="hidden" name="VK_ACC" value="'.$this->config['settings']['VK_ACC'].'"/>'; //client account number
							echo '<input type="hidden" name="VK_NAME" value="'.$this->config['settings']['VK_NAME'].'"/>'; //client name
						}
						$reference=@$this->referenceNumber($this->config['order']['order-code']);
						echo '<input type="hidden" name="VK_REF" value="'.$reference.'"/>'; //'standard reference number'?
						echo '<input type="hidden" name="VK_MSG" value="'.$this->config['order']['message'].'"/>'; //custom message
						echo '<input type="hidden" name="VK_CHARSET" value="UTF-8"/>'; //UTF-8 or ISO-8859-1 (default)
						
						if(isset($this->config['settings']['client-private-key-password'])){
							$key=openssl_pkey_get_private($this->config['settings']['client-private-key'],$this->config['settings']['private-key-password']);
						} else {
							$key=openssl_pkey_get_private($this->config['settings']['client-private-key'],'');
						}
						
						$mac='';
						if(isset($this->config['settings']['VK_ACC']) || isset($this->config['settings']['VK_NAME'])){
							$mac.=str_pad(strlen('1001'),3,'0',STR_PAD_LEFT).'1001';
						} else {
							$mac.=str_pad(strlen('1002'),3,'0',STR_PAD_LEFT).'1002';
						}
						$mac.=str_pad(strlen('008'),3,'0',STR_PAD_LEFT).'008';
						$mac.=str_pad(strlen($this->config['settings']['VK_SND_ID']),3,'0',STR_PAD_LEFT).$this->config['settings']['VK_SND_ID'];
						$mac.=str_pad(strlen($this->config['order']['order-code']),3,'0',STR_PAD_LEFT).$this->config['order']['order-code'];
						$mac.=str_pad(strlen($amount),3,'0',STR_PAD_LEFT).$amount;
						$mac.=str_pad(strlen($this->config['order']['currency']),3,'0',STR_PAD_LEFT).strtoupper($this->config['order']['currency']);
						if(isset($this->config['settings']['VK_ACC']) || isset($this->config['settings']['VK_NAME'])){
							$mac.=str_pad(strlen($this->config['settings']['VK_ACC']),3,'0',STR_PAD_LEFT).$this->config['settings']['VK_ACC'];
							$mac.=str_pad(strlen($this->config['settings']['VK_NAME']),3,'0',STR_PAD_LEFT).$this->config['settings']['VK_NAME'];
						}
						$mac.=str_pad(strlen($reference),3,'0',STR_PAD_LEFT).$reference;
						$mac.=str_pad(strlen($this->config['order']['message']),3,'0',STR_PAD_LEFT).$this->config['order']['message'];
						
						openssl_sign($mac,$signature,$key);
						$mac = base64_encode($signature);
						
						echo '<input type="hidden" name="VK_MAC" value="'.$mac.'"/>'; //security hash
						echo '<input type="hidden" name="VK_RETURN" value="'.$this->config['this'].'&epay-rt=return&epay-r='.urlencode($this->config['settings']['return-url']).'"/>'; //url to be returned to, if successful
						echo '<input type="hidden" name="VK_CANCEL" value="'.$this->config['this'].'&epay-rt=cancel&epay-r='.urlencode($this->config['settings']['return-url']).'"/>'; //url to be returned to, if rejected
						$this->config['settings']['language']=strtolower($this->config['settings']['language']);
						if($this->config['settings']['language']=='estonia' || $this->config['settings']['language']=='estonian' || $this->config['settings']['language']=='et' || $this->config['settings']['language']=='est'){
							$this->config['settings']['language']='est';
						} else if($this->config['settings']['language']=='english' || $this->config['settings']['language']=='en' || $this->config['settings']['language']=='eng'){
							$this->config['settings']['language']='eng';
						} else if($this->config['settings']['language']=='russian' || $this->config['settings']['language']=='ru' || $this->config['settings']['language']=='rus'){
							$this->config['settings']['language']='rus';
						} else {
							$this->config['settings']['language']='eng';
						}
						echo '<input type="hidden" name="VK_LANG" value="'.strtoupper($this->config['settings']['language']).'"/>'; //preferred langauge
						echo '<input type="hidden" name="VK_AUTO" value="Y"/>'; //whether sent automatically
						echo '<input type="submit" name="epay-submitbutton" id="epay-submitbutton" value="click here if you are not being redirected"/>';
					echo '</form>';
					break;
				case 'sampo-est':
					echo '<form name="epay-form" method="post" action="'.$this->config['settings']['service-url'].'">';
						if(isset($this->config['settings']['VK_ACC']) || isset($this->config['settings']['VK_NAME'])){
							echo '<input type="hidden" name="VK_SERVICE" value="1001"/>'; //service number
						} else {
							echo '<input type="hidden" name="VK_SERVICE" value="1002"/>'; //service number
						}
						echo '<input type="hidden" name="VK_VERSION" value="008"/>'; //crypto algorithm used
						echo '<input type="hidden" name="VK_SND_ID" value="'.$this->config['settings']['VK_SND_ID'].'"/>'; //service provider id
						echo '<input type="hidden" name="VK_STAMP" value="'.$this->config['order']['order-code'].'"/>'; //unique order code in e-shop to eliminate duplicate transactions
						$amount=number_format($this->config['order']['amount'], 2, '.', '');
						echo '<input type="hidden" name="VK_AMOUNT" value="'.$amount.'"/>'; //amount to be transferred
						echo '<input type="hidden" name="VK_CURR" value="'.strtoupper($this->config['order']['currency']).'"/>'; //currency
						if(isset($this->config['settings']['VK_ACC']) || isset($this->config['settings']['VK_NAME'])){
							echo '<input type="hidden" name="VK_ACC" value="'.$this->config['settings']['VK_ACC'].'"/>'; //client account number
							echo '<input type="hidden" name="VK_NAME" value="'.$this->config['settings']['VK_NAME'].'"/>'; //client name
						}
						$reference=@$this->referenceNumber($this->config['order']['order-code']);
						echo '<input type="hidden" name="VK_REF" value="'.$reference.'"/>'; //'standard reference number'?
						echo '<input type="hidden" name="VK_MSG" value="'.$this->config['order']['message'].'"/>'; //custom message
						
						if(isset($this->config['settings']['client-private-key-password'])){
							$key=openssl_pkey_get_private($this->config['settings']['client-private-key'],$this->config['settings']['private-key-password']);
						} else {
							$key=openssl_pkey_get_private($this->config['settings']['client-private-key'],'');
						}
						
						$mac='';
						if(isset($this->config['settings']['VK_ACC']) || isset($this->config['settings']['VK_NAME'])){
							$mac.=str_pad(strlen('1001'),3,'0',STR_PAD_LEFT).'1001';
						} else {
							$mac.=str_pad(strlen('1002'),3,'0',STR_PAD_LEFT).'1002';
						}
						$mac.=str_pad(strlen('008'),3,'0',STR_PAD_LEFT).'008';
						$mac.=str_pad(strlen($this->config['settings']['VK_SND_ID']),3,'0',STR_PAD_LEFT).$this->config['settings']['VK_SND_ID'];
						$mac.=str_pad(strlen($this->config['order']['order-code']),3,'0',STR_PAD_LEFT).$this->config['order']['order-code'];
						$mac.=str_pad(strlen($amount),3,'0',STR_PAD_LEFT).$amount;
						$mac.=str_pad(strlen($this->config['order']['currency']),3,'0',STR_PAD_LEFT).strtoupper($this->config['order']['currency']);
						if(isset($this->config['settings']['VK_ACC']) || isset($this->config['settings']['VK_NAME'])){
							$mac.=str_pad(strlen($this->config['settings']['VK_ACC']),3,'0',STR_PAD_LEFT).$this->config['settings']['VK_ACC'];
							$mac.=str_pad(strlen($this->config['settings']['VK_NAME']),3,'0',STR_PAD_LEFT).$this->config['settings']['VK_NAME'];
						}
						$mac.=str_pad(strlen($reference),3,'0',STR_PAD_LEFT).$reference;
						$mac.=str_pad(strlen($this->config['order']['message']),3,'0',STR_PAD_LEFT).$this->config['order']['message'];
						
						openssl_sign($mac,$signature,$key);
						$mac = base64_encode($signature);
						
						echo '<input type="hidden" name="VK_MAC" value="'.$mac.'"/>'; //security hash
						echo '<input type="hidden" name="VK_RETURN" value="'.$this->config['this'].'&epay-rt=return&epay-r='.urlencode($this->config['settings']['return-url']).'"/>'; //url to be returned to, if successful
						$this->config['settings']['language']=strtolower($this->config['settings']['language']);
						if($this->config['settings']['language']=='estonia' || $this->config['settings']['language']=='estonian' || $this->config['settings']['language']=='et' || $this->config['settings']['language']=='est'){
							$this->config['settings']['language']='est';
						} else if($this->config['settings']['language']=='english' || $this->config['settings']['language']=='en' || $this->config['settings']['language']=='eng'){
							$this->config['settings']['language']='eng';
						} else if($this->config['settings']['language']=='russian' || $this->config['settings']['language']=='ru' || $this->config['settings']['language']=='rus'){
							$this->config['settings']['language']='rus';
						} else {
							$this->config['settings']['language']='eng';
						}
						echo '<input type="hidden" name="VK_LANG" value="'.strtoupper($this->config['settings']['language']).'"/>'; //preferred langauge
						echo '<input type="hidden" name="VK_AUTO" value="Y"/>'; //whether sent automatically
						echo '<input type="submit" name="epay-submitbutton" id="epay-submitbutton" value="click here if you are not being redirected"/>';
					echo '</form>';
					break;
				case 'nordea-est':
					echo '<form name="epay-form" method="post" action="'.$this->config['settings']['service-url'].'">';
						echo '<input type="hidden" name="SOLOPMT_VERSION" value="0003"/>'; //presentation form of payment data, either 0002 or 0003, latter is recommended
						echo '<input type="hidden" name="SOLOPMT_STAMP" value="'.$this->config['order']['order-code'].'"/>'; //unique order code in e-shop to eliminate duplicate transactions
						echo '<input type="hidden" name="SOLOPMT_RCV_ID" value="'.$this->config['settings']['RCV_ID'].'"/>'; //service provider ID
						if(isset($this->config['settings']['RCV_ACCOUNT']) || isset($this->config['settings']['RCV_NAME'])){
							echo '<input type="hidden" name="SOLOPMT_RCV_ACCOUNT" value="'.$this->config['settings']['SOLOPMT_RCV_ACCOUNT'].'"/>'; //alternative account, must be registered in Nordea
							echo '<input type="hidden" name="SOLOPMT_RCV_NAME" value="'.$this->config['settings']['SOLOPMT_RCV_NAME'].'"/>'; //payment receiver name, if not default
						}
						$this->config['settings']['language']=strtolower($this->config['settings']['language']);
						if($this->config['settings']['language']=='estonia' || $this->config['settings']['language']=='estonian' || $this->config['settings']['language']=='et' || $this->config['settings']['language']=='est'){
							$this->config['settings']['language']=4;
						} else if($this->config['settings']['language']=='english' || $this->config['settings']['language']=='en' || $this->config['settings']['language']=='eng'){
							$this->config['settings']['language']=3;
						} else if($this->config['settings']['language']=='latvian' || $this->config['settings']['language']=='lv' || $this->config['settings']['language']=='lat'){
							$this->config['settings']['language']=6;
						} else if($this->config['settings']['language']=='lithuanian' || $this->config['settings']['language']=='lt' || $this->config['settings']['language']=='lit'){
							$this->config['settings']['language']=7;
						} else {
							$this->config['settings']['language']=3;
						}
						echo '<input type="hidden" name="SOLOPMT_LANGUAGE" value="'.$this->config['settings']['language'].'"/>';
						$amount=number_format($this->config['order']['amount'], 2, '.', '');
						echo '<input type="hidden" name="SOLOPMT_AMOUNT" value="'.$amount.'"/>'; //amount to be transferred
						$reference=@$this->referenceNumber($this->config['order']['order-code']);
						echo '<input type="hidden" name="SOLOPMT_REF" value="'.$reference.'"/>'; //'standard reference number'?
						echo '<input type="hidden" name="SOLOPMT_DATE" value="EXPRESS"/>'; //EXPRESS or DD.MM.YYYY
						echo '<input type="hidden" name="SOLOPMT_MSG" value="'.$this->config['order']['message'].'"/>'; //custom message
						echo '<input type="hidden" name="SOLOPMT_RETURN" value="'.$this->config['this'].'&epay-rt=return&epay-r='.urlencode($this->config['settings']['return-url']).'"/>'; //url to be returned to, if successful
						echo '<input type="hidden" name="SOLOPMT_REJECT" value="'.$this->config['this'].'&epay-rt=reject&epay-r='.urlencode($this->config['settings']['return-url']).'"/>'; //url to be returned to, if rejected
						echo '<input type="hidden" name="SOLOPMT_CANCEL" value="'.$this->config['this'].'&epay-rt=cancel&epay-r='.urlencode($this->config['settings']['return-url']).'"/>'; //url to be returned to, if canceled
						$mac=strtoupper(md5('0003&'.$this->config['order']['order-code'].'&'.$this->config['settings']['RCV_ID'].'&'.$amount.'&'.$reference.'&EXPRESS&'.$this->config['order']['currency'].'&'.$this->config['settings']['private-key'].'&'));
						echo '<input type="hidden" name="SOLOPMT_MAC" value="'.$mac.'"/>'; //security hash
						echo '<input type="hidden" name="SOLOPMT_CONFIRM" value="YES"/>'; //if value is YES, the service provider receives information on the payment processing through all return links
						echo '<input type="hidden" name="SOLOPMT_KEYVERS" value="0001"/>'; //MAC key version
						echo '<input type="hidden" name="SOLOPMT_CUR" value="'.strtoupper($this->config['order']['currency']).'"/>'; //currency
						echo '<input type="submit" name="epay-submitbutton" id="epay-submitbutton" value="click here if you are not being redirected"/>';
					echo '</form>';
					break;
				case 'nordea-fin':
					echo '<form name="epay-form" method="post" action="'.$this->config['settings']['service-url'].'">';
						echo '<input type="hidden" name="SOLOPMT_VERSION" value="0003"/>'; //presentation form of payment data, either 0002 or 0003, latter is recommended
						echo '<input type="hidden" name="SOLOPMT_STAMP" value="'.$this->config['order']['order-code'].'"/>'; //unique order code in e-shop to eliminate duplicate transactions
						echo '<input type="hidden" name="SOLOPMT_RCV_ID" value="'.$this->config['settings']['RCV_ID'].'"/>'; //service provider ID
						if(isset($this->config['settings']['RCV_ACCOUNT']) || isset($this->config['settings']['RCV_NAME'])){
							echo '<input type="hidden" name="SOLOPMT_RCV_ACCOUNT" value="'.$this->config['settings']['SOLOPMT_RCV_ACCOUNT'].'"/>'; //alternative account, must be registered in Nordea
							echo '<input type="hidden" name="SOLOPMT_RCV_NAME" value="'.$this->config['settings']['SOLOPMT_RCV_NAME'].'"/>'; //payment receiver name, if not default
						}
						$this->config['settings']['language']=strtolower($this->config['settings']['language']);
						if($this->config['settings']['language']=='finnish' || $this->config['settings']['language']=='finnish' || $this->config['settings']['language']=='fi' || $this->config['settings']['language']=='fin'){
							$this->config['settings']['language']=1;
						} else {
							$this->config['settings']['language']=1;
						}
						echo '<input type="hidden" name="SOLOPMT_LANGUAGE" value="'.$this->config['settings']['language'].'"/>';
						$amount=number_format($this->config['order']['amount'], 2, '.', '');
						echo '<input type="hidden" name="SOLOPMT_AMOUNT" value="'.$amount.'"/>'; //amount to be transferred
						$reference=@$this->referenceNumber($this->config['order']['order-code']);
						echo '<input type="hidden" name="SOLOPMT_REF" value="'.$reference.'"/>'; //'standard reference number'?
						echo '<input type="hidden" name="SOLOPMT_DATE" value="EXPRESS"/>'; //EXPRESS or DD.MM.YYYY
						echo '<input type="hidden" name="SOLOPMT_MSG" value="'.$this->config['order']['message'].'"/>'; //custom message
						echo '<input type="hidden" name="SOLOPMT_RETURN" value="'.$this->config['this'].'&epay-rt=return&epay-r='.urlencode($this->config['settings']['return-url']).'"/>'; //url to be returned to, if successful
						echo '<input type="hidden" name="SOLOPMT_REJECT" value="'.$this->config['this'].'&epay-rt=reject&epay-r='.urlencode($this->config['settings']['return-url']).'"/>'; //url to be returned to, if rejected
						echo '<input type="hidden" name="SOLOPMT_CANCEL" value="'.$this->config['this'].'&epay-rt=cancel&epay-r='.urlencode($this->config['settings']['return-url']).'"/>'; //url to be returned to, if canceled
						$mac=strtoupper(md5('0003&'.$this->config['order']['order-code'].'&'.$this->config['settings']['RCV_ID'].'&'.$amount.'&'.$reference.'&EXPRESS&'.$this->config['order']['currency'].'&'.$this->config['settings']['private-key'].'&'));
						echo '<input type="hidden" name="SOLOPMT_MAC" value="'.$mac.'"/>'; //security hash
						echo '<input type="hidden" name="SOLOPMT_CONFIRM" value="YES"/>'; //if value is YES, the service provider receives information on the payment processing through all return links
						echo '<input type="hidden" name="SOLOPMT_KEYVERS" value="0001"/>'; //MAC key version
						echo '<input type="hidden" name="SOLOPMT_CUR" value="'.strtoupper($this->config['order']['currency']).'"/>'; //currency
						echo '<input type="submit" name="epay-submitbutton" id="epay-submitbutton" value="click here if you are not being redirected"/>';
					echo '</form>';
					break;
					break;
				case 'sampo-fin':
					echo '<form name="epay-form" method="post" action="'.$this->config['settings']['service-url'].'">';
						echo '<input type="hidden" name="KNRO" value="'.$this->config['settings']['KNRO'].'"/>'; //
						$amount=number_format($this->config['order']['amount'], 2, '.', '');
						echo '<input type="hidden" name="SUMMA" value="'.$amount.'"/>'; //
						echo '<input type="hidden" name="VIITE" value="'.$this->config['order']['order-code'].'"/>'; //
						echo '<input type="hidden" name="VALUUTTA" value="'.strtoupper($this->config['order']['currency']).'"/>'; //currency
						echo '<input type="hidden" name="VERSIO" value="3"/>'; //
						echo '<input type="hidden" name="OKURL" value="'.$this->config['this'].'&epay-rt=return&epay-r='.urlencode($this->config['settings']['return-url']).'"/>'; //if payment a success url
						echo '<input type="hidden" name="VIRHEURL" value="'.$this->config['settings']['cancel-url'].'"/>'; //if payment failed url
						$mac=md5($this->config['settings']['private-key'].str_replace('.',',',$amount).$this->config['order']['order-code'].$this->config['settings']['KNRO'].'3'.strtoupper($this->config['order']['currency']).$this->config['this'].'&epay-rt=return&epay-r='.urlencode($this->config['settings']['return-url']).$this->config['settings']['cancel-url']);
						echo '<input type="hidden" name="TARKISTE" value="'.$mac.'"/>'; //
						echo '<input type="submit" name="epay-submitbutton" id="epay-submitbutton" value="click here if you are not being redirected"/>';
					echo '</form>';
					break;
				case 'estcard-est':
					echo '<form name="epay-form" method="get" action="'.$this->config['settings']['service-url'].'">';

						echo '<input type="hidden" name="action" value="gaf"/>'; //
						echo '<input type="hidden" name="ver" value="002"/>'; //
						echo '<input type="hidden" name="id" value="'.$this->config['settings']['SERVICE'].'"/>'; //
						while (strlen($this->config['settings']['SERVICE']) < 10){
							$this->config['settings']['SERVICE'] = $this->config['settings']['SERVICE'].' ';
						}
						while(strlen($this->config['order']['order-code']) < 12){
							$this->config['order']['order-code'] = '0'.$this->config['order']['order-code'];
						}
						echo '<input type="hidden" name="ecuno" value="'.$this->config['order']['order-code'].'"/>'; //
						$price=number_format($this->config['order']['amount'], 2, '.', '');
						$price = $price*100;
						while (strlen($price) < 12){
							$price = '0'.$price;
						}
						echo '<input type="hidden" name="eamount" value="'.$price.'"/>'; //
						echo '<input type="hidden" name="cur" value="'.strtoupper($this->config['order']['currency']).'"/>'; //
						$date=date('YmdHis');
						echo '<input type="hidden" name="datetime" value="'.$date.'"/>'; //
						
						$mac='002'.$this->config['settings']['SERVICE'].$this->config['order']['order-code'].$price.strtoupper($this->config['order']['currency']).$date;
						$private_key = openssl_pkey_get_private($this->config['settings']['client-private-key']);
						openssl_sign($mac, $signature, $private_key, OPENSSL_ALGO_SHA1);
						openssl_free_key($private_key); 
						$mac=bin2hex($signature);
						
						echo '<input type="hidden" name="mac" value="'.$mac.'"/>'; //
						$this->config['settings']['language']=strtolower($this->config['settings']['language']);
						if($this->config['settings']['language']=='estonia' || $this->config['settings']['language']=='estonian' || $this->config['settings']['language']=='et' || $this->config['settings']['language']=='est'){
							$this->config['settings']['language']='et';
						} else if($this->config['settings']['language']=='english' || $this->config['settings']['language']=='en' || $this->config['settings']['language']=='eng'){
							$this->config['settings']['language']='en';
						} else if($this->config['settings']['language']=='russian' || $this->config['settings']['language']=='ru' || $this->config['settings']['language']=='rus'){
							$this->config['settings']['language']='ru';
						} else {
							$this->config['settings']['language']='en';
						}
						echo '<input type="hidden" name="lang" value="'.$this->config['settings']['language'].'"/>'; //
						echo '<input type="submit" name="epay-submitbutton" id="epay-submitbutton" value="click here if you are not being redirected"/>';
					echo '</form>';
					break;
			}
		}
		
		public function checkPayment($data){
			$return=array();
			switch ($this->config['payment']) {
				case 'swed-est':
					if($data['VK_SERVICE']=='1101'){
						$mac='';
						$mac.=str_pad(mb_strlen($data['VK_SERVICE'],'UTF-8'),3,'0',STR_PAD_LEFT).$data['VK_SERVICE'];
						$mac.=str_pad(mb_strlen($data['VK_VERSION'],'UTF-8'),3,'0',STR_PAD_LEFT).$data['VK_VERSION'];
						$mac.=str_pad(mb_strlen($data['VK_SND_ID'],'UTF-8'),3,'0',STR_PAD_LEFT).$data['VK_SND_ID'];
						$mac.=str_pad(mb_strlen($data['VK_REC_ID'],'UTF-8'),3,'0',STR_PAD_LEFT).$data['VK_REC_ID'];
						$mac.=str_pad(mb_strlen($data['VK_STAMP'],'UTF-8'),3,'0',STR_PAD_LEFT).$data['VK_STAMP'];
						$mac.=str_pad(mb_strlen($data['VK_T_NO'],'UTF-8'),3,'0',STR_PAD_LEFT).$data['VK_T_NO'];
						$mac.=str_pad(mb_strlen($data['VK_AMOUNT'],'UTF-8'),3,'0',STR_PAD_LEFT).$data['VK_AMOUNT'];
						$mac.=str_pad(mb_strlen($data['VK_CURR'],'UTF-8'),3,'0',STR_PAD_LEFT).$data['VK_CURR'];
						$mac.=str_pad(mb_strlen($data['VK_REC_ACC'],'UTF-8'),3,'0',STR_PAD_LEFT).$data['VK_REC_ACC'];
						$mac.=str_pad(mb_strlen($data['VK_REC_NAME'],'UTF-8'),3,'0',STR_PAD_LEFT).$data['VK_REC_NAME'];
						$mac.=str_pad(mb_strlen($data['VK_SND_ACC'],'UTF-8'),3,'0',STR_PAD_LEFT).$data['VK_SND_ACC'];
						$mac.=str_pad(mb_strlen($data['VK_SND_NAME'],'UTF-8'),3,'0',STR_PAD_LEFT).$data['VK_SND_NAME'];
						$mac.=str_pad(mb_strlen($data['VK_REF'],'UTF-8'),3,'0',STR_PAD_LEFT).$data['VK_REF'];
						$mac.=str_pad(mb_strlen($data['VK_MSG'],'UTF-8'),3,'0',STR_PAD_LEFT).$data['VK_MSG'];
						$mac.=str_pad(mb_strlen($data['VK_T_DATE'],'UTF-8'),3,'0',STR_PAD_LEFT).$data['VK_T_DATE'];
						
						$key=openssl_pkey_get_public($this->config['settings']['bank-public-key']);
						if(openssl_verify($mac,base64_decode($data['VK_MAC']),$key)){
							$return['result']='success';
							$return['payment-code']=$data['VK_T_NO'];
							$return['reference-number']=$data['VK_REF'];
							$return['order-code']=$data['VK_STAMP'];
							$return['sender-name']=$data['VK_SND_NAME'];
							$return['sender-account']=$data['VK_SND_ACC'];
						} else {
							$return['result']='failed';
							$return['message']='security hash incorrect - '.openssl_error_string();
						}
						openssl_free_key($key);
					}
					if($data['VK_SERVICE']=='1901'){
						$mac='';
						$mac.=str_pad(mb_strlen($data['VK_SERVICE'],'UTF-8'),3,'0',STR_PAD_LEFT).$data['VK_SERVICE'];
						$mac.=str_pad(mb_strlen($data['VK_VERSION'],'UTF-8'),3,'0',STR_PAD_LEFT).$data['VK_VERSION'];
						$mac.=str_pad(mb_strlen($data['VK_SND_ID'],'UTF-8'),3,'0',STR_PAD_LEFT).$data['VK_SND_ID'];
						$mac.=str_pad(mb_strlen($data['VK_REC_ID'],'UTF-8'),3,'0',STR_PAD_LEFT).$data['VK_REC_ID'];
						$mac.=str_pad(mb_strlen($data['VK_STAMP'],'UTF-8'),3,'0',STR_PAD_LEFT).$data['VK_STAMP'];
						$mac.=str_pad(mb_strlen($data['VK_REF'],'UTF-8'),3,'0',STR_PAD_LEFT).$data['VK_REF'];
						$mac.=str_pad(mb_strlen($data['VK_MSG'],'UTF-8'),3,'0',STR_PAD_LEFT).$data['VK_MSG'];
						$key=openssl_pkey_get_public($this->config['settings']['bank-public-key']);
						if(openssl_verify($mac,base64_decode($data['VK_MAC']),$key)){
							$return['result']='failed';
							$return['reference-number']=$data['VK_REF'];
							$return['order-code']=$data['VK_STAMP'];
							$return['message']='payment canceled';
						} else {
							$return['result']='failed';
							$return['message']='security hash incorrect - '.openssl_error_string();
						}
						openssl_free_key($key);
					}
					break;
				case 'seb-est':
					if($data['VK_SERVICE']=='1101'){
						$mac='';
						$mac.=str_pad(strlen($data['VK_SERVICE']),3,'0',STR_PAD_LEFT).$data['VK_SERVICE'];
						$mac.=str_pad(strlen($data['VK_VERSION']),3,'0',STR_PAD_LEFT).$data['VK_VERSION'];
						$mac.=str_pad(strlen($data['VK_SND_ID']),3,'0',STR_PAD_LEFT).$data['VK_SND_ID'];
						$mac.=str_pad(strlen($data['VK_REC_ID']),3,'0',STR_PAD_LEFT).$data['VK_REC_ID'];
						$mac.=str_pad(strlen($data['VK_STAMP']),3,'0',STR_PAD_LEFT).$data['VK_STAMP'];
						$mac.=str_pad(strlen($data['VK_T_NO']),3,'0',STR_PAD_LEFT).$data['VK_T_NO'];
						$mac.=str_pad(strlen($data['VK_AMOUNT']),3,'0',STR_PAD_LEFT).$data['VK_AMOUNT'];
						$mac.=str_pad(strlen($data['VK_CURR']),3,'0',STR_PAD_LEFT).$data['VK_CURR'];
						$mac.=str_pad(strlen($data['VK_REC_ACC']),3,'0',STR_PAD_LEFT).$data['VK_REC_ACC'];
						$mac.=str_pad(strlen($data['VK_REC_NAME']),3,'0',STR_PAD_LEFT).$data['VK_REC_NAME'];
						$mac.=str_pad(strlen($data['VK_SND_ACC']),3,'0',STR_PAD_LEFT).$data['VK_SND_ACC'];
						$mac.=str_pad(strlen($data['VK_SND_NAME']),3,'0',STR_PAD_LEFT).$data['VK_SND_NAME'];
						$mac.=str_pad(strlen($data['VK_REF']),3,'0',STR_PAD_LEFT).$data['VK_REF'];
						$mac.=str_pad(strlen($data['VK_MSG']),3,'0',STR_PAD_LEFT).$data['VK_MSG'];
						$mac.=str_pad(strlen($data['VK_T_DATE']),3,'0',STR_PAD_LEFT).$data['VK_T_DATE'];
						
						$key=openssl_pkey_get_public($this->config['settings']['bank-public-key']);
						if(openssl_verify($mac,base64_decode($data['VK_MAC']),$key)){
							$return['result']='success';
							$return['payment-code']=$data['VK_T_NO'];
							$return['reference-number']=$data['VK_REF'];
							$return['order-code']=$data['VK_STAMP'];
							$return['sender-name']=$data['VK_SND_NAME'];
							$return['sender-account']=$data['VK_SND_ACC'];
						} else {
							$return['result']='failed';
							$return['message']='security hash incorrect - '.openssl_error_string();
						}
						openssl_free_key($key);
					}
					if($data['VK_SERVICE']=='1901'){
						$mac='';
						$mac.=str_pad(strlen($data['VK_SERVICE']),3,'0',STR_PAD_LEFT).$data['VK_SERVICE'];
						$mac.=str_pad(strlen($data['VK_VERSION']),3,'0',STR_PAD_LEFT).$data['VK_VERSION'];
						$mac.=str_pad(strlen($data['VK_SND_ID']),3,'0',STR_PAD_LEFT).$data['VK_SND_ID'];
						$mac.=str_pad(strlen($data['VK_REC_ID']),3,'0',STR_PAD_LEFT).$data['VK_REC_ID'];
						$mac.=str_pad(strlen($data['VK_STAMP']),3,'0',STR_PAD_LEFT).$data['VK_STAMP'];
						$mac.=str_pad(strlen($data['VK_REF']),3,'0',STR_PAD_LEFT).$data['VK_REF'];
						$mac.=str_pad(strlen($data['VK_MSG']),3,'0',STR_PAD_LEFT).$data['VK_MSG'];
						$key=openssl_pkey_get_public($this->config['settings']['bank-public-key']);
						if(openssl_verify($mac,base64_decode($data['VK_MAC']),$key)){
							$return['result']='failed';
							$return['reference-number']=$data['VK_REF'];
							$return['order-code']=$data['VK_STAMP'];
							$return['message']='payment canceled';
						} else {
							$return['result']='failed';
							$return['message']='security hash incorrect - '.openssl_error_string();
						}
						openssl_free_key($key);
					}
					if($data['VK_SERVICE']=='1902'){
						$mac='';
						$mac.=str_pad(strlen($data['VK_SERVICE']),3,'0',STR_PAD_LEFT).$data['VK_SERVICE'];
						$mac.=str_pad(strlen($data['VK_VERSION']),3,'0',STR_PAD_LEFT).$data['VK_VERSION'];
						$mac.=str_pad(strlen($data['VK_SND_ID']),3,'0',STR_PAD_LEFT).$data['VK_SND_ID'];
						$mac.=str_pad(strlen($data['VK_REC_ID']),3,'0',STR_PAD_LEFT).$data['VK_REC_ID'];
						$mac.=str_pad(strlen($data['VK_STAMP']),3,'0',STR_PAD_LEFT).$data['VK_STAMP'];
						$mac.=str_pad(strlen($data['VK_REF']),3,'0',STR_PAD_LEFT).$data['VK_REF'];
						$mac.=str_pad(strlen($data['VK_MSG']),3,'0',STR_PAD_LEFT).$data['VK_MSG'];
						$mac.=str_pad(strlen($data['VK_ERROR_CODE']),3,'0',STR_PAD_LEFT).$data['VK_ERROR_CODE'];
						$key=openssl_pkey_get_public($this->config['settings']['bank-public-key']);
						if(openssl_verify($mac,base64_decode($data['VK_MAC']),$key)){
							$return['result']='failed';
							$return['reference-number']=$data['VK_REF'];
							$return['order-code']=$data['VK_STAMP'];
							$return['message']='payment rejected, error code '.$data['VK_ERROR_CODE'];
						} else {
							$return['result']='failed';
							$return['message']='security hash incorrect - '.openssl_error_string();
						}
						openssl_free_key($key);
					}
					break;
				case 'sampo-est':
					if($data['VK_SERVICE']=='1101'){
						$mac='';
						$mac.=str_pad(strlen($data['VK_SERVICE']),3,'0',STR_PAD_LEFT).$data['VK_SERVICE'];
						$mac.=str_pad(strlen($data['VK_VERSION']),3,'0',STR_PAD_LEFT).$data['VK_VERSION'];
						$mac.=str_pad(strlen($data['VK_SND_ID']),3,'0',STR_PAD_LEFT).$data['VK_SND_ID'];
						$mac.=str_pad(strlen($data['VK_REC_ID']),3,'0',STR_PAD_LEFT).$data['VK_REC_ID'];
						$mac.=str_pad(strlen($data['VK_STAMP']),3,'0',STR_PAD_LEFT).$data['VK_STAMP'];
						$mac.=str_pad(strlen($data['VK_T_NO']),3,'0',STR_PAD_LEFT).$data['VK_T_NO'];
						$mac.=str_pad(strlen($data['VK_AMOUNT']),3,'0',STR_PAD_LEFT).$data['VK_AMOUNT'];
						$mac.=str_pad(strlen($data['VK_CURR']),3,'0',STR_PAD_LEFT).$data['VK_CURR'];
						$mac.=str_pad(strlen($data['VK_REC_ACC']),3,'0',STR_PAD_LEFT).$data['VK_REC_ACC'];
						$mac.=str_pad(strlen($data['VK_REC_NAME']),3,'0',STR_PAD_LEFT).$data['VK_REC_NAME'];
						$mac.=str_pad(strlen($data['VK_SND_ACC']),3,'0',STR_PAD_LEFT).$data['VK_SND_ACC'];
						$mac.=str_pad(strlen($data['VK_SND_NAME']),3,'0',STR_PAD_LEFT).$data['VK_SND_NAME'];
						$mac.=str_pad(strlen($data['VK_REF']),3,'0',STR_PAD_LEFT).$data['VK_REF'];
						$mac.=str_pad(strlen($data['VK_MSG']),3,'0',STR_PAD_LEFT).$data['VK_MSG'];
						$mac.=str_pad(strlen($data['VK_T_DATE']),3,'0',STR_PAD_LEFT).$data['VK_T_DATE'];
						
						$key=openssl_pkey_get_public($this->config['settings']['bank-public-key']);
						if(openssl_verify($mac,base64_decode($data['VK_MAC']),$key)){
							$return['result']='success';
							$return['payment-code']=$data['VK_T_NO'];
							$return['reference-number']=$data['VK_REF'];
							$return['order-code']=$data['VK_STAMP'];
							$return['sender-name']=$data['VK_SND_NAME'];
							$return['sender-account']=$data['VK_SND_ACC'];
						} else {
							$return['result']='failed';
							$return['message']='security hash incorrect - '.openssl_error_string();
						}
						openssl_free_key($key);
					}
					if($data['VK_SERVICE']=='1901'){
						$mac='';
						$mac.=str_pad(strlen($data['VK_SERVICE']),3,'0',STR_PAD_LEFT).$data['VK_SERVICE'];
						$mac.=str_pad(strlen($data['VK_VERSION']),3,'0',STR_PAD_LEFT).$data['VK_VERSION'];
						$mac.=str_pad(strlen($data['VK_SND_ID']),3,'0',STR_PAD_LEFT).$data['VK_SND_ID'];
						$mac.=str_pad(strlen($data['VK_REC_ID']),3,'0',STR_PAD_LEFT).$data['VK_REC_ID'];
						$mac.=str_pad(strlen($data['VK_STAMP']),3,'0',STR_PAD_LEFT).$data['VK_STAMP'];
						$mac.=str_pad(strlen($data['VK_REF']),3,'0',STR_PAD_LEFT).$data['VK_REF'];
						$mac.=str_pad(strlen($data['VK_MSG']),3,'0',STR_PAD_LEFT).$data['VK_MSG'];
						$key=openssl_pkey_get_public($this->config['settings']['bank-public-key']);
						if(openssl_verify($mac,base64_decode($data['VK_MAC']),$key)){
							$return['result']='failed';
							$return['reference-number']=$data['VK_REF'];
							$return['order-code']=$data['VK_STAMP'];
							$return['message']='payment canceled';
						} else {
							$return['result']='failed';
							$return['message']='security hash incorrect - '.openssl_error_string();
						}
						openssl_free_key($key);
					}
					break;
				case 'nordea-est':
					$MAC=strtoupper(md5(@$data['SOLOPMT_RETURN_VERSION'].'&'.@$data['SOLOPMT_RETURN_STAMP'].'&'.@$data['SOLOPMT_RETURN_REF'].'&'.@$data['SOLOPMT_RETURN_PAID'].'&'.$this->config['settings']['private-key'].'&'));
					if($data['SOLOPMT_RETURN_MAC']==$MAC){
						if(isset($data['SOLOPMT_RETURN_PAID']) && $data['SOLOPMT_RETURN_PAID']!=''){
							$return['result']='success';
							$return['payment-code']=$data['SOLOPMT_RETURN_PAID'];
							$return['reference-number']=$data['SOLOPMT_RETURN_REF'];
							$return['order-code']=$data['SOLOPMT_RETURN_STAMP'];
						} else {
							$return['result']='failed';
							$return['message']='no payment code';
						}
					} else {
						$return['result']='failed';
						$return['message']='security hash incorrect';
					}
					break;
				case 'nordea-fin':
					$MAC=strtoupper(md5(@$data['SOLOPMT_RETURN_VERSION'].'&'.@$data['SOLOPMT_RETURN_STAMP'].'&'.@$data['SOLOPMT_RETURN_REF'].'&'.@$data['SOLOPMT_RETURN_PAID'].'&'.$this->config['settings']['private-key'].'&'));
					if($data['SOLOPMT_RETURN_MAC']==$MAC){
						if(isset($data['SOLOPMT_RETURN_PAID']) && $data['SOLOPMT_RETURN_PAID']!=''){
							$return['result']='success';
							$return['payment-code']=$data['SOLOPMT_RETURN_PAID'];
							$return['reference-number']=$data['SOLOPMT_RETURN_REF'];
							$return['order-code']=$data['SOLOPMT_RETURN_STAMP'];
						} else {
							$return['result']='failed';
							$return['message']='no payment code';
						}
					} else {
						$return['result']='failed';
						$return['message']='security hash incorrect';
					}
					break;
				case 'sampo-fin':
					$MAC=md5($this->config['settings']['private-key'].$data['VIITE'].$data['SUMMA'].$data['STATUS'].$this->config['settings']['KNRO'].$data['VERSIO'].$data['VALUUTTA']);
					if($data['STATUS']==0 && $data['TARKISTE']==$MAC){
						$return['result']='success';
						$return['order-code']=$data['VIITE'];
					} else if($data['STATUS']!=0 && $data['TARKISTE']==$MAC){
						$return['result']='failed';
						$return['message']='problem with payment, status '.$data['STATUS'];
					} else {
						$return['result']='failed';
						$return['message']='security hash incorrect';
					}
					break;
				case 'estcard-est':
					echo '<pre>';
					print_r($data);
					echo '</pre>';
					$macstring=sprintf("%03s",$data['ver']).sprintf("%-10s",$data['id']).sprintf("%012s",$data['ecuno']).sprintf("%06s",$data['receipt_no']).sprintf("%012s",$data['eamount']).sprintf("%3s",$data['cur']).$data['respcode'].$data['datetime'].sprintf("%-40s",$data['msgdata']).sprintf("%-40s", $data['actiontext']);
					$mac='';
					for($i=0;$i<strlen($data['mac']);$i+=2){
						$mac.=chr(hexdec(substr($data['mac'],$i,2)));
					}
					$public_key = openssl_get_publickey($this->config['settings']['bank-public-key']);
					if(openssl_verify($macstring,$mac,$public_key)){
						if($data['respcode']=='000'){
							$return['result']='success';
							$return['order-code']=$data['ecuno'];
						} else {
							$return['result']='failed';
							$return['message']='problem with payment, status '.$data['respcode'];
						}
					} else {
						$return['result']='failed';
						$return['message']='security hash incorrect';
					}
					openssl_free_key($public_key);
					break;
			}
			return $return;
		}
		
		public function referenceNumber($nr){
			$nr = (string)$nr;
			$weight = array(7,3,1);
			$sl = $st = strlen($nr);
			while($nr{--$sl}>='0'){
				$total += $nr{($st-1)-$sl}*$weight[($sl%3)];
			}
			$checknr = ((ceil(($total/10))*10)-$total);
			return $nr.$checknr;
		}

	}

?>
For more information send a message to info at phpclasses dot org.