@yuno-payments/yuno-sdk-react-native 1.0.17-beta.0 → 1.0.17-beta.1
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/android/build.gradle +1 -1
- package/ios/YunoSdk.swift +14 -6
- package/lib/commonjs/YunoPaymentMethods.js +16 -13
- package/lib/commonjs/YunoPaymentMethods.js.map +1 -1
- package/lib/module/YunoPaymentMethods.js +16 -13
- package/lib/module/YunoPaymentMethods.js.map +1 -1
- package/package.json +1 -1
- package/src/YunoPaymentMethods.tsx +16 -11
package/android/build.gradle
CHANGED
|
@@ -107,7 +107,7 @@ dependencies {
|
|
|
107
107
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
108
108
|
|
|
109
109
|
// Yuno Android SDK
|
|
110
|
-
implementation "com.yuno.payments:android-sdk:2.
|
|
110
|
+
implementation "com.yuno.payments:android-sdk:2.10.2"
|
|
111
111
|
implementation "androidx.appcompat:appcompat:1.6.1"
|
|
112
112
|
|
|
113
113
|
// Jetpack Compose (required for YunoPaymentMethodsViewManager)
|
package/ios/YunoSdk.swift
CHANGED
|
@@ -324,29 +324,37 @@ class YunoSdk: RCTEventEmitter {
|
|
|
324
324
|
|
|
325
325
|
self.checkoutSession = checkoutSession
|
|
326
326
|
self.currentCountryCode = safeCountryCode
|
|
327
|
-
|
|
327
|
+
|
|
328
|
+
guard let viewController = RCTPresentedViewController() else {
|
|
329
|
+
throw NSError(domain: "YunoSdk", code: -1, userInfo: [NSLocalizedDescriptionKey: "No view controller available to present seamless payment"])
|
|
330
|
+
}
|
|
331
|
+
|
|
328
332
|
let paymentSelected = PaymentMethodSelection(
|
|
329
333
|
paymentMethodType: paymentMethodType,
|
|
330
334
|
vaultedToken: vaultedToken
|
|
331
335
|
)
|
|
332
336
|
|
|
333
|
-
// Create SeamlessParams for seamless payment
|
|
334
337
|
let seamlessParams = SeamlessParams(
|
|
335
338
|
checkoutSession: checkoutSession,
|
|
336
339
|
countryCode: safeCountryCode,
|
|
337
340
|
language: language,
|
|
338
|
-
viewController:
|
|
341
|
+
viewController: viewController
|
|
339
342
|
)
|
|
340
343
|
|
|
341
|
-
Task {
|
|
342
|
-
|
|
344
|
+
Task { [weak self] in
|
|
345
|
+
guard let self = self else { return }
|
|
346
|
+
|
|
347
|
+
let result = await Yuno.startPaymentSeamlessLite(
|
|
343
348
|
with: seamlessParams,
|
|
344
349
|
paymentSelected: paymentSelected,
|
|
345
350
|
showPaymentStatus: showPaymentStatus
|
|
346
351
|
)
|
|
352
|
+
|
|
353
|
+
DispatchQueue.main.async {
|
|
354
|
+
self.sendPaymentStatusEvent(result: result)
|
|
355
|
+
}
|
|
347
356
|
}
|
|
348
357
|
|
|
349
|
-
// Return initial processing status
|
|
350
358
|
resolver("PROCESSING")
|
|
351
359
|
} catch {
|
|
352
360
|
rejecter("SEAMLESS_ERROR", "Failed to start seamless payment: \(error.localizedDescription)", error)
|
|
@@ -21,19 +21,21 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
21
21
|
|
|
22
22
|
// Native component interface
|
|
23
23
|
|
|
24
|
-
const
|
|
24
|
+
const getLinkingError = () => `The package '@yuno/yuno-sdk-react-native' doesn't seem to be linked correctly for native views. Make sure:\n\n` + _reactNative.Platform.select({
|
|
25
25
|
ios: "- Run 'pod install'\n",
|
|
26
26
|
default: ''
|
|
27
27
|
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n' + '- The Yuno SDK is properly initialized\n';
|
|
28
|
-
|
|
29
|
-
// Get native module for event emitter
|
|
30
|
-
const YunoSdkNative = _reactNative.NativeModules.YunoSdk;
|
|
31
|
-
|
|
32
|
-
// Create event emitter
|
|
28
|
+
const getYunoSdkNative = () => _reactNative.NativeModules.YunoSdk;
|
|
33
29
|
let eventEmitter = null;
|
|
34
|
-
|
|
35
|
-
eventEmitter
|
|
36
|
-
|
|
30
|
+
const getEventEmitter = () => {
|
|
31
|
+
if (eventEmitter === null) {
|
|
32
|
+
const native = getYunoSdkNative();
|
|
33
|
+
if (native) {
|
|
34
|
+
eventEmitter = new _reactNative.NativeEventEmitter(native);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return eventEmitter;
|
|
38
|
+
};
|
|
37
39
|
|
|
38
40
|
// Require the native component
|
|
39
41
|
const NativeYunoPaymentMethodsView = (0, _reactNative.requireNativeComponent)('YunoPaymentMethodsView');
|
|
@@ -103,15 +105,16 @@ const YunoPaymentMethods = ({
|
|
|
103
105
|
}) => {
|
|
104
106
|
// Set up event listeners
|
|
105
107
|
(0, _react.useEffect)(() => {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
+
const emitter = getEventEmitter();
|
|
109
|
+
if (!emitter) {
|
|
110
|
+
console.warn(getLinkingError());
|
|
108
111
|
return;
|
|
109
112
|
}
|
|
110
113
|
const subscriptions = [];
|
|
111
114
|
|
|
112
115
|
// Listen for payment method selection events
|
|
113
116
|
if (onPaymentMethodSelected) {
|
|
114
|
-
const selectionListener =
|
|
117
|
+
const selectionListener = emitter.addListener('onPaymentMethodSelected', event => {
|
|
115
118
|
onPaymentMethodSelected(event);
|
|
116
119
|
});
|
|
117
120
|
subscriptions.push(selectionListener);
|
|
@@ -119,7 +122,7 @@ const YunoPaymentMethods = ({
|
|
|
119
122
|
|
|
120
123
|
// Listen for error events
|
|
121
124
|
if (onPaymentMethodError) {
|
|
122
|
-
const errorListener =
|
|
125
|
+
const errorListener = emitter.addListener('onPaymentMethodError', event => {
|
|
123
126
|
onPaymentMethodError(event);
|
|
124
127
|
});
|
|
125
128
|
subscriptions.push(errorListener);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","getLinkingError","Platform","select","ios","getYunoSdkNative","NativeModules","YunoSdk","eventEmitter","getEventEmitter","native","NativeEventEmitter","NativeYunoPaymentMethodsView","requireNativeComponent","YunoPaymentMethods","checkoutSession","countryCode","onPaymentMethodSelected","onPaymentMethodError","style","testID","useEffect","emitter","console","warn","subscriptions","selectionListener","addListener","event","push","errorListener","forEach","sub","remove","createElement","exports"],"sourceRoot":"../../src","sources":["YunoPaymentMethods.tsx"],"mappings":"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","ignoreList":[]}
|
|
@@ -15,19 +15,21 @@ import { requireNativeComponent, NativeModules, NativeEventEmitter, Platform } f
|
|
|
15
15
|
|
|
16
16
|
// Native component interface
|
|
17
17
|
|
|
18
|
-
const
|
|
18
|
+
const getLinkingError = () => `The package '@yuno/yuno-sdk-react-native' doesn't seem to be linked correctly for native views. Make sure:\n\n` + Platform.select({
|
|
19
19
|
ios: "- Run 'pod install'\n",
|
|
20
20
|
default: ''
|
|
21
21
|
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n' + '- The Yuno SDK is properly initialized\n';
|
|
22
|
-
|
|
23
|
-
// Get native module for event emitter
|
|
24
|
-
const YunoSdkNative = NativeModules.YunoSdk;
|
|
25
|
-
|
|
26
|
-
// Create event emitter
|
|
22
|
+
const getYunoSdkNative = () => NativeModules.YunoSdk;
|
|
27
23
|
let eventEmitter = null;
|
|
28
|
-
|
|
29
|
-
eventEmitter
|
|
30
|
-
|
|
24
|
+
const getEventEmitter = () => {
|
|
25
|
+
if (eventEmitter === null) {
|
|
26
|
+
const native = getYunoSdkNative();
|
|
27
|
+
if (native) {
|
|
28
|
+
eventEmitter = new NativeEventEmitter(native);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return eventEmitter;
|
|
32
|
+
};
|
|
31
33
|
|
|
32
34
|
// Require the native component
|
|
33
35
|
const NativeYunoPaymentMethodsView = requireNativeComponent('YunoPaymentMethodsView');
|
|
@@ -97,15 +99,16 @@ export const YunoPaymentMethods = ({
|
|
|
97
99
|
}) => {
|
|
98
100
|
// Set up event listeners
|
|
99
101
|
useEffect(() => {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
+
const emitter = getEventEmitter();
|
|
103
|
+
if (!emitter) {
|
|
104
|
+
console.warn(getLinkingError());
|
|
102
105
|
return;
|
|
103
106
|
}
|
|
104
107
|
const subscriptions = [];
|
|
105
108
|
|
|
106
109
|
// Listen for payment method selection events
|
|
107
110
|
if (onPaymentMethodSelected) {
|
|
108
|
-
const selectionListener =
|
|
111
|
+
const selectionListener = emitter.addListener('onPaymentMethodSelected', event => {
|
|
109
112
|
onPaymentMethodSelected(event);
|
|
110
113
|
});
|
|
111
114
|
subscriptions.push(selectionListener);
|
|
@@ -113,7 +116,7 @@ export const YunoPaymentMethods = ({
|
|
|
113
116
|
|
|
114
117
|
// Listen for error events
|
|
115
118
|
if (onPaymentMethodError) {
|
|
116
|
-
const errorListener =
|
|
119
|
+
const errorListener = emitter.addListener('onPaymentMethodError', event => {
|
|
117
120
|
onPaymentMethodError(event);
|
|
118
121
|
});
|
|
119
122
|
subscriptions.push(errorListener);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useEffect","requireNativeComponent","NativeModules","NativeEventEmitter","Platform","
|
|
1
|
+
{"version":3,"names":["React","useEffect","requireNativeComponent","NativeModules","NativeEventEmitter","Platform","getLinkingError","select","ios","default","getYunoSdkNative","YunoSdk","eventEmitter","getEventEmitter","native","NativeYunoPaymentMethodsView","YunoPaymentMethods","checkoutSession","countryCode","onPaymentMethodSelected","onPaymentMethodError","style","testID","emitter","console","warn","subscriptions","selectionListener","addListener","event","push","errorListener","forEach","sub","remove","createElement"],"sourceRoot":"../../src","sources":["YunoPaymentMethods.tsx"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,QAAqB,OAAO;AACrD,SACEC,sBAAsB,EACtBC,aAAa,EACbC,kBAAkB,EAGlBC,QAAQ,QACH,cAAc;;AAErB;AACA;AACA;;AAMA;AACA;AACA;;AAMA;AACA;AACA;;AA2BA;;AAQA,MAAMC,eAAe,GAAGA,CAAA,KACtB,gHAAgH,GAChHD,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,uBAAuB;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GAC9D,sDAAsD,GACtD,+BAA+B,GAC/B,0CAA0C;AAE5C,MAAMC,gBAAgB,GAAGA,CAAA,KAAMP,aAAa,CAACQ,OAAO;AAEpD,IAAIC,YAAuC,GAAG,IAAI;AAClD,MAAMC,eAAe,GAAGA,CAAA,KAAM;EAC5B,IAAID,YAAY,KAAK,IAAI,EAAE;IACzB,MAAME,MAAM,GAAGJ,gBAAgB,CAAC,CAAC;IACjC,IAAII,MAAM,EAAE;MACVF,YAAY,GAAG,IAAIR,kBAAkB,CAACU,MAAM,CAAC;IAC/C;EACF;EACA,OAAOF,YAAY;AACrB,CAAC;;AAED;AACA,MAAMG,4BAA4B,GAAGb,sBAAsB,CACzD,wBACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMc,kBAAqD,GAAGA,CAAC;EACpEC,eAAe;EACfC,WAAW;EACXC,uBAAuB;EACvBC,oBAAoB;EACpBC,KAAK;EACLC;AACF,CAAC,KAAK;EACJ;EACArB,SAAS,CAAC,MAAM;IACd,MAAMsB,OAAO,GAAGV,eAAe,CAAC,CAAC;IACjC,IAAI,CAACU,OAAO,EAAE;MACZC,OAAO,CAACC,IAAI,CAACnB,eAAe,CAAC,CAAC,CAAC;MAC/B;IACF;IAEA,MAAMoB,aAAoB,GAAG,EAAE;;IAE/B;IACA,IAAIP,uBAAuB,EAAE;MAC3B,MAAMQ,iBAAiB,GAAGJ,OAAO,CAACK,WAAW,CAC3C,yBAAyB,EACxBC,KAAiC,IAAK;QACrCV,uBAAuB,CAACU,KAAK,CAAC;MAChC,CACF,CAAC;MACDH,aAAa,CAACI,IAAI,CAACH,iBAAiB,CAAC;IACvC;;IAEA;IACA,IAAIP,oBAAoB,EAAE;MACxB,MAAMW,aAAa,GAAGR,OAAO,CAACK,WAAW,CACvC,sBAAsB,EACrBC,KAA8B,IAAK;QAClCT,oBAAoB,CAACS,KAAK,CAAC;MAC7B,CACF,CAAC;MACDH,aAAa,CAACI,IAAI,CAACC,aAAa,CAAC;IACnC;;IAEA;IACA,OAAO,MAAM;MACXL,aAAa,CAACM,OAAO,CAAEC,GAAG,IAAK;QAC7B,IAAIA,GAAG,IAAIA,GAAG,CAACC,MAAM,EAAE;UACrBD,GAAG,CAACC,MAAM,CAAC,CAAC;QACd;MACF,CAAC,CAAC;IACJ,CAAC;EACH,CAAC,EAAE,CAACf,uBAAuB,EAAEC,oBAAoB,CAAC,CAAC;EAEnD,oBACEpB,KAAA,CAAAmC,aAAA,CAACpB,4BAA4B;IAC3BO,MAAM,EAAEA,MAAO;IACfL,eAAe,EAAEA,eAAgB;IACjCC,WAAW,EAAEA,WAAY;IACzBG,KAAK,EAAEA;EAAM,CACd,CAAC;AAEN,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuno-payments/yuno-sdk-react-native",
|
|
3
|
-
"version": "1.0.17-beta.
|
|
3
|
+
"version": "1.0.17-beta.1",
|
|
4
4
|
"description": "Yuno React Native SDK empowers you to create seamless payment experiences in your native Android and iOS apps built with React Native.",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -61,21 +61,25 @@ interface NativeYunoPaymentMethodsProps {
|
|
|
61
61
|
testID?: string;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
const
|
|
64
|
+
const getLinkingError = () =>
|
|
65
65
|
`The package '@yuno/yuno-sdk-react-native' doesn't seem to be linked correctly for native views. Make sure:\n\n` +
|
|
66
66
|
Platform.select({ ios: "- Run 'pod install'\n", default: '' }) +
|
|
67
67
|
'- You rebuilt the app after installing the package\n' +
|
|
68
68
|
'- You are not using Expo Go\n' +
|
|
69
69
|
'- The Yuno SDK is properly initialized\n';
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
const YunoSdkNative = NativeModules.YunoSdk;
|
|
71
|
+
const getYunoSdkNative = () => NativeModules.YunoSdk;
|
|
73
72
|
|
|
74
|
-
// Create event emitter
|
|
75
73
|
let eventEmitter: NativeEventEmitter | null = null;
|
|
76
|
-
|
|
77
|
-
eventEmitter
|
|
78
|
-
|
|
74
|
+
const getEventEmitter = () => {
|
|
75
|
+
if (eventEmitter === null) {
|
|
76
|
+
const native = getYunoSdkNative();
|
|
77
|
+
if (native) {
|
|
78
|
+
eventEmitter = new NativeEventEmitter(native);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return eventEmitter;
|
|
82
|
+
};
|
|
79
83
|
|
|
80
84
|
// Require the native component
|
|
81
85
|
const NativeYunoPaymentMethodsView = requireNativeComponent<NativeYunoPaymentMethodsProps>(
|
|
@@ -147,8 +151,9 @@ export const YunoPaymentMethods: React.FC<YunoPaymentMethodsProps> = ({
|
|
|
147
151
|
}) => {
|
|
148
152
|
// Set up event listeners
|
|
149
153
|
useEffect(() => {
|
|
150
|
-
|
|
151
|
-
|
|
154
|
+
const emitter = getEventEmitter();
|
|
155
|
+
if (!emitter) {
|
|
156
|
+
console.warn(getLinkingError());
|
|
152
157
|
return;
|
|
153
158
|
}
|
|
154
159
|
|
|
@@ -156,7 +161,7 @@ export const YunoPaymentMethods: React.FC<YunoPaymentMethodsProps> = ({
|
|
|
156
161
|
|
|
157
162
|
// Listen for payment method selection events
|
|
158
163
|
if (onPaymentMethodSelected) {
|
|
159
|
-
const selectionListener =
|
|
164
|
+
const selectionListener = emitter.addListener(
|
|
160
165
|
'onPaymentMethodSelected',
|
|
161
166
|
(event: PaymentMethodSelectedEvent) => {
|
|
162
167
|
onPaymentMethodSelected(event);
|
|
@@ -167,7 +172,7 @@ export const YunoPaymentMethods: React.FC<YunoPaymentMethodsProps> = ({
|
|
|
167
172
|
|
|
168
173
|
// Listen for error events
|
|
169
174
|
if (onPaymentMethodError) {
|
|
170
|
-
const errorListener =
|
|
175
|
+
const errorListener = emitter.addListener(
|
|
171
176
|
'onPaymentMethodError',
|
|
172
177
|
(event: PaymentMethodErrorEvent) => {
|
|
173
178
|
onPaymentMethodError(event);
|