Redsys Payment gateway intergration Request


Generate Request with Redsys



To setup Redsys payment gateway you must have DS MERCHANT MERCHANTCODE and MERCHANT TERMINAL . to make request you have to specify the transaction detail like amount , currency type and you also have specify
1 merchanturl: where redsys hit the response
2 merchant_urlok : page to redirect after successful transaction
3 merchant_urlko: page to redirect after error or unsuccessful transaction



Use this code. Change the basic detail with your redsys merchant detail

include 'redsys/ApiRedsys.php';
        $miObj = new RedsysAPI;
        $GlobalsRedsys=Globals::getredsys();

             $miObj->setParameter("DS_MERCHANT_AMOUNT",$europrice);
    $miObj->setParameter("DS_MERCHANT_ORDER",$order );
    $miObj->setParameter("DS_MERCHANT_MERCHANTCODE",$GlobalsRedsys['DS_MERCHANT_MERCHANTCODE']);
    $miObj->setParameter("DS_MERCHANT_CURRENCY", $GlobalsRedsys['DS_MERCHANT_CURRENCY']);
        $miObj->setParameter("DS_MERCHANT_CONSUMERLANGUAGE", $GlobalsRedsys['DS_MERCHANT_CONSUMERLANGUAGE']);
    $miObj->setParameter("DS_MERCHANT_TRANSACTIONTYPE", 1);
    $miObj->setParameter("DS_MERCHANT_TERMINAL",$GlobalsRedsys['DS_MERCHANT_TERMINAL']);
    $miObj->setParameter("DS_MERCHANT_MERCHANTURL",SITE_LIVE_URL . "cron/backfromredsys");
    $miObj->setParameter("DS_MERCHANT_URLOK",SITE_LIVE_URL . "index/thankyoupage");
    $miObj->setParameter("DS_MERCHANT_URLKO",SITE_LIVE_URL . "index/error");
//7793083094
        $miObj->setParameter("Ds_MERCHANT_MERCHANTDATA",$delivery_option);

        $request = "";
        $params = $miObj->createMerchantParameters();
    $signature = $miObj->createMerchantSignature($GlobalsRedsys['signature']);
        $account_details = array(
            'Ds_SignatureVersion'  => $GlobalsRedsys['version'],
            'Ds_MerchantParameters'    => $params,
            'Ds_Signature'   => $signature,
            'URL'  => $GlobalsRedsys['URL'],
        );
        $version = $account_details['Ds_SignatureVersion'];
        $params = $params;
        $signature = $signature;
        $redsysurl = $account_details['URL'];

Then Redsys will generate :
1 Signature version
2 Merchant Parameter
3 Signature
4 url
Your have to keep first three things in the hidden field and you have to send the user to that url.

Comments

Popular posts from this blog

Cubit/Bitcoin With curl function

Bitcoin Final Step