Pass the purchase token through the various layers of the billing system

pull/14/head
Sam Bosley 14 years ago
parent 8147986fb1
commit fea5fb275d

@ -195,7 +195,7 @@ public class BillingActivity extends Activity {
@Override
public void onPurchaseStateChange(PurchaseState purchaseState, String itemId,
int quantity, long purchaseTime, String developerPayload) {
int quantity, long purchaseTime, String developerPayload, String purchaseToken) {
if (Constants.DEBUG) {
Log.i(TAG, "onPurchaseStateChange() itemId: " + itemId + " " + purchaseState);
}

@ -551,7 +551,7 @@ public class BillingService extends Service implements ServiceConnection {
notifyList.add(vp.notificationId);
}
ResponseHandler.purchaseResponse(this, vp.purchaseState, vp.productId,
vp.orderId, vp.purchaseTime, vp.developerPayload);
vp.orderId, vp.purchaseTime, vp.developerPayload, vp.purchaseToken);
}
if (!notifyList.isEmpty()) {
String[] notifyIds = notifyList.toArray(new String[notifyList.size()]);

@ -66,7 +66,7 @@ public abstract class PurchaseObserver {
* milliseconds since the epoch (Jan 1, 1970)
*/
public abstract void onPurchaseStateChange(PurchaseState purchaseState,
String itemId, int quantity, long purchaseTime, String developerPayload);
String itemId, int quantity, long purchaseTime, String developerPayload, String purchaseToken);
/**
* This is called when we receive a response code from Market for a
@ -150,12 +150,12 @@ public abstract class PurchaseObserver {
* @param quantity the quantity of items in this purchase
*/
void postPurchaseStateChange(final PurchaseState purchaseState, final String itemId,
final int quantity, final long purchaseTime, final String developerPayload) {
final int quantity, final long purchaseTime, final String developerPayload, final String purchaseToken) {
mHandler.post(new Runnable() {
@Override
public void run() {
onPurchaseStateChange(
purchaseState, itemId, quantity, purchaseTime, developerPayload);
purchaseState, itemId, quantity, purchaseTime, developerPayload, purchaseToken);
}
});
}

@ -104,7 +104,7 @@ public class ResponseHandler {
*/
public static void purchaseResponse(
final Context context, final PurchaseState purchaseState, final String productId,
final String orderId, final long purchaseTime, final String developerPayload) {
final String orderId, final long purchaseTime, final String developerPayload, final String purchaseToken) {
// Update the database with the purchase state. We shouldn't do that
// from the main thread so we do the work in a background thread.
@ -118,15 +118,15 @@ public class ResponseHandler {
// int quantity = db.updatePurchase(
// orderId, productId, purchaseState, purchaseTime, developerPayload);
// db.close();
//
// // This needs to be synchronized because the UI thread can change the
// // value of sPurchaseObserver.
// synchronized(ResponseHandler.class) {
// if (sPurchaseObserver != null) {
// sPurchaseObserver.postPurchaseStateChange(
// purchaseState, productId, quantity, purchaseTime, developerPayload);
// }
// }
// This needs to be synchronized because the UI thread can change the
// value of sPurchaseObserver.
synchronized(ResponseHandler.class) {
if (sPurchaseObserver != null) {
sPurchaseObserver.postPurchaseStateChange(
purchaseState, productId, 1, purchaseTime, developerPayload, purchaseToken);
}
}
}
}).start();
}

@ -62,15 +62,17 @@ public class Security {
public String orderId;
public long purchaseTime;
public String developerPayload;
public String purchaseToken;
public VerifiedPurchase(PurchaseState purchaseState, String notificationId,
String productId, String orderId, long purchaseTime, String developerPayload) {
String productId, String orderId, long purchaseTime, String developerPayload, String purchaseToken) {
this.purchaseState = purchaseState;
this.notificationId = notificationId;
this.productId = productId;
this.orderId = orderId;
this.purchaseTime = purchaseTime;
this.developerPayload = developerPayload;
this.purchaseToken = purchaseToken;
}
}
@ -169,6 +171,7 @@ public class Security {
if (jElement.has("notificationId")) {
notifyId = jElement.getString("notificationId");
}
String purchaseToken = jElement.optString("purchaseToken");
String developerPayload = jElement.optString("developerPayload", null);
// If the purchase state is PURCHASED, then we require a
@ -177,7 +180,7 @@ public class Security {
continue;
}
purchases.add(new VerifiedPurchase(purchaseState, notifyId, productId,
orderId, purchaseTime, developerPayload));
orderId, purchaseTime, developerPayload, purchaseToken));
}
} catch (JSONException e) {
Log.e(TAG, "JSON exception: ", e);

Loading…
Cancel
Save