For smart Primates & ROBOTS (oh and ALIENS ).

Blogroll

Saturday, October 18, 2014

Orbital chase paymentech gateway Mark for Capture

Orbital Chase Paymentech Gateway Mark for Capture

Chase Orbital is one of the complex Payment Gateway. It's authorization process is very complex.
Here is the code for Orbital Chase Paymentech Gateway Mark for Capture Request in PHP.
You can frequently use it as free.

If you want to implement Orbital chase paymentech by me then Please contact me and I will let you know my charges.

<?php
$url = "https://orbitalvar2.paymentech.net"; // testing
//$url = "https://orbital1.paymentech.net"; // production
$post_string="
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
    <Request>
        <MarkForCapture>
            <OrbitalConnectionUsername>YOUR-USERNAME-HERE</OrbitalConnectionUsername>
            <OrbitalConnectionPassword>YOUR-PASSWORD-HERE</OrbitalConnectionPassword>
            <OrderID>123456789</OrderID>
            <Amount>8500</Amount>
            <BIN>000002</BIN>
            <MerchantID>YOUR-MERCHANT-ID-HERE</MerchantID>
            <TerminalID>001</TerminalID>
            <TxRefNum>4F320B79F23280DAE62777C80721F838FF13548D</TxRefNum>
        </MarkForCapture>
    </Request>";
    $header= "POST /authorize/ HTTP/1.0\r\n";
    $header.= "MIME-Version: 1.0\r\n";
    $header.= "Content-type: application/PTI\r\n";
    $header.= "Content-length: "  .strlen($post_string) . "\r\n";
    $header.= "Content-transfer-encoding: text\r\n";
    $header.= "Request-number: 1\r\n";
    $header.= "Document-type: Request\r\n";
    $header.= "Interface-Version: Test 1.4\r\n";
    $header.= "Connection: close \r\n\r\n";
    $header.= $post_string;
 
   //// just initialize curl here and post the data to the orbital server.


 
?>
Share:

Friday, October 17, 2014

Download image without cURL and with cURL in PHP

 Download image without cURL and with cURL in PHP




<?php
// without cURL
$downloadImageUrl="http://fc04.deviantart.net/fs26/f/2008/072/b/1/Frozen_Galaxy_by_Vpr87.jpg";
////// Using without CURL
$img = file_get_contents($downloadImageUrl);
$file1 = dirname(__file__).'/aaa.jpg';
file_put_contents($file1, $img);



////// // with cURL
$fileName=$downloadImageUrl;
$header = array(
            "Accept-Encoding: gzip,deflate",
            "Accept-Charset: utf-8;q=0.7,*;q=0.7",
            "Connection: close"
        );
