Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo Plugins Support › Also Soomla on Android

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #24515

    Patrik Dusek

    Hi all,

    I’m also going insane with getting inapppurchase running on Android.

    I made the steps from the docu. I found the rsa-key on the playstore.

        Store {
            id: storeSoomla
    
            version: 1
            secret: "myOwndefinedSecret"             // replace with your Soomla secret
            androidPublicKey: "MIIBIjAN.... much more signs"
    
            goods: [
                LifetimeGood {
                  id: fullVersionGood
                  itemId: "upgrade.eichelmann2022"
                  name: "Upgrade Vollversion"
                  description: "Alle 935 Winzer und ihre Weine 2022"
                  purchaseType: StorePurchase {
                             id: myAppSubPurchase
                             productId: fullVersionGood.itemId
                  }
                }
            ]
    
            onItemPurchased: {
                NativeDialog.confirm("Info", "Successfully bought: " + itemId, null, false)
            }
    
            onInsufficientFundsError: {
                NativeDialog.confirm("Fehler",
                                     "Der Kauf konnte nicht abgeschlossen werden. Bitte überprüfen Sie Ihre App-Store Einstellungen.",
                                     function(ok) {
                                         if (ok) {
                                             // Trigger credits purchase right from dialog
                                             storeSoomla.buyItem(fullVersionGood.itemId)
                                         }
                                     },
                                     true)
            }
    
            onRestoreAllTransactionsFinished: {
            }
    
            onItemNotFoundError: {
                NativeDialog.confirm("Error", "Not found", function(ok) {
                    if(ok) {
                     // confirmBtn.text = "Confirmed!"
                    }
                  })
            }
            onUnexpectedError: {
                NativeDialog.confirm("Error", "UnexpectedError", function(ok) {
                    if(ok) {
                     // confirmBtn.text = "Confirmed!"
                    }
                  })
            }
        }
    

     

    Within the pro I added the plugin und in gradle also.

    But the only thing when I try to test it in the closed test of the playstore I get my “UnexpectedError” dialog.

    Any hints? Is the rsa-key from the monitarization settings page realy the right one?

    thx,

    Patrik

    #24517

    Alex
    Felgo Team
    #24519

    Patrik Dusek

    Hi Alex,

    I tested it in several different tracks. Internal, test. No difference 🙁

    In my pro I added:

    FELGO_PLUGINS += soomla
    

    My gradle:

    buildscript {
        repositories {
            google()
            mavenCentral()
        }
    
        dependencies {
            classpath 'com.android.tools.build:gradle:3.6.0'
        }
    }
    
    allprojects {
        repositories {
            google()
            mavenCentral()
            maven { url 'https://install.felgo.com/maven/' }
        }
    }
    
    apply plugin: 'com.android.application'
    
    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
    
        implementation "androidx.appcompat:appcompat:1.2.0"
        implementation 'net.vplay.plugins:plugin-soomla:3.+'
    
    }
    
    android {
        /*******************************************************
         * The following variables:
         * - androidBuildToolsVersion,
         * - androidCompileSdkVersion
         * - qt5AndroidDir - holds the path to qt android files
         *                   needed to build any Qt application
         *                   on Android.
         *
         * are defined in gradle.properties file. This file is
         * updated by QtCreator and androiddeployqt tools.
         * Changing them manually might break the compilation!
         *******************************************************/
    
        compileSdkVersion    androidCompileSdkVersion.toInteger()
        buildToolsVersion    androidBuildToolsVersion
    
        compileOptions {
          sourceCompatibility 1.8
          targetCompatibility 1.8
        }
    
        defaultConfig {
          multiDexEnabled true
          targetSdkVersion   androidCompileSdkVersion.toInteger()
          applicationId    = productIdentifier
          versionCode      = productVersionCode.toInteger()
          versionName      = productVersionName
          minSdkVersion    = project.hasProperty("qtMinSdkVersion") ? qtMinSdkVersion.toInteger() : 29
    
          int qtVersionNr = project.hasProperty("qtVersionInt") ? qtVersionInt.toInteger() : 5132
          if (qtVersionNr < 5140) {
            resValue('array', 'load_local_libs', "")
          } else if (qtVersionNr >= 5140) {
            resValue('array', 'bundled_in_lib', "")
            resValue('array', 'bundled_in_assets', "")
          }
        }
    
        sourceSets {
            main {
                manifest.srcFile 'AndroidManifest.xml'
                java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
                aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
                res.srcDirs = [qt5AndroidDir + '/res', 'res']
                resources.srcDirs = ['src']
                renderscript.srcDirs = ['src']
                assets.srcDirs = ['assets']
                jniLibs.srcDirs = ['libs']
           }
        }
    
        lintOptions {
            abortOnError false
        }
        aaptOptions { // Do not compress Qt binary resources file
            noCompress 'rcc'
        }
        tasks.withType(JavaCompile) {
            options.incremental = true
        }
    }
    
    

    And my manifest:

    ......
                <meta-data android:name="billing.service" android:value="google.GooglePlayIabService"/>
            </activity>
        </application>
        <supports-screens android:normalScreens="true" android:smallScreens="true" android:largeScreens="true" android:anyDensity="true"/>
    
        <!-- %%INSERT_FEATURES -->
    
     <uses-permission android:name="com.android.vending.BILLING"/>
        <uses-permission android:name="android.permission.INTERNET"/>
        <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    

    Is there anything special about the soomla secret?

    Do you have any tricks/hints for debuging. Because of loading the app from the store I don’t get realy any hints whats going wrong. Only the unexpected error with no params 🙁

    Thx,

    Patrik

    #24520

    Alex
    Felgo Team

    Hi Patrik,

    your billing service is added as child of the activity, and not the application tag, as mentioned in the docs, that might be the culprit here?

    Best,
    Alex

    #24521

    Patrik Dusek

    Hi Alex,

    you saved my day 🙂

    Many thanks,

    Patrik

    #24523

    Patrik Dusek

    Hi Alex,

    now it nearly works. But what happens is that at the start of the app the

    onRestoreAllTransactionsFinished

    methode is called. And the success param is true 🙁

    I searched my whole project for something which could trigger the restore but I defintly don’t trigger the restore.

    From the documentation I can’t find a hint that restore is called automatically.

    Here again my code and the place where I call restore.

     

        // Plugin Item
        Store {
            id: storeSoomla
    
            version: 1
            secret: "xxx"
            androidPublicKey: "MIIB...."
         //   supported : Theme.isAndroid
    
            // Goods contain either single-use, single-use-pack or lifetime goods
            goods: [
                LifetimeGood {
                  id: fullVersionGood
                  itemId: "upgrade"
                  name: "Upgrade Vollversion"
                  description: "Alle"
                  purchaseType: StorePurchase {
                             id: myAppSubPurchase
                             productId: fullVersionGood.itemId
                  }
                }
            ]
    
            onItemPurchased: {
                console.debug("Purchases item:", itemId)
                service.addPurchaseToPersistentStorage(fullVersionGood.itemId)
                NativeDialog.confirm("Info", "InApp Kauf erfolgreich: " + fullVersionGood.itemId, null, false)
            }
    
            onInsufficientFundsError: {
                console.debug("Insufficient funds for purchasing item")
                NativeDialog.confirm("Fehler",
                                     "Der Kauf konnte nicht abgeschlossen werden. Bitte überprüfen Sie Ihre App-Store Einstellungen.",
                                     function(ok) {
                                         if (ok) {
                                             // Trigger credits purchase right from dialog
                                             storeSoomla.buyItem(fullVersionGood.itemId)
                                         }
                                     },
                                     true)
            }
    
            onRestoreAllTransactionsFinished: {
                if(success){
                    service.addPurchaseToPersistentStorage(fullVersionGood.itemId)
                    NativeDialog.confirm("Info", "InApp wiederhergestellt ", null, false)
                }
                console.debug("Purchases restored with success:", success)
            }
    
            onItemNotFoundError: {
                NativeDialog.confirm("Error", "Not found", function(ok) {
                    if(ok) {
                     // confirmBtn.text = "Confirmed!"
                    }
                  })
            }
            onUnexpectedError: {
                NativeDialog.confirm("Error", "Ein Fehler ist aufgetreten. Bitte versuchen Sie es später nochmal oder kontaktieren Sie uns.", function(ok) {
                    if(ok) {
                     // confirmBtn.text = "Confirmed!"
                    }
                  })
            }
        }
    
        MainApplication {
            id: mainAppForm
            visible: !splashScreen.visible
    
            onMakeInAppPurchase: {
                NativeDialog.confirm("Error", "called by me", function(ok) {
                    if(ok) {
                     // confirmBtn.text = "Confirmed!"
                    }
                  })
                console.log("make inapp",fullVersionGood.itemId)
                storeSoomla.buyItem(fullVersionGood.itemId)
            }
            onRestoreInAppPurchase: {
                console.log("make restore")
                NativeDialog.confirm("Error", "called by me", function(ok) {
                    if(ok) {
                     // confirmBtn.text = "Confirmed!"
                    }
                  })
                storeSoomla.restoreAllTransactions()
            }
        }
    

    I added a dialog to test if I call it in some way. But the dialog doesn’t appear.

    Thx,

    Patrik

    #24524

    Alex
    Felgo Team

    Hi Patrik,

    it is possible that this is called on app start by default. I did not dig into the code yet. Does it cause any problems for you? If you would like to inform the user about the result of a manual restore, you could add an own flag like “restorePending” when the user clicks a restore button, and only show a dialog if that flag is set in the restore handler. I will add a note to check this for the dev team anyway.

    Best,
    Alex

    #24526

    Patrik Dusek

    Hi Alex,

    your idea would work if “succeeded” would not always be true. If I test the purchase the test work fine for a valid card and not valid card. But what I

    can always do is to call

    restoreAllTransactions

    and get “succeeded” as true even if I haven’t made a successfull inapp purchase on the device.

    I ported an bigger older qt (none felgo) app to this project. A lot of loaders and dynamic connections. So I would not exclude that the problem is somewhere on my end. But its a little weired. The code for the plugin is not available, correct?

    Best,

    Patrik

    #24527

    Alex
    Felgo Team

    Hi Patrik,

    the success flag does only indicate that there was no error, not that there were any specific purchases restored. We will have a closer look when and why the restore method might be called by the plugin. Is this very time critical for you?

    Best,
    Alex

    #24528

    Patrik Dusek

    Hi Alex,

    indeed its time critical. I’m already 1.5 week over 🙁

    Thx,

    Patrik

    #24541

    Alex
    Felgo Team

    Hi Patrik,

    I don’t quite understand what the exact issue is. From what I see, you can ignore the restoreAllTransactionsFinished signal as well. If an actual restore is performed, you should also receive the itemPurchased signal for this specific item and can inform the user, could you check if that works for you. Soomla will call the restore by default on every application start.

    Best,
    Alex

    #24542

    Patrik Dusek

    Hi Alex,

    thx. That’s the way I will go.

    Best,

    Patrik

Viewing 12 posts - 1 through 12 (of 12 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded