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 w w w . j a v a2 s . c om*/ import java.util.Date; import org.json.JSONException; import org.json.JSONObject; import com.amazon.inapp.purchasing.Receipt; import com.amazon.inapp.purchasing.SubscriptionPeriod; public class AmazonReceipt implements JSONValue { private final Receipt receipt; public AmazonReceipt(final Receipt receipt) { if (receipt == null) { throw new AmazonInAppException("'receipt' cannot be null"); } this.receipt = receipt; } protected Receipt getReceipt() { return receipt; } @Override public JSONObject toJSON() throws JSONException { if (receipt == null) { return null; } final JSONObject jobj = new JSONObject(); // sku jobj.put("sku", receipt.getSku()); // itemType jobj.put("itemType", receipt.getItemType()); // purchase token jobj.put("purchaseToken", receipt.getPurchaseToken()); // subscription period final SubscriptionPeriod subscriptionPeriod = receipt.getSubscriptionPeriod(); if (subscriptionPeriod != null) { final Date startDate = subscriptionPeriod.getStartDate(); if (startDate != null) { jobj.put("startDate", startDate.getTime()); } final Date endDate = subscriptionPeriod.getEndDate(); if (endDate != null) { jobj.put("endDate", endDate.getTime()); } } return jobj; } }