Avatar of JRockFL
JRockFL
Flag for United States of America asked on

Plugable Payment Providers

BaitShop.BusinnessLogic has a reference to Baitshop.Payment
BaitShop.Payment has an interface called IPayable
BaitShop.Payment has a reference to BaitShop.Payment.AuthorizeNet
BaitShop.Payment has a reference to BaitShop.Payment.PayPal

I'm trying to design this somewhat plugable so I can switch out the Payment Providers.
At checkout a customer can select Credit Card or PayPal.

I'm not sure if my references are correct.

I attached a screen shot
solution.jpg
C#PayPal

Avatar of undefined
Last Comment
jamesrh

8/22/2022 - Mon
jamesrh

The above doesn't seem to match the attachment.  

The attachment seems to imply:
BaitShop.Payment has an interface called IPayable
BaitShop.BusinnessLogic has a reference to Baitshop.Payment
BaitShop.Payment.AuthorizeNet has a reference to BaitShop.Payment
BaitShop.Payment.PayPal has a reference to BaitShop.Payment

And then AuthorizeNet and PayPal implement IPayable?

If yes, then this is a reasonable structure to have a pluggable option in BusinessLogic calling the IPayable interface against whichever class is appropriate.
JRockFL

ASKER
The issue that I'm having is that

BaitShop.Payment.AuthorizeNet
BaitShop.Payment.PayPal
each have a reference to Baitshop.Payment and they implement IPayable.

However, BaitShop.Payment  does not have a reference and does not know about them.

In the business layer, how can I create an instance of IPayable?
AuthorizeNetProcessor implements IPayable;


//this wont work
IPayable payable = new BaitShop.Payment.AuthorizeNet.AuthorizeNetProcessor();
ASKER CERTIFIED SOLUTION
jamesrh

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes