The Billing Programs API is the modern way to handle external billing programs in Google Play Billing Library 8.2.0+. It provides methods to check availability, launch external purchase flows, and retrieve reporting tokens for transactions made outside of Google Play.
Important Requirements:
- The external transaction token must be reported to the Google Play backend within 24 hours.
- Requires server-side integration with the Google Play Developer API.
- Failure to report tokens can result in refunds and account suspension.
import {
isBillingProgramAvailableAndroid,
launchExternalLinkAndroid,
createBillingProgramReportingDetailsAndroid,
} from 'expo-iap';
async function purchaseWithBillingProgram(productId: string) {
// Step 1: Check availability
const availability = await isBillingProgramAvailableAndroid('external-offer');
if (!availability.isAvailable) {
throw new Error('External offer program not available');
}
// 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/purchase/${productId}`,
});
// Step 3: After payment completes, get reporting token
const details = await createBillingProgramReportingDetailsAndroid('external-offer');
// Step 4: Report to Google (must be done within 24 hours)
await reportToGooglePlayBackend(details.externalTransactionToken, productId);
return {success: true, token: details.externalTransactionToken};
}