UCDEMİR YAZILIM : As your service, Developing Future
You can test this library, with real device: Android Example App
This Library designed as Google guide
- Library is supported for "INAPP"
- Subscription will be supported later!
- Library use Roomdb for your products
- Library use Shared dependency (App module ). Your app will be less sized and no multidex needed
- Library checks your products status on every time app starts.
- Every product bought by client need to be " Acknowledged" in SUCCES State. Library is making this for you!
android:fullBackupContent="false"
android:allowBackup="false"
tools:replace="android:allowBackup"
<uses-permission android:name="com.android.vending.BILLING"/>
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
ext.sharedGroup = {dependencyHandler->
delegate = dependencyHandler
implementation 'com.android.billingclient:billing:5.1.0'
implementation "androidx.room:room-runtime:2.4.3"
annotationProcessor 'androidx.room:room-compiler:2.4.3'
implementation 'com.kaopiz:kprogresshud:1.2.0'
implementation group: 'com.google.guava', name: 'guava', version: '11.0.2'
}
Why should you add those in project module?
Answer: Those dependencies can be use on every module if you add on project module... So less size, No multidex!
implementation 'com.github.Ucdemir:Ucdemir-Inn_App_Purchase_v2:0.0.6.3'
sharedGroup dependencies
public static List<String> listOfApplicationSKU;
listOfApplicationSKU = new ArrayList<>();
listOfApplicationSKU.add("bor");
listOfApplicationSKU.add("gas");
listOfApplicationSKU.add("noads");
listOfApplicationSKU.add("pro");
listOfApplicationSKU.add("sun");
Add below code inside your "Main Activity". Those codes check your products status on every application start and returns true results...
ConnectToPlay.getInstance().initForActivity(this).billingSKUS(DataManager.listOfApplicationSKU).startToWork(ConnectToPlay.CallType.CheckProductStatus).
setProductStatusGotListener(new ProductStatusGotListener() {
@Override
public void onProductStatusGot(HashMap<String, Purchase> hashMapPurchaseDetails) {
}
});
Add below codes inside Buyout -> Activity or Fragment... Those codes get products data’s such as price. Moreover you need "ProductDetails" data in order to buyout item
ConnectToPlay.getInstance().initForActivity(this).showHud("Loading").startToWork(ConnectToPlay.CallType.GetPriceProducts)
.setInAppPurchaseListener(new InAppPurchaseListener() {
@Override
public void returnAllProductsDetailsFromPlayStore(HashMap<String,ProductDetails> hashMapSkuDetails) {
ProFragment.this.hashMapSkuDetails = hashMapSkuDetails;
setPrice();
ConnectToPlay.getInstance().hideHud();
}
});
private void setPrice(){
for (Map.Entry<String, ProductDetails> e : hashMapSkuDetails.entrySet()){
Log.d("YHY", "price : " + e.getValue().getOneTimePurchaseOfferDetails().getFormattedPrice());
switch (e.getKey()){
case "bor":
binding.btnOfBor.setText( e.getValue().getOneTimePurchaseOfferDetails().getFormattedPrice());
break;
case "gas":
binding.btnOfGas.setText( e.getValue().getOneTimePurchaseOfferDetails().getFormattedPrice());
break;
case "noads":
binding.btnOfNoads.setText( e.getValue().getOneTimePurchaseOfferDetails().getFormattedPrice());
break;
case "pro":
binding.btnOfPro.setText( e.getValue().getOneTimePurchaseOfferDetails().getFormattedPrice());
break;
case "sun":
binding.btnOfSun.setText( e.getValue().getOneTimePurchaseOfferDetails().getFormattedPrice());
break;
}
}
}
private HashMap<String, ProductDetails> hashMapSkuDetails = new HashMap<>();
ConnectToPlay.getInstance().startBuyOut(this,hashMapSkuDetails.get("bor"));
"bor" is product name
ConnectToPlay.getInstance().whatIsProductStatus("bor")
Below listener for consume :
setAfterConsumeListener(new AfterConsumeListener() {
@Override
public void afterConsume(BillingResult billingResult, String s) {
}
});
Below after acknowledge :
setAfterAcknowledgePurchaseResponseListener(new AfterAcknowledgePurchaseResponseListener() {
@Override
public void onAcknowledgePurchaseResponse(BillingResult billingResult) {
}
});
Below after purchase
setSuccessfullyPurchasedListener(new SuccessfullyPurchasedListener() {
@Override
public void successfullyPurchased(String sku) {
}
});
At fresh instalation of user set below code true if you want your products to response true... Think that: Your app have ads and you dont want to shown at fresh start
shouldFirstProductsReturnTrue(true);
if you want your app to be restart after purchase you can make below function to be true..
shouldRestartApp(true)
Purchase p = hashMapPurchaseDetails.get("bor");
ConnectToPlay.getInstance().consumeProduct(p.getPurchaseToken(),p.getDeveloperPayload());