27.12.11

Caixa Catalunya payment gateway integration php







                    Integrate Catalunya  Caixa Payment Gateway

  • Get a test details for setring up the Payment gateway
  • Get the caixacatalunya Passphrasein (Unique string that is used to create the sha1 code)
  • Get the caixacatalunya Merchantid (The merchant Id is the Account id)
  • After the buy we need to validate the user details 
  • Before for sending the details to payment gateway we need to save the details so that we can verify the details after the payment
  • After entering all the details we need to redirect to another page it contain a form and the  variables which are in hidden and we need to auto submit after loading the page
In the Redirect page model way of implementing the payment gateway

                      Creating the signature
<?php

        $order = rand(1000,9999).sha1(date('ymdhis'));
        $unique_id = substr($order, 0, 12);
        $amount = 10.00;// orginal price of product
        $CaixaCatalunya = $amount * 100;
        $MERCHANTID = $caixacatalunyaMerchantid; //'1234567';
        $shacode = $passPhrasein; //046hgj5h55h7j0a8f6a
        $currency = '978';
        $transactionType = '0';
        $terminal = '1';
        $urlMerchant = 'siteurl/success'; //success url

        $sigFormat =     $CaixaCatalunya.$unique_id.$MERCHANTID.
         $currency.$transactionType.$urlMerchant.$shacode;

        $signature = sha1($sigFormat);

        $actionUrl = "https://sis-t.sermepa.es:25443/sis/realizarPago"; //For test Payments

        $actionUrl = "https://sis.sermepa.es/sis/realizarPago"; //For Production

         $languageArray = array('es_LA'=>'1', 'en_US'=>'2', 'fr_FR'=>'7', 'nl_NL'=>'6',    'sv_SE'=>'8');  //language Codes                               


?>
intermediate Page


<form method="post" name="caixacatalunya" action="https://sis-t.sermepa.es:25443/sis/realizarPago" id=caixacatalunya >
    <input type="hidden" name="Ds_Merchant_MerchantCode" value="1234567"/>
    <input type="hidden" name="Ds_Merchant_Terminal" value="1"/>
    <input type="hidden" name="DS_Merchant_Currency" value="<?php echo $currency;?>"/>
    <input type="hidden" name="Ds_Merchant_Amount" value="<?php echo $CaixaCatalunya;?>"/>
    <input type="hidden" name="Ds_Merchant_Order" value="<?php echo $unique_id;?>"/>
    <input type="hidden" name="Ds_Merchant_ProductDescription" value="Product Details"/>
    <input type="hidden" name="Ds_Merchant_Titular" value="Name of user"/>
    <input type="hidden" name="Ds_Merchant_MerchantURL" value="<?php echo $urlMerchant;?>"/>
    <input type="hidden" name="Ds_Merchant_UrlOK" value="<?php echo $urlMerchant;?>"/>
    <input type="hidden" name="Ds_Merchant_UrlKO" value="BASEURL/error"/>
    <input type="hidden" name="Ds_Merchant_MerchantName" value="Name of the Merchant"/>
    <input type="hidden" name="Ds_Merchant_ConsumerLanguage" value="<?php echo $languageArray['en_US'];?>"/>
    <input type="hidden" name="Ds_Merchant_MerchantData" value="Description of the site"/>
    <input type="hidden" name="Ds_Merchant_TransactionType" value="<?php echo $transactionType;?>"/>
    <input type="hidden" name="Ds_Merchant_MerchantSignature" value="<?php echo $signature;?>"/>
    <input type="submit" name="submit" value="Submit"/>
 </form>


After the Success full payment the payment gateway will redirect to successurl



  • The return Url will pass all the details
  • Get the datas in the return url
  • $resp_data //contains all the variables Passed via Url

            Validation of Success full Payment

    $shacode = $caixacatalunyaPassphrasein; //ghfghfghf123456789


        $CaixaCatalunya = $resp_data['Ds_Amount'].$resp_data['Ds_Order']. $resp_data['Ds_MerchantCode'].$resp_data['Ds_Currency'].
$resp_data['Ds_Response'].$shacode;

        $CaixaCatalunya = strtoupper(sha1($CaixaCatalunya));

    if($resp_data['Ds_Signature'] == $CaixaCatalunya && ($resp_data['Ds_Response'] == '0000' || $resp_data['Ds_Response'] == '0001')) {
    //Success
    }else{//Failed
    }













No comments:

Post a Comment