Back to project page AmazonInAppPurchasing.
The source code is released under:
Copyright 2012 Bob Easterday, Adobe Systems Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal ...
If you think the Android project AmazonInAppPurchasing listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.rahulrav.cordova.amazon.plugin; /*from ww w. ja v a 2 s .co m*/ import org.json.JSONException; import org.json.JSONObject; import com.amazon.inapp.purchasing.PurchaseResponse; import com.amazon.inapp.purchasing.PurchaseResponse.PurchaseRequestStatus; import com.amazon.inapp.purchasing.Receipt; public class AmazonPurchaseResponse implements JSONValue { private final PurchaseResponse purchaseResponse; protected PurchaseResponse getPurchaseResponse() { return purchaseResponse; } public AmazonPurchaseResponse(final PurchaseResponse purchaseResponse) { if (purchaseResponse == null) { throw new AmazonInAppException("'purchaseResponse' cannot be null"); } this.purchaseResponse = purchaseResponse; } @Override public JSONObject toJSON() throws JSONException { if (purchaseResponse == null) { return null; } final JSONObject jobj = new JSONObject(); final PurchaseRequestStatus status = purchaseResponse.getPurchaseRequestStatus(); // requestId jobj.put("requestId", purchaseResponse.getRequestId()); // purchase request status jobj.put("purchaseRequestStatus", status); // logged in userId jobj.put("userId", purchaseResponse.getUserId()); // we have a receipt only if the request was successful if (status == PurchaseRequestStatus.SUCCESSFUL) { final Receipt receipt = purchaseResponse.getReceipt(); if (receipt != null) { final AmazonReceipt amazonReceipt = new AmazonReceipt(receipt); // receipt jobj.put("receipt", amazonReceipt.toJSON()); } } return jobj; } }