Configure list of purchasable items in linphonerc

This commit is contained in:
Sylvain Berfini 2015-05-20 13:54:27 +02:00
parent e82385749c
commit ff64caaa8f
3 changed files with 18 additions and 4 deletions

View file

@ -34,3 +34,4 @@ user_certificates_path=/data/data/org.linphone/files
[in-app-purchase]
server_url=https://www.linphone.org/inapp.php
purchasable_items_ids=test_account_subscription

View file

@ -19,6 +19,8 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
import java.util.ArrayList;
import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneAddress.TransportType;
import org.linphone.core.LinphoneAuthInfo;
@ -1156,6 +1158,19 @@ public class LinphonePreferences {
return getConfig().getString("in-app-purchase", "server_url", null);
}
public ArrayList<String> getInAppPurchasables() {
ArrayList<String> purchasables = new ArrayList<String>();
String list = getConfig().getString("in-app-purchase", "purchasable_items_ids", null);
if (list != null) {
for(String purchasable : list.split(";")) {
if (purchasable.length() > 0) {
purchasables.add(purchasable);
}
}
}
return purchasables;
}
public String getDebugPopupAddress(){
return getConfig().getString("app", "debug_popup_magic", null);
}

View file

@ -55,7 +55,6 @@ import de.timroes.axmlrpc.XMLRPCServerException;
*/
public class InAppPurchaseHelper {
public static final int API_VERSION = 3;
public static final String TEST_ITEM = "test_account_subscription";
public static final int ACTIVITY_RESULT_CODE_PURCHASE_ITEM = 11089;
public static final String SKU_DETAILS_ITEM_LIST = "ITEM_ID_LIST";
@ -182,8 +181,7 @@ public class InAppPurchaseHelper {
private ArrayList<Purchasable> getAvailableItemsForPurchase() {
ArrayList<Purchasable> products = new ArrayList<Purchasable>();
ArrayList<String> skuList = new ArrayList<String> ();
skuList.add(TEST_ITEM);
ArrayList<String> skuList = LinphonePreferences.instance().getInAppPurchasables();
Bundle querySkus = new Bundle();
querySkus.putStringArrayList(SKU_DETAILS_ITEM_LIST, skuList);