Thursday, October 18, 2012

Ogone payment integration in php

Ogone payment simply done in two steps.

 Step 1:        
 $PSPID = 'YOURPSPID'; //'OGONETEST';
 $Price = "100"; // PAYPAL
 $passphrase = 'YOURSECRETKEY';
 $unique_id = RAND(890000,895689596);
 $pm = "CREDIT CARD";
$accept_url="http://yourreturnurl.com"; //Like IPN
$cancelurl="http://yourcancelurl.com";

//If you add any parameters in  Ogone_sha1 order by Alphabet order.
 $Ogone_sha1 =  
                        "ACCEPTURL=".$accept_url.$passphrase.
                        "AMOUNT=".$credit.$passphrase.
                         "BGCOLOR=#010000".$passphrase.
                         "CANCELURL=".$cancelurl.$passphrase.
                         "CURRENCY=EUR".$passphrase.
                         "LANGUAGE=en_us".$passphrase.
                         "ORDERID=".$unique_id.$passphrase.
                         "PM=".$pm.$passphrase.
                         "PSPID=".$PSPID.$passphrase.
                         "TITLE=Payment via Ogone".$passphrase;
//Creating the signature
   $Ogone_sha1 = sha1($Ogone_sha1);

// For test use the url in action https://secure.ogone.com/ncol/test/orderstandard.asp

 $form1 = '<form name="directpayment1" id="directpayment" action="https://secure.ogone.com/ncol/prod/orderstandard.asp" method="post" >
      <input name="PSPID" type="hidden" value="'.$PSPID.'" />
      <input name="AMOUNT" type="hidden" value="'.$credit.'" />
      <input name="ACCEPTURL" type="hidden" value="'.$accept_url.'" />
      <input name="CANCELURL" type="hidden" value="'.$cancelurl.'" />
      <input name="ORDERID" type="hidden" value="'.$unique_id.'" />
      <input name="CURRENCY" type="hidden" value="EUR" />
      <input name="LANGUAGE" type="hidden" value="en_us" />
      <input name="PM"  type="hidden" value="'.$pm.'">
      <input name="TITLE"  type="hidden" value="Payment via Ogone">
      <input name="BGCOLOR"  type="hidden" value="#010000">
      <input name="SHASIGN" type="hidden" value="'.$Ogone_sha1.'" />    
      </form><script>document.getElementById("directpayment").submit()</script>';   
      echo $form1;

Step 2:

If the ogone payment is done it calls the accept url.

$pay_status= $_REQUEST['STATUS'];
//Status 9 is success for PAYPAL and 5 is authorized for CREDIT CARD
$pay_id=$_REQUEST['PAYID'];
//Like Transaction id
$pay_types=$_REQUEST['BRAND'];
$pay_ipaddress=$_REQUEST['IP'];
$paytype =$_REQUEST['PM'];
$amount=$_REQUEST['AMOUNT'];
$invoiceNumber = $_REQUEST['ORDERID'];

Just all the values are get from request like PAYID , ORDERID , STATUS values. Thats all. simply ogone payment is implemented.
Cheers!!!!

7 comments:

  1. I have this Error (sha1)
    unknown order/1/s/
    please help

    ReplyDelete
    Replies
    1. signature of sha1 not generated correctly.Kindly check your form all names are assigned in $Ogone_sha1 in alphabetic order.

      Thnx

      Delete
    2. unknown order/1/s/
      I got this error, and i have changed some code, but it not work now.
      Can you please explain for me?
      Thanks

      Delete
  2. it's ok thank you for this tuto :)

    ReplyDelete
  3. how to Ogone payment integration using curl in php

    ReplyDelete
  4. Hello ,
    I am new to Ogone Payment and i am using Ogon payment in my cakephp website,
    I am using the above code for the Ogone payment but i do not know that where to find "passphrase" and "pm" data from my Ogon test account ?

    ReplyDelete
  5. Here's another very nice article
    http://www.sula.be/ictbase/ogone.html

    ReplyDelete