This repository was archived by the owner on Apr 26, 2026. It is now read-only.
Commit 045933e
authored
feat(android): support android billing client 8.2.0 (#3103)
## Summary
This release adds support for **Google Play Billing Library 8.2.0**
features, including the new **Billing Programs API** for external
billing and **one-time product discount support** from Billing Library
7.0+.
## New Features
### 1. Billing Programs API (Android 8.2.0+)
New methods for handling external billing programs:
- `isBillingProgramAvailableAndroid(program)` - Check if a billing
program is available for the user
- `createBillingProgramReportingDetailsAndroid(program)` - Get external
transaction token for reporting
- `launchExternalLinkAndroid(params)` - Launch external link for billing
programs
**Supported Programs:**
- `external-offer` - External offer programs
- `external-content-link` - External content link programs
```tsx
import {
isBillingProgramAvailableAndroid,
createBillingProgramReportingDetailsAndroid,
launchExternalLinkAndroid,
} from 'react-native-iap';
// Step 1: Check availability
const result = await isBillingProgramAvailableAndroid('external-offer');
if (!result.isAvailable) return;
// Step 2: Launch external link
await launchExternalLinkAndroid({
billingProgram: 'external-offer',
launchMode: 'launch-in-external-browser-or-app',
linkType: 'link-to-digital-content-offer',
linkUri: 'https://your-payment-site.com',
});
// Step 3: Get reporting token
const details = await createBillingProgramReportingDetailsAndroid('external-offer');
// Report token to Google Play within 24 hours
```
### 2. One-Time Product Discounts (Android 7.0+)
`oneTimePurchaseOfferDetailsAndroid` is now an **array** to support
multiple offers with discounts.
**New Fields:**
- `offerId` - Unique offer identifier
- `fullPriceMicros` - Original price before discount
- `discountDisplayInfo` - Percentage and amount discount info
- `limitedQuantityInfo` - Purchase quantity limits
- `validTimeWindow` - Offer validity period
- `preorderDetailsAndroid` - Preorder release info
- `rentalDetailsAndroid` - Rental period info
### 3. Purchase Suspension Status (Android 8.1.0+)
- Added `isSuspendedAndroid` field to `PurchaseAndroid` type
## Breaking Changes
### `oneTimePurchaseOfferDetailsAndroid` Type Change
**Before (14.5.x):**
```ts
oneTimePurchaseOfferDetailsAndroid?: ProductAndroidOneTimePurchaseOfferDetail | null;
```
**After (14.6.0):**
```ts
oneTimePurchaseOfferDetailsAndroid?: ProductAndroidOneTimePurchaseOfferDetail[] | null;
```
**Migration:** Update code that accesses this field to handle arrays:
```ts
// Before
const price = product.oneTimePurchaseOfferDetailsAndroid?.formattedPrice;
// After
const offers = product.oneTimePurchaseOfferDetailsAndroid;
const price = offers?.[0]?.formattedPrice;
```
## New Types
```ts
// Billing Programs
type BillingProgramAndroid = 'unspecified' | 'external-content-link' | 'external-offer';
type ExternalLinkLaunchModeAndroid = 'unspecified' | 'launch-in-external-browser-or-app' | 'caller-will-launch-link';
type ExternalLinkTypeAndroid = 'unspecified' | 'link-to-digital-content-offer' | 'link-to-app-download';
interface LaunchExternalLinkParamsAndroid {
billingProgram: BillingProgramAndroid;
launchMode: ExternalLinkLaunchModeAndroid;
linkType: ExternalLinkTypeAndroid;
linkUri: string;
}
interface BillingProgramAvailabilityResultAndroid {
billingProgram: BillingProgramAndroid;
isAvailable: boolean;
}
interface BillingProgramReportingDetailsAndroid {
billingProgram: BillingProgramAndroid;
externalTransactionToken: string;
}
// One-Time Product Discounts
interface DiscountDisplayInfoAndroid {
percentageDiscount?: number | null;
discountAmount?: DiscountAmountAndroid | null;
}
interface DiscountAmountAndroid {
discountAmountMicros: string;
formattedDiscountAmount: string;
}
interface LimitedQuantityInfoAndroid {
maximumQuantity: number;
remainingQuantity: number;
}
interface ValidTimeWindowAndroid {
startTimeMillis: string;
endTimeMillis: string;
}
interface PreorderDetailsAndroid {
preorderReleaseTimeMillis: string;
preorderPresaleEndTimeMillis: string;
}
interface RentalDetailsAndroid {
rentalPeriod: string;
rentalExpirationPeriod?: string | null;
}
```
## OpenIAP Updates
- **openiap-google**: [1.3.10 →
1.3.12](hyodotdev/openiap@google-v1.3.10...google-v1.3.12)
- **openiap-gql**: [1.3.0 →
1.3.2](hyodotdev/openiap@1.3.0...1.3.2)
## Dependency Updates
- **Kotlin**: 2.1.20 → 2.2.0
## Documentation
- Added versioned docs for 14.5 (preserving previous API documentation)
- Updated types documentation with new Android discount fields
- Updated alternative billing guide with Billing Programs API
- Added release blog post for 14.6.0
## Files Changed
### Core Implementation
- `android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt` - Billing
Programs API implementation
- `ios/HybridRnIap.swift` - iOS stub implementations for cross-platform
API
- `src/specs/RnIap.nitro.ts` - Nitro interface definitions
- `src/types.ts` - TypeScript type definitions
- `src/index.ts` - Public API exports
### Example App
- `example/screens/AlternativeBilling.tsx` - Billing Programs API demo
with mode selector
- `example/screens/AllProducts.tsx` - One-time offer discount display
- `example/src/components/AndroidOneTimeOfferDetails.tsx` - Shared
discount component
### Documentation
- `docs/blog/2025-12-11-release-14.6.0-billing-programs.md` - Release
blog post
- `docs/docs/api/types.md` - Updated type documentation
- `docs/docs/api/methods/core-methods.md` - New method documentation
- `docs/docs/guides/alternative-billing.md` - Billing Programs guide
- `docs/docs/examples/alternative-billing.md` - Updated examples
- `docs/versioned_docs/version-14.5/` - Complete 14.5 version
documentation
## Testing
- Added tests for Android one-time purchase offer array handling
- Example app includes full Billing Programs API flow demonstration
## References
- [Google Play Billing Library 8.2.0 Release
Notes](https://developer.android.com/google/play/billing/release-notes#8-2-0)
- [Google Play Billing
Programs](https://developer.android.com/google/play/billing/billing-programs)
- [Google Play One-Time Product
Discounts](https://developer.android.com/google/play/billing/integrate#one-time-discounts)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Google Play Billing Programs API (Android 8.2.0+) —
enable/availability/reporting and external-link launching; richer
Android one‑time offer metadata; purchase suspended flag; example app
verification UI and Android deep‑link flow.
* **Breaking Changes**
* oneTimePurchaseOfferDetailsAndroid changed from a single object to an
array.
* **Documentation**
* Extensive docs, guides and examples for Billing Programs, alternative
billing, offers, installation, error handling, and troubleshooting.
* **Chores**
* Kotlin requirement bumped to 2.2.0+ and Billing Library references
updated.
<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 parent 71c739e commit 045933e
68 files changed
Lines changed: 12282 additions & 243 deletions
File tree
- android/src/main/java/com/margelo/nitro/iap
- docs
- blog
- docs
- api
- methods
- examples
- getting-started
- guides
- troubleshooting
- src/css
- versioned_docs/version-14.5
- api
- methods
- examples
- getting-started
- guides
- versioned_sidebars
- example-expo
- app
- components
- hooks
- scripts
- utils
- example
- __tests__/screens
- android
- ios
- screens
- src
- components
- utils
- ios
- src
- __tests__
- specs
- utils
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 173 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
34 | 39 | | |
35 | 40 | | |
36 | 41 | | |
| |||
815 | 820 | | |
816 | 821 | | |
817 | 822 | | |
818 | | - | |
| 823 | + | |
819 | 824 | | |
820 | 825 | | |
821 | 826 | | |
822 | 827 | | |
823 | 828 | | |
824 | 829 | | |
825 | | - | |
| 830 | + | |
826 | 831 | | |
827 | 832 | | |
828 | 833 | | |
829 | | - | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
830 | 874 | | |
831 | | - | |
| 875 | + | |
832 | 876 | | |
833 | 877 | | |
834 | 878 | | |
| |||
839 | 883 | | |
840 | 884 | | |
841 | 885 | | |
842 | | - | |
| 886 | + | |
843 | 887 | | |
844 | 888 | | |
845 | 889 | | |
| |||
903 | 947 | | |
904 | 948 | | |
905 | 949 | | |
906 | | - | |
| 950 | + | |
907 | 951 | | |
908 | 952 | | |
909 | 953 | | |
| |||
957 | 1001 | | |
958 | 1002 | | |
959 | 1003 | | |
960 | | - | |
| 1004 | + | |
| 1005 | + | |
961 | 1006 | | |
962 | 1007 | | |
963 | 1008 | | |
| |||
1341 | 1386 | | |
1342 | 1387 | | |
1343 | 1388 | | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
1344 | 1510 | | |
1345 | 1511 | | |
1346 | 1512 | | |
| |||
0 commit comments