Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Chargily/chargily-epay-springboot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Spring Boot Library for Chargily ePay Gateway

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages