-
Notifications
You must be signed in to change notification settings - Fork 22
/
index.js
45 lines (38 loc) · 880 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* @providesModule Conekta
*/
'use strict';
// RNConekta
const RNConekta = require('react-native').NativeModules.RNConekta;
const Platform = require('react-native').Platform;
var Conekta = function() {
this.publicKey = false;
};
/**
* Params:
* publicKey: String (Your testing or production Public Key)
*/
Conekta.prototype.setPublicKey = function(publicKey: String) {
this.publicKey = publicKey;
};
/**
* Params:
* info = {
* cardNumber: String
* name: String
* cvc: String
* expMonth: String
* expYear: String
* }
*/
Conekta.prototype.createToken = function(info: Object, success: Function, error:Function) {
info.publicKey = this.publicKey;
RNConekta.createToken(info, function(response){
if ( Platform.OS === 'android' ) {
success( JSON.parse( response ) );
} else {
success( response );
}
}, error);
};
module.exports = Conekta;