Tuesday, June 24, 2008

Paypal Reporting API - PHP code

Most of the websites use paypal processor for their online payments.Transaction details and various reports can be checked from Paypal Manager interface. The same reports can be generated using API calls(reporting xml api).We can generate reports using PHP as follows.

Library needed

1. Curl

Common Parameters for all API calls

All the API call require payal account information.So we can save these details in an array as follows.




Common Functions

The following functions are common for all API calls.












Steps to generate Custom Reports

1.The parameters needed for generating a custom report are 'start_date' and 'end_date'.So we can save the parameters in an array as follows.



2.Now we can run the report request as follows.



Here the second parametes is the name of the report.To generate another report we just need to change the report name and give the corresponding parameters in the parameter array.Remeber to give parameter names as keys of parameter array.

3.We will get reportId if the above Api call is successful.We can parse the response from above call and get reportId as follows.



4. Request for the results.



5.Now we can get all the fields in the report.



We can arrange the field names in an array using the function GenerateFieldArray().



6.Finally we can get data for our report.



Now we just need to display it in a report format.

Saturday, June 21, 2008

The accident...

Hi guys..

I would like to share some of those funny moments which we may come across in our day to day life.Have a good a laugh at the following one.

It was a really busy day at office.After having a wrestling with my client to make him understand some of the issues in the project ,which he never understood... i was really tired.As usual i took bus to home from bus station.The traffic on the roads seemed more hectic than usual.Once the bus got out of the city traffic, the driver was in a hurry to make up for the lost time.It was past 7 pm and there was hardly any light on the village roads.

The bus was taking a turn at some high speed,suddenly there was a huge noise from passengers on the bus.When the driver turned around,he saw the passengers and the conductor, who stood on the door step shouting at him to stop the bus.The driver soon had his thoughts on the person walking on the side of the road...may be he is being hit...By the time the bus stopped, the conductor jumped out and started running backwards.

The poor driver was really frightened of the consequences which drivers has to face on such occasions.Locals running in will usually handle the driver before contacting the police.Having seen the conductor running away, the driver jumped out and ran as if he is participating in a 100 m race.

By the time the conductor returned to the bus after taking the money bag which had fallen out of his hand while the bus was taking the turn,he saw the passengers having a laugh riot.I was having the laugh of my life and there was not even a single drop of stress left on my mind.One of the passengers told the conductor what happened... he too couldn't resist the comedy.Finally the conductor took his mobile and called the driver and told him what happened.The driver may have reached miles away or may be he was more afraid of the laughter people will have on him,it took some time before he returned.

I still remember the face of the driver....No words can explain the expression on his face....