@dev_innovations_labs/phonepe-pg-sdk 1.0.1 → 1.0.2
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 -27
- package/dist/PhonePeReact.d.ts +4 -5
- package/dist/PhonePeReactNative.d.ts +4 -5
- package/dist/index.esm.js +17 -31
- package/dist/native.esm.js +482 -21
- package/dist/types.d.ts +1 -2
- package/dist/utils.d.ts +1 -2
- package/package.json +11 -39
- package/rollup.config.js +39 -22
- package/src/PhonePeNode.ts +15 -20
- package/src/PhonePeReact.tsx +15 -22
- package/src/PhonePeReactNative.tsx +23 -27
- package/src/env.ts +3 -3
- package/src/index.ts +1 -0
- package/src/native.ts +1 -0
- package/src/types/react-native-webview.d.ts +1 -4
- package/src/types.ts +1 -2
- package/src/utils.ts +2 -7
- package/tsconfig.json +8 -5
- package/dist/index.js +0 -142
- package/dist/native.js +0 -83
package/dist/native.esm.js
CHANGED
|
@@ -1,20 +1,487 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useState, useEffect } from 'react';
|
|
1
|
+
import require$$0, { useState, useEffect } from 'react';
|
|
3
2
|
import { WebView } from 'react-native-webview';
|
|
4
|
-
|
|
3
|
+
|
|
4
|
+
var jsxRuntime = {exports: {}};
|
|
5
|
+
|
|
6
|
+
var reactJsxRuntime_production = {};
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @license React
|
|
10
|
+
* react-jsx-runtime.production.js
|
|
11
|
+
*
|
|
12
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the MIT license found in the
|
|
15
|
+
* LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
var hasRequiredReactJsxRuntime_production;
|
|
19
|
+
|
|
20
|
+
function requireReactJsxRuntime_production () {
|
|
21
|
+
if (hasRequiredReactJsxRuntime_production) return reactJsxRuntime_production;
|
|
22
|
+
hasRequiredReactJsxRuntime_production = 1;
|
|
23
|
+
var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
|
|
24
|
+
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
|
|
25
|
+
function jsxProd(type, config, maybeKey) {
|
|
26
|
+
var key = null;
|
|
27
|
+
void 0 !== maybeKey && (key = "" + maybeKey);
|
|
28
|
+
void 0 !== config.key && (key = "" + config.key);
|
|
29
|
+
if ("key" in config) {
|
|
30
|
+
maybeKey = {};
|
|
31
|
+
for (var propName in config)
|
|
32
|
+
"key" !== propName && (maybeKey[propName] = config[propName]);
|
|
33
|
+
} else maybeKey = config;
|
|
34
|
+
config = maybeKey.ref;
|
|
35
|
+
return {
|
|
36
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
37
|
+
type: type,
|
|
38
|
+
key: key,
|
|
39
|
+
ref: void 0 !== config ? config : null,
|
|
40
|
+
props: maybeKey
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
reactJsxRuntime_production.Fragment = REACT_FRAGMENT_TYPE;
|
|
44
|
+
reactJsxRuntime_production.jsx = jsxProd;
|
|
45
|
+
reactJsxRuntime_production.jsxs = jsxProd;
|
|
46
|
+
return reactJsxRuntime_production;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
var reactJsxRuntime_development = {};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @license React
|
|
53
|
+
* react-jsx-runtime.development.js
|
|
54
|
+
*
|
|
55
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
56
|
+
*
|
|
57
|
+
* This source code is licensed under the MIT license found in the
|
|
58
|
+
* LICENSE file in the root directory of this source tree.
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
var hasRequiredReactJsxRuntime_development;
|
|
62
|
+
|
|
63
|
+
function requireReactJsxRuntime_development () {
|
|
64
|
+
if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
|
|
65
|
+
hasRequiredReactJsxRuntime_development = 1;
|
|
66
|
+
"production" !== process.env.NODE_ENV &&
|
|
67
|
+
(function () {
|
|
68
|
+
function getComponentNameFromType(type) {
|
|
69
|
+
if (null == type) return null;
|
|
70
|
+
if ("function" === typeof type)
|
|
71
|
+
return type.$$typeof === REACT_CLIENT_REFERENCE
|
|
72
|
+
? null
|
|
73
|
+
: type.displayName || type.name || null;
|
|
74
|
+
if ("string" === typeof type) return type;
|
|
75
|
+
switch (type) {
|
|
76
|
+
case REACT_FRAGMENT_TYPE:
|
|
77
|
+
return "Fragment";
|
|
78
|
+
case REACT_PROFILER_TYPE:
|
|
79
|
+
return "Profiler";
|
|
80
|
+
case REACT_STRICT_MODE_TYPE:
|
|
81
|
+
return "StrictMode";
|
|
82
|
+
case REACT_SUSPENSE_TYPE:
|
|
83
|
+
return "Suspense";
|
|
84
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
|
85
|
+
return "SuspenseList";
|
|
86
|
+
case REACT_ACTIVITY_TYPE:
|
|
87
|
+
return "Activity";
|
|
88
|
+
}
|
|
89
|
+
if ("object" === typeof type)
|
|
90
|
+
switch (
|
|
91
|
+
("number" === typeof type.tag &&
|
|
92
|
+
console.error(
|
|
93
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
94
|
+
),
|
|
95
|
+
type.$$typeof)
|
|
96
|
+
) {
|
|
97
|
+
case REACT_PORTAL_TYPE:
|
|
98
|
+
return "Portal";
|
|
99
|
+
case REACT_CONTEXT_TYPE:
|
|
100
|
+
return type.displayName || "Context";
|
|
101
|
+
case REACT_CONSUMER_TYPE:
|
|
102
|
+
return (type._context.displayName || "Context") + ".Consumer";
|
|
103
|
+
case REACT_FORWARD_REF_TYPE:
|
|
104
|
+
var innerType = type.render;
|
|
105
|
+
type = type.displayName;
|
|
106
|
+
type ||
|
|
107
|
+
((type = innerType.displayName || innerType.name || ""),
|
|
108
|
+
(type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef"));
|
|
109
|
+
return type;
|
|
110
|
+
case REACT_MEMO_TYPE:
|
|
111
|
+
return (
|
|
112
|
+
(innerType = type.displayName || null),
|
|
113
|
+
null !== innerType
|
|
114
|
+
? innerType
|
|
115
|
+
: getComponentNameFromType(type.type) || "Memo"
|
|
116
|
+
);
|
|
117
|
+
case REACT_LAZY_TYPE:
|
|
118
|
+
innerType = type._payload;
|
|
119
|
+
type = type._init;
|
|
120
|
+
try {
|
|
121
|
+
return getComponentNameFromType(type(innerType));
|
|
122
|
+
} catch (x) {}
|
|
123
|
+
}
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
function testStringCoercion(value) {
|
|
127
|
+
return "" + value;
|
|
128
|
+
}
|
|
129
|
+
function checkKeyStringCoercion(value) {
|
|
130
|
+
try {
|
|
131
|
+
testStringCoercion(value);
|
|
132
|
+
var JSCompiler_inline_result = !1;
|
|
133
|
+
} catch (e) {
|
|
134
|
+
JSCompiler_inline_result = true;
|
|
135
|
+
}
|
|
136
|
+
if (JSCompiler_inline_result) {
|
|
137
|
+
JSCompiler_inline_result = console;
|
|
138
|
+
var JSCompiler_temp_const = JSCompiler_inline_result.error;
|
|
139
|
+
var JSCompiler_inline_result$jscomp$0 =
|
|
140
|
+
("function" === typeof Symbol &&
|
|
141
|
+
Symbol.toStringTag &&
|
|
142
|
+
value[Symbol.toStringTag]) ||
|
|
143
|
+
value.constructor.name ||
|
|
144
|
+
"Object";
|
|
145
|
+
JSCompiler_temp_const.call(
|
|
146
|
+
JSCompiler_inline_result,
|
|
147
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
148
|
+
JSCompiler_inline_result$jscomp$0
|
|
149
|
+
);
|
|
150
|
+
return testStringCoercion(value);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function getTaskName(type) {
|
|
154
|
+
if (type === REACT_FRAGMENT_TYPE) return "<>";
|
|
155
|
+
if (
|
|
156
|
+
"object" === typeof type &&
|
|
157
|
+
null !== type &&
|
|
158
|
+
type.$$typeof === REACT_LAZY_TYPE
|
|
159
|
+
)
|
|
160
|
+
return "<...>";
|
|
161
|
+
try {
|
|
162
|
+
var name = getComponentNameFromType(type);
|
|
163
|
+
return name ? "<" + name + ">" : "<...>";
|
|
164
|
+
} catch (x) {
|
|
165
|
+
return "<...>";
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function getOwner() {
|
|
169
|
+
var dispatcher = ReactSharedInternals.A;
|
|
170
|
+
return null === dispatcher ? null : dispatcher.getOwner();
|
|
171
|
+
}
|
|
172
|
+
function UnknownOwner() {
|
|
173
|
+
return Error("react-stack-top-frame");
|
|
174
|
+
}
|
|
175
|
+
function hasValidKey(config) {
|
|
176
|
+
if (hasOwnProperty.call(config, "key")) {
|
|
177
|
+
var getter = Object.getOwnPropertyDescriptor(config, "key").get;
|
|
178
|
+
if (getter && getter.isReactWarning) return false;
|
|
179
|
+
}
|
|
180
|
+
return void 0 !== config.key;
|
|
181
|
+
}
|
|
182
|
+
function defineKeyPropWarningGetter(props, displayName) {
|
|
183
|
+
function warnAboutAccessingKey() {
|
|
184
|
+
specialPropKeyWarningShown ||
|
|
185
|
+
((specialPropKeyWarningShown = true),
|
|
186
|
+
console.error(
|
|
187
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
188
|
+
displayName
|
|
189
|
+
));
|
|
190
|
+
}
|
|
191
|
+
warnAboutAccessingKey.isReactWarning = true;
|
|
192
|
+
Object.defineProperty(props, "key", {
|
|
193
|
+
get: warnAboutAccessingKey,
|
|
194
|
+
configurable: true
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
function elementRefGetterWithDeprecationWarning() {
|
|
198
|
+
var componentName = getComponentNameFromType(this.type);
|
|
199
|
+
didWarnAboutElementRef[componentName] ||
|
|
200
|
+
((didWarnAboutElementRef[componentName] = true),
|
|
201
|
+
console.error(
|
|
202
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
203
|
+
));
|
|
204
|
+
componentName = this.props.ref;
|
|
205
|
+
return void 0 !== componentName ? componentName : null;
|
|
206
|
+
}
|
|
207
|
+
function ReactElement(type, key, props, owner, debugStack, debugTask) {
|
|
208
|
+
var refProp = props.ref;
|
|
209
|
+
type = {
|
|
210
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
211
|
+
type: type,
|
|
212
|
+
key: key,
|
|
213
|
+
props: props,
|
|
214
|
+
_owner: owner
|
|
215
|
+
};
|
|
216
|
+
null !== (void 0 !== refProp ? refProp : null)
|
|
217
|
+
? Object.defineProperty(type, "ref", {
|
|
218
|
+
enumerable: false,
|
|
219
|
+
get: elementRefGetterWithDeprecationWarning
|
|
220
|
+
})
|
|
221
|
+
: Object.defineProperty(type, "ref", { enumerable: false, value: null });
|
|
222
|
+
type._store = {};
|
|
223
|
+
Object.defineProperty(type._store, "validated", {
|
|
224
|
+
configurable: false,
|
|
225
|
+
enumerable: false,
|
|
226
|
+
writable: true,
|
|
227
|
+
value: 0
|
|
228
|
+
});
|
|
229
|
+
Object.defineProperty(type, "_debugInfo", {
|
|
230
|
+
configurable: false,
|
|
231
|
+
enumerable: false,
|
|
232
|
+
writable: true,
|
|
233
|
+
value: null
|
|
234
|
+
});
|
|
235
|
+
Object.defineProperty(type, "_debugStack", {
|
|
236
|
+
configurable: false,
|
|
237
|
+
enumerable: false,
|
|
238
|
+
writable: true,
|
|
239
|
+
value: debugStack
|
|
240
|
+
});
|
|
241
|
+
Object.defineProperty(type, "_debugTask", {
|
|
242
|
+
configurable: false,
|
|
243
|
+
enumerable: false,
|
|
244
|
+
writable: true,
|
|
245
|
+
value: debugTask
|
|
246
|
+
});
|
|
247
|
+
Object.freeze && (Object.freeze(type.props), Object.freeze(type));
|
|
248
|
+
return type;
|
|
249
|
+
}
|
|
250
|
+
function jsxDEVImpl(
|
|
251
|
+
type,
|
|
252
|
+
config,
|
|
253
|
+
maybeKey,
|
|
254
|
+
isStaticChildren,
|
|
255
|
+
debugStack,
|
|
256
|
+
debugTask
|
|
257
|
+
) {
|
|
258
|
+
var children = config.children;
|
|
259
|
+
if (void 0 !== children)
|
|
260
|
+
if (isStaticChildren)
|
|
261
|
+
if (isArrayImpl(children)) {
|
|
262
|
+
for (
|
|
263
|
+
isStaticChildren = 0;
|
|
264
|
+
isStaticChildren < children.length;
|
|
265
|
+
isStaticChildren++
|
|
266
|
+
)
|
|
267
|
+
validateChildKeys(children[isStaticChildren]);
|
|
268
|
+
Object.freeze && Object.freeze(children);
|
|
269
|
+
} else
|
|
270
|
+
console.error(
|
|
271
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
272
|
+
);
|
|
273
|
+
else validateChildKeys(children);
|
|
274
|
+
if (hasOwnProperty.call(config, "key")) {
|
|
275
|
+
children = getComponentNameFromType(type);
|
|
276
|
+
var keys = Object.keys(config).filter(function (k) {
|
|
277
|
+
return "key" !== k;
|
|
278
|
+
});
|
|
279
|
+
isStaticChildren =
|
|
280
|
+
0 < keys.length
|
|
281
|
+
? "{key: someKey, " + keys.join(": ..., ") + ": ...}"
|
|
282
|
+
: "{key: someKey}";
|
|
283
|
+
didWarnAboutKeySpread[children + isStaticChildren] ||
|
|
284
|
+
((keys =
|
|
285
|
+
0 < keys.length ? "{" + keys.join(": ..., ") + ": ...}" : "{}"),
|
|
286
|
+
console.error(
|
|
287
|
+
'A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',
|
|
288
|
+
isStaticChildren,
|
|
289
|
+
children,
|
|
290
|
+
keys,
|
|
291
|
+
children
|
|
292
|
+
),
|
|
293
|
+
(didWarnAboutKeySpread[children + isStaticChildren] = true));
|
|
294
|
+
}
|
|
295
|
+
children = null;
|
|
296
|
+
void 0 !== maybeKey &&
|
|
297
|
+
(checkKeyStringCoercion(maybeKey), (children = "" + maybeKey));
|
|
298
|
+
hasValidKey(config) &&
|
|
299
|
+
(checkKeyStringCoercion(config.key), (children = "" + config.key));
|
|
300
|
+
if ("key" in config) {
|
|
301
|
+
maybeKey = {};
|
|
302
|
+
for (var propName in config)
|
|
303
|
+
"key" !== propName && (maybeKey[propName] = config[propName]);
|
|
304
|
+
} else maybeKey = config;
|
|
305
|
+
children &&
|
|
306
|
+
defineKeyPropWarningGetter(
|
|
307
|
+
maybeKey,
|
|
308
|
+
"function" === typeof type
|
|
309
|
+
? type.displayName || type.name || "Unknown"
|
|
310
|
+
: type
|
|
311
|
+
);
|
|
312
|
+
return ReactElement(
|
|
313
|
+
type,
|
|
314
|
+
children,
|
|
315
|
+
maybeKey,
|
|
316
|
+
getOwner(),
|
|
317
|
+
debugStack,
|
|
318
|
+
debugTask
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
function validateChildKeys(node) {
|
|
322
|
+
isValidElement(node)
|
|
323
|
+
? node._store && (node._store.validated = 1)
|
|
324
|
+
: "object" === typeof node &&
|
|
325
|
+
null !== node &&
|
|
326
|
+
node.$$typeof === REACT_LAZY_TYPE &&
|
|
327
|
+
("fulfilled" === node._payload.status
|
|
328
|
+
? isValidElement(node._payload.value) &&
|
|
329
|
+
node._payload.value._store &&
|
|
330
|
+
(node._payload.value._store.validated = 1)
|
|
331
|
+
: node._store && (node._store.validated = 1));
|
|
332
|
+
}
|
|
333
|
+
function isValidElement(object) {
|
|
334
|
+
return (
|
|
335
|
+
"object" === typeof object &&
|
|
336
|
+
null !== object &&
|
|
337
|
+
object.$$typeof === REACT_ELEMENT_TYPE
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
var React = require$$0,
|
|
341
|
+
REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
|
|
342
|
+
REACT_PORTAL_TYPE = Symbol.for("react.portal"),
|
|
343
|
+
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
|
|
344
|
+
REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
|
|
345
|
+
REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
|
|
346
|
+
REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
|
|
347
|
+
REACT_CONTEXT_TYPE = Symbol.for("react.context"),
|
|
348
|
+
REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
|
|
349
|
+
REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
|
|
350
|
+
REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
|
|
351
|
+
REACT_MEMO_TYPE = Symbol.for("react.memo"),
|
|
352
|
+
REACT_LAZY_TYPE = Symbol.for("react.lazy"),
|
|
353
|
+
REACT_ACTIVITY_TYPE = Symbol.for("react.activity"),
|
|
354
|
+
REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"),
|
|
355
|
+
ReactSharedInternals =
|
|
356
|
+
React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
|
|
357
|
+
hasOwnProperty = Object.prototype.hasOwnProperty,
|
|
358
|
+
isArrayImpl = Array.isArray,
|
|
359
|
+
createTask = console.createTask
|
|
360
|
+
? console.createTask
|
|
361
|
+
: function () {
|
|
362
|
+
return null;
|
|
363
|
+
};
|
|
364
|
+
React = {
|
|
365
|
+
react_stack_bottom_frame: function (callStackForError) {
|
|
366
|
+
return callStackForError();
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
var specialPropKeyWarningShown;
|
|
370
|
+
var didWarnAboutElementRef = {};
|
|
371
|
+
var unknownOwnerDebugStack = React.react_stack_bottom_frame.bind(
|
|
372
|
+
React,
|
|
373
|
+
UnknownOwner
|
|
374
|
+
)();
|
|
375
|
+
var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
|
|
376
|
+
var didWarnAboutKeySpread = {};
|
|
377
|
+
reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
|
|
378
|
+
reactJsxRuntime_development.jsx = function (type, config, maybeKey) {
|
|
379
|
+
var trackActualOwner =
|
|
380
|
+
1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
|
|
381
|
+
return jsxDEVImpl(
|
|
382
|
+
type,
|
|
383
|
+
config,
|
|
384
|
+
maybeKey,
|
|
385
|
+
false,
|
|
386
|
+
trackActualOwner
|
|
387
|
+
? Error("react-stack-top-frame")
|
|
388
|
+
: unknownOwnerDebugStack,
|
|
389
|
+
trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
|
|
390
|
+
);
|
|
391
|
+
};
|
|
392
|
+
reactJsxRuntime_development.jsxs = function (type, config, maybeKey) {
|
|
393
|
+
var trackActualOwner =
|
|
394
|
+
1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
|
|
395
|
+
return jsxDEVImpl(
|
|
396
|
+
type,
|
|
397
|
+
config,
|
|
398
|
+
maybeKey,
|
|
399
|
+
true,
|
|
400
|
+
trackActualOwner
|
|
401
|
+
? Error("react-stack-top-frame")
|
|
402
|
+
: unknownOwnerDebugStack,
|
|
403
|
+
trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
|
|
404
|
+
);
|
|
405
|
+
};
|
|
406
|
+
})();
|
|
407
|
+
return reactJsxRuntime_development;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
if (process.env.NODE_ENV === 'production') {
|
|
411
|
+
jsxRuntime.exports = requireReactJsxRuntime_production();
|
|
412
|
+
} else {
|
|
413
|
+
jsxRuntime.exports = requireReactJsxRuntime_development();
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
var jsxRuntimeExports = jsxRuntime.exports;
|
|
417
|
+
|
|
418
|
+
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
419
|
+
// require the crypto API and do not support built-in fallback to lower quality random number
|
|
420
|
+
// generators (like Math.random()).
|
|
421
|
+
let getRandomValues;
|
|
422
|
+
const rnds8 = new Uint8Array(16);
|
|
423
|
+
function rng() {
|
|
424
|
+
// lazy load so that environments that need to polyfill have a chance to do so
|
|
425
|
+
if (!getRandomValues) {
|
|
426
|
+
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
|
|
427
|
+
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
428
|
+
|
|
429
|
+
if (!getRandomValues) {
|
|
430
|
+
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
return getRandomValues(rnds8);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Convert array of 16 byte values to UUID string format of the form:
|
|
439
|
+
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
440
|
+
*/
|
|
441
|
+
|
|
442
|
+
const byteToHex = [];
|
|
443
|
+
|
|
444
|
+
for (let i = 0; i < 256; ++i) {
|
|
445
|
+
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
function unsafeStringify(arr, offset = 0) {
|
|
449
|
+
// Note: Be careful editing this code! It's been tuned for performance
|
|
450
|
+
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
451
|
+
return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
455
|
+
var native = {
|
|
456
|
+
randomUUID
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
function v4(options, buf, offset) {
|
|
460
|
+
if (native.randomUUID && true && !options) {
|
|
461
|
+
return native.randomUUID();
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
options = options || {};
|
|
465
|
+
const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
466
|
+
|
|
467
|
+
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
468
|
+
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
|
|
469
|
+
|
|
470
|
+
return unsafeStringify(rnds);
|
|
471
|
+
}
|
|
5
472
|
|
|
6
473
|
const PhonePeUrls = {
|
|
7
474
|
production: {
|
|
8
475
|
token: "https://api.phonepe.com/apis/identity-manager/v1/oauth/token",
|
|
9
476
|
pay: "https://api.phonepe.com/apis/pg/checkout/v2/pay",
|
|
10
477
|
status: "https://api.phonepe.com/apis/pg/checkout/v2/order/status",
|
|
11
|
-
script: "https://mercury.phonepe.com/web/bundle/checkout.js"
|
|
478
|
+
script: "https://mercury.phonepe.com/web/bundle/checkout.js"
|
|
12
479
|
},
|
|
13
480
|
sandbox: {
|
|
14
481
|
token: "https://api-preprod.phonepe.com/apis/identity-manager/v1/oauth/token",
|
|
15
482
|
pay: "https://api-preprod.phonepe.com/apis/pg-sandbox/checkout/v2/pay",
|
|
16
483
|
status: "https://api-preprod.phonepe.com/apis/pg-sandbox/checkout/v2/order/status",
|
|
17
|
-
script: "https://mercury.phonepe.com/web/bundle/checkout.js"
|
|
484
|
+
script: "https://mercury.phonepe.com/web/bundle/checkout.js"
|
|
18
485
|
}
|
|
19
486
|
};
|
|
20
487
|
|
|
@@ -24,20 +491,13 @@ function normalizeEnvironment(env) {
|
|
|
24
491
|
return "production";
|
|
25
492
|
if (e === "sandbox")
|
|
26
493
|
return "sandbox";
|
|
27
|
-
throw new Error(`Invalid environment
|
|
494
|
+
throw new Error(`Invalid environment: ${env}`);
|
|
28
495
|
}
|
|
29
496
|
|
|
30
497
|
const PhonePeCheckoutNative = ({ clientId, clientSecret, environment, request, onSuccess, onError }) => {
|
|
498
|
+
const urls = PhonePeUrls[normalizeEnvironment(environment)];
|
|
31
499
|
const [url, setUrl] = useState();
|
|
32
|
-
|
|
33
|
-
const urls = PhonePeUrls[env];
|
|
34
|
-
if (!urls) {
|
|
35
|
-
onError(`Invalid environment: ${environment}`);
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
init();
|
|
40
|
-
}, []);
|
|
500
|
+
useEffect(() => { init(); }, []);
|
|
41
501
|
const init = async () => {
|
|
42
502
|
try {
|
|
43
503
|
const tokenResp = await fetch(urls.token, {
|
|
@@ -64,18 +524,19 @@ const PhonePeCheckoutNative = ({ clientId, clientSecret, environment, request, o
|
|
|
64
524
|
},
|
|
65
525
|
body: JSON.stringify(payload)
|
|
66
526
|
});
|
|
67
|
-
const
|
|
68
|
-
setUrl(redirectUrl);
|
|
527
|
+
const data = await payResp.json();
|
|
528
|
+
setUrl(data.redirectUrl);
|
|
69
529
|
}
|
|
70
530
|
catch (err) {
|
|
71
531
|
onError(err);
|
|
72
532
|
}
|
|
73
533
|
};
|
|
74
|
-
|
|
75
|
-
|
|
534
|
+
if (!url)
|
|
535
|
+
return null;
|
|
536
|
+
return (jsxRuntimeExports.jsx(WebView, { source: { uri: url }, onNavigationStateChange: nav => {
|
|
537
|
+
if (nav.url.includes("callback"))
|
|
76
538
|
onSuccess(nav);
|
|
77
|
-
|
|
78
|
-
} })) : null;
|
|
539
|
+
} }));
|
|
79
540
|
};
|
|
80
541
|
|
|
81
542
|
export { PhonePeCheckoutNative };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
export type PhonePeEnvironment = "Production" | "Sandbox";
|
|
2
1
|
export interface PhonePeCredentials {
|
|
3
2
|
clientId: string;
|
|
4
3
|
clientSecret: string;
|
|
5
|
-
environment:
|
|
4
|
+
environment: string;
|
|
6
5
|
}
|
|
7
6
|
export interface PhonePePaymentInit {
|
|
8
7
|
merchantId: string;
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function normalizeEnvironment(env: PhonePeEnvironment): "production" | "sandbox";
|
|
1
|
+
export declare function normalizeEnvironment(env: string): "production" | "sandbox";
|
package/package.json
CHANGED
|
@@ -1,41 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dev_innovations_labs/phonepe-pg-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"
|
|
6
|
-
"phonepe",
|
|
7
|
-
"phonepe-pg",
|
|
8
|
-
"payment-gateway",
|
|
9
|
-
"pg-sdk",
|
|
10
|
-
"checkout-v2",
|
|
11
|
-
"upi",
|
|
12
|
-
"react",
|
|
13
|
-
"react-native",
|
|
14
|
-
"nodejs",
|
|
15
|
-
"javascript",
|
|
16
|
-
"typescript",
|
|
17
|
-
"web-payments"
|
|
18
|
-
],
|
|
19
|
-
"main": "dist/index.js",
|
|
20
|
-
"module": "dist/index.esm.js",
|
|
5
|
+
"main": "dist/index.esm.js",
|
|
21
6
|
"types": "dist/index.d.ts",
|
|
22
|
-
"
|
|
23
|
-
"name": "Dev Innovations Labs"
|
|
24
|
-
},
|
|
7
|
+
"module": "dist/index.esm.js",
|
|
25
8
|
"exports": {
|
|
26
|
-
".":
|
|
27
|
-
|
|
28
|
-
"require": "./dist/index.js",
|
|
29
|
-
"types": "./dist/index.d.ts"
|
|
30
|
-
},
|
|
31
|
-
"./native": {
|
|
32
|
-
"import": "./dist/native.esm.js",
|
|
33
|
-
"require": "./dist/native.js",
|
|
34
|
-
"types": "./dist/native.d.ts"
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
"scripts": {
|
|
38
|
-
"build": "rollup -c"
|
|
9
|
+
".": "./dist/index.esm.js",
|
|
10
|
+
"./native": "./dist/native.esm.js"
|
|
39
11
|
},
|
|
40
12
|
"dependencies": {
|
|
41
13
|
"axios": "^1.6.0",
|
|
@@ -46,15 +18,15 @@
|
|
|
46
18
|
"react-native": "*",
|
|
47
19
|
"react-native-webview": "*"
|
|
48
20
|
},
|
|
49
|
-
"peerDependenciesMeta": {
|
|
50
|
-
"react-native-webview": {
|
|
51
|
-
"optional": true
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
21
|
"devDependencies": {
|
|
55
22
|
"typescript": "^5.3.3",
|
|
56
23
|
"rollup": "^4.9.0",
|
|
57
|
-
"rollup-plugin-typescript2": "^0.34.1"
|
|
24
|
+
"rollup-plugin-typescript2": "^0.34.1",
|
|
25
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
26
|
+
"@rollup/plugin-commonjs": "^25.0.7"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "rollup -c"
|
|
58
30
|
},
|
|
59
31
|
"publishConfig": {
|
|
60
32
|
"access": "public"
|
package/rollup.config.js
CHANGED
|
@@ -1,26 +1,43 @@
|
|
|
1
|
+
|
|
1
2
|
import typescript from "rollup-plugin-typescript2";
|
|
3
|
+
import resolve from "@rollup/plugin-node-resolve";
|
|
4
|
+
import commonjs from "@rollup/plugin-commonjs";
|
|
2
5
|
|
|
3
6
|
export default [
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
7
|
+
{
|
|
8
|
+
input: "src/index.ts",
|
|
9
|
+
output: [{ file: "dist/index.esm.js", format: "esm" }],
|
|
10
|
+
plugins: [
|
|
11
|
+
resolve({ extensions: [".ts", ".tsx"] }),
|
|
12
|
+
commonjs(),
|
|
13
|
+
typescript({
|
|
14
|
+
clean: true,
|
|
15
|
+
tsconfigOverride: {
|
|
16
|
+
compilerOptions: {
|
|
17
|
+
jsx: "react-jsx",
|
|
18
|
+
jsxImportSource: "react"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
],
|
|
23
|
+
external: ["react","react/jsx-runtime","axios","uuid"]
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
input: "src/native.ts",
|
|
27
|
+
output: [{ file: "dist/native.esm.js", format: "esm" }],
|
|
28
|
+
plugins: [
|
|
29
|
+
resolve({ extensions: [".ts", ".tsx"] }),
|
|
30
|
+
commonjs(),
|
|
31
|
+
typescript({
|
|
32
|
+
clean: true,
|
|
33
|
+
tsconfigOverride: {
|
|
34
|
+
compilerOptions: {
|
|
35
|
+
jsx: "react-jsx",
|
|
36
|
+
jsxImportSource: "react"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
],
|
|
41
|
+
external: ["react","react-native","react-native-webview"]
|
|
42
|
+
}
|
|
26
43
|
];
|