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

conekta-capacitor

v0.0.22

Published

A Conekta plugin compatible with Capacitor 2.0

Downloads

7

Readme

conekta-capacitor

A Capacitor plugin for Conekta, that supports Capacitor 2.0

Supported platforms

The plugin supports JS, Android and iOS exposing the Conekta SDK functionalities. Here is the official Conekta documentation for the SDK's.

Installation

npm install -s conekta-capacitor

If you are working on a framework like Quasar, the package should be installed in the Quasar project and installed again in the capacitor project (inside src-capacitor), so you could use the JS implementation within Quasar and the native version within Capacitor's project. Here is a [Quasar example](link to quasar)

Note: Remember that after installation an npx cap sync call could be needed.

Extra steps for Android

As per the Capacitor docs the plugin should be added to the app MainActivity.

The next line should be added to your app MainActivity

add(com.villavanilla.conekta.capacitor.ConektaPlugin.class);

The full code should look something like this:

// Other imports...

public class MainActivity extends BridgeActivity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Initializes the Bridge
    this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
      // Additional plugins you've installed go here
      // Ex: add(TotallyAwesomePlugin.class);
      add(com.villavanilla.conekta.capacitor.ConektaPlugin.class);
    }});
  }
}

Usage

import { Plugins } from '@capacitor/core'
const { ConektaPlugin } = Plugins
import 'conekta-capacitor' /* This last import import is needed for web support */

/* Your code goes here */

Exposed methods:

ConektaPlugin.setPublicKey({ key: string }): Promise<void>;

ConektaPlugin.getPublicKey(): Promise<{ key: string }>;

ConektaPlugin.setLanguage({ language: string }): Promise<void>;

ConektaPlugin.getLanguage(): Promise<{ language: string }>;

ConektaPlugin.createToken({ number: string, name: string, cvc: string, exp_month: string, exp_year: string }): Promise<any>;

ConektaPlugin.setApiVersion({ api_version: string }): Promise<void>;

ConektaPlugin.getApiVersion(): Promise<{ api_version: string }>;

ConektaPlugin.deviceFingerPrint(): Promise<{ fingerprint: string }>

ConektaPlugin.getBaseUri(): Promise<{ uri: string }>;

The most important action is the token creation

Here is an example:

import { Plugins } from '@capacitor/core'
const { ConektaPlugin } = Plugins
import 'conekta-capacitor'

/**Some function body**/
ConektaPlugin.setPluginKey({key:"[YOUR_CONEKTA_KEY]"})
let card = {
        number: 'Card number',
        name: 'Card name',
        cvc: 'Card CVC',
        exp_month: 'Card expiration month',
        exp_year: 'Card expiration year',
      }

try{
let result = await ConektaPlugin.createToken(card)
/* Result schema
{
  id:String,
  livemode:Boolean,
  object: String | 'token',
  used: boolean
}
*/
console.log(`Here is your token: ${result.id}`)
}catch(error){
/* Error schema
{
  code:String
  message:String,
  message_to_purchaser:String,
  object:"error",
  type:String,
  validation_error:String
}
*/
console.log(error)
}