CodeIgniter Forums
how do i store some value to use after redirected from Payment gateway - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: how do i store some value to use after redirected from Payment gateway (/showthread.php?tid=88656)



how do i store some value to use after redirected from Payment gateway - anuragk - 10-12-2023

i want to store some value to use later when the page is being redirected back from payment gateway. 
for ex. i want customer name, address later after the payment is successful.
i have tried using session for that but the session value got destroyed after redicted from another domain or server.
i am new to this so please explain properly. 
i am using Codeigniter 4.


RE: how do i store some value to use after redirected from Payment gateway - captain-sensible - 10-12-2023

not sure but when i integrated paypay they had a " if successful post payment url" you could set yourself and there was the means to get info. So it was only a matter of extracting that info , putting in a database, before the client sees something .like "payment successful" .


RE: how do i store some value to use after redirected from Payment gateway - demyr - 10-12-2023

In order to keep your session you should check CORS subject. There are lots of threads about it including mine here

And in order to trigger anything on a page,  like sending data to the database,   you can use JavaScript (Jquery or whatever your know) on the page load


RE: how do i store some value to use after redirected from Payment gateway - InsiteFX - 10-12-2023

Or save the info in an encrypted cookie.


RE: how do i store some value to use after redirected from Payment gateway - anuragk - 10-13-2023

(10-12-2023, 09:25 PM)InsiteFX Wrote: Or save the info in an encrypted cookie.

can you please explain how can I use an encrypted cookie?

I tried using cookie but it is not working.

PHP Code:
helper('cookie');
 
set_cookie('username'$data['billing_name'], time() + 60*60*24*30);
return 
redirect('testing'); exit; 


PHP Code:
public function testing(){
  helper('cookie');
  echo "page is working";
  echo get_cookie('username'false'');




RE: how do i store some value to use after redirected from Payment gateway - InsiteFX - 10-13-2023

Set a secure PHP cookie for an encrypted connection


RE: how do i store some value to use after redirected from Payment gateway - kenjis - 10-13-2023

@anuragk Never use exit().


RE: how do i store some value to use after redirected from Payment gateway - kenjis - 10-13-2023

@InsiteFX The cookie is not encrypted, but for an encrypted connection (HTTPS).


RE: how do i store some value to use after redirected from Payment gateway - InsiteFX - 10-13-2023

Right, but he would need to encrypted the cookie data then store it in the cookie.


RE: how do i store some value to use after redirected from Payment gateway - anuragk - 10-14-2023

ok but first it needs to work, set_cookie is not working is CI4
and using the mentioned way is not working for storing the cookie


PHP Code:
helper('cookie');
set_cookie('username'$data['billing_name'], time() + 60*60*24*30);
return 
redirect('testing'); 



PHP Code:
public function testing(){
  helper('cookie');
  echo "page is working";
  echo get_cookie('username'false'');


The above code does not give me any output, it only prints page is working, not the cookie value
whereas the conventional PHP way of using cookie is working fine.

I tried
PHP Code:
setcookie('name''this is cookie'); 



PHP Code:
echo $COOKIE['name']; 

this code worked.