forked from gazaret/react-native-cloudpayments
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
50 lines (42 loc) · 1.29 KB
/
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
46
47
48
49
50
import { NativeModules } from 'react-native';
const RNCloudPaymentsModule = NativeModules.RNCloudPayments;
export default class RNCloudPayments {
static async isValidCard(cardNumber, cardExp, cardCvv) {
try {
return await RNCloudPaymentsModule.isValidNumber(cardNumber, cardExp, cardCvv);
} catch(error) {
return createError(error);
}
}
static async getType(cardNumber, cardExp, cardCvv) {
try {
return await RNCloudPaymentsModule.getType(cardNumber, cardExp, cardCvv);
} catch(error) {
return createError(error);
}
}
static async createCryptogram(cardNumber, cardExp, cardCvv, publicId) {
try {
return await RNCloudPaymentsModule.createCryptogram(cardNumber, cardExp, cardCvv, publicId);
} catch(error) {
return createError(error);
}
}
static async show3DSForm(acsUrl, transactionId, paReq) {
try {
return await RNCloudPaymentsModule.show3DSForm(acsUrl, transactionId, paReq);
} catch(error) {
return createError(error);
}
}
}
class RNCloudPaymentsError extends Error {
constructor(details) {
super();
this.name = 'RNCloudPaymentsError';
this.message = typeof details === 'string' ? details : details.message;
}
}
function createError(error) {
return new RNCloudPaymentsError(error);
}