public final class MpUtils
extends java.lang.Object
A helper class for querying enduser's purchase history or to figure out if this enduser is using an operator that is supported by Fortumo.
Modifier and Type | Field and Description |
---|---|
static int |
MESSAGE_STATUS_BILLED
Constant value for message billing status indicating that payment was successful.
|
static int |
MESSAGE_STATUS_FAILED
Constant value for message billing status indicating that payment failed.
|
static int |
MESSAGE_STATUS_NOT_SENT
Constant value for message billing status indicating that no payment has been made.
|
static int |
MESSAGE_STATUS_PENDING
Constant value for message billing status indicating that payment is still pending.
|
static java.lang.String |
PAYMENT_STATUS_CHANGED
Action for status change intents, to be used in the manifest.
|
static int |
PRODUCT_TYPE_CONSUMABLE
Constant value for consumables.
|
static int |
PRODUCT_TYPE_NON_CONSUMABLE
Constant value for non-consumables, which can only purchased once.
|
static int |
PRODUCT_TYPE_SUBSCRIPTION
Constant value for subscription services.
|
Modifier and Type | Method and Description |
---|---|
static void |
enablePaymentBroadcast(android.content.Context context,
java.lang.String permission)
Enables the PAYMENT_STATUS_CHANGED broadcast.
|
static void |
fetchPaymentData(android.content.Context context,
java.lang.String serviceId,
java.lang.String inAppSecret)
Allows the application to query the latest "small" XML payment data for a service and store it on device to be
available offline.
|
static java.util.List<java.lang.String> |
getFetchedPriceData(android.content.Context context,
java.lang.String serviceId,
java.lang.String inAppSecret)
Returns the latest service price data that is stored on device and available offline.
|
static int |
getLocalNonConsumablePaymentStatus(android.content.Context context,
java.lang.String serviceId,
java.lang.String productName)
Returns non-consumable item purchase status as it is stored on the device.
|
static int |
getNonConsumablePaymentStatus(android.content.Context context,
java.lang.String serviceId,
java.lang.String inAppSecret,
java.lang.String productName)
Returns the purchase status of a non-consumable item .
|
static PaymentResponse |
getPaymentResponse(android.content.Context context,
long messageId)
Allows the application to query message status later.
NB: This method might make a http request to Fortumo servers and can take considerable amount of time, avoid calling it in UI thread. |
static java.util.List<PaymentResponse> |
getPurchaseHistory(android.content.Context context,
java.lang.String serviceId,
java.lang.String inAppSecret,
int timeout)
Returns the list of purchased non-consumable items.
|
static boolean |
isPaymentBroadcastEnabled(android.content.Context context) |
static boolean |
isSupportedOperator(android.content.Context context,
java.lang.String serviceId,
java.lang.String appId)
Allows the application to query if user's carrier is supported by Fortumo.
|
static boolean |
isSupportedOperator(android.content.Context context,
java.lang.String serviceId,
java.lang.String appId,
long timeout)
Allows the application to query if user's carrier is supported by Fortumo.
|
public static final java.lang.String PAYMENT_STATUS_CHANGED
<receiver android:name=".PaymentStatusReceiver" ...>
<intent-filter>
<action android:name="mp.info.PAYMENT_STATUS_CHANGED" />
</intent-filter>
</receiver>
public static final int MESSAGE_STATUS_NOT_SENT
public static final int MESSAGE_STATUS_PENDING
public static final int MESSAGE_STATUS_BILLED
public static final int MESSAGE_STATUS_FAILED
public static final int PRODUCT_TYPE_CONSUMABLE
public static final int PRODUCT_TYPE_NON_CONSUMABLE
public static final int PRODUCT_TYPE_SUBSCRIPTION
public static java.util.List<PaymentResponse> getPurchaseHistory(android.content.Context context, java.lang.String serviceId, java.lang.String inAppSecret, int timeout)
NB: If some items were purchased, but the application was re-installed or local data was deleted, and no internet connection is available, this method will always return an empty list.
NB: This method makes a http request to Fortumo servers and can take considerable amount of time, avoid calling it in UI thread.
serviceId
- The service id the payment was made from (overrides the default service id)inAppSecret
- The in-app secret of the servicetimeout
- The timeout for the request to Fortumo servers in millisecondspublic static PaymentResponse getPaymentResponse(android.content.Context context, long messageId)
messageId
- ID of the message as received from a PaymentResponse.getMessageId()
.java.lang.IllegalArgumentException
- message with the ID was not foundpublic static int getLocalNonConsumablePaymentStatus(android.content.Context context, java.lang.String serviceId, java.lang.String productName)
NB: If an item was purchased, but the application was re-installed or local data was deleted,
this method would always return MESSAGE_STATUS_NOT_SENT
.
serviceId
- The service id the payment was made from (overrides the default service id)productName
- productName of the message as specified when calling PaymentRequest.PaymentRequestBuilder.setProductName(String)
NB: Only latin alphanumeric characters, dash ('-', hyphen-minus, U+002D) and underscore ('_', low line, U+005F) are supported and the value is truncated to 32 characters.MESSAGE_STATUS_NOT_SENT
, MESSAGE_STATUS_PENDING
, MESSAGE_STATUS_BILLED
, MESSAGE_STATUS_FAILED
public static int getNonConsumablePaymentStatus(android.content.Context context, java.lang.String serviceId, java.lang.String inAppSecret, java.lang.String productName)
NB: If an item was purchased, but the application was re-installed or local data was deleted, and no internet
connection is available, this method would always return MESSAGE_STATUS_NOT_SENT
.
NB: This method might make a http request to Fortumo servers and can take considerable amount of time, avoid calling it in UI thread.
serviceId
- The service id the payment was made from (overrides the default service id)inAppSecret
- The in-app secret of the serviceproductName
- productName of the message as specified when calling PaymentRequest.PaymentRequestBuilder.setProductName(String)
NB: Only latin alphanumeric characters, dash ('-', hyphen-minus, U+002D) and underscore ('_', low line, U+005F) are supported and the value is truncated to 32 characters.MESSAGE_STATUS_NOT_SENT
, MESSAGE_STATUS_PENDING
, MESSAGE_STATUS_BILLED
, MESSAGE_STATUS_FAILED
public static void enablePaymentBroadcast(android.content.Context context, java.lang.String permission)
permission
- String naming a permission that a receiver must hold in order to receive your broadcast. If null, no permission is required.public static boolean isPaymentBroadcastEnabled(android.content.Context context)
public static boolean isSupportedOperator(android.content.Context context, java.lang.String serviceId, java.lang.String appId)
serviceId
- A service id, will override the default oneappId
- The in-app secret of the servicepublic static boolean isSupportedOperator(android.content.Context context, java.lang.String serviceId, java.lang.String appId, long timeout)
isSupportedOperator(Context, String, String)
but allows overriding the timeout value
parameters. The timeout determines how long the thread is waiting for the request to complete.serviceId
- A service id, will override the default oneappId
- The in-app secret of the servicetimeout
- The timeout in milliseconds.public static void fetchPaymentData(android.content.Context context, java.lang.String serviceId, java.lang.String inAppSecret)
serviceId
- The ID of the serviceinAppSecret
- The in-app secret of the servicepublic static java.util.List<java.lang.String> getFetchedPriceData(android.content.Context context, java.lang.String serviceId, java.lang.String inAppSecret)
serviceId
- The ID of the serviceinAppSecret
- The in-app secret of the service