-
Notifications
You must be signed in to change notification settings - Fork 12
Amazon
This BillingProvider
implementation adds support for Amazon Appstore.
###Links
###Dependency
Amazon billing provider depends on proprietary in-app-purchasing.jar
which can be found within Amazon Mobile App SDK.
You can download it yourself and manually add it to your project, or use our GitHub hosted repo instead:
allprojects {
repositories {
...
// third-party dependencies
maven { url 'https://raw.githubusercontent.com/onepf/OPF-mvn-repo/master/' }
}
}
Dependencies:
dependencies {
compile 'org.onepf:opfiab-amazon:x.x.x@aar'
compile 'com.amazon:in-app-purchasing:+'
}
Add following entries to your AndroidManifest.xml
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application>
<receiver
android:name="com.amazon.device.iap.ResponseReceiver"
android:exported="true">
<intent-filter>
<action
android:name="com.amazon.inapp.purchasing.NOTIFY"
android:permission="com.amazon.inapp.purchasing.Permission.NOTIFY"/>
</intent-filter>
</receiver>
</application>
final AmazonBillingProvider amazon = new AmazonBillingProvider.Builder(context)
// optional
.setPurchaseVerifier(new MyAmazonPurchaseVerifier())
// optional
.setSkuResolver(new MyAmazonSkuResolver())
.build();
According to official documentation Amazon recommends using server-side purchase verification.
Unfortunately that means you'll have to make your own implementation of PurchaseVerifier
interface.
-optimizationpasses 1
-dontwarn com.amazon.**
-keep class com.amazon.** {*;}
-keepattributes *Annotation*
Check here for more details.
There are two ways to test Amazon in-app billing with you app.
- Using Amazon App Tester
- App Tester User Guide
- Download and install Amazon App Tester
- Add [JSON file](https://developer.amazon.com/public/apis/earn/in-app-purchasing/docs-v2/installing-and-configuring-app-tester#Obtaining a JSON Data File) to your testing device.
- Live App Testing
It's recommended to that you try both before releasing your app.
When something goes wrong I almost always get 'UNKNOWN_ERROR' response instead of more specific one.
Unfortunately Amazon just doesn't report reason for error. Right now there's nothing we can do about it.
I'm logged in Amazon but I get
Unauthorized
response code from library.
App can only communicate with Amazon Store if it was downloaded from it. To test your app without uploading it to store you'll need Amazon App Tester.
I've just purchased something, but it's not returned in inventory.
Amazon takes some time (few minutes) to update inventory and add newly purchased items to it. Thus it's best to handle purchase is onPurchase()
callback.