I've been putting some serious thought into how the Payment module can
be improved. Whilst the module has been separated from eCommerce, I
think some more work can be done to further decouple it, and make it
more flexible to use, and easier to extend (eg submitting more payment
types).
Your thoughts on any aspect of what I'm proposing are appreciated.
Here's a summary of what I've detailed below:
* I think we firstly need to clearly define what is required of
the Payment module.
* I've also more clearly defined the types of payment gateways
there are, in hopes that common functionality can be abstracted.
* The redirect linking needs to be abstracted, and flexible.
Ie..where the customer is linked back to after paying on the external
gateway.
* Finally I've listed a bunch of feature ideas.
There's also some tickets in trac for Payments that I think really
need to be merged in.
Core Requirements of Payment Module
=============================
* Must not be tied to any particular module – many payment types
are still heavily tied to eCommerce.
* Ability to pay for different objects. Eg: product, event,
subscription …all within one site.
* An integration guide is needed for developers to know how to
incorporate the Payments module into their application / website.
* Provide methods for common functionality
* Provide appropriate hooks for customisation
Payment Type Categories
===================
These could possibly become sub-payment classes to provide common
functionality where appropriate.
View UML sequence diagrams here:
https://code.google.com/p/silverstripe-ecommerce/downloads/detail?name=PaymentsSequenceDiagram.pdf
* Internal Payment – payments made within the store, staff
interaction required to approve, meaning payment is usually slow to
process.
eg: cheque, cash, bank deposit
* External Payment – customer is redirected to an external
gateway site for entering and processing credit card details. External
gateway then redirects the customer back to the merchant website, so a
controller is always needed somewhere to handle the incoming redirect.
eg: Paypal, Paymate, Paystation
* Merchant Hosted Payment – credit card details etc are filled
out in a form on the merchant site. No other site is ever visited by
the customer’s browser. Will require SSL certificate to secure
communications.
eg: DPS?
Final/Success Page Linking
====================
I'm referring to the 'final page' as the URL that is redirected to
after a payment has been completed successfully or unsuccessfully.
Open up the final page redirect options to allow for better
customisation:
* $payment->PaidObject()->Link(‘someaction’);
* $payment->PaidObject()->{someRelation}->Link(‘someaction’);
* Per payment, session stored link?
* Mysite/predefined-page/$PaymentID/$PaidObjectID
* PreDefinedController/someaction/$PaymentID/$PaidObjectID
* Default – home, or PaymentController??
…this link would be retrieved automatically via $payment-
>RedirectURL() based on Payment module configuration settings. Perhaps
this could be customisable based on payment status also, or
overridable via decorator or sub-classing.
Additional Feature Ideas
=================
* Validation – making sure required fields are filled out, and
fields are filled out correctly. This could just be user_errors.
* Allow for a single payment type – ie provide relevant form
fields when there is only one allowed type, instead of radio buttons
all the time.
* Provide a decorator to make something ‘Payable’. This would add
has_many Payments to the parent object. It would also include useful
functions like TotalPaid, createPayment.
* Allow external payments to be filled out within an IFrame. This
simply looks a bit nicer than being redirected to an entirely
different website.
* Allow cross-checking against ip, session id, transaction id etc…
perhaps make it customisable.
* Provide factory methods for quickly creating new payments.