1,105,416 Community Members

tripletex with php

Member Avatar
subrata_ushasi
Junior Poster
115 posts since Aug 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi all ,

After a long googling I am raising this issue. I want an online invoice from distribut to customer using tripletex but every one used using magento or drupal and I want it from website in php using tripletex.Is there any way to do it because I did it using paypal but difficult using tripletex.

Thanks in advance

Subrata

Member Avatar
pritaeas
mod_pritaeas
11,315 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,835 [?]
Skill Endorsements: 156 [?]
Moderator
Featured
Sponsor
 
0
 

What exactly are you trying to achieve?

Member Avatar
subrata_ushasi
Junior Poster
115 posts since Aug 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 0 [?]
 
0
 

From tripletex.no(online invoice generating website) and paypal invoice can be generated online for any product sale. I want to integrate in my website .When I order a product ,based on the order info it will go to tripletex and generate invoice to the customer or any one.

Member Avatar
pritaeas
mod_pritaeas
11,315 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,835 [?]
Skill Endorsements: 156 [?]
Moderator
Featured
Sponsor
 
0
 

I can't read Norsk well enough, but they have an API. There's also a Drupal plugin that integrates, so perhaps you can start there.

Member Avatar
subrata_ushasi
Junior Poster
115 posts since Aug 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi Pritaeas ,

I have the tripletex basic which has the link as pdf here http://tripletex.no/resources/api/tripletex-api.pdf.The and the other links are given below where codes are given.
http://json-rpc.org/
https://tripletex.no/JSON-RPC
http://json-rpc.org/wiki/implementations
just to integrate tripletex.no where .php page will send parameters to tripletex invoice system and tripletex will send/mail invoice to respective customer/buyer as pdf or csv or doc .

Thanks
Subrata

Member Avatar
subrata_ushasi
Junior Poster
115 posts since Aug 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi ,

Sorry the link will be as follows:
http://tripletex.no/resources/api/tripletex-api.pdf

Subrata

Member Avatar
pritaeas
mod_pritaeas
11,315 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,835 [?]
Skill Endorsements: 156 [?]
Moderator
Featured
Sponsor
 
0
 

Looks like you'll need to POST JSON. You can do that with cUrl.

Member Avatar
subrata_ushasi
Junior Poster
115 posts since Aug 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 0 [?]
 
0
 

pritaeas ,

Using cUrl it is done and running but returning null instead of giving proper output as per given link http://tripletex.no/resources/api/tripletex-api.pdf. here is the code :

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml"dir="ltr"lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
error_reporting(E_ALL ^ E_NOTICE);
//RESPONSE:
$header = "Server: Apache-Coyote/1.1;";
$header .= "X-Powered-By: Servlet 2.4;JBoss-4.0.2 (build: CVSTag=JBoss_4_0_2  date=200505022023)/Tomcat-5.5";
$header .="DSet-Cookie: JSESSIONID=09E2172BB69BA99F9CBA3A9C0F2A025; Path=/;";
$header .="Set-Cookie: JSESSIONID=F81885A42D1CC3876039EAB8C441C5B3; Path=/;";
$header .="Content-Type: text/plain;charset=utf-8";
$header .= "Content-Length: 29";
$header .= "Date: Wed, 21 Jul 2010 06:59:38 GMT";



    ## lets setup the target API url
   // $url = 'https://tripletex.no/JSON-RPC';
    ## define the cookie directory wher the cookie recieved will be stored
   // $cookie_bin = 'cookie/cookie.txt'; // as described in step 1
    ## lets initialize the curl.. if this method does not work you can use the commented option below.
    $ch = curl_init($url);
    ## we might not need this for now
    //curl_setopt($ch, CURLOPT_HEADER, 0);
    ## we define where to store and check for cookies
    curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie_bin);
    curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_bin);
    ## we try this first
    curl_setopt($ch, CURLOPT_POSTFIELDS, $methodData);
    ## if the above does not work, uncomment below
   // curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    ## we need to witheld the paypal data for now.
    //curl_setopt($ch, CURLOPT_POSTFIELDS, $methodData);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER,
    ## we notify the remote server of the content type and the lenght of the entire methodData string
    array('Content-Type: application/json','Content-Length: ' . strlen($methodData)) );
    ## finally, we will use either var_dump or print_r to view the respnse of the remote server..
   // var_dump(curl_exec($ch));
    //var_dump(json_decode(curl_exec($ch)));
    //print_r(json_decode(curl_exec($ch)));

    /*++++++++++++++++++++ Login check starts*/
        ## lets setup the target API url
    echo "login checking in tripletex";
    $methodData = array('method'=>'Sync.login','params'=>array(7,'pwd','jason@test.no','pwd'),'id'=>1);
    ## now we use json_encode function
    $methodData = json_encode($methodData);
    $url = 'https://tripletex.no/JSON-RPC';
    ## define the cookie directory wher the cookie recieved will be stored
    $cookie_bin = 'cookie/cookie.txt'; // as described in step 1
    ## lets initialize the curl.. if this method does not work you can use the commented option below.
    $ch = curl_init($url);
    ## we might not need this for now
    //curl_setopt($ch, CURLOPT_HEADER, 0);
    ## we define where to store and check for cookies
    curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie_bin);
    curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_bin);
    ## we try this first
    curl_setopt($ch, CURLOPT_POSTFIELDS, $methodData);
    ## if the above does not work, uncomment below
    //curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    ## we need to witheld the paypal data for now.
    //curl_setopt($ch, CURLOPT_POSTFIELDS, $methodData);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER,
    ## we notify the remote server of the content type and the lenght of the entire methodData string
    array('Content-Type: application/json',
    'Content-Length: ' . strlen($methodData)) );
    ## finally, we will use either var_dump or print_r to view the respnse of the remote server..
       var_dump(json_decode(curl_exec($ch)));
    /*+++++++++++++++++    Login check ends*/

    //$methodData = array('method'=>'Sync.login','params'=>array(7,'pwd','jason@test.no','pwd'),'id'=>1);

    //array_push($methodData,'inventory'=>'100','sold'=>'50','receipt'=>'45597798','t_id'=>'1235488');
        $ch = curl_init('https://tripletex.no/resources/examples/order_import_example.csv');
        $csv_data = array('method'=>'Project.importOrdersTripletexCSV','params'=>array('encoding','amountsIncVat','ignoreFirstRow'),'id'=>1);
        $csv_data = json_encode($csv_data);

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_HEADER, true);
        curl_setopt($ch, CURLOPT_VERBOSE, true);
        curl_setopt($ch, CURLOPT_URL, 'https://tripletex.no/JSON-RPC');

        curl_setopt($ch, CURLOPT_HTTPHEADER,array('Content-Type: application/json','Content-Length: ' . strlen($csv_data)) );


       /* $data = array
                    (
                    'ignore-robots' => 'false',
                    'language' => 'english',
                    'crawl-delay' => '0',
                    'depth' => '3',
                    'root' => array('url' => 'http://bartleby.com/')
                     );*/

        curl_setopt($ch, CURLOPT_POSTFIELDS, $csv_data);
        $result=curl_exec($ch);
        //var_dump($result);

?>


<?php 
 //SECOND METHOD

//CreateInvoice API
    $url = 'https://tripletex.no/JSON-RPC';
    $cookie_bin = 'cookie/cookie.txt'; 
    ## lets initialize the curl.. if this method does not work you can use the commented option below.
   // $ch = curl_init($url);
    ## we might not need this for now
    //curl_setopt($ch, CURLOPT_HEADER, 0);
    ## we define where to store and check for cookies
    curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie_bin);
    curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_bin);
    $methodData = array('method'=>'Sync.login','params'=>array(7,'pwd','jason@test.no','pwd'),'id'=>1);
    ## now we use json_encode function
    $methodData = json_encode($methodData);
//$csv_data = array('method'=>'Project.importOrdersTripletexCSV','params'=>array('encoding','amountsIncVat','ignoreFirstRow'),'id'=>1);
//$csv_data = json_encode($csv_data);
$response = PPHttpPost($url,$methodData,$header);
echo "<br /><br />Response: <br />";
//print_r($response);
//parse the response
$response_ar = explode("&", $response);
$p_response = parseAPIResponse($response_ar);
echo "<br /><br /><br />";

//for now
//print_r($p_response);

