conekta-react-native

React Native Conekta wrapper

Usage no npm install needed!

<script type="module">
  import conektaReactNative from 'https://cdn.skypack.dev/conekta-react-native';
</script>

README

Conekta React Native banner

Conekta React Native npm version Swift Version

Conekta online payment processing platform on React Native

Currently iOS only

Installation

yarn add conekta-react-native # or npm i

Link the module

react-native link conekta-react-native

iOS Notes

Check that the Libraries group in Xcode have RNConekta and the project settings include libRNConekta in Linked Frameworks and Libraries. See Manual Linking.

Important. Since this module uses Swift, and RN projects are based in Obj-C, add an empty Swift file inside your project (no bridging header required), this will remove linked Xcode error. See related Stack Overflow Post

Usage

With async/await:

const conekta = new Conekta('key_KJysdbf6PotS2ut2')

const card = conekta.createCard({
  number: '4242424242424242',
  name: 'Julian Ceballos',
  cvc: '123',
  expMonth: '10',
  expYear: '2018',
})

try {
  const data = await card.createToken()
  console.log('DATA', data)
} catch (error) {
  console.log('ERROR', error)
}

Or if you prefer promises:

const conekta = new Conekta("key_KJysdbf6PotS2ut2");

const card = conekta.createCard({
  number: "4242424242424242",
  name: "Julian Ceballos",
  cvc: "123",
  expMonth: "10",
  expYear: "2018"
});

card
  .createToken()
  .then(data => {
    console.log("DATA", data);
  })
  .catch(error => {
    console.log("ERROR", error);
  });

TODO

  • Android version
  • Optimization
  • Testing

Please feel free to post a PR

Licence

MIT