Ticket #502 (reopened Patch)

Opened 7 months ago

Last modified 6 months ago

Paypal Website Payments Pro - Kohana Payment Driver

Reported by: atomless Owned by: zombor
Priority: minor Milestone: 2.2
Component: Libraries Version: SVN HEAD
Keywords: Cc:

Description

Paypal's website Payments Pro service enables transactions to be completed from within the initial site without having to visit paypal by using the paypal API

Paypal Website Payments Pro - overview https://www.paypal.com/us/cgi-bin/webscr?cmd=_wp-pro-overview

Name-Value Pair API Developer Guide and Reference https://www.paypal.com/en_US/ebook/PP_NVPAPI_DeveloperGuide/toc.html

Here's a Paypal Website Payments Pro driver for Kohana and the necessary payment config file - I tried where possible to follow the example of the existing drivers - it seems to work well, please let me know if you find any bugs!

Attachments

Paypalpro.php (6.0 kB) - added by atomless 7 months ago.
Kohana Payment driver for Paypal Website Payments Pro
payment.php (2.0 kB) - added by atomless 7 months ago.
Kohana payment config for Paypal Website Payments Pro
Paypalpro.2.php (6.6 kB) - added by atomless 7 months ago.
Tidied Paypalpro driver with the bug in the process method fixed

Change History

Changed 7 months ago by atomless

Kohana Payment driver for Paypal Website Payments Pro

Changed 7 months ago by atomless

Kohana payment config for Paypal Website Payments Pro

  Changed 7 months ago by zombor

  • owner changed from - No owner - to zombor

follow-up: ↓ 3   Changed 7 months ago by zombor

I'm not too familiar with Payments Pro (only use standard), but with Pro, the customer does not need a paypal account?

in reply to: ↑ 2   Changed 7 months ago by atomless

Yes - that's correct. Paypal Website Payments Pro accepts VISA, Mastercard, Amex and Discovery - and the entire transaction is completed within your site -

There are some requirements imposed by paypal : you need PCI compliance certification ( this is provided free for the first year with every Payments pro account http://www.scanalert.com/site/en/pci/intro/ - and you are also required to offer paypal express checkout as an option in the checkout process of your site.

follow-up: ↓ 5   Changed 7 months ago by atomless

The paypal documentation is a complete and utter mess - but once you wade through it all, it is an effective and reasonably simple solution.

in reply to: ↑ 4   Changed 7 months ago by zombor

Replying to atomless:

The paypal documentation is a complete and utter mess - but once you wade through it all, it is an effective and reasonably simple solution.

Yes, I found that out when doing the Payments Standard Driver! ;)

I'll clean this one up and add it to SVN for 2.2.

  Changed 7 months ago by zombor

  • status changed from new to closed
  • resolution set to fixed

Added in r2322.

  Changed 7 months ago by atomless

  • status changed from closed to reopened
  • resolution deleted

Hi Zombor,

Nice tidy-up job on the code.

- though I've just noticed a few possible problems -

There's now a small bug in the driver code at the end of the process function where the nvp array is wrongly named in the return statement.

I can see why it would be desirable to just have a success or failure boolean returned from the process method rather than the entire response - however the ACK parameter of the response is never simply true or false - see here: https://www.paypal.com/en_US/ebook/PP_NVPAPI_DeveloperGuide/overview.html#2075845

Also, if the transaction does fail, it may be desirable to present the user with differing feedback depending on the type of failure - whether it was an internal paypal api error (I've had a few of those!) or if it was an error with the formatting of one of the parameters passed or that the card details failed to validate for some reason - in which case it would be nice to notify the user where they need to adjust the form input - more info on the response parameters here: https://www.paypal.com/en_US/ebook/PP_NVPAPI_DeveloperGuide/Appx_fieldreference.html#2646588

I was thinking of keeping it so the process method returns a simple boolean but add an additional method for retrieving the full response array or even something more sophisticated that will analyse the response array and return the reason for failure and so negating the need for knowledge of the api response parameters completely?

happy to re-post what i come up with if this sounds like a good idea to you?

  Changed 7 months ago by atomless

also, might be a good idea to add this link to the paypalpro payment config settings

https://www.paypal.com/en_US/pdf/PP_Sandbox_UserGuide.pdf

as unless the developer sets up their own sandbox account it seems that test transactions can't be checked/viewed within any paypal sanbox interface.

follow-up: ↓ 10   Changed 7 months ago by atomless

after giving this some more thought I realise that adding a method for returning why the transaction failed goes beyond simply editing the Paypalpro driver and would require a change to the Payment library itself - do you think it would be a good idea to add a method for retrieving why the transaction failed to the payment library? - so the process method of any payment driver would always return a boolean then on failure the developer can call the get_transaction_errors method - with the respective drivers implimenting this function in whatever way best suited to the responses from the given merchant.

in reply to: ↑ 9   Changed 7 months ago by zombor

Replying to atomless:

after giving this some more thought I realise that adding a method for returning why the transaction failed goes beyond simply editing the Paypalpro driver and would require a change to the Payment library itself - do you think it would be a good idea to add a method for retrieving why the transaction failed to the payment library? - so the process method of any payment driver would always return a boolean then on failure the developer can call the get_transaction_errors method - with the respective drivers implimenting this function in whatever way best suited to the responses from the given merchant.

The payment library is actually set up to return TRUE on succesful payment, or error string on a failure. So you could grab the error from paypal, and return that insteady of TRUE. When I cleaned it up, I just returned based on the ACK for the speed of getting it in SVN. Feel free to submit a patch, or I may take a look at it this weekend.

Look at the other payment drivers for an example of this.

  Changed 7 months ago by atomless

What I mean is that it might be nice to generalise a little more so that the payment drivers and the responses of the various merchants are more encapsulated - so rather than the developer needing to know what response error parameters to look for in the response string from the process method - there are much more generalised error messages that can be retrieved by calling a get_response_errors method - that all drivers could have - i'm not sure how far it's possible to go with generalising the possible errors but i'd imagine the main ones would be cvv2_error, card_number_error, exp_date_error and address_match_error.

anyway - I've fixed the bug in the process function of the paypalpro driver and will attach it to this ticket.

Changed 7 months ago by atomless

Tidied Paypalpro driver with the bug in the process method fixed

  Changed 7 months ago by zombor

That's a good idea to generalize the errors. I'll look into that for the 2.2 release.

  Changed 6 months ago by JAAulde

  • milestone changed from 2.1.2 to 2.2

zombor stated the added code would be available for 2.2

moving this ticket to that milestone

Note: See TracTickets for help on using tickets.