Download BSc_Project_Final_Report_v1.1
Transcript
be taken into account when achieving this: the model and the use of the adapter to execute payments. The PaymentConnector and the other connector classes are introduced in the model, to make it easier to expand it with a new payment method. The only thing that needs to be done is extending the connector classes with classes containing specific information to that payment method. Very little work needs to be done in the existing classes. A weak point on maintainability in this approach, is that when changing or adding a method to the Payment class, a corresponding method using this method needs to be added to the PaymentConnector class (or a similar class and connector). Even with this weakness, the chosen solution remains the better one. More details on the model design can be found in section 4.1. In order to keep the execution of payments generic, an abstract class PaymentAdapter is created, containing functions commonly used in the payment process. More specifically, those functions are executePayments, setUpRecurringPayment and paymentsAreValid. The PaypalAdapter class implements those functions to: ● executePayments: Retrieve a token for the given payment from PayPal; ● setUpRecurringPayment: Retrieve a pre-approval token for the recurring payment from PayPal; ● paymentsAreValid: Checks PayPal specific constraints for a payment. In the current flow, the executePayments and setUpRecurringPayment functions are used in AJAX calls from the summary page. Adding a new payment method would involve creating those calls as well. This is built this way, because a different payment method can involve a whole different process. What if, for example, the other method does not work with tokens and redirecting it to an external website at all? A general approach is not possible in this case and therefore those AJAX calls refer to an action in the PayPalController, holding PayPal specific actions. For a new payment method, a new controller should be created with actions specific to this new payment method. It is a different story for the paymentsAreValid function. No matter what payment method is used, it can be implemented to return results for a specific payment method in the corresponding adapter created. There is one change that needs to be done when adding a second payment method though. Currently, the PayPal specific checks are done right after the general input checks and, on error, returned with them. When adding a second payment method this is not the wanted behaviour. PayPal may restrict a certain condition, but a second payment method may not. If the second payment method would allow the payment to be made and PayPal does not, the wanted behaviour is to show the summary page and disable the option to pay with PayPal with the reason why it is disabled. Users can then still choose to use the second option. The place to do the checks can remain the same, the way the response is handled should change. 50