@gyjshow/react-native-alipay 1.0.5 → 1.0.6

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.
Files changed (2) hide show
  1. package/README.md +144 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -0,0 +1,144 @@
1
+ # @gyjshow/react-native-alipay
2
+
3
+ A lightweight **React Native** plugin for integrating **Alipay** payments on both **iOS** and **Android**.
4
+ Supports initiating payments, setting iOS scheme, and fetching the Alipay SDK version.
5
+
6
+ ---
7
+
8
+ ## Features
9
+
10
+ * 🔹 Unified API for iOS & Android
11
+ * 🔹 Supports initiating Alipay payments
12
+ * 🔹 Fetch Alipay SDK version
13
+ * 🔹 Easy to configure and use in React Native >= 0.83
14
+
15
+ ---
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ # Using npm
21
+ npm install @gyjshow/react-native-alipay
22
+
23
+ # Using pnpm
24
+ pnpm add @gyjshow/react-native-alipay
25
+ ```
26
+
27
+ ### iOS
28
+
29
+ 1. Add your **URL scheme** in `Info.plist` (this will be used in `setAlipayScheme`):
30
+
31
+ ```xml
32
+ <key>CFBundleURLTypes</key>
33
+ <array>
34
+ <dict>
35
+ <key>CFBundleURLSchemes</key>
36
+ <array>
37
+ <string>your_app_scheme</string>
38
+ </array>
39
+ </dict>
40
+ </array>
41
+ ```
42
+
43
+ 2. Install pods:
44
+
45
+ ```bash
46
+ cd ios
47
+ pod install
48
+ ```
49
+
50
+ ### Android
51
+
52
+ No additional configuration required beyond normal React Native setup.
53
+
54
+ ---
55
+
56
+ ## Usage
57
+
58
+ ### Import
59
+
60
+ ```ts
61
+ import Alipay from '@gyjshow/react-native-alipay';
62
+ ```
63
+
64
+ ### Set iOS Scheme (iOS only)
65
+
66
+ ```ts
67
+ Alipay.setAlipayScheme('your_app_scheme');
68
+ ```
69
+
70
+ ### Initiate Payment
71
+
72
+ ```ts
73
+ const payInfo = 'your_order_string_from_server';
74
+ try {
75
+ const result = await Alipay.alipay(payInfo);
76
+ console.log('Payment result:', result);
77
+ } catch (error) {
78
+ console.error('Payment failed:', error);
79
+ }
80
+ ```
81
+
82
+ ### Get Alipay SDK Version
83
+
84
+ ```ts
85
+ const version = await Alipay.getVersion();
86
+ console.log('Alipay SDK version:', version);
87
+ ```
88
+
89
+ ---
90
+
91
+ ## API Reference
92
+
93
+ | Method | Params | Returns | Description |
94
+ | --------------------------------- | ------------------------- | ----------------- | ----------------------------------------------------- |
95
+ | `setAlipayScheme(scheme: string)` | `scheme` - iOS URL scheme | `void` | Sets the Alipay URL scheme for iOS |
96
+ | `alipay(payInfo: string)` | `payInfo` - order string | `Promise<string>` | Initiates Alipay payment, resolves with result string |
97
+ | `getVersion()` | - | `Promise<string>` | Returns the current Alipay SDK version |
98
+
99
+ ---
100
+
101
+ ## Example
102
+
103
+ ```ts
104
+ import React, { useEffect } from 'react';
105
+ import { Button, View, Alert, Platform } from 'react-native';
106
+ import Alipay from '@gyjshow/react-native-alipay';
107
+
108
+ export default function App() {
109
+ useEffect(() => {
110
+ if (Platform.OS === 'ios') {
111
+ Alipay.setAlipayScheme('myapp');
112
+ }
113
+ }, []);
114
+
115
+ const handlePay = async () => {
116
+ try {
117
+ const result = await Alipay.alipay('order_info_from_server');
118
+ Alert.alert('Payment Result', result);
119
+ } catch (e) {
120
+ Alert.alert('Payment Failed', e.message);
121
+ }
122
+ };
123
+
124
+ return (
125
+ <View>
126
+ <Button title="Pay with Alipay" onPress={handlePay} />
127
+ </View>
128
+ );
129
+ }
130
+ ```
131
+
132
+ ---
133
+
134
+ ## Notes
135
+
136
+ * Ensure your server generates valid Alipay order strings.
137
+ * On iOS, **setAlipayScheme** must be called before initiating payment.
138
+ * Test payments in sandbox mode before production.
139
+
140
+ ---
141
+
142
+ ## License
143
+
144
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gyjshow/react-native-alipay",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "private": false,
5
5
  "description": "基于 React Native 的支付宝插件,支持 Android / iOS。",
6
6
  "main": "lib/index.js",