Jump to content

Custom Payment Gateway Help


cyberdoc

Recommended Posts

Hi guys, im trying to develop a custom payment gateway module for bitcoin payments on presta. The process goes as under. 

ive listed it as a gateway. when the user chooses it, i redirect him to a page on my gateway server where he's shown a barcode. He scans the barcode and make the bitcoin payment. Then ive another page on my server which tells presta the status of the user activitiy. (its called listening.aspx) and it returns a JSON response (PAID: if user has paid/EXPIRED: Timeout/ AWAITING : waiting for user activity)

So what i need is after i redirect user to my server for showing barcode for payment, 

my prestashop should check this status every 10 seconds and if it has changed to paid or expired update the order respectively.. 

I've come up with the following code for this, (am a newbie and excuse me if its lame...) Hope to get some help soon on how to proceed.

$order_id = $this->module->currentOrder;
		
		if (!$order_id) {
			Tools::redirect($this->context->link->getPageLink('history'), true);
		}

		
		
		$price = (float)$cart->getOrderTotal(true, Cart::BOTH);
	//Get url of payment and listening page for the transaction	
$json = file_get_contents('http://old.kbourbaki.com/xapiserverprestashop.aspx?servicio=rfp&keyapi=abc1234efg&importe=248,64&orden=uvw234xyz');
$obj = json_decode($json);
$paypage = $obj->paymentpage;
Tools::redirect($paypage);
while($endloop==0)   // till a response is received
{		
$json = file_get_contents('http://old.kbourbaki.com/xlisteningpageprestashop.aspx?yyyyyyy');
$obj = json_decode($json);
$result=$obj->response;  //response of server listening page
echo($result);
if ($result=='paid') 
{
return 1; // paid, update presta 
$end=1;
}elseif ($result=='expired' ) {
return -1; // timeout, redirect to home
$end=1;
Tools::redirect('http://www.ahmspro.com/presta');
}	else{
 return 0; // awaiting response
 sleep(10); // wait for 10 seconds
}
	}

any help would be highly appreciated :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...