onepf / OpenIAB

Open In-App Billing for Google Play, SlideMe, Amazon Store, Nokia Store, Samsung Apps, Yandex.Store, Appland, Aptoide, AppMall and Fortumo.
http://onepf.org/openiab/
Apache License 2.0
474 stars 171 forks source link

no example on how to use amazon in-app purchase #125

Closed evolapp closed 9 years ago

evolapp commented 10 years ago

I have no problem with google play, but i want to work with amazon too. After few hours of looking and trying, I really have no ideas on how to do so...

I think i should add something like this: storeKeys.put(OpenIabHelper.NAME_AMAZON, ??); but i tried with different value for ??, but none of them works. I will be highly appreciated if anyone can provide a example on amazon appstore. thanks

oorlov commented 10 years ago

Amazon doesn't support RSA verification, so key is not needed.

Will update TrivialDrive sample accordingly

oorlov commented 10 years ago

SamsungApps also doesn't support keys. Need to put it only for GooglePlay and OpenStores like Yandex.Store or Appland

evolapp commented 10 years ago

Thanks for reply. So, I only need to add below code? What should I type in "???" static { OpenIabHelper.mapSku(SKU_PREMIUM, OpenIabHelper.NAME_AMAZON, "???"); }
Also, my testing device has google play and amazon. Every time when i click purchase, only show google play billing. How can I prompt amazon instead? thank you very much!

oorlov commented 10 years ago

Amazon and Samsung don't have keys, but you still need to specify SKU mapping

For Amazon you need to find your ids at https://developer.amazon.com/myapps.html Amazon Developers -> Your App -> In-App Items

OpenIabHelper.mapSku(SKU_PREMIUM, OpenIabHelper.NAME_AMAZON, "org.onepf.trivialdrive.amazon.premium");

For Samsung all of them looks like GroupID / ItemID

100000100696/000001003744

It's better to check in TrivialDrive sample code: https://github.com/onepf/OpenIAB/blob/master/samples/trivialdrive/src/org/onepf/trivialdrive/MainActivity.java#L110-L123

evolapp commented 10 years ago

i checked the sample code for many times, but it did not tell where do "org.onepf.trivialdrive.amazon.premium" come from? Is "org.onepf.trivialdrive.amazon.premium" simple the name of SKU? Or just a random name user defined? I have added a SKU called premium. But should i use "org.onepf.trivialdrive.amazon.premium" or "premium"? Thanks for help!

P.S. I think it may be better to add additional comment to the sample code. For example, from the sample, I would guess I need to add something like below, storeKeys.put(OpenIabHelper.NAME_AMAZON, ??); But after hours of testing, and finally, I am so lucky to get help from you and so know that I should never trying to find the key from amazon webpage because the keycord never existed..

oorlov commented 10 years ago

Oh, this SKU comes from Amazon Developer Console where you need to create In-App Item. See "SKU" field here: https://www.dropbox.com/s/9upaa1lxd20w2q6/Screenshot%20Amazon%20In-Apps.png

To publish on Amazon Appstore you need to create Amazon Accont, then add new application in Developer Console. For this application you can add in-app items. For each item you have to specify SKU. This SKU should be used for OpenIABHelper.mapSku()

evolapp commented 10 years ago

Thank you very much for help. I have another question. It seems the default billing service the App called is Google play. If I uploaded to amazon, what should I change the code so when user press a button to purchase, it will open amazon in app payment dialog instead of google play? thank a lot.

oorlov commented 10 years ago

In fact nothing. OpenIAB takes care about choosing appropriate Store.

One important thing: OpenIAB lookup for special Amazon classes in your package to understand that app is installed from Amazon. Amazon adds these classes (com.amazon.Kiwi*) and re-sign your .apk after submission, but moderators performs review with original .apk. So you'd better to specify testing instruction to try in-apps on Amazon device with repacked version in

Due to same reason you need to override AmazonAppstore class to test app with Amazon SDK Tester. To do this you need

Options opts = new Options();
opts.availableStores = new ArrayList();
opts.availableStores.add(new AmazonAppstore() {
    public boolean isPackageInstaller(String packageName) {
        return true;
    }
}

new OpenIabHelper(context, opts)
evolapp commented 10 years ago

Thank a lot for your instruction, very useful. I tried. Work very well! Nice!

dps999 commented 10 years ago

Hello! What about amazon in-app test in Unity? what i have to change? Thank you.

oorlov commented 10 years ago

Hi @dps999

Now it should be simple. Just need to infall .apk using adb shell pm install -i, see last comment at #136

sanmn19 commented 9 years ago

Problem: I get the error "An error occured while processing the transaction"

Scenario: I have built the APK and created a live test on amazon developer console. I added my other accounts as testers and submitted the test. I downloaded the app store on my phones(not kindle, regular android) and installed it through the app store. In both my mobile phones, I get the same error.

Question: My in-app billing items in my amazon app store are in the status 'Ready to submit'. Should they be submitted for this to work?

Any suggestions?

RomanZhilich commented 9 years ago

I don't think Amazon in app purchases are available before you publish your app. You should probably try them with Amazon App Tester application, which is available in Amazon app store. Please refer for [this](https://developer.amazon.com/public/apis/earn/in-app-purchasing/docs-v2/testing-iap-2.0#How the App Tester Works) instruction for details.