com.globalcharge.android
Class BillingManager

java.lang.Object
  extended by com.globalcharge.android.BillingManager
All Implemented Interfaces:
android.content.DialogInterface.OnCancelListener

public class BillingManager
extends java.lang.Object
implements android.content.DialogInterface.OnCancelListener

BillingManager is a payment manager class for Subscriptions as well as One-Off payments. All the methods on this class will allow your application to SEND requests to GAL (to receive the response of those requests please see PaymentListener Interface). With this class you can :

Author:
Ahmed Dini

Field Summary
static java.lang.String BILLING_LIBRARY_VERSION
          GlobalCharge's Android Billing LIbrary version
 
Constructor Summary
BillingManager(android.content.Context context, android.os.Handler handler)
          creates new BillingManager
 
Method Summary
 boolean beginPayment(long accountID, java.lang.String endUserId, java.lang.String clientAppVersion, boolean isOneStepBilling)
          Initiates a billing request.
 Environment getEnvironment()
          Gets the current environment MODE for the current payment session.
 java.lang.String getTheRightTranslation(java.lang.String key)
           
 void onCancel(android.content.DialogInterface arg0)
           
 boolean purchaseProduct(com.globalcharge.android.products.Product product)
          Use this method only if you don't want GAL to display the product selection screen and instead you prefer displaying your own version of the product selection screen.
 void registerPaymentListener(PaymentListener notifier)
          Register a notifier to receive updates regarding a payments progress.
 boolean sendAcknowledgementFailure(java.lang.String clientTransactionId)
          If the developer's application is unable to credit/topup user's account after the user has successfully been billed.
 boolean sendAcknowledgementFailure(java.lang.String clientTransactionId, java.lang.String comment)
          If the developer's application is unable to credit/topup user's account after the user has successfully been billed.
 boolean sendAcknowledgementSuccess(java.lang.String clientTransactionId)
          If the developer's application is able to credit/topup user's account after the user has successfully been billed.
 void setEnvironment(Environment environment)
          Enables or disables Local Sandboxing and Server-side Sandboxing (default Environment.PRODUCTION).
 void setTestNumber(java.lang.String testNumber)
          Allows developers to fake server text messages while developing on Environment.LOCAL mode.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BILLING_LIBRARY_VERSION

public static final java.lang.String BILLING_LIBRARY_VERSION
GlobalCharge's Android Billing LIbrary version

See Also:
Constant Field Values
Constructor Detail

BillingManager

public BillingManager(android.content.Context context,
                      android.os.Handler handler)
creates new BillingManager

Parameters:
context - current Android context
handler - a handler on defined on your activity.
Method Detail

beginPayment

public boolean beginPayment(long accountID,
                            java.lang.String endUserId,
                            java.lang.String clientAppVersion,
                            boolean isOneStepBilling)
Initiates a billing request. This starts a fresh transaction. After GAL receives this request, it finds out the country of the user, and returns the appropriate products (prices) available for the user. The GAL will notify the result to the calling Application through this callback method #onProductsReceived(List ).

Parameters:
clientAppVersion - The version of the developers application
accountID - Account ID given to the client by GlobalCharge
endUserId - Unique identifier for the end user running the developer's application
isOneStepBilling - flag if you like to use ONE STEP BILLING or TWO STEP BILLING. Set true for ONE STEP BILLING so that GAL has a full control of product selection. Note you don't have to call purchaseProduct(Product) method. set false for TWO STEP BILLING so that your application displays the product selection screen and you later call the purchaseProduct(Product) method after the user selects the product.
Returns:
true if GAL accepts your request

getTheRightTranslation

public java.lang.String getTheRightTranslation(java.lang.String key)

purchaseProduct

public boolean purchaseProduct(com.globalcharge.android.products.Product product)
Use this method only if you don't want GAL to display the product selection screen and instead you prefer displaying your own version of the product selection screen. A call to this method follows after a successful call to beginPayment(long, String ,String , boolean) returns a list of products. Please make sure you only pass this method (purchaseProduct(Product product))a product that exists in the list of products returned to you.

Parameters:
product - the product to purchase that was selected by the user.
Returns:
true if GAL accepts your request.

sendAcknowledgementSuccess

public boolean sendAcknowledgementSuccess(java.lang.String clientTransactionId)
If the developer's application is able to credit/topup user's account after the user has successfully been billed. To help GlobalCharge resolve any customer service issues, the developer's application can register with GlobalCharge server by calling this method with a clientTranssactionId.

Parameters:
clientTransactionId - a unique transaction ID generated by the developer's application or server for the current payment.
Returns:
true if request has successfully been sent to GlobalCharge servers.

sendAcknowledgementFailure

public boolean sendAcknowledgementFailure(java.lang.String clientTransactionId,
                                          java.lang.String comment)
If the developer's application is unable to credit/topup user's account after the user has successfully been billed. To help GlobalCharge resolve any customer service issues, the developer's application can register with GlobalCharge server by calling this method with a clientTranssactionId.

Parameters:
clientTransactionId - a unique transaction ID generated by the developer's application or server for the current payment.
comment - reason of failure.
Returns:
true if request has successfully been sent to GlobalCharge servers.

sendAcknowledgementFailure

public boolean sendAcknowledgementFailure(java.lang.String clientTransactionId)
If the developer's application is unable to credit/topup user's account after the user has successfully been billed. To help GlobalCharge resolve any customer service issues, the developer's application can register with GlobalCharge server by calling this method with a clientTranssactionId.

Parameters:
clientTransactionId - a unique transaction ID generated by the developer's application or server for the current payment.
Returns:
true if request has successfully been sent to GlobalCharge servers.

registerPaymentListener

public void registerPaymentListener(PaymentListener notifier)
Register a notifier to receive updates regarding a payments progress. This method allows you to register your activity so that it can receive callbacks.

Parameters:
notifier -

setEnvironment

public void setEnvironment(Environment environment)
Enables or disables Local Sandboxing and Server-side Sandboxing (default Environment.PRODUCTION). GAL supports three types of Environment MODEs, available Environment modes are:-
  1. com.globalcharge.android.BillingManger.Environment.LOCAL
  2. com.globalcharge.android.BillingManger.Environment.TEST
  3. com.globalcharge.android.BillingManger.Enviroment.PRODUCTION

  1. Environment.LOCAL allows developers to test the integration without connecting to GlobalCharge's billing servers. It retrieves products and account configuration information from a sandbox server embedded into the GlobalCharge Android Library (GAL).
  2. Environment.TEST allows developers to test the integration with GlobalCharges Test server which is a clone of the Production server. To test your integration on the Test Platform, you will need a unique account details and products setup.
  3. Enviroment.PRODUCTION allows developers to connect to the production platform. This is the default behaviour if the Environment MODE is not set. Again when using this mode you you will need prior Account and Product setup for your application.

Parameters:
mode -

getEnvironment

public Environment getEnvironment()
Gets the current environment MODE for the current payment session.


onCancel

public void onCancel(android.content.DialogInterface arg0)
Specified by:
onCancel in interface android.content.DialogInterface.OnCancelListener

setTestNumber

public void setTestNumber(java.lang.String testNumber)
Allows developers to fake server text messages while developing on Environment.LOCAL mode. When in Environment.LOCAL mode, There is no server to process the SMS sent from the handset. So, this method allows you to specify a test number or (another local emulator number) that receives the SMS and replies to it (This will only work on products setup as Premuim SMS, for Direct Billing Products no SMS messaging is required). For a real mobile number add a full country code to the number and prefix it with a plus sign. You can send/receive the text on the same handset on which the app is installed. This Example shows how to set a UK number billingManager.setTestNumber("+447947755628"); For emulator use the first 4 digits in the title bar of your emulator. To test this with emulators you will need two instances of emulators running on the same computer. This Example shows how to set an emulator number billingManager.setTestNumber("5558"); Please remember to disable this once your application is fully integrated and ready for production use.