Giter Site home page Giter Site logo

ceviche9 / gk-webhook-java Goto Github PK

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

📫 This project is a Java-based API designed to integrate an anti-fraud system for credit card purchases within an e-commerce platform. The API offers endpoints to interact with the anti-fraud service, enabling the e-commerce platform to conduct fraud checks on incoming orders.

Java 100.00%
java spring-boot webhook

gk-webhook-java's Introduction

GK-WEBHOOK JAVA

Overview

This project is a Java-based API designed to integrate an anti-fraud system for credit card purchases within an e-commerce platform. The API offers endpoints to interact with the anti-fraud service, enabling the e-commerce platform to conduct fraud checks on incoming orders. Additionally, the API facilitates sending emails to buyers to validate certain information. The API also includes specific endpoints for handling webhook calls from the e-commerce platform and managing emails sent to buyers.

Features

The webhook route has several features, including:

  • Check if the data sent by the webhook has all the necessary fields; these are the fields that have previously caused errors for being empty.
    public void verifyEmailFields(VerifyOrderDTO order) throws Exception {
        if(
                order.pagamentos() == null ||
                order.pagamentos().get(0).valor_parcela() == null ||
                order.pagamentos().get(0).forma_pagamento() == null ||
                order.pagamentos().get(0).valor() == null
        ) {
            logger.error("This order does not have all the payments fields");
            throw new Exception("This order does not have all the payments fields.");
        }

        if(
                order.itens() == null
        ) {
            logger.error("This order does not have any item.");
            throw new Exception("This order does not have any item.");
        }
    }
  • Check if the payment was made by card and if it's approved.
     public void verifyOrderStatus(VerifyOrderDTO order) throws Exception {
        logger.info("Check order status");
        if (!order.pagamentos().isEmpty() && !"mercadopagov1".equals(order.pagamentos().get(0).forma_pagamento().codigo())) {
            logger.error("This order was not payed with credit card: "+ order.pagamentos().get(0).forma_pagamento().codigo());
            throw new Exception("Esse pedido não não foi pago no cartão.");
        }

        if (!order.situacao().aprovado()) {
            logger.error("Order not approved: "+ order.numero());
            throw new Exception("Esse pedido ainda não foi aprovado!");
        }
    }

Requirements

  • Java JDK 8 or higher
  • Apache Maven for dependency management
  • SMTP server for sending emails

Installation

  1. Clone the repository from GitHub Repository Link.
  2. Build the project using Maven: mvn clean install.
  3. Deploy the generated artifact to your desired application server or run it locally.

Usage

  1. Include the API into your e-commerce platform project as a dependency.
  2. Configure the API endpoints and integrate them into your platform's order processing flow.
  3. Utilize the API endpoints to conduct fraud checks on incoming orders.
  4. Implement email validation logic using the provided API endpoints.
  5. Configure webhook integration to handle automatic calls from the e-commerce platform.
  6. Monitor and analyze the results provided by the anti-fraud system.

API Endpoints

  • /orders/webhook: Webhook endpoint called automatically by the e-commerce platform.
  • /orders/send-email/{orderId}: Endpoint to send an email by the order ID.
  • /emails: Endpoint to retrieve all emails that have been sent.

Configuration

  • Configure the API to communicate with your preferred anti-fraud service provider.
  • Set up authentication and authorization mechanisms to secure the API endpoints.
  • Configure the SMTP server for sending emails.
  • Customize email templates and content as per your requirements.

gk-webhook-java's People

Contributors

ceviche9 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.