react-native-bootpay-api 4.1.2 → 4.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/index.js +4 -0
- package/lib/Bootpay.d.ts +43 -0
- package/lib/Bootpay.d.ts.map +1 -0
- package/lib/Bootpay.js +413 -0
- package/lib/BootpayModal.d.ts +72 -0
- package/lib/BootpayModal.d.ts.map +1 -0
- package/lib/BootpayModal.js +710 -0
- package/lib/BootpayShared.d.ts +1 -0
- package/lib/BootpayShared.d.ts.map +1 -0
- package/lib/BootpayShared.js +1 -0
- package/lib/BootpayTypes.d.ts +97 -0
- package/lib/BootpayTypes.d.ts.map +1 -0
- package/lib/BootpayTypes.js +69 -0
- package/{src → lib}/UserInfo.d.ts +2 -3
- package/lib/UserInfo.d.ts.map +1 -0
- package/lib/UserInfo.js +136 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +5 -0
- package/package.json +47 -52
- package/react-native-bootpay-api.podspec +20 -0
- package/react-native.config.js +34 -0
- package/images/close.png +0 -0
- package/src/BootpayAnalytics.js +0 -130
- package/src/BootpayWebView.js +0 -440
- package/src/UserInfo.d.ts.map +0 -1
- package/src/UserInfo.js +0 -67
- package/src/UserInfo.tsx +0 -78
- package/src/index.d.ts +0 -11
- package/src/index.js +0 -6
package/README.md
CHANGED
package/index.js
ADDED
package/lib/Bootpay.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import WebView, { WebViewMessageEvent } from 'react-native-webview-bootpay';
|
|
3
|
+
import { BootpayTypesProps, Payload, Extra, Item, User } from './BootpayTypes';
|
|
4
|
+
export declare class Bootpay extends Component<BootpayTypesProps> {
|
|
5
|
+
webView: React.RefObject<WebView>;
|
|
6
|
+
constructor(props: BootpayTypesProps);
|
|
7
|
+
payload?: Payload;
|
|
8
|
+
state: {
|
|
9
|
+
visibility: boolean;
|
|
10
|
+
script: string;
|
|
11
|
+
firstLoad: boolean;
|
|
12
|
+
showCloseButton: boolean;
|
|
13
|
+
};
|
|
14
|
+
_VERSION: string;
|
|
15
|
+
_DEBUG: boolean;
|
|
16
|
+
dismiss: () => void;
|
|
17
|
+
closeDismiss: () => void;
|
|
18
|
+
onMessage: (event: WebViewMessageEvent) => void;
|
|
19
|
+
onShouldStartLoadWithRequest: (_: string) => boolean;
|
|
20
|
+
getSDKVersion: () => string;
|
|
21
|
+
getEnvironmentMode: () => "" | "Bootpay.setEnvironmentMode('development');";
|
|
22
|
+
getBootpayPlatform: () => "" | "Bootpay.setDevice('IOS');" | "Bootpay.setDevice('ANDROID');";
|
|
23
|
+
transactionConfirm: () => void;
|
|
24
|
+
removePaymentWindow: () => void;
|
|
25
|
+
callJavaScript: (script: string) => void;
|
|
26
|
+
getAnalyticsData: () => Promise<string>;
|
|
27
|
+
confirm: () => string;
|
|
28
|
+
done: () => string;
|
|
29
|
+
issued: () => string;
|
|
30
|
+
error: () => string;
|
|
31
|
+
cancel: () => string;
|
|
32
|
+
close: () => string;
|
|
33
|
+
componentWillUnmount(): Promise<void>;
|
|
34
|
+
componentDidMount(): void;
|
|
35
|
+
render(): JSX.Element;
|
|
36
|
+
requestPayment: (payload: Payload, items: [Item], user: User, extra: Extra) => Promise<void>;
|
|
37
|
+
requestSubscription: (payload: Payload, items: [Item], user: User, extra: Extra) => Promise<void>;
|
|
38
|
+
requestAuthentication: (payload: Payload, items: [Item], user: User, extra: Extra) => Promise<void>;
|
|
39
|
+
bootpayRequest: (payload: Payload, items: [Item], user: User, extra: Extra, requestMethod: string) => Promise<void>;
|
|
40
|
+
getMountJavascript: () => Promise<string>;
|
|
41
|
+
generateScript: (payload: Payload, requestMethod: string) => string;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=Bootpay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Bootpay.d.ts","sourceRoot":"","sources":["../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AsBvG;IAGD,kBAAkB,wBAQjB;IAGD,cAAc,YAAY,OAAO,iBAAiB,MAAM,YAavD;CAEJ"}
|
package/lib/Bootpay.js
ADDED
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
26
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
27
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
28
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
29
|
+
function step(op) {
|
|
30
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
31
|
+
while (_) try {
|
|
32
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
33
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
34
|
+
switch (op[0]) {
|
|
35
|
+
case 0: case 1: t = op; break;
|
|
36
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
37
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
38
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
39
|
+
default:
|
|
40
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
41
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
42
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
43
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
44
|
+
if (t[2]) _.ops.pop();
|
|
45
|
+
_.trys.pop(); continue;
|
|
46
|
+
}
|
|
47
|
+
op = body.call(thisArg, _);
|
|
48
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
49
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
import React, { Component } from 'react';
|
|
53
|
+
import { SafeAreaView, Modal, TouchableOpacity, Image, StyleSheet, Platform } from 'react-native';
|
|
54
|
+
// import { StyleSheet, Platform } from 'react-native';
|
|
55
|
+
// import { Platform, StyleSheet, Dimensions } from 'react-native';
|
|
56
|
+
import WebView from 'react-native-webview-bootpay';
|
|
57
|
+
import { debounce } from 'lodash';
|
|
58
|
+
import UserInfo from './UserInfo';
|
|
59
|
+
var Bootpay = /** @class */ (function (_super) {
|
|
60
|
+
__extends(Bootpay, _super);
|
|
61
|
+
function Bootpay(props) {
|
|
62
|
+
var _this = _super.call(this, props) || this;
|
|
63
|
+
_this.state = {
|
|
64
|
+
visibility: false,
|
|
65
|
+
script: '',
|
|
66
|
+
firstLoad: false,
|
|
67
|
+
showCloseButton: false
|
|
68
|
+
};
|
|
69
|
+
// _payload = {}
|
|
70
|
+
_this._VERSION = "4.1.5";
|
|
71
|
+
_this._DEBUG = false;
|
|
72
|
+
_this.dismiss = function () {
|
|
73
|
+
_this.setState({
|
|
74
|
+
visibility: false
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
_this.closeDismiss = function () {
|
|
78
|
+
if (_this.props.onClose != undefined)
|
|
79
|
+
_this.props.onClose();
|
|
80
|
+
_this.dismiss();
|
|
81
|
+
};
|
|
82
|
+
_this.onMessage = function (event) {
|
|
83
|
+
var _a, _b, _c, _d;
|
|
84
|
+
if (event == undefined)
|
|
85
|
+
return;
|
|
86
|
+
var res = JSON.parse(JSON.stringify(event.nativeEvent.data));
|
|
87
|
+
if (res == 'close') {
|
|
88
|
+
_this.closeDismiss();
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
var data = JSON.parse(res);
|
|
92
|
+
// console.log(`redirect: ${JSON.stringify(data)}`);
|
|
93
|
+
var redirect = false;
|
|
94
|
+
var show_success = false;
|
|
95
|
+
var show_error = false;
|
|
96
|
+
if (((_a = _this.payload) === null || _a === void 0 ? void 0 : _a.extra) != undefined) {
|
|
97
|
+
if (((_b = _this.payload.extra) === null || _b === void 0 ? void 0 : _b.open_type) == 'redirect') {
|
|
98
|
+
redirect = true;
|
|
99
|
+
}
|
|
100
|
+
if (((_c = _this.payload.extra) === null || _c === void 0 ? void 0 : _c.display_error_result) == true) {
|
|
101
|
+
show_error = true;
|
|
102
|
+
}
|
|
103
|
+
if (((_d = _this.payload.extra) === null || _d === void 0 ? void 0 : _d.display_success_result) == true) {
|
|
104
|
+
show_success = true;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (redirect === true) {
|
|
108
|
+
switch (data.event) {
|
|
109
|
+
case 'cancel':
|
|
110
|
+
if (_this.props.onCancel != undefined)
|
|
111
|
+
_this.props.onCancel(data);
|
|
112
|
+
_this.closeDismiss();
|
|
113
|
+
break;
|
|
114
|
+
case 'error':
|
|
115
|
+
if (_this.props.onError != undefined)
|
|
116
|
+
_this.props.onError(data);
|
|
117
|
+
if (show_error == false) {
|
|
118
|
+
_this.closeDismiss();
|
|
119
|
+
}
|
|
120
|
+
break;
|
|
121
|
+
case 'issued':
|
|
122
|
+
if (_this.props.onIssued != undefined)
|
|
123
|
+
_this.props.onIssued(data);
|
|
124
|
+
if (show_success == false) {
|
|
125
|
+
_this.closeDismiss();
|
|
126
|
+
}
|
|
127
|
+
break;
|
|
128
|
+
case 'confirm':
|
|
129
|
+
if (_this.props.onConfirm != undefined)
|
|
130
|
+
_this.props.onConfirm(data);
|
|
131
|
+
break;
|
|
132
|
+
case 'done':
|
|
133
|
+
if (_this.props.onDone != undefined)
|
|
134
|
+
_this.props.onDone(data);
|
|
135
|
+
if (show_success == false) {
|
|
136
|
+
_this.closeDismiss();
|
|
137
|
+
}
|
|
138
|
+
break;
|
|
139
|
+
case 'close':
|
|
140
|
+
_this.closeDismiss();
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
switch (data.event) {
|
|
146
|
+
case 'cancel':
|
|
147
|
+
if (_this.props.onCancel != undefined)
|
|
148
|
+
_this.props.onCancel(data);
|
|
149
|
+
break;
|
|
150
|
+
case 'error':
|
|
151
|
+
if (_this.props.onError != undefined)
|
|
152
|
+
_this.props.onError(data);
|
|
153
|
+
break;
|
|
154
|
+
case 'issued':
|
|
155
|
+
if (_this.props.onIssued != undefined)
|
|
156
|
+
_this.props.onIssued(data);
|
|
157
|
+
break;
|
|
158
|
+
case 'confirm':
|
|
159
|
+
if (_this.props.onConfirm != undefined)
|
|
160
|
+
_this.props.onConfirm(data);
|
|
161
|
+
break;
|
|
162
|
+
case 'done':
|
|
163
|
+
if (_this.props.onDone != undefined)
|
|
164
|
+
_this.props.onDone(data);
|
|
165
|
+
break;
|
|
166
|
+
case 'close':
|
|
167
|
+
_this.closeDismiss();
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
_this.onShouldStartLoadWithRequest = function (_) {
|
|
173
|
+
return true;
|
|
174
|
+
};
|
|
175
|
+
_this.getSDKVersion = function () {
|
|
176
|
+
if (Platform.OS == 'ios') {
|
|
177
|
+
return "Bootpay.setVersion('" + _this._VERSION + "', 'ios_react_native')";
|
|
178
|
+
// return "Bootpay.setDevice('IOS');";
|
|
179
|
+
}
|
|
180
|
+
else if (Platform.OS == 'android') {
|
|
181
|
+
return "Bootpay.setVersion('" + _this._VERSION + "', 'android_react_native')";
|
|
182
|
+
// return "Bootpay.setDevice('ANDROID');";
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
return "";
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
_this.getEnvironmentMode = function () {
|
|
189
|
+
if (_this._DEBUG) {
|
|
190
|
+
return "Bootpay.setEnvironmentMode('development');";
|
|
191
|
+
}
|
|
192
|
+
return "";
|
|
193
|
+
};
|
|
194
|
+
_this.getBootpayPlatform = function () {
|
|
195
|
+
if (Platform.OS == 'ios') {
|
|
196
|
+
return "Bootpay.setDevice('IOS');";
|
|
197
|
+
}
|
|
198
|
+
else if (Platform.OS == 'android') {
|
|
199
|
+
return "Bootpay.setDevice('ANDROID');";
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
return "";
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
// setPayScript = () => {
|
|
206
|
+
// const fullScript = this.generateScript(this.state.script);
|
|
207
|
+
// this.injectJavaScript(fullScript);
|
|
208
|
+
// if(this.state.showCloseButton == true) {
|
|
209
|
+
// if(this.webView == null || this.webView == undefined) return;
|
|
210
|
+
// this.webView.showCloseButton();
|
|
211
|
+
// }
|
|
212
|
+
// }
|
|
213
|
+
_this.transactionConfirm = function () {
|
|
214
|
+
var script = "Bootpay.confirm()"
|
|
215
|
+
+
|
|
216
|
+
".then( function (res) {" +
|
|
217
|
+
_this.confirm() +
|
|
218
|
+
_this.issued() +
|
|
219
|
+
_this.done() +
|
|
220
|
+
"}, function (res) {" +
|
|
221
|
+
_this.error() +
|
|
222
|
+
_this.cancel() +
|
|
223
|
+
"})";
|
|
224
|
+
_this.callJavaScript(script);
|
|
225
|
+
};
|
|
226
|
+
_this.removePaymentWindow = function () {
|
|
227
|
+
_this.dismiss();
|
|
228
|
+
// this.callJavaScript(`
|
|
229
|
+
// Bootpay.removePaymentWindow();
|
|
230
|
+
// `);
|
|
231
|
+
};
|
|
232
|
+
_this.callJavaScript = function (script) {
|
|
233
|
+
var _a;
|
|
234
|
+
if (_this.webView == null || _this.webView == undefined)
|
|
235
|
+
return;
|
|
236
|
+
(_a = _this.webView.current) === null || _a === void 0 ? void 0 : _a.injectJavaScript("\n setTimeout(function() { ".concat(script, " }, 30);\n "));
|
|
237
|
+
};
|
|
238
|
+
_this.getAnalyticsData = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
239
|
+
var uuid, bootLastTime, elaspedTime;
|
|
240
|
+
return __generator(this, function (_a) {
|
|
241
|
+
switch (_a.label) {
|
|
242
|
+
case 0: return [4 /*yield*/, UserInfo.getBootpayUUID()];
|
|
243
|
+
case 1:
|
|
244
|
+
uuid = _a.sent();
|
|
245
|
+
return [4 /*yield*/, UserInfo.getBootpayLastTime()];
|
|
246
|
+
case 2:
|
|
247
|
+
bootLastTime = _a.sent();
|
|
248
|
+
elaspedTime = Date.now() - bootLastTime;
|
|
249
|
+
return [2 /*return*/, "window.Bootpay.$analytics.setAnalyticsData({uuid:'".concat(uuid, "', time:").concat(elaspedTime, "});")];
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
}); };
|
|
253
|
+
_this.confirm = function () {
|
|
254
|
+
return "if (res.event === 'confirm') { window.BootpayRNWebView.postMessage( JSON.stringify(res) ); }";
|
|
255
|
+
};
|
|
256
|
+
_this.done = function () {
|
|
257
|
+
return "else if (res.event === 'done') { window.BootpayRNWebView.postMessage( JSON.stringify(res) ); }";
|
|
258
|
+
};
|
|
259
|
+
_this.issued = function () {
|
|
260
|
+
return "else if (res.event === 'issued') { window.BootpayRNWebView.postMessage( JSON.stringify(res) ); }";
|
|
261
|
+
};
|
|
262
|
+
_this.error = function () {
|
|
263
|
+
return "if (res.event === 'error') { window.BootpayRNWebView.postMessage( JSON.stringify(res) ); }";
|
|
264
|
+
};
|
|
265
|
+
_this.cancel = function () {
|
|
266
|
+
return "else if (res.event === 'cancel') { window.BootpayRNWebView.postMessage( JSON.stringify(res) ); }";
|
|
267
|
+
};
|
|
268
|
+
_this.close = function () {
|
|
269
|
+
return "document.addEventListener('bootpayclose', function (e) { window.BootpayRNWebView.postMessage('close'); });";
|
|
270
|
+
};
|
|
271
|
+
_this.requestPayment = function (payload, items, user, extra) { return __awaiter(_this, void 0, void 0, function () {
|
|
272
|
+
return __generator(this, function (_a) {
|
|
273
|
+
this.bootpayRequest(payload, items, user, extra, "requestPayment");
|
|
274
|
+
return [2 /*return*/];
|
|
275
|
+
});
|
|
276
|
+
}); };
|
|
277
|
+
_this.requestSubscription = function (payload, items, user, extra) { return __awaiter(_this, void 0, void 0, function () {
|
|
278
|
+
return __generator(this, function (_a) {
|
|
279
|
+
this.bootpayRequest(payload, items, user, extra, "requestSubscription");
|
|
280
|
+
return [2 /*return*/];
|
|
281
|
+
});
|
|
282
|
+
}); };
|
|
283
|
+
_this.requestAuthentication = function (payload, items, user, extra) { return __awaiter(_this, void 0, void 0, function () {
|
|
284
|
+
return __generator(this, function (_a) {
|
|
285
|
+
this.bootpayRequest(payload, items, user, extra, "requestAuthentication");
|
|
286
|
+
return [2 /*return*/];
|
|
287
|
+
});
|
|
288
|
+
}); };
|
|
289
|
+
_this.bootpayRequest = function (payload, items, user, extra, requestMethod) { return __awaiter(_this, void 0, void 0, function () {
|
|
290
|
+
var _a, _b;
|
|
291
|
+
var _c;
|
|
292
|
+
return __generator(this, function (_d) {
|
|
293
|
+
switch (_d.label) {
|
|
294
|
+
case 0:
|
|
295
|
+
payload.application_id = Platform.OS == 'ios' ? this.props.ios_application_id : this.props.android_application_id;
|
|
296
|
+
payload.items = items;
|
|
297
|
+
payload.user = user;
|
|
298
|
+
payload.extra = extra;
|
|
299
|
+
this.payload = payload;
|
|
300
|
+
_a = this.setState;
|
|
301
|
+
_c = {
|
|
302
|
+
visibility: true
|
|
303
|
+
};
|
|
304
|
+
_b = "\n ".concat;
|
|
305
|
+
return [4 /*yield*/, this.getMountJavascript()];
|
|
306
|
+
case 1:
|
|
307
|
+
_a.apply(this, [(_c.script = _b.apply("\n ", [_d.sent(), " \n "]).concat(this.generateScript(payload, requestMethod), "\n "),
|
|
308
|
+
_c.firstLoad = false,
|
|
309
|
+
_c.showCloseButton = extra.show_close_button || false,
|
|
310
|
+
_c)]);
|
|
311
|
+
UserInfo.updateInfo();
|
|
312
|
+
return [2 /*return*/];
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
}); };
|
|
316
|
+
_this.getMountJavascript = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
317
|
+
var _a, _b;
|
|
318
|
+
return __generator(this, function (_c) {
|
|
319
|
+
switch (_c.label) {
|
|
320
|
+
case 0:
|
|
321
|
+
_b = (_a = "\n ".concat(this.getSDKVersion(), "\n ").concat(this.getEnvironmentMode(), "\n ").concat(this.getBootpayPlatform(), "\n ").concat(this.close(), "\n ")).concat;
|
|
322
|
+
return [4 /*yield*/, this.getAnalyticsData()];
|
|
323
|
+
case 1: return [2 /*return*/, _b.apply(_a, [_c.sent(), "\n "])];
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
}); };
|
|
327
|
+
_this.generateScript = function (payload, requestMethod) {
|
|
328
|
+
var script = "Bootpay." + requestMethod +
|
|
329
|
+
"(".concat(JSON.stringify(payload), ")") +
|
|
330
|
+
".then( function (res) {" +
|
|
331
|
+
_this.confirm() +
|
|
332
|
+
_this.issued() +
|
|
333
|
+
_this.done() +
|
|
334
|
+
"}, function (res) {" +
|
|
335
|
+
_this.error() +
|
|
336
|
+
_this.cancel() +
|
|
337
|
+
"}); void(0);";
|
|
338
|
+
return script;
|
|
339
|
+
};
|
|
340
|
+
_this.webView = React.createRef();
|
|
341
|
+
return _this;
|
|
342
|
+
}
|
|
343
|
+
Bootpay.prototype.componentWillUnmount = function () {
|
|
344
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
345
|
+
return __generator(this, function (_a) {
|
|
346
|
+
this.setState({
|
|
347
|
+
visibility: false,
|
|
348
|
+
firstLoad: false,
|
|
349
|
+
showCloseButton: false
|
|
350
|
+
});
|
|
351
|
+
UserInfo.setBootpayLastTime(Date.now());
|
|
352
|
+
return [2 /*return*/];
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
};
|
|
356
|
+
Bootpay.prototype.componentDidMount = function () {
|
|
357
|
+
this.closeDismiss = debounce(this.closeDismiss, 30);
|
|
358
|
+
};
|
|
359
|
+
Bootpay.prototype.render = function () {
|
|
360
|
+
var _this = this;
|
|
361
|
+
return (<Modal animationType={'slide'} transparent={false} onRequestClose={function () {
|
|
362
|
+
_this.closeDismiss();
|
|
363
|
+
// console.log(1234);
|
|
364
|
+
// this.dismiss();
|
|
365
|
+
}} visible={this.state.visibility}>
|
|
366
|
+
<SafeAreaView style={{ flex: 1 }}>
|
|
367
|
+
{this.state.showCloseButton &&
|
|
368
|
+
<TouchableOpacity onPress={function () {
|
|
369
|
+
var cancelData = {
|
|
370
|
+
action: 'BootpayCancel',
|
|
371
|
+
message: '사용자에 의해 취소되었습니다'
|
|
372
|
+
};
|
|
373
|
+
if (_this.props.onCancel != undefined)
|
|
374
|
+
_this.props.onCancel(cancelData);
|
|
375
|
+
if (_this.props.onClose != undefined)
|
|
376
|
+
_this.props.onClose();
|
|
377
|
+
_this.setState({ visibility: false });
|
|
378
|
+
}}>
|
|
379
|
+
<Image style={[styles.overlay]} source={require('../images/close.png')}/>
|
|
380
|
+
</TouchableOpacity>}
|
|
381
|
+
<WebView ref={this.webView} originWhitelist={['*']} source={{
|
|
382
|
+
uri: 'https://webview.bootpay.co.kr/4.1.5'
|
|
383
|
+
}} injectedJavaScript={this.state.script} javaScriptEnabled={true} javaScriptCanOpenWindowsAutomatically={true}
|
|
384
|
+
// scalesPageToFit={true}
|
|
385
|
+
onMessage={this.onMessage}/>
|
|
386
|
+
</SafeAreaView>
|
|
387
|
+
|
|
388
|
+
</Modal>);
|
|
389
|
+
};
|
|
390
|
+
return Bootpay;
|
|
391
|
+
}(Component));
|
|
392
|
+
export { Bootpay };
|
|
393
|
+
var styles = StyleSheet.create({
|
|
394
|
+
container: {
|
|
395
|
+
flex: 1,
|
|
396
|
+
justifyContent: 'center',
|
|
397
|
+
alignItems: 'center',
|
|
398
|
+
backgroundColor: '#F5FCFF'
|
|
399
|
+
},
|
|
400
|
+
welcome: {
|
|
401
|
+
fontSize: 20,
|
|
402
|
+
textAlign: 'center',
|
|
403
|
+
margin: 10
|
|
404
|
+
},
|
|
405
|
+
// Flex to fill, position absolute,
|
|
406
|
+
// Fixed left/top, and the width set to the window width
|
|
407
|
+
overlay: {
|
|
408
|
+
width: 25,
|
|
409
|
+
height: 25,
|
|
410
|
+
right: 5,
|
|
411
|
+
alignSelf: 'flex-end'
|
|
412
|
+
}
|
|
413
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import WebView, { WebViewMessageEvent } from 'react-native-webview-bootpay';
|
|
3
|
+
import { BootpayTypesProps, Payload, Extra, Item, User } from './BootpayTypes';
|
|
4
|
+
export declare class BootpayTemp extends Component<BootpayTypesProps> {
|
|
5
|
+
_VERSION: string;
|
|
6
|
+
_DEBUG: boolean;
|
|
7
|
+
webView: React.RefObject<WebView>;
|
|
8
|
+
state: {
|
|
9
|
+
visibility: boolean;
|
|
10
|
+
script: string;
|
|
11
|
+
firstLoad: boolean;
|
|
12
|
+
showCloseButton: boolean;
|
|
13
|
+
};
|
|
14
|
+
constructor(props: BootpayTypesProps);
|
|
15
|
+
dismiss: () => void;
|
|
16
|
+
closeDismiss: () => void;
|
|
17
|
+
onMessage: (event: WebViewMessageEvent) => void;
|
|
18
|
+
onShouldStartLoadWithRequest: (_: string) => boolean;
|
|
19
|
+
getSDKVersion: () => string;
|
|
20
|
+
getEnvironmentMode: () => "" | "Bootpay.setEnvironmentMode('development');";
|
|
21
|
+
getBootpayPlatform: () => "" | "Bootpay.setDevice('IOS');" | "Bootpay.setDevice('ANDROID');";
|
|
22
|
+
removePaymentWindow: () => void;
|
|
23
|
+
getAnalyticsData: () => Promise<string>;
|
|
24
|
+
confirm: () => string;
|
|
25
|
+
done: () => string;
|
|
26
|
+
issued: () => string;
|
|
27
|
+
error: () => string;
|
|
28
|
+
cancel: () => string;
|
|
29
|
+
close: () => string;
|
|
30
|
+
componentWillUnmount(): Promise<void>;
|
|
31
|
+
componentDidMount(): void;
|
|
32
|
+
render(): JSX.Element;
|
|
33
|
+
}
|
|
34
|
+
export declare class BootpayModal extends Component<BootpayTypesProps> {
|
|
35
|
+
webView: React.RefObject<WebView>;
|
|
36
|
+
constructor(props: BootpayTypesProps);
|
|
37
|
+
state: {
|
|
38
|
+
visibility: boolean;
|
|
39
|
+
script: string;
|
|
40
|
+
firstLoad: boolean;
|
|
41
|
+
showCloseButton: boolean;
|
|
42
|
+
};
|
|
43
|
+
_VERSION: string;
|
|
44
|
+
_DEBUG: boolean;
|
|
45
|
+
dismiss: () => void;
|
|
46
|
+
closeDismiss: () => void;
|
|
47
|
+
onMessage: (event: WebViewMessageEvent) => void;
|
|
48
|
+
onShouldStartLoadWithRequest: (_: string) => boolean;
|
|
49
|
+
getSDKVersion: () => string;
|
|
50
|
+
getEnvironmentMode: () => "" | "Bootpay.setEnvironmentMode('development');";
|
|
51
|
+
getBootpayPlatform: () => "" | "Bootpay.setDevice('IOS');" | "Bootpay.setDevice('ANDROID');";
|
|
52
|
+
transactionConfirm: () => void;
|
|
53
|
+
removePaymentWindow: () => void;
|
|
54
|
+
callJavaScript: (script: string) => void;
|
|
55
|
+
getAnalyticsData: () => Promise<string>;
|
|
56
|
+
confirm: () => string;
|
|
57
|
+
done: () => string;
|
|
58
|
+
issued: () => string;
|
|
59
|
+
error: () => string;
|
|
60
|
+
cancel: () => string;
|
|
61
|
+
close: () => string;
|
|
62
|
+
componentWillUnmount(): Promise<void>;
|
|
63
|
+
componentDidMount(): void;
|
|
64
|
+
render(): JSX.Element;
|
|
65
|
+
requestPayment: (payload: Payload, items: [Item], user: User, extra: Extra) => Promise<void>;
|
|
66
|
+
requestSubscription: (payload: Payload, items: [Item], user: User, extra: Extra) => Promise<void>;
|
|
67
|
+
requestAuthentication: (payload: Payload, items: [Item], user: User, extra: Extra) => Promise<void>;
|
|
68
|
+
bootpayRequest: (payload: Payload, items: [Item], user: User, extra: Extra, requestMethod: string) => Promise<void>;
|
|
69
|
+
getMountJavascript: () => Promise<string>;
|
|
70
|
+
generateScript: (payload: Payload, requestMethod: string) => string;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=BootpayModal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BootpayModal.d.ts","sourceRoot":"","sources":["../src/BootpayModal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIzC,OAAO,OAAO,EAAE,EAAC,mBAAmB,EAAC,MAAO,8BAA8B,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,KAA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