Code Monkey home page Code Monkey logo

epayco-js's Introduction

Epayco

Node/ReactNative/Web wrapper for Epayco API

Description

API to interact with Epayco https://epayco.co/docs/api/

Installation

As usual, you can install it using npm.

$ npm install epayco

Usage

var epayco = require('epayco-js')({
    apiKey: 'PUBLIC_KEY',
    privateKey: 'PRIVATE_KEY',
    test: true | false
}, isReact);

Create Token

epayco.token.create({
    "card[number]": "4575623182290326",
    "card[exp_year]": "2017",
    "card[exp_month]": "07",
    "card[cvc]": "123"
}).then((token) => {
        console.log(token);
    })
    .catch((err) => {
        console.log("err: " + err);
    });

Customers

Create

epayco.customers.create({
    token_card: "toke_id",
    name: "Joe Doe",
    email: "[email protected]",
    phone: "3005234321",
    default: true
})
    .then((customer) => {
        console.log(customer);
    })
    .catch((err) => {
        console.log("err: " + err);
    });

Retrieve

epayco.customers.get("id_customer")
    .then((customer) => {
        console.log(customer);
    })
    .catch((err) => {
        console.log("err: " + err);
    });

List

epayco.customers.list()
    .then((customers) => {
        console.log(customers);
    })
    .catch((err) => {
        console.log("err: " + err);
    });

Update

epayco.customers.update("id_customer", {
    name: "Alex"
}).then((customer) => {
        console.log(customer);
    })
    .catch((err) => {
        console.log("err: " + err);
    });

Plans

Create

epayco.plans.create({
    id_plan: "coursereact",
    name: "Course react js",
    description: "Course react and redux",
    amount: 30000,
    currency: "cop",
    interval: "month",
    interval_count: 1,
    trial_days: 30
})
    .then((plan) => {
        console.log(plan);
    })
    .catch((err) => {
        console.log("err: " + err);
    });

Retrieve

epayco.plans.get("id_plan")
    .then((plan) => {
        console.log(plan);
    })
    .catch((err) => {
        console.log("err: " + err);
    });

List

epayco.plans.list()
    .then((plans) => {
        console.log(plans);
    })
    .catch((err) => {
        console.log("err: " + err);
    });

Remove

epayco.plans.delete("id_plan")
    .then((plan) => {
        console.log(plan);
    })
    .catch((err) => {
        console.log("err: " + err);
    });

Subscriptions

Create

epayco.subscriptions.create({
    id_plan: "-id_plan",
    customer: "id_customer",
    token_card: "id_token",
    doc_type: "CC",
    doc_number: "5234567"
})
    .then((subscription) => {
        console.log(subscription);
    })
    .catch((err) => {
        console.log("err: " + err);
    });

Retrieve

epayco.subscriptions.get("id_subscription")
    .then((subscription) => {
        console.log(subscription);
    })
    .catch((err) => {
        console.log("err: " + err);
    });

List

epayco.subscriptions.list()
    .then((subscriptions) => {
        console.log(subscriptions);
    })
    .catch((err) => {
        console.log("err: " + err);
    });

Cancel

epayco.subscriptions.cancel("id_subscription")
    .then((subscription) => {
        console.log(subscription);
    })
    .catch((err) => {
        console.log("err: " + err);
    });

Pay Subscription

epayco.subscriptions.charge({
    id_plan: "-id_plan",
    customer: "id_customer",
    token_card: "id_token",
    doc_type: "CC",
    doc_number: "5234567"
})
    .then((subscription) => {
        console.log(subscription);
    })
    .catch((err) => {
        console.log("err: " + err);
    });

PSE

Create

epayco.bank.create({
    bank: "1022",
    invoice: "1472050778",
    description: "pay test",
    value: "10000",
    tax: "0",
    tax_base: "0",
    currency: "COP",
    type_person: "0",
    doc_type: "CC",
    doc_number: "10358519",
    name: "testing",
    last_name: "PAYCO",
    email: "[email protected]",
    country: "CO",
    cell_phone: "3010000001",
    url_response: "https:/secure.payco.co/restpagos/testRest/endpagopse.php",
    url_confirmation: "https:/secure.payco.co/restpagos/testRest/endpagopse.php",
    method_confirmation: "GET",
})
    .then((bank) => {
        console.log(bank);
    })
    .catch((err) => {
        console.log("err: " + err);
    });

Retrieve

epayco.bank.get("transaction_id")
    .then((bank) => {
        console.log(bank);
    })
    .catch((err) => {
        console.log("err: " + err);
    });

Cash

Create

epayco.cash.create("efecty", {
    invoice: "1472050778",
    description: "pay test",
    value: "20000",
    tax: "0",
    tax_base: "0",
    currency: "COP",
    type_person: "0",
    doc_type: "CC",
    doc_number: "10358519",
    name: "testing",
    last_name: "PAYCO",
    email: "[email protected]",
    cell_phone: "3010000001",
    end_date: "2017-12-05",
    url_response: "https:/secure.payco.co/restpagos/testRest/endpagopse.php",
    url_confirmation: "https:/secure.payco.co/restpagos/testRest/endpagopse.php",
    method_confirmation: "GET",
})
    .then((cash) => {
        console.log(cash);
    })
    .catch((err) => {
        console.log("err: " + err);
    });

Retrieve

epayco.cash.get("transaction_id")
    .then((cash) => {
        console.log(cash);
    })
    .catch((err) => {
        console.log("err: " + err);
    });

Payment

Create

```javascript`git epayco.charge.create({ token_card: "token_id", customer_id: "customer_id", doc_type: "CC", doc_number: "1035851980", name: "John", last_name: "Doe", email: "[email protected]", bill: "OR-1234", description: "Test Payment", value: "116000", tax: "16000", tax_base: "100000", currency: "COP", dues: "12" }) .then((charge) => { console.log(charge); }) .catch((err) => { console.log("err: " + err); });


#### Retrieve

```javascript
epayco.charge.get("transaction_id")
    .then((charge) => {
        console.log(charge);
    })
    .catch((err) => {
        console.log("err: " + err);
    });

epayco-js's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

crorodriguezro

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.