Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return ability to set 'obfuscatedAccountId' and 'obfuscatedProfileId' for android billing v3 #1141

Merged
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ Method
`getSubscriptions(skus: string[])`<ul><li>skus: array of Subscription ID/sku</li></ul> | `Promise<Subscription[]>` | Get a list of subscriptions.<br>Note: With before `iOS 11.2`, this method _will_ also return products if they are included in your list of SKUs. This is because we cannot differentiate between IAP products and subscriptions prior to `iOS 11.2`.
`getPurchaseHistory()` | `Promise<Purchase>` | Gets an inventory of purchases made by the user regardless of consumption status (where possible).
`getAvailablePurchases()` | `Promise<Purchase[]>` | Get all purchases made by the user (either non-consumable, or haven't been consumed yet). On Android, it can be called at app launch, but on iOS, only at restoring purchase is recommended (See: [#747](https://github.com/dooboolab/react-native-iap/issues/747)).
`requestPurchase(sku: string, andDangerouslyFinishTransactionAutomatically: boolean)`<ul></ul> | `Promise<ProductPurchase>` | Request a purchase.<br>`purchaseUpdatedListener` will receive the result.<br/> `andDangerouslyFinishTransactionAutomatically` defaults to `true` for backwards compatibility but this is deprecated and you should set it to false once you're [manually finishing your transactions][a-purchase-flow].
`requestPurchase(sku: string, andDangerouslyFinishTransactionAutomatically: boolean, obfuscatedAccountIdAndroid: string, obfuscatedProfileIdAndroid: string)`<ul></ul> | `Promise<ProductPurchase>` | Request a purchase.<br>`purchaseUpdatedListener` will receive the result.<br/> `andDangerouslyFinishTransactionAutomatically` defaults to `true` for backwards compatibility but this is deprecated and you should set it to false once you're [manually finishing your transactions][a-purchase-flow].
`requestPurchaseWithQuantityIOS(sku: string, quantity: number)`<ul><li>sku: product ID/sku</li><li>quantity: Quantity</li></ul> | `void` | **iOS only**<br>Buy a product with a specified quantity.<br>`purchaseUpdatedListener` will receive the result
_*deprecated_<br>~~`buySubscription(sku: string)`~~<ul><li>sku: subscription ID/sku</li></ul> | `void` | Create (buy) a subscription to a sku.
`requestSubscription(sku: string, andDangerouslyFinishTransactionAutomaticallyIOS: boolean, oldSkuAndroid: string, purchaseTokenAndroid: string, prorationModeAndroid: string)`<ul><li>sku: subscription ID/sku</li></ul> | `void` | Create (buy) a subscription to a sku.
`requestSubscription(sku: string, andDangerouslyFinishTransactionAutomaticallyIOS: boolean, oldSkuAndroid: string, purchaseTokenAndroid: string, prorationModeAndroid: string, obfuscatedAccountIdAndroid: string, obfuscatedProfileIdAndroid: string)`<ul><li>sku: subscription ID/sku</li></ul> | `void` | Create (buy) a subscription to a sku.
`clearTransactionIOS()` | `void` | **iOS only**<br>Clear up unfinished transanctions which sometimes cause problems. Read more in [#257](https://github.com/dooboolab/react-native-iap/issues/257), [#801](https://github.com/dooboolab/react-native-iap/issues/801).
`clearProductsIOS()` | `void` | **iOS only**<br>Clear all products and subscriptions.<br>Read more in below README.
`getReceiptIOS()` | `Promise<string>` | **iOS only**<br>Get the current receipt.
Expand Down
10 changes: 10 additions & 0 deletions android/src/main/java/com/dooboolab/RNIap/RNIapModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ public void buyItemByType(
final String oldSku,
final String purchaseToken,
final Integer prorationMode,
final String obfuscatedAccountId,
final String obfuscatedProfileId,
final Promise promise
) {
final Activity activity = getCurrentActivity();
Expand Down Expand Up @@ -459,6 +461,14 @@ public void run() {
builder.setOldSku(oldSku, purchaseToken);
}

if (obfuscatedAccountId != null) {
builder.setObfuscatedAccountId(obfuscatedAccountId);
}

if (obfuscatedProfileId != null) {
builder.setObfuscatedProfileId(obfuscatedProfileId);
}

if (prorationMode != null && prorationMode != -1) {
if (prorationMode == BillingFlowParams.ProrationMode.IMMEDIATE_AND_CHARGE_PRORATED_PRICE) {
builder.setReplaceSkusProrationMode(BillingFlowParams.ProrationMode.IMMEDIATE_AND_CHARGE_PRORATED_PRICE);
Expand Down
13 changes: 12 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,15 @@ InAppPurchase | SubscriptionPurchase
* Request a purchase for product. This will be received in `PurchaseUpdatedListener`.
* @param {string} sku The product's sku/ID
* @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.
* @param {string} [userIdAndroid] Specify an optional obfuscated string that is uniquely associated with the user's account in.
* @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.
* @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.
* @returns {Promise<InAppPurchase>}
*/
export const requestPurchase = (
sku: string,
andDangerouslyFinishTransactionAutomaticallyIOS?: boolean,
obfuscatedAccountIdAndroid?: string,
obfuscatedProfileIdAndroid?: string,
): Promise<InAppPurchase> =>
Platform.select({
ios: async () => {
Expand All @@ -361,6 +364,8 @@ export const requestPurchase = (
null,
null,
0,
obfuscatedAccountIdAndroid,
obfuscatedProfileIdAndroid,
);
},
})();
Expand All @@ -371,6 +376,8 @@ export const requestPurchase = (
* @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.
* @param {string} [oldSkuAndroid] SKU that the user is upgrading or downgrading from.
* @param {string} [purchaseTokenAndroid] purchaseToken that the user is upgrading or downgrading from (Android).
* @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.
* @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.
* @param {ProrationModesAndroid} [prorationModeAndroid] UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, IMMEDIATE_WITH_TIME_PRORATION, IMMEDIATE_AND_CHARGE_PRORATED_PRICE, IMMEDIATE_WITHOUT_PRORATION, DEFERRED
* @returns {Promise<void>}
*/
Expand All @@ -380,6 +387,8 @@ export const requestSubscription = (
oldSkuAndroid?: string,
purchaseTokenAndroid?: string,
prorationModeAndroid?: ProrationModesAndroid,
obfuscatedAccountIdAndroid?: string,
obfuscatedProfileIdAndroid?: string,
): Promise<SubscriptionPurchase> =>
Platform.select({
ios: async () => {
Expand Down Expand Up @@ -407,6 +416,8 @@ export const requestSubscription = (
oldSkuAndroid,
purchaseTokenAndroid,
prorationModeAndroid,
obfuscatedAccountIdAndroid,
obfuscatedProfileIdAndroid,
);
},
})();
Expand Down