@yuno-payments/yuno-sdk-react-native 1.0.16
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/LICENSE +22 -0
- package/README.md +621 -0
- package/android/build.gradle +131 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/com/yunosdkreactnative/YunoPaymentMethodsViewManager.kt +194 -0
- package/android/src/main/java/com/yunosdkreactnative/YunoSdkModule.kt +777 -0
- package/android/src/main/java/com/yunosdkreactnative/YunoSdkPackage.kt +24 -0
- package/ios/YunoSdk.m +65 -0
- package/ios/YunoSdk.podspec +48 -0
- package/ios/YunoSdk.swift +442 -0
- package/lib/commonjs/YunoPaymentMethods.js +145 -0
- package/lib/commonjs/YunoPaymentMethods.js.map +1 -0
- package/lib/commonjs/YunoSdk.js +455 -0
- package/lib/commonjs/YunoSdk.js.map +1 -0
- package/lib/commonjs/core/enums/CardFlow.js +26 -0
- package/lib/commonjs/core/enums/CardFlow.js.map +1 -0
- package/lib/commonjs/core/enums/YunoLanguage.js +58 -0
- package/lib/commonjs/core/enums/YunoLanguage.js.map +1 -0
- package/lib/commonjs/core/enums/YunoStatus.js +40 -0
- package/lib/commonjs/core/enums/YunoStatus.js.map +1 -0
- package/lib/commonjs/core/enums/index.js +27 -0
- package/lib/commonjs/core/enums/index.js.map +1 -0
- package/lib/commonjs/core/index.js +28 -0
- package/lib/commonjs/core/index.js.map +1 -0
- package/lib/commonjs/core/types/AndroidConfig.js +2 -0
- package/lib/commonjs/core/types/AndroidConfig.js.map +1 -0
- package/lib/commonjs/core/types/EnrollmentArguments.js +2 -0
- package/lib/commonjs/core/types/EnrollmentArguments.js.map +1 -0
- package/lib/commonjs/core/types/IosConfig.js +2 -0
- package/lib/commonjs/core/types/IosConfig.js.map +1 -0
- package/lib/commonjs/core/types/OneTimeTokenInfo.js +2 -0
- package/lib/commonjs/core/types/OneTimeTokenInfo.js.map +1 -0
- package/lib/commonjs/core/types/SeamlessArguments.js +6 -0
- package/lib/commonjs/core/types/SeamlessArguments.js.map +1 -0
- package/lib/commonjs/core/types/StartPayment.js +2 -0
- package/lib/commonjs/core/types/StartPayment.js.map +1 -0
- package/lib/commonjs/core/types/YunoConfig.js +6 -0
- package/lib/commonjs/core/types/YunoConfig.js.map +1 -0
- package/lib/commonjs/core/types/index.js +2 -0
- package/lib/commonjs/core/types/index.js.map +1 -0
- package/lib/commonjs/index.js +36 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/YunoPaymentMethods.js +138 -0
- package/lib/module/YunoPaymentMethods.js.map +1 -0
- package/lib/module/YunoSdk.js +448 -0
- package/lib/module/YunoSdk.js.map +1 -0
- package/lib/module/core/enums/CardFlow.js +20 -0
- package/lib/module/core/enums/CardFlow.js.map +1 -0
- package/lib/module/core/enums/YunoLanguage.js +52 -0
- package/lib/module/core/enums/YunoLanguage.js.map +1 -0
- package/lib/module/core/enums/YunoStatus.js +34 -0
- package/lib/module/core/enums/YunoStatus.js.map +1 -0
- package/lib/module/core/enums/index.js +4 -0
- package/lib/module/core/enums/index.js.map +1 -0
- package/lib/module/core/index.js +3 -0
- package/lib/module/core/index.js.map +1 -0
- package/lib/module/core/types/AndroidConfig.js +2 -0
- package/lib/module/core/types/AndroidConfig.js.map +1 -0
- package/lib/module/core/types/EnrollmentArguments.js +2 -0
- package/lib/module/core/types/EnrollmentArguments.js.map +1 -0
- package/lib/module/core/types/IosConfig.js +2 -0
- package/lib/module/core/types/IosConfig.js.map +1 -0
- package/lib/module/core/types/OneTimeTokenInfo.js +2 -0
- package/lib/module/core/types/OneTimeTokenInfo.js.map +1 -0
- package/lib/module/core/types/SeamlessArguments.js +2 -0
- package/lib/module/core/types/SeamlessArguments.js.map +1 -0
- package/lib/module/core/types/StartPayment.js +2 -0
- package/lib/module/core/types/StartPayment.js.map +1 -0
- package/lib/module/core/types/YunoConfig.js +2 -0
- package/lib/module/core/types/YunoConfig.js.map +1 -0
- package/lib/module/core/types/index.js +2 -0
- package/lib/module/core/types/index.js.map +1 -0
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -0
- package/package.json +142 -0
- package/src/YunoPaymentMethods.tsx +196 -0
- package/src/YunoSdk.ts +518 -0
- package/src/core/enums/CardFlow.ts +18 -0
- package/src/core/enums/YunoLanguage.ts +50 -0
- package/src/core/enums/YunoStatus.ts +32 -0
- package/src/core/enums/index.ts +3 -0
- package/src/core/index.ts +2 -0
- package/src/core/types/AndroidConfig.ts +17 -0
- package/src/core/types/EnrollmentArguments.ts +32 -0
- package/src/core/types/IosConfig.ts +17 -0
- package/src/core/types/OneTimeTokenInfo.ts +207 -0
- package/src/core/types/SeamlessArguments.ts +42 -0
- package/src/core/types/StartPayment.ts +59 -0
- package/src/core/types/YunoConfig.ts +55 -0
- package/src/core/types/index.ts +7 -0
- package/src/index.ts +17 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Yuno
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,621 @@
|
|
|
1
|
+
# Yuno SDK React Native
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img alt="Yuno React Native SDK" loading="lazy" src="https://files.readme.io/2e1d03a6eec5051a64763f36225454778d7125c344f1d741d0c01cfcdafe4186-flutter-image.png" title="" height="auto" width="auto">
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<div align="center">
|
|
8
|
+
<a href="https://www.y.uno/">
|
|
9
|
+
<img alt="Maintained by Yuno" src="https://img.shields.io/badge/maintained_by-Yuno-4E3DD8?style=for-the-badge">
|
|
10
|
+
</a>
|
|
11
|
+
<a href="https://opensource.org/licenses/MIT">
|
|
12
|
+
<img src="https://img.shields.io/badge/license-MIT-purple.svg?style=for-the-badge" alt="License: MIT">
|
|
13
|
+
</a>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<br>
|
|
17
|
+
|
|
18
|
+
> **⚠️ Open Source Project Notice**
|
|
19
|
+
>
|
|
20
|
+
> This is an open source project related to YUNO. Support is provided by the community, not by YUNO directly. For community support, please open an issue in this repository.
|
|
21
|
+
|
|
22
|
+
Yuno React Native SDK empowers you to create seamless payment experiences in your native Android and iOS apps built with React Native. It offers powerful and customizable functionality that can be used to gather payment details from your users efficiently and effectively.
|
|
23
|
+
|
|
24
|
+
## 📱 Platform Support
|
|
25
|
+
|
|
26
|
+
| | Android | iOS |
|
|
27
|
+
|-------------|---------|-------|
|
|
28
|
+
| **Support** | SDK 21+ | 14.0+ |
|
|
29
|
+
|
|
30
|
+
## 🚀 Example App
|
|
31
|
+
|
|
32
|
+
A complete example application is available in the [`example/`](./example) directory. This app demonstrates all SDK features with a fully functional UI:
|
|
33
|
+
|
|
34
|
+
- ✅ **Full SDK Integration**: All payment flows implemented
|
|
35
|
+
- ✅ **Modern UI**: Clean, professional interface with real-time status monitoring
|
|
36
|
+
- ✅ **Ready to Run**: Pre-configured for both Android and iOS
|
|
37
|
+
- ✅ **Complete Documentation**: Step-by-step guides included
|
|
38
|
+
|
|
39
|
+
**Quick Start:**
|
|
40
|
+
```bash
|
|
41
|
+
cd example
|
|
42
|
+
npm install
|
|
43
|
+
npm run android # or npm run ios
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
See [`example/README.md`](./example/README.md) for detailed instructions.
|
|
47
|
+
|
|
48
|
+
## ✨ Features
|
|
49
|
+
|
|
50
|
+
### 1. Powerful Payment Integrations
|
|
51
|
+
- **Multiple Payment Methods**: Supports a variety of payment options including credit cards, debit cards, wallets, and alternative payment methods
|
|
52
|
+
- **Tokenization**: Implements secure tokenization to safely handle sensitive card data, reducing PCI compliance scope
|
|
53
|
+
- **Seamless Payments**: One-tap payments for returning users with saved payment methods
|
|
54
|
+
|
|
55
|
+
### 2. Flexible Payment Flows
|
|
56
|
+
- **Full Payment Flow**: Complete payment experience with built-in UI
|
|
57
|
+
- **Payment Lite**: Lightweight payment flow for custom integrations
|
|
58
|
+
- **Seamless Payment**: Headless payment flow for maximum customization
|
|
59
|
+
- **Enrollment**: Save payment methods for future use
|
|
60
|
+
|
|
61
|
+
### 3. Developer-Friendly
|
|
62
|
+
- **TypeScript Support**: Full TypeScript definitions included
|
|
63
|
+
- **Clean Architecture**: Well-structured codebase following React Native best practices
|
|
64
|
+
- **Event-Based**: React to payment events in real-time
|
|
65
|
+
- **Error Handling**: Comprehensive error messages and status reporting
|
|
66
|
+
|
|
67
|
+
### 4. Security Features
|
|
68
|
+
- **PCI Compliance**: Adheres to PCI DSS standards
|
|
69
|
+
- **3D Secure Support**: Built-in support for additional authentication
|
|
70
|
+
- **Data Encryption**: All transactions protected with advanced encryption
|
|
71
|
+
|
|
72
|
+
### 5. Localization
|
|
73
|
+
- **Multi-Language Support**: EN, ES, PT, MS, ID, TH
|
|
74
|
+
- **Regional Configuration**: Country-specific payment method support
|
|
75
|
+
|
|
76
|
+
## 📦 Installation
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
npm install @y.uno/yuno-sdk-react-native
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
or
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
yarn add @y.uno/yuno-sdk-react-native
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## ⚙️ Setup
|
|
89
|
+
|
|
90
|
+
### Android Configuration
|
|
91
|
+
|
|
92
|
+
#### 1. Update your `android/build.gradle` (project level):
|
|
93
|
+
|
|
94
|
+
```gradle
|
|
95
|
+
allprojects {
|
|
96
|
+
repositories {
|
|
97
|
+
google()
|
|
98
|
+
mavenCentral()
|
|
99
|
+
maven { url "https://yunopayments.jfrog.io/artifactory/snapshots-libs-release" }
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
#### 2. Create or update `android/app/src/main/java/.../MainApplication.kt`:
|
|
105
|
+
|
|
106
|
+
```kotlin
|
|
107
|
+
import android.app.Application
|
|
108
|
+
import com.yunosdkreactnative.YunoSdkModule
|
|
109
|
+
|
|
110
|
+
class MainApplication : Application(), ReactApplication {
|
|
111
|
+
override fun onCreate() {
|
|
112
|
+
super.onCreate()
|
|
113
|
+
|
|
114
|
+
// Initialize Yuno SDK
|
|
115
|
+
YunoSdkModule.initialize(this, "YOUR_YUNO_API_KEY")
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// ... rest of your application code
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
#### 3. Ensure minimum SDK version in `android/app/build.gradle`:
|
|
123
|
+
|
|
124
|
+
```gradle
|
|
125
|
+
android {
|
|
126
|
+
defaultConfig {
|
|
127
|
+
minSdkVersion 21
|
|
128
|
+
// ...
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### iOS Configuration
|
|
134
|
+
|
|
135
|
+
#### 1. Install CocoaPods dependencies:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
cd ios && pod install && cd ..
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
#### 2. Update your `Info.plist` if you need to handle deeplinks:
|
|
142
|
+
|
|
143
|
+
```xml
|
|
144
|
+
<key>CFBundleURLTypes</key>
|
|
145
|
+
<array>
|
|
146
|
+
<dict>
|
|
147
|
+
<key>CFBundleURLSchemes</key>
|
|
148
|
+
<array>
|
|
149
|
+
<string>your-app-scheme</string>
|
|
150
|
+
</array>
|
|
151
|
+
</dict>
|
|
152
|
+
</array>
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## 🚀 Usage
|
|
156
|
+
|
|
157
|
+
### Initialize the SDK
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
import { YunoSdk, YunoLanguage, CardFlow } from '@y.uno/yuno-sdk-react-native';
|
|
161
|
+
|
|
162
|
+
// Initialize the SDK
|
|
163
|
+
await YunoSdk.initialize({
|
|
164
|
+
apiKey: 'YOUR_API_KEY',
|
|
165
|
+
countryCode: 'CO', // ISO country code
|
|
166
|
+
yunoConfig: {
|
|
167
|
+
lang: YunoLanguage.ES,
|
|
168
|
+
cardFlow: CardFlow.STEP_BY_STEP,
|
|
169
|
+
saveCardEnabled: true,
|
|
170
|
+
keepLoader: false,
|
|
171
|
+
isDynamicViewEnabled: true,
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Listen to Payment Events
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
import { YunoSdk, YunoStatus } from '@y.uno/yuno-sdk-react-native';
|
|
180
|
+
import { useEffect } from 'react';
|
|
181
|
+
|
|
182
|
+
function PaymentScreen() {
|
|
183
|
+
useEffect(() => {
|
|
184
|
+
// Listen to payment status
|
|
185
|
+
const paymentSubscription = YunoSdk.onPaymentStatus((state) => {
|
|
186
|
+
console.log('Payment Status:', state.status);
|
|
187
|
+
|
|
188
|
+
switch (state.status) {
|
|
189
|
+
case YunoStatus.SUCCEEDED:
|
|
190
|
+
console.log('Payment succeeded!');
|
|
191
|
+
if (state.token) {
|
|
192
|
+
console.log('OTT Token:', state.token);
|
|
193
|
+
}
|
|
194
|
+
break;
|
|
195
|
+
case YunoStatus.FAILED:
|
|
196
|
+
console.log('Payment failed');
|
|
197
|
+
break;
|
|
198
|
+
case YunoStatus.REJECTED:
|
|
199
|
+
console.log('Payment rejected');
|
|
200
|
+
break;
|
|
201
|
+
case YunoStatus.CANCELLED_BY_USER:
|
|
202
|
+
console.log('Payment cancelled by user');
|
|
203
|
+
break;
|
|
204
|
+
// ... handle other cases
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
// Listen to one-time tokens
|
|
209
|
+
const tokenSubscription = YunoSdk.onOneTimeToken((token) => {
|
|
210
|
+
console.log('Received OTT:', token);
|
|
211
|
+
// Use token for server-side processing
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
return () => {
|
|
215
|
+
paymentSubscription.remove();
|
|
216
|
+
tokenSubscription.remove();
|
|
217
|
+
};
|
|
218
|
+
}, []);
|
|
219
|
+
|
|
220
|
+
return (
|
|
221
|
+
// Your UI
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Start a Full Payment Flow
|
|
227
|
+
|
|
228
|
+
```typescript
|
|
229
|
+
import { YunoSdk } from '@y.uno/yuno-sdk-react-native';
|
|
230
|
+
|
|
231
|
+
async function handlePayment() {
|
|
232
|
+
try {
|
|
233
|
+
await YunoSdk.startPayment(true); // true to show payment status
|
|
234
|
+
console.log('Payment flow started');
|
|
235
|
+
} catch (error) {
|
|
236
|
+
console.error('Payment error:', error);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### Start Payment Lite
|
|
242
|
+
|
|
243
|
+
```typescript
|
|
244
|
+
import { YunoSdk } from '@y.uno/yuno-sdk-react-native';
|
|
245
|
+
|
|
246
|
+
async function handlePaymentLite() {
|
|
247
|
+
try {
|
|
248
|
+
await YunoSdk.startPaymentLite({
|
|
249
|
+
checkoutSession: 'your_checkout_session_token',
|
|
250
|
+
methodSelected: {
|
|
251
|
+
vaultedToken: 'payment_method_token',
|
|
252
|
+
paymentMethodType: 'CARD',
|
|
253
|
+
},
|
|
254
|
+
showPaymentStatus: true,
|
|
255
|
+
});
|
|
256
|
+
} catch (error) {
|
|
257
|
+
console.error('Payment lite error:', error);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Start Seamless Payment
|
|
263
|
+
|
|
264
|
+
```typescript
|
|
265
|
+
import { YunoSdk, YunoStatus } from '@y.uno/yuno-sdk-react-native';
|
|
266
|
+
|
|
267
|
+
async function handleSeamlessPayment() {
|
|
268
|
+
try {
|
|
269
|
+
const status = await YunoSdk.startPaymentSeamlessLite({
|
|
270
|
+
checkoutSession: 'your_checkout_session_token',
|
|
271
|
+
methodSelected: {
|
|
272
|
+
vaultedToken: 'payment_method_token',
|
|
273
|
+
paymentMethodType: 'CARD',
|
|
274
|
+
},
|
|
275
|
+
showPaymentStatus: false,
|
|
276
|
+
countryCode: 'CO',
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
console.log('Seamless payment status:', status);
|
|
280
|
+
|
|
281
|
+
if (status === YunoStatus.SUCCEEDED) {
|
|
282
|
+
// Handle success
|
|
283
|
+
}
|
|
284
|
+
} catch (error) {
|
|
285
|
+
console.error('Seamless payment error:', error);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### Enrollment Payment
|
|
291
|
+
|
|
292
|
+
```typescript
|
|
293
|
+
import { YunoSdk, YunoStatus } from '@y.uno/yuno-sdk-react-native';
|
|
294
|
+
import { useEffect } from 'react';
|
|
295
|
+
|
|
296
|
+
function EnrollmentScreen() {
|
|
297
|
+
useEffect(() => {
|
|
298
|
+
// Listen to enrollment status
|
|
299
|
+
const subscription = YunoSdk.onEnrollmentStatus((state) => {
|
|
300
|
+
console.log('Enrollment Status:', state.status);
|
|
301
|
+
|
|
302
|
+
switch (state.status) {
|
|
303
|
+
case YunoStatus.SUCCEEDED:
|
|
304
|
+
console.log('Enrollment succeeded!');
|
|
305
|
+
break;
|
|
306
|
+
case YunoStatus.FAILED:
|
|
307
|
+
console.log('Enrollment failed');
|
|
308
|
+
break;
|
|
309
|
+
// ... handle other cases
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
return () => subscription.remove();
|
|
314
|
+
}, []);
|
|
315
|
+
|
|
316
|
+
const handleEnrollment = async () => {
|
|
317
|
+
try {
|
|
318
|
+
await YunoSdk.enrollmentPayment({
|
|
319
|
+
customerSession: 'customer_session_token',
|
|
320
|
+
showPaymentStatus: true,
|
|
321
|
+
countryCode: 'CO',
|
|
322
|
+
});
|
|
323
|
+
} catch (error) {
|
|
324
|
+
console.error('Enrollment error:', error);
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
return (
|
|
329
|
+
// Your UI
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### Handle Deep Links (iOS)
|
|
335
|
+
|
|
336
|
+
```typescript
|
|
337
|
+
import { YunoSdk } from '@y.uno/yuno-sdk-react-native';
|
|
338
|
+
import { Linking } from 'react-native';
|
|
339
|
+
import { useEffect } from 'react';
|
|
340
|
+
|
|
341
|
+
function App() {
|
|
342
|
+
useEffect(() => {
|
|
343
|
+
// Handle initial URL
|
|
344
|
+
Linking.getInitialURL().then((url) => {
|
|
345
|
+
if (url) {
|
|
346
|
+
YunoSdk.receiveDeeplink(url);
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
// Handle URL updates
|
|
351
|
+
const subscription = Linking.addEventListener('url', (event) => {
|
|
352
|
+
YunoSdk.receiveDeeplink(event.url);
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
return () => subscription.remove();
|
|
356
|
+
}, []);
|
|
357
|
+
|
|
358
|
+
return (
|
|
359
|
+
// Your app
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
### Continue Payment
|
|
365
|
+
|
|
366
|
+
```typescript
|
|
367
|
+
import { YunoSdk } from '@y.uno/yuno-sdk-react-native';
|
|
368
|
+
|
|
369
|
+
async function handleContinuePayment() {
|
|
370
|
+
try {
|
|
371
|
+
await YunoSdk.continuePayment(true);
|
|
372
|
+
console.log('Payment continued');
|
|
373
|
+
} catch (error) {
|
|
374
|
+
console.error('Continue payment error:', error);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
### Hide Loader
|
|
380
|
+
|
|
381
|
+
```typescript
|
|
382
|
+
import { YunoSdk } from '@y.uno/yuno-sdk-react-native';
|
|
383
|
+
|
|
384
|
+
async function hideLoader() {
|
|
385
|
+
try {
|
|
386
|
+
await YunoSdk.hideLoader();
|
|
387
|
+
} catch (error) {
|
|
388
|
+
console.error('Hide loader error:', error);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
## 📖 API Reference
|
|
394
|
+
|
|
395
|
+
### YunoSdk
|
|
396
|
+
|
|
397
|
+
The main class for interacting with the Yuno SDK.
|
|
398
|
+
|
|
399
|
+
#### Methods
|
|
400
|
+
|
|
401
|
+
##### `initialize(params)`
|
|
402
|
+
|
|
403
|
+
Initializes the SDK with configuration.
|
|
404
|
+
|
|
405
|
+
**Parameters:**
|
|
406
|
+
- `apiKey` (string, required): Your Yuno API key
|
|
407
|
+
- `countryCode` (string, required): ISO country code
|
|
408
|
+
- `yunoConfig` (object, optional): SDK configuration
|
|
409
|
+
- `lang` (YunoLanguage): Language for the SDK UI
|
|
410
|
+
- `cardFlow` (CardFlow): Card flow type
|
|
411
|
+
- `saveCardEnabled` (boolean): Enable save card option
|
|
412
|
+
- `keepLoader` (boolean): Keep loader visible
|
|
413
|
+
- `isDynamicViewEnabled` (boolean): Enable dynamic view
|
|
414
|
+
- `iosConfig` (object, optional): iOS-specific configuration
|
|
415
|
+
- `androidConfig` (object, optional): Android-specific configuration
|
|
416
|
+
|
|
417
|
+
**Returns:** Promise<void>
|
|
418
|
+
|
|
419
|
+
##### `startPayment(showPaymentStatus)`
|
|
420
|
+
|
|
421
|
+
Starts a full payment flow.
|
|
422
|
+
|
|
423
|
+
**Parameters:**
|
|
424
|
+
- `showPaymentStatus` (boolean): Show payment status screen
|
|
425
|
+
|
|
426
|
+
**Returns:** Promise<void>
|
|
427
|
+
|
|
428
|
+
##### `startPaymentLite(arguments, countryCode?)`
|
|
429
|
+
|
|
430
|
+
Starts a payment lite flow.
|
|
431
|
+
|
|
432
|
+
**Parameters:**
|
|
433
|
+
- `arguments` (StartPayment): Payment configuration
|
|
434
|
+
- `countryCode` (string, optional): Country code override
|
|
435
|
+
|
|
436
|
+
**Returns:** Promise<void>
|
|
437
|
+
|
|
438
|
+
##### `startPaymentSeamlessLite(arguments)`
|
|
439
|
+
|
|
440
|
+
Starts a seamless payment lite flow.
|
|
441
|
+
|
|
442
|
+
**Parameters:**
|
|
443
|
+
- `arguments` (SeamlessArguments): Seamless payment configuration
|
|
444
|
+
|
|
445
|
+
**Returns:** Promise<YunoStatus>
|
|
446
|
+
|
|
447
|
+
##### `enrollmentPayment(arguments)`
|
|
448
|
+
|
|
449
|
+
Starts an enrollment payment flow.
|
|
450
|
+
|
|
451
|
+
**Parameters:**
|
|
452
|
+
- `arguments` (EnrollmentArguments): Enrollment configuration
|
|
453
|
+
|
|
454
|
+
**Returns:** Promise<void>
|
|
455
|
+
|
|
456
|
+
##### `continuePayment(showPaymentStatus)`
|
|
457
|
+
|
|
458
|
+
Continues a previously started payment.
|
|
459
|
+
|
|
460
|
+
**Parameters:**
|
|
461
|
+
- `showPaymentStatus` (boolean): Show payment status screen
|
|
462
|
+
|
|
463
|
+
**Returns:** Promise<void>
|
|
464
|
+
|
|
465
|
+
##### `hideLoader()`
|
|
466
|
+
|
|
467
|
+
Hides the loading indicator.
|
|
468
|
+
|
|
469
|
+
**Returns:** Promise<void>
|
|
470
|
+
|
|
471
|
+
##### `receiveDeeplink(url)`
|
|
472
|
+
|
|
473
|
+
Handles a deep link for payment resumption (iOS only).
|
|
474
|
+
|
|
475
|
+
**Parameters:**
|
|
476
|
+
- `url` (string): Deep link URL
|
|
477
|
+
|
|
478
|
+
**Returns:** Promise<void>
|
|
479
|
+
|
|
480
|
+
##### `onPaymentStatus(listener)`
|
|
481
|
+
|
|
482
|
+
Subscribes to payment status events.
|
|
483
|
+
|
|
484
|
+
**Parameters:**
|
|
485
|
+
- `listener` (function): Callback function
|
|
486
|
+
|
|
487
|
+
**Returns:** Subscription object with `remove()` method
|
|
488
|
+
|
|
489
|
+
##### `onEnrollmentStatus(listener)`
|
|
490
|
+
|
|
491
|
+
Subscribes to enrollment status events.
|
|
492
|
+
|
|
493
|
+
**Parameters:**
|
|
494
|
+
- `listener` (function): Callback function
|
|
495
|
+
|
|
496
|
+
**Returns:** Subscription object with `remove()` method
|
|
497
|
+
|
|
498
|
+
##### `onOneTimeToken(listener)`
|
|
499
|
+
|
|
500
|
+
Subscribes to one-time token events.
|
|
501
|
+
|
|
502
|
+
**Parameters:**
|
|
503
|
+
- `listener` (function): Callback function
|
|
504
|
+
|
|
505
|
+
**Returns:** Subscription object with `remove()` method
|
|
506
|
+
|
|
507
|
+
### Enums
|
|
508
|
+
|
|
509
|
+
#### YunoLanguage
|
|
510
|
+
|
|
511
|
+
```typescript
|
|
512
|
+
enum YunoLanguage {
|
|
513
|
+
EN = 'EN',
|
|
514
|
+
ES = 'ES',
|
|
515
|
+
PT = 'PT',
|
|
516
|
+
MS = 'MW',
|
|
517
|
+
ID = 'ID',
|
|
518
|
+
TH = 'TH',
|
|
519
|
+
}
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
#### YunoStatus
|
|
523
|
+
|
|
524
|
+
```typescript
|
|
525
|
+
enum YunoStatus {
|
|
526
|
+
REJECTED = 'REJECTED',
|
|
527
|
+
SUCCEEDED = 'SUCCEEDED',
|
|
528
|
+
FAILED = 'FAILED',
|
|
529
|
+
PROCESSING = 'PROCESSING',
|
|
530
|
+
INTERNAL_ERROR = 'INTERNAL_ERROR',
|
|
531
|
+
CANCELLED_BY_USER = 'CANCELLED_BY_USER',
|
|
532
|
+
}
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
#### CardFlow
|
|
536
|
+
|
|
537
|
+
```typescript
|
|
538
|
+
enum CardFlow {
|
|
539
|
+
ONE_STEP = 'ONE_STEP',
|
|
540
|
+
STEP_BY_STEP = 'STEP_BY_STEP',
|
|
541
|
+
}
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
## 🔄 Updating Native SDK Versions
|
|
545
|
+
|
|
546
|
+
### Android Native SDK
|
|
547
|
+
|
|
548
|
+
To update the Android native SDK version:
|
|
549
|
+
|
|
550
|
+
1. Navigate to `node_modules/@y.uno/yuno-sdk-react-native/android/build.gradle`
|
|
551
|
+
2. Update the Yuno Android SDK version:
|
|
552
|
+
```gradle
|
|
553
|
+
dependencies {
|
|
554
|
+
implementation "com.yuno.payments:android-sdk:x.x.x"
|
|
555
|
+
}
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
### iOS Native SDK
|
|
559
|
+
|
|
560
|
+
To update the iOS native SDK version:
|
|
561
|
+
|
|
562
|
+
1. Navigate to `node_modules/@y.uno/yuno-sdk-react-native/ios/YunoSdk.podspec`
|
|
563
|
+
2. Update the Yuno iOS SDK version:
|
|
564
|
+
```ruby
|
|
565
|
+
s.dependency "YunoSDK", "x.x.x"
|
|
566
|
+
```
|
|
567
|
+
3. Run `pod install` in the `ios` directory
|
|
568
|
+
|
|
569
|
+
## 🏗️ Project Structure
|
|
570
|
+
|
|
571
|
+
```
|
|
572
|
+
yuno-sdk-react-native/
|
|
573
|
+
├── src/
|
|
574
|
+
│ ├── core/
|
|
575
|
+
│ │ ├── enums/ # TypeScript enums
|
|
576
|
+
│ │ └── types/ # TypeScript type definitions
|
|
577
|
+
│ ├── YunoSdk.ts # Main SDK class
|
|
578
|
+
│ └── index.ts # Public API exports
|
|
579
|
+
├── android/ # Android native implementation
|
|
580
|
+
│ └── src/main/java/
|
|
581
|
+
│ └── com/yunosdkreactnative/
|
|
582
|
+
│ ├── YunoSdkModule.kt
|
|
583
|
+
│ └── YunoSdkPackage.kt
|
|
584
|
+
├── ios/ # iOS native implementation
|
|
585
|
+
│ ├── YunoSdk.swift
|
|
586
|
+
│ ├── YunoSdk.m
|
|
587
|
+
│ └── YunoSdk.podspec
|
|
588
|
+
└── package.json
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
## 📝 Contributing
|
|
592
|
+
|
|
593
|
+
We welcome contributions! Please feel free to open issues or submit pull requests.
|
|
594
|
+
|
|
595
|
+
### Development Setup
|
|
596
|
+
|
|
597
|
+
1. Clone the repository
|
|
598
|
+
2. Install dependencies: `yarn install`
|
|
599
|
+
3. Run type checking: `yarn typecheck`
|
|
600
|
+
4. Run linting: `yarn lint`
|
|
601
|
+
|
|
602
|
+
## 📄 License
|
|
603
|
+
|
|
604
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
605
|
+
|
|
606
|
+
## 🔗 Links
|
|
607
|
+
|
|
608
|
+
- [Yuno Website](https://www.y.uno/)
|
|
609
|
+
- [Official Documentation](https://docs.y.uno/)
|
|
610
|
+
- [GitHub Repository](https://github.com/yuno-payments/yuno-sdk-react-native)
|
|
611
|
+
|
|
612
|
+
## 💬 Support
|
|
613
|
+
|
|
614
|
+
For issues, questions, or contributions, please open an issue in this repository.
|
|
615
|
+
|
|
616
|
+
---
|
|
617
|
+
|
|
618
|
+
<div align="center">
|
|
619
|
+
Made with ❤️ by the Yuno Team
|
|
620
|
+
</div>
|
|
621
|
+
|