Friday, May 9, 2014

1) pay.php page create

include(“config/class/class.se_paypal.php”);
$payment = new se_paypal();
$payment->splitPay($trendcy,$total,$emailid); function

2) class.se_paypal.php page create

<?php
class se_paypal{
var $api_user = “addon.dipak_api1.addonsoultions.com”;
var $api_pass = “1393674471″;
var $api_sig = “AFcWxV21C7fd0v3bYYYRCpSSRl31A4R9DtVt5l5HIzffuVxFFfGYufLR”;
var $app_id = “APP-80W284485P519543T”;
var $apiUrl = “https://svcs.sandbox.paypal.com/AdaptivePayments/”;
var $paypalUrl=”https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_ap-payment&paykey=”;

var $job_cats; var $DB; var $fbid;

function se_paypal() {
$this->job_cats = “”;
$this->fbid = “”;
$this->DB = new MySqlDB();
}

function __construct(){
$this->headers = array(
“X-PAYPAL-SECURITY-USERID: “.$this->api_user,
“X-PAYPAL-SECURITY-PASSWORD: “.$this->api_pass,
“X-PAYPAL-SECURITY-SIGNATURE: “.$this->api_sig,
“X-PAYPAL-REQUEST-DATA-FORMAT: JSON”,
“X-PAYPAL-RESPONSE-DATA-FORMAT: JSON”,
“X-PAYPAL-APPLICATION-ID: “.$this->app_id,
);

echo ‘<pre>’;
print_r($this->headers);
$this->envelope = array(
“errorLanguage” => “en_US”,
“detailLevel” => “ReturnAll”
);
}

function getPaymentOptions($paykey){
$packet = array(
“requestEnvelope” => $this->envelope,
“payKey” => $paykey
);
return $this->_paypalSend($packet,”GetPaymentOptions”);
}

function setPaymentOptions(){}

function createPayRequest(){}

function _paypalSend($data,$call){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->apiUrl.$call);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers);

$response = json_decode(curl_exec($ch),true);
return $response;
}

function splitPay($trendcy,$total,$emailid){
$remain = number_format(($total – $trendcy),2);
$createPacket = array(
“actionType” =>”PAY”,
“currencyCode” => “USD”,
“feesPayer”=>”PRIMARYRECEIVER”,
“receiverList” => array(
“receiver” => array(
array(
“amount”=> “$total”,
“email”=>”addon.dipak@addonsoultions.com”,
//”email”=>”$emailid”,
“primary”=>”true”
),
array(
“amount”=> “$trendcy”,
“email”=>”addon.pinaking@addonsolutions.com”,
“primary”=>”false”
),
),
),
“returnUrl” => “http://staging.trendcy.com/ajax_handler.php?mode=paid_finally”,
“cancelUrl” => “http://staging.trendcy.com/pay_error.php”,
“requestEnvelope” => $this->envelope
);

$response = $this->_paypalSend($createPacket,”Pay”);

echo ‘<pre>’;
print_r($response);
print_r($createPacket);

echo $paykey = $response['payKey'];
//exit;
$dets = $this->getPaymentOptions($paykey);
header(“Location: “.$this->paypalUrl.$paykey);
}
}

References Link
1) https://www.youtube.com/watch?v=rzRR1i-F_VA
2) https://www.youtube.com/watch?v=TPFFIuydHn4
create a new test account in authorize.net. Automatically Generate API Login ID and Transaction key of create new account.

In this API Login ID and Transaction key used in files than directly access athorize.net account.
The Authorize.Net PHP SDK gives you access to the full suite of APIs.
Download SDK of authorize.net.

You’ll need to include the file “anet_php_sdk/AuthorizeNet.php” in your project so make sure you save the SDK into a folder that your web server can access such as your var/www folder or your htdocs folder.
Mainly three method used in authorize.net.

1)Direct Post Method
<?php
          require_once ‘anet_php_sdk/AuthorizeNet.php’; // The SDK
          $url = “http://YOUR_DOMAIN.com/direct_post.php”;
          $api_login_id = ‘YOUR_API_LOGIN_ID’;
          $transaction_key = ‘YOUR_TRANSACTION_KEY’;
         $md5_setting = ‘YOUR_API_LOGIN_ID’; // Your MD5 Setting
         $amount = “5.99″;
        AuthorizeNetDPM::directPostDemo($url, $api_login_id, $transaction_key, $amount, $md5_setting);
?>

