Skip to content

Commit ca3eef0

Browse files
author
dessant
committed
remove deprecated billing implementation
1 parent 19d6778 commit ca3eef0

31 files changed

+0
-3454
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ Relating to SDL2 only:
7979
- App loading screen
8080
- Public dir installation
8181
- Keyboard height getter
82-
- Billing support
8382
- Kivy Launcher build (can now be implemented as a bootstrap...maybe?)
8483
- Several build options for build.py
8584
- Probably some other stuff

doc/source/old_toolchain/android.rst

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -80,73 +80,6 @@ Example::
8080
# ...
8181

8282

83-
Billing (``android.billing``)
84-
-----------------------------
85-
86-
.. module:: android.billing
87-
88-
This billing module gives an access to the `In-App Billing <http://developer.android.com/guide/google/play/billing/billing_overview.html>`_:
89-
90-
#. `Setup a test account <http://developer.android.com/guide/google/play/billing/billing_admin.html#billing-testing-setup>`_, and get your Public Key
91-
#. Export your public key::
92-
93-
export BILLING_PUBKEY="Your public key here"
94-
95-
#. `Setup some In-App product <http://developer.android.com/guide/google/play/billing/billing_admin.html>`_ to buy. Let's say you've created a product with the id "org.kivy.gopremium"
96-
97-
#. In your application, you can use the ``billing`` module like this::
98-
99-
100-
from android.billing import BillingService
101-
from kivy.clock import Clock
102-
103-
class MyBillingService(object):
104-
105-
def __init__(self):
106-
super(MyBillingService, self).__init__()
107-
108-
# Start the billing service, and attach our callback
109-
self.service = BillingService(billing_callback)
110-
111-
# Start a clock to check billing service message every second
112-
Clock.schedule_interval(self.service.check, 1)
113-
114-
def billing_callback(self, action, *largs):
115-
'''Callback that will receive all the events from the Billing service
116-
'''
117-
if action == BillingService.BILLING_ACTION_ITEMSCHANGED:
118-
items = largs[0]
119-
if 'org.kivy.gopremium' in items:
120-
print "Congratulations, you have a premium acess"
121-
else:
122-
print "Unfortunately, you don't have premium access"
123-
124-
def buy(self, sku):
125-
# Method to buy something.
126-
self.service.buy(sku)
127-
128-
def get_purchased_items(self):
129-
# Return all the items purchased
130-
return self.service.get_purchased_items()
131-
132-
#. To initiate an in-app purchase, just call the ``buy()`` method::
133-
134-
# Note: start the service at the start, and never twice!
135-
bs = MyBillingService()
136-
bs.buy('org.kivy.gopremium')
137-
138-
# Later, when you get the notification that items have been changed, you
139-
# can still check all the items you bought:
140-
print bs.get_purchased_items()
141-
{'org.kivy.gopremium': {'qt: 1}}
142-
143-
#. You'll receive all the notifications about the billing process in the callback.
144-
145-
#. Last step, create your application with ``--with-billing $BILLING_PUBKEY``::
146-
147-
./build.py ... --with-billing $BILLING_PUBKEY
148-
149-
15083
Broadcast (``android.broadcast``)
15184
---------------------------------
15285

@@ -366,4 +299,3 @@ Application service part example, ``service/main.py``:
366299
# this will print 'Hello From Service' continually, even when the application is switched
367300
print arg
368301
time.sleep(1)
369-

pythonforandroid/bootstraps/pygame/build/build.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,6 @@ def parse_args(args=None):
432432
'filename containing xml. The filename should be '
433433
'located relative to the python-for-android '
434434
'directory'))
435-
ap.add_argument('--with-billing', dest='billing_pubkey',
436-
help='If set, the billing service will be added')
437435
ap.add_argument('--blacklist', dest='blacklist',
438436
default=join(curdir, 'blacklist.txt'),
439437
help=('Use a blacklist file to match unwanted file in '

pythonforandroid/bootstraps/pygame/build/src/com/android/vending/billing/IMarketBillingService.aidl

Lines changed: 0 additions & 24 deletions
This file was deleted.

pythonforandroid/bootstraps/pygame/build/src/org/renpy/android/PythonActivity.java

Lines changed: 0 additions & 207 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,6 @@
2222
import java.util.Collections;
2323
import java.util.Iterator;
2424

25-
// Billing
26-
import org.renpy.android.Configuration;
27-
import org.renpy.android.billing.BillingService.RequestPurchase;
28-
import org.renpy.android.billing.BillingService.RestoreTransactions;
29-
import org.renpy.android.billing.Consts.PurchaseState;
30-
import org.renpy.android.billing.Consts.ResponseCode;
31-
import org.renpy.android.billing.PurchaseObserver;
32-
import org.renpy.android.billing.BillingService;
33-
import org.renpy.android.billing.PurchaseDatabase;
34-
import org.renpy.android.billing.Consts;
35-
import org.renpy.android.billing.ResponseHandler;
36-
import org.renpy.android.billing.Security;
3725
import android.os.Handler;
3826
import android.database.Cursor;
3927
import java.util.List;
@@ -133,10 +121,6 @@ protected void onCreate(Bundle savedInstanceState) {
133121
} catch (PackageManager.NameNotFoundException e) {
134122
}
135123

136-
if ( Configuration.use_billing ) {
137-
mBillingHandler = new Handler();
138-
}
139-
140124
// Start showing an SDLSurfaceView.
141125
mView = new SDLSurfaceView(
142126
this,
@@ -333,8 +317,6 @@ public boolean onKeyUp(int keyCode, final KeyEvent event) {
333317
}
334318

335319
protected void onDestroy() {
336-
mPurchaseDatabase.close();
337-
mBillingService.unbind();
338320

339321
if (mView != null) {
340322
mView.onDestroy();
@@ -435,193 +417,4 @@ protected void onActivityResult(int requestCode, int resultCode, Intent intent)
435417
}
436418
}
437419

438-
//----------------------------------------------------------------------------
439-
// Billing
440-
//
441-
class PythonPurchaseObserver extends PurchaseObserver {
442-
public PythonPurchaseObserver(Handler handler) {
443-
super(PythonActivity.this, handler);
444-
}
445-
446-
@Override
447-
public void onBillingSupported(boolean supported, String type) {
448-
if (Consts.DEBUG) {
449-
Log.i(TAG, "supported: " + supported);
450-
}
451-
452-
String sup = "1";
453-
if ( !supported )
454-
sup = "0";
455-
if (type == null)
456-
type = Consts.ITEM_TYPE_INAPP;
457-
458-
// add notification for python message queue
459-
mActivity.mBillingQueue.add("billingSupported|" + type + "|" + sup);
460-
461-
// for managed items, restore the database
462-
if ( type == Consts.ITEM_TYPE_INAPP && supported ) {
463-
restoreDatabase();
464-
}
465-
}
466-
467-
@Override
468-
public void onPurchaseStateChange(PurchaseState purchaseState, String itemId,
469-
int quantity, long purchaseTime, String developerPayload) {
470-
mActivity.mBillingQueue.add(
471-
"purchaseStateChange|" + itemId + "|" + purchaseState.toString());
472-
}
473-
474-
@Override
475-
public void onRequestPurchaseResponse(RequestPurchase request,
476-
ResponseCode responseCode) {
477-
mActivity.mBillingQueue.add(
478-
"requestPurchaseResponse|" + request.mProductId + "|" + responseCode.toString());
479-
}
480-
481-
@Override
482-
public void onRestoreTransactionsResponse(RestoreTransactions request,
483-
ResponseCode responseCode) {
484-
if (responseCode == ResponseCode.RESULT_OK) {
485-
mActivity.mBillingQueue.add("restoreTransaction|ok");
486-
if (Consts.DEBUG) {
487-
Log.d(TAG, "completed RestoreTransactions request");
488-
}
489-
// Update the shared preferences so that we don't perform
490-
// a RestoreTransactions again.
491-
SharedPreferences prefs = getPreferences(Context.MODE_PRIVATE);
492-
SharedPreferences.Editor edit = prefs.edit();
493-
edit.putBoolean(DB_INITIALIZED, true);
494-
edit.commit();
495-
} else {
496-
if (Consts.DEBUG) {
497-
Log.d(TAG, "RestoreTransactions error: " + responseCode);
498-
}
499-
500-
mActivity.mBillingQueue.add(
501-
"restoreTransaction|error|" + responseCode.toString());
502-
}
503-
}
504-
}
505-
506-
/**
507-
* If the database has not been initialized, we send a
508-
* RESTORE_TRANSACTIONS request to Android Market to get the list of purchased items
509-
* for this user. This happens if the application has just been installed
510-
* or the user wiped data. We do not want to do this on every startup, rather, we want to do
511-
* only when the database needs to be initialized.
512-
*/
513-
private void restoreDatabase() {
514-
SharedPreferences prefs = getPreferences(MODE_PRIVATE);
515-
boolean initialized = prefs.getBoolean(DB_INITIALIZED, false);
516-
if (!initialized) {
517-
mBillingService.restoreTransactions();
518-
}
519-
}
520-
521-
/** An array of product list entries for the products that can be purchased. */
522-
523-
private enum Managed { MANAGED, UNMANAGED, SUBSCRIPTION }
524-
525-
526-
private PythonPurchaseObserver mPythonPurchaseObserver;
527-
private Handler mBillingHandler;
528-
private BillingService mBillingService;
529-
private PurchaseDatabase mPurchaseDatabase;
530-
private String mPayloadContents;
531-
public List<String> mBillingQueue;
532-
533-
public void billingServiceStart_() {
534-
mBillingQueue = new ArrayList<String>();
535-
536-
// Start the billing part
537-
mPythonPurchaseObserver = new PythonPurchaseObserver(mBillingHandler);
538-
mBillingService = new BillingService();
539-
mBillingService.setContext(this);
540-
mPurchaseDatabase = new PurchaseDatabase(this);
541-
542-
ResponseHandler.register(mPythonPurchaseObserver);
543-
if (!mBillingService.checkBillingSupported()) {
544-
//showDialog(DIALOG_CANNOT_CONNECT_ID);
545-
Log.w(TAG, "NO BILLING SUPPORTED");
546-
}
547-
if (!mBillingService.checkBillingSupported(Consts.ITEM_TYPE_SUBSCRIPTION)) {
548-
//showDialog(DIALOG_SUBSCRIPTIONS_NOT_SUPPORTED_ID);
549-
Log.w(TAG, "NO SUBSCRIPTION SUPPORTED");
550-
}
551-
}
552-
553-
public void billingServiceStop_() {
554-
}
555-
556-
public void billingBuy_(String mSku) {
557-
Managed mManagedType = Managed.MANAGED;
558-
if (Consts.DEBUG) {
559-
Log.d(TAG, "buying sku: " + mSku);
560-
}
561-
562-
if (mManagedType == Managed.MANAGED) {
563-
if (!mBillingService.requestPurchase(mSku, Consts.ITEM_TYPE_INAPP, mPayloadContents)) {
564-
Log.w(TAG, "ERROR IN BILLING REQUEST PURCHASE");
565-
}
566-
} else if (mManagedType == Managed.SUBSCRIPTION) {
567-
if (!mBillingService.requestPurchase(mSku, Consts.ITEM_TYPE_INAPP, mPayloadContents)) {
568-
Log.w(TAG, "ERROR IN BILLING REQUEST PURCHASE");
569-
}
570-
}
571-
}
572-
573-
public String billingGetPurchasedItems_() {
574-
String ownedItems = "";
575-
Cursor cursor = mPurchaseDatabase.queryAllPurchasedItems();
576-
if (cursor == null)
577-
return "";
578-
579-
try {
580-
int productIdCol = cursor.getColumnIndexOrThrow(
581-
PurchaseDatabase.PURCHASED_PRODUCT_ID_COL);
582-
int qtCol = cursor.getColumnIndexOrThrow(
583-
PurchaseDatabase.PURCHASED_QUANTITY_COL);
584-
while (cursor.moveToNext()) {
585-
String productId = cursor.getString(productIdCol);
586-
String qt = cursor.getString(qtCol);
587-
588-
productId = Security.unobfuscate(this, Configuration.billing_salt, productId);
589-
if ( productId == null )
590-
continue;
591-
592-
if ( ownedItems != "" )
593-
ownedItems += "\n";
594-
ownedItems += productId + "," + qt;
595-
}
596-
} finally {
597-
cursor.close();
598-
}
599-
600-
return ownedItems;
601-
}
602-
603-
604-
static void billingServiceStart() {
605-
mActivity.billingServiceStart_();
606-
}
607-
608-
static void billingServiceStop() {
609-
mActivity.billingServiceStop_();
610-
}
611-
612-
static void billingBuy(String sku) {
613-
mActivity.billingBuy_(sku);
614-
}
615-
616-
static String billingGetPurchasedItems() {
617-
return mActivity.billingGetPurchasedItems_();
618-
}
619-
620-
static String billingGetPendingMessage() {
621-
if (mActivity.mBillingQueue.isEmpty())
622-
return null;
623-
return mActivity.mBillingQueue.remove(0);
624-
}
625-
626420
}
627-

0 commit comments

Comments
 (0)