Post by mikeytrw » Tue Oct 14, 2008 7:36 pm

Hi Guys,

Im using OpenCart for a project that requires WorldPay support,

I'm a confident OOP PHP coder but would like to know if anybody has done this before, or if anybody has an empty class or example code to work from.

Thanks,
Mike

New member

Posts

Joined
Tue May 27, 2008 9:28 pm

Post by bruce » Tue Oct 14, 2008 7:49 pm

It will depend on the worldpay API.

If the customer is diverted to a worldpay website to collect credit card details for payment then the paypal module shipped with opencart or the new authorize.net (SIM) module by Qphoria are good starting points.

If you want to capture the customer's credit card details within opencart and send them to worldpay to make a payment then the SecurePay example in payment contributions is a good starting point.

The above mentioned can be found here.

cheers

Bruce

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by mikeytrw » Wed Oct 22, 2008 11:51 pm

Thanks Bruce,

Ive been looking through both the paypal and the securepay modules, I'll have a look into authorize.net as well.

Just getting my head around opencarts internal structure at the mo, should get it sorted.

New member

Posts

Joined
Tue May 27, 2008 9:28 pm

Post by Qphoria » Thu Oct 23, 2008 12:13 am

OpenCart's structure is based on MVC (Model-View-Controller) Framework. OpenCartv0.x is about 66.66666% MVC (as model isn't really used in this version) and 1.x has been set 100% MVC. You can read more about MVC on wikipedia and such.

Anyway, to keep it simple.

There are 5 major sections.

1. First the "library" files do a lot of the common stuff. Handle sessions, totals, format conversions
2. Then the "controller" files are the invididual brains of each functional page. They define what content drives that page. Home page, product page, categories, cart, etc.
3. A subset of controller files are the "extension" files. These are the sideboxes, header/footer, but also where payment & shipping modules are handled. For example, the main controller for "checkout_shipping" looks up all the available shipping "extensions". The controller for "checkout_payment" looks up all the available payment "extensions".
4. The "View" part of MVC is handled by the Templates. These are the tpl files. There is virtually a one-for-one match between controller and templates.  So 'catalog/controller/product.php is displayed using "catalog/template/default/content/product.tpl", etc.
5. Finally, as part of "view", proper language support is also used, a generic placeholder is put in place in the template file, and that placeholder variable is replaced by the version defined in the language file so "$text_yes" looks up in the current language setting and finds "yes" (in english) or "si" (in spanish), etc. It too has a similar directory structure with the related controllers.
Last edited by Qphoria on Thu Oct 23, 2008 12:15 am, edited 1 time in total.

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by mikeytrw » Tue Oct 28, 2008 1:55 am

Hey Guys,


WorldPay module coming on really well, although my client hasn't received his account login so i'm kinda coding blind lol  ;D

I have written the controller for admin, the language and the template file. I'm just working on the catalog extension.

I need a clarification...

The process() function : I assume this is called to actually add the order to the DB, and you can pass it an order status id. Usually this is called after the payment gateway has completed and it passes the user back to a URL on the shopping cart. However i'm not sure with WorldPay its possible to pass a return URL in the payment submit form (although it might be possible to configure it in the admin panel - i wont know till i get a login).

If its not possible to config the return URL in the WorldPay panel, should I just call process in the callback() function so that when WorldPay posts a notification the order gets processed and confirmed in one swoop?

The only drawback I can see is that the user won't receive an order confirmation email until WorldPay calls callback().


Please correct any incorrect assumptions :)

Thanks

Mike

New member

Posts

Joined
Tue May 27, 2008 9:28 pm

Post by bruce » Tue Oct 28, 2008 10:26 am

mikeytrw wrote: However i'm not sure with WorldPay its possible to pass a return URL in the payment submit form (although it might be possible to configure it in the admin panel - i wont know till i get a login).

If its not possible to config the return URL in the WorldPay panel, should I just call process in the callback() function so that when WorldPay posts a notification the order gets processed and confirmed in one swoop?

The only drawback I can see is that the user won't receive an order confirmation email until WorldPay calls callback().
All assumptions are ok but...

After redirecting to worldpay, it should return you to some configurable location on the store website. This would be checkout_process which automatically calls the process function of your payment extension. That function should check the REQUEST for confirmation/rejection details. Success then $order->process otherwise redirect to checkout_failure.

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by mikeytrw » Tue Oct 28, 2008 5:31 pm

Awesome, thanks for clearing that up.

8)

New member

Posts

Joined
Tue May 27, 2008 9:28 pm

Post by mikeytrw » Tue Oct 28, 2008 10:38 pm

Hi Guys,

Nearly finished :)

Can someone clarify which order_status i should be using for each part of the order process?

Pending , Processing , Cancelled , Shipped , Complete....

in PaymentWorldpay->process() should i be setting the order status to 'pending'? if so then what do i set it to in callback() once payment has been verified?

thanks

this contrib will be available for others as soon as ive tested with a live account.

New member

Posts

Joined
Tue May 27, 2008 9:28 pm

Post by Qphoria » Tue Oct 28, 2008 11:53 pm

