Skip to content

Commit 927d0af

Browse files
feat: integrate local search functionality and enhance documentation
- Added `@easyops-cn/docusaurus-search-local` package for improved search capabilities in the documentation. - Configured the search plugin in `docusaurus.config.ts` to index documentation. - Updated sidebar to include new navigation items for better user experience. - Enhanced the examples and payment flow documentation to clarify integration steps and usage patterns. - Removed outdated "Common mistakes" guide and streamlined troubleshooting content for clarity.
1 parent 620b517 commit 927d0af

29 files changed

Lines changed: 561 additions & 682 deletions

bun.lock

Lines changed: 82 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/docs/api/components.md

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,7 @@ import { ApplePayButton } from '@gmisoftware/react-native-pay'
3636

3737
### Nitro and onPress
3838

39-
If `onPress` does not fire (e.g. with Nitro host components), wrap the handler with `callback` from `react-native-nitro-modules`:
40-
41-
```tsx
42-
import { callback } from 'react-native-nitro-modules'
43-
44-
<ApplePayButton
45-
buttonType="buy"
46-
buttonStyle="black"
47-
onPress={callback(handlePayment)}
48-
style={{ width: '100%', height: 48 }}
49-
/>
50-
```
39+
If `onPress` does not fire, use Nitro's `callback(...)` wrapper. See [Troubleshooting: Nitro callback for onPress](/docs/troubleshooting#nitro-callback-for-onpress).
5140

5241
---
5342

@@ -84,7 +73,7 @@ import { GooglePayButton } from '@gmisoftware/react-native-pay'
8473

8574
### Nitro and onPress
8675

