java.lang.Objectcom.globalcharge.android.BillingManager
public class BillingManager
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 :
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 |
---|
public static final java.lang.String BILLING_LIBRARY_VERSION
Constructor Detail |
---|
public BillingManager(android.content.Context context, android.os.Handler handler)
context
- current Android contexthandler
- a handler on defined on your activity.Method Detail |
---|
public boolean beginPayment(long accountID, java.lang.String endUserId, java.lang.String clientAppVersion, boolean isOneStepBilling)
#onProductsReceived(List )
.
clientAppVersion
- The version of the developers applicationaccountID
- Account ID given to the client by GlobalChargeendUserId
- Unique identifier for the end user running the developer's
applicationisOneStepBilling
- 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.
public java.lang.String getTheRightTranslation(java.lang.String key)
public boolean purchaseProduct(com.globalcharge.android.products.Product product)
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.
product
- the product to purchase that was selected by the user.
public boolean sendAcknowledgementSuccess(java.lang.String clientTransactionId)
clientTransactionId
- a unique transaction ID generated by the developer's
application or server for the current payment.
public boolean sendAcknowledgementFailure(java.lang.String clientTransactionId, java.lang.String comment)
clientTransactionId
- a unique transaction ID generated by the developer's
application or server for the current payment.comment
- reason of failure.
public boolean sendAcknowledgementFailure(java.lang.String clientTransactionId)
clientTransactionId
- a unique transaction ID generated by the developer's
application or server for the current payment.
public void registerPaymentListener(PaymentListener notifier)
notifier
- public void setEnvironment(Environment environment)
- com.globalcharge.android.BillingManger.Environment.LOCAL
- com.globalcharge.android.BillingManger.Environment.TEST
- com.globalcharge.android.BillingManger.Enviroment.PRODUCTION
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). 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. 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.
mode
- public Environment getEnvironment()
public void onCancel(android.content.DialogInterface arg0)
onCancel
in interface android.content.DialogInterface.OnCancelListener
public void setTestNumber(java.lang.String testNumber)
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.