Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Approved and product.id #192

Closed
chrisschaub opened this issue May 18, 2015 · 28 comments
Closed

Approved and product.id #192

chrisschaub opened this issue May 18, 2015 · 28 comments

Comments

@chrisschaub
Copy link

So, it looks like when the product moves to APPROVED, the product id is no longer intact, it becomes 'application data' -- but from the doc, it seems that the info is stored in product.transaction.product_id ? But that field of transaction does not exist. The purchase is going through, it's a restore. One other question, should I just use a global "when" to catch updates and switch on status? Or should I use "once" since I'm selling NON_CONSUMABLE?

@butlimous
Copy link

What do you get when you log "product"? not product.transaction . In my case the product ID and everything is intact but the receipt is missing so I can't verify that authenticity of the purchase

@chrisschaub
Copy link
Author

My product is very funky -- all the data is wiped. The product id is
swapped for "application data". I'm trying to figure out if it's because
i'm using WHEN with NON_CONSUMABLE.

On Mon, May 18, 2015 at 6:13 PM, butlimous notifications@github.com wrote:

What do you get when you log "product"? not product.transaction . In my
case the product ID and everything is intact but the receipt is missing so
I can't verify that authenticity of the purchase


Reply to this email directly or view it on GitHub
#192 (comment)
.

Christopher Schaub
http://chris.schaub.com

@butlimous
Copy link

No I'm using "when" with nonconsumable and it's not a problem

@chrisschaub
Copy link
Author

Do you wait to call store.refresh() untill all products are registered?

On Mon, May 18, 2015 at 6:19 PM, butlimous notifications@github.com wrote:

No I'm using "when" with nonconsumable and it's not a problem


Reply to this email directly or view it on GitHub
#192 (comment)
.

Christopher Schaub
http://chris.schaub.com

@butlimous
Copy link

Yes the correct sequence is like this:

store.register({id: 'first', type: store.xxxx});
store.register({id: 'second', type: store.xxxx});
store.refresh();

store.when('first', 'updated', function(product) { });
store.when('second', 'updated', function(product) { });

This is the sequence I'm using and It works well.

@butlimous
Copy link

Are you sure you have setup the WHOLE environment in iOS correctly? It's more tricky than that of Android.

@chrisschaub
Copy link
Author

I think so. If I've registered products and have a store ready, should I
re-register and declare when's every time the page is drawn? It's an app,
so the store object is just around. Wondering if store.off on leaving the
view is a good idea since it's an angular / ionic app.

On Mon, May 18, 2015 at 7:12 PM, butlimous notifications@github.com wrote:

Are you sure you have setup the WHOLE environment in iOS correctly? It's
more tricky than that of Android.


Reply to this email directly or view it on GitHub
#192 (comment)
.

Christopher Schaub
http://chris.schaub.com

@butlimous
Copy link

Is the state of the product(s) valid or invalid?

@chrisschaub
Copy link
Author

Valid.

On Mon, May 18, 2015 at 8:19 PM, butlimous notifications@github.com wrote:

Is the state of the product(s) valid or invalid?


Reply to this email directly or view it on GitHub
#192 (comment)
.

Christopher Schaub
http://chris.schaub.com

@butlimous
Copy link

In this case I don't really know what's wrong...As long as the product is valid and the confirm purchase is showing the correct price, the approve state should also show the same info. May it's a bug in ionic as I use phonegap

@chrisschaub
Copy link
Author

Thanks, I got it working much better by messing with bundle ids. Is it
calling store.finish() that moves it from APPROVED back to VALID?

On Tue, May 19, 2015 at 5:48 AM, butlimous notifications@github.com wrote:

In this case I don't really know what's wrong...As long as the product is
valid and the confirm purchase is showing the correct price, the approve
state should also show the same info. May it's a bug in ionic as I use
phonegap


Reply to this email directly or view it on GitHub
#192 (comment)
.

Christopher Schaub
http://chris.schaub.com

@chrisschaub
Copy link
Author

sorry, calling product.finish()

On Tue, May 19, 2015 at 5:55 AM, Christopher Schaub chris@schaub.com
wrote:

Thanks, I got it working much better by messing with bundle ids. Is it
calling store.finish() that moves it from APPROVED back to VALID?

On Tue, May 19, 2015 at 5:48 AM, butlimous notifications@github.com
wrote:

In this case I don't really know what's wrong...As long as the product is
valid and the confirm purchase is showing the correct price, the approve
state should also show the same info. May it's a bug in ionic as I use
phonegap


Reply to this email directly or view it on GitHub
#192 (comment)
.

Christopher Schaub
http://chris.schaub.com

Christopher Schaub
http://chris.schaub.com

@chrisschaub
Copy link
Author

So maybe it's this. On Android, do I need to use MANAGED instead of
NON_CONSUMABLE for type?

On Tue, May 19, 2015 at 5:56 AM, Christopher Schaub chris@schaub.com
wrote:

sorry, calling product.finish()

On Tue, May 19, 2015 at 5:55 AM, Christopher Schaub chris@schaub.com
wrote:

Thanks, I got it working much better by messing with bundle ids. Is it
calling store.finish() that moves it from APPROVED back to VALID?

On Tue, May 19, 2015 at 5:48 AM, butlimous notifications@github.com
wrote:

In this case I don't really know what's wrong...As long as the product
is valid and the confirm purchase is showing the correct price, the approve
state should also show the same info. May it's a bug in ionic as I use
phonegap


Reply to this email directly or view it on GitHub
#192 (comment)
.

Christopher Schaub
http://chris.schaub.com

Christopher Schaub
http://chris.schaub.com

Christopher Schaub
http://chris.schaub.com

@butlimous
Copy link

No when creating a product in your Google Play developer account, always shows managed, whether It's consumable or not. Then in your code, write it as usual either CONSUMABLE or NON_CONSUMABLE

@chrisschaub
Copy link
Author

It's weird, iOS is working fine for the most part. But I can't get products in google to register as valid. I have the same bundle id's, BILLING_ID set during plugin install, store object because register works. But products just stay invalid on android. Is there anything special to registering android product I might be missing? My app is in "alpha" and the build is for release, not debug. I've also made sure the uploaded APK matches the one I'm testing with. Any suggestions are apprciated, and thanks for the previous help as well!

@butlimous
Copy link

Have you published the app? Remember that the app MUST be published to test the purchase. You can publish the alpha version so that It's not available to public

@chrisschaub
Copy link
Author

Ok, I've got the plugin working much more smoothly now with my app. But, on ios, sometimes after logging in, I get an approved product with a very strange product id, the id is "application data". And it's weird because the product is somehow registered, valid and then approved -- but I'm not passing any product with that id. So, this reply directly relates to my initial comment. Is it possible that the plugin is somethow adding a pseudo product via a bug into store.products?

@RouR
Copy link
Contributor

RouR commented Jun 13, 2015

How to publish publish the alpha version? I uploaded app, turn-on TestFligh, add tester acc, open in device app via TestFligh. I got:

{"id":"application data","alias":"application data","type":"non consumable","state":"approved","title":null,"description":null,"price":null,"currency":null,"loaded":true,"canPurchase":false,"owned":false,"transaction":{"type":"ios-appstore"},"valid":true}

I think follow is mistakes:

  • id="application data" (instead of my id),
  • price="null" (instead of setted tier6),
  • transaction={"type":"ios-appsore"} (where is receipt?)
  • type="non-consumable" (registered type is store.PAID_SUBSCRIPTION)

@MauriceButler
Copy link

Was there ever a resolution to the "application data" id issue?

I am having the same problem.

@gsfioravanti
Copy link

Is there any update to this issue? I'm also getting this.

@vinceoralim
Copy link

I'm experiencing the same issue.
Details:

  • in app v3.11.1
  • one app with only one product on iOS and Android
  • due to store specifics, my product type is différent : PAID_SUBSCRIPTION on iOS, CONSUMABLE on Android. This is the only difference in the code
  • in app purchase is globally working fine (app in production, daily purchases...)
  • occurs only on iOS (runs fine on Android)
  • first call to store.refresh() is OK
  • but each following call adds a product (id="application data"...) to the store.products array

This is not a big issue, I end up to prevent further .refresh() calls on iOS.

@alexdrel
Copy link

alexdrel commented Jan 7, 2016

+1
I am getting "application data" non consumable of second refresh.

@acoard
Copy link

acoard commented Jan 8, 2016

I'm also suffering from this problem. I believe it's because of this code:

var p = data.bundleIdentifier ? store.get(data.bundleIdentifier) : null;
if (!p) {
p = new store.Product({
id: data.bundleIdentifier || "application data",
alias: "application data",
type: store.NON_CONSUMABLE
});
store.register(p);
}

Here's the relevant bit:

if (data) {
    var p = data.bundleIdentifier ? store.get(data.bundleIdentifier) : null;
    if (!p) {
        p = new store.Product({
            id: data.bundleIdentifier || "application data",
            alias: "application data",
            type: store.NON_CONSUMABLE
        });
        store.register(p);
    }
    p.version = data.bundleShortVersion;
    p.transaction = {
        type: "ios-appstore",
        appStoreReceipt: data.appStoreReceipt,
        signature: data.signature
    };
    p.trigger("loaded");
    p.set("state", store.APPROVED);
}

Basically it says, 'if we can't get the bundleIdentifier' (presumably the IAP's name), then create a new one with "application data" as the id, and then register it.

This callback is in the storekit re-refresh event, which is called everytime that refresh() is called. So, that explains why it's adding a new one each time.

edit: In case anyone is wondering, at this time data is a string around ~6,000 characters long. I believe it's base64 encoded, but I'm not positive.

@milhad
Copy link

milhad commented Feb 16, 2016

I'm having the same issue. On the first run, everything runs OK, but on subsequent runs a lot of "fake" products with id "application data" are getting generated and being pushed into the purchase flow because their state is forced to "approved".
This is causing the validator to run, posting the imaginary transaction to my API for validation, which obviously fails.

I will try to circumvent this by checking for "fake" ids in "approved" event handler, but it is still unknown to me as why it happens in the first place.

@acoard
Copy link

acoard commented Feb 16, 2016

@milhad I just wanted to help point you in the right direction

I will try to circumvent this by checking for "fake" ids in "approved" event handler, but it is still unknown to me as why it happens in the first place.

I tried this, but wound up having lots of trouble.

Instead what worked for me was writing my event handlers like so:

store.when(SINGLE_REPORT).approved(handleSingleReportApproved);

Essentially, always use store.when("INDIVIDUAL_PRODUCT"). Do NOT get all products. You'll just have to filter them and wind up with headaches. At least that's what happened in my case.

Best of luck!

@isayeter
Copy link

any update ? the same issue here. why plugin registering a new item as @acoard wrote ?

@j3k0 j3k0 added the Backlog label May 26, 2016
@xgat
Copy link

xgat commented Apr 29, 2017

Hi,
it seems the workaround from @acoard is working for me: for each product register callbacks with store.when(<single product id>), do not register callbacks with store.when("product").

@stale
Copy link

stale bot commented May 11, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label May 11, 2018
@stale stale bot closed this as completed Jun 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests