Thursday, March 11, 2010

Paypal Integration Demystified

Asynchronous paypal integration can be a handful for programmers especially with so many different ways of doing the same thing and few proper fullscale implementations in .NET.
I really wished that Paypal could have just created an API/Dll for the .NET developer community and they could just focus on integrating to the payment gateway instead of having to learn the API and create wrappers.

Just out of interest here is the overview of the Paypal IPN process as well as the code which you can use at your own risk!!!

1. SetUp requirements or paypal
a.Login to your PayPal account/ Sandbox .
b.In the profile set the Instant Payment Notification (IPN) link to the location of the webpage where paypal should notify the result of the IPN transaction eg.www.xxx.com/ConfirmIPNResult.aspx

c.Using the setup above, paypal knows which URL to execute when the IPN transaction result is completed.

2.SetUp the Thank you page to be displayed and add it to your PayPal Profile ie. the page where paypal
will navigate the user back to your site.

3. User clicks checkout from the shopping cart and transfered paypal.com.
The user will log in to their paypal account and make a payment.

4. When the user completes the purchase they will be redirected to the thankyou page configured in Paypal(STEP 2 above).This link should display a message
"Thank you for your purchase you will shortly receive an email blah blah blah.."
Dont care doing anything now as Paypal will take some time to process the payment and provide the result.
This is asynchronous processing happening and not a direct payment/realtime processing.

5.Paypal will take perhaps some time to process the payment and then it will send a receipt(or more clearly execute the IPN page configured in Step 1b above.

6. In the aspx page PaymentVerified()
a.Add database logging code, EMail informing about success/failure.
b. Send User Login credentials or anything else to the customer
c.Activates user accounts

7.Remember you dont need to do anything very flashy on your notification aspx page
as paypal will only execute this page as a background process.What is important
is the code behind ie.what you want to be logged when Paypal calls this page and
how much of feedback logic you can implement here.

8.The real part is the C# dll which provides you the delegates to communicate
asynchronously to PayPal.If anybody can extend this code to other gateways then
do drop in a message for me.

As usual the code is here

Wednesday, February 24, 2010

Quick primer to Amazon SOAP Api Order Download

Break your calls into 2 parts:
1.First get the document ids using GetAllPendingDocuments() and store it in an array of string or anything that you can enumerate
eg
List pendingDocuments = yourproxy.GetAllPendingDocuments(AMAZONCODE);

2.Next iterate through the documentids and call GetDocument()
foreach (string id in pendingDocuments)
{
StreamReader txtReader = yourProxy.GetDocument(id);
//Pump it into XmlDocument
XmlDocument document = new XmlDocument();
document.Load(txtReader);
}
Follow my on my Amazon.com profile for Amazon related solutions suggested by me at
http://www.amazonsellercommunity.com/forums/profile.jspa?userID=48618

Tuesday, February 23, 2010

Amazon Seller Central integration using Soap/XML Services

Introduction
The documentation for Amazon Web Services API for Seller Central is fairly detailed and it would appear that it would be a few easy steps required and you should be able to port your application to work with Seller Central easily.
This is exactly the impression ,I had in the beginning, when I started the integration work for my company.
It turned out that the documents available provided a few very elementary samples and there was a shortage of full examples and API information which could be used while developing for the real world scenario.There are quite a few things missing and so I thought I bring my experience into this document.

Attached HERE is the full document explaining the whole process along with the FEED Design and explaination.

Feel free to contact me incase you are stuck with any Amazon Integration related issue and I will be happy to suggest solutions based on my knowedge.

Monday, February 15, 2010

REST vs SOAP XML WebServices

In a discussion with my friend and I gave him a big technical introduction of how we were using Xml Webservices as our enterprise platform in our company.
He came up with a query for which I did not have any answer.

He enquired whether we were using REST Webservices or not?

I came back defeated and battered and here is what I found out during my followup on the technology and I though I should put up here.

Regarding REST Web Service?

REST stands for Representational state transfer where
1. Each operation in a service is uniquely identified.
2. Each operation has their, own unique URI and can be accessed via this URL all across the web.
3. Each URL is an object representation.
4. The Object can retreived using HTTP GET.
5. The Object can be deleted using a POST or PUT, use DELETE to modify the object


It also happens that Yahoo web services use REST, including Flickr, del.icio.us API uses it, pubsub, bloglines, technorati.

EBay and Amazon have web services for both REST and SOAP.


Google use SOAP web services only, except that Blogger uses XML-RPC. Of course our company uses SOAP too :)

REST vs SOAP

REST api's are a new development and most the big player apis have mostly come out this year.
So REST is definitely the latest 'COOL' way to create a web service.

The main advantages of REST web services are:
* Lightweight - not a lot of extra xml markup
* Human Readable Results
* Easy to build - no toolkits required

SOAP also has some advantages:

* Easy to consume - sometimes
* Rigid - type checking, adheres to a contract
* Development tools available at hand.

Travel back in time machine of .Net Remoting

I accidently happened to hit upon one of my articles that I wrote on www.codeproject.com a few years back.I though it would be a good idea to put a link to it here for anybody who may be still working on remoting.

Here is the URL http://www.codeproject.com/KB/cs/RemotingInterface.aspx

Wednesday, February 10, 2010

WCF: Data Contracts and Serialization-2

As per my Data Contracts and Serialization-1 blog,I am putting up an example of a WCF Service which you would possibly design in a real world application scenario.

In this case I have integrated the WCF with LINQ to SQL Entity classes which provide the backbone for the DataContracts and DataMembers which are serialized between a typical Client -> Server communication for
Selecting/Adding/Deleting/Updating database records.

I have also added the script for the table I am using in this demo that you could just run on your SqlServer and regenerate the table and the associated objects.

This sample assumes that you know LINQ syntaxes and if you are not familiar then there are plenty of resources out on the net to get you started.

For privacy reasons I have modified the SqlConnection string to
Data Source=SERVER;Initial Catalog=Singh;Persist Security Info=True;User ID=YOURID;Password=YOURPASSWORD.
You would need to replace the parameters SERVER/YOURID/YOURPASSWORD to values specific to your environment.Incase you still have problems then get in touch with me for any help that may be required to get the sample running on your machine.


The code can be downloaded from here .
The Database script can be downloaded from here

Tuesday, February 9, 2010

WCF service contract Versioning-1

Generally we provide the client with the WSDL having details of service contracts,operation contracts and data contracts.
In the real world the service contracts are bound to change over time.
In this 1st of the 2 part session we will look at the impact that such changes can have on the clients and how best we can accommodate our architecture to avoid such
tight coupling of the client to the server.

As usual Slides for this session are here.
And the source code is here