Code Monkey home page Code Monkey logo

chargily-epay-springboot's Introduction

chargily-epay-springboot

Spring Boot Library for Chargily ePay Gateway

Chargily ePay Gateway

How to use

To use this library add the jar to your project libraries (it will be added to maven when possible)

There are two ways to configure keys and secrets:

  • By providing your own configuration class like this

import ChargilyEpayClientConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import static ChargilyEpayConfigParams.*;

@Configuration
    public class ChargilyEpayConfiguration {

        @Bean
        public ChargilyEpayClientConfig configureChargily(){
        ChargilyEpayClientConfig chargilyEpayClientConfig = new ChargilyEpayClientConfig();
        chargilyEpayClientConfig.put(BASE_URL, "https://epay.chargily.com.dz");
        chargilyEpayClientConfig.put(API_KEY, "your_api_key");
        chargilyEpayClientConfig.put(SECRET, "your_secret");
        return chargilyEpayClientConfig;
    }
}
  • or simply adding by these properties on application.properties file

chargily.epay.apikey=your_api_key
chargily.epay.url=https://epay.chargily.com.dz
chargily.epay.secret=your_secret

then to make a payment simply inject the ChargilyClient in your service

either by constructor or field injection like this (constructor injection is preferred, but I will use field injection just for demo)

public class MyService{
@Autowired
private ChargilyEpayClient client;

public void makePayment(){
    InvoiceModel invoice = new InvoiceModel(
                "someClient",
                "[email protected]",
                "1000",
                BigDecimal.valueOf(75.0),
                55d,
                "https://backurl.com/",
                "https://webhookurl.com/",
                Mode.CIB,
                "a comment"
                );
    //handle response after you get it as a call back
    client.makePayment(invoice, new Callback() {
            @Override
            public void onFailure(@NotNull Call call, @NotNull IOException e) {
                //in case of failure
            }

            @Override
            public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
                //in case of success
            }
        });
    }
}

Here's a demo

chargilyTest.mp4

chargily-epay-springboot's People

Contributors

springadam avatar chargilydev avatar

Stargazers

0xADB3 avatar Hadj H. avatar  avatar

Watchers

James Cloos 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.