com.fortumo.android
Class Fortumo

java.lang.Object
  extended by com.fortumo.android.Fortumo

public class Fortumo
extends java.lang.Object

A helper class for querying statuses of messages after the payment process is complete. Especially useful if message status was returned as MESSAGE_STATUS_PENDING. Also provides facilities to enable or disable logging (by default logging is disabled).

Author:
Fortumo

Field Summary
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.
 
Method Summary
static void disablePaymentBroadcast(android.content.Context context)
          Disable PAYMENT_STATUS_CHANGED broadcast.
static void enablePaymentBroadcast(android.content.Context context, java.lang.String permission)
          Enables the PAYMENT_STATUS_CHANGED broadcast.
static int getLocalNonConsumablePaymentStatus(android.content.Context context, java.lang.String productName)
          Queries local SQLite database for payment status.
static int getLocalNonConsumablePaymentStatus(android.content.Context context, java.lang.String serviceId, java.lang.String appSecret, java.lang.String productName)
          Similar to getLocalNonConsumablePaymentStatus(Context, String) but allows you to override the Fortumo service properties (service id, in-app secret).
static int getNonConsumablePaymentStatus(android.content.Context context, java.lang.String productName)
          Allows the application to query a non-consumable payment status by productId.
static int getNonConsumablePaymentStatus(android.content.Context context, java.lang.String serviceId, java.lang.String appSecret, java.lang.String productName)
          Similar to getNonConsumablePaymentStatus(Context, String) but allows you to override the Fortumo service properties (service id, in-app secret).
static PaymentResponse getPaymentResponse(android.content.Context context, long messageId)
          Allows the application to query message status later.
static boolean isPaymentBroadcastEnabled(android.content.Context context)
           
static boolean isSupportedOperator(android.content.Context context)
          Allows the application to query if user's carrier is supported by Fortumo and your service.
static boolean isSupportedOperator(android.content.Context context, java.lang.String serviceId, java.lang.String appSecret)
          Allows the application to query if user's carrier is supported by Fortumo.
static void setFlurryEnabled(boolean flurryEnabled)
          Deprecated. 
static void setLoggingEnabled(boolean loggingEnabled)
          Enables logging of errors.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MESSAGE_STATUS_NOT_SENT

public static final int MESSAGE_STATUS_NOT_SENT
Constant value for message billing status indicating that no payment has been made.

See Also:
Constant Field Values

MESSAGE_STATUS_PENDING

public static final int MESSAGE_STATUS_PENDING
Constant value for message billing status indicating that payment is still pending.

See Also:
Constant Field Values

MESSAGE_STATUS_BILLED

public static final int MESSAGE_STATUS_BILLED
Constant value for message billing status indicating that payment was successful.

See Also:
Constant Field Values

MESSAGE_STATUS_FAILED

public static final int MESSAGE_STATUS_FAILED
Constant value for message billing status indicating that payment failed.

See Also:
Constant Field Values
Method Detail

getPaymentResponse

public static PaymentResponse getPaymentResponse(android.content.Context context,
                                                 long messageId)
                                          throws java.lang.IllegalArgumentException
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.

Parameters:
context -
messageId - ID of the message as received from a PaymentResponse.getMessageId() method call.
Returns:
A refreshed PaymentResponse object with the latest billing status.
Throws:
java.lang.IllegalArgumentException - message with the ID was not found

getNonConsumablePaymentStatus

public static int getNonConsumablePaymentStatus(android.content.Context context,
                                                java.lang.String productName)
Allows the application to query a non-consumable payment status by productId.
NB: This method might make a http request to Fortumo servers and can take considerable amount of time, avoid calling it in UI thread.

Parameters:
context -
productName - productName of the message as specified when calling 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.
Returns:
one of MESSAGE_STATUS_NOT_SENT, MESSAGE_STATUS_PENDING, MESSAGE_STATUS_BILLED, MESSAGE_STATUS_FAILED

getNonConsumablePaymentStatus

public static int getNonConsumablePaymentStatus(android.content.Context context,
                                                java.lang.String serviceId,
                                                java.lang.String appSecret,
                                                java.lang.String productName)
Similar to getNonConsumablePaymentStatus(Context, String) but allows you to override the Fortumo service properties (service id, in-app secret).
NB: This method might make a http request to Fortumo servers and can take considerable amount of time, avoid calling it in UI thread.

Parameters:
context -
serviceId - The service id the payment was made from (overrides the default service id)
appSecret - The in-app secret of the service
productName - productName of the message as specified when calling 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.
Returns:
one of MESSAGE_STATUS_NOT_SENT, MESSAGE_STATUS_PENDING, MESSAGE_STATUS_BILLED, MESSAGE_STATUS_FAILED

getLocalNonConsumablePaymentStatus

public static int getLocalNonConsumablePaymentStatus(android.content.Context context,
                                                     java.lang.String productName)
Queries local SQLite database for payment status.

Parameters:
context -
productName - productName of the message as specified when calling 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.
Returns:
one of MESSAGE_STATUS_NOT_SENT, MESSAGE_STATUS_PENDING, MESSAGE_STATUS_BILLED, MESSAGE_STATUS_FAILED

getLocalNonConsumablePaymentStatus

public static int getLocalNonConsumablePaymentStatus(android.content.Context context,
                                                     java.lang.String serviceId,
                                                     java.lang.String appSecret,
                                                     java.lang.String productName)
Similar to getLocalNonConsumablePaymentStatus(Context, String) but allows you to override the Fortumo service properties (service id, in-app secret).

Parameters:
context -
serviceId - The service id the payment was made from (overrides the default service id)
appSecret - The in-app secret of the service
productName - productName of the message as specified when calling 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.
Returns:
one of MESSAGE_STATUS_NOT_SENT, MESSAGE_STATUS_PENDING, MESSAGE_STATUS_BILLED, MESSAGE_STATUS_FAILED

isSupportedOperator

public static boolean isSupportedOperator(android.content.Context context)
Allows the application to query if user's carrier is supported by Fortumo and your service.
NB: This method might make a http request to Fortumo servers and can take considerable amount of time, avoid calling it in UI thread.

Parameters:
context -
Returns:
true if payments for this country-carrier combination are supported

isSupportedOperator

public static boolean isSupportedOperator(android.content.Context context,
                                          java.lang.String serviceId,
                                          java.lang.String appSecret)
Allows the application to query if user's carrier is supported by Fortumo. It is similar to isSupportedOperator(Context) but allows overriding the default serviceId and appSecret parameters.
NB: This method might make a http request to Fortumo servers and can take considerable amount of time, avoid calling it in UI thread.

Parameters:
context -
serviceId - A service id, will override the default one
appSecret - The in-app secret of the service
Returns:
true if payments for this country-carrier combination are supported

setLoggingEnabled

public static void setLoggingEnabled(boolean loggingEnabled)
Enables logging of errors.

Parameters:
loggingEnabled - true if error-logging should be enabled

setFlurryEnabled

@Deprecated
public static void setFlurryEnabled(boolean flurryEnabled)
Deprecated. 

Deprecated.This method has no effect.


enablePaymentBroadcast

public static void enablePaymentBroadcast(android.content.Context context,
                                          java.lang.String permission)
Enables the PAYMENT_STATUS_CHANGED broadcast. The PAYMENT_STATUS_CHANGED broadcast is disabled by default.
For example this broadcast will allow to get a notification when the actual payment process starts and payment status first changes to MESSAGE_STATUS_PENDING.
The broadcast will give similar information to a PaymentResponse object, the intent will contain extras with the following keys:
billing_status, credit_amount (virtual credit sales only), credit_name (virtual credit sales only), message_id, payment_code, price_amount, price_currency, product_name, service_id, user_id
NB: To listen for this broadcast you must declare and implement a broadcast receiver with the correct permission.

Parameters:
permission - String naming a permission that a receiver must hold in order to receive your broadcast. If null, no permission is required.

disablePaymentBroadcast

public static void disablePaymentBroadcast(android.content.Context context)
Disable PAYMENT_STATUS_CHANGED broadcast.

Parameters:
context -

isPaymentBroadcastEnabled

public static boolean isPaymentBroadcastEnabled(android.content.Context context)