2)Server Integration Method
<?php
         require_once ‘anet_php_sdk/AuthorizeNet.php’; // Include the SDK you downloaded in Step 2
         $api_login_id = ‘YOUR_API_LOGIN_ID’;
         $transaction_key = ‘YOUR_TRANSACTION_KEY’;
         $amount = “5.99″;
         $fp_timestamp = time();
         $fp_sequence = “123″ . time(); // Enter an invoice or other unique number.
         $fingerprint = AuthorizeNetSIM_Form::getFingerprint($api_login_id,
         $transaction_key, $amount, $fp_sequence, $fp_timestamp)
?>

<form method=’post’ action=”https://test.authorize.net/gateway/transact.dll”>
<input type=’hidden’ name=”x_login” value=”<?php echo $api_login_id?>” />
<input type=’hidden’ name=”x_fp_hash” value=”<?php echo $fingerprint?>” />
<input type=’hidden’ name=”x_amount” value=”<?php echo $amount?>” />
<input type=’hidden’ name=”x_fp_timestamp” value=”<?php echo $fp_timestamp?>” />
<input type=’hidden’ name=”x_fp_sequence” value=”<?php echo $fp_sequence?>” />
<input type=’hidden’ name=”x_version” value=”3.1″>
<input type=’hidden’ name=”x_show_form” value=”payment_form”>
<input type=’hidden’ name=”x_test_request” value=”false” />
<input type=’hidden’ name=”x_method” value=”cc”>
<input type=’submit’ value=”Click here for the secure payment form”>
</form>

3)Advanced Integration Method
 <?php
           require_once ‘anet_php_sdk/AuthorizeNet.php’; // Make sure this path is correct.
           $transaction = new AuthorizeNetAIM(‘YOUR_API_LOGIN_ID’, ‘YOUR_TRANSACTION_KEY’);
           $transaction->amount = ’9.99′;
           $transaction->card_num = ’4007000000027′;
           $transaction->exp_date = ’10/16′;
          $response = $transaction->authorizeAndCapture();

          if ($response->approved){
      echo “<h1>Success! The test credit card has been charged!</h1>”;
      echo “Transaction ID: ” . $response->transaction_id;
         }
        else{
      echo $response->error_message;
       }
?>
How to create the custom flash messages in the cakephp

1) First of all go to the -> app/View/Elements and create the ctp file for the flsah messages.like flash_error.ctp, flash_info.ctp, flash_success.ctp, flash_warning.ctp.

2) And add content in the ctp file like

<div>
<button type=”button” data-dismiss=”alert”>&times;</button>
<strong>Well done! </strong><?php echo h($message); ?>
</div>

3) And call the particular meassage like info,error,warning then call the “ $this->Session->setFlash(‘Your Profile Update Successfully’,'flash_success’); ” in cakephp controller.
What is Lazy Loading?

Lazy loading is a design pattern commonly used in programming to defer initialization of an object until the point at which it is needed. It can contribute to efficiency in the program’s operation if properly and appropriately used. The opposite of lazy loading is eager loading
Lazy Loading is use for Images, contents, blocks etc., It means when page or blocks gets scroll then and then only content or images will be displayed. its a jQuery Plugin.

How to Integrate with our application?

There are three simple steps and get done. For now I am going to explain lazy loading with images,
Add lazy load javascript and css(jquery.lazyload.js and lazyload.css) on head tag, JS and CSS are available on market so, get it from it and add to head tag

The basic usage of Lazy is very easy. First of all you need to add a ‘data-src’ attribute to those images you want to load when image block will get displayed and insert the image path you want to load over Lazy: like below,
<img class=”lazyload” data-original=”actual source of image” src=”blank or loading image”/>

Add simple line of code to call lazy load class at footer, like below,

<script type=”text/javascript”>jQuery(“img.lazyload”).lazyload();</script>
 With This script site performance can be increase because now a days people are adding big image on websites so developer needs to resize to display on web, and also page will take time to load images also, so this is one good way to optimize site performance.

Hope you like this post and it will be useful for all of you.
By default, Magento use 8 digits for Orders, Invoices, Creditmemo and Shipments’ increment ID.
However, sometime you would like to change the length to meet 3rd party’s system requirement.

This can be easily accomplished by:

* modify the field “increment_pad_length” in the “eav_entity_type” table for whatever entity you’re wanting to modify.
* modify the field “increment_last_id” in “eav_entity_store” table with the same “entity_type_id” in table “eav_entity_type” which the document type’s increment ID you would like to change. Remember to change all existing records for this “entity_type_id”.