$useragent = 'Amit Kumar Gaur amitt800@gmail.com  http://amitkgaur.blogspot.com';
$file2 = dirname(__file__).'/bbb.jpg';
$curlObj=curl_init();
curl_setopt($curlObj, CURLOPT_HTTPHEADER, $header);
curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curlObj, CURLOPT_HEADER, false);
curl_setopt($curlObj, CURLOPT_USERAGENT, $useragent);
curl_setopt($curlObj, CURLOPT_CONNECTTIMEOUT, 999);
curl_setopt($curlObj, CURLOPT_TIMEOUT, 9999);
curl_setopt($curlObj, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($curlObj, CURLOPT_URL, $downloadImageUrl);
$response = curl_exec($curlObj);
$return = false;
if(!curl_errno($curlObj)) {
    file_put_contents($file2, $response);
}
?>
Share:

Extract Corrupt Zip File By Java

Extract Corrupt Zip File By Java


I received an zip file from customer. I have tried to extract with WinZip, but unable to extract zip file because that zip file was corrupt.

So I have tried to extract with Java Zip API and got the success. The code is listed below:

I am sure that the zip file having 5% to 10% part corrupt will be unzip with this code, but if it is having more corrupt then the code will not work.


import java.io.*;
import java.util.zip.*;

class ExtractCorruptZip {
public void extractZipFiles(String fileName) {
try {
String zipDir = "c:\\zip\\";
//String zipDir = "/home/usr/amit/zip/";
byte[] by = new byte[2048];
ZipInputStream ziStream = null;
ZipEntry zipEntry;
ziStream = new ZipInputStream(new FileInputStream(fileName));

zipEntry = ziStream.getNextEntry();
int count=1;
while (zipEntry != null) {
String entry = zipDir + zipEntry.getName();
entry = entry.replace('/', File.separatorChar).replace('\\', File.separatorChar);
int n;
FileOutputStream fOTStream;
File newFile = new File(entry);
if (zipEntry.isDirectory()) {
if (!newFile.mkdirs()) {
break;
}
zipEntry = ziStream.getNextEntry();
continue;
}
fOTStream = new FileOutputStream(entry);
while ((n = ziStream.read(by, 0, 2048)) > -1) {
fOTStream.write(by, 0, n);
}
System.out.println("Working....."+(++count));
fOTStream.close();
ziStream.closeEntry();
zipEntry = ziStream.getNextEntry();
}
ziStream.close();
System.out.println("DONE!!!!!");
} catch(IOException ioe) {
ioe.printStackTrace();
}
}

public static void main(String[] ss) {
try {
String fileName = "w1.zip";
ExtractCorruptZip extractCorruptZip = new ExtractCorruptZip();
extractCorruptZip.extractZipFiles(fileName);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}




Share:

Google chart api 3d

Google chart api 3d


Here is the simple example of Google 3d chart. just use listed below code.
I have everything explained in commented.



Google chart api 3d
















<html>
<head>
<script type='text/javascript' src='http://www.google.com/jsapi'></script>
<script type="text/javascript">
    // Load Google Visualization API with piechart package.
    google.load('visualization', '1', {'packages':['piechart', 'imagepiechart', 'barchart','imageBarChart','linechart']});
    // load API.
    google.setOnLoadCallback(initChart);
    // Populates datas and draw it.
    function initChart() {
        var dTable = new google.visualization.DataTable();
        // Add two columns
        dTable.addColumn('string', 'Names');
        dTable.addColumn('number', 'Percentage');
     
        //Add fie rows
        dTable.addRows(5);
     
        //set the 5 values
        dTable.setValue(0, 0, 'Java');
        dTable.setValue(0, 1, 50);
     
        dTable.setValue(1, 0, 'ASP.Net');
        dTable.setValue(1, 1, 30);
     
        dTable.setValue(2, 0, 'PHP');
        dTable.setValue(2, 1,10);
     
        dTable.setValue(3, 0, 'ASP');
        dTable.setValue(3, 1, 7);
     
        dTable.setValue(4, 0, 'Java Applet');
        dTable.setValue(4, 1, 3);
        //draw it
        var pChart = new google.visualization.PieChart(document.getElementById('programmingLanguages3DChart'));
        pChart.draw(dTable, {width: 400, height: 240, is3D: true, title: 'Programming Languages 3D Chart'});
    }
</script>
</head>
<body>
    <div id='programmingLanguages3DChart' ></div>
</body>
</html>


Share:

Multiple step OLE DB operation generated errors Check each OLE DB status value if available No work was done


Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done


If you are working with MS Access database then you encounter with the "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done" error.
There are many reasons that produce the above error.
But the common error is Ms Access database password is mismatching. the 2007 Ms Access database password length is 20 characters and if you mistakenly set 21 characters as a password then last 21th character will automatically suppressed by Ms Access Database. for example you have types password as:
abcdefghijklmnopqrstu

then last "u" will automatically deleted and Ms Access will not inform you about it and set the password as:
abcdefghijklmnopqrst

You will not aware this Ms Access activity and while working with C# or VB.Net you will used the password as:
abcdefghijklmnopqrstu
then you can face the "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done" error.

So just check the password and you will not face this types of error.



Share:

Friday, October 03, 2014

TIFF Reader in java

TIFF File Reader

If you have a multiple pages TIFF file and want to see it in java then listed below code will help you.




import java.io.File;
import java.io.IOException;
import java.awt.Frame;
import java.awt.image.RenderedImage;
import javax.media.jai.widget.ScrollingImagePanel;
import javax.media.jai.NullOpImage;
import javax.media.jai.OpImage;
import com.sun.media.jai.codec.SeekableStream;
import com.sun.media.jai.codec.FileSeekableStream;
import com.sun.media.jai.codec.TIFFDecodeParam;
import com.sun.media.jai.codec.ImageDecoder;
import com.sun.media.jai.codec.ImageCodec;

public class ReadTiff extends Frame {
    ScrollingImagePanel panel;
    public ReadTiff(String filename) throws IOException {
        setTitle("ReadTiff");
        File file = new File(filename);
        SeekableStream s = new FileSeekableStream(file);
        TIFFDecodeParam param = null;
        ImageDecoder dec = ImageCodec.createImageDecoder("tiff", s, param);
        System.out.println("Number of images in this TIFF: " +
                           dec.getNumPages());
        // 0 means the first, 1 for second and so on.
        int imageToLoad = 0;
        RenderedImage op =
            new NullOpImage(dec.decodeAsRenderedImage(imageToLoad),
                            null,
                            OpImage.OP_IO_BOUND,
                            null);
        panel = new ScrollingImagePanel(op, 800, 800);
        add(panel);
    }

    public static void main(String [] args) {
        String filename = "C:\\java\\tiff\\car1.tif";
        try {
            ReadTiff window = new ReadTiff(filename);
            window.pack();
            window.show();
        } catch (java.io.IOException ioe) {
            System.out.println(ioe);
        }
    }
}





Share:

Multiple attribute passing in querySelectorAll

Multiple attribute passing in querySelectorAll     Here I am demonstrating code to how to pass multiple attributes in querySelectorAll. <...

Ads Inside Post

Powered by Blogger.

Arsip