function parseAPIResponse($response){
     $parsed_response = array();
     foreach ($response as $i => $value) {
          $tmpAr = explode("=", $value);
               if(sizeof($tmpAr) > 1) {
                    $parsed_response[$tmpAr[0]] = $tmpAr[1];
               }
     }
     return $parsed_response;
 }

/*function requestPayKey(){
//request token string:
$reqstr = "requestEnvelope.errorLanguage=en_US&invoice.merchantEmail=caples69%40hotmail.com&invoice.payerEmail=caples23%40hotmail.com&invoice.currencyCode=USD&invoice.items(0).name=Banana+Leaf+--+001&invoice.items(0).description=Banana+Leaf&invoice.items(0).quantity=1&invoice.items(0).unitPrice=1&invoice.items(0).taxName=Tax1&invoice.items(0).taxRate=10.25&invoice.paymentTerms=Net15";
return $reqstr;
}*/

function PPHttpPost($my_endpoint, $headers,$csvdatum){
 // setting the curl parameters.
 $ch = curl_init();
 curl_setopt($ch, CURLOPT_URL, $my_endpoint);
 curl_setopt($ch, CURLOPT_VERBOSE, 1);
 curl_setopt($ch, CURLOPT_HTTPHEADER,array('Content-Type: application/json','Content-Length: ' . strlen($methodData)) );
 //curl_setopt($ch, CURLOPT_HEADER, 1); // tells curl to include headers in response, use for testing
 // turning off the server and peer verification(TrustManager Concept).
 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 curl_setopt($ch, CURLOPT_POST, true);
 // setting the NVP $my_api_str as POST FIELD to curl
 curl_setopt($ch, CURLOPT_POSTFIELDS,$csvdatum);
 // getting response from server
 $httpResponse = curl_exec($ch);
 if(!$httpResponse)
   {
   $response = "$API_method failed: ".curl_error($ch)."(".curl_errno($ch).")";
   return $response;
   }

 return $httpResponse;
}
?>

</body>
</html>

I checked it out with this link http://jsonlint.com/ whether returning json or not.

Member Avatar
subrata_ushasi
Junior Poster
115 posts since Aug 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 0 [?]
 
1
 

pritaeas,

done and running on the web .

Thanks

Member Avatar
aswathivalsaraj
Newbie Poster
3 posts since Jul 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi,

Can any one please tell me how to test triplex in php website.

I got error, like this,

login checking in tripletexobject(stdClass)#1
Invalid syncSystemId (7) or password (pwd).

Member Avatar
pritaeas
mod_pritaeas
11,315 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,835 [?]
Skill Endorsements: 156 [?]
Moderator
Featured
Sponsor
 
0
 

Looks like your credentials are wrong.

Member Avatar
aswathivalsaraj
Newbie Poster
3 posts since Jul 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 
$methodData = array('method'=>'Sync.login','params'=>array(7,'pwd','jason@test.no','pwd'),'id'=>1);

this is the method i have used, can any one please help what all are the parameters ?

Member Avatar
pritaeas
mod_pritaeas
11,315 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,835 [?]
Skill Endorsements: 156 [?]
Moderator
Featured
Sponsor
 
0
 

Now I see... You cannot expect to take someone else's credentials and expect it to work. Get your own account.

Member Avatar
aswathivalsaraj
Newbie Poster
3 posts since Jul 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

@ pritaeas :

i have created a test/trial account in tripletex . so i have only username & password. what all are the other parameters required to test tripletex . can u please help.

Member Avatar
subrata_ushasi
Junior Poster
115 posts since Aug 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 0 [?]
 
0
 

Aswathi Valsaraj,

I didn't open this forum for quite a few days. Anyway, after creating your account in Tripletex ,you need to ask the same to give password against user "7" which is currently "pwd". Then you will be able to execute the php code and rest of the methods. I solved all the methods from tripletex API given in pdf format. Hope this will solve your issues.

Thanks ,

Subrata Nandi

Member Avatar
shadia_1
Newbie Poster
7 posts since Oct 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
-1
 

thanks for the tips

jani5
Newbie Poster
3 posts since Oct 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
Unverified Member
 
-1
 

please what is add asyncrhonous update
thanks
العاب تنظيف الحيوانات

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: