-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
107 lines (90 loc) · 2.73 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/* eslint-disable no-restricted-properties, no-caller */
import {
// findNodeHandle,
NativeModules,
} from 'react-native';
const { ACSquareSDK } = NativeModules;
function SquareSDKModule() { // es5 singleton
//
if (arguments.callee.singletonInstance) {
return arguments.callee.singletonInstance;
}
arguments.callee.singletonInstance = this;
this.hasInitialized = false;
this.initSdk =
function initSdk() {
if (/* __DEV__ != true && */this.hasInitialized !== true) {
this.hasInitialized = true;
return ACSquareSDK.initSdk();
}
return Promise.resolve();
};
this.hasInit =
function hasInit() {
if (this.hasInitialized) {
return ACSquareSDK.hasInit().then(res => res.hasInit);
}
return Promise.resolve(false);
};
this.requestPermissions =
function requestPermissions() {
return ACSquareSDK.requestPermissions();
};
this.isLoggedIn =
function isLoggedIn() {
return ACSquareSDK.isLoggedIn().then(res => res.isLoggedIn);
};
this.authorizeWithCode =
function authorizeWithCode(deviceCode) {
return ACSquareSDK.authorizeWithCode(deviceCode);
};
this.deauthorize =
function deauthorize() {
return ACSquareSDK.deauthorize();
};
this.checkoutWithAmount =
function checkoutWithAmount(cents, note) {
return ACSquareSDK.checkoutWithAmount(cents, note || '');
};
this.getAuthorizedLocation =
function getAuthorizedLocation() {
return ACSquareSDK.getAuthorizedLocation();
};
this.presentReaderSettingsScreen =
function presentReaderSettingsScreen() {
return ACSquareSDK.presentReaderSettingsScreen();
};
this.setCheckoutParameters = function setCheckoutParameters(
additionalPaymentTypes,
tipPercentages,
tipsEnabled = true,
customTipFieldVisible = false,
separateTipScreenVisible = false,
skipReceipt = false,
alwaysRequireSignature = false,
allowSplitTender = false,
) {
return ACSquareSDK.setCheckoutParameters(
tipsEnabled,
customTipFieldVisible,
tipPercentages,
separateTipScreenVisible,
skipReceipt,
alwaysRequireSignature,
allowSplitTender,
additionalPaymentTypes || 0,
).catch((e) => {
// eslint-disable-next-line
console.log(`ACSquareSDK.setCheckoutParameters err: ${e}`);
});
};
// this.setTenderType = function setTenderType(tenderType) {
// return ACSquareSDK.setTenderType(tenderType);
// };
}
SquareSDKModule.AdditionalPaymentTypes = {
MANUAL_CARD_ENTRY: ACSquareSDK.SQRDAdditionalPaymentTypeManualCardEntry,
CASH: ACSquareSDK.SQRDAdditionalPaymentTypeCash,
OTHER: ACSquareSDK.SQRDAdditionalPaymentTypeOther,
};
module.exports = SquareSDKModule;