GithubHelp home page GithubHelp logo

larbikhounti / progressive-payment-gateway Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 13 KB

a payment structure gateway allowing for progressive development, making it easy to add new payment gateways in the future without needing to change the code structure.

Java 100.00%

progressive-payment-gateway's Introduction

progressive payment gateway structure

a payment structure gateway allowing for progressive development, making it easy to add new payment gateways in the future without needing to change the code structure.

what's the code is missing ?

  • the pay(Card card) logic because every payment gateway has its own logic
  • the checkCardValidation(Card card) logic to check if the card is valid

To add new payment gateway

Inside paymentProccessors directory add new class, for example Paypal that implements paymentProcessor, you will need to Override two methods pay(Card card) and checkCardValidation(Card card), both of them accepts ``Card``` as an arguments.

Building a new card

Card is using Builder pattern so you have to Build it like this for example :

Card card = new Card.CardBuilder()
                .setCardNumber("5350239959461533")
                .setSecurityNumber(369)
                .setExpiryDate("01/29")
                .setAddress("some street address")
                .setCardIssuer(CardIssuer.MASTERCARD)
                .setName("mr Mohamed khounti")
                .build();

then you need to pass the card to the pay(Card card) method and checkCardValidation(Card card) like this :

//create an instance of stripe
Stripe stripe = new Stripe();

// chick if card is valid
boolean isValid = stripe.checkCardValidation(card);

// pay using the card provided
String result = stripe.pay(card);

progressive-payment-gateway's People

Contributors

larbikhounti avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.