npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

loopback-component-openpay

v0.0.3

Published

Loopback component to work with openpay platform.

Downloads

15

Readme

loopback-component-openpay

LoopBack component to use openpay platform.

Description

loopback-component-openpay is a package to wrap openpay package inside a loopback app. After installation you will notice important changes in your application:

  • New models created:
    • card
    • customer
    • request_openpay

Getting ready

This component is meant to be used inside a loopback application, there is no point to use it in any other kind of application.

Dependencies

In order to work with openpay you need to install the corresponding package:

npm install --save openpay

Environment variables

Set the following environment variables to work with openpay platform

export MERCHANT_ID="your merchant id"
export MERCHANT_SK="your merchant secret key"

Enabling the component

In order to use this component you need to enable it as any other component. Edit the file project-dir/server/component-config.json and include the configuration below.

{
  "loopback-component-openpay": {
     "isProduction": "boolean"
   }
}

isProduction will help you to indicate if you are in production mode.

Enabling models

As you may notice there is new models generated after installation of this component, to start using "geoposition" model just enable it as any other model. Edit the file project-dir/server/model-config.json and include it.

{
  "card": {
    "dataSource": "<datasource>",
    "public": true
  },
  "customer": {
      "dataSource": "<datasource>",
      "public": true
  },
  "request_openpay": {
      "dataSource": "<datasource>",
      "public": true
  }
}

Remember to put the datasource of your preference.

Features availables

Create cards and customers.

There is a hook before creating cards and customers which will allow you to store on your database those models after a successfully post on openpay platform. It will watch a common post to create card and/or customer models.

Request to create a card POST /api/cards ,most include structure below.

{
   "card_number": "number",
   "holder_name": "string",
   "expiration_year": "number",
   "expiration_month": "number",
   "cvv2": "number",
   "customer_id": "string" 
}

WARNING: Include customer_id field with string value if you want to create a card for an specific customer. The customer_id is the one given by the openpay platform.

Request to create a customer POST /api/customers ,most include structure below.

{
   "name": "string",
   "email": "string"
}

INFO: Include requires_account field with boolean value, set false value if you need to create the customer without an account to manage the balance. It will take true as default value.

Charges

There is remote methods/endpoints to create a charge for your merchant or for an specific customer.

Request to create a charge for a customer: POST /api/request_openpays/customerCharge, most include the structure below.

{
   "customer_id": "string",
   "source_id": "string", 
   "amount": "number",
   "description": "string",
   "device_session_id": "string"
}

WARNING: Field source_id is the saved ID card or token id created from where the funds are withdrawn. WARNING: Field device_session_id is the identifier of the device generated by the anti fraud tool.

Request to create a charge for a merchant POST /api/request_openpays/merchantCharge ,most include structure below.

{
   "source_id": "string", 
   "amount": "number",
   "description": "string",
   "device_session_id": "string",
   "customer": "object"
}

INFO: Field customer is the Customer information who is charged. You can use the same parameters used in the creation of a customer but an account for the customer will not be created.