Call Us : +1-678-551-2452
+91 77381-86899

Integrate Citrus Bank Payment Gateway in WooCommerce

Download Plugin For CitrusPay in WooCommerce

You can include Citrus Bank  Payment Gateway in a WooCommerce Application provided you have purchased Citrus Bank Payment Gateway and have the PHP Integration Kit which consists of a lib Folder and test folder.

Below Are the steps to integrate CitrusPay Payment Gateway  in WooCommerce (Popular E-Commerce Plugin for Wordpress).

  1. Login to Citrus Payment account using user id and password and navigate to Checkout Page Settings page as shown below
  2. Open up the Security Credentials section. This section will display the system generated unique access key and Secret key. Keep the secret key secret as the merchant will have to use this key to encrypt the data while sending any request to Citrus Payment Gateway.
     
  3. The PHP Driver  bundle consists of  two folders :-
    lib Directory: This directory contains all the files required to integrate with CitrusPay Payment Solutions.
    test Directory: This directory contains sample html files which will illustrate how you can integrate with the CitrusPay Payment Solutions Pvt. Ltd.
  4. Download WooCommerce Custom Payment Gateway Plugin from the link below:
    https://wordpress.org/plugins/woocommerce-custom-payment-gateways/ 
  5. Activate the plugin and do the settings for Title, Description and Instructions from,
    Dashboard–>WooCommerce–>Settings–>Checkout–>Custom Payment Gateways 2  (See below Screenshot)
  6. Edit file: Website/wp-content/plugins/woocommerce-custom-payment-gateways/class-wc-custom_payment_gateway_2.php 

    Find the method process_payment and add the below code within it. (See the Code And Screenshot)
    function process_payment ($order_id) {global $woocommerce;
    $order = new WC_Order( $order_id );set_include_path(‘../lib’.PATH_SEPARATOR.get_include_path());
    require_once(‘../lib/CitrusPay.php’);
    require_once ‘Zend/Crypt/Hmac.php';

    $action=”class-wc-custom_payment_gateway_2.php”;
    CitrusPay::setApiKey(“MerchantAccessKey“,’sandbox’);

    $vanityUrl = “Vanity“;
    $orderAmount = $order->get_total();
    $merchantTxnId = $order_id;
    $currency = “INR“;
    $data = “$vanityUrl$orderAmount$merchantTxnId$currency”;
    //$secSignature = generateHmacKey($data,CitrusPay::getApiKey());
    $secSignature = Zend_Crypt_Hmac::compute(CitrusPay::getApiKey(), “sha1″, $data);
    $addressState = $order->shipping_state;
    $addressCity = $order->shipping_city;
    $addressStreet1 = $order->shipping_address_1;
    $addressCountry = “”;
    $addressZip = $order->shipping_postcode;
    $firstName = $order->billing_first_name;
    $lastName = $order->billing_last_name;
    $phoneNumber = $order->billing_phone;
    $email = $order->billing_email;
    $paymentMode = “”;
    $issuerCode = “”;
    $cardHolderName = “”;
    $cardNumber = “”;
    $expiryMonth = “”;
    $cardType = “”;
    $cvvNumber = “”;
    $expiryYear = “”;
    $returnUrl = “http://WebsiteURL/test/Response.php”;
    $flag = “post”;
    $action = CitrusPay::getCPBase().”$vanityUrl”;
    $time = time()*1000;
    $time = number_format($time,0,’.’,”);
    $order->update_status(‘processing’, __( ‘Your order wont be shipped until the funds have cleared in our account.’, ‘woocommerce’ ));
    $order->reduce_order_stock();

    // Remove cart
    $woocommerce->cart->empty_cart();

    ?>

    <html><head>
    <script language=”javascript” type=”text/javascript”>

    window.self.location=’http://WebsiteURL/test/testSSL.php?merchantTxnId=<?php echo $merchantTxnId ?>&orderAmount=<?php echo $orderAmount ?>&secSignature=<?php echo $secSignature ?>&returnUrl=<?php echo $returnUrl ?>&currency=<?php echo $currency ?>&addressState=<?php echo $addressState ?>&addressCity=<?php echo $addressCity ?>&addressStreet1=<?php echo $addressStreet1 ?>&addressZip=<?php echo $addressZip ?>&firstName=<?php echo $firstName ?>&lastName=<?php echo $lastName ?>&phoneNumber=<?php echo $phoneNumber ?>&email=<?php echo $email ?>';

    </script>
    </head></html>
    <?php exit; ?>

    }

  7. Edit file: Website/wp-content/plugins/woocommerce-custom-payment-gateways/test/testSSL.php 

    Add Access key on line number 15: CitrusPay::setApiKey(“ACCESSKEY“,’sandbox’); and edit the file (by adding the else statement) to handle Get Requests. The default file which is provided in Integration kit handles only Post requests.if(isset($_POST[‘submit’]))
    {
    echo”comes in if parameter set”;
    $vanityUrl = “uns”;
    //
    $orderAmount = $_POST[‘orderAmount’];
    $merchantTxnId = $_POST[‘merchantTxnId’];
    $currency = “INR”;
    $data = “$vanityUrl$orderAmount$merchantTxnId$currency”;
    $secSignature = generateHmacKey($data,CitrusPay::getApiKey());$addressState = $_POST[‘addressState’];
    $addressCity = $_POST[‘addressCity’];
    $addressStreet1 = $_POST[‘addressStreet1′];
    $addressCountry = $_POST[‘addressCountry’];
    $addressZip = $_POST[‘addressZip’];
    $firstName = $_POST[‘firstName’];
    $lastName = $_POST[‘lastName’];
    $phoneNumber = $_POST[‘phoneNumber’];
    $email = $_POST[’email’];
    $paymentMode = $_POST[‘paymentMode’];
    $issuerCode = $_POST[‘issuerCode’];
    $cardHolderName = $_POST[‘cardHolderName’];
    $cardNumber = $_POST[‘cardNumber’];
    $expiryMonth = $_POST[‘expiryMonth’];
    $cardType = $_POST[‘cardType’];
    $cvvNumber = $_POST[‘cvvNumber’];
    $expiryYear = $_POST[‘expiryYear’];
    $returnUrl = “http://WebSiteURL/test/Response.php”;
    $flag = “post”;
    $action = CitrusPay::getCPBase().”$vanityUrl”;
    $time = time()*1000;
    $time = number_format($time,0,’.’,”);
    /* $iscod = $_POST[‘COD’]; */

    /*$customParamsName = $_POST[‘customParamsName’];*/
    /*$customParamsValue = $_POST[‘customParamsValue’];*/
    }else
    {
    echo”comes in else parameter set”;
    $vanityUrl = “Vanity”;
    //
    $orderAmount = $_GET[‘orderAmount’];
    $merchantTxnId = $_GET[‘merchantTxnId’];
    $currency = “INR”;
    $data = “$vanityUrl$orderAmount$merchantTxnId$currency”;
    $secSignature = generateHmacKey($data,CitrusPay::getApiKey());

    $addressState = $_GET[‘addressState’];
    $addressCity = $_GET[‘addressCity’];
    $addressStreet1 = $_GET[‘addressStreet1′];
    $addressCountry = $_GET[‘addressCountry’];
    $addressZip = $_GET[‘addressZip’];
    $firstName = $_GET[‘firstName’];
    $lastName = $_GET[‘lastName’];
    $phoneNumber = $_GET[‘phoneNumber’];
    $email = $_GET[’email’];
    $paymentMode = $_GET[‘paymentMode’];
    $issuerCode = $_GET[‘issuerCode’];
    $cardHolderName = $_GET[‘cardHolderName’];
    $cardNumber = $_GET[‘cardNumber’];
    $expiryMonth = $_GET[‘expiryMonth’];
    $cardType = $_GET[‘cardType’];
    $cvvNumber = $_GET[‘cvvNumber’];
    $expiryYear = $_GET[‘expiryYear’];
    $returnUrl = “http://WebsiteURL/test/Response.php”;
    $flag = “post”;
    $action = CitrusPay::getCPBase().”$vanityUrl”;
    $time = time()*1000;
    $time = number_format($time,0,’.’,”);
    }
    ?>


  8. Now on the website, you will see the Citrus Bank Payment Gateway Option in Checkout page as in the below screenshot:

 

Download Plugin For CitrusPay in WooCommerce

Leave a Reply

Pay with PayPal

Icon Web Solutions Service
Other Amount:
Name:

Testimonials

It has been a great pleasure working with Icon Web Solutions on the development of my digitized logo and website. From the initial phases of web design, the Icon Web Solutions team has been a pleasure to work with
Naren, USA

REQUEST A QUOTE

Request A Quote

Please fill the form to request a quote from us

Name (required)

Email (required)

Phone

Services
 Website Design & Development Logo Design SEO SMO Payment Gateway Integration Others

Any Other Detail

Input Text Shown in Image
captcha