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

Feature/add additional checker #223

Merged
merged 2 commits into from
Dec 24, 2016
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
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,21 @@ Simply call static method `BillingProcessor.isIabServiceAvailable()`:
// continue
}
```
Please take a note that calling to `BillingProcessor.isIabServiceAvailable()` (only checks Play Market app installed or not) is not enough because there might be a case when it returns true but still payment won't success. Therefore, it's better to
call to method `isOnTimePurchaseSupported()` after initializing `BillingProcessor`:
```java
boolean isOneTimePurchaseSupported = billingProcessor.isOnTimePurchaseSupported();
if(isOneTimePurchaseSupported) {
// launch payment flow
}
```
or call to method `isSubscriptionUpdateSupported()` for checking update subcription usecase:
```java
boolean isSubsUpdateSupported = billingProcessor.isSubscriptionUpdateSupported();
if(isSubsUpdateSupported) {
// launch payment flow
}
```

## Consume Purchased Products

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public interface IBillingHandler {
private BillingCache cachedSubscriptions;
private IBillingHandler eventHandler;
private String developerMerchantId;
private boolean isOneTimePurchaseSupported;
private boolean isSubsUpdateSupported;

private class HistoryInitializationTask extends AsyncTask<Void, Void, Boolean>
Expand Down Expand Up @@ -233,6 +234,19 @@ public boolean subscribe(Activity activity, String productId, String developerPa
return purchase(activity, productId, Constants.PRODUCT_TYPE_SUBSCRIPTION, developerPayload);
}

public boolean isOnTimePurchaseSupported(){
if (isOneTimePurchaseSupported)
return true;

try {
int response = billingService.isBillingSupported(Constants.GOOGLE_API_VERSION, contextPackageName, Constants.PRODUCT_TYPE_MANAGED);
isOneTimePurchaseSupported = response == Constants.BILLING_RESPONSE_RESULT_OK;
} catch (RemoteException e) {
e.printStackTrace();
}
return isOneTimePurchaseSupported;
}

public boolean isSubscriptionUpdateSupported() {
// Avoid calling the service again if this value is true
if (isSubsUpdateSupported)
Expand Down