views:

99

answers:

1

Hi

Service layers and repository seem so simple on paper but I am getting myself confused.

So here is what I am confused about. I have a service layer for my PayPal service layer with validation logic relating to my PayPal stuff and methods that connect to my paypal repository and return results (and do more logic if needed).

Now on my signin page I need to run some checks to see if the user subscription has expired or not. So I got to check some of my PayPal tables.

Now do I put this logic in the PayPal service layer? Or my sigin service layer?

I am not sure which one is the most appropriate place to put it.

+4  A: 

I'd have the signin layer call the PayPal layer.

It sounds like you're using PayPal for authentication and for payments. So you may want to consider what might happen should you replace PayPal with another method for authentication.

In general there should be no problems with layers calling each other.

Jeremy McGee
What if service1 uses service2 and service2 uses service1. Is this asking for trouble or bad design in general?
Malcolm Frexner
Hmm thats a good point. I also was wondering that just about service layers calling another service layer. I was not sure if that was bad design.
chobo2
that depends. If you're accessing the services only through interfaces, and the interfaces are independent, then its not an issue. It sounds like the services may be doing too much. i'd look into separating responsibilities as @JeremyMcGee said (have separate authentication, and payment).
JBland