connector-openpay-mx

0.1.4 • Public • Published

Features

  • Package that allows us to connect to OpenPay Mexico and make use of the following resources.

Installation

$ npm install connector-openpay-mx

Basic

The ctx (context) you assign can be sandbox or production in case of not sending it, the default ctx (context) is sandbox to make the connection to OpenPay Mexico.
The merchant is an object to which the id, private_key, public_key of the OpenPay Mexico merchant must be sent.

Examples

Get Merchant

const OpenpayMX = require('connector-openpay-mx');

const merchant = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    }
};

OpenPayMx.getMerchant(merchant).then(resolve => {
    //..
});

Create Customer

const OpenpayMX = require('connector-openpay-mx');

const params = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    },
    customer: {
        external_id: "0f29d777-8fe8-4891-99e6-00",
        name: "Quiniela King",
        email: "mauro.sanchez.simental@gmail.com",
        requires_account: false,
        phone_number: "3321594848"
    }
}

OpenPayMx.createCustomer(params).then(resolve => {
    //..
});

Update Customer

const OpenpayMX = require('connector-openpay-mx');

const params = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    },
    customerId: "axrpe1svywlkfl9w7rhr",
    customer : {
        name: "Paco",
        email: "mauro.sanchez.simental@gmail.com",
        phone_number: "3325414963"
    }
}

OpenPayMx.updateCustomer(params).then(resolve => {
    //..
});

Get Customer

const OpenpayMX = require('connector-openpay-mx');

const params = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    },
    customerId: "axrpe1svywlkfl9w7rhr"
}

OpenPayMx.getCustomer(params).then(resolve => {
    //..
});

Get Customers

const OpenpayMX = require('connector-openpay-mx');

const params = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    },
    searchParams: {
        limit : 10
    }
}

OpenPayMx.getCustomers(params).then(resolve => {
    //..
});

Delete Customer

const OpenpayMX = require('connector-openpay-mx');

const params = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    },
    customerId: "ap7xkc6i9gfbr1dciq0k"
}

OpenPayMx.deleteCustomer(params).then(resolve => {
    //..
});

Create Bank Account

const OpenpayMX = require('connector-openpay-mx');

const params = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    },
    customerId: "ap7xkc6i9gfbr1dciq0k",
    bankAccount: {
        clabe : "032180000118359719",
        alias : "Cuenta principal",
        holder_name : "Juan Hernández Sánchez"
    }
}

OpenPayMx.createBankAccount(params).then(resolve => {
    //..
});

Delete Bank Account

const OpenpayMX = require('connector-openpay-mx');

const params = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    },
    customerId: "alq8azwq8njbwijtrlty",
    bankaccountId: "bhsxm0yecxqg42x10zsw"
}

OpenPayMx.deleteBankAccount(params).then(resolve => {
    //..
});

Get Bank Account

const OpenpayMX = require('connector-openpay-mx');

const params = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    },
    customerId: "atxunufmfqpfyoklxten",
    bankaccountId: "bcwktkrrfxbzntzpcd53"
}

OpenPayMx.getBankAccount(params).then(resolve => {
    //..
});

Get Bank Accounts

const OpenpayMX = require('connector-openpay-mx');

const params = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    },
    customerId: "atxunufmfqpfyoklxten"
}

OpenPayMx.getBankAccounts(params).then(resolve => {
    //..
});

Create Card

const OpenpayMX = require('connector-openpay-mx');

const params = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    },
    customerId: "a1a3laf931xnckwbfq8j",
    cardRequest : {
        token_id : "ki6xlyzpyqsskmdwplb7",
        device_session_id : "Mddr8BGbgLQ9VnzkjoUcciAyDOBSfDJf"
    }
}

OpenPayMx.createCard(params).then(resolve => {
    //..
});

Delete Card

const OpenpayMX = require('connector-openpay-mx');

const params = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    },
    customerId: "a1a3laf931xnckwbfq8j",
    cardId: "k8tqzqvwfuhoc3vd7fqe"
}

OpenPayMx.deleteCard(params).then(resolve => {
    //..
});

Get Card

const OpenpayMX = require('connector-openpay-mx');

const params = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    },
    customerId: "ajkq3sxihfoszmbemk48",
    cardId: "kb5k2fdgrty0kybbshh7",
}

OpenPayMx.getCard(params).then(resolve => {
    //..
});

Get Cards

const OpenpayMX = require('connector-openpay-mx');

const params = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    },
    customerId: "ajkq3sxihfoszmbemk47",
    searchParams: {
        limit: 3
    }
}

OpenPayMx.getCards(params).then(resolve => {
    //..
});

Create WebHook

const OpenpayMX = require('connector-openpay-mx');

const params = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    },
    webhook: {
        url: "https://requestb.in/11vxrsf1",
        user: "juanito",
        password: "passjuanito",
        event_types: [
            "charge.refunded",
            "charge.failed",
            "charge.cancelled",
            "charge.created",
            "chargeback.accepted"
        ]
    }
}

OpenPayMx.createWebHook(params).then(resolve => {
    //..
});

Delete WebHook

const OpenpayMX = require('connector-openpay-mx');

const params = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    },
    webhookId: "wxvanstudf4ssme8khmc"
}

OpenPayMx.deleteWebHook(params).then(resolve => {
    //..
});

Get WebHook

const OpenpayMX = require('connector-openpay-mx');

const params = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    },
    webhookId: "wxvanstudf4ssme8khmc"
}

OpenPayMx.getWebHook(params).then(resolve => {
    //..
});

Get WebHooks

const OpenpayMX = require('connector-openpay-mx');

const params = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    }
}

OpenPayMx.getWebHooks(params).then(resolve => {
    //..
});

Create Bank Charge

const OpenpayMX = require('connector-openpay-mx');

const params = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    },
    customerId: "axrpe1svywlkfl9w7rhr",
    bankChargeRequest: {
        method: "bank_account",
        amount: 100,
        description: "Cargo con banco",
        order_id: "oid-00055"
    }
}

OpenPayMx.createBankCharge(params).then(resolve => {
    //..
});

Create Store Charge

const OpenpayMX = require('connector-openpay-mx');

const params = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    },
    customerId: "axrpe1svywlkfl9w7rhr",
    storeChargeRequest : {
        method: "store",
        amount: 100,
        description: "Cargo con tienda",
        order_id: "oid-00053",
        due_date: "2014-05-28T13:45:00"
    }
}

OpenPayMx.createStoreCharge(params).then(resolve => {
    //..
});

Create Card Charge

const OpenpayMX = require('connector-openpay-mx');

const params = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    },
    customerId: "axrpe1svywlkfl9w7rhr",
    chargeRequest : {
        source_id: "kqgykn96i7bcs1wwhvgw",
        method: "card",
        amount: 100,
        currency: "MXN",
        description: "Cargo inicial a mi cuenta",
        order_id: "oid-00051",
        device_session_id: "kR1MiQhz2otdIuUlQkbEyitIqVMiI16f"
    }
}

OpenPayMx.createCardCharge(params).then(resolve => {
    //..
});

Can Confirm Charge

const OpenpayMX = require('connector-openpay-mx');

const params = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    },
    customerId: "axrpe1svywlkfl9w7rhr",
    transactionId: "tryqihxac3msedn4yxed",
    captureRequest : {
        "amount": 100.00
    }
}

OpenPayMx.canConfirmCharge(params).then(resolve => {
    //..
});

Get Charge

const OpenpayMX = require('connector-openpay-mx');

const params = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    },
    customerId: "axrpe1svywlkfl9w7rhr",
    transactionId: "tryqihxac3msedn4yxed"
}

OpenPayMx.getCharge(params).then(resolve => {
    //..
});

Create Payment

const OpenpayMX = require('connector-openpay-mx');

const params = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    },
    customerId: "axrpe1svywlkfl9w7rhr",
    payoutRequest : {
        method: "bank_account",
        destination_id: "b3d54sd3mdjf75udjfvoc",
        amount: 10.50,
        description: "Retiro de saldo semanal",
        order_id: "oid-00021"
    }
}

OpenPayMx.createPayment(params).then(resolve => {
    //..
});

Get Payment

const OpenpayMX = require('connector-openpay-mx');

const params = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    },
    customerId: "axrpe1svywlkfl9w7rhr",
    transactionId: "tr6cxbcefzatd10guvvw"
}

OpenPayMx.getPayment(params).then(resolve => {
    //..
});

Create Plan

const OpenpayMX = require('connector-openpay-mx');

const params = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    },
    planRequest : {
        amount: 150.00,
        status_after_retry: "cancelled",
        retry_times: 2,
        name: "Curso de ingles",
        repeat_unit: "month",
        trial_days: "30",
        repeat_every: "1"
    }
}

OpenPayMx.createPlan(params).then(resolve => {
    //..
});

Get Plan

const OpenpayMX = require('connector-openpay-mx');

const params = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    },
    planId: "p8e6x3hafqqsbmnoevrt"
}

OpenPayMx.getPlan(params).then(resolve => {
    //..
});

Get Plans

const OpenpayMX = require('connector-openpay-mx');

const params = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    },
    searchParams: {
        limit: 10
    }
}

OpenPayMx.getPlans(params).then(resolve => {
    //..
});

Create Subscription

const OpenpayMX = require('connector-openpay-mx');

const params = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    },
    customerId: "axrpe1svywlkfl9w7rhr",
    subscriptionRequest : {
        plan_id: "pbi4kb8hpb64x0uud2eb",
        source_id : "kqgykn96i7bcs1wwhvgw",
        trial_end_date: "2020-01-11"
    }
}

OpenPayMx.createSubscription(params).then(resolve => {
    //..
});

Update Subscription

const OpenpayMX = require('connector-openpay-mx');

const params = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    },
    customerId: "axrpe1svywlkfl9w7rhr",
    subscriptionId: "s0gmyor4yqtyv1miqwr0",
    subscriptionRequest : {
        source_id : "kqgykn96i7bcs1wwhvgw",
        trial_end_date: "2021-01-11"
    }
}

OpenPayMx.updateSubscription(params).then(resolve => {
    //..
});

Delete Subscription

const OpenpayMX = require('connector-openpay-mx');

const params = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    },
    customerId: "axrpe1svywlkfl9w7rhr",
    subscriptionId: "s0gmyor4yqtyv1miqwr0"
}

OpenPayMx.deleteSubscription(params).then(resolve => {
    //..
});

Get Subscription

const OpenpayMX = require('connector-openpay-mx');

const params = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    },
    customerId: "axrpe1svywlkfl9w7rhr",
    subscriptionId: "s0gmyor4yqtyv1miqwr0"
}

OpenPayMx.getSubscription(params).then(resolve => {
    //..
});

Get Subscriptions

const OpenpayMX = require('connector-openpay-mx');

const params = {
    ctx: "sandbox",
    merchant: {
        id: "mXXXXXXXXXXXXXXXXXXX",
        private_key: "sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        public_key: "pk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    },
    customerId: "axrpe1svywlkfl9w7rhr",
    searchParams : {
        limit: 2
    }
}

OpenPayMx.getSubscriptions(params).then(resolve => {
    //..
});

Official documentation Openpay México

End

Package Sidebar

Install

npm i connector-openpay-mx

Weekly Downloads

2

Version

0.1.4

License

MIT

Unpacked Size

37.9 kB

Total Files

8

Last publish

Collaborators

  • csmasanchez
  • vmaza
  • marcocarrillo