@oxyhq/services 5.12.1 → 5.12.3
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/lib/commonjs/ui/components/OxyProvider.js +3 -36
- package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
- package/lib/commonjs/ui/index.js +0 -1
- package/lib/commonjs/ui/index.js.map +1 -1
- package/lib/commonjs/ui/screens/PaymentGatewayScreen.js +0 -153
- package/lib/commonjs/ui/screens/PaymentGatewayScreen.js.map +1 -1
- package/lib/module/ui/components/OxyProvider.js +5 -38
- package/lib/module/ui/components/OxyProvider.js.map +1 -1
- package/lib/module/ui/index.js +1 -1
- package/lib/module/ui/index.js.map +1 -1
- package/lib/module/ui/screens/PaymentGatewayScreen.js +1 -153
- package/lib/module/ui/screens/PaymentGatewayScreen.js.map +1 -1
- package/lib/typescript/ui/components/OxyProvider.d.ts.map +1 -1
- package/lib/typescript/ui/index.d.ts.map +1 -1
- package/lib/typescript/ui/screens/PaymentGatewayScreen.d.ts.map +1 -1
- package/package.json +1 -6
- package/src/ui/components/OxyProvider.tsx +4 -37
- package/src/ui/index.ts +1 -1
- package/src/ui/screens/PaymentGatewayScreen.tsx +6 -154
|
@@ -25,7 +25,7 @@ import { Ionicons } from '@expo/vector-icons';
|
|
|
25
25
|
import { FAIRWalletIcon } from '../components/icon';
|
|
26
26
|
import { toast } from 'sonner';
|
|
27
27
|
import QRCode from 'react-native-qrcode-svg';
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
import { GroupedSection } from '../components';
|
|
30
30
|
|
|
31
31
|
// Restrict payment methods to Card, Oxy Pay, and FairCoin (QR)
|
|
@@ -35,16 +35,7 @@ const PAYMENT_METHODS = [
|
|
|
35
35
|
{ key: 'faircoin', label: 'FAIRWallet', icon: 'qr-code-outline', description: 'Pay with FairCoin by scanning a QR code.' },
|
|
36
36
|
];
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
const ANDROID_IAP_METHOD = {
|
|
40
|
-
key: 'googleplay',
|
|
41
|
-
label: 'Google Play Billing',
|
|
42
|
-
icon: 'logo-google-playstore',
|
|
43
|
-
description: 'Pay securely with your Google Play account.'
|
|
44
|
-
};
|
|
45
|
-
if (Platform.OS === 'android' && !PAYMENT_METHODS.find(m => m.key === 'googleplay')) {
|
|
46
|
-
PAYMENT_METHODS.push(ANDROID_IAP_METHOD);
|
|
47
|
-
}
|
|
38
|
+
|
|
48
39
|
|
|
49
40
|
// Add PaymentItem type
|
|
50
41
|
export type PaymentItem = {
|
|
@@ -116,7 +107,6 @@ const getItemTypeIcon = (type: string, color: string) => {
|
|
|
116
107
|
}
|
|
117
108
|
};
|
|
118
109
|
|
|
119
|
-
const IAP_PRODUCT_IDS = ['test_product_1', 'test_product_2']; // TODO: Replace with real product IDs
|
|
120
110
|
|
|
121
111
|
// Helper to get unique item types (move to top-level, before component)
|
|
122
112
|
const getUniqueItemTypes = (items: PaymentItem[]) => {
|
|
@@ -155,11 +145,7 @@ const PaymentGatewayScreen: React.FC<PaymentGatewayScreenProps> = (props) => {
|
|
|
155
145
|
const [isPaying, setIsPaying] = useState(false);
|
|
156
146
|
const [success, setSuccess] = useState(false);
|
|
157
147
|
|
|
158
|
-
|
|
159
|
-
const [iapProducts, setIapProducts] = useState<RNIap.Product[]>([]);
|
|
160
|
-
const [iapError, setIapError] = useState<string | null>(null);
|
|
161
|
-
const [iapLoading, setIapLoading] = useState(false);
|
|
162
|
-
const [iapPurchase, setIapPurchase] = useState<RNIap.Purchase | null>(null);
|
|
148
|
+
|
|
163
149
|
|
|
164
150
|
// Animations
|
|
165
151
|
const fadeAnim = useRef(new Animated.Value(1)).current;
|
|
@@ -335,42 +321,7 @@ const PaymentGatewayScreen: React.FC<PaymentGatewayScreenProps> = (props) => {
|
|
|
335
321
|
Linking.openURL(url);
|
|
336
322
|
};
|
|
337
323
|
|
|
338
|
-
|
|
339
|
-
useEffect(() => {
|
|
340
|
-
if (paymentMethod !== 'googleplay' || Platform.OS !== 'android') return;
|
|
341
|
-
let purchaseUpdateSub: any, purchaseErrorSub: any;
|
|
342
|
-
setIapLoading(true);
|
|
343
|
-
RNIap.initConnection()
|
|
344
|
-
.then(() => RNIap.getProducts({ skus: IAP_PRODUCT_IDS }))
|
|
345
|
-
.then(setIapProducts)
|
|
346
|
-
.catch((e: any) => setIapError(e.message))
|
|
347
|
-
.finally(() => setIapLoading(false));
|
|
348
|
-
purchaseUpdateSub = RNIap.purchaseUpdatedListener((purchase: any) => {
|
|
349
|
-
setIapPurchase(purchase);
|
|
350
|
-
setSuccess(true);
|
|
351
|
-
nextStep();
|
|
352
|
-
});
|
|
353
|
-
purchaseErrorSub = RNIap.purchaseErrorListener((err: any) => {
|
|
354
|
-
setIapError(err.message);
|
|
355
|
-
});
|
|
356
|
-
return () => {
|
|
357
|
-
purchaseUpdateSub && purchaseUpdateSub.remove();
|
|
358
|
-
purchaseErrorSub && purchaseErrorSub.remove();
|
|
359
|
-
RNIap.endConnection();
|
|
360
|
-
};
|
|
361
|
-
}, [paymentMethod]);
|
|
362
|
-
|
|
363
|
-
const handleIapBuy = async (sku: string) => {
|
|
364
|
-
setIapError(null);
|
|
365
|
-
setIapLoading(true);
|
|
366
|
-
try {
|
|
367
|
-
await RNIap.requestPurchase({ sku });
|
|
368
|
-
} catch (e: any) {
|
|
369
|
-
setIapError(e.message);
|
|
370
|
-
} finally {
|
|
371
|
-
setIapLoading(false);
|
|
372
|
-
}
|
|
373
|
-
};
|
|
324
|
+
|
|
374
325
|
|
|
375
326
|
// Helper for dynamic styles
|
|
376
327
|
const getStepIndicatorStyle = (active: boolean) => [
|
|
@@ -842,73 +793,13 @@ const PaymentGatewayScreen: React.FC<PaymentGatewayScreenProps> = (props) => {
|
|
|
842
793
|
</Animated.View>
|
|
843
794
|
);
|
|
844
795
|
|
|
845
|
-
// Step: Google Play Billing (Android only)
|
|
846
|
-
const renderGooglePlayStep = () => (
|
|
847
|
-
<Animated.View style={[styles.stepContainer, {
|
|
848
|
-
opacity: fadeAnim,
|
|
849
|
-
transform: [
|
|
850
|
-
{ translateY: slideAnim },
|
|
851
|
-
{ scale: scaleAnim },
|
|
852
|
-
]
|
|
853
|
-
}]}
|
|
854
|
-
>
|
|
855
|
-
<View style={styles.section}>
|
|
856
|
-
<Text style={styles.sectionTitle}>Google Play Products</Text>
|
|
857
|
-
|
|
858
|
-
{iapLoading && (
|
|
859
|
-
<View style={styles.loadingContainer}>
|
|
860
|
-
<Text style={styles.loadingText}>Loading products...</Text>
|
|
861
|
-
</View>
|
|
862
|
-
)}
|
|
863
796
|
|
|
864
|
-
{iapError && (
|
|
865
|
-
<View style={styles.paymentErrorContainer}>
|
|
866
|
-
<Text style={styles.paymentErrorText}>{iapError}</Text>
|
|
867
|
-
</View>
|
|
868
|
-
)}
|
|
869
|
-
|
|
870
|
-
{!iapLoading && !iapError && (
|
|
871
|
-
<GroupedSection
|
|
872
|
-
items={iapProducts.map(product => ({
|
|
873
|
-
id: product.productId,
|
|
874
|
-
icon: 'pricetag',
|
|
875
|
-
iconColor: colors.primary,
|
|
876
|
-
title: product.title,
|
|
877
|
-
subtitle: product.localizedPrice,
|
|
878
|
-
onPress: () => handleIapBuy(product.productId),
|
|
879
|
-
disabled: iapLoading,
|
|
880
|
-
}))}
|
|
881
|
-
theme={theme}
|
|
882
|
-
/>
|
|
883
|
-
)}
|
|
884
|
-
|
|
885
|
-
{iapPurchase && (
|
|
886
|
-
<View style={styles.iapSuccessContainer}>
|
|
887
|
-
<Text style={styles.iapSuccessText}>Purchase successful!</Text>
|
|
888
|
-
</View>
|
|
889
|
-
)}
|
|
890
|
-
</View>
|
|
891
|
-
<GroupedPillButtons
|
|
892
|
-
buttons={[
|
|
893
|
-
{
|
|
894
|
-
text: 'Back',
|
|
895
|
-
onPress: prevStep,
|
|
896
|
-
icon: 'arrow-back',
|
|
897
|
-
variant: 'transparent',
|
|
898
|
-
},
|
|
899
|
-
]}
|
|
900
|
-
colors={colors}
|
|
901
|
-
/>
|
|
902
|
-
</Animated.View>
|
|
903
|
-
);
|
|
904
797
|
|
|
905
798
|
const renderCurrentStep = () => {
|
|
906
799
|
switch (currentStep) {
|
|
907
800
|
case 0: return renderSummaryStep();
|
|
908
801
|
case 1: return renderMethodStep();
|
|
909
|
-
case 2:
|
|
910
|
-
if (paymentMethod === 'googleplay') return renderGooglePlayStep();
|
|
911
|
-
return renderDetailsStep();
|
|
802
|
+
case 2: return renderDetailsStep();
|
|
912
803
|
case 3: return renderReviewStep();
|
|
913
804
|
case 4: return renderSuccessStep();
|
|
914
805
|
default: return renderSummaryStep();
|
|
@@ -1410,46 +1301,7 @@ const createStyles = (colors: any, theme: string) => StyleSheet.create({
|
|
|
1410
1301
|
marginTop: 6,
|
|
1411
1302
|
marginBottom: 2,
|
|
1412
1303
|
},
|
|
1413
|
-
|
|
1414
|
-
loadingContainer: {
|
|
1415
|
-
padding: 16,
|
|
1416
|
-
alignItems: 'center',
|
|
1417
|
-
backgroundColor: '#fff',
|
|
1418
|
-
borderRadius: 12,
|
|
1419
|
-
marginBottom: 16,
|
|
1420
|
-
},
|
|
1421
|
-
loadingText: {
|
|
1422
|
-
color: colors.secondaryText,
|
|
1423
|
-
fontSize: 16,
|
|
1424
|
-
fontStyle: 'italic',
|
|
1425
|
-
},
|
|
1426
|
-
paymentErrorContainer: {
|
|
1427
|
-
padding: 16,
|
|
1428
|
-
backgroundColor: '#ffebee',
|
|
1429
|
-
borderRadius: 12,
|
|
1430
|
-
marginBottom: 16,
|
|
1431
|
-
borderWidth: 1,
|
|
1432
|
-
borderColor: '#ffcdd2',
|
|
1433
|
-
},
|
|
1434
|
-
paymentErrorText: {
|
|
1435
|
-
color: '#d32f2f',
|
|
1436
|
-
fontSize: 14,
|
|
1437
|
-
textAlign: 'center',
|
|
1438
|
-
},
|
|
1439
|
-
iapSuccessContainer: {
|
|
1440
|
-
padding: 16,
|
|
1441
|
-
backgroundColor: '#e8f5e8',
|
|
1442
|
-
borderRadius: 12,
|
|
1443
|
-
marginTop: 16,
|
|
1444
|
-
borderWidth: 1,
|
|
1445
|
-
borderColor: '#c8e6c9',
|
|
1446
|
-
},
|
|
1447
|
-
iapSuccessText: {
|
|
1448
|
-
color: colors.success || '#4BB543',
|
|
1449
|
-
fontSize: 16,
|
|
1450
|
-
textAlign: 'center',
|
|
1451
|
-
fontWeight: '600',
|
|
1452
|
-
},
|
|
1304
|
+
|
|
1453
1305
|
// Summary step styles
|
|
1454
1306
|
summaryDescriptionContainer: {
|
|
1455
1307
|
marginBottom: 16,
|