Welcome, Guest
Username: Password: Remember me

TOPIC: [HOW TO] INTEGRATE PayPal IPN into Component

[HOW TO] INTEGRATE PayPal IPN into Component 01 Nov 2012 10:37 #4876

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Dear Cooks,

I was just wondering if anyone had any experience of integrating PayPal IPN into your Joomla Components and how you've managed to do it? I've searched a lot sites to see how best to handle this in the context of joomla components but there is not a lot of info out there...

I wouldn't say I'm 100% confident with the IPN but I've read and understood the docs and know how I'm going to approach this side of things. My question relates more specifically to how best to implement it in the context of my Joomla component.

SCENARIO
I'm building a custom shopping cart for a client that at present, will only require Paypal Payments (and an offline option for trade customers). Therefore, in this instance, I appreciate that I could just go ahead and add all of the IPN calls directly in the component however, I would like to be able to re-use it in the future and possibly wish to add other payment options and gateways.

This raises the question, how can I best implement this so that I can easily swap in/out payment gateways in the future?

The obvious answer to me is in the form of a plugin but I just wanted to check if there were any other options to me? I suppose the advantage of this would be that users could load multiple plugins to give customers multiple options as to how they wish to pay, right?

Logically, this seems to be the way to go IMHO;
  1. Transactions table that stores a unique transaction id in my component, payment method (currently paypal or offline & any others I add in future), the gateway's transaction id, order total, order status (awaiting payment, complete, cancelled etc.), customer id and so on. In the controller for this will be a bunch of methods to retrieve the cart from the session, retrieve & call the payment method, calculate the total & discounts and so on.
  2. Also in this controller I would need to call the payment plugin where the order gets sent to the gateway for checking, sent back to controller to be checked again in the transactions table in case of price jacking before being sent back to the gateway for processing.
  3. Update the transactions table with the new status & send any notification emails to admin & customers on update from the plugin/gateway
Does this all make sense?

Any flaws, anything missing or a better way to do it other than a plugin???

Any help or pointers on this would be most appreciated!!!

Many thanks in advance,

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.

[HOW TO] INTEGRATE PayPal IPN into Component 01 Nov 2012 10:42 #4877

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Incidentally, I'm pretty sure that I will be processing the IPN transactions to paypal using cURL as it will be more secure than adding a load of additional hidden fields in the cart. Also, this allows for extending payment gateway options via other plugins that will obviously require different fields...

Thanks

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.

Re: [HOW TO] INTEGRATE PayPal IPN into Component 03 Nov 2012 07:44 #4966

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Sorry I know the original post was lengthy...

In essence, is a plugin the best way to integrate paypal into a component?

Many thanks,

Gez!!!
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.

Re: [HOW TO] INTEGRATE PayPal IPN into Component 10 Nov 2012 23:20 #5245

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
IPN role is to validate something. ... So, a transaction.

Your main table for this part is a table called 'Transactions'

The shop or whatever is preparing a transaction, using this MVC for transaction.
Then at any moment, an IPN can arrive to close the transaction and validate. How it works ?

Very easy.
You've created a new function in the controller, for instance ipn(), and the entry point to furnish to PayPal system is the url of your component :
index.php?option=comxxxx.....view=transaction&task=ipn

This controller function get the posted informations from PayPal, decode them and treat them. The transaction item is updated, and you can continue the process elsewhere or a callback function.

Do not use the redirections because the robot processing IPN is not human and not able to read anything ;-)

One important thing is to write all this in the FRONT of your component, because the robot do not have admin access either.

What to say more ?

Need help for processing the first part ? Querying paypal ?

If I need to implement any kind of TPE, I read the documentation and I get all instructions. for POST values and IPN receipts.
So ...
You got it ?
Coding is now a piece of cake
The administrator has disabled public write access.

Re: [HOW TO] INTEGRATE PayPal IPN into Component 10 Nov 2012 23:35 #5246

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Mostly - I think...
IPN role is to validate something. ... So, a transaction.

Your main table for this part is a table called 'Transactions' - YES

The shop or whatever is preparing a transaction, using this MVC for transaction.
Then at any moment, an IPN can arrive to close the transaction and validate. How it works ? - YES

I was wondering whether a plugin might be the best way although, I guess, processing in the MVC can still be extended to incorporate other gateways in the future...

One question; Should this be a controller function or a model? You did say controller but I just wanted to check. I mean RE:
You've created a new function in the controller, for instance ipn(), and the entry point to furnish to PayPal system is the url of your component :
index.php?option=comxxxx.....view=transaction&task=ipn
So I call the IPN into action here in the controller, right? Then, I should call the checking/saving/updating scripts in my model, right?

I will be storing the transaction before calling paypal, then get the response from paypal, get, validate and cleanse all of the data and process the payment (update the payment status, txn_id etc).

Pretty sure I got the IPN sorted (in sandbox at least, with a standalone class/sub-class that does the processing/logging to a file for testing).]

Thanks so much for looking at this!!!

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.

Re: [HOW TO] INTEGRATE PayPal IPN into Component 10 Nov 2012 23:42 #5247

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
You got everithing.

Your way of doing with MVC is OK.

About the plugin, you know paypal is querieng an url. So where do you want to point the url ? A plugin is not reachable like that.

So for sure you first have to do a component. then if you want to plugin from others components in joomla, you can use plugins, but I don't think your idea was so complex.

Use component. You are on an excellent way.
Coding is now a piece of cake
Last Edit: 10 Nov 2012 23:43 by admin.
The administrator has disabled public write access.

Re: [HOW TO] INTEGRATE PayPal IPN into Component 10 Nov 2012 23:49 #5249

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Brilliant - Yes, I realised that if I were to go down the plugin route, I'd have to include a separate file that could be called by paypal although it wasn't exactly clear to me what the implications of this would be.

Thanks so much for this!!!

I can really get on my way with this project now!

Bonne nuit!

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.

Re: [HOW TO] INTEGRATE PayPal IPN into Component 11 Nov 2012 20:44 #5299

  • BTB300
  • BTB300's Avatar
  • Offline
  • Moderator
  • Posts: 415
  • Thank you received: 132
  • Karma: 47
Hi audibleid,

I trust you have these or similar before you start...

Website Payments standard - Integration – www.x.com/developers/paypal/products/website-payments-standard

Express Checkout – Integration –https://www.x.com/developers/paypal/products/express-checkout

IPN Reference - cms.paypal.com/us/cgi-bin/?cmd=_render-c...o_admin_IPNReference

if you need a hand give me a yell
Last Edit: 11 Nov 2012 21:14 by BTB300.
The administrator has disabled public write access.

Re: [HOW TO] INTEGRATE PayPal IPN into Component 11 Nov 2012 21:03 #5300

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
@BTB3000

Yes, I have the IPN stuff all working fine in a standalone script that validates with cURL, checks the transaction for price jacking, normalises the charset and all of that good stuff... I was just really unsure how best to move forward with integrating it into the component - mainly whether to go plugin route or code in the component itself...

I think I'm on the right track now and intend to go with coding directly in the component as it will still be extendible should I wish to introduce another gateway in the future.

I hope I don't need to bother you with anything but would definitely like to keep the door open on your kind offer of help just incase! ;)

Thanks again!!!

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.
Time to create page: 0.162 seconds

Get Started