87-
Same as Apple: if needed, use `callback(handlePayment)` for `onPress`.
76+
Same as Apple: if needed, use `callback(handlePayment)` for `onPress`. See [Troubleshooting: Nitro callback for onPress](/docs/troubleshooting#nitro-callback-for-onpress).
8877

8978
---
9079

docs/docs/api/types.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ Use `'TEST'` for development/sandbox; `'PRODUCTION'` for live charges.
147147
148148
## Pass types (iOS)
149149
150+
These iOS-only types appear in payment-related metadata returned by Apple Pay APIs (for example pass details tied to the selected card) and are mostly useful in advanced/native-integrated flows.
151+
150152
```ts
151153
type PassActivationState =
152154
| 'activated'
@@ -178,6 +180,8 @@ interface PKSecureElementPass extends PKPass {
178180

179181
Used on iOS when `billingContactRequired` / `shippingContactRequired` is requested in `PaymentRequest`.
180182

183+
These fields are populated from the contact information the user approves in the Apple Pay sheet.
184+
181185
```ts
182186
type CNContactType = 'person' | 'organization'
183187

docs/docs/api/use-payment-checkout.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import { usePaymentCheckout } from '@gmisoftware/react-native-pay'
1212

1313
Pass a single config object. iOS reads the Apple Pay merchant ID from the native app configuration. Use `applePayMerchantIdentifier` only if you need to override it at runtime.
1414

15+
Source of truth for these types: [`package/src/hooks/usePaymentCheckout.ts`](https://github.com/gmi-software/react-native-pay/blob/main/package/src/hooks/usePaymentCheckout.ts).
16+
1517
```ts
1618
interface UsePaymentCheckoutConfig {
1719
merchantName?: string
@@ -115,7 +117,7 @@ If you call `startPayment()` when `items.length === 0`, the hook sets `error` to
115117

116118
Use `usePaymentCheckout` when you want cart state + defaults managed in React state.
117119

118-
Use [HybridPaymentHandler](/docs/api/hybrid-payment-handler) when you need to build the full `PaymentRequest` yourself (for example custom shipping/contact requirements or prebuilt request payloads from your backend).
120+
Use [HybridPaymentHandler](/docs/api/hybrid-payment-handler) when you need to build the full `PaymentRequest` yourself (for example custom shipping/contact requirements or prebuilt request payloads from your backend). Utility helpers for this path are documented in [Utility functions](/docs/api/utils).
119121

120122
## Next
121123

docs/docs/api/utils.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
Helpers for building payment requests, items, and formatting. All are exported from `@gmisoftware/react-native-pay`.
44

5+
## When to use these helpers
6+
7+
Use these functions when you are building a manual or low-level flow (usually with `HybridPaymentHandler`) and need to assemble `PaymentRequest` data yourself.
8+
9+
If you use `usePaymentCheckout`, cart state and request building are handled for you internally, so these helpers are optional.
10+
511
## createPaymentRequest(options)
612

713
Builds a full `PaymentRequest` with one line item and sensible defaults.

docs/docs/examples.md

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,75 @@
22

33
The repository includes a full example app in the **`example/`** folder: an Expo app that demonstrates the checkout flow with `usePaymentCheckout`, cart management, and platform-specific buttons.
44

5-
## What’s in the example
5+
## Key checkout snippet
6+
7+
From `example/app/(tabs)/index.tsx`:
8+
9+
```tsx
10+
import { Platform } from 'react-native'
11+
import {
12+
ApplePayButton,
13+
GooglePayButton,
14+
usePaymentCheckout,
15+
} from '@gmisoftware/react-native-pay'
16+
import { callback } from 'react-native-nitro-modules'
17+
18+
const {
19+
canMakePayments,
20+
isCheckingStatus,
21+
items,
22+
total,
23+
addItems,
24+
clearItems,
25+
startPayment,
26+
isProcessing,
27+
reset,
28+
} = usePaymentCheckout({
29+
countryCode: 'US',
30+
currencyCode: 'USD',
31+
})
32+
33+
const handleAddCoffee = () => {
34+
clearItems()
35+
addItems([
36+
{ label: 'Coffee', amount: 4.99 },
37+
{ label: 'Tax', amount: 0.5 },
38+
])
39+
}
40+
41+
const handlePayment = async () => {
42+
const paymentResult = await startPayment()
43+
if (paymentResult?.success) {
44+
reset()
45+
clearItems()
46+
}
47+
}
48+
49+
{Platform.OS === 'ios' ? (
50+
<ApplePayButton
51+
buttonType="buy"
52+
buttonStyle="black"
53+
onPress={callback(handlePayment)}
54+
style={{ width: '100%', height: 56 }}
55+
/>
56+
) : (
57+
<GooglePayButton
58+
buttonType="buy"
59+
theme="dark"
60+
radius={8}
61+
onPress={callback(handlePayment)}
62+
style={{ width: '100%', height: 56 }}
63+
/>
64+
)}
65+
```
66+
67+
## What’s in the full example
668

769
- **Checkout flow** — Add items (e.g. “Coffee”, “Subscription”), see cart and total, then pay with Apple Pay or Google Pay.
870
- **Status** — Check whether the device can make payments or only set up cards.
971
- **Cart UI** — Add/clear items and display total.
1072
- **Result handling** — Success and error messages; reset and clear cart after success.
11-
- **Nitro `callback`** — Buttons use `callback(handlePayment)` from `react-native-nitro-modules` so `onPress` works correctly with Nitro host components.
73+
- **Nitro `callback`** — Buttons use `callback(handlePayment)` (see [Troubleshooting: Nitro callback for onPress](/docs/troubleshooting#nitro-callback-for-onpress)).
1274

1375
## Run the example
1476

@@ -42,7 +104,7 @@ Use the checkout screen in the example app as a reference for:
42104
5. Renders **ApplePayButton** on iOS and **GooglePayButton** on Android with `callback(handlePayment)`.
43105
6. On successful payment, shows an alert and calls `reset()` and `clearItems()`.
44106

45-
Copy these patterns into your app: config setup, cart handling, button usage, and `callback(...)` wrapping where needed.
107+
Copy these patterns into your app: config setup, cart handling, button usage, and native-safe `onPress` handlers.
46108

47109
## Plugin config in the example
48110

@@ -52,4 +114,4 @@ The example’s **`app.json`** includes the React Native Pay plugin (e.g. with a
52114

53115
- [Quick Start](/docs/quick-start) — Minimal integration in your app
54116
- [API: usePaymentCheckout](/docs/api/use-payment-checkout) — Hook options and return value
55-
- [Common mistakes](/docs/guides/common-mistakes)What to avoid
117+
- [Troubleshooting](/docs/troubleshooting)Common integration issues and fixes

docs/docs/guides/common-mistakes.md

Lines changed: 0 additions & 93 deletions
This file was deleted.

docs/docs/guides/server-processing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ app.post('/process-payment', async (req, res) => {
6969
- Creating a payment method/source/intent from Apple Pay or Google Pay token payloads.
7070
- Idempotency (e.g. using `transactionId` to avoid duplicate charges).
7171
- Handling failures and refunds.
72-
- Provider-specific walkthroughs in [Integrations](/docs/integrations/overview) (for example: [Przelewy24 Apple Pay + Google Pay cookbook](/docs/integrations/przelewy24)).
72+
- Provider-specific walkthroughs in [Przelewy24 Apple Pay + Google Pay cookbook](/docs/integrations/przelewy24).
7373

7474
## Security
7575

docs/docs/integrations/overview.md

Lines changed: 0 additions & 28 deletions
This file was deleted.

docs/docs/integrations/przelewy24.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
This cookbook shows how to use `@gmisoftware/react-native-pay` for wallet payments and process them with Przelewy24 on your backend.
44

5+
The library is not a gateway SDK. It only presents the native payment sheet and returns the payment token that your backend maps to Przelewy24 APIs.
6+
57
It follows the same contract used across this library:
68

79
- the app collects `PaymentResult` and `PaymentToken`

0 commit comments

Comments
 (0)