Pending usually means "order is pending payment". Like waiting for a money order or check to clear
Processing usually means the payment was made and the order is being processed
Canceled is obvious
Shipped means it was shipped from you to the customer
Complete means you have confirmed delivery

Pending is probably good enough for what you want, however, some have opted to add a slightly less ambiguous title like "Unconfirmed Payment" which means that the order was "pre-processed" (to prevent losing it) and then when the callback is hit, it updates the order to "Processing" state.

To keep it simple, you could probably just use
PaymentWorldpay->process()  ----> Pending
Callback ----> Processing

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by mikeytrw » Mon Nov 24, 2008 11:45 pm

Hi Guys,

Just (finally) got a login for my clients worldpay account.


I'm a little bit stuck here...

It seems that I can only configure a single URL with worldpay that is where the shopper gets returned AND processes the payment notification (success of failure) there isnt a separate customer return and notification URL. which sucks.

At this point I can either...
- Do all the 'callback' processing in the process() function and tell worldpay to just send the user and payment post notification there.
- call $this->order->process() in the payment callback() function.

I've been trying the first method but having 2 problems. Firstly, i cant seem to get the order to appear in the 'order' table in the database, even if i call the $this->order->process() function, secondly if i set the return/ipn url to be http://myurl.com/store/index.php?contro ... ut_process Worldpay doesnt redirect and i get a callback failure.

Trying option 2 gives me the same frustration, i cant get the order to appear in the DB. so i can set its status to processing...

code attached.

thanks :)

New member

Posts

Joined
Tue May 27, 2008 9:28 pm

Post by mikeytrw » Tue Nov 25, 2008 1:01 am

Little update

I was looking in the wrong table :(

anyway, the payment module works, but the customer gets passed back to the callback URL, also i dont seem to be able to properly redirect them to the checkout success Worldpay says im not aloud to do a redirect in this script. which is a total pain...I'll call them tomorrow and find out what the problem is.

Thanks

New member

Posts

Joined
Tue May 27, 2008 9:28 pm

Post by Qphoria » Tue Nov 25, 2008 1:26 am

Your callback should make the redirect choice, not worldpay.

Worldpay should return its payment results to checkout_process 'callback'
callback should read the message and check for pass/fail and depending on that, redirect from there to success or checkout_failure

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by mikeytrw » Tue Nov 25, 2008 7:37 pm

Thing is worldpay dont actually redirect the customer anywhere, their system displays the output from checkout_process 'callback' to the user and strictly forbids and redirect codes. I've tried some shenanigans with meta refresh but I just dont think that is the way forward.

from Worldpay's help pages:

Code: Select all

Q - Can I use callback to redirect shoppers back to my web site? 
A - No. All methods of automatic redirection are prohibited.

If you wish to present a custom page to shoppers after a transaction is authorised or cancelled, please see What should I be aware of if I wish to display a customised page to shoppers as a response to a callback?.
All worldpay will allow me to do is upload an HTML page that they display to the shopper with a link back to the shopping cart.

If I put a link to http://mycart.com//store/index.php?cont ... ut_success will this omit any required processing? Is this the page I should link back to?

thanks,

New member

Posts

Joined
Tue May 27, 2008 9:28 pm

Post by Qphoria » Tue Nov 25, 2008 10:20 pm

You are going to have to revamp your thinking a bit. I am currently trying to get a new version of paypal out there for 0.7.9 final that instead of sending from checkout_confirm -> Paypal it sends back to itself for pre-processing. Then goes to a checkout_pending page that has the actual form call to the outside vendor.

You can read more about it here.

If this method is accepted, then you can use the design to create your module as well. This will pre-process the order and clear the cart before going to the payment processor

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by mikeytrw » Tue Nov 25, 2008 11:48 pm

Ahah,

I think this is exactly what I need to look at.

Thanks

New member

Posts

Joined
Tue May 27, 2008 9:28 pm

Post by mikeytrw » Wed Nov 26, 2008 6:30 pm

Hi,

I've had a look at your new Paypal model, this looks good but is kinda out of the way for this contrib I think, as I want this to be something people can use with existing installations. Also it will require me to re-invent the wheel as I think there could be a simpler solution for me.

Currently I've set up a success HTML page that redirects the user to

http://persec.co.uk/store/index.php?con ... ut_process

On the hope that this will clear the cart and redirect the user to checkout_success, however the user is redirect but the cart doesnt seem to clear.... :(

Any ideas why this could be?

The site is http://www.persec.co.uk, worldpay is configured in test mode so feel free to check it out.

test solo card number (from worlpay's docs) : 6334580500000000

thanks

New member

Posts

Joined
Tue May 27, 2008 9:28 pm

Post by mikeytrw » Wed Nov 26, 2008 6:31 pm

oh forgot to mention there is a test product in Audio Surveillance » Plugs category that has a valid price.

Thanks

New member

Posts

Joined
Tue May 27, 2008 9:28 pm

Post by Qphoria » Wed Nov 26, 2008 8:11 pm

Actually, if people like the paypal contrib, then it will be part of the existing installation starting tonight. It is actually how all payment modules from here-on-out should be written to use the confirmation validation. Otherwise, all payment modules are susceptible to be bypassed

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am
Who is online

Users browsing this forum: No registered users and 6 guests