我正在尝试在我的应用程序中实现amazon的应用内购买(IAP(。我按照下面的文章来实现它。https://developer.amazon.com/docs/in-app-purchasing/iap-implement-iap.html
但是,当我调用PurchasingService.purchase(MySku.MY_MAGAZINE_SUBS.getSku(((时,我收到了以下错误;
com.amazon.a.a.n.a.a.a: AUTH_TOKEN_VERIFICATION_FAILURE: null: null
at com.amazon.a.a.n.a.b.a(AuthenticationTokenVerifier.java:94)
at com.amazon.a.a.n.a.a.a(AbstractCommandTask.java:204)
at com.amazon.a.a.n.a.a.a(AbstractCommandTask.java:131)
at com.amazon.a.a.n.b.b$1.run(SimpleTaskPipeline.java:179)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.os.HandlerThread.run(HandlerThread.java:65)
MySku.java
public enum MySku {
//The only subscription product used in this sample app
MY_MAGAZINE_SUBS("com.subscription.annually", "US");
private final String sku;
private final String availableMarkpetplace;
/**
* Returns the Sku string of the MySku object
*
* @return
*/
public String getSku() {
return this.sku;
}
/**
* Returns the Available Marketplace of the MySku object
*
* @return
*/
public String getAvailableMarketplace() {
return this.availableMarkpetplace;
}
private MySku(final String sku, final String availableMarkpetplace) {
this.sku = sku;
this.availableMarkpetplace = availableMarkpetplace;
}
/**
* Returns the MySku object from the specified Sku and marketplace value.
*
* @param sku
* @param marketplace
* @return
*/
public static MySku fromSku(final String sku, final String marketplace) {
if (MY_MAGAZINE_SUBS.getSku().equals(sku) && (null == marketplace || MY_MAGAZINE_SUBS.getAvailableMarketplace()
.equals(marketplace))) {
return MY_MAGAZINE_SUBS;
}
return null;
}
}
确保您的Android清单文件中有以下代码:
<receiver android:name="com.amazon.device.iap.ResponseReceiver" android:exported="true"
android:permission="com.amazon.inapp.purchasing.Permission.NOTIFY" >
<intent-filter>
<action
android:name="com.amazon.inapp.purchasing.NOTIFY" />
</intent-filter>
</receiver>