Skip to content

alejandroBrb/react-native-conekta

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React Native Conekta npm version

React Native Conekta SDK for iOS and Android

Installation

npm install react-native-conekta

iOS Installation

Please see: Linking Libraries iOS

Library folder: your-project/node_modules/react-native-conekta/RNConekta

Android Installation

In android/settings.gradle

...

include ':react-native-conekta'
project(':react-native-conekta').projectDir = file('../node_modules/react-native-conekta/RNConektaAndroid')

In android/app/build.gradle

...

dependencies {
    ...

    compile project(':react-native-conekta')
}

Register module (in MainActivity.java)

import com.dieam.reactnativeconekta.ReactNativeConektaPackage;  // <--- import

public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {
  ......

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mReactRootView = new ReactRootView(this);

    mReactInstanceManager = ReactInstanceManager.builder()
      .setApplication(getApplication())
      .setBundleAssetName("index.android.bundle")
      .setJSMainModuleName("index.android")
      .addPackage(new MainReactPackage())
      .addPackage(new ReactNativeConektaPackage(this))// <------ add the package
      .setUseDeveloperSupport(BuildConfig.DEBUG)
      .setInitialLifecycleState(LifecycleState.RESUMED)
      .build();

    mReactRootView.startReactApplication(mReactInstanceManager, "ExampleApp", null);

    setContentView(mReactRootView);
  }

  ......

}

Usage

var conektaApi = new Conekta();

conektaApi.setPublicKey( 'YOUR_PUBLIC_KEY' );

conektaApi.createToken({
	cardNumber: '4242424242424242',
	name: 'Manolo Virolo',
	cvc: '111',
	expMonth: '11',
	expYear: '21',
}, function(data){
	console.log( 'DATA:', data ); // data.id to get the Token ID
}, function(){
	console.log( 'Error!' );
});

About

React Native Conekta SDK for iOS and Android

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Objective-C 73.0%
  • Java 21.0%
  • JavaScript 6.0%