Coder Social home page Coder Social logo

moip-technical-challenge's Introduction

moip-technical-challenge

This is a Payment REST API for the Moip Technical Challenge, with this API it is possible simulate new payments (using credit card or boleto) and getting its status.

How to Build:

Building and Running with Docker

Build the image

$ docker-compose build

Execute migration and load a preset database

$ docker-compose run web rails db:reset db:seed

Run Server

$ docker-compose up

Run Specs

$ docker-compose run web rails spec
Building and Running without Docker

Install the dependencies

$ bundle install

Comment host parameter from database.yml

...
    #host db
...

Execute migration and load a preset database

$ rails db:reset db:seed

Run server

$ rails s

Run specs

$ rails specs

Usage:

This API has two endpoints, one to create new payments and other one to get the payment status. The usage for these endpoints are written below:

  • POST v1/payments create a payment

Request for credit card:

{
  "payment": {
    "method_type": "Card",
      "amount": "500.50",
      "client": {
        "client_id": "1"
      },
      "buyer": {
        "name": "Darius Hamill",
        "email": "[email protected]",
        "CPF": "123.123.123-12"
      },
      "method": {
        "holder_name": "DARIUS HAMILL",
        "number": "1234123412341234",
        "expiration_date": "2018-12-12",
        "cvv": "123"
      }
  }
}

Response for credit card:

{
    "id": 25,
    "status": "success"
}

Request for boletos:

{
  "payment": {
    "method_type": "Boleto",
      "amount": "500.50",
      "client": {
        "client_id": "1"	
      },
      "buyer": {
        "name": "Darius Hamill",
        "email": "[email protected]",
        "CPF": "123.123.123-12"
      }
  }
}

Response for boletos:

{
    "id": 26,
    "number": "44883713286039411099542945642906502798614817748"
}
  • GET v1/payments/{id} get the status from {id} payment

Response for credit card:

{
    "id": 25,
    "amount": 500.5,
    "method_type": "Card",
    "status": "success",
    "client": {
        "id": 1
    },
    "buyer": {
        "name": "Darius Hamill",
        "email": "[email protected]",
        "CPF": "123.123.123-12"
    },
    "method": {
        "holder_name": "DARIUS HAMILL",
        "number": "1234123412341234",
        "expiration_date": "2018-12-12",
        "cvv": 123
    }
}

Response for boletos:

{
    "id": 26,
    "amount": 500.5,
    "method_type": "Boleto",
    "status": "success",
    "client": {
        "id": 1
    },
    "buyer": {
        "name": "Darius Hamill",
        "email": "[email protected]",
        "CPF": "123.123.123-12"
    }
}

moip-technical-challenge's People

Contributors

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