Question : I want to make Liberty reserve API

my problem It's not updating credit:
Here's Buy creditpage
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
<?php

	class BuyCredits{
		public $error;

		public function head(){

			global $db,$root;

			if(!$_SESSION['vcount_wait']) $_SESSION['vcount_wait']=0;

			//Gutschein einl¿sen
			if($_POST['voucher']){
				if(!$_SESSION['vcount'] || $_SESSION['vcount']<6){
					$is=$db->selectOne('SELECT * FROM vouchers WHERE code="'.$db->escape($_POST['voucher']).'" AND active=1 AND userId=0');
					if($is['id']){
						$db->query('UPDATE vouchers SET userId='.$_SESSION['userId'].',active=0,date='.time().',ip="'.$_SERVER['REMOTE_ADDR'].'" WHERE id='.$is['id']);
						$db->query('UPDATE user SET account=account+'.$is['amount'].' WHERE id='.$_SESSION['userId']);
						$db->insert('INSERT INTO transactions VALUES(NULL,'.$_SESSION['userId'].',1,"'.$_SERVER['REMOTE_ADDR'].'",'.$is['amount'].',"Voucher '.$_POST['voucher'].'",'.time().')');

						header('Location:'.$root.'/?do=account&s=credits&balance=1');

					}else{


						$_SESSION['vcount']++;
						$_SESSION['vcount_time']=time();
						$this->error='Coupon unknown, already radeemed or deactivated.';

						if($_SESSION['vcount']>=5){
							$_SESSION['vcount_wait']+=5;
						}
					}
				}
			}

			//entsperren
			if($_SESSION['vcount']>=5){
				if(((time()-$_SESSION['vcount_time'])/60)>=$_SESSION['vcount_wait']){
					$_SESSION['vcount']=0;
				}
			}

			#$_SESSION['vcount']=0;
			#$_SESSION['vcount_wait']=0;

			$html='<div class="title">Add Credits</div><div class="pane">';

			return $html;
		}

		public function view(){
			global $db,$root,$accountValue,$wmPurse,$wmString;
			if($this->error){
					$html.='<div style="padding:10px;border:1px dotted #db0000;margin-top:15px;background-color:#ffdede" class="text"><b>'.$this->error.'</b></div>';

				}


				require_once('app/classes/account/paysafecard2.php');
				$paysafe=new Paysafecard();



				$html.='<form method="post"><div style="border:1px dotted #666666;padding:6px">
				<table border="0" width="100%" cellspacing="0" cellpadding="8">
					<tr>
						<td width="109" style="text-align:right"><img src="{root}/media/present_32.png"></td>
						<td>';

						if(!$_SESSION['vcount'] || $_SESSION['vcount']<5){
							$html.='
							<div class="subtitle">Radeem Coupon</div>
							<div class="text" style="margin-top:5px;margin-bottom:5px">Please enter Coupon Code:</div>
							<div style="margin-top:8px"><input type="text" name="voucher" value="" style="width:170px"> '.Utility::button('Radeem',false,100,0).'</div>';
						}else{
							$html.=Utility::syserror('Error: too much trials - please wait for '.$_SESSION['vcount_wait'].' minutes!');
						}


						$html.='
						</td>
					</tr>
				</table>
				</div>
				</form>';


				//Deposit Money
				if($_POST['resolve']){

					//Store to Session
					$_SESSION['paysafe'][0]=$_POST['randomNumber_1'];
					$_SESSION['paysafe'][1]=$_POST['randomNumber_2'];
					$_SESSION['paysafe'][2]=$_POST['randomNumber_3'];
					$_SESSION['paysafe'][3]=$_POST['randomNumber_4'];
					$_SESSION['captchaResponse']=$_POST['captchaResponse'];
					$_SESSION['captchaId']=$_POST['captchaId'];
					$_SESSION['password']=$_POST['psPassword'];
					$_SESSION['jsessid']=$_POST['jsess'];
					$_SESSION['retry']=0;

					$html.='
					<div style="margin-top:40px;border:1px dotted #666666;background-color:#ffffff;padding:6px">
					<table border="0" width="100%" cellspacing="0" cellpadding="8">
						<tr valign="top">
								<div class="text" style="margin-top:5px;margin-bottom:5px">
								<div id="psprocess">
								  <img src="{root}/media/ajax-load-bar.gif" style="vertical-align:middle"> checking card ...
								</div>
								'.Utility::button('back','?do=account&s=buycredits',120,5).'

								<script language="javascript">
									num=0;
									function asyncPaysafeRequest(){
										//alert("ok1");
										num++;
										var x = getHTTPObject2();
										var div = document.getElementById("psprocess");
										//var cdiv = document.getElementById("counter");
										//	cdiv.innerHTML=num;

										x.open ("GET", "'.$root.'/?do=ajax&function=pscard", true);
										x.onreadystatechange = function (){
											if (x.readyState == 4){


												if(x.responseText=="retry"){
													asyncPaysafeRequest();
												}else{
													div.innerHTML="";
													div.innerHTML = x.responseText;
												}

											}
										}
										x.send(null);
									}
									asyncPaysafeRequest();
								</script>

								</div>
								<div style="margin-top:8px"></div>
							</td>
						</tr>
					</table>
					</div>
					';

					/*
					$state=$paysafe->getCardStatus(Array($_POST['randomNumber_1'],$_POST['randomNumber_2'],$_POST['randomNumber_3'],$_POST['randomNumber_4']),$_POST['psPassword'],$_POST['captchaId'],$_POST['captchaResponse'],$_POST['jsess']);
					if($state[0]==0){
						$html.=Utility::syserror('Fehler: '.$state[1]).'<br>'.Utility::button('zurück','?do=credits&buy=1',120,5);

					}else{
						$html.='<div class="text" style="border:1px dotted #3bc200;padding:8px;background-color:#ecffe4;margin-top:10px">';
						$html.='<div class="title">Successfully booked!</div>'.$state[1].'</div>';
					}*/

				}else{
					#$captcha=$paysafe->getCaptcha();

					if($_GET['r1']) $_SESSION['paysafe'][0]=$_GET['r1'];
					if($_GET['r2']) $_SESSION['paysafe'][1]=$_GET['r2'];
					if($_GET['r3']) $_SESSION['paysafe'][2]=$_GET['r3'];
					if($_GET['r4']) $_SESSION['paysafe'][3]=$_GET['r4'];
					$_SESSION['retry']=0;
					//$_SESSION['paysafe']
					$html.='
					<form method="post">
					<input type="hidden" name="resolve" value="1">
					<input type="hidden" name="jsess" value="'.$captcha[2].'">
					<div style="margin-top:0px;border:0px dotted #666666;padding:0px">
						<tr valign="top">
							<td>										</td>
									</tr>

								</table>




							</td>
						</tr>
					</table>
					</div>
					</form>


					<div style="margin-top:20px;border:1px dotted #666666;padding:6px">
					<table border="0" width="100%" cellspacing="0" cellpadding="2">
						<tr valign="top">
							<td width="109" style="text-align:right"><img src="{root}/media/money.gif"></td>
							<td>

								<div class="subtitle" style="margin-top:20px">Buy via LibertyReserve <img src="{root}/media/lr.gif" style="vertical-align:middle"></div>
								<div class="text" style="margin-top:5px;margin-bottom:5px">


                                <div style="padding:4px">
                                <form action="{root}/app/classes/account/lr.php" method="post">
                                Credit Amount ($):<input type="text" name="amnt" />
                                <input type="hidden" value="'.$_SESSION['userID'].'" name="usr" />
                             
				<button class="Button" width="100" style="width: 100px;" type="submit">
					<div class="Button1">
						<div class="Button2">
						<div class="Button3">Buy</div>
						</div>

					</div>
				</button>

                                </form>

								</div>
								<div style="margin-top:8px"></div>

							</td>
						</tr>
					</table>
					</div>


					<div style="margin-top:20px;border:1px dotted #666666;padding:6px">
					<table border="0" width="100%" cellspacing="0" cellpadding="8">
						<tr valign="top">
							<td width="109" style="text-align:right"><img src="{root}/media/money.gif"></td>
							<td>

								<div class="subtitle" style="margin-top:20px">Deposit money with <img src="{root}/media/webmoney.gif" style="vertical-align:middle"></div>
								<div class="text" style="margin-top:5px;margin-bottom:5px">
									<div style="padding:4px">'.$wmString.'</div>
									<div style="padding:4px">Purse: <b>'.$wmPurse.'</b></div>
									<div style="padding:4px">Subject: <b>"User-Id: '.$_SESSION['userId'].'"
								</div>
								<div style="margin-top:8px"></div>


							</td>
						</tr>
					</table>
					</div>




					';

				}
			$html.='</div>';
			return $html;
			}

	}


Anything else I can provide so you fix it for me ?

Answer : I want to make Liberty reserve API

Couple of suggestions.  Adopt a coding standard that uses comments, so we do not have to guess at your intent, set error_reporting(E_ALL) whenever you are writing and debugging, and use the session_start() unconditionally in the top of the code.  It may be somewhere else, but it's not showing here and without it, your $_SESSION array is pretty useless.  I doubt if I can fix the code here, but maybe those suggestions will be useful to you.  HTH, ~Ray
Random Solutions  
 
programming4us programming4us