Telerik-Verified-Plugins / InAppPurchase

In-App Purchase for PhoneGap / Cordova iOS and Android
8 stars 3 forks source link

InAppPurchase Consumables Not Available #9

Open fiodhrid opened 8 years ago

fiodhrid commented 8 years ago

I have a working alpha version Android Cordova app using Telerik plugin, InAppPurchase. I was able to do a test purchase for each of my CONSUMABLE products one time. Now all products return "Not Available" in my test account although their status is "VALID". I have revised the apk, and verified the name and version. The current plugin doesn't seem to set the product to "consumed" so that the product is again "valid" and "available".

Can someone please explain how to reset the products so that the CONSUMABLE products are again available for repurchase?

Thanks ptaffet@sohosoft.us

fiodhrid commented 8 years ago

This code invokes the plugin. As I indicated each product successfully purchased once. "Not available" message is received since the one purchase.

`var IAP = {};

// // Constructor // ----------- //

IAP.initialize = function () { log('initialize');

// Listen to the deviceready event.
// Make sure the score of 'this' isn't lost.
document.addEventListener('deviceready', this.bind(this.onDeviceReady), false);

};

// // Methods // ------- //

// deviceready event handler. // // will just initialize the Purchase plugin IAP.onDeviceReady = function() { log('onDeviceReady'); this.initStore(); };

// initialize the purchase plugin if available IAP.initStore = function() {

if (!window.store) {
    log('Store not available');
    return;
}

IAP.platform = device.platform.toLowerCase();
document.getElementsByTagName('body')[0].className = IAP.platform;

// Enable maximum logging level
store.verbosity = store.DEBUG;

// Inform the store of your products
log('registerProducts');
store.register({
    id: 'hint_tokens_250_99',
    alias: '250 Hint Tokens',
    type: store.CONSUMABLE
});

// alert("registered 250 tokes");

store.register({
    id: 'hint_tokens_1000_199',
    alias: '1000 Hint Tokens',
    type: store.CONSUMABLE
});

// alert("registered 1000 tokes");

store.register({
    id: 'hint_tokens_2500_299',
    alias: '2500 Hint Tokens',
    type: store.CONSUMABLE
});

// alert("registered 2500 tokes");

// When any product gets updated, refresh the HTML.
store.when("product").updated(function (p) {
    IAP.renderIAP(p);
});
// When purchase of hint tokens is approved, show an alert
store.when("hint_tokens_250_99").approved(function (order) {
    alert("You got an additional 250 hint tokens!");
    SaveHintCount(250);
    order.finish();
});
store.when("hint_tokens_1000_199").approved(function (order) {
    alert("You got an additional 1000 hint tokens!");
    SaveHintCount(1000);
    order.finish();
});
store.when("hint_tokens_2500_299").approved(function (order) {
    alert("You got an additional 2500 hint tokens!");
    SaveHintCount(2500);
    order.finish();
});

// Log all errors
store.error(function(error) {
    log('ERROR ' + error.code + ': ' + error.message);
});

// Refresh the store.
//
// This will contact the server to check all registered products
// validity and ownership status.
//
// It's fine to do this only at IAPlication startup, as it could be
// pretty expensive.
log('refresh');
store.refresh();

};

IAP.renderIAP = function(p) { if (!p.valid) { $('#' + p.id).off(); } }; `