Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 82 additions & 2 deletions packages/apple/Sources/Models/Types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public enum AlternativeBillingModeAndroid: String, Codable, CaseIterable {
case alternativeOnly = "alternative-only"
}

/// Billing program types for external content links and external offers (Android)
/// Available in Google Play Billing Library 8.2.0+
/// Billing program types for external content links, external offers, and external payments (Android)
/// Available in Google Play Billing Library 8.2.0+, EXTERNAL_PAYMENTS added in 8.3.0
public enum BillingProgramAndroid: String, Codable, CaseIterable {
/// Unspecified billing program. Do not use.
case unspecified = "unspecified"
Expand All @@ -31,6 +31,25 @@ public enum BillingProgramAndroid: String, Codable, CaseIterable {
/// External Offers program.
/// Allows offering digital content purchases outside the app.
case externalOffer = "external-offer"
/// External Payments program (Japan only).
/// Allows presenting a side-by-side choice between Google Play Billing and developer's external payment option.
/// Users can choose to complete the purchase on the developer's website.
/// Available in Google Play Billing Library 8.3.0+
case externalPayments = "external-payments"
}

/// Launch mode for developer billing option (Android)
/// Determines how the external payment URL is launched
/// Available in Google Play Billing Library 8.3.0+
public enum DeveloperBillingLaunchModeAndroid: String, Codable, CaseIterable {
/// Unspecified launch mode. Do not use.
case unspecified = "unspecified"
/// Google Play will launch the link in an external browser or eligible app.
/// Use this when you want Play to handle launching the external payment URL.
case launchInExternalBrowserOrApp = "launch-in-external-browser-or-app"
/// The caller app will launch the link after Play returns control.
/// Use this when you want to handle launching the external payment URL yourself.
case callerWillLaunchLink = "caller-will-launch-link"
}

public enum ErrorCode: String, Codable, CaseIterable {
Expand Down Expand Up @@ -194,6 +213,9 @@ public enum IapEvent: String, Codable, CaseIterable {
case purchaseError = "purchase-error"
case promotedProductIos = "promoted-product-ios"
case userChoiceBillingAndroid = "user-choice-billing-android"
/// Fired when user selects developer-provided billing option in external payments flow.
/// Available on Android with Google Play Billing Library 8.3.0+
case developerProvidedBillingAndroid = "developer-provided-billing-android"
}

/// Unified purchase states from IAPKit verification response.
Expand Down Expand Up @@ -401,6 +423,16 @@ public struct BillingProgramReportingDetailsAndroid: Codable {
public var externalTransactionToken: String
}

/// Details provided when user selects developer billing option (Android)
/// Received via DeveloperProvidedBillingListener callback
/// Available in Google Play Billing Library 8.3.0+
public struct DeveloperProvidedBillingDetailsAndroid: Codable {
/// External transaction token used to report transactions made through developer billing.
/// This token must be used when reporting the external transaction to Google Play.
/// Must be reported within 24 hours of the transaction.
public var externalTransactionToken: String
}

/// Discount amount details for one-time purchase offers (Android)
/// Available in Google Play Billing Library 7.0+
public struct DiscountAmountAndroid: Codable {
Expand Down Expand Up @@ -896,6 +928,20 @@ public struct AndroidSubscriptionOfferInput: Codable {
}
}

/// Parameters for creating billing program reporting details (Android)
/// Used with createBillingProgramReportingDetailsAsync
/// Available in Google Play Billing Library 8.3.0+
public struct BillingProgramReportingDetailsParamsAndroid: Codable {
/// The billing program to create reporting details for
public var billingProgram: BillingProgramAndroid

public init(
billingProgram: BillingProgramAndroid
) {
self.billingProgram = billingProgram
}
}

public struct DeepLinkOptions: Codable {
/// Android package name to target (required on Android)
public var packageNameAndroid: String?
Expand All @@ -911,6 +957,28 @@ public struct DeepLinkOptions: Codable {
}
}

/// Parameters for developer billing option in purchase flow (Android)
/// Used with BillingFlowParams to enable external payments flow
/// Available in Google Play Billing Library 8.3.0+
public struct DeveloperBillingOptionParamsAndroid: Codable {
/// The billing program (should be EXTERNAL_PAYMENTS for external payments flow)
public var billingProgram: BillingProgramAndroid
/// The launch mode for the external payment link
public var launchMode: DeveloperBillingLaunchModeAndroid
/// The URI where the external payment will be processed
public var linkUri: String

public init(
billingProgram: BillingProgramAndroid,
launchMode: DeveloperBillingLaunchModeAndroid,
linkUri: String
) {
self.billingProgram = billingProgram
self.launchMode = launchMode
self.linkUri = linkUri
}
}

public struct DiscountOfferInputIOS: Codable {
public var identifier: String
public var keyIdentifier: String
Expand Down Expand Up @@ -1032,6 +1100,10 @@ public struct PurchaseOptions: Codable {
}

public struct RequestPurchaseAndroidProps: Codable {
/// Developer billing option parameters for external payments flow (8.3.0+).
/// When provided, the purchase flow will show a side-by-side choice between
/// Google Play Billing and the developer's external payment option.
public var developerBillingOption: DeveloperBillingOptionParamsAndroid?
/// Personalized offer flag
public var isOfferPersonalized: Bool?
/// Obfuscated account ID
Expand All @@ -1042,11 +1114,13 @@ public struct RequestPurchaseAndroidProps: Codable {
public var skus: [String]

public init(
developerBillingOption: DeveloperBillingOptionParamsAndroid? = nil,
isOfferPersonalized: Bool? = nil,
obfuscatedAccountIdAndroid: String? = nil,
obfuscatedProfileIdAndroid: String? = nil,
skus: [String]
) {
self.developerBillingOption = developerBillingOption
self.isOfferPersonalized = isOfferPersonalized
self.obfuscatedAccountIdAndroid = obfuscatedAccountIdAndroid
self.obfuscatedProfileIdAndroid = obfuscatedProfileIdAndroid
Expand Down Expand Up @@ -1188,6 +1262,10 @@ public struct RequestPurchasePropsByPlatforms: Codable {
}

public struct RequestSubscriptionAndroidProps: Codable {
/// Developer billing option parameters for external payments flow (8.3.0+).
/// When provided, the purchase flow will show a side-by-side choice between
/// Google Play Billing and the developer's external payment option.
public var developerBillingOption: DeveloperBillingOptionParamsAndroid?
/// Personalized offer flag
public var isOfferPersonalized: Bool?
/// Obfuscated account ID
Expand All @@ -1208,6 +1286,7 @@ public struct RequestSubscriptionAndroidProps: Codable {
public var subscriptionProductReplacementParams: SubscriptionProductReplacementParamsAndroid?

public init(
developerBillingOption: DeveloperBillingOptionParamsAndroid? = nil,
isOfferPersonalized: Bool? = nil,
obfuscatedAccountIdAndroid: String? = nil,
obfuscatedProfileIdAndroid: String? = nil,
Expand All @@ -1217,6 +1296,7 @@ public struct RequestSubscriptionAndroidProps: Codable {
subscriptionOffers: [AndroidSubscriptionOfferInput]? = nil,
subscriptionProductReplacementParams: SubscriptionProductReplacementParamsAndroid? = nil
) {
self.developerBillingOption = developerBillingOption
self.isOfferPersonalized = isOfferPersonalized
self.obfuscatedAccountIdAndroid = obfuscatedAccountIdAndroid
self.obfuscatedProfileIdAndroid = obfuscatedProfileIdAndroid
Expand Down
1 change: 1 addition & 0 deletions packages/docs/src/components/MenuDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export function MenuDropdown({
display: 'flex',
alignItems: 'center',
gap: '0.5rem',
padding: '0.4rem 0',
}}
>
<button
Expand Down
24 changes: 20 additions & 4 deletions packages/docs/src/pages/docs/android-setup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,27 @@ function AndroidSetup() {
#
</a>
</h3>
<p>Ensure you have the necessary dependencies:</p>
<pre className="code-block">{`dependencies {
implementation 'com.android.billingclient:billing:6.0.0'
// Your other dependencies
<p>Add the OpenIAP Android dependency:</p>
<pre className="code-block">{`// build.gradle.kts
dependencies {
implementation("io.github.hyochan.openiap:openiap-google:${"$"}version")
}

// Or build.gradle (Groovy)
dependencies {
implementation 'io.github.hyochan.openiap:openiap-google:${"$"}version'
}`}</pre>
<p style={{ marginTop: '0.5rem', fontSize: '0.875rem', color: 'var(--text-secondary)' }}>
Check the latest version at{' '}
<a
href="https://central.sonatype.com/artifact/io.github.hyochan.openiap/openiap-google"
target="_blank"
rel="noopener noreferrer"
>
Maven Central
</a>
.
</p>

<h3 id="configure-proguard" className="anchor-heading">
3. Configure ProGuard (if using)
Expand Down
Loading
Loading