Implementing ogone payment gateway and sample code
- Get the test details for implementation
- Get the ogone Id that is pspid
- Add passphrasein and passphrase out in payment gateway console
- The signature is created by arranging the passing variables(ie the variable/field that are passed to payment gateway) should be arranged in alphabetical order and crate the sha1 as shown below
- They use a redirect model for payment
- ie the user will be rediected to there site for making the payment
- Before for sending the details to payment gateway we need to save the details so that we can verify the details after the payment
- On the buy page on submitting we need a serverside validation of the details the user have entered and after that the user details need to be stored in our DB after the payment is successfully completed
- After entering all the details we need to redirect to another page it contain a form and the form variables, which are in hidden and we need to auto submit after loading the page
$PSPID = $ogonepspid; //'OGONETEST';
$Price = $amount * 100;
$passphrase = $passphrasein;//'TESTPHASEIN';
$unique_id =RAND(890000,895689596);
$Ogone_sha1 = "ACCEPTURL="BASEURL/successURL".$passphrase.
"AMOUNT=".$Price.$passphrase.
"CANCELURL="BASEURL/error".$passphrase.
"CN=".$data['firstname'].$passphrase.
"CURRENCY=EUR".$passphrase.
"DECLINEURL="BASEURL/error".$passphrase.
"EMAIL=".$data['email'].$passphrase.
"EXCEPTIONURL="BASEURL/error".$passphrase.
"LANGUAGE=en_us".$passphrase.
"LOGO="LOGOURL".$passphrase.
"OPERATION=SAL".$passphrase.
"ORDERID=".$unique_id.$passphrase.
"PSPID=".$PSPID.$passphrase;
- Creating the signature
?>
On the intermediate page
<form action="https://secure.ogone.com/ncol/test/orderstandard.asp" method="post" name="ogone">
<input name="PSPID" type="hidden" value="963852741" />
<input name="ORDERID" type="hidden" value="123469" />
<input name="AMOUNT" type="hidden" value="1000" />
<input name="CURRENCY" type="hidden" value="EUR" />
<input name="LANGUAGE" type="hidden" value="en_us" />
<input name="CN" type="hidden" value="FIRSTNAME" />
<input name="EMAIL" type="hidden" value="test@example.com" />
<input name="OPERATION" type="hidden" value="SAL" />
<input name="SHASIGN" type="hidden" value="<?php echo $Ogone_sha1;?>" />
<input name="LOGO" type="hidden" value="Logo to be shown on page" />
<input name="acceptUrl" type="hidden" value="acceptUrl" />
<input name="declineUrl" type="hidden" value="cancel Url" />
<input name="exceptionUrl" type="hidden" value="exceptionUrl or Cancel url" />
<input name="cancelurl" type="hidden" value="cancel url" />
<input name="submit" type="submit" value="submit" />
</form>
After the successful payment the payment will redirect to success url
- validation of success url details
$resp_data = $urldetails; //GET[DATA] / POST[DATA];
// get the data from the payment gateway by get or by post method
$passphrase = $ogonepassphraseout; //test phraseout
$ogoneSha = 'ACCEPTANCE='.$resp_data['ACCEPTANCE'].$passphrase
.'AMOUNT='.$resp_data['amount'].$passphrase
.'BRAND='.$resp_data['BRAND'].$passphrase
.'CARDNO='.$resp_data['CARDNO'].$passphrase
.'CN='.$resp_data['CN'].$passphrase
.'CURRENCY='.$resp_data['currency'].$passphrase
.'ED='.$resp_data['ED'].$passphrase
.'IP='.$resp_data['IP'].$passphrase
.'NCERROR='.$resp_data['NCERROR'].$passphrase
.'ORDERID='.$resp_data['orderID'].$passphrase
.'PAYID='.$resp_data['PAYID'].$passphrase
.'PM='.$resp_data['PM'].$passphrase
.'STATUS='.$resp_data['STATUS'].$passphrase
.'TRXDATE='.$resp_data['TRXDATE'].$passphrase;
$ogoneSha1 = strtoupper(sha1($ogoneSha));
if($ogoneSha1 == $resp_data['SHASIGN'] && ($resp_data['STATUS'] == '9')){
// payment success
}else{
// payment failed
}
?>
No comments:
Post a Comment