Added methods & class to help with in app purchase
This commit is contained in:
parent
3633e9af9d
commit
c73ebbb0c8
4 changed files with 80 additions and 2 deletions
|
@ -35,6 +35,7 @@ import org.linphone.core.LinphoneProxyConfig;
|
||||||
import org.linphone.core.LpConfig;
|
import org.linphone.core.LpConfig;
|
||||||
import org.linphone.core.TunnelConfig;
|
import org.linphone.core.TunnelConfig;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
|
import org.linphone.purchase.Purchasable;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
|
@ -1158,6 +1159,26 @@ public class LinphonePreferences {
|
||||||
return getConfig().getString("in-app-purchase", "server_url", null);
|
return getConfig().getString("in-app-purchase", "server_url", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Purchasable getInAppPurchasedItem() {
|
||||||
|
String id = getConfig().getString("in-app-purchase", "purchase_item_id", null);
|
||||||
|
String payload = getConfig().getString("in-app-purchase", "purchase_item_payload", null);
|
||||||
|
String signature = getConfig().getString("in-app-purchase", "purchase_item_signature", null);
|
||||||
|
String username = getConfig().getString("in-app-purchase", "purchase_item_username", null);
|
||||||
|
|
||||||
|
Purchasable item = new Purchasable(id).setPayloadAndSignature(payload, signature).setUserData(username);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInAppPurchasedItem(Purchasable item) {
|
||||||
|
if (item == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
getConfig().setString("in-app-purchase", "purchase_item_id", item.getId());
|
||||||
|
getConfig().setString("in-app-purchase", "purchase_item_payload", item.getPayload());
|
||||||
|
getConfig().setString("in-app-purchase", "purchase_item_signature", item.getPayloadSignature());
|
||||||
|
getConfig().setString("in-app-purchase", "purchase_item_username", item.getUserData());
|
||||||
|
}
|
||||||
|
|
||||||
public ArrayList<String> getInAppPurchasables() {
|
public ArrayList<String> getInAppPurchasables() {
|
||||||
ArrayList<String> purchasables = new ArrayList<String>();
|
ArrayList<String> purchasables = new ArrayList<String>();
|
||||||
String list = getConfig().getString("in-app-purchase", "purchasable_items_ids", null);
|
String list = getConfig().getString("in-app-purchase", "purchasable_items_ids", null);
|
||||||
|
|
47
src/org/linphone/purchase/InAppPurchaseListenerBase.java
Normal file
47
src/org/linphone/purchase/InAppPurchaseListenerBase.java
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
package org.linphone.purchase;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class InAppPurchaseListenerBase implements InAppPurchaseListener {
|
||||||
|
@Override
|
||||||
|
public void onServiceAvailableForQueries() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAvailableItemsForPurchaseQueryFinished(ArrayList<Purchasable> items) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPurchasedItemsQueryFinished(ArrayList<Purchasable> items) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPurchasedItemConfirmationQueryFinished(Purchasable item) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRecoverAccountSuccessful(boolean success) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivateAccountSuccessful(boolean success) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(String error) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ import java.sql.Date;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Purchasable.java
|
Purchasable.java
|
||||||
Copyright (C) 2015 Belledonne Communications, Grenoble, France
|
Copyright (C) 2015 Belledonne Communications, Grenoble, France
|
||||||
|
@ -30,6 +31,7 @@ public class Purchasable {
|
||||||
private String id, title, description, price;
|
private String id, title, description, price;
|
||||||
private long expire;
|
private long expire;
|
||||||
private String purchasePayload, purchasePayloadSignature;
|
private String purchasePayload, purchasePayloadSignature;
|
||||||
|
private String userData;
|
||||||
|
|
||||||
public Purchasable(String id) {
|
public Purchasable(String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
@ -94,4 +96,13 @@ public class Purchasable {
|
||||||
public String getPayloadSignature() {
|
public String getPayloadSignature() {
|
||||||
return this.purchasePayloadSignature;
|
return this.purchasePayloadSignature;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Purchasable setUserData(String data) {
|
||||||
|
this.userData = data;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserData() {
|
||||||
|
return this.userData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,5 +66,4 @@ public class XmlRpcListenerBase implements XmlRpcListener {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue