Skip to content
This repository was archived by the owner on Apr 26, 2026. It is now read-only.

Commit 51af058

Browse files
committed
docs: add IAPKit server verification setup and testing guide
1 parent bd56bb1 commit 51af058

2 files changed

Lines changed: 116 additions & 21 deletions

File tree

docs/docs/examples/purchase-flow.md

Lines changed: 83 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,98 @@ await requestPurchase({
5656
- **Validation**: Always validate receipts on your server before finishing
5757
- **Finish transaction**: Call `finishTransaction()` after validation to prevent replay
5858

59-
## IAPKit Verification
59+
## IAPKit Server Verification
6060

61-
For server-side validation without your own infrastructure, use [IAPKit](https://iapkit.com):
61+
[IAPKit](https://iapkit.com) provides server-side receipt verification without your own infrastructure.
62+
63+
### Setup
64+
65+
1. Get your API key from [IAPKit Dashboard](https://iapkit.com)
66+
2. Add environment variable:
67+
```
68+
EXPO_PUBLIC_IAPKIT_API_KEY=your_api_key_here
69+
```
70+
71+
### Usage
72+
73+
```tsx
74+
import {verifyPurchaseWithProvider} from 'react-native-iap';
75+
76+
const verifyPurchase = async (purchase: Purchase) => {
77+
const result = await verifyPurchaseWithProvider({
78+
provider: 'iapkit',
79+
iapkit: {
80+
apiKey: process.env.EXPO_PUBLIC_IAPKIT_API_KEY!,
81+
apple: {jws: purchase.purchaseToken!},
82+
google: {purchaseToken: purchase.purchaseToken!},
83+
},
84+
});
85+
86+
if (result.iapkit.isValid) {
87+
// Grant entitlement to user
88+
await finishTransaction({purchase, isConsumable: true});
89+
}
90+
};
91+
```
92+
93+
### With useIAP Hook
6294

6395
```tsx
64-
const result = await verifyPurchaseWithProvider({
65-
provider: 'iapkit',
66-
iapkit: {
67-
apiKey: IAPKIT_API_KEY,
68-
apple: {jws: purchase.purchaseToken!},
69-
google: {purchaseToken: purchase.purchaseToken!},
96+
const {finishTransaction} = useIAP({
97+
onPurchaseSuccess: async (purchase) => {
98+
const result = await verifyPurchaseWithProvider({
99+
provider: 'iapkit',
100+
iapkit: {
101+
apiKey: process.env.EXPO_PUBLIC_IAPKIT_API_KEY!,
102+
apple: {jws: purchase.purchaseToken!},
103+
google: {purchaseToken: purchase.purchaseToken!},
104+
},
105+
});
106+
107+
if (result.iapkit.isValid) {
108+
await finishTransaction({purchase, isConsumable: true});
109+
}
70110
},
71111
});
112+
```
113+
114+
### Verification Response
72115

73-
if (result.iapkit.isValid) {
74-
await finishTransaction({purchase, isConsumable: true});
116+
IAPKit returns a standardized response:
117+
118+
```typescript
119+
interface IapkitVerificationResult {
120+
isValid: boolean;
121+
state: IapkitPurchaseState;
122+
store: 'apple' | 'google';
75123
}
124+
125+
type IapkitPurchaseState =
126+
| 'entitled'
127+
| 'pending-acknowledgment'
128+
| 'pending'
129+
| 'canceled'
130+
| 'expired'
131+
| 'ready-to-consume'
132+
| 'consumed'
133+
| 'unknown'
134+
| 'inauthentic';
76135
```
77136

137+
### Verification Methods
138+
139+
| Method | Description | Use Case |
140+
| ------------------- | ------------------------------------ | ---------------------- |
141+
| **None (Skip)** | Skip verification | Testing/Development |
142+
| **Local (Device)** | Verify with Apple/Google directly | Simple validation |
143+
| **IAPKit (Server)** | Server-side verification via IAPKit | Production recommended |
144+
145+
### Testing
146+
147+
The [example app](https://github.com/hyochan/react-native-iap/blob/main/example/screens/PurchaseFlow.tsx) has built-in IAPKit support. Set your API key and use the "Purchase Verification" button to test.
148+
149+
For more information, visit [IAPKit Documentation](https://iapkit.com/docs).
150+
78151
## Resources
79152

80153
- [Complete example](https://github.com/hyochan/react-native-iap/blob/main/example/screens/PurchaseFlow.tsx)

docs/docs/examples/subscription-flow.md

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,23 +101,45 @@ await requestPurchase({
101101
| `2` | CHARGE_PRORATED_PRICE | Immediate with prorated charge |
102102
| `6` | DEFERRED | Change at next renewal |
103103

104-
## IAPKit Verification
104+
## IAPKit Server Verification
105+
106+
[IAPKit](https://iapkit.com) provides server-side subscription verification without your own infrastructure.
107+
108+
### Setup
109+
110+
1. Get your API key from [IAPKit Dashboard](https://iapkit.com)
111+
2. Add environment variable:
112+
```
113+
EXPO_PUBLIC_IAPKIT_API_KEY=your_api_key_here
114+
```
115+
116+
### Usage
105117

106118
```tsx
107-
const result = await verifyPurchaseWithProvider({
108-
provider: 'iapkit',
109-
iapkit: {
110-
apiKey: IAPKIT_API_KEY,
111-
apple: {jws: purchase.purchaseToken!},
112-
google: {purchaseToken: purchase.purchaseToken!},
119+
import {verifyPurchaseWithProvider} from 'react-native-iap';
120+
121+
const {finishTransaction} = useIAP({
122+
onPurchaseSuccess: async (purchase) => {
123+
const result = await verifyPurchaseWithProvider({
124+
provider: 'iapkit',
125+
iapkit: {
126+
apiKey: process.env.EXPO_PUBLIC_IAPKIT_API_KEY!,
127+
apple: {jws: purchase.purchaseToken!},
128+
google: {purchaseToken: purchase.purchaseToken!},
129+
},
130+
});
131+
132+
if (result.iapkit.isValid) {
133+
await finishTransaction({purchase});
134+
}
113135
},
114136
});
115-
116-
if (result.iapkit.isValid) {
117-
await finishTransaction({purchase});
118-
}
119137
```
120138

139+
### Testing
140+
141+
The [example app](https://github.com/hyochan/react-native-iap/blob/main/example/screens/SubscriptionFlow.tsx) has built-in IAPKit support. Set your API key and test subscription verification.
142+
121143
## Key Points
122144

123145
- **iOS**: Use subscription groups for automatic plan management

0 commit comments

Comments